]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/private.cpp
don't use deprecated toolbar API
[wxWidgets.git] / src / gtk / private.cpp
CommitLineData
e8759560
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: src/gtk/private.cpp
3// Purpose: implementation of wxGTK private functions
4// Author: Marcin Malich
5// Modified by:
6// Created: 28.06.2008
7// RCS-ID: $Id$
8// Copyright: (c) 2008 Marcin Malich <me@malcom.pl>
9// License: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20// for compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
27#ifndef WX_PRECOMP
28 #include "wx/module.h"
29#endif
30
31#include "wx/gtk/private.h"
32
33// ----------------------------------------------------------------------------
34// wxGTKPrivate functions implementation
35// ----------------------------------------------------------------------------
36
37namespace wxGTKPrivate
38{
39
40static GtkWidget *gs_container = NULL;
41
42static GtkContainer* GetContainer()
43{
44 if ( gs_container == NULL )
45 {
46 GtkWidget* window = gtk_window_new(GTK_WINDOW_POPUP);
47 gs_container = gtk_fixed_new();
48 gtk_container_add(GTK_CONTAINER(window), gs_container);
49 }
50 return GTK_CONTAINER(gs_container);
51}
52
53GtkWidget *GetButtonWidget()
54{
55 static GtkWidget *s_button = NULL;
56
57 if ( !s_button )
58 {
59 s_button = gtk_button_new();
60 gtk_container_add(GetContainer(), s_button);
61 gtk_widget_realize(s_button);
62 }
63
64 return s_button;
65}
66
67GtkWidget *GetCheckButtonWidget()
68{
69 static GtkWidget *s_button = NULL;
70
71 if ( !s_button )
72 {
73 s_button = gtk_check_button_new();
74 gtk_container_add(GetContainer(), s_button);
75 gtk_widget_realize(s_button);
76 }
77
78 return s_button;
79}
80
81GtkWidget *GetEntryWidget()
82{
83 static GtkWidget *s_entry = NULL;
84
85 if ( !s_entry )
86 {
87 s_entry = gtk_entry_new();
88 gtk_container_add(GetContainer(), s_entry);
89 gtk_widget_realize(s_entry);
90 }
91
92 return s_entry;
93}
94
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.
98GtkWidget *GetHeaderButtonWidget()
99{
100 static GtkWidget *s_button = NULL;
101
102 if ( !s_button )
103 {
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;
110 }
111
112 return s_button;
113}
114
115GtkWidget* GetSplitterWidget()
116{
117 static GtkWidget* widget;
118
119 if (widget == NULL)
120 {
121 widget = gtk_vpaned_new();
122 gtk_container_add(GetContainer(), widget);
123 gtk_widget_realize(widget);
124 }
125
126 return widget;
127}
128
129GtkWidget *GetTreeWidget()
130{
131 static GtkWidget *s_tree = NULL;
132
133 if ( !s_tree )
134 {
135 s_tree = gtk_tree_view_new();
136 gtk_container_add(GetContainer(), s_tree);
137 gtk_widget_realize(s_tree);
138 }
139
140 return s_tree;
141}
142
143
144// Module for destroying created widgets
145class WidgetsCleanupModule : public wxModule
146{
147public:
148 virtual bool OnInit()
149 {
150 return true;
151 }
152
153 virtual void OnExit()
154 {
155 if ( gs_container )
156 {
157 GtkWidget* parent = gtk_widget_get_parent(gs_container);
158 gtk_widget_destroy(parent);
159 }
160 }
161
162 DECLARE_DYNAMIC_CLASS(WidgetsCleanupModule)
163};
164
165IMPLEMENT_DYNAMIC_CLASS(WidgetsCleanupModule, wxModule)
166
167static WidgetsCleanupModule gs_widgetsCleanupModule;
168
169} // wxGTKPrivate namespace