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 // License: 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
*GetCheckButtonWidget()
69 static GtkWidget
*s_button
= NULL
;
73 s_button
= gtk_check_button_new();
74 gtk_container_add(GetContainer(), s_button
);
75 gtk_widget_realize(s_button
);
81 GtkWidget
*GetEntryWidget()
83 static GtkWidget
*s_entry
= NULL
;
87 s_entry
= gtk_entry_new();
88 gtk_container_add(GetContainer(), s_entry
);
89 gtk_widget_realize(s_entry
);
95 // This one just gets the button used by the column header. Although it's
96 // still a gtk_button the themes will typically differentiate and draw them
97 // differently if the button is in a treeview.
98 GtkWidget
*GetHeaderButtonWidget()
100 static GtkWidget
*s_button
= NULL
;
104 // Get the dummy tree widget, give it a column, and then use the
105 // widget in the column header for the rendering code.
106 GtkWidget
* treewidget
= GetTreeWidget();
107 GtkTreeViewColumn
*column
= gtk_tree_view_column_new();
108 gtk_tree_view_append_column(GTK_TREE_VIEW(treewidget
), column
);
109 s_button
= column
->button
;
115 GtkWidget
* GetSplitterWidget()
117 static GtkWidget
* widget
;
121 widget
= gtk_vpaned_new();
122 gtk_container_add(GetContainer(), widget
);
123 gtk_widget_realize(widget
);
129 GtkWidget
*GetTreeWidget()
131 static GtkWidget
*s_tree
= NULL
;
135 s_tree
= gtk_tree_view_new();
136 gtk_container_add(GetContainer(), s_tree
);
137 gtk_widget_realize(s_tree
);
144 // Module for destroying created widgets
145 class WidgetsCleanupModule
: public wxModule
148 virtual bool OnInit()
153 virtual void OnExit()
157 GtkWidget
* parent
= gtk_widget_get_parent(gs_container
);
158 gtk_widget_destroy(parent
);
162 DECLARE_DYNAMIC_CLASS(WidgetsCleanupModule
)
165 IMPLEMENT_DYNAMIC_CLASS(WidgetsCleanupModule
, wxModule
)
167 static WidgetsCleanupModule gs_widgetsCleanupModule
;
169 } // wxGTKPrivate namespace