http://mulliner.org/bluetooth/xkbdbthid-0.1_src.tar.gz
[xkbdbthid.git] / xkbd-0.8.15_bthid / src / structs.h
1 /* 
2    xkbd - xlib based onscreen keyboard.
3
4    Copyright (C) 2001 Matthew Allum
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2, or (at your option)
9    any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15 */
16
17 #ifndef _STRUCT_H_
18 #define _STRUCT_H_
19
20 #include <X11/Xlib.h>
21 #include <X11/Xutil.h>
22 #ifdef USE_XFT
23 #include <X11/Xft/Xft.h>
24 #endif
25 #define BUTTON_PRESSED  0
26 #define BUTTON_RELEASED 1
27 #define BUTTON_LOCKED   2
28
29 #define KB_STATE_NORMAL 0 
30 #define KB_STATE_SHIFT  (1<<1)
31 #define KB_STATE_MOD    (1<<2)
32 #define KB_STATE_CTRL   (1<<3)
33 #define KB_STATE_CAPS   (1<<4)
34 #define KB_STATE_META   (1<<5)
35 #define KB_STATE_ALT    (1<<6)
36
37 #define BUT_NORMAL      0
38 #define BUT_SHIFT       (1<<1)
39 #define BUT_MOD         (1<<2)
40 #define BUT_CTRL        (1<<3)
41 #define BUT_CAPS        (1<<4)
42 #define BUT_META        (1<<5)
43 #define BUT_ALT         (1<<6)
44
45 #define OPT_NORMAL      0
46 #define OPT_OBEYCAPS    (1<<0)
47
48 #define TRUE            1
49 #define FALSE           0
50
51 #define UP              1
52 #define DOWN            2
53 #define LEFT            3
54 #define RIGHT           4
55
56 #define MAX_LAYOUTS     3
57
58 #define KB_STATE_ALT_L (1<<1)
59 #define KB_STATE_ALT_R (1<<2)
60 #define KB_STATE_CTRL_L (1<<3)
61 #define KB_STATE_CTRL_R (1<<4)
62 #define KB_STATE_SHIFT_L (1<<5)
63 #define KB_STATE_SHIFT_R (1<<6)
64
65 typedef struct _list
66 {
67   struct _list *next;
68   int type;
69   void *data;
70
71 } list;
72
73
74 typedef struct _box
75 {
76   enum { vbox, hbox } type;
77   list *root_kid;
78   list *tail_kid;
79   int min_width;        /* ( num_kids*(kid_c_width+(kid_border*2) ) */
80   int min_height; 
81   int act_width;        /* actual calculated width */
82   int act_height;       /* ( num_kids*(kid_c_width+padding+(kid_border*2) ) */
83   int x;                /* relative to parent ? */
84   int y;
85
86   struct _box *parent;  /* pointer to parent keyboard */
87
88 } box;
89
90 typedef struct _keyboard 
91 {
92   int mode;
93   box *kbd_layouts[MAX_LAYOUTS];
94   int total_layouts;
95   box *vbox;  /* container */
96
97   int x;      /* but vbox contains this ? */
98   int y;
99   Window win;
100   Display *display;
101   Pixmap backing;
102
103   GC gc;
104   GC rev_gc;   /* inverse gc of above */
105   GC txt_gc;   /* gc's for button txt */
106   GC txt_rev_gc;
107   GC bdr_gc;
108   
109   XFontStruct* font_info;
110   int state;  /* shifted | caps | modded | normal */
111   int state_locked;  /* shifted | modded | normal */
112   
113   enum { oldskool, xft } render_type;
114   enum { rounded, square, plain } theme;
115   
116   int slide_margin;
117   int key_delay_repeat; /* delay time before key repeat */
118   int key_repeat;       /* delay time between key repeats */
119   
120 #ifdef USE_XFT
121   XftDraw *xftdraw;   /* xft aa bits */
122   XftFont *xftfont;
123   XftColor color_bg; 
124   XftColor color_fg;
125 #endif
126
127   int bthid_state;
128         
129 } keyboard;
130
131 typedef struct _button
132 {
133   int x;             /* actual co-ords relative to window */
134   int y;
135   
136   char *default_txt; /* default button txt */
137   KeySym default_ks; /* default button Xkeysym */
138   char *shift_txt;
139   KeySym shift_ks;
140   char *mod_txt;
141   KeySym mod_ks;
142
143   KeySym slide_up_ks;
144   KeySym slide_down_ks;
145   KeySym slide_left_ks;
146   KeySym slide_right_ks;
147
148   enum { none, up, down, left, right } slide;
149
150   int modifier; /* set to BUT_ if key is shift,ctrl,caps etc */
151
152   int options; /* bit-field of OPT_* */
153
154   int c_width;  /* width  of contents ( min width ) */
155   int c_height; /* height of contents ( min height ) */
156   int x_pad;    /* total padding horiz */
157   int y_pad;    /* total padding vert  */
158   int b_size;   /* size of border in pixels */
159                 /* eg. total width = c_width+pad_x+(2*b_size) */ 
160
161   Bool is_width_spec; /* width is specified in conf file */ 
162   int key_span_width; /* width in number of keys spanned */
163    
164   int act_width; 
165   int act_height;
166
167   keyboard *kb;   /* pointer to parent keyboard */
168   box   *parent;  /* pointer to holding box */
169
170   GC fg_gc;       /* gc's for 'general' button cols */
171   GC bg_gc;
172
173   signed int layout_switch; /* Signals the button switches layout 
174                                set to -1 for no switch            */
175
176 #ifdef USE_XFT
177   XftColor *xft_fg_col;  /* xft */ 
178   XftColor *xft_bg_col;
179 #endif
180
181   Pixmap *pixmap;
182   Pixmap *mask;
183   GC mask_gc;
184
185   int scancode;
186         
187 } button;
188
189
190 #endif
191
192
193
194
195
196