/[james]/archive/guilib/gui_gtk.h
ViewVC logotype

Annotation of /archive/guilib/gui_gtk.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 16 - (hide annotations) (download) (as text)
Mon Feb 10 22:56:40 2003 UTC (21 years, 10 months ago) by james
File MIME type: text/x-chdr
File size: 3864 byte(s)
Initial import.

1 james 16 /*
2     * gui_gtk.h -- portable gui library, GTK header
3     */
4    
5     #include <gtk/gtk.h>
6    
7     typedef gboolean bool;
8    
9     struct gui_menu_data;
10    
11     typedef unsigned int gui_window_id;
12     #define gui_WINDOW_UNKNOWN ((gui_window_id) 0xffffffff)
13     typedef GtkWidget *gui_gadget_id;
14     typedef struct gui_menu_data *gui_menu_id;
15    
16     /*extern wimp_t gui_wimp_task; /* wimp task handle */
17     /*extern os_error *gui_error; /* last error block pointer */
18     extern const char *gui_error_message; /* last error message */
19     extern int gui_error_line; /* last error line */
20     extern jmp_buf gui_error_jump; /* longjmp buffer for error handling */
21    
22     struct gui_window_data
23     {
24     enum { UNUSED, WINDOW, DIALOG } used;
25     GtkWindow *handle;
26     char *title;
27     void (*close_fn)(gui_window_id window_id);
28     void (*redraw_fn)(gui_window_id window_id, unsigned int invalid[]);
29     void (*click_fn)(gui_window_id window_id, unsigned int x, unsigned int y, unsigned int z);
30     void (*resize_fn)(gui_window_id window_id, unsigned int width, unsigned int height);
31     void (*key_fn)(gui_window_id window_id, unsigned int key);
32     void (*input_fn)(gui_window_id window_id, wchar_t key);
33     void (*menu_fn)(gui_window_id window_id, unsigned int items[]);
34     unsigned int width, height;
35     struct gui_menu_data *menu;
36     /* wimp_menu *menu;
37     wimp_w *bbar;*/
38     // struct gui_dialog_icon *icon;
39     const char *help;
40     GtkDrawingArea *drawing_area;
41     };
42     extern struct gui_window_data *gui_window_list; /* array of window details */
43     extern unsigned int gui_window_list_items; /* length of windows list */
44    
45     extern gui_window_id gui_get_free_window_id(void);
46     extern gui_window_id gui_handle_to_window_id(GtkWidget *handle);
47     extern gui_window_id menu_window_id;
48     extern signed int gui_window_origin_x, gui_window_origin_y;
49     extern GtkWidget *gui_redraw_widget;
50    
51     #define WINDOW_LIST_CHUNK 20
52    
53     struct gui_menu_data
54     {
55     unsigned int size;
56     GtkWidget *menu;
57     GtkWidget **item;
58     struct gui_menu_data *parent;
59     unsigned int i;
60     };
61    
62     struct gui_ta_style
63     {
64     unsigned int xsize;
65     unsigned int ysize;
66     unsigned int fcolour;
67     unsigned int bcolour;
68     unsigned int space;
69     GdkFont *handle;
70     char font[1];
71     };
72    
73     #define gui_SIZEOF_GUI_TA_STYLE(n) (offsetof(struct gui_ta_style, font) + (n) * sizeof(char))
74    
75    
76     #define KEY_BACKSPACE 1
77     #define KEY_RETURN 2
78     #define KEY_ESCAPE 3
79     #define KEY_HOME 4
80     #define KEY_DELETE 5
81     #define KEY_SHIFT 6
82     #define KEY_CONTROL 7
83     #define KEY_PRINT 8
84     #define KEY_F1 1
85     #define KEY_F2 2
86     #define KEY_F3 3
87     #define KEY_F4 4
88     #define KEY_F5 5
89     #define KEY_F6 6
90     #define KEY_F7 7
91     #define KEY_F8 8
92     #define KEY_F9 9
93     #define KEY_TAB 10
94     #define KEY_COPY 11
95     #define KEY_LEFT 12
96     #define KEY_RIGHT 13
97     #define KEY_LOGO 14
98     #define KEY_MENU 15
99     #define KEY_F10 16
100     #define KEY_F11 17
101     #define KEY_F12 18
102     #define KEY_INSERT 19
103     #define KEY_DOWN 20
104     #define KEY_UP 21
105     #define KEY_PAGE_DOWN 22
106     #define KEY_PAGE_UP 23
107    
108    
109    
110     #define BGR_TO_GDK(colour, gdk_colour) gdk_colour.red = ((colour & 0xff) << 8) | (colour & 0xff); \
111     gdk_colour.green = (colour & 0xff00) | ((colour & 0xff00) >> 8); \
112     gdk_colour.blue = ((colour & 0xff0000) >> 8) | ((colour & 0xff0000) >> 16)
113    
114    
115    
116    
117     /*
118     * Error handling
119     */
120    
121     /*
122     * gui_check_error -- check for an error after a swi
123     */
124    
125     /* #define gui_check_error() if (gui_error) { gui_error_message = gui_error->errmess; gui_error_line = __LINE__; longjmp(gui_error_jump, 1); } */
126    
127     /*
128     * gui_raise_error -- generate an error
129     */
130    
131     #define gui_raise_error(message) { gui_error_message = (message); gui_error_line = __LINE__; longjmp(gui_error_jump, 1); }
132    
133    
134     /*
135     * assert
136     */
137    
138     #ifdef DEBUG
139     #define assert(expression) ((void) ((expression) ? 0 : (printf("%s:%u: *** assert(" #expression ") failed ***\n", __FILE__, __LINE__), exit(EXIT_FAILURE), 0)))
140     #else
141     #define assert(expression) ((void) 0)
142     #endif

  ViewVC Help
Powered by ViewVC 1.1.26