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

Annotation of /archive/guilib/gui.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, 3 months ago) by james
File MIME type: text/x-chdr
File size: 7619 byte(s)
Initial import.

1 james 16 /*
2     * gui.h -- portable gui library, platform independent header
3     */
4    
5     #ifndef gui_H
6     #define gui_H
7    
8     #include <setjmp.h>
9     #include <stddef.h>
10     #include <stdio.h>
11     #include <stdlib.h>
12     #include <string.h>
13     #include <varargs.h>
14     #include <wchar.h>
15    
16     #include "wstring.h"
17    
18     /*
19     * user variables and functions
20     */
21    
22     extern const char *task_name;
23     extern void task_initialise(void);
24     extern void task_finalise(void);
25    
26     /*
27     * #include gui_<platform>.h
28     */
29    
30     #ifdef riscos
31     #include "gui_riscos.h"
32     #elif defined gtk
33     #include "gui_gtk.h"
34     #else
35     #error Unknown platform
36     #endif
37    
38     /*
39     * main_<platform>.c
40     */
41    
42     extern char **gui_message;
43    
44     extern int main(int argc, char *argv[]);
45     extern void gui_initialise(void);
46     extern void gui_event_loop(void);
47    
48     /*
49     * window_<platform>.c
50     */
51    
52     #define gui_H_SCROLL_BAR 0x1
53     #define gui_V_SCROLL_BAR 0x2
54     #define gui_CLICK 1
55     #define gui_CLICK_MENU 2
56     #define gui_CLICK_RIGHT 3
57     #define gui_DRAG 4
58     #define gui_DRAG_RIGHT 5
59    
60     extern gui_window_id gui_create_window(const unsigned int flags,
61     char *title,
62     const unsigned int width, const unsigned int height,
63     void (*close_fn)(gui_window_id window_id),
64     void (*redraw_fn)(gui_window_id window_id, unsigned int invalid[]),
65     void (*click_fn)(gui_window_id window_id, unsigned int x, unsigned int y,
66     unsigned int z),
67     void (*resize_fn)(gui_window_id window_id, unsigned int width, unsigned int height),
68     bool (*key_fn)(gui_window_id window_id, unsigned int key),
69     void (*input_fn)(gui_window_id window_id, wchar_t key),
70     void (*menu_fn)(gui_window_id window_id, unsigned int items[]),
71     gui_menu_id menu,
72     const char *bbar,
73     const char *help);
74     extern void gui_remove_window(const gui_window_id window_id);
75     extern void gui_refresh_window(const gui_window_id window_id);
76     extern void gui_refresh_box(const gui_window_id window_id, unsigned int x0,
77     unsigned int y0,
78     unsigned int x1, unsigned int y1);
79     extern void gui_window_extent(const gui_window_id window_id,
80     unsigned int width, unsigned int height);
81     extern void gui_fill(unsigned int colour, unsigned int x0, unsigned int y0,
82     unsigned int x1, unsigned int y1);
83     extern void gui_move_box(const gui_window_id window_id, unsigned int x0, unsigned int y0,
84     unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2);
85    
86     /*
87     * dialog_<platform>.c
88     */
89    
90     extern void gui_start_dialog(char *title, unsigned int width,
91     bool close, const char *help);
92     extern gui_window_id gui_create_dialog(void);
93     extern void ensure_dialog_space(void);
94     extern void gui_create_label(char *text, const char *help);
95     extern gui_gadget_id gui_create_text_box(char *text, const char *mask,
96     const char *help);
97     extern gui_gadget_id gui_create_display_box(char *text, char *value,
98     const char *help);
99     extern void gui_create_button(char *text, void (*click_fn)(gui_window_id window_id, gui_gadget_id gadget_id),
100     const char *help);
101    
102     /*
103     * textarea.c
104     */
105    
106     struct gui_ta;
107     struct gui_ta_content;
108     struct gui_ta_word;
109     struct gui_ta_style;
110     struct gui_ta_position;
111     struct gui_ta_selection;
112    
113     struct gui_ta
114     {
115     unsigned long width;
116     unsigned long height;
117     unsigned long contents;
118     unsigned long styles;
119     struct gui_ta_content *(*content)[];
120     struct gui_ta_style *(*style)[];
121     };
122    
123     struct gui_ta_content
124     {
125     enum { CONTENT_SPACE, CONTENT_PARAGRAPH } type;
126     unsigned long y0;
127     unsigned long y1;
128     unsigned long leading;
129     unsigned long base;
130     unsigned long words;
131     enum { ALIGN_LEFT, ALIGN_CENTRE, ALIGN_RIGHT, ALIGN_FULL } align;
132     struct gui_ta_word *(*word)[];
133     };
134    
135     struct gui_ta_word
136     {
137     signed long x; /* real x coordinate */
138     unsigned long lx; /* left-align x coordinate */
139     unsigned long y; /* y coordinate */
140     unsigned long width; /* width of text */
141     unsigned long style; /* font style */
142     int start : 1; /* at start of a line */
143     int end : 1; /* at end of a line */
144     signed long box_x0; /* rubout box */
145     signed long box_x1;
146     wchar_t text[1];
147     };
148    
149     #define gui_SIZEOF_GUI_TA_WORD(n) (offsetof(struct gui_ta_word, text) + (n) * sizeof(wchar_t))
150    
151     struct gui_ta_position
152     {
153     unsigned long content;
154     unsigned long word;
155     unsigned long offset;
156     unsigned long x;
157     unsigned long y;
158     };
159    
160     struct gui_ta_selection
161     {
162     struct gui_ta_position start;
163     struct gui_ta_position end;
164     };
165    
166     extern struct gui_ta *gui_ta(unsigned long width);
167     extern long gui_ta_add_space(struct gui_ta *doc, unsigned long height);
168     extern int gui_ta_add_paragraph(struct gui_ta *doc, unsigned long leading,
169     unsigned long base, wchar_t *text, unsigned long style, unsigned long align);
170     extern unsigned long gui_ta_get_style(struct gui_ta *doc, unsigned long xsize,
171     unsigned long ysize, unsigned long fcolour, unsigned long bcolour, char *font);
172     extern void gui_ta_render(struct gui_ta *doc, unsigned long x, unsigned long y,
173     unsigned int invalid[], struct gui_ta_selection *sel);
174     extern void gui_ta_position_xy(struct gui_ta *doc, struct gui_ta_position *pos,
175     signed long x, unsigned long y);
176     extern void gui_ta_reformat(struct gui_ta *doc, unsigned long width);
177     extern unsigned int gui_ta_reformat_paragraph(struct gui_ta *doc,
178     struct gui_ta_content *con, unsigned long y, unsigned long width,
179     unsigned long *y0_ret, unsigned long *y1_ret);
180     extern void gui_ta_insert_char(struct gui_ta *doc, struct gui_ta_position *pos,
181     wchar_t text, gui_window_id window_id,
182     unsigned long x_offset, unsigned long y_offset);
183     extern void gui_ta_insert_split(struct gui_ta *doc, struct gui_ta_position *pos,
184     gui_window_id window_id, unsigned long x_offset, unsigned long y_offset);
185     extern void gui_ta_insert_newline(struct gui_ta *doc, struct gui_ta_position *pos,
186     gui_window_id window_id, unsigned long x_offset, unsigned long y_offset);
187     extern void gui_ta_position_cwo(struct gui_ta *doc, struct gui_ta_position *pos);
188     extern void gui_ta_delete(struct gui_ta *doc, struct gui_ta_position *start,
189     struct gui_ta_position *end, gui_window_id window_id,
190     unsigned long x_offset, unsigned long y_offset);
191     extern void gui_ta_remove(struct gui_ta *doc);
192     extern void gui_ta_align(struct gui_ta *doc, unsigned int content, unsigned int align,
193     gui_window_id window_id, unsigned int x_offset, unsigned int y_offset);
194     extern void gui_ta_export(struct gui_ta *doc, const char *path);
195    
196     /*
197     * textarea_<platform>.c
198     */
199    
200     extern unsigned long gui_ta_text_width(struct gui_ta *doc, const wchar_t *text,
201     unsigned long s);
202     extern void gui_ta_render_text(struct gui_ta *doc, wchar_t *text, unsigned long s,
203     unsigned long x, unsigned long y, unsigned long box_x0,
204     unsigned long box_y0, unsigned long box_x1, unsigned long box_y1,
205     bool sel);
206     extern unsigned long gui_ta_position_x(struct gui_ta *doc, wchar_t *text, unsigned long s,
207     signed long *x);
208     extern unsigned long gui_ta_position_o(struct gui_ta *doc, wchar_t *text, unsigned long s,
209     unsigned long offset);
210     extern void gui_ta_caret(gui_window_id window_id, struct gui_ta *doc,
211     struct gui_ta_position *pos, unsigned long x, unsigned long y);
212     extern void gui_ta_fill_style(struct gui_ta_style *style);
213     extern void gui_ta_empty_style(struct gui_ta_style *style);
214    
215     /*
216     * messages.c
217     */
218    
219     extern char **gui_messages_read(const char *file_name);
220    
221     /*
222     * menu_<platform>.c
223     */
224    
225     extern gui_menu_id gui_menu(unsigned int base, unsigned int items);
226     extern void gui_menu_attach(gui_menu_id menu, unsigned int item, gui_menu_id submenu);
227    
228     /*
229     * log
230     */
231    
232     #ifdef DEBUG
233     #define gui_log(fmt, args...) { fprintf(stdout, fmt, ## args); fflush(stdout); }
234     #else
235     #define gui_log(fmt, args...) {}
236     #endif
237    
238    
239     #endif

  ViewVC Help
Powered by ViewVC 1.1.26