gltiki

view src/gltiki_impl.h @ 0:ea177566fe79

initial commit
author John Tsiombikas <nuclear@mutantstargoat.com>
date Sat, 07 Jul 2012 07:07:40 +0300
parents
children
line source
1 /*
2 A simple cross-platform OpenGL GUI toolkit
3 Copyright (C) 2012 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef GLTIKI_IMPL_H_
19 #define GLTIKI_IMPL_H_
21 #include "gltiki.h"
23 enum { UNKNOWN, LABEL, BUTTON, CHECKBOX, SLIDER, INTSLIDER, LISTBOX };
25 #define GLTK_CAST(w, t, ctype) \
26 ((w)->type == (t) ? ((ctype)(w)) : 0)
28 #define GLTK_LABEL(w) GLTK_CAST(w, LABEL, struct gltk_label)
29 #define GLTK_BUTTON(w) GLTK_CAST(w, BUTTON, struct gltk_button)
30 #define GLTK_CHECKBOX(w) GLTK_CAST(w, CHECKBOX, struct gltk_checkbox)
31 #define GLTK_SLIDER(w) GLTK_CAST(w, SLIDER, struct gltk_slider)
32 #define GLTK_INTSLIDER(w) GLTK_CAST(w, INTSLIDER, struct gltk_int_slider)
33 #define GLTK_LISTBOX(w) GLTK_CAST(w, LISTBOX, struct gltk_listbox)
35 #define GLTK_WIDGET_VARS \
36 int type; \
37 float x, y, width, height; \
38 int active; \
39 struct gltk_widget *next; \
40 gltk_callback callback; \
41 void *cls; \
42 void (*draw)()
44 struct gltk_widget {
45 GLTK_WIDGET_VARS;
46 };
48 struct gltk_label {
49 GLTK_WIDGET_VARS;
50 char *text;
51 };
53 struct gltk_button {
54 GLTK_WIDGET_VARS;
55 char *text;
56 };
58 struct gltk_checkbox {
59 GLTK_WIDGET_VARS;
60 char *text;
61 int state;
62 };
64 struct gltk_slider {
65 GLTK_WIDGET_VARS;
66 float value, min, max;
67 };
69 struct gltk_int_slider {
70 GLTK_WIDGET_VARS;
71 int value, min, max;
72 };
74 struct gltk_listbox {
75 GLTK_WIDGET_VARS;
76 int sel;
77 int vislines;
78 gltk_item *items, *items_tail, *sel_item;
79 };
81 struct gltk_item {
82 char *text;
83 gltk_pixmap *img;
84 };
86 struct gltk_pixmap {
87 int width, height;
88 unsigned char *pixels;
89 };
91 #endif /* GLTIKI_IMPL_H_ */