8 #define NEWT_COLORSET_ROOT 2
9 #define NEWT_COLORSET_BORDER 3
10 #define NEWT_COLORSET_WINDOW 4
11 #define NEWT_COLORSET_SHADOW 5
12 #define NEWT_COLORSET_TITLE 6
13 #define NEWT_COLORSET_BUTTON 7
14 #define NEWT_COLORSET_ACTBUTTON 8
15 #define NEWT_COLORSET_CHECKBOX 9
16 #define NEWT_COLORSET_ACTCHECKBOX 10
17 #define NEWT_COLORSET_ENTRY 11
18 #define NEWT_COLORSET_LABEL 12
19 #define NEWT_COLORSET_LISTBOX 13
20 #define NEWT_COLORSET_ACTLISTBOX 14
21 #define NEWT_COLORSET_TEXTBOX 15
22 #define NEWT_COLORSET_ACTTEXTBOX 16
23 #define NEWT_COLORSET_HELPLINE 17
24 #define NEWT_COLORSET_ROOTTEXT 18
25 #define NEWT_COLORSET_EMPTYSCALE 19
26 #define NEWT_COLORSET_FULLSCALE 20
27 #define NEWT_COLORSET_DISENTRY 21
28 #define NEWT_COLORSET_COMPACTBUTTON 22
29 #define NEWT_COLORSET_ACTSELLISTBOX 23
30 #define NEWT_COLORSET_SELLISTBOX 24
33 char * rootFg
, * rootBg
;
34 char * borderFg
, * borderBg
;
35 char * windowFg
, * windowBg
;
36 char * shadowFg
, * shadowBg
;
37 char * titleFg
, * titleBg
;
38 char * buttonFg
, * buttonBg
;
39 char * actButtonFg
, * actButtonBg
;
40 char * checkboxFg
, * checkboxBg
;
41 char * actCheckboxFg
, * actCheckboxBg
;
42 char * entryFg
, * entryBg
;
43 char * labelFg
, * labelBg
;
44 char * listboxFg
, * listboxBg
;
45 char * actListboxFg
, * actListboxBg
;
46 char * textboxFg
, * textboxBg
;
47 char * actTextboxFg
, * actTextboxBg
;
48 char * helpLineFg
, * helpLineBg
;
49 char * rootTextFg
, * rootTextBg
;
50 char * emptyScale
, * fullScale
;
51 char * disabledEntryFg
, * disabledEntryBg
;
52 char * compactButtonFg
, * compactButtonBg
;
53 char * actSelListboxFg
, * actSelListboxBg
;
54 char * selListboxFg
, * selListboxBg
;
57 enum newtFlagsSense
{ NEWT_FLAGS_SET
, NEWT_FLAGS_RESET
, NEWT_FLAGS_TOGGLE
};
59 #define NEWT_FLAG_RETURNEXIT (1 << 0)
60 #define NEWT_FLAG_HIDDEN (1 << 1)
61 #define NEWT_FLAG_SCROLL (1 << 2)
62 #define NEWT_FLAG_DISABLED (1 << 3)
63 #define NEWT_FLAG_NOSCROLL (1 << 4) /* for listboxes */
64 #define NEWT_FLAG_DOBORDER (1 << 5)
65 #define NEWT_FLAG_WRAP (1 << 6)
66 #define NEWT_FLAG_NOF12 (1 << 7)
67 #define NEWT_FLAG_MULTIPLE (1 << 8)
68 #define NEWT_FLAG_SELECTED (1 << 9)
70 /* Backwards compatibility */
71 #define NEWT_LISTBOX_RETURNEXIT NEWT_FLAG_RETURNEXIT
72 #define NEWT_ENTRY_SCROLL NEWT_FLAG_SCROLL
73 #define NEWT_ENTRY_HIDDEN NEWT_FLAG_HIDDEN
74 #define NEWT_ENTRY_RETURNEXIT NEWT_FLAG_RETURNEXIT
75 #define NEWT_ENTRY_DISABLED NEWT_FLAG_DISABLED
77 #define NEWT_TEXTBOX_WRAP NEWT_FLAG_WRAP
78 #define NEWT_TEXTBOX_SCROLL NEWT_FLAG_SCROLL
79 #define NEWT_FORM_NOF12 NEWT_FLAG_NOF12
81 typedef struct newtComponent_struct
* newtComponent
;
83 extern struct newtColors newtDefaultColorPalette
;
85 typedef void (*newtCallback
)(newtComponent
, void *);
86 typedef void (*newtSuspendCallback
)(void);
89 int newtFinished(void);
91 void newtWaitForKey(void);
92 void newtClearKeyBuffer(void);
93 void newtDelay(int usecs
);
94 /* top, left are *not* counting the border */
95 int newtOpenWindow(int left
, int top
, int width
, int height
,
97 int newtCenteredWindow(int width
, int height
, const char * title
);
98 void newtPopWindow(void);
99 void newtSetColors(struct newtColors colors
);
100 void newtRefresh(void);
101 void newtSuspend(void);
102 void newtSetSuspendCallback(newtSuspendCallback cb
);
103 void newtResume(void);
104 void newtPushHelpLine(const char * text
);
105 void newtRedrawHelpLine(void);
106 void newtPopHelpLine(void);
107 void newtDrawRootText(int row
, int col
, const char * text
);
112 newtComponent
newtCompactButton(int left
, int top
, const char * text
);
113 newtComponent
newtButton(int left
, int top
, const char * text
);
114 newtComponent
newtCheckbox(int left
, int top
, const char * text
, char defValue
,
115 const char * seq
, char * result
);
116 newtComponent
newtRadiobutton(int left
, int top
, const char * text
, int isDefault
,
117 newtComponent prevButton
);
118 newtComponent
newtRadioGetCurrent(newtComponent setMember
);
119 newtComponent
newtListitem(int left
, int top
, const char * text
, int isDefault
,
120 newtComponent prevItem
, const void * data
, int flags
);
121 void newtListitemSet(newtComponent co
, const char * text
);
122 void * newtListitemGetData(newtComponent co
);
124 newtComponent
newtLabel(int left
, int top
, const char * text
);
125 void newtLabelSetText(newtComponent co
, const char * text
);
126 newtComponent
newtVerticalScrollbar(int left
, int top
, int height
,
127 int normalColorset
, int thumbColorset
);
128 void newtScrollbarSet(newtComponent co
, int where
, int total
);
130 newtComponent
newtListbox(int left
, int top
, int height
, int flags
);
131 void * newtListboxGetCurrent(newtComponent co
);
132 void newtListboxSetCurrent(newtComponent co
, int num
);
133 void newtListboxSetText(newtComponent co
, int num
, const char * text
);
134 void newtListboxSetEntry(newtComponent co
, int num
, const char * text
);
135 void newtListboxSetWidth(newtComponent co
, int width
);
136 /* return the data passed to AddEntry */
137 void newtListboxSetData(newtComponent co
, int num
, void * data
);
138 int newtListboxAddEntry(newtComponent co
, const char * text
, const void * data
);
139 int newtListboxInsertEntry(newtComponent co
, const char * text
, const void * data
, int num
);
140 int newtListboxDeleteEntry(newtComponent co
, int num
);
141 void newtListboxClear(newtComponent co
); /* removes all entries from listbox */
142 void newtListboxGetEntry(newtComponent co
, int num
, char **text
, void **data
);
143 /* Returns an array of data pointers from items, last element is NULL */
144 void **newtListboxGetSelection(newtComponent co
, int *numitems
);
145 void newtListboxClearSelection(newtComponent co
);
146 void newtListboxSelectItem(newtComponent co
, int item
,
147 enum newtFlagsSense sense
);
150 newtComponent
newtTextbox(int left
, int top
, int with
, int height
, int flags
);
151 void newtTextboxSetText(newtComponent co
, const char * text
);
152 void newtTextboxSetHeight(newtComponent co
, int height
);
153 int newtTextboxGetNumLines(newtComponent co
);
155 struct newtExitStruct
{
156 enum { NEWT_EXIT_HOTKEY
, NEWT_EXIT_COMPONENT
} reason
;
163 newtComponent
newtForm(newtComponent vertBar
, const char * help
, int flags
);
164 newtComponent
newtFormGetCurrent(newtComponent co
);
165 void newtFormSetBackground(newtComponent co
, int color
);
166 void newtFormSetCurrent(newtComponent co
, newtComponent subco
);
167 void newtFormAddComponent(newtComponent form
, newtComponent co
);
168 void newtFormAddComponents(newtComponent form
, ...);
169 void newtFormSetHeight(newtComponent co
, int height
);
170 void newtFormSetWidth(newtComponent co
, int width
);
171 newtComponent
newtRunForm(newtComponent form
); /* obsolete */
172 void newtFormRun(newtComponent co
, struct newtExitStruct
* es
);
173 void newtDrawForm(newtComponent form
);
174 void newtFormAddHotKey(newtComponent co
, int key
);
176 newtComponent
newtEntry(int left
, int top
, const char * initialValue
, int width
,
177 char ** resultPtr
, int flags
);
178 void newtEntrySet(newtComponent co
, const char * value
, int cursorAtEnd
);
179 void newtEntrySetFlags(newtComponent co
, int flags
, enum newtFlagsSense sense
);
181 newtComponent
newtScale(int left
, int top
, int width
, long long fullValue
);
182 void newtScaleSet(newtComponent co
, unsigned long long amount
);
184 void newtComponentAddCallback(newtComponent co
, newtCallback f
, void * data
);
185 void newtComponentTakesFocus(newtComponent co
, int val
);
187 /* this also destroys all of the components (including other forms) on the
189 void newtFormDestroy(newtComponent form
);
193 #define NEWT_KEY_TAB '\t'
194 #define NEWT_KEY_ENTER '\r'
195 #define NEWT_KEY_SUSPEND '\032' /* ctrl - z*/
196 #define NEWT_KEY_RETURN NEWT_KEY_ENTER
198 #define NEWT_KEY_EXTRA_BASE 0x8000
199 #define NEWT_KEY_UP NEWT_KEY_EXTRA_BASE + 1
200 #define NEWT_KEY_DOWN NEWT_KEY_EXTRA_BASE + 2
201 #define NEWT_KEY_LEFT NEWT_KEY_EXTRA_BASE + 4
202 #define NEWT_KEY_RIGHT NEWT_KEY_EXTRA_BASE + 5
203 #define NEWT_KEY_BKSPC NEWT_KEY_EXTRA_BASE + 6
204 #define NEWT_KEY_DELETE NEWT_KEY_EXTRA_BASE + 7
205 #define NEWT_KEY_HOME NEWT_KEY_EXTRA_BASE + 8
206 #define NEWT_KEY_END NEWT_KEY_EXTRA_BASE + 9
207 #define NEWT_KEY_UNTAB NEWT_KEY_EXTRA_BASE + 10
208 #define NEWT_KEY_PGUP NEWT_KEY_EXTRA_BASE + 11
209 #define NEWT_KEY_PGDN NEWT_KEY_EXTRA_BASE + 12
211 #define NEWT_KEY_F1 NEWT_KEY_EXTRA_BASE + 101
212 #define NEWT_KEY_F2 NEWT_KEY_EXTRA_BASE + 102
213 #define NEWT_KEY_F3 NEWT_KEY_EXTRA_BASE + 103
214 #define NEWT_KEY_F4 NEWT_KEY_EXTRA_BASE + 104
215 #define NEWT_KEY_F5 NEWT_KEY_EXTRA_BASE + 105
216 #define NEWT_KEY_F6 NEWT_KEY_EXTRA_BASE + 106
217 #define NEWT_KEY_F7 NEWT_KEY_EXTRA_BASE + 107
218 #define NEWT_KEY_F8 NEWT_KEY_EXTRA_BASE + 108
219 #define NEWT_KEY_F9 NEWT_KEY_EXTRA_BASE + 109
220 #define NEWT_KEY_F10 NEWT_KEY_EXTRA_BASE + 110
221 #define NEWT_KEY_F11 NEWT_KEY_EXTRA_BASE + 111
222 #define NEWT_KEY_F12 NEWT_KEY_EXTRA_BASE + 112
224 #define NEWT_ANCHOR_LEFT (1 << 0)
225 #define NEWT_ANCHOR_RIGHT (1 << 1)
226 #define NEWT_ANCHOR_TOP (1 << 2)
227 #define NEWT_ANCHOR_BOTTOM (1 << 3)
229 #define NEWT_GRID_FLAG_GROWX (1 << 0)
230 #define NEWT_GRID_FLAG_GROWY (1 << 1)
232 typedef struct grid_s
* newtGrid
;
233 enum newtGridElement
{ NEWT_GRID_EMPTY
= 0,
234 NEWT_GRID_COMPONENT
, NEWT_GRID_SUBGRID
};
236 newtGrid
newtCreateGrid(int cols
, int rows
);
237 void newtGridSetField(newtGrid grid
, int col
, int row
,
238 enum newtGridElement type
, void * val
, int padLeft
,
239 int padTop
, int padRight
, int padBottom
, int anchor
,
241 void newtGridPlace(newtGrid grid
, int left
, int top
);
242 void newtGridFree(newtGrid grid
, int recurse
);
243 void newtGridGetSize(newtGrid grid
, int * width
, int * height
);
244 void newtGridWrappedWindow(newtGrid grid
, char * title
);
247 } /* End of extern "C" { */