]> git.ipfire.org Git - thirdparty/newt.git/blob - newt.h
Initial revision
[thirdparty/newt.git] / newt.h
1 #ifndef H_NEWT
2 #define H_NEWT
3
4 struct newtColors {
5 char * rootFg, * rootBg;
6 char * borderFg, * borderBg;
7 char * windowFg, * windowBg;
8 char * shadowFg, * shadowBg;
9 char * titleFg, * titleBg;
10 char * buttonFg, * buttonBg;
11 char * actButtonFg, * actButtonBg;
12 char * checkboxFg, * checkboxBg;
13 char * actCheckboxFg, * actCheckboxBg;
14 char * entryFg, * entryBg;
15 };
16
17 extern struct newtColors newtDefaultColorPalette;
18
19 int newtInit(void);
20 int newtFinished(void);
21 void newtCls(void);
22 void newtWaitForKey(void);
23 void newtClearKeyBuffer(void);
24 void newtDelay(int usecs);
25 /* top, left are *not* counting the border */
26 int newtOpenWindow(int left, int top, int width, int height,
27 char * title);
28 void newtPopWindow(void);
29 void newtSetColors(struct newtColors colors);
30 void newtRefresh(void);
31
32 /* Components */
33
34 typedef struct newtComponent * newtComponent;
35 typedef struct newtForm * newtForm;
36
37 newtComponent newtButton(int left, int top, char * text);
38 newtComponent newtCheckbox(int left, int top, char * text, char defValue,
39 char * seq, char * result);
40 newtComponent newtRadiobutton(int left, int top, char * text, int isDefault,
41 newtComponent prevButton);
42
43 #define NEWT_ENTRY_SCROLL (1 << 0)
44 #define NEWT_ENTRY_HIDDEN (1 << 1)
45
46 newtComponent newtEntry(int left, int top, char * initialValue, int width,
47 char ** resultPtr, int flags);
48
49 /* Forms */
50
51 newtForm newtCreateForm(void);
52 void newtAddComponentToForm(newtForm form, newtComponent co);
53 void newtAddComponentsToForm(newtForm form, ...);
54 newtComponent newtRunForm(newtForm form);
55
56 /* this also destroys all of the components on the form */
57 void newtDestroyForm(newtForm form);
58
59 /* Key codes */
60
61 #define NEWT_KEY_TAB '\t'
62 #define NEWT_KEY_ENTER '\r'
63 #define NEWT_KEY_RETURN NEWT_KEY_ENTER
64
65 #define NEWT_KEY_EXTRA_BASE 0x8000
66 #define NEWT_KEY_UP NEWT_KEY_EXTRA_BASE + 1
67 #define NEWT_KEY_DOWN NEWT_KEY_EXTRA_BASE + 2
68 #define NEWT_KEY_LEFT NEWT_KEY_EXTRA_BASE + 4
69 #define NEWT_KEY_RIGHT NEWT_KEY_EXTRA_BASE + 5
70 #define NEWT_KEY_BKSPC NEWT_KEY_EXTRA_BASE + 6
71 #define NEWT_KEY_DELETE NEWT_KEY_EXTRA_BASE + 7
72 #define NEWT_KEY_HOME NEWT_KEY_EXTRA_BASE + 8
73 #define NEWT_KEY_END NEWT_KEY_EXTRA_BASE + 9
74
75 #endif /* H_NEWT */