1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/private.cpp
3 // Purpose: implementation of wxGTK private functions
4 // Author: Marcin Malich
8 // Copyright: (c) 2008 Marcin Malich <me@malcom.pl>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // for compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
28 #include "wx/module.h"
31 #include "wx/gtk/private.h"
33 // ----------------------------------------------------------------------------
34 // wxGTKPrivate functions implementation
35 // ----------------------------------------------------------------------------
37 namespace wxGTKPrivate
40 static GtkWidget
*gs_container
= NULL
;
42 static GtkContainer
* GetContainer()
44 if ( gs_container
== NULL
)
46 GtkWidget
* window
= gtk_window_new(GTK_WINDOW_POPUP
);
47 gs_container
= gtk_fixed_new();
48 gtk_container_add(GTK_CONTAINER(window
), gs_container
);
50 return GTK_CONTAINER(gs_container
);
53 GtkWidget
*GetButtonWidget()
55 static GtkWidget
*s_button
= NULL
;
59 s_button
= gtk_button_new();
60 gtk_container_add(GetContainer(), s_button
);
61 gtk_widget_realize(s_button
);
67 GtkWidget
*GetNotebookWidget()
69 static GtkWidget
*s_notebook
= NULL
;
73 s_notebook
= gtk_notebook_new();
74 gtk_container_add(GetContainer(), s_notebook
);
75 gtk_widget_realize(s_notebook
);
81 GtkWidget
*GetCheckButtonWidget()
83 static GtkWidget
*s_button
= NULL
;
87 s_button
= gtk_check_button_new();
88 gtk_container_add(GetContainer(), s_button
);
89 gtk_widget_realize(s_button
);
95 GtkWidget
* GetComboBoxWidget()
97 static GtkWidget
*s_button
= NULL
;
98 static GtkWidget
*s_window
= NULL
;
102 s_window
= gtk_window_new( GTK_WINDOW_POPUP
);
103 gtk_widget_realize( s_window
);
104 s_button
= gtk_combo_box_new();
105 gtk_container_add( GTK_CONTAINER(s_window
), s_button
);
106 gtk_widget_realize( s_button
);
113 GtkWidget
*GetEntryWidget()
115 static GtkWidget
*s_entry
= NULL
;
119 s_entry
= gtk_entry_new();
120 gtk_container_add(GetContainer(), s_entry
);
121 gtk_widget_realize(s_entry
);
127 // This one just gets the button used by the column header. Although it's
128 // still a gtk_button the themes will typically differentiate and draw them
129 // differently if the button is in a treeview.
130 static GtkWidget
*s_first_button
= NULL
;
131 static GtkWidget
*s_other_button
= NULL
;
132 static GtkWidget
*s_last_button
= NULL
;
134 static void CreateHeaderButtons()
136 // Get the dummy tree widget, give it a column, and then use the
137 // widget in the column header for the rendering code.
138 GtkWidget
* treewidget
= GetTreeWidget();
140 GtkTreeViewColumn
*column
= gtk_tree_view_column_new();
141 gtk_tree_view_append_column(GTK_TREE_VIEW(treewidget
), column
);
142 s_first_button
= column
->button
;
144 column
= gtk_tree_view_column_new();
145 gtk_tree_view_append_column(GTK_TREE_VIEW(treewidget
), column
);
146 s_other_button
= column
->button
;
148 column
= gtk_tree_view_column_new();
149 gtk_tree_view_append_column(GTK_TREE_VIEW(treewidget
), column
);
150 s_last_button
= column
->button
;
153 GtkWidget
*GetHeaderButtonWidgetFirst()
156 CreateHeaderButtons();
158 return s_first_button
;
161 GtkWidget
*GetHeaderButtonWidgetLast()
164 CreateHeaderButtons();
166 return s_last_button
;
169 GtkWidget
*GetHeaderButtonWidget()
172 CreateHeaderButtons();
174 return s_other_button
;
177 GtkWidget
* GetRadioButtonWidget()
179 static GtkWidget
*s_button
= NULL
;
180 static GtkWidget
*s_window
= NULL
;
184 s_window
= gtk_window_new( GTK_WINDOW_POPUP
);
185 gtk_widget_realize( s_window
);
186 s_button
= gtk_radio_button_new(NULL
);
187 gtk_container_add( GTK_CONTAINER(s_window
), s_button
);
188 gtk_widget_realize( s_button
);
194 GtkWidget
* GetSplitterWidget()
196 static GtkWidget
* widget
;
200 widget
= gtk_vpaned_new();
201 gtk_container_add(GetContainer(), widget
);
202 gtk_widget_realize(widget
);
208 GtkWidget
* GetTextEntryWidget()
210 static GtkWidget
*s_button
= NULL
;
211 static GtkWidget
*s_window
= NULL
;
215 s_window
= gtk_window_new( GTK_WINDOW_POPUP
);
216 gtk_widget_realize( s_window
);
217 s_button
= gtk_entry_new();
218 gtk_container_add( GTK_CONTAINER(s_window
), s_button
);
219 gtk_widget_realize( s_button
);
225 GtkWidget
*GetTreeWidget()
227 static GtkWidget
*s_tree
= NULL
;
231 s_tree
= gtk_tree_view_new();
232 gtk_container_add(GetContainer(), s_tree
);
233 gtk_widget_realize(s_tree
);
240 // Module for destroying created widgets
241 class WidgetsCleanupModule
: public wxModule
244 virtual bool OnInit()
249 virtual void OnExit()
253 GtkWidget
* parent
= gtk_widget_get_parent(gs_container
);
254 gtk_widget_destroy(parent
);
258 DECLARE_DYNAMIC_CLASS(WidgetsCleanupModule
)
261 IMPLEMENT_DYNAMIC_CLASS(WidgetsCleanupModule
, wxModule
)
263 static WidgetsCleanupModule gs_widgetsCleanupModule
;
265 } // wxGTKPrivate namespace