]>
git.saurik.com Git - wxWidgets.git/blob - misc/theme_test/test.c
4 /* This function rotates the position of the tabs */
5 void rotate_book (GtkButton
*button
, GtkNotebook
*notebook
)
7 gtk_notebook_set_tab_pos (notebook
, (notebook
->tab_pos
+1) %4
);
10 /* Add/Remove the page tabs and the borders */
11 void tabsborder_book (GtkButton
*button
, GtkNotebook
*notebook
)
15 if (notebook
->show_tabs
== 0)
17 if (notebook
->show_border
== 0)
20 gtk_notebook_set_show_tabs (notebook
, tval
);
21 gtk_notebook_set_show_border (notebook
, bval
);
24 /* Remove a page from the notebook */
25 void remove_book (GtkButton
*button
, GtkNotebook
*notebook
)
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
);
36 void delete (GtkWidget
*widget
, GtkWidget
*event
, gpointer data
)
41 void assign_new_style(GtkWidget
*widget
)
43 GtkStyle
*default_style
,*new_style
;
45 default_style
= gtk_rc_get_style( widget
);
48 default_style
= gtk_widget_get_default_style();
50 new_style
= gtk_style_copy( default_style
);
51 new_style
->engine_data
= default_style
->engine_data
;
52 new_style
->klass
= default_style
->klass
;
54 gtk_widget_set_style( widget
, new_style
);
58 int main (int argc
, char *argv
[])
67 gtk_init (&argc
, &argv
);
69 window
= gtk_window_new (GTK_WINDOW_TOPLEVEL
);
71 gtk_signal_connect (GTK_OBJECT (window
), "delete_event",
72 GTK_SIGNAL_FUNC (delete), NULL
);
74 gtk_container_set_border_width (GTK_CONTAINER (window
), 10);
76 table
= gtk_table_new(3,6,FALSE
);
77 gtk_container_add (GTK_CONTAINER (window
), table
);
79 /* Create a new notebook, place the position of the tabs */
80 notebook
= gtk_notebook_new ();
81 assign_new_style( notebook
);
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
);
87 /* Now finally let's prepend pages to the notebook */
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
);
94 label
= gtk_label_new ("label");
95 assign_new_style( label
);
96 gtk_container_add (GTK_CONTAINER (frame
), label
);
97 gtk_widget_show (label
);
99 label
= gtk_label_new ("page");
100 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), frame
, label
);
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
);
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
);
113 label
= gtk_label_new ("page");
114 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), frame
, label
);
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
);
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
);
128 label
= gtk_label_new ("page");
129 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), frame
, label
);
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
);
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
);
142 label
= gtk_label_new ("page");
143 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), frame
, label
);
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
);
151 label
= gtk_entry_new ();
152 assign_new_style( label
);
153 gtk_container_add (GTK_CONTAINER (frame
), label
);
154 gtk_widget_show (label
);
156 label
= gtk_label_new ("page");
157 gtk_notebook_append_page (GTK_NOTEBOOK (notebook
), frame
, label
);
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
);
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
);
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
);
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
);
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
);
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
);
200 gtk_widget_show(table
);
201 gtk_widget_show(window
);