]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: frame.cpp | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
5 | // Created: 01/02/97 | |
6 | // Id: | |
7 | // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem | |
19717c50 | 8 | // Licence: wxWindows licence |
c801d85f KB |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
11 | #ifdef __GNUG__ | |
12 | #pragma implementation "frame.h" | |
13 | #endif | |
14 | ||
15 | #include "wx/frame.h" | |
16 | #include "wx/dialog.h" | |
17 | #include "wx/control.h" | |
18 | #include "wx/app.h" | |
cf4219e7 RR |
19 | #include "wx/menu.h" |
20 | #include "wx/toolbar.h" | |
21 | #include "wx/statusbr.h" | |
d4c99d6f | 22 | #include "wx/mdi.h" |
362c6693 | 23 | #include "wx/dcclient.h" |
c801d85f KB |
24 | #include "wx/gtk/win_gtk.h" |
25 | ||
26 | const wxMENU_HEIGHT = 28; | |
27 | const wxSTATUS_HEIGHT = 25; | |
28 | ||
29 | extern wxList wxTopLevelWindows; | |
30 | extern wxList wxPendingDelete; | |
31 | ||
32 | //----------------------------------------------------------------------------- | |
33 | // wxFrame | |
34 | //----------------------------------------------------------------------------- | |
35 | ||
36 | //----------------------------------------------------------------------------- | |
47908e25 | 37 | // set size |
c801d85f KB |
38 | |
39 | void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win ) | |
ed7a557b | 40 | { |
c801d85f KB |
41 | if (!win->HasVMT()) return; |
42 | ||
43 | /* | |
44 | printf( "OnFrameResize from " ); | |
45 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) | |
46 | printf( win->GetClassInfo()->GetClassName() ); | |
47 | printf( ".\n" ); | |
48 | */ | |
ed7a557b | 49 | |
219f895a | 50 | win->GtkOnSize( alloc->x, alloc->y, alloc->width, alloc->height ); |
362c6693 | 51 | } |
c801d85f KB |
52 | |
53 | //----------------------------------------------------------------------------- | |
54 | // delete | |
55 | ||
56 | bool gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxFrame *win ) | |
ed7a557b | 57 | { |
c801d85f KB |
58 | /* |
59 | printf( "OnDelete from " ); | |
60 | if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) | |
61 | printf( win->GetClassInfo()->GetClassName() ); | |
62 | printf( ".\n" ); | |
63 | */ | |
ed7a557b | 64 | |
c801d85f KB |
65 | win->Close(); |
66 | ||
67 | return TRUE; | |
362c6693 | 68 | } |
c801d85f | 69 | |
47908e25 RR |
70 | //----------------------------------------------------------------------------- |
71 | // configure | |
72 | ||
73 | gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win ) | |
74 | { | |
75 | if (!win->HasVMT()) return FALSE; | |
76 | ||
77 | win->m_x = event->x; | |
78 | win->m_y = event->y; | |
79 | ||
80 | return FALSE; | |
362c6693 | 81 | } |
47908e25 | 82 | |
c801d85f KB |
83 | //----------------------------------------------------------------------------- |
84 | ||
85 | BEGIN_EVENT_TABLE(wxFrame, wxWindow) | |
c801d85f | 86 | EVT_SIZE(wxFrame::OnSize) |
716b7364 | 87 | EVT_CLOSE(wxFrame::OnCloseWindow) |
e2414cbe | 88 | EVT_IDLE(wxFrame::OnIdle) |
c801d85f KB |
89 | END_EVENT_TABLE() |
90 | ||
91 | IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow) | |
92 | ||
19717c50 | 93 | wxFrame::wxFrame() |
c801d85f | 94 | { |
c801d85f KB |
95 | m_frameMenuBar = NULL; |
96 | m_frameStatusBar = NULL; | |
46dc76ba | 97 | m_frameToolBar = NULL; |
c801d85f | 98 | m_sizeSet = FALSE; |
46dc76ba | 99 | m_addPrivateChild = FALSE; |
cf4219e7 RR |
100 | m_wxwindow = NULL; |
101 | m_mainWindow = NULL; | |
c801d85f | 102 | wxTopLevelWindows.Insert( this ); |
362c6693 | 103 | } |
c801d85f | 104 | |
ed7a557b | 105 | wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, |
debe6624 JS |
106 | const wxPoint &pos, const wxSize &size, |
107 | long style, const wxString &name ) | |
c801d85f | 108 | { |
46dc76ba RR |
109 | m_frameMenuBar = NULL; |
110 | m_frameStatusBar = NULL; | |
111 | m_frameToolBar = NULL; | |
c801d85f | 112 | m_sizeSet = FALSE; |
46dc76ba | 113 | m_addPrivateChild = FALSE; |
cf4219e7 RR |
114 | m_wxwindow = NULL; |
115 | m_mainWindow = NULL; | |
c801d85f KB |
116 | Create( parent, id, title, pos, size, style, name ); |
117 | wxTopLevelWindows.Insert( this ); | |
362c6693 | 118 | } |
c801d85f | 119 | |
debe6624 | 120 | bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, |
c801d85f | 121 | const wxPoint &pos, const wxSize &size, |
debe6624 | 122 | long style, const wxString &name ) |
c801d85f KB |
123 | { |
124 | m_needParent = FALSE; | |
ed7a557b | 125 | |
c801d85f KB |
126 | PreCreation( parent, id, pos, size, style, name ); |
127 | ||
c801d85f | 128 | m_title = title; |
ed7a557b | 129 | |
c801d85f | 130 | m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL ); |
ed7a557b | 131 | if ((size.x != -1) && (size.y != -1)) |
c801d85f | 132 | gtk_widget_set_usize( m_widget, m_width, m_height ); |
ed7a557b | 133 | if ((pos.x != -1) && (pos.y != -1)) |
c801d85f | 134 | gtk_widget_set_uposition( m_widget, m_x, m_y ); |
ed7a557b | 135 | |
c801d85f KB |
136 | gtk_window_set_title( GTK_WINDOW(m_widget), title ); |
137 | GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); | |
ed7a557b | 138 | |
c801d85f | 139 | gtk_widget_set( m_widget, "GtkWindow::allow_shrink", TRUE, NULL); |
ed7a557b VZ |
140 | |
141 | gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", | |
c801d85f | 142 | GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this ); |
ed7a557b | 143 | |
c801d85f KB |
144 | m_mainWindow = gtk_myfixed_new(); |
145 | gtk_widget_show( m_mainWindow ); | |
146 | GTK_WIDGET_UNSET_FLAGS( m_mainWindow, GTK_CAN_FOCUS ); | |
ed7a557b | 147 | |
c801d85f KB |
148 | gtk_container_add( GTK_CONTAINER(m_widget), m_mainWindow ); |
149 | gtk_widget_set_uposition( m_mainWindow, 0, 0 ); | |
ed7a557b | 150 | |
c801d85f KB |
151 | m_wxwindow = gtk_myfixed_new(); |
152 | gtk_widget_show( m_wxwindow ); | |
153 | GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); | |
ed7a557b | 154 | |
c801d85f | 155 | gtk_container_add( GTK_CONTAINER(m_mainWindow), m_wxwindow ); |
ed7a557b | 156 | |
ed7a557b | 157 | gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", |
c801d85f | 158 | GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); |
ed7a557b | 159 | |
47908e25 RR |
160 | gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", |
161 | GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this ); | |
162 | ||
c801d85f | 163 | PostCreation(); |
ed7a557b | 164 | |
c801d85f | 165 | gtk_widget_realize( m_mainWindow ); |
ed7a557b | 166 | |
c801d85f | 167 | return TRUE; |
362c6693 | 168 | } |
c801d85f | 169 | |
19717c50 | 170 | wxFrame::~wxFrame() |
c801d85f KB |
171 | { |
172 | if (m_frameMenuBar) delete m_frameMenuBar; | |
173 | if (m_frameStatusBar) delete m_frameStatusBar; | |
ed7a557b | 174 | |
c801d85f KB |
175 | // if (m_mainWindow) gtk_widget_destroy( m_mainWindow ); |
176 | ||
177 | wxTopLevelWindows.DeleteObject( this ); | |
178 | if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop(); | |
362c6693 | 179 | } |
ed7a557b | 180 | |
debe6624 | 181 | bool wxFrame::Show( bool show ) |
c801d85f KB |
182 | { |
183 | if (show) | |
184 | { | |
185 | wxSizeEvent event( wxSize(m_width,m_height), GetId() ); | |
186 | m_sizeSet = FALSE; | |
187 | ProcessEvent( event ); | |
362c6693 | 188 | } |
c801d85f | 189 | return wxWindow::Show( show ); |
362c6693 | 190 | } |
c801d85f | 191 | |
debe6624 | 192 | void wxFrame::Enable( bool enable ) |
c801d85f KB |
193 | { |
194 | wxWindow::Enable( enable ); | |
195 | gtk_widget_set_sensitive( m_mainWindow, enable ); | |
362c6693 | 196 | } |
c801d85f | 197 | |
716b7364 | 198 | void wxFrame::OnCloseWindow( wxCloseEvent &event ) |
c801d85f | 199 | { |
716b7364 RR |
200 | if ( GetEventHandler()->OnClose() || event.GetForce()) |
201 | { | |
202 | this->Destroy(); | |
203 | } | |
362c6693 | 204 | } |
c801d85f | 205 | |
19717c50 | 206 | bool wxFrame::Destroy() |
c801d85f KB |
207 | { |
208 | if (!wxPendingDelete.Member(this)) | |
209 | wxPendingDelete.Append(this); | |
ed7a557b | 210 | |
c801d85f KB |
211 | return TRUE; |
212 | } | |
213 | ||
903f689b RR |
214 | void wxFrame::ImplementSetPosition(void) |
215 | { | |
216 | if ((m_x != -1) || (m_y != -1)) | |
217 | gtk_widget_set_uposition( m_widget, m_x, m_y ); | |
218 | } | |
219 | ||
220 | void wxFrame::Centre( int direction ) | |
221 | { | |
222 | if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2; | |
223 | if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2; | |
224 | ImplementSetPosition(); | |
225 | } | |
226 | ||
c801d85f KB |
227 | void wxFrame::GetClientSize( int *width, int *height ) const |
228 | { | |
229 | wxWindow::GetClientSize( width, height ); | |
230 | if (height) | |
231 | { | |
232 | if (m_frameMenuBar) (*height) -= wxMENU_HEIGHT; | |
233 | if (m_frameStatusBar) (*height) -= wxSTATUS_HEIGHT; | |
46dc76ba RR |
234 | if (m_frameToolBar) |
235 | { | |
236 | int y = 0; | |
237 | m_frameToolBar->GetSize( NULL, &y ); | |
238 | (*height) -= y; | |
239 | } | |
362c6693 RR |
240 | } |
241 | } | |
c801d85f | 242 | |
b593568e RR |
243 | void wxFrame::SetClientSize( int const width, int const height ) |
244 | { | |
245 | int h = height; | |
246 | if (m_frameMenuBar) h += wxMENU_HEIGHT; | |
247 | if (m_frameStatusBar) h += wxSTATUS_HEIGHT; | |
248 | if (m_frameToolBar) | |
249 | { | |
250 | int y = 0; | |
251 | m_frameToolBar->GetSize( NULL, &y ); | |
252 | h += y; | |
253 | } | |
254 | wxWindow::SetClientSize( width, h ); | |
362c6693 | 255 | } |
b593568e | 256 | |
47908e25 | 257 | void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height ) |
c801d85f | 258 | { |
47908e25 RR |
259 | // due to a bug in gtk, x,y are always 0 |
260 | // m_x = x; | |
261 | // m_y = y; | |
219f895a | 262 | |
c801d85f KB |
263 | if ((m_height == height) && (m_width == width) && |
264 | (m_sizeSet)) return; | |
265 | if (!m_mainWindow) return; | |
266 | if (!m_wxwindow) return; | |
267 | ||
268 | m_width = width; | |
269 | m_height = height; | |
ed7a557b | 270 | |
c801d85f | 271 | gtk_widget_set_usize( m_widget, width, height ); |
ed7a557b | 272 | |
c801d85f KB |
273 | int main_x = 0; |
274 | int main_y = 0; | |
275 | int main_height = height; | |
276 | int main_width = width; | |
ed7a557b | 277 | |
c801d85f KB |
278 | // This emulates Windows behaviour: |
279 | // The menu bar is part of the main window, but the status bar | |
280 | // is on the implementation side in the client area. The | |
281 | // function GetClientSize returns the size of the client area | |
282 | // minus the status bar height. Under wxGTK, the main window | |
283 | // is represented by m_mainWindow. The menubar is inserted | |
284 | // into m_mainWindow whereas the statusbar is insertes into | |
285 | // m_wxwindow just like any other window. | |
ed7a557b | 286 | |
c801d85f | 287 | // not really needed |
47908e25 | 288 | // gtk_widget_set_usize( m_mainWindow, width, height ); |
ed7a557b | 289 | |
c801d85f KB |
290 | if (m_frameMenuBar) |
291 | { | |
292 | main_y = wxMENU_HEIGHT; | |
293 | main_height -= wxMENU_HEIGHT; | |
362c6693 | 294 | } |
ed7a557b | 295 | |
46dc76ba RR |
296 | int toolbar_height = 0; |
297 | if (m_frameToolBar) m_frameToolBar->GetSize( NULL, &toolbar_height ); | |
298 | ||
299 | main_y += toolbar_height; | |
300 | main_height -= toolbar_height; | |
301 | ||
d4c99d6f RR |
302 | gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_wxwindow, main_x, main_y ); |
303 | gtk_widget_set_usize( m_wxwindow, main_width, main_height ); | |
ed7a557b | 304 | |
c801d85f KB |
305 | if (m_frameMenuBar) |
306 | { | |
d4c99d6f | 307 | gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameMenuBar->m_widget, 1, 1 ); |
c801d85f | 308 | gtk_widget_set_usize( m_frameMenuBar->m_widget, width-2, wxMENU_HEIGHT-2 ); |
362c6693 | 309 | } |
ed7a557b | 310 | |
46dc76ba RR |
311 | if (m_frameToolBar) |
312 | { | |
d4c99d6f | 313 | gtk_myfixed_move( GTK_MYFIXED(m_mainWindow), m_frameToolBar->m_widget, 1, wxMENU_HEIGHT ); |
46dc76ba | 314 | gtk_widget_set_usize( m_frameToolBar->m_widget, width-2, toolbar_height ); |
362c6693 | 315 | } |
46dc76ba | 316 | |
c801d85f KB |
317 | if (m_frameStatusBar) |
318 | { | |
319 | m_frameStatusBar->SetSize( 0, main_height-wxSTATUS_HEIGHT, width, wxSTATUS_HEIGHT ); | |
362c6693 | 320 | } |
c801d85f KB |
321 | |
322 | m_sizeSet = TRUE; | |
ed7a557b | 323 | |
c801d85f KB |
324 | wxSizeEvent event( wxSize(m_width,m_height), GetId() ); |
325 | event.SetEventObject( this ); | |
326 | ProcessEvent( event ); | |
362c6693 | 327 | } |
c801d85f KB |
328 | |
329 | void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) | |
330 | { | |
ed7a557b VZ |
331 | if ( GetAutoLayout() ) |
332 | Layout(); | |
333 | else { | |
cf5f9c9c GL |
334 | // no child: go out ! |
335 | if (!GetChildren()->First()) | |
336 | return; | |
46dc76ba | 337 | |
ed7a557b VZ |
338 | // do we have exactly one child? |
339 | wxWindow *child = NULL; | |
340 | for(wxNode *node = GetChildren()->First(); node; node = node->Next()) | |
c801d85f | 341 | { |
ed7a557b | 342 | wxWindow *win = (wxWindow *)node->Data(); |
e3e65dac | 343 | if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog) |
46dc76ba | 344 | #if 0 // not in m_children anyway |
ed7a557b | 345 | && (win != m_frameMenuBar) && |
46dc76ba | 346 | (win != m_frameToolBar) && |
ed7a557b VZ |
347 | (win != m_frameStatusBar) |
348 | #endif | |
349 | ) | |
350 | { | |
351 | if ( child ) // it's the second one: do nothing | |
352 | return; | |
353 | ||
354 | child = win; | |
362c6693 RR |
355 | } |
356 | } | |
c801d85f | 357 | |
ed7a557b | 358 | // yes: set it's size to fill all the frame |
c801d85f | 359 | int client_x, client_y; |
c801d85f | 360 | GetClientSize(&client_x, &client_y); |
c801d85f KB |
361 | child->SetSize( 1, 1, client_x-2, client_y); |
362 | } | |
362c6693 | 363 | } |
c801d85f | 364 | |
46dc76ba RR |
365 | void wxFrame::AddChild( wxWindow *child ) |
366 | { | |
e3e65dac RR |
367 | // wxFrame and wxDialog as children aren't placed into the parents |
368 | ||
d4c99d6f RR |
369 | if (IS_KIND_OF(child,wxMDIChildFrame)) printf( "wxFrame::AddChild error.\n" ); |
370 | ||
371 | if ( IS_KIND_OF(child,wxFrame) || IS_KIND_OF(child,wxDialog)) | |
e3e65dac RR |
372 | { |
373 | m_children.Append( child ); | |
374 | ||
375 | if ((child->m_x != -1) && (child->m_y != -1)) | |
376 | gtk_widget_set_uposition( child->m_widget, child->m_x, child->m_y ); | |
377 | ||
378 | return; | |
379 | } | |
380 | ||
46dc76ba RR |
381 | if (m_addPrivateChild) |
382 | { | |
383 | gtk_myfixed_put( GTK_MYFIXED(m_mainWindow), child->m_widget, child->m_x, child->m_y ); | |
384 | ||
385 | gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height ); | |
386 | } | |
387 | else | |
388 | { | |
389 | m_children.Append( child ); | |
390 | ||
391 | if (m_wxwindow) | |
392 | gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), child->m_widget, child->m_x, child->m_y ); | |
393 | ||
394 | gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height ); | |
395 | } | |
362c6693 | 396 | } |
46dc76ba | 397 | |
716b7364 | 398 | static void SetInvokingWindow( wxMenu *menu, wxWindow *win ) |
c801d85f KB |
399 | { |
400 | menu->SetInvokingWindow( win ); | |
401 | wxNode *node = menu->m_items.First(); | |
402 | while (node) | |
403 | { | |
404 | wxMenuItem *menuitem = (wxMenuItem*)node->Data(); | |
19717c50 VZ |
405 | if (menuitem->IsSubMenu()) |
406 | SetInvokingWindow( menuitem->GetSubMenu(), win ); | |
c801d85f | 407 | node = node->Next(); |
362c6693 RR |
408 | } |
409 | } | |
c801d85f KB |
410 | |
411 | void wxFrame::SetMenuBar( wxMenuBar *menuBar ) | |
412 | { | |
413 | m_frameMenuBar = menuBar; | |
716b7364 RR |
414 | |
415 | if (m_frameMenuBar) | |
c801d85f | 416 | { |
30dea054 RR |
417 | wxNode *node = m_frameMenuBar->m_menus.First(); |
418 | while (node) | |
419 | { | |
420 | wxMenu *menu = (wxMenu*)node->Data(); | |
421 | SetInvokingWindow( menu, this ); | |
422 | node = node->Next(); | |
362c6693 | 423 | } |
30dea054 | 424 | |
716b7364 RR |
425 | if (m_frameMenuBar->m_parent != this) |
426 | { | |
716b7364 RR |
427 | m_frameMenuBar->m_parent = this; |
428 | gtk_myfixed_put( GTK_MYFIXED(m_mainWindow), | |
429 | m_frameMenuBar->m_widget, m_frameMenuBar->m_x, m_frameMenuBar->m_y ); | |
430 | } | |
431 | } | |
362c6693 | 432 | } |
c801d85f | 433 | |
362c6693 | 434 | wxMenuBar *wxFrame::GetMenuBar(void) const |
46dc76ba RR |
435 | { |
436 | return m_frameMenuBar; | |
362c6693 | 437 | } |
46dc76ba | 438 | |
362c6693 | 439 | wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) |
46dc76ba | 440 | { |
362c6693 RR |
441 | wxCHECK_MSG( m_frameToolBar == NULL, FALSE, "recreating toolbar in wxFrame" ); |
442 | ||
46dc76ba | 443 | m_addPrivateChild = TRUE; |
362c6693 | 444 | m_frameToolBar = OnCreateToolBar( style, id, name ); |
46dc76ba RR |
445 | m_addPrivateChild = FALSE; |
446 | ||
447 | return m_frameToolBar; | |
362c6693 | 448 | } |
46dc76ba | 449 | |
362c6693 | 450 | wxToolBar* wxFrame::OnCreateToolBar( long style, wxWindowID id, const wxString& name ) |
46dc76ba | 451 | { |
362c6693 RR |
452 | return new wxToolBar( this, id, wxDefaultPosition, wxDefaultSize, style, name ); |
453 | } | |
454 | ||
455 | wxToolBar *wxFrame::GetToolBar(void) const | |
456 | { | |
457 | return m_frameToolBar; | |
458 | } | |
46dc76ba | 459 | |
e3e65dac | 460 | wxStatusBar* wxFrame::CreateStatusBar( int number, long style, wxWindowID id, const wxString& name ) |
c801d85f | 461 | { |
362c6693 | 462 | wxCHECK_MSG( m_frameStatusBar == NULL, FALSE, "recreating status bar in wxFrame" ); |
c801d85f | 463 | |
362c6693 | 464 | m_frameStatusBar = OnCreateStatusBar( number, style, id, name ); |
e3e65dac RR |
465 | |
466 | return m_frameStatusBar; | |
362c6693 RR |
467 | } |
468 | ||
469 | wxStatusBar *wxFrame::OnCreateStatusBar( int number, long style, wxWindowID id, const wxString& name ) | |
470 | { | |
471 | wxStatusBar *statusBar = NULL; | |
472 | ||
473 | statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 20), style, name); | |
474 | ||
475 | // Set the height according to the font and the border size | |
476 | wxClientDC dc(statusBar); | |
477 | dc.SetFont( *statusBar->GetFont() ); | |
478 | ||
479 | long x, y; | |
480 | dc.GetTextExtent( "X", &x, &y ); | |
481 | ||
482 | int height = (int)( (y * 1.1) + 2* statusBar->GetBorderY()); | |
483 | ||
484 | statusBar->SetSize( -1, -1, 100, height ); | |
485 | ||
486 | statusBar->SetFieldsCount( number ); | |
487 | return statusBar; | |
488 | } | |
c801d85f | 489 | |
362c6693 | 490 | void wxFrame::SetStatusText(const wxString& text, int number) |
c801d85f | 491 | { |
362c6693 | 492 | wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set text for" ); |
c801d85f | 493 | |
362c6693 RR |
494 | m_frameStatusBar->SetStatusText(text, number); |
495 | } | |
496 | ||
497 | void wxFrame::SetStatusWidths(int n, const int widths_field[] ) | |
c801d85f | 498 | { |
362c6693 RR |
499 | wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set widths for" ); |
500 | ||
501 | m_frameStatusBar->SetStatusWidths(n, widths_field); | |
502 | } | |
c801d85f | 503 | |
362c6693 | 504 | wxStatusBar *wxFrame::GetStatusBar(void) const |
c801d85f KB |
505 | { |
506 | return m_frameStatusBar; | |
362c6693 | 507 | } |
c801d85f | 508 | |
c801d85f KB |
509 | void wxFrame::SetTitle( const wxString &title ) |
510 | { | |
511 | m_title = title; | |
362c6693 | 512 | if (m_title.IsNull()) m_title = ""; |
c801d85f | 513 | gtk_window_set_title( GTK_WINDOW(m_widget), title ); |
362c6693 | 514 | } |
c801d85f | 515 | |
46dc76ba | 516 | void wxFrame::SetSizeHints(int minW, int minH, int maxW, int maxH, int WXUNUSED(incW) ) |
c801d85f | 517 | { |
46dc76ba RR |
518 | if (m_wxwindow) |
519 | gdk_window_set_hints( m_wxwindow->window, -1, -1, | |
520 | minW, minH, maxW, maxH, GDK_HINT_MIN_SIZE | GDK_HINT_MIN_SIZE ); | |
e2414cbe | 521 | } |
d355d3fe RR |
522 | |
523 | void wxFrame::SetIcon( const wxIcon &icon ) | |
524 | { | |
525 | m_icon = icon; | |
526 | if (!icon.Ok()) return; | |
527 | ||
528 | wxMask *mask = icon.GetMask(); | |
529 | GdkBitmap *bm = NULL; | |
530 | if (mask) bm = mask->GetBitmap(); | |
531 | ||
532 | gdk_window_set_icon( m_widget->window, NULL, icon.GetPixmap(), bm ); | |
533 | } | |
534 |