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