]> git.saurik.com Git - wxWidgets.git/blob - misc/theme_test/test.c
make --enable-optimise the default in absence of --enable-debug again
[wxWidgets.git] / misc / theme_test / test.c
1
2 #include <gtk/gtk.h>
3
4 /* This function rotates the position of the tabs */
5 void rotate_book (GtkButton *button, GtkNotebook *notebook)
6 {
7 gtk_notebook_set_tab_pos (notebook, (notebook->tab_pos +1) %4);
8 }
9
10 /* Add/Remove the page tabs and the borders */
11 void tabsborder_book (GtkButton *button, GtkNotebook *notebook)
12 {
13 gint tval = FALSE;
14 gint bval = FALSE;
15 if (notebook->show_tabs == 0)
16 tval = TRUE;
17 if (notebook->show_border == 0)
18 bval = TRUE;
19
20 gtk_notebook_set_show_tabs (notebook, tval);
21 gtk_notebook_set_show_border (notebook, bval);
22 }
23
24 /* Remove a page from the notebook */
25 void remove_book (GtkButton *button, GtkNotebook *notebook)
26 {
27 gint page;
28
29 page = gtk_notebook_get_current_page(notebook);
30 gtk_notebook_remove_page (notebook, page);
31 /* Need to refresh the widget --
32 This forces the widget to redraw itself. */
33 gtk_widget_draw(GTK_WIDGET(notebook), NULL);
34 }
35
36 void delete (GtkWidget *widget, GtkWidget *event, gpointer data)
37 {
38 gtk_main_quit ();
39 }
40
41 void assign_new_style(GtkWidget *widget)
42 {
43 GtkStyle *default_style,*new_style;
44
45 default_style = gtk_rc_get_style( widget );
46
47 if (!default_style)
48 default_style = gtk_widget_get_default_style();
49
50 new_style = gtk_style_copy( default_style );
51 new_style->engine_data = default_style->engine_data;
52 new_style->klass = default_style->klass;
53
54 gtk_widget_set_style( widget, new_style );
55 }
56
57
58 int main (int argc, char *argv[])
59 {
60 GtkWidget *window;
61 GtkWidget *button;
62 GtkWidget *table;
63 GtkWidget *notebook;
64 GtkWidget *frame;
65 GtkWidget *label;
66
67 gtk_init (&argc, &argv);
68
69 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
70
71 gtk_signal_connect (GTK_OBJECT (window), "delete_event",
72 GTK_SIGNAL_FUNC (delete), NULL);
73
74 gtk_container_set_border_width (GTK_CONTAINER (window), 10);
75
76 table = gtk_table_new(3,6,FALSE);
77 gtk_container_add (GTK_CONTAINER (window), table);
78
79 /* Create a new notebook, place the position of the tabs */
80 notebook = gtk_notebook_new ();
81 assign_new_style( notebook );
82
83 gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
84 gtk_table_attach_defaults(GTK_TABLE(table), notebook, 0,6,0,1);
85 gtk_widget_show(notebook);
86
87 /* Now finally lets prepend pages to the notebook */
88
89 frame = gtk_frame_new ("frame");
90 gtk_container_set_border_width (GTK_CONTAINER (frame), 10);
91 gtk_widget_set_usize (frame, 100, 75);
92 gtk_widget_show (frame);
93
94 label = gtk_label_new ("label");
95 assign_new_style( label );
96 gtk_container_add (GTK_CONTAINER (frame), label);
97 gtk_widget_show (label);
98
99 label = gtk_label_new ("page");
100 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label);
101
102
103 frame = gtk_frame_new ("frame");
104 gtk_container_set_border_width (GTK_CONTAINER (frame), 10);
105 gtk_widget_set_usize (frame, 100, 75);
106 gtk_widget_show (frame);
107
108 label = gtk_button_new_with_label ("button");
109 assign_new_style( label );
110 gtk_container_add (GTK_CONTAINER (frame), label);
111 gtk_widget_show (label);
112
113 label = gtk_label_new ("page");
114 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label);
115
116
117
118 frame = gtk_frame_new ("frame");
119 gtk_container_set_border_width (GTK_CONTAINER (frame), 10);
120 gtk_widget_set_usize (frame, 100, 75);
121 gtk_widget_show (frame);
122
123 label = gtk_check_button_new_with_label ("check button");
124 assign_new_style( label );
125 gtk_container_add (GTK_CONTAINER (frame), label);
126 gtk_widget_show (label);
127
128 label = gtk_label_new ("page");
129 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label);
130
131
132 frame = gtk_frame_new ("frame");
133 gtk_container_set_border_width (GTK_CONTAINER (frame), 10);
134 gtk_widget_set_usize (frame, 100, 75);
135 gtk_widget_show (frame);
136
137 label = gtk_radio_button_new_with_label (NULL, "radio button");
138 assign_new_style( label );
139 gtk_container_add (GTK_CONTAINER (frame), label);
140 gtk_widget_show (label);
141
142 label = gtk_label_new ("page");
143 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label);
144
145
146 frame = gtk_frame_new ("frame");
147 gtk_container_set_border_width (GTK_CONTAINER (frame), 10);
148 gtk_widget_set_usize (frame, 100, 75);
149 gtk_widget_show (frame);
150
151 label = gtk_entry_new ();
152 assign_new_style( label );
153 gtk_container_add (GTK_CONTAINER (frame), label);
154 gtk_widget_show (label);
155
156 label = gtk_label_new ("page");
157 gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label);
158
159 /* Create a bunch of buttons */
160 button = gtk_button_new_with_label ("close");
161 gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
162 GTK_SIGNAL_FUNC (delete), NULL);
163 gtk_table_attach_defaults(GTK_TABLE(table), button, 0,1,1,2);
164 gtk_widget_show(button);
165
166 button = gtk_button_new_with_label ("next page");
167 gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
168 (GtkSignalFunc) gtk_notebook_next_page,
169 GTK_OBJECT (notebook));
170 gtk_table_attach_defaults(GTK_TABLE(table), button, 1,2,1,2);
171 gtk_widget_show(button);
172
173 button = gtk_button_new_with_label ("prev page");
174 gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
175 (GtkSignalFunc) gtk_notebook_prev_page,
176 GTK_OBJECT (notebook));
177 gtk_table_attach_defaults(GTK_TABLE(table), button, 2,3,1,2);
178 gtk_widget_show(button);
179
180 button = gtk_button_new_with_label ("tab position");
181 gtk_signal_connect (GTK_OBJECT (button), "clicked",
182 (GtkSignalFunc) rotate_book, GTK_OBJECT(notebook));
183 gtk_table_attach_defaults(GTK_TABLE(table), button, 3,4,1,2);
184 gtk_widget_show(button);
185
186 button = gtk_button_new_with_label ("tabs/border on/off");
187 gtk_signal_connect (GTK_OBJECT (button), "clicked",
188 (GtkSignalFunc) tabsborder_book,
189 GTK_OBJECT (notebook));
190 gtk_table_attach_defaults(GTK_TABLE(table), button, 4,5,1,2);
191 gtk_widget_show(button);
192
193 button = gtk_button_new_with_label ("remove page");
194 gtk_signal_connect (GTK_OBJECT (button), "clicked",
195 (GtkSignalFunc) remove_book,
196 GTK_OBJECT(notebook));
197 gtk_table_attach_defaults(GTK_TABLE(table), button, 5,6,1,2);
198 gtk_widget_show(button);
199
200 gtk_widget_show(table);
201 gtk_widget_show(window);
202
203 gtk_main ();
204
205 return(0);
206 }
207 /* example-end */