]> git.ipfire.org Git - thirdparty/newt.git/blob - newt.h
added newtFormSetWidth()
[thirdparty/newt.git] / newt.h
1 #ifndef H_NEWT
2 #define H_NEWT
3
4 #define COLORSET_ROOT 2
5 #define COLORSET_BORDER 3
6 #define COLORSET_WINDOW 4
7 #define COLORSET_SHADOW 5
8 #define COLORSET_TITLE 6
9 #define COLORSET_BUTTON 7
10 #define COLORSET_ACTBUTTON 8
11 #define COLORSET_CHECKBOX 9
12 #define COLORSET_ACTCHECKBOX 10
13 #define COLORSET_ENTRY 11
14 #define COLORSET_LABEL 12
15 #define COLORSET_LISTBOX 13
16 #define COLORSET_ACTLISTBOX 14
17 #define COLORSET_TEXTBOX 15
18 #define COLORSET_ACTTEXTBOX 16
19
20 struct newtColors {
21 char * rootFg, * rootBg;
22 char * borderFg, * borderBg;
23 char * windowFg, * windowBg;
24 char * shadowFg, * shadowBg;
25 char * titleFg, * titleBg;
26 char * buttonFg, * buttonBg;
27 char * actButtonFg, * actButtonBg;
28 char * checkboxFg, * checkboxBg;
29 char * actCheckboxFg, * actCheckboxBg;
30 char * entryFg, * entryBg;
31 char * labelFg, * labelBg;
32 char * listboxFg, * listboxBg;
33 char * actListboxFg, * actListboxBg;
34 char * textboxFg, * textboxBg;
35 char * actTextboxFg, * actTextboxBg;
36 };
37
38 typedef struct newtComponent * newtComponent;
39
40
41 extern struct newtColors newtDefaultColorPalette;
42
43 typedef void (*newtCallback)(newtComponent, void *);
44
45 int newtInit(void);
46 int newtFinished(void);
47 void newtCls(void);
48 void newtWaitForKey(void);
49 void newtClearKeyBuffer(void);
50 void newtDelay(int usecs);
51 /* top, left are *not* counting the border */
52 int newtOpenWindow(int left, int top, int width, int height,
53 char * title);
54 void newtPopWindow(void);
55 void newtSetColors(struct newtColors colors);
56 void newtRefresh(void);
57
58 /* Components */
59
60 newtComponent newtButton(int left, int top, char * text);
61 newtComponent newtCheckbox(int left, int top, char * text, char defValue,
62 char * seq, char * result);
63 newtComponent newtRadiobutton(int left, int top, char * text, int isDefault,
64 newtComponent prevButton);
65 newtComponent newtRadioGetCurrent(newtComponent setMember);
66 newtComponent newtListitem(int left, int top, char * text, int isDefault,
67 newtComponent prevItem, void * data);
68 void newtListitemSet(newtComponent co, char * text);
69 void * newtListitemGetData(newtComponent co);
70
71 newtComponent newtLabel(int left, int top, char * text);
72 void newtLabelSetText(newtComponent co, char * text);
73 newtComponent newtVerticalScrollbar(int left, int top, int height,
74 int normalColorset, int thumbColorset);
75 void newtScrollbarSet(newtComponent co, int where, int total);
76
77 #define NEWT_LISTBOX_RETURNEXIT (1 << 0)
78 newtComponent newtListbox(int left, int top, int height, int flags);
79 /* return the data passed to AddEntry */
80 void * newtListboxGetCurrent(newtComponent co);
81 void newtListboxSetCurrent(newtComponent co, int num);
82 void newtListboxAddEntry(newtComponent co, char * text, void * data);
83 void newtListboxSetEntry(newtComponent co, int num, char * text);
84
85 #define NEWT_TEXTBOX_WRAP (1 << 0)
86 #define NEWT_TEXTBOX_SCROLL (1 << 1)
87
88 newtComponent newtTextbox(int left, int top, int with, int height, int flags);
89 void newtTextboxSetText(newtComponent co, const char * text);
90
91 #define NEWT_FORM_NOF12 (1 << 0)
92
93 struct newtExitStruct {
94 enum { NEWT_EXIT_HOTKEY, NEWT_EXIT_COMPONENT } reason;
95 union {
96 int key;
97 newtComponent co;
98 } u;
99 } ;
100
101 newtComponent newtForm(newtComponent vertBar, char * help, int flags);
102 newtComponent newtFormGetCurrent(newtComponent co);
103 void newtFormSetBackground(newtComponent co, int color);
104 void newtFormSetCurrent(newtComponent co, newtComponent subco);
105 void newtFormAddComponent(newtComponent form, newtComponent co);
106 void newtFormAddComponents(newtComponent form, ...);
107 void newtFormSetHeight(newtComponent co, int height);
108 void newtFormSetWidth(newtComponent co, int width);
109 newtComponent newtRunForm(newtComponent form); /* obsolete */
110 void newtFormRun(newtComponent co, struct newtExitStruct * es);
111 void newtDrawForm(newtComponent form);
112 void newtFormAddHotKey(newtComponent co, int key);
113
114 #define NEWT_ENTRY_SCROLL (1 << 0)
115 #define NEWT_ENTRY_HIDDEN (1 << 1)
116 #define NEWT_ENTRY_RETURNEXIT (1 << 2)
117
118 newtComponent newtEntry(int left, int top, char * initialValue, int width,
119 char ** resultPtr, int flags);
120 void newtEntrySet(newtComponent co, char * value, int cursorAtEnd);
121 void newtComponentAddCallback(newtComponent co, newtCallback f, void * data);
122
123 /* this also destroys all of the components (including other forms) on the
124 form */
125 void newtFormDestroy(newtComponent form);
126
127 /* Key codes */
128
129 #define NEWT_KEY_TAB '\t'
130 #define NEWT_KEY_ENTER '\r'
131 #define NEWT_KEY_RETURN NEWT_KEY_ENTER
132
133 #define NEWT_KEY_EXTRA_BASE 0x8000
134 #define NEWT_KEY_UP NEWT_KEY_EXTRA_BASE + 1
135 #define NEWT_KEY_DOWN NEWT_KEY_EXTRA_BASE + 2
136 #define NEWT_KEY_LEFT NEWT_KEY_EXTRA_BASE + 4
137 #define NEWT_KEY_RIGHT NEWT_KEY_EXTRA_BASE + 5
138 #define NEWT_KEY_BKSPC NEWT_KEY_EXTRA_BASE + 6
139 #define NEWT_KEY_DELETE NEWT_KEY_EXTRA_BASE + 7
140 #define NEWT_KEY_HOME NEWT_KEY_EXTRA_BASE + 8
141 #define NEWT_KEY_END NEWT_KEY_EXTRA_BASE + 9
142 #define NEWT_KEY_UNTAB NEWT_KEY_EXTRA_BASE + 10
143 #define NEWT_KEY_PGUP NEWT_KEY_EXTRA_BASE + 11
144 #define NEWT_KEY_PGDN NEWT_KEY_EXTRA_BASE + 12
145
146 #define NEWT_KEY_F1 NEWT_KEY_EXTRA_BASE + 101
147 #define NEWT_KEY_F2 NEWT_KEY_EXTRA_BASE + 102
148 #define NEWT_KEY_F3 NEWT_KEY_EXTRA_BASE + 103
149 #define NEWT_KEY_F4 NEWT_KEY_EXTRA_BASE + 104
150 #define NEWT_KEY_F5 NEWT_KEY_EXTRA_BASE + 105
151 #define NEWT_KEY_F6 NEWT_KEY_EXTRA_BASE + 106
152 #define NEWT_KEY_F7 NEWT_KEY_EXTRA_BASE + 107
153 #define NEWT_KEY_F8 NEWT_KEY_EXTRA_BASE + 108
154 #define NEWT_KEY_F9 NEWT_KEY_EXTRA_BASE + 109
155 #define NEWT_KEY_F10 NEWT_KEY_EXTRA_BASE + 110
156 #define NEWT_KEY_F11 NEWT_KEY_EXTRA_BASE + 111
157 #define NEWT_KEY_F12 NEWT_KEY_EXTRA_BASE + 112
158
159 #endif /* H_NEWT */