]> git.ipfire.org Git - thirdparty/newt.git/blob - newt.h
62e70ae05bc0e419d7b18a9851ba7f7b394e07f2
[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 char * labelFg, * labelBg;
16 char * listboxFg, * listboxBg;
17 char * actListboxFg, * actListboxBg;
18 char * textboxFg, * textboxBg;
19 char * actTextboxFg, * actTextboxBg;
20 };
21
22 extern struct newtColors newtDefaultColorPalette;
23
24 int newtInit(void);
25 int newtFinished(void);
26 void newtCls(void);
27 void newtWaitForKey(void);
28 void newtClearKeyBuffer(void);
29 void newtDelay(int usecs);
30 /* top, left are *not* counting the border */
31 int newtOpenWindow(int left, int top, int width, int height,
32 char * title);
33 void newtPopWindow(void);
34 void newtSetColors(struct newtColors colors);
35 void newtRefresh(void);
36
37 /* Components */
38
39 typedef struct newtComponent * newtComponent;
40
41 newtComponent newtButton(int left, int top, char * text);
42 newtComponent newtCheckbox(int left, int top, char * text, char defValue,
43 char * seq, char * result);
44 newtComponent newtRadiobutton(int left, int top, char * text, int isDefault,
45 newtComponent prevButton);
46 newtComponent newtListitem(int left, int top, char * text, int isDefault,
47 newtComponent prevItem);
48
49 newtComponent newtLabel(int left, int top, char * text);
50 newtComponent newtVerticalScrollbar(int left, int top, int height,
51 int normalColorset, int thumbColorset);
52 void newtScrollbarSet(newtComponent co, int where, int total);
53
54 newtComponent newtListbox(int left, int top, int height, int flags);
55 void newtListboxAddEntry(newtComponent co, char * text);
56
57 #define NEWT_TEXTBOX_WRAP (1 << 0)
58 #define NEWT_TEXTBOX_SCROLL (1 << 1)
59
60 newtComponent newtTextbox(int left, int top, int with, int height, int flags);
61 void newtTextboxSetText(newtComponent co, const char * text);
62
63 newtComponent newtForm(newtComponent vertBar);
64 void newtFormAddComponent(newtComponent form, newtComponent co);
65 void newtFormAddComponents(newtComponent form, ...);
66 void newtFormSetHeight(newtComponent co, int height);
67 newtComponent newtRunForm(newtComponent form);
68
69 #define NEWT_ENTRY_SCROLL (1 << 0)
70 #define NEWT_ENTRY_HIDDEN (1 << 1)
71
72 newtComponent newtEntry(int left, int top, char * initialValue, int width,
73 char ** resultPtr, int flags);
74
75
76 /* this also destroys all of the components (including other forms) on the
77 form */
78 void newtFormDestroy(newtComponent form);
79
80 /* Key codes */
81
82 #define NEWT_KEY_TAB '\t'
83 #define NEWT_KEY_ENTER '\r'
84 #define NEWT_KEY_RETURN NEWT_KEY_ENTER
85
86 #define NEWT_KEY_EXTRA_BASE 0x8000
87 #define NEWT_KEY_UP NEWT_KEY_EXTRA_BASE + 1
88 #define NEWT_KEY_DOWN NEWT_KEY_EXTRA_BASE + 2
89 #define NEWT_KEY_LEFT NEWT_KEY_EXTRA_BASE + 4
90 #define NEWT_KEY_RIGHT NEWT_KEY_EXTRA_BASE + 5
91 #define NEWT_KEY_BKSPC NEWT_KEY_EXTRA_BASE + 6
92 #define NEWT_KEY_DELETE NEWT_KEY_EXTRA_BASE + 7
93 #define NEWT_KEY_HOME NEWT_KEY_EXTRA_BASE + 8
94 #define NEWT_KEY_END NEWT_KEY_EXTRA_BASE + 9
95 #define NEWT_KEY_UNTAB NEWT_KEY_EXTRA_BASE + 10
96
97 #endif /* H_NEWT */