1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "frame.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
29 #include "wx/dialog.h"
30 #include "wx/settings.h"
31 #include "wx/dcclient.h"
34 #include "wx/msw/private.h"
35 #include "wx/statusbr.h"
36 #include "wx/toolbar.h"
37 #include "wx/menuitem.h"
39 #ifdef LoadAccelerators
40 #undef LoadAccelerators
43 #if USE_NATIVE_STATUSBAR
44 #include <wx/msw/statbr95.h>
47 extern wxList wxModelessWindows
;
48 extern wxList wxPendingDelete
;
49 extern char wxFrameClassName
[];
51 #if !USE_SHARED_LIBRARY
52 BEGIN_EVENT_TABLE(wxFrame
, wxWindow
)
53 EVT_SIZE(wxFrame::OnSize
)
54 EVT_ACTIVATE(wxFrame::OnActivate
)
55 EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight
)
56 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
57 EVT_IDLE(wxFrame::OnIdle
)
58 EVT_CLOSE(wxFrame::OnCloseWindow
)
61 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
64 #if USE_NATIVE_STATUSBAR
65 bool wxFrame::m_useNativeStatusBar
= TRUE
;
67 bool wxFrame::m_useNativeStatusBar
= FALSE
;
70 wxFrame::wxFrame(void)
72 m_frameToolBar
= NULL
;
73 m_frameMenuBar
= NULL
;
74 m_frameStatusBar
= NULL
;
76 m_windowParent
= NULL
;
80 bool wxFrame::Create(wxWindow
*parent
,
82 const wxString
& title
,
89 wxTopLevelWindows
.Append(this);
92 // m_modalShowing = FALSE;
93 m_windowStyle
= style
;
94 m_frameMenuBar
= NULL
;
95 m_frameToolBar
= NULL
;
96 m_frameStatusBar
= NULL
;
98 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
104 m_windowId
= (int)NewControlId();
106 if (parent
) parent
->AddChild(this);
114 MSWCreate(m_windowId
, (wxWindow
*)parent
, wxFrameClassName
, this, (char *)(const char *)title
,
115 x
, y
, width
, height
, style
);
117 wxModelessWindows
.Append(this);
121 wxFrame::~wxFrame(void)
123 m_isBeingDeleted
= TRUE
;
124 wxTopLevelWindows
.DeleteObject(this);
126 if (m_frameStatusBar
)
127 delete m_frameStatusBar
;
129 delete m_frameMenuBar
;
131 /* New behaviour March 1998: check if it's the last top-level window */
132 // if (wxTheApp && (this == wxTheApp->GetTopWindow()))
134 if (wxTheApp
&& (wxTopLevelWindows
.Number() == 0))
136 wxTheApp
->SetTopWindow(NULL
);
138 if (wxTheApp
->GetExitOnFrameDelete())
144 wxModelessWindows
.DeleteObject(this);
146 // For some reason, wxWindows can activate another task altogether
147 // when a frame is destroyed after a modal dialog has been invoked.
148 // Try to bring the parent to the top.
149 if (GetParent() && GetParent()->GetHWND())
150 ::BringWindowToTop((HWND
) GetParent()->GetHWND());
153 WXHMENU
wxFrame::GetWinMenu(void) const
158 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
159 void wxFrame::GetClientSize(int *x
, int *y
) const
162 GetClientRect((HWND
) GetHWND(), &rect
);
164 if ( GetStatusBar() )
166 int statusX
, statusY
;
167 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
168 rect
.bottom
-= statusY
;
171 wxPoint
pt(GetClientAreaOrigin());
179 // Set the client size (i.e. leave the calculation of borders etc.
181 void wxFrame::SetClientSize(int width
, int height
)
183 HWND hWnd
= (HWND
) GetHWND();
186 GetClientRect(hWnd
, &rect
);
189 GetWindowRect(hWnd
, &rect2
);
191 // Find the difference between the entire window (title bar and all)
192 // and the client area; add this to the new client size to move the
194 int actual_width
= rect2
.right
- rect2
.left
- rect
.right
+ width
;
195 int actual_height
= rect2
.bottom
- rect2
.top
- rect
.bottom
+ height
;
197 if ( GetStatusBar() )
199 int statusX
, statusY
;
200 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
201 actual_height
+= statusY
;
204 wxPoint
pt(GetClientAreaOrigin());
205 actual_width
+= pt
.y
;
206 actual_height
+= pt
.x
;
209 point
.x
= rect2
.left
;
212 MoveWindow(hWnd
, point
.x
, point
.y
, actual_width
, actual_height
, (BOOL
)TRUE
);
214 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
215 event
.SetEventObject( this );
216 GetEventHandler()->ProcessEvent(event
);
219 void wxFrame::GetSize(int *width
, int *height
) const
222 GetWindowRect((HWND
) GetHWND(), &rect
);
223 *width
= rect
.right
- rect
.left
;
224 *height
= rect
.bottom
- rect
.top
;
227 void wxFrame::GetPosition(int *x
, int *y
) const
230 GetWindowRect((HWND
) GetHWND(), &rect
);
239 void wxFrame::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
241 int currentX
, currentY
;
247 GetPosition(¤tX
, ¤tY
);
248 if (x
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
250 if (y
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
255 if (width
== -1) w1
= ww
;
256 if (height
==-1) h1
= hh
;
258 MoveWindow((HWND
) GetHWND(), x1
, y1
, w1
, h1
, (BOOL
)TRUE
);
260 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
261 event
.SetEventObject( this );
262 GetEventHandler()->ProcessEvent(event
);
265 bool wxFrame::Show(bool show
)
275 // Try to highlight the correct window (the parent)
279 hWndParent
= (HWND
) GetParent()->GetHWND();
281 ::BringWindowToTop(hWndParent
);
285 ShowWindow((HWND
) GetHWND(), (BOOL
)cshow
);
288 BringWindowToTop((HWND
) GetHWND());
290 wxActivateEvent
event(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
291 event
.SetEventObject( this );
292 GetEventHandler()->ProcessEvent(event
);
297 void wxFrame::Iconize(bool iconize
)
307 ShowWindow((HWND
) GetHWND(), (BOOL
)cshow
);
308 m_iconized
= iconize
;
311 // Equivalent to maximize/restore in Windows
312 void wxFrame::Maximize(bool maximize
)
320 ShowWindow((HWND
) GetHWND(), cshow
);
324 bool wxFrame::IsIconized(void) const
326 ((wxFrame
*)this)->m_iconized
= (::IsIconic((HWND
) GetHWND()) != 0);
330 void wxFrame::SetTitle(const wxString
& title
)
332 SetWindowText((HWND
) GetHWND(), (const char *)title
);
335 wxString
wxFrame::GetTitle(void) const
337 GetWindowText((HWND
) GetHWND(), wxBuffer
, 1000);
338 return wxString(wxBuffer
);
341 void wxFrame::SetIcon(const wxIcon
& icon
)
344 #if defined(__WIN95__)
346 SendMessage((HWND
) GetHWND(), WM_SETICON
,
347 (WPARAM
)TRUE
, (LPARAM
)(HICON
) m_icon
.GetHICON());
351 void wxFrame::SetAcceleratorTable(const wxAcceleratorTable
& accel
)
353 m_acceleratorTable
= accel
;
356 wxStatusBar
*wxFrame::OnCreateStatusBar(int number
, long style
, wxWindowID id
,
357 const wxString
& name
)
359 wxStatusBar
*statusBar
= NULL
;
361 #if USE_NATIVE_STATUSBAR
362 if (UsesNativeStatusBar())
364 statusBar
= new wxStatusBar95(this, id
, style
);
369 statusBar
= new wxStatusBar(this, id
, wxPoint(0, 0), wxSize(100, 20),
372 // Set the height according to the font and the border size
373 wxClientDC
dc(statusBar
);
374 dc
.SetFont(* statusBar
->GetFont());
377 dc
.GetTextExtent("X", &x
, &y
);
379 int height
= (int)( (y
* 1.1) + 2* statusBar
->GetBorderY());
381 statusBar
->SetSize(-1, -1, 100, height
);
384 statusBar
->SetFieldsCount(number
);
388 wxStatusBar
* wxFrame::CreateStatusBar(int number
, long style
, wxWindowID id
,
389 const wxString
& name
)
391 // VZ: calling CreateStatusBar twice is an error - why anyone would do it?
392 wxCHECK_MSG( m_frameStatusBar
== NULL
, FALSE
,
393 "recreating status bar in wxFrame" );
395 m_frameStatusBar
= OnCreateStatusBar(number
, style
, id
,
397 if ( m_frameStatusBar
)
400 return m_frameStatusBar
;
406 void wxFrame::SetStatusText(const wxString
& text
, int number
)
408 wxCHECK_RET( m_frameStatusBar
!= NULL
, "no statusbar to set text for" );
410 m_frameStatusBar
->SetStatusText(text
, number
);
413 void wxFrame::SetStatusWidths(int n
, const int widths_field
[])
415 wxCHECK_RET( m_frameStatusBar
!= NULL
, "no statusbar to set widths for" );
417 m_frameStatusBar
->SetStatusWidths(n
, widths_field
);
421 void wxFrame::PositionStatusBar(void)
423 // native status bar positions itself
425 #if USE_NATIVE_STATUSBAR
426 && !m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
))
431 GetClientSize(&w
, &h
);
433 m_frameStatusBar
->GetSize(&sw
, &sh
);
435 // Since we wish the status bar to be directly under the client area,
436 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
437 m_frameStatusBar
->SetSize(0, h
, w
, sh
);
441 void wxFrame::SetMenuBar(wxMenuBar
*menu_bar
)
445 m_frameMenuBar
= NULL
;
449 if (menu_bar
->m_menuBarFrame
)
453 HMENU menu
= CreateMenu();
455 for (i
= 0; i
< menu_bar
->m_menuCount
; i
++)
457 HMENU popup
= (HMENU
)menu_bar
->m_menus
[i
]->m_hMenu
;
459 // After looking Bounds Checker result, it seems that all
460 // menus must be individually destroyed. So, don't reset m_hMenu,
461 // to allow ~wxMenu to do the job.
463 menu_bar
->m_menus
[i
]->m_savehMenu
= (WXHMENU
) popup
;
464 // Uncommenting for the moment... JACS
465 menu_bar
->m_menus
[i
]->m_hMenu
= 0;
466 AppendMenu(menu
, MF_POPUP
| MF_STRING
, (UINT
)popup
, menu_bar
->m_titles
[i
]);
469 menu_bar
->m_hMenu
= (WXHMENU
)menu
;
471 delete m_frameMenuBar
;
473 this->m_hMenu
= (WXHMENU
) menu
;
476 if (!SetMenu((HWND
) GetHWND(), menu
))
479 err
= GetLastError();
483 m_frameMenuBar
= menu_bar
;
484 menu_bar
->m_menuBarFrame
= this;
488 bool wxFrame::LoadAccelerators(const wxString
& table
)
490 m_acceleratorTable
= (WXHANDLE
)
493 ::LoadAcceleratorsW(wxGetInstance(), (const char *)table
);
495 ::LoadAcceleratorsA(wxGetInstance(), (const char *)table
);
498 ::LoadAccelerators(wxGetInstance(), (const char *)table
);
501 // The above is necessary because LoadAccelerators is a macro
502 // which we have undefed earlier in the file to avoid confusion
503 // with wxFrame::LoadAccelerators. Ugh!
505 return (m_acceleratorTable
!= (WXHANDLE
) NULL
);
509 void wxFrame::Fit(void)
511 // Work out max. size
512 wxNode
*node
= GetChildren()->First();
517 // Find a child that's a subwindow, but not a dialog box.
518 wxWindow
*win
= (wxWindow
*)node
->Data();
520 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) &&
521 !win
->IsKindOf(CLASSINFO(wxDialog
)))
525 win
->GetSize(&width
, &height
);
526 win
->GetPosition(&x
, &y
);
528 if ((x
+ width
) > max_width
)
529 max_width
= x
+ width
;
530 if ((y
+ height
) > max_height
)
531 max_height
= y
+ height
;
535 SetClientSize(max_width
, max_height
);
538 // Responds to colour changes, and passes event on to children.
539 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
541 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
544 if ( m_frameStatusBar
)
546 wxSysColourChangedEvent event2
;
547 event2
.SetEventObject( m_frameStatusBar
);
548 m_frameStatusBar
->ProcessEvent(event2
);
551 // Propagate the event to the non-top-level children
552 wxWindow::OnSysColourChanged(event
);
560 void wxFrame::MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
561 int x
, int y
, int width
, int height
, long style
)
564 m_defaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
566 // If child windows aren't properly drawn initially, WS_CLIPCHILDREN
567 // could be the culprit. But without it, you can get a lot of flicker.
570 if ((style
& wxCAPTION
) == wxCAPTION
)
571 msflags
= WS_OVERLAPPED
;
575 if (style
& wxMINIMIZE_BOX
)
576 msflags
|= WS_MINIMIZEBOX
;
577 if (style
& wxMAXIMIZE_BOX
)
578 msflags
|= WS_MAXIMIZEBOX
;
579 if (style
& wxTHICK_FRAME
)
580 msflags
|= WS_THICKFRAME
;
581 if (style
& wxSYSTEM_MENU
)
582 msflags
|= WS_SYSMENU
;
583 if ((style
& wxMINIMIZE
) || (style
& wxICONIZE
))
584 msflags
|= WS_MINIMIZE
;
585 if (style
& wxMAXIMIZE
)
586 msflags
|= WS_MAXIMIZE
;
587 if (style
& wxCAPTION
)
588 msflags
|= WS_CAPTION
;
589 if (style
& wxCLIP_CHILDREN
)
590 msflags
|= WS_CLIPCHILDREN
;
592 // Keep this in wxFrame because it saves recoding this function
595 if (style
& wxTINY_CAPTION_VERT
)
596 msflags
|= IBS_VERTCAPTION
;
597 if (style
& wxTINY_CAPTION_HORIZ
)
598 msflags
|= IBS_HORZCAPTION
;
600 if (style
& wxTINY_CAPTION_VERT
)
601 msflags
|= WS_CAPTION
;
602 if (style
& wxTINY_CAPTION_HORIZ
)
603 msflags
|= WS_CAPTION
;
605 if ((style
& wxTHICK_FRAME
) == 0)
606 msflags
|= WS_BORDER
;
608 WXDWORD extendedStyle
= MakeExtendedStyle(style
);
610 if (style
& wxSTAY_ON_TOP
)
611 extendedStyle
|= WS_EX_TOPMOST
;
614 wxWindow::MSWCreate(id
, parent
, wclass
, wx_win
, title
, x
, y
, width
, height
,
615 msflags
, NULL
, extendedStyle
);
616 // Seems to be necessary if we use WS_POPUP
617 // style instead of WS_OVERLAPPED
618 if (width
> -1 && height
> -1)
619 ::PostMessage((HWND
) GetHWND(), WM_SIZE
, SIZE_RESTORED
, MAKELPARAM(width
, height
));
622 bool wxFrame::MSWOnPaint(void)
625 wxDebugMsg("wxFrameWnd::OnPaint %d\n", handle
);
628 if (GetUpdateRect((HWND
) GetHWND(), &rect
, FALSE
))
634 the_icon
= (HICON
) m_icon
.GetHICON();
636 the_icon
= (HICON
) m_defaultIcon
;
639 // Hold a pointer to the dc so long as the OnPaint() message
640 // is being processed
641 HDC cdc
= BeginPaint((HWND
) GetHWND(), &ps
);
643 // Erase background before painting or we get white background
644 this->MSWDefWindowProc(WM_ICONERASEBKGND
,(WORD
)ps
.hdc
,0L);
649 GetClientRect((HWND
) GetHWND(), &rect
);
651 int icon_height
= 32;
652 int icon_x
= (int)((rect
.right
- icon_width
)/2);
653 int icon_y
= (int)((rect
.bottom
- icon_height
)/2);
654 DrawIcon(cdc
, icon_x
, icon_y
, the_icon
);
657 EndPaint((HWND
) GetHWND(), &ps
);
661 wxPaintEvent
event(m_windowId
);
662 event
.m_eventObject
= this;
663 if (!GetEventHandler()->ProcessEvent(event
))
671 WXHICON
wxFrame::MSWOnQueryDragIcon(void)
673 if (m_icon
.Ok() && (m_icon
.GetHICON() != 0))
674 return m_icon
.GetHICON();
676 return m_defaultIcon
;
679 void wxFrame::MSWOnSize(int x
, int y
, WXUINT id
)
682 wxDebugMsg("wxFrameWnd::OnSize %d\n", m_hWnd
);
697 // forward WM_SIZE to status bar control
698 #if USE_NATIVE_STATUSBAR
699 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
701 wxSizeEvent
event(wxSize(x
, y
), m_frameStatusBar
->GetId());
702 event
.SetEventObject( m_frameStatusBar
);
704 ((wxStatusBar95
*)m_frameStatusBar
)->OnSize(event
);
711 wxSizeEvent
event(wxSize(x
, y
), m_windowId
);
712 event
.SetEventObject( this );
713 if (!GetEventHandler()->ProcessEvent(event
))
718 bool wxFrame::MSWOnClose(void)
721 wxDebugMsg("wxFrameWnd::OnClose %d\n", handle
);
726 bool wxFrame::MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
729 wxDebugMsg("wxFrameWnd::OnCommand %d\n", handle
);
731 if (cmd
== 0 || cmd
== 1 ) // Can be either a menu command or an accelerator.
733 // In case it's e.g. a toolbar.
734 wxWindow
*win
= wxFindWinFromHandle(control
);
736 return win
->MSWCommand(cmd
, id
);
738 if (GetMenuBar() && GetMenuBar()->FindItemForId(id
))
750 void wxFrame::MSWOnMenuHighlight(WXWORD nItem
, WXWORD nFlags
, WXHMENU hSysMenu
)
752 if (nFlags
== 0xFFFF && hSysMenu
== 0)
754 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, -1);
755 event
.SetEventObject( this );
756 GetEventHandler()->ProcessEvent(event
);
758 else if (nFlags
!= MF_SEPARATOR
)
760 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, nItem
);
761 event
.SetEventObject( this );
762 GetEventHandler()->ProcessEvent(event
);
766 bool wxFrame::MSWProcessMessage(WXMSG
* pMsg
)
771 bool wxFrame::MSWTranslateMessage(WXMSG
* pMsg
)
773 if (m_acceleratorTable
.Ok() &&
774 ::TranslateAccelerator((HWND
) GetHWND(), (HACCEL
) m_acceleratorTable
.GetHACCEL(), (MSG
*)pMsg
))
780 // Default resizing behaviour - if only ONE subwindow,
781 // resize to client rectangle size
782 void wxFrame::OnSize(wxSizeEvent
& event
)
784 // if we're using constraints - do use them
786 if ( GetAutoLayout() ) {
792 // do we have _exactly_ one child?
793 wxWindow
*child
= NULL
;
794 for ( wxNode
*node
= GetChildren()->First(); node
; node
= node
->Next() )
796 wxWindow
*win
= (wxWindow
*)node
->Data();
797 if ( !win
->IsKindOf(CLASSINFO(wxFrame
)) &&
798 !win
->IsKindOf(CLASSINFO(wxDialog
)) &&
799 (win
!= GetStatusBar()) &&
800 (win
!= GetToolBar()) )
803 return; // it's our second subwindow - nothing to do
809 // we have exactly one child - set it's size to fill the whole frame
810 int clientW
, clientH
;
811 GetClientSize(&clientW
, &clientH
);
816 child
->SetSize(x
, y
, clientW
, clientH
);
820 // Default activation behaviour - set the focus for the first child
822 void wxFrame::OnActivate(wxActivateEvent
& event
)
824 for(wxNode
*node
= GetChildren()->First(); node
; node
= node
->Next())
826 // Find a child that's a subwindow, but not a dialog box.
827 wxWindow
*child
= (wxWindow
*)node
->Data();
828 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) &&
829 !child
->IsKindOf(CLASSINFO(wxDialog
)))
832 wxDebugMsg("wxFrame::OnActivate: about to set the child's focus.\n");
840 // The default implementation for the close window event - calls
841 // OnClose for backward compatibility.
843 void wxFrame::OnCloseWindow(wxCloseEvent
& event
)
846 if ( GetEventHandler()->OnClose() || event
.GetForce())
852 bool wxFrame::OnClose(void)
857 // Destroy the window (delayed, if a managed window)
858 bool wxFrame::Destroy(void)
860 if (!wxPendingDelete
.Member(this))
861 wxPendingDelete
.Append(this);
865 // Default menu selection behaviour - display a help string
866 void wxFrame::OnMenuHighlight(wxMenuEvent
& event
)
870 if (event
.GetMenuId() == -1)
874 wxMenuBar
*menuBar
= GetMenuBar();
877 wxString
helpString(menuBar
->GetHelpString(event
.GetMenuId()));
878 if (helpString
!= "")
879 SetStatusText(helpString
);
885 wxMenuBar
*wxFrame::GetMenuBar(void) const
887 return m_frameMenuBar
;
890 void wxFrame::Centre(int direction
)
892 int display_width
, display_height
, width
, height
, x
, y
;
893 wxDisplaySize(&display_width
, &display_height
);
895 GetSize(&width
, &height
);
898 if (direction
& wxHORIZONTAL
)
899 x
= (int)((display_width
- width
)/2);
900 if (direction
& wxVERTICAL
)
901 y
= (int)((display_height
- height
)/2);
903 SetSize(x
, y
, width
, height
);
906 // Call this to simulate a menu command
907 void wxFrame::Command(int id
)
912 void wxFrame::ProcessCommand(int id
)
914 wxCommandEvent
commandEvent(wxEVENT_TYPE_MENU_COMMAND
, id
);
915 commandEvent
.SetInt( id
);
916 commandEvent
.SetEventObject( this );
918 wxMenuBar
*bar
= GetMenuBar() ;
922 wxMenuItem
*item
= bar
->FindItemForId(id
) ;
923 if (item
&& item
->IsCheckable())
925 bar
->Check(id
,!bar
->Checked(id
)) ;
927 GetEventHandler()->ProcessEvent(commandEvent
);
930 // Checks if there is a toolbar, and returns the first free client position
931 wxPoint
wxFrame::GetClientAreaOrigin() const
937 GetToolBar()->GetSize(& w
, & h
);
939 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
951 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
953 wxCHECK_MSG( m_frameToolBar
== NULL
, FALSE
,
954 "recreating toolbar in wxFrame" );
956 wxToolBar
* toolBar
= OnCreateToolBar(style
, id
, name
);
969 wxToolBar
* wxFrame::OnCreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
971 return new wxToolBar(this, id
, wxDefaultPosition
, wxDefaultSize
, style
, name
);
974 void wxFrame::PositionToolBar(void)
979 ::GetClientRect((HWND
) GetHWND(), &rect
);
981 if ( GetStatusBar() )
983 int statusX
, statusY
;
984 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
985 rect
.bottom
-= statusY
;
991 GetToolBar()->GetSize(& tw
, & th
);
993 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
995 // Use the 'real' MSW position
996 GetToolBar()->SetSize(0, 0, tw
, rect
.bottom
, wxSIZE_NO_ADJUSTMENTS
);
1000 // Use the 'real' MSW position
1001 GetToolBar()->SetSize(0, 0, rect
.right
, th
, wxSIZE_NO_ADJUSTMENTS
);