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 
* GetComboBoxWidget() 
  83     static GtkWidget 
*s_button 
= NULL
; 
  84     static GtkWidget 
*s_window 
= NULL
; 
  88         s_window 
= gtk_window_new( GTK_WINDOW_POPUP 
); 
  89         gtk_widget_realize( s_window 
); 
  90         s_button 
= gtk_combo_box_new(); 
  91         gtk_container_add( GTK_CONTAINER(s_window
), s_button 
); 
  92         gtk_widget_realize( s_button 
); 
  99 GtkWidget 
*GetEntryWidget() 
 101     static GtkWidget 
*s_entry 
= NULL
; 
 105         s_entry 
= gtk_entry_new(); 
 106         gtk_container_add(GetContainer(), s_entry
); 
 107         gtk_widget_realize(s_entry
); 
 113 // This one just gets the button used by the column header. Although it's 
 114 // still a gtk_button the themes will typically differentiate and draw them 
 115 // differently if the button is in a treeview. 
 116 GtkWidget 
*GetHeaderButtonWidget() 
 118     static GtkWidget 
*s_button 
= NULL
; 
 122         // Get the dummy tree widget, give it a column, and then use the 
 123         // widget in the column header for the rendering code. 
 124         GtkWidget
* treewidget 
= GetTreeWidget(); 
 125         GtkTreeViewColumn 
*column 
= gtk_tree_view_column_new(); 
 126         gtk_tree_view_append_column(GTK_TREE_VIEW(treewidget
), column
); 
 127         s_button 
= column
->button
; 
 133 GtkWidget 
* GetRadioButtonWidget() 
 135     static GtkWidget 
*s_button 
= NULL
; 
 136     static GtkWidget 
*s_window 
= NULL
; 
 140         s_window 
= gtk_window_new( GTK_WINDOW_POPUP 
); 
 141         gtk_widget_realize( s_window 
); 
 142         s_button 
= gtk_radio_button_new(NULL
); 
 143         gtk_container_add( GTK_CONTAINER(s_window
), s_button 
); 
 144         gtk_widget_realize( s_button 
); 
 150 GtkWidget
* GetSplitterWidget() 
 152     static GtkWidget
* widget
; 
 156         widget 
= gtk_vpaned_new(); 
 157         gtk_container_add(GetContainer(), widget
); 
 158         gtk_widget_realize(widget
); 
 164 GtkWidget 
* GetTextEntryWidget() 
 166     static GtkWidget 
*s_button 
= NULL
; 
 167     static GtkWidget 
*s_window 
= NULL
; 
 171         s_window 
= gtk_window_new( GTK_WINDOW_POPUP 
); 
 172         gtk_widget_realize( s_window 
); 
 173         s_button 
= gtk_entry_new(); 
 174         gtk_container_add( GTK_CONTAINER(s_window
), s_button 
); 
 175         gtk_widget_realize( s_button 
); 
 181 GtkWidget 
*GetTreeWidget() 
 183     static GtkWidget 
*s_tree 
= NULL
; 
 187         s_tree 
= gtk_tree_view_new(); 
 188         gtk_container_add(GetContainer(), s_tree
); 
 189         gtk_widget_realize(s_tree
); 
 196 // Module for destroying created widgets 
 197 class WidgetsCleanupModule 
: public wxModule
 
 200     virtual bool OnInit() 
 205     virtual void OnExit() 
 209             GtkWidget
* parent 
= gtk_widget_get_parent(gs_container
); 
 210             gtk_widget_destroy(parent
); 
 214     DECLARE_DYNAMIC_CLASS(WidgetsCleanupModule
) 
 217 IMPLEMENT_DYNAMIC_CLASS(WidgetsCleanupModule
, wxModule
) 
 219 static WidgetsCleanupModule gs_widgetsCleanupModule
; 
 221 } // wxGTKPrivate namespace