~ubuntu-branches/ubuntu/raring/wxwidgets2.8/raring

« back to all changes in this revision

Viewing changes to .pc/appmenu.patch/src/gtk/frame.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2011-02-19 20:17:05 UTC
  • Revision ID: james.westby@ubuntu.com-20110219201705-cvs2fpdukq5tujlr
Tags: 2.8.11.0-0ubuntu7
Apply appmenu.patch to get menus back (LP: #662077).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/////////////////////////////////////////////////////////////////////////////
 
2
// Name:        src/gtk/frame.cpp
 
3
// Purpose:
 
4
// Author:      Robert Roebling
 
5
// Id:          $Id: frame.cpp 62616 2009-11-11 18:04:09Z PC $
 
6
// Copyright:   (c) 1998 Robert Roebling
 
7
// Licence:     wxWindows licence
 
8
/////////////////////////////////////////////////////////////////////////////
 
9
 
 
10
// For compilers that support precompilation, includes "wx.h".
 
11
#include "wx/wxprec.h"
 
12
 
 
13
#include "wx/frame.h"
 
14
 
 
15
#ifndef WX_PRECOMP
 
16
    #include "wx/menu.h"
 
17
    #include "wx/toolbar.h"
 
18
    #include "wx/statusbr.h"
 
19
#endif // WX_PRECOMP
 
20
 
 
21
#include "wx/gtk/private.h"
 
22
#include "wx/gtk/win_gtk.h"
 
23
 
 
24
// ----------------------------------------------------------------------------
 
25
// constants
 
26
// ----------------------------------------------------------------------------
 
27
 
 
28
static const int wxSTATUS_HEIGHT  = 25;
 
29
static const int wxPLACE_HOLDER   = 0;
 
30
 
 
31
// ----------------------------------------------------------------------------
 
32
// event tables
 
33
// ----------------------------------------------------------------------------
 
34
 
 
35
IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
 
36
 
 
37
// ============================================================================
 
38
// implementation
 
39
// ============================================================================
 
40
 
 
41
// ----------------------------------------------------------------------------
 
42
// GTK callbacks
 
43
// ----------------------------------------------------------------------------
 
44
 
 
45
#if wxUSE_MENUS_NATIVE
 
46
 
 
47
//-----------------------------------------------------------------------------
 
48
// "child_attached" of menu bar
 
49
//-----------------------------------------------------------------------------
 
50
 
 
51
extern "C" {
 
52
static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
 
53
{
 
54
    if (!win->m_hasVMT) return;
 
55
 
 
56
    win->m_menuBarDetached = false;
 
57
    win->GtkUpdateSize();
 
58
}
 
59
}
 
60
 
 
61
//-----------------------------------------------------------------------------
 
62
// "child_detached" of menu bar
 
63
//-----------------------------------------------------------------------------
 
64
 
 
65
extern "C" {
 
66
static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
 
67
{
 
68
    if (g_isIdle)
 
69
        wxapp_install_idle_handler();
 
70
 
 
71
    if (!win->m_hasVMT) return;
 
72
 
 
73
    // Raise the client area area
 
74
    gdk_window_raise( win->m_wxwindow->window );
 
75
 
 
76
    win->m_menuBarDetached = true;
 
77
    win->GtkUpdateSize();
 
78
}
 
79
}
 
80
 
 
81
//-----------------------------------------------------------------------------
 
82
// "size-request" from menubar
 
83
//-----------------------------------------------------------------------------
 
84
 
 
85
extern "C" {
 
86
static void menubar_size_request(GtkWidget* widget, GtkRequisition*, wxFrame* win)
 
87
{
 
88
    g_signal_handlers_disconnect_by_func(
 
89
        widget, (void*)menubar_size_request, win);
 
90
    win->UpdateMenuBarSize();
 
91
}
 
92
}
 
93
 
 
94
//-----------------------------------------------------------------------------
 
95
// "style-set" from menubar
 
96
//-----------------------------------------------------------------------------
 
97
 
 
98
extern "C" {
 
99
static void menubar_style_set(GtkWidget* widget, GtkStyle*, wxFrame* win)
 
100
{
 
101
    g_signal_connect(widget, "size-request",
 
102
        G_CALLBACK(menubar_size_request), win);
 
103
}
 
104
}
 
105
#endif // wxUSE_MENUS_NATIVE
 
106
 
 
107
#if wxUSE_TOOLBAR
 
108
//-----------------------------------------------------------------------------
 
109
// "child_attached" of tool bar
 
110
//-----------------------------------------------------------------------------
 
111
 
 
112
extern "C" {
 
113
static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
 
114
{
 
115
    if (!win->m_hasVMT) return;
 
116
 
 
117
    win->m_toolBarDetached = false;
 
118
    win->GtkUpdateSize();
 
119
}
 
120
}
 
121
 
 
122
//-----------------------------------------------------------------------------
 
123
// "child_detached" of tool bar
 
124
//-----------------------------------------------------------------------------
 
125
 
 
126
extern "C" {
 
127
static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win )
 
128
{
 
129
    if (g_isIdle)
 
130
        wxapp_install_idle_handler();
 
131
 
 
132
    if (!win->m_hasVMT) return;
 
133
 
 
134
    // Raise the client area area
 
135
    gdk_window_raise( win->m_wxwindow->window );
 
136
 
 
137
    win->m_toolBarDetached = true;
 
138
    win->GtkUpdateSize();
 
139
}
 
140
}
 
141
#endif // wxUSE_TOOLBAR
 
142
 
 
143
 
 
144
// ----------------------------------------------------------------------------
 
145
// wxFrame itself
 
146
// ----------------------------------------------------------------------------
 
147
 
 
148
//-----------------------------------------------------------------------------
 
149
// InsertChild for wxFrame
 
150
//-----------------------------------------------------------------------------
 
151
 
 
152
/* Callback for wxFrame. This very strange beast has to be used because
 
153
 * C++ has no virtual methods in a constructor. We have to emulate a
 
154
 * virtual function here as wxWidgets requires different ways to insert
 
155
 * a child in container classes. */
 
156
 
 
157
static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
 
158
{
 
159
    wxASSERT( GTK_IS_WIDGET(child->m_widget) );
 
160
 
 
161
    if (!parent->m_insertInClientArea)
 
162
    {
 
163
        // These are outside the client area
 
164
        wxFrame* frame = (wxFrame*) parent;
 
165
        gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget),
 
166
                         GTK_WIDGET(child->m_widget),
 
167
                         child->m_x,
 
168
                         child->m_y,
 
169
                         child->m_width,
 
170
                         child->m_height );
 
171
 
 
172
#if wxUSE_TOOLBAR_NATIVE
 
173
        // We connect to these events for recalculating the client area
 
174
        // space when the toolbar is floating
 
175
        if (wxIS_KIND_OF(child,wxToolBar))
 
176
        {
 
177
            wxToolBar *toolBar = (wxToolBar*) child;
 
178
            if (toolBar->GetWindowStyle() & wxTB_DOCKABLE)
 
179
            {
 
180
                g_signal_connect (toolBar->m_widget, "child_attached",
 
181
                                  G_CALLBACK (gtk_toolbar_attached_callback),
 
182
                                  parent);
 
183
                g_signal_connect (toolBar->m_widget, "child_detached",
 
184
                                  G_CALLBACK (gtk_toolbar_detached_callback),
 
185
                                  parent);
 
186
            }
 
187
        }
 
188
#endif // wxUSE_TOOLBAR
 
189
    }
 
190
    else
 
191
    {
 
192
        // These are inside the client area
 
193
        gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
 
194
                         GTK_WIDGET(child->m_widget),
 
195
                         child->m_x,
 
196
                         child->m_y,
 
197
                         child->m_width,
 
198
                         child->m_height );
 
199
    }
 
200
}
 
201
 
 
202
// ----------------------------------------------------------------------------
 
203
// wxFrame creation
 
204
// ----------------------------------------------------------------------------
 
205
 
 
206
void wxFrame::Init()
 
207
{
 
208
    m_menuBarDetached = false;
 
209
    m_toolBarDetached = false;
 
210
    m_menuBarHeight = 2;
 
211
}
 
212
 
 
213
bool wxFrame::Create( wxWindow *parent,
 
214
                      wxWindowID id,
 
215
                      const wxString& title,
 
216
                      const wxPoint& pos,
 
217
                      const wxSize& sizeOrig,
 
218
                      long style,
 
219
                      const wxString &name )
 
220
{
 
221
    bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig,
 
222
                                       style, name);
 
223
    m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame;
 
224
 
 
225
    return rt;
 
226
}
 
227
 
 
228
wxFrame::~wxFrame()
 
229
{
 
230
    m_isBeingDeleted = true;
 
231
    DeleteAllBars();
 
232
}
 
233
 
 
234
// ----------------------------------------------------------------------------
 
235
// overridden wxWindow methods
 
236
// ----------------------------------------------------------------------------
 
237
 
 
238
void wxFrame::DoGetClientSize( int *width, int *height ) const
 
239
{
 
240
    wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
 
241
 
 
242
    wxTopLevelWindow::DoGetClientSize( width, height );
 
243
 
 
244
    if (height)
 
245
    {
 
246
#if wxUSE_MENUS_NATIVE
 
247
        // menu bar
 
248
        if (m_frameMenuBar && !(m_fsIsShowing && (m_fsSaveFlag & wxFULLSCREEN_NOMENUBAR) != 0))
 
249
        {
 
250
            if (!m_menuBarDetached)
 
251
                (*height) -= m_menuBarHeight;
 
252
            else
 
253
                (*height) -= wxPLACE_HOLDER;
 
254
        }
 
255
#endif // wxUSE_MENUS_NATIVE
 
256
 
 
257
#if wxUSE_STATUSBAR
 
258
        // status bar
 
259
        if (m_frameStatusBar && m_frameStatusBar->IsShown() && 
 
260
            !(m_fsIsShowing && (m_fsSaveFlag & wxFULLSCREEN_NOSTATUSBAR) != 0))
 
261
            (*height) -= wxSTATUS_HEIGHT;
 
262
#endif // wxUSE_STATUSBAR
 
263
    }
 
264
 
 
265
#if wxUSE_TOOLBAR
 
266
    // tool bar
 
267
    if (m_frameToolBar && m_frameToolBar->IsShown())
 
268
    {
 
269
        if (m_toolBarDetached)
 
270
        {
 
271
            if (height != NULL)
 
272
                *height -= wxPLACE_HOLDER;
 
273
        }
 
274
        else
 
275
        {
 
276
            int x, y;
 
277
            m_frameToolBar->GetSize( &x, &y );
 
278
            if ( m_frameToolBar->IsVertical() )
 
279
            {
 
280
                if (width != NULL)
 
281
                    *width -= x;
 
282
            }
 
283
            else
 
284
            {
 
285
                if (height != NULL)
 
286
                    *height -= y;
 
287
            }
 
288
        }
 
289
    }
 
290
#endif // wxUSE_TOOLBAR
 
291
 
 
292
    if (width != NULL && *width < 0)
 
293
        *width = 0;
 
294
    if (height != NULL && *height < 0)
 
295
        *height = 0;
 
296
}
 
297
 
 
298
void wxFrame::DoSetClientSize( int width, int height )
 
299
{
 
300
    wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
 
301
 
 
302
#if wxUSE_MENUS_NATIVE
 
303
        // menu bar
 
304
        if (m_frameMenuBar && !(m_fsIsShowing && (m_fsSaveFlag & wxFULLSCREEN_NOMENUBAR) != 0))
 
305
        {
 
306
            if (!m_menuBarDetached)
 
307
                height += m_menuBarHeight;
 
308
            else
 
309
                height += wxPLACE_HOLDER;
 
310
        }
 
311
#endif // wxUSE_MENUS_NATIVE
 
312
 
 
313
#if wxUSE_STATUSBAR
 
314
        // status bar
 
315
        if (m_frameStatusBar && m_frameStatusBar->IsShown() && 
 
316
            !(m_fsIsShowing && (m_fsSaveFlag & wxFULLSCREEN_NOSTATUSBAR) != 0))
 
317
            height += wxSTATUS_HEIGHT;
 
318
#endif
 
319
 
 
320
#if wxUSE_TOOLBAR
 
321
        // tool bar
 
322
        if (m_frameToolBar && m_frameToolBar->IsShown())
 
323
        {
 
324
            if (m_toolBarDetached)
 
325
            {
 
326
                height += wxPLACE_HOLDER;
 
327
            }
 
328
            else
 
329
            {
 
330
                int x, y;
 
331
                m_frameToolBar->GetSize( &x, &y );
 
332
                if ( m_frameToolBar->IsVertical() )
 
333
                {
 
334
                    width += x;
 
335
                }
 
336
                else
 
337
                {
 
338
                    height += y;
 
339
                }
 
340
            }
 
341
        }
 
342
#endif
 
343
 
 
344
    wxTopLevelWindow::DoSetClientSize( width, height );
 
345
}
 
346
 
 
347
void wxFrame::GtkOnSize()
 
348
{
 
349
    // avoid recursions
 
350
    if (m_resizing) return;
 
351
    m_resizing = true;
 
352
 
 
353
    // this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow
 
354
    wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
 
355
 
 
356
    // space occupied by m_frameToolBar and m_frameMenuBar
 
357
    int client_area_x_offset = 0,
 
358
        client_area_y_offset = 0;
 
359
 
 
360
    /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses
 
361
       wxWindow::Create to create it's GTK equivalent. m_mainWidget is only
 
362
       set in wxFrame::Create so it is used to check what kind of frame we
 
363
       have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we
 
364
       skip the part which handles m_frameMenuBar, m_frameToolBar and (most
 
365
       importantly) m_mainWidget */
 
366
 
 
367
    int minWidth = GetMinWidth(),
 
368
        minHeight = GetMinHeight(),
 
369
        maxWidth = GetMaxWidth(),
 
370
        maxHeight = GetMaxHeight();
 
371
 
 
372
    if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth;
 
373
    if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight;
 
374
    if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth;
 
375
    if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight;
 
376
 
 
377
    if (m_mainWidget)
 
378
    {
 
379
        // TODO
 
380
        // Rewrite this terrible code to using GtkVBox
 
381
 
 
382
        // m_mainWidget holds the menubar, the toolbar and the client
 
383
        // area, which is represented by m_wxwindow.
 
384
 
 
385
#if wxUSE_MENUS_NATIVE
 
386
        if (m_frameMenuBar && !(m_fsIsShowing && (m_fsSaveFlag & wxFULLSCREEN_NOMENUBAR) != 0))
 
387
        {
 
388
            if (m_frameMenuBar->IsShown() && !GTK_WIDGET_VISIBLE(m_frameMenuBar->m_widget))
 
389
                gtk_widget_show( m_frameMenuBar->m_widget );
 
390
            int xx = m_miniEdge;
 
391
            int yy = m_miniEdge + m_miniTitle;
 
392
            int ww = m_width  - 2*m_miniEdge;
 
393
            if (ww < 0)
 
394
                ww = 0;
 
395
            int hh = m_menuBarHeight;
 
396
            if (m_menuBarDetached) hh = wxPLACE_HOLDER;
 
397
            m_frameMenuBar->m_x = xx;
 
398
            m_frameMenuBar->m_y = yy;
 
399
            m_frameMenuBar->m_width = ww;
 
400
            m_frameMenuBar->m_height = hh;
 
401
            gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
 
402
                                  m_frameMenuBar->m_widget,
 
403
                                  xx, yy, ww, hh );
 
404
            client_area_y_offset += hh;
 
405
        }
 
406
        else
 
407
        {
 
408
            if (m_frameMenuBar)
 
409
            {
 
410
                if (GTK_WIDGET_VISIBLE(m_frameMenuBar->m_widget))
 
411
                    gtk_widget_hide( m_frameMenuBar->m_widget );
 
412
            }
 
413
        }
 
414
#endif // wxUSE_MENUS_NATIVE
 
415
 
 
416
#if wxUSE_TOOLBAR
 
417
        if ((m_frameToolBar) && m_frameToolBar->IsShown() &&
 
418
            (m_frameToolBar->m_widget->parent == m_mainWidget))
 
419
        {
 
420
            int xx = m_miniEdge;
 
421
            int yy = m_miniEdge + m_miniTitle;
 
422
#if wxUSE_MENUS_NATIVE
 
423
            if (m_frameMenuBar)
 
424
            {
 
425
                if (!m_menuBarDetached)
 
426
                    yy += m_menuBarHeight;
 
427
                else
 
428
                    yy += wxPLACE_HOLDER;
 
429
            }
 
430
#endif // wxUSE_MENUS_NATIVE
 
431
 
 
432
            m_frameToolBar->m_x = xx;
 
433
            m_frameToolBar->m_y = yy;
 
434
 
 
435
            // don't change the toolbar's reported height/width
 
436
            int ww, hh;
 
437
            if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL )
 
438
            {
 
439
                ww = m_toolBarDetached ? wxPLACE_HOLDER
 
440
                                       : m_frameToolBar->m_width;
 
441
                hh = m_height - 2*m_miniEdge;
 
442
 
 
443
                client_area_x_offset += ww;
 
444
            }
 
445
            else if( m_frameToolBar->HasFlag(wxTB_RIGHT) )
 
446
            {
 
447
               yy += 2;
 
448
               ww = m_toolBarDetached ? wxPLACE_HOLDER
 
449
                                      : m_frameToolBar->m_width;
 
450
               xx = GetClientSize().x - 1;
 
451
               hh = m_height - 2*m_miniEdge;
 
452
               if( hh < 0 )
 
453
                  hh = 0;
 
454
 
 
455
            }
 
456
            else if( m_frameToolBar->GetWindowStyle() & wxTB_BOTTOM )
 
457
            {
 
458
                xx = m_miniEdge;
 
459
                yy = GetClientSize().y;
 
460
#if wxUSE_MENUS_NATIVE
 
461
                yy += m_menuBarHeight;
 
462
#endif // wxUSE_MENU_NATIVE
 
463
                m_frameToolBar->m_x = xx;
 
464
                m_frameToolBar->m_y = yy;
 
465
                ww = m_width - 2*m_miniEdge;
 
466
                hh = m_toolBarDetached ? wxPLACE_HOLDER
 
467
                                       : m_frameToolBar->m_height;
 
468
            }
 
469
            else
 
470
            {
 
471
                ww = m_width - 2*m_miniEdge;
 
472
                hh = m_toolBarDetached ? wxPLACE_HOLDER
 
473
                                       : m_frameToolBar->m_height;
 
474
 
 
475
                client_area_y_offset += hh;
 
476
            }
 
477
 
 
478
            if (ww < 0)
 
479
                ww = 0;
 
480
            if (hh < 0)
 
481
                hh = 0;
 
482
            gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
 
483
                                  m_frameToolBar->m_widget,
 
484
                                  xx, yy, ww, hh );
 
485
        }
 
486
#endif // wxUSE_TOOLBAR
 
487
 
 
488
        int client_x = client_area_x_offset + m_miniEdge;
 
489
        int client_y = client_area_y_offset + m_miniEdge + m_miniTitle;
 
490
        int client_w = m_width - client_area_x_offset - 2*m_miniEdge;
 
491
        int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle;
 
492
        if (client_w < 0)
 
493
            client_w = 0;
 
494
        if (client_h < 0)
 
495
            client_h = 0;
 
496
        gtk_pizza_set_size( GTK_PIZZA(m_mainWidget),
 
497
                              m_wxwindow,
 
498
                              client_x, client_y, client_w, client_h );
 
499
    }
 
500
    else
 
501
    {
 
502
        // If there is no m_mainWidget between m_widget and m_wxwindow there
 
503
        // is no need to set the size or position of m_wxwindow.
 
504
    }
 
505
 
 
506
#if wxUSE_STATUSBAR
 
507
    if (m_frameStatusBar && m_frameStatusBar->IsShown() &&
 
508
        !(m_fsIsShowing && (m_fsSaveFlag & wxFULLSCREEN_NOSTATUSBAR) != 0))
 
509
    {
 
510
        if (!GTK_WIDGET_VISIBLE(m_frameStatusBar->m_widget))
 
511
            gtk_widget_show( m_frameStatusBar->m_widget );
 
512
            
 
513
        int xx = 0 + m_miniEdge;
 
514
        int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset;
 
515
        int ww = m_width - 2*m_miniEdge;
 
516
        if (ww < 0)
 
517
            ww = 0;
 
518
        int hh = wxSTATUS_HEIGHT;
 
519
        m_frameStatusBar->m_x = xx;
 
520
        m_frameStatusBar->m_y = yy;
 
521
        m_frameStatusBar->m_width = ww;
 
522
        m_frameStatusBar->m_height = hh;
 
523
        gtk_pizza_set_size( GTK_PIZZA(m_wxwindow),
 
524
                            m_frameStatusBar->m_widget,
 
525
                            xx, yy, ww, hh );
 
526
    }
 
527
    else
 
528
    {
 
529
        if (m_frameStatusBar)
 
530
        {
 
531
            if (GTK_WIDGET_VISIBLE(m_frameStatusBar->m_widget))
 
532
                gtk_widget_hide( m_frameStatusBar->m_widget );
 
533
        }
 
534
    }
 
535
#endif // wxUSE_STATUSBAR
 
536
 
 
537
    m_sizeSet = true;
 
538
 
 
539
    // send size event to frame
 
540
    wxSizeEvent event( wxSize(m_width,m_height), GetId() );
 
541
    event.SetEventObject( this );
 
542
    GetEventHandler()->ProcessEvent( event );
 
543
 
 
544
#if wxUSE_STATUSBAR
 
545
    // send size event to status bar
 
546
    if (m_frameStatusBar)
 
547
    {
 
548
        wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() );
 
549
        event2.SetEventObject( m_frameStatusBar );
 
550
        m_frameStatusBar->GetEventHandler()->ProcessEvent( event2 );
 
551
    }
 
552
#endif // wxUSE_STATUSBAR
 
553
 
 
554
    m_resizing = false;
 
555
}
 
556
 
 
557
void wxFrame::OnInternalIdle()
 
558
{
 
559
    wxFrameBase::OnInternalIdle();
 
560
 
 
561
#if wxUSE_MENUS_NATIVE
 
562
    if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle();
 
563
#endif // wxUSE_MENUS_NATIVE
 
564
#if wxUSE_TOOLBAR
 
565
    if (m_frameToolBar) m_frameToolBar->OnInternalIdle();
 
566
#endif
 
567
#if wxUSE_STATUSBAR
 
568
    if (m_frameStatusBar)
 
569
    {
 
570
        m_frameStatusBar->OnInternalIdle();
 
571
 
 
572
        // There may be controls in the status bar that
 
573
        // need to be updated
 
574
        for ( wxWindowList::compatibility_iterator node = m_frameStatusBar->GetChildren().GetFirst();
 
575
          node;
 
576
          node = node->GetNext() )
 
577
        {
 
578
            wxWindow *child = node->GetData();
 
579
            child->OnInternalIdle();
 
580
        }
 
581
    }
 
582
#endif
 
583
}
 
584
 
 
585
// ----------------------------------------------------------------------------
 
586
// menu/tool/status bar stuff
 
587
// ----------------------------------------------------------------------------
 
588
 
 
589
#if wxUSE_MENUS_NATIVE
 
590
 
 
591
void wxFrame::DetachMenuBar()
 
592
{
 
593
    wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
 
594
    wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") );
 
595
 
 
596
    if ( m_frameMenuBar )
 
597
    {
 
598
        g_signal_handlers_disconnect_by_func(
 
599
            m_frameMenuBar->m_widget, (void*)menubar_style_set, this);
 
600
 
 
601
        m_frameMenuBar->UnsetInvokingWindow( this );
 
602
 
 
603
        if (m_frameMenuBar->GetWindowStyle() & wxMB_DOCKABLE)
 
604
        {
 
605
            g_signal_handlers_disconnect_by_func (m_frameMenuBar->m_widget,
 
606
                    (gpointer) gtk_menu_attached_callback,
 
607
                    this);
 
608
 
 
609
            g_signal_handlers_disconnect_by_func (m_frameMenuBar->m_widget,
 
610
                    (gpointer) gtk_menu_detached_callback,
 
611
                    this);
 
612
        }
 
613
 
 
614
        gtk_widget_ref( m_frameMenuBar->m_widget );
 
615
 
 
616
        gtk_container_remove( GTK_CONTAINER(m_mainWidget), m_frameMenuBar->m_widget );
 
617
    }
 
618
 
 
619
    wxFrameBase::DetachMenuBar();
 
620
}
 
621
 
 
622
void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
 
623
{
 
624
    wxFrameBase::AttachMenuBar(menuBar);
 
625
 
 
626
    if (m_frameMenuBar)
 
627
    {
 
628
        m_frameMenuBar->SetInvokingWindow( this );
 
629
 
 
630
        m_frameMenuBar->SetParent(this);
 
631
        gtk_pizza_put( GTK_PIZZA(m_mainWidget),
 
632
                m_frameMenuBar->m_widget,
 
633
                m_frameMenuBar->m_x,
 
634
                m_frameMenuBar->m_y,
 
635
                m_frameMenuBar->m_width,
 
636
                m_frameMenuBar->m_height );
 
637
 
 
638
        if (menuBar->GetWindowStyle() & wxMB_DOCKABLE)
 
639
        {
 
640
            g_signal_connect (menuBar->m_widget, "child_attached",
 
641
                              G_CALLBACK (gtk_menu_attached_callback),
 
642
                              this);
 
643
            g_signal_connect (menuBar->m_widget, "child_detached",
 
644
                              G_CALLBACK (gtk_menu_detached_callback),
 
645
                              this);
 
646
        }
 
647
 
 
648
        gtk_widget_show( m_frameMenuBar->m_widget );
 
649
 
 
650
        UpdateMenuBarSize();
 
651
 
 
652
        g_signal_connect(menuBar->m_widget, "style-set",
 
653
            G_CALLBACK(menubar_style_set), this);
 
654
    }
 
655
    else
 
656
    {
 
657
        m_menuBarHeight = 2;
 
658
        GtkUpdateSize();        // resize window in OnInternalIdle
 
659
    }
 
660
}
 
661
 
 
662
void wxFrame::UpdateMenuBarSize()
 
663
{
 
664
    m_menuBarHeight = 2;
 
665
 
 
666
    // this is called after Remove with a NULL m_frameMenuBar
 
667
    if ( m_frameMenuBar )
 
668
    {
 
669
        GtkRequisition req;
 
670
        gtk_widget_ensure_style(m_frameMenuBar->m_widget);
 
671
        // have to call class method directly because
 
672
        // "size_request" signal is overridden by wx
 
673
        GTK_WIDGET_GET_CLASS(m_frameMenuBar->m_widget)->size_request(
 
674
            m_frameMenuBar->m_widget, &req);
 
675
 
 
676
        m_menuBarHeight = req.height;
 
677
    }
 
678
 
 
679
    // resize window in OnInternalIdle
 
680
    GtkUpdateSize();
 
681
}
 
682
 
 
683
#endif // wxUSE_MENUS_NATIVE
 
684
 
 
685
#if wxUSE_TOOLBAR
 
686
 
 
687
wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& name )
 
688
{
 
689
    wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
 
690
 
 
691
    m_insertInClientArea = false;
 
692
 
 
693
    m_frameToolBar = wxFrameBase::CreateToolBar( style, id, name );
 
694
 
 
695
    m_insertInClientArea = true;
 
696
 
 
697
    GtkUpdateSize();
 
698
 
 
699
    return m_frameToolBar;
 
700
}
 
701
 
 
702
void wxFrame::SetToolBar(wxToolBar *toolbar)
 
703
{
 
704
    bool hadTbar = m_frameToolBar != NULL;
 
705
 
 
706
    wxFrameBase::SetToolBar(toolbar);
 
707
 
 
708
    if ( m_frameToolBar )
 
709
    {
 
710
        // insert into toolbar area if not already there
 
711
        if ((m_frameToolBar->m_widget->parent) &&
 
712
            (m_frameToolBar->m_widget->parent != m_mainWidget))
 
713
        {
 
714
            GetChildren().DeleteObject( m_frameToolBar );
 
715
 
 
716
            gtk_widget_reparent( m_frameToolBar->m_widget, m_mainWidget );
 
717
            GtkUpdateSize();
 
718
        }
 
719
    }
 
720
    else // toolbar unset
 
721
    {
 
722
        // still need to update size if it had been there before
 
723
        if ( hadTbar )
 
724
        {
 
725
            GtkUpdateSize();
 
726
        }
 
727
    }
 
728
}
 
729
 
 
730
#endif // wxUSE_TOOLBAR
 
731
 
 
732
#if wxUSE_STATUSBAR
 
733
 
 
734
wxStatusBar* wxFrame::CreateStatusBar(int number,
 
735
                                      long style,
 
736
                                      wxWindowID id,
 
737
                                      const wxString& name)
 
738
{
 
739
    wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
 
740
 
 
741
    // because it will change when toolbar is added
 
742
    GtkUpdateSize();
 
743
 
 
744
    return wxFrameBase::CreateStatusBar( number, style, id, name );
 
745
}
 
746
 
 
747
void wxFrame::SetStatusBar(wxStatusBar *statbar)
 
748
{
 
749
    bool hadStatBar = m_frameStatusBar != NULL;
 
750
 
 
751
    wxFrameBase::SetStatusBar(statbar);
 
752
 
 
753
    if (hadStatBar && !m_frameStatusBar)
 
754
        GtkUpdateSize();
 
755
}
 
756
 
 
757
void wxFrame::PositionStatusBar()
 
758
{
 
759
    if ( !m_frameStatusBar )
 
760
        return;
 
761
 
 
762
    GtkUpdateSize();
 
763
}
 
764
#endif // wxUSE_STATUSBAR