Initial commit
[forms.git] / F / F_Types.H
bloba196307a1cb9c9aaebba665a63ece4b39b159b47
2 #ifndef _F_TYPES_H_
3 #define _F_TYPES_H_
5 #include <sys/types.h>
6 #include <sys/time.h>
7 #include <F_Version.H>
8 #include <string>
10 // TODO: F_Types ÄÏÌÖÅΠÓÏÄÅÒÖÁÔØ ÏÂÝÉÅ ÄÌÑ ×ÓÅÈ ÉÎÔÅÒÆÅÊÓÏ× ÔÉÐÙ, Á ÎÅ 
11 // ÔÉÐÙ ÄÌÑ ÔÅËÓÔÁ
13 namespace F {
15  extern const char *demangled_(const char *mngl);
16  // ËÏÏÒÄÉÎÁÔÙ ÍÏÇÕÔ ÂÙÔØ ÏÔÒÉÃÁÔÅÌØÎÙÍÉ - ÅÓÌÉ ×ÙÈÏÄÑÔ ÚÁ ÇÒÁÎÉÃÙ ÜËÒÁÎÁ
17  typedef int16_t coord_t;
18  typedef struct { coord_t x, y; } coords_t;
19  typedef u_int16_t dim_t;
20  typedef struct { dim_t w, h; } dims_t;
22 #define F_MAX_COORD_T   SHRT_MAX
23 #define F_MAX_DIM_T     USHRT_MAX
24 #define F_MAX_WIDGETS   USHRT_MAX
26 #define F_HORIZONTAL    0
27 #define F_VERTICAL      1
29  //! ËÏÎÓÔÁÎÔÁ ×ÒÅÍÅÎÉ ÏÖÉÄÁÎÉÑ × ÆÕÎËÃÉÉ F_App::wait()
30  const int start_only = 0,
31            forever    = 1;
33  enum log_level_t { DEBUG_LEVEL, CHAT_LEVEL, INFO_LEVEL, NOTICE_LEVEL,
34       WARN_LEVEL, ERROR_LEVEL, ALERT_LEVEL, CRITICAL_LEVEL, FATAL_LEVEL };
35       
36  //! ×ÉÄÙ ÐÏÌØÚÏ×ÁÔÅÌØÓËÉÈ ÉÎÔÅÒÆÅÊÓÏ×
37  enum ui_class_t {
38    DAEMON_UI,   // no tty
39    BATCH_UI,    // stdout/stdin
40    TTY_UI,      // /dev/tty
41    CONSOLE_UI,  // /dev/vcsa
42    FBDEV_UI,    // /dev/fb0
43    X11_UI       // X'Ù
44   };
46  //! ÚÁÍÅÎÉÔØ ÍÁÐÏÊ
47  typedef struct val_names_t {
48        int val;
49        const char *name;
50  } val_names_t ;
52 #define F_TRACE_SIGNAL  SIGURG
54  // idea got from mysql-ptrace
55  typedef struct {
56         u_int32_t       foo1;   /* +0x00 */
57         u_int32_t       foo2;
58         u_int32_t       foo3;
59         u_int32_t       foo4;   /* usually 2 */
60         u_int32_t       foo5;   /* +0x10 */
61         u_int32_t       xgs;    /* always zero */
62         u_int32_t       xfs;    /* always zero */
63         u_int32_t       xes;    /* always es=ds=ss */
64         u_int32_t       xds;    /* +0x20 */
65         u_int32_t       edi;
66         u_int32_t       esi;
67         u_int32_t       ebp;
68         u_int32_t       esp;    /* +0x30 */
69         u_int32_t       ebx;
70         u_int32_t       edx;
71         u_int32_t       ecx;
72         u_int32_t       eax;    /* +0x40 */
73         u_int32_t       foo11;  /* usually 0xe */
74         u_int32_t       foo12;  /* usually 0x6 */
75         u_int32_t       eip;    /* instruction pointer */
76         u_int32_t       xcs;    /* +0x50 */
77         u_int32_t       foo21;  /* usually 0x2 */
78         u_int32_t       foo22;  /* second stack pointer?! Probably. */
79         u_int32_t       xss;
80         u_int32_t       foo31;  /* +0x60 */ /* usually 0x0 */
81         u_int32_t       foo32;  /* usually 0x2 */
82         u_int32_t       fault_addr;     /* Address which caused a fault */
83         u_int32_t       foo41;  /* usually 0x2 */
84  } signal_regs_t;
86  enum F_Align_Type_t {
87    F_NO_ALIGN              = 0,
88    F_ALIGN_CENTER          = 1,
89    F_ALIGN_LEFT            = 2,
90    F_ALIGN_RIGHT           = 4,
91    F_ALIGN_TOP             = 8,
92    F_ALIGN_BOTTOM          = 16,
93    F_ALIGN_INSIDE          = 32,
94    F_ALIGN_CLIP            = 64,
95    F_ALIGN_WRAP            = 128,
96    F_ALIGN_TOP_LEFT        = F_ALIGN_TOP | F_ALIGN_LEFT,
97    F_ALIGN_TOP_RIGHT       = F_ALIGN_TOP | F_ALIGN_RIGHT,
98    F_ALIGN_BOTTOM_LEFT     = F_ALIGN_BOTTOM | F_ALIGN_LEFT,
99    F_ALIGN_BOTTOM_RIGHT    = F_ALIGN_BOTTOM | F_ALIGN_RIGHT,
100    F_ALIGN_LEFT_TOP        = F_ALIGN_TOP_LEFT,
101    F_ALIGN_RIGHT_TOP       = F_ALIGN_TOP_RIGHT,
102    F_ALIGN_LEFT_BOTTOM     = F_ALIGN_BOTTOM_LEFT,
103    F_ALIGN_RIGHT_BOTTOM    = F_ALIGN_BOTTOM_RIGHT
104  };
106  // Event Devices
107  enum F_Event_Device_t {
108    F_TYPE_NONE = 0,
109    F_DISPLAY,
110    F_KEYBOARD,
111    F_POINTER
112  };
114  enum F_Event_Type_t {
115    F_EVENT_NONE = 0,
116    // display types
117    F_WINDOW_SHOW,
118    F_WINDOW_HIDE,
119    // draw_buf sync window area
120    F_WINDOW_FLUSH,
121    // draw_buf sync all display area
122    F_DISPLAY_FLUSH,
123    // input types
124    F_POINTER_MOVE,
125    F_POINTER_DRAG,
126    F_POINTER_DROP,
127    // mouse buttons
128    F_POINTER_PRESS,
129    F_POINTER_RELEASE,
130    F_POINTER_SINGLE_CLICK, // ÜÔÏÔ event = input_press & input_release
131    F_POINTER_DOUBLE_CLICK,
132    F_POINTER_TRIPPLE_CLICK,
133    F_POINTER_AUTOREPEAT,
134    // keys
135    F_KEY_PRESS,
136    F_KEY_RELEASE,
137    F_KEY_AUTOREPEAT,
138    // wheel rolling
139    F_POINTER_WHEEL_INCR,
140    F_POINTER_WHEEL_DECR,
141    // general events
142    F_ENTER,
143    F_LEAVE,
144    F_FOCUS,
145    F_UNFOCUS
146  };
148  enum F_Pointer_Event_Code_t {
149    F_POINTER_NONE            = 0,
150    // mouse codes
151    F_POINTER_LEFT_BUTTON,
152    F_POINTER_MIDDLE_BUTTON,
153    F_POINTER_RIGHT_BUTTON,
154    F_POINTER_BUTTON_4,
155    F_POINTER_BUTTON_5,
156    F_POINTER_BUTTON_6,
157    F_POINTER_BUTTON_7,
158    F_POINTER_BUTTON_8,
159    F_POINTER_BUTTON_9,
160    F_POINTER_BUTTON_10,
161    F_POINTER_WHEEL_V, // vertical wheel
162    F_POINTER_WHEEL_H  // horizontal one
163  };
165  class F_Window;
166  class F_Widget;
168  typedef struct F_Event_t {
170   timeval timestamp; // hm ...
171   int delay; // × 10ms ÔÉËÁÈ ÚÁÄÅÒÖËÁ
172   F_Widget *widget; // ËÕÄÙ ÐÏÓÙÌÁÔØ ÓÉÇÎÁÌ
173   // F_DISPLAY / F_POINTER / F_KEY
174   F_Event_Device_t dev;
175   // F_POINTER_PRESS / F_POINTER_RELELASE
176   F_Event_Type_t type;
177   // Event values
178   // device specific state
179   union {
180    struct { // mouse
181     // may be implement as 'F_Point pointer;' ?
182     coord_t x;
183     coord_t y;
184     unsigned int buttons;
185     unsigned int click;
186     F_Pointer_Event_Code_t ev_c;
187    } mouse;
188    struct { // keyboard
189     unsigned int key;
190     unsigned int modifiers;
191    } kbd;
192    struct { // display
193     F_Window *window;
194    } display;
195   };
196  } F_Event_t;
198  // key codes idea is gently borrowed from fltk, naturally with all comments
199  // need to move to specific ui file as will conflict with fltk for ex.
201  #define F_Printable(x) ((x < 0xf000) ? true : false)
203  #define F_Beep         0xf007
204  #define F_BackSpace    0xf008
205  #define F_Tab          0xf009
206  #define F_Enter        0xf00d
207  #define F_Pause        0xf013
208  #define F_Scroll_Lock  0xf014
209  #define F_Escape       0xf01b
210  #define F_Home         0xf050
211  #define F_Left         0xf051
212  #define F_Up           0xf052
213  #define F_Right        0xf053
214  #define F_Down         0xf054
215  #define F_Page_Up      0xf055
216  #define F_Page_Down    0xf056
217  #define F_End          0xf057
218  #define F_Center       0xf058 // Keypad 5
219  #define F_Print        0xf061
220  #define F_Insert       0xf063
221  #define F_Menu_key     0xf067 // the "menu/apps" key on XFree86
222  #define F_Help         0xf068 // the 'help' key on Mac keyboards
223  #define F_Num_Lock     0xf07f
224  #define F_F            0xf090 // F_F + key = functional keys
225  #define F_F1           0xf091
226  #define F_F2           0xf092
227  #define F_F3           0xf093
228  #define F_F4           0xf094
229  #define F_F5           0xf095
230  #define F_F6           0xf096
231  #define F_F7           0xf097
232  #define F_F8           0xf098
233  #define F_F9           0xf099
234  #define F_F10          0xf09a
235  #define F_F11          0xf09b
236  #define F_F12          0xf09c
237  #define F_Shift_L      0xf0e1
238  #define F_Shift_R      0xf0e2
239  #define F_Control_L    0xf0e3
240  #define F_Control_R    0xf0e4
241  #define F_Caps_Lock    0xf0e5
242  #define F_Meta_L       0xf0e7 // the left MSWindows key on XFree86
243  #define F_Meta_R       0xf0e8 // the right MSWindows key on XFree86
244  #define F_Alt_L        0xf0e9
245  #define F_Alt_R        0xf0ea
246  #define F_Delete       0xf0eb
248  // modifiers
249  #define F_SHIFT        0x00010000
250  #define F_CAPS_LOCK    0x00020000
251  #define F_CTRL         0x00040000
252  #define F_ALT          0x00080000
253  #define F_NUM_LOCK     0x00100000 // most X servers do this?
254  #define F_META         0x00400000 // correct for XFree86
255  #define F_SCROLL_LOCK  0x00800000 // correct for XFree86
257  #define F_BUTTON1      0x01000000
258  #define F_BUTTON2      0x02000000
259  #define F_BUTTON3      0x04000000
260  #define F_BUTTONS      0x7f000000 // All possible buttons
261  #define F_BUTTON(n)    (0x00800000<<(n))
263 // Damage ÏÐÒÅÄÅÌÑÅÔ ËÁËÉÅ ÞÁÓÔÉ ×ÉÄÖÅÔÁ ÎÕÖÎÏ ÏÂÎÏ×ÉÔØ ÎÁ ÜËÒÁÎÅ
265 typedef unsigned int F_Damage_t;
267 #define F_DAMAGE_NONE     0x00
268 // ÒÁÍËÁ
269 #define F_DAMAGE_BORDER   0x01
270 // ÓÐÒÑÔÁÔØ/ÐÏËÁÚÁÔØ ×ÉÄÖÅÔ
271 #define F_DAMAGE_EXPOSE   0x02
272 // ÏÂÎÏ×ÉÔØ draw_buf ×ÙÛÅ ÐÏ ÉÅÒÁÒÈÉÉ
273 #define F_DAMAGE_FLUSH    0x04
274 // ÎÕÖÎÏ ÐÅÒÅÒÉÓÏ×ÁÔØ
275 #define F_DAMAGE_DRAW     0x08
276 // ÕÓÅ
277 #define F_DAMAGE_ALL      0xFF
279 typedef unsigned int F_Color_t;
281  // utf-8, where you ?
282  typedef unsigned char F_Char_t;
284  typedef struct F_Color {
285    F_Color_t fg_, bg_;
286  } F_Color;
288 const F_Color_t   F_BLACK           = 0,
289                   F_BLUE            = 1,
290                   F_GREEN           = 2,
291                   F_CYAN            = 3,
292                   F_RED             = 4,
293                   F_MAGENTA         = 5,
294                   F_YELLOW          = 6,
295                   F_WHITE           = 7,
296                   F_GREY            = 8,
297                   F_BRIGHT_BLUE     = 9,
298                   F_BRIGHT_GREEN    = 10,
299                   F_BRIGHT_CYAN     = 11,
300                   F_BRIGHT_RED      = 12,
301                   F_BRIGHT_MAGENTA  = 13,
302                   F_BRIGHT_YELLOW   = 14,
303                   F_BRIGHT_WHITE    = 15,
305                   F_BOLD            = 0x10000000,
306                   F_UNDERLINED      = 0x20000000,
307                   F_DIM             = 0x40000000,
308                   F_BLINK           = 0x80000000;
310 #define F_TRANSPARENT   F_GLASSY
312 #define F_DEFAULT_BG    F_BLUE
313 #define F_DEFAULT_FG    F_WHITE
315 enum F_Box_Type_t {
316   F_NO_BOX = 0,
317   F_UP_BOX,
318   F_DOWN_BOX
321 enum F_Window_Type_t {
322   F_NORMAL_WINDOW = 0,
323   F_MODAL_WINDOW
326 enum F_Wrap_t {
327   F_NO_WRAP = 0,
328   F_WRAP_WORDS,
329   F_WRAP_CHARS
332 typedef unsigned char F_Border_t;
334 const F_Border_t  F_NO_BORDER       = 0,
335                   F_SINGLE_BORDER   = 1,
336                   F_DOUBLE_BORDER   = 2,
337                   F_MOVING_BORDER   = 3;
339  enum F_Button_State_t {
340    F_BUTTON_NORMAL,
341    F_BUTTON_ON_FOCUS,
342    F_BUTTON_PRESSED
343  };
345  enum F_When {
346   F_WHEN_NEVER                  = 0,
347   F_WHEN_CHANGED                = 1,
348   F_WHEN_NOT_CHANGED            = 2,
349   F_WHEN_RELEASE                = 4,
350   F_WHEN_RELEASE_ALWAYS         = 6,
351   F_WHEN_ENTER_KEY              = 8,
352   F_WHEN_ENTER_KEY_ALWAYS       = 10,
353   F_WHEN_ENTER_KEY_CHANGED      = 11
354  };
355 } // namespace F
357 #endif