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"
40 #ifdef LoadAccelerators
41 #undef LoadAccelerators
44 #if wxUSE_NATIVE_STATUSBAR
45 #include <wx/msw/statbr95.h>
48 extern wxWindowList wxModelessWindows
;
49 extern wxList WXDLLEXPORT wxPendingDelete
;
50 extern char wxFrameClassName
[];
51 extern wxMenu
*wxCurrentPopupMenu
;
53 #if !USE_SHARED_LIBRARY
54 BEGIN_EVENT_TABLE(wxFrame
, wxWindow
)
55 EVT_SIZE(wxFrame::OnSize
)
56 EVT_ACTIVATE(wxFrame::OnActivate
)
57 EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight
)
58 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
59 EVT_IDLE(wxFrame::OnIdle
)
60 EVT_CLOSE(wxFrame::OnCloseWindow
)
63 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
66 #if wxUSE_NATIVE_STATUSBAR
67 bool wxFrame::m_useNativeStatusBar
= TRUE
;
69 bool wxFrame::m_useNativeStatusBar
= FALSE
;
74 m_frameToolBar
= NULL
;
75 m_frameMenuBar
= NULL
;
76 m_frameStatusBar
= NULL
;
81 bool wxFrame::Create(wxWindow
*parent
,
83 const wxString
& title
,
94 wxTopLevelWindows
.Append(this);
97 // m_modalShowing = FALSE;
98 m_windowStyle
= style
;
99 m_frameMenuBar
= NULL
;
100 m_frameToolBar
= NULL
;
101 m_frameStatusBar
= NULL
;
103 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
109 m_windowId
= (int)NewControlId();
111 if (parent
) parent
->AddChild(this);
120 // we pass NULL as parent to MSWCreate because frames with parents behave
121 // very strangely under Win95 shell
122 // Alteration by JACS: keep normal Windows behaviour (float on top of parent)
124 if ((m_windowStyle
& wxFRAME_FLOAT_ON_PARENT
) == 0)
127 MSWCreate(m_windowId
, parent
, wxFrameClassName
, this, title
,
128 x
, y
, width
, height
, style
);
130 wxModelessWindows
.Append(this);
136 m_isBeingDeleted
= TRUE
;
137 wxTopLevelWindows
.DeleteObject(this);
139 if (m_frameStatusBar
)
140 delete m_frameStatusBar
;
142 delete m_frameMenuBar
;
144 /* New behaviour March 1998: check if it's the last top-level window */
145 // if (wxTheApp && (this == wxTheApp->GetTopWindow()))
147 if (wxTheApp
&& (wxTopLevelWindows
.Number() == 0))
149 wxTheApp
->SetTopWindow(NULL
);
151 if (wxTheApp
->GetExitOnFrameDelete())
157 wxModelessWindows
.DeleteObject(this);
159 // For some reason, wxWindows can activate another task altogether
160 // when a frame is destroyed after a modal dialog has been invoked.
161 // Try to bring the parent to the top.
162 if (GetParent() && GetParent()->GetHWND())
163 ::BringWindowToTop((HWND
) GetParent()->GetHWND());
166 WXHMENU
wxFrame::GetWinMenu() const
171 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
172 void wxFrame::DoGetClientSize(int *x
, int *y
) const
175 ::GetClientRect((HWND
) GetHWND(), &rect
);
177 if ( GetStatusBar() )
179 int statusX
, statusY
;
180 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
181 rect
.bottom
-= statusY
;
184 wxPoint
pt(GetClientAreaOrigin());
192 // Set the client size (i.e. leave the calculation of borders etc.
194 void wxFrame::DoSetClientSize(int width
, int height
)
196 HWND hWnd
= (HWND
) GetHWND();
199 ::GetClientRect(hWnd
, &rect
);
202 GetWindowRect(hWnd
, &rect2
);
204 // Find the difference between the entire window (title bar and all)
205 // and the client area; add this to the new client size to move the
207 int actual_width
= rect2
.right
- rect2
.left
- rect
.right
+ width
;
208 int actual_height
= rect2
.bottom
- rect2
.top
- rect
.bottom
+ height
;
210 if ( GetStatusBar() )
212 int statusX
, statusY
;
213 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
214 actual_height
+= statusY
;
217 wxPoint
pt(GetClientAreaOrigin());
218 actual_width
+= pt
.y
;
219 actual_height
+= pt
.x
;
222 point
.x
= rect2
.left
;
225 MoveWindow(hWnd
, point
.x
, point
.y
, actual_width
, actual_height
, (BOOL
)TRUE
);
227 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
228 event
.SetEventObject( this );
229 GetEventHandler()->ProcessEvent(event
);
232 void wxFrame::DoGetSize(int *width
, int *height
) const
235 GetWindowRect((HWND
) GetHWND(), &rect
);
236 *width
= rect
.right
- rect
.left
;
237 *height
= rect
.bottom
- rect
.top
;
240 void wxFrame::DoGetPosition(int *x
, int *y
) const
243 GetWindowRect((HWND
) GetHWND(), &rect
);
252 void wxFrame::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
254 int currentX
, currentY
;
260 GetPosition(¤tX
, ¤tY
);
261 if (x
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
263 if (y
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
268 if (width
== -1) w1
= ww
;
269 if (height
==-1) h1
= hh
;
271 MoveWindow((HWND
) GetHWND(), x1
, y1
, w1
, h1
, (BOOL
)TRUE
);
273 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
274 event
.SetEventObject( this );
275 GetEventHandler()->ProcessEvent(event
);
278 bool wxFrame::Show(bool show
)
288 // Try to highlight the correct window (the parent)
292 hWndParent
= (HWND
) GetParent()->GetHWND();
294 ::BringWindowToTop(hWndParent
);
298 ShowWindow((HWND
) GetHWND(), (BOOL
)cshow
);
301 BringWindowToTop((HWND
) GetHWND());
303 wxActivateEvent
event(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
304 event
.SetEventObject( this );
305 GetEventHandler()->ProcessEvent(event
);
310 void wxFrame::Iconize(bool iconize
)
320 ShowWindow((HWND
) GetHWND(), (BOOL
)cshow
);
321 m_iconized
= iconize
;
324 // Equivalent to maximize/restore in Windows
325 void wxFrame::Maximize(bool maximize
)
333 ShowWindow((HWND
) GetHWND(), cshow
);
337 bool wxFrame::IsIconized() const
339 ((wxFrame
*)this)->m_iconized
= (::IsIconic((HWND
) GetHWND()) != 0);
344 bool wxFrame::IsMaximized() const
346 return (::IsZoomed((HWND
) GetHWND()) != 0) ;
349 void wxFrame::SetTitle(const wxString
& title
)
351 SetWindowText((HWND
) GetHWND(), (const char *)title
);
354 wxString
wxFrame::GetTitle() const
356 GetWindowText((HWND
) GetHWND(), wxBuffer
, 1000);
357 return wxString(wxBuffer
);
360 void wxFrame::SetIcon(const wxIcon
& icon
)
363 #if defined(__WIN95__)
365 SendMessage((HWND
) GetHWND(), WM_SETICON
,
366 (WPARAM
)TRUE
, (LPARAM
)(HICON
) m_icon
.GetHICON());
370 wxStatusBar
*wxFrame::OnCreateStatusBar(int number
, long style
, wxWindowID id
,
371 const wxString
& name
)
373 wxStatusBar
*statusBar
= NULL
;
375 #if wxUSE_NATIVE_STATUSBAR
376 if (UsesNativeStatusBar())
378 statusBar
= new wxStatusBar95(this, id
, style
);
383 statusBar
= new wxStatusBar(this, id
, wxPoint(0, 0), wxSize(100, 20),
386 // Set the height according to the font and the border size
387 wxClientDC
dc(statusBar
);
388 dc
.SetFont(statusBar
->GetFont());
391 dc
.GetTextExtent("X", &x
, &y
);
393 int height
= (int)( (y
* 1.1) + 2* statusBar
->GetBorderY());
395 statusBar
->SetSize(-1, -1, 100, height
);
398 statusBar
->SetFieldsCount(number
);
402 wxStatusBar
* wxFrame::CreateStatusBar(int number
, long style
, wxWindowID id
,
403 const wxString
& name
)
405 // VZ: calling CreateStatusBar twice is an error - why anyone would do it?
406 wxCHECK_MSG( m_frameStatusBar
== NULL
, FALSE
,
407 "recreating status bar in wxFrame" );
409 m_frameStatusBar
= OnCreateStatusBar(number
, style
, id
,
411 if ( m_frameStatusBar
)
414 return m_frameStatusBar
;
420 void wxFrame::SetStatusText(const wxString
& text
, int number
)
422 wxCHECK_RET( m_frameStatusBar
!= NULL
, "no statusbar to set text for" );
424 m_frameStatusBar
->SetStatusText(text
, number
);
427 void wxFrame::SetStatusWidths(int n
, const int widths_field
[])
429 wxCHECK_RET( m_frameStatusBar
!= NULL
, "no statusbar to set widths for" );
431 m_frameStatusBar
->SetStatusWidths(n
, widths_field
);
435 void wxFrame::PositionStatusBar()
437 // native status bar positions itself
439 #if wxUSE_NATIVE_STATUSBAR
440 && !m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
))
445 GetClientSize(&w
, &h
);
447 m_frameStatusBar
->GetSize(&sw
, &sh
);
449 // Since we wish the status bar to be directly under the client area,
450 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
451 m_frameStatusBar
->SetSize(0, h
, w
, sh
);
455 void wxFrame::SetMenuBar(wxMenuBar
*menu_bar
)
459 m_frameMenuBar
= NULL
;
463 wxCHECK_RET( !menu_bar
->GetFrame(), "this menubar is already attached" );
466 delete m_frameMenuBar
;
468 m_hMenu
= menu_bar
->Create();
473 if ( !::SetMenu((HWND
)GetHWND(), (HMENU
)m_hMenu
) )
475 wxLogLastError("SetMenu");
478 m_frameMenuBar
= menu_bar
;
479 menu_bar
->Attach(this);
483 bool wxFrame::LoadAccelerators(const wxString
& table
)
485 m_acceleratorTable
= (WXHANDLE
)
488 ::LoadAcceleratorsW(wxGetInstance(), (const char *)table
);
490 ::LoadAcceleratorsA(wxGetInstance(), (const char *)table
);
493 ::LoadAccelerators(wxGetInstance(), (const char *)table
);
496 // The above is necessary because LoadAccelerators is a macro
497 // which we have undefed earlier in the file to avoid confusion
498 // with wxFrame::LoadAccelerators. Ugh!
500 return (m_acceleratorTable
!= (WXHANDLE
) NULL
);
506 // Work out max. size
507 wxNode
*node
= GetChildren().First();
512 // Find a child that's a subwindow, but not a dialog box.
513 wxWindow
*win
= (wxWindow
*)node
->Data();
515 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) &&
516 !win
->IsKindOf(CLASSINFO(wxDialog
)))
520 win
->GetSize(&width
, &height
);
521 win
->GetPosition(&x
, &y
);
523 if ((x
+ width
) > max_width
)
524 max_width
= x
+ width
;
525 if ((y
+ height
) > max_height
)
526 max_height
= y
+ height
;
530 SetClientSize(max_width
, max_height
);
533 // Responds to colour changes, and passes event on to children.
534 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
536 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
539 if ( m_frameStatusBar
)
541 wxSysColourChangedEvent event2
;
542 event2
.SetEventObject( m_frameStatusBar
);
543 m_frameStatusBar
->GetEventHandler()->ProcessEvent(event2
);
546 // Propagate the event to the non-top-level children
547 wxWindow::OnSysColourChanged(event
);
555 bool wxFrame::MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
556 int x
, int y
, int width
, int height
, long style
)
559 m_defaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
561 // If child windows aren't properly drawn initially, WS_CLIPCHILDREN
562 // could be the culprit. But without it, you can get a lot of flicker.
565 if ((style
& wxCAPTION
) == wxCAPTION
)
566 msflags
= WS_OVERLAPPED
;
570 if (style
& wxMINIMIZE_BOX
)
571 msflags
|= WS_MINIMIZEBOX
;
572 if (style
& wxMAXIMIZE_BOX
)
573 msflags
|= WS_MAXIMIZEBOX
;
574 if (style
& wxTHICK_FRAME
)
575 msflags
|= WS_THICKFRAME
;
576 if (style
& wxSYSTEM_MENU
)
577 msflags
|= WS_SYSMENU
;
578 if ((style
& wxMINIMIZE
) || (style
& wxICONIZE
))
579 msflags
|= WS_MINIMIZE
;
580 if (style
& wxMAXIMIZE
)
581 msflags
|= WS_MAXIMIZE
;
582 if (style
& wxCAPTION
)
583 msflags
|= WS_CAPTION
;
584 if (style
& wxCLIP_CHILDREN
)
585 msflags
|= WS_CLIPCHILDREN
;
587 // Keep this in wxFrame because it saves recoding this function
590 if (style
& wxTINY_CAPTION_VERT
)
591 msflags
|= IBS_VERTCAPTION
;
592 if (style
& wxTINY_CAPTION_HORIZ
)
593 msflags
|= IBS_HORZCAPTION
;
595 if (style
& wxTINY_CAPTION_VERT
)
596 msflags
|= WS_CAPTION
;
597 if (style
& wxTINY_CAPTION_HORIZ
)
598 msflags
|= WS_CAPTION
;
600 if ((style
& wxTHICK_FRAME
) == 0)
601 msflags
|= WS_BORDER
;
603 WXDWORD extendedStyle
= MakeExtendedStyle(style
);
605 #if !defined(__WIN16__) && !defined(__SC__)
606 if (style
& wxFRAME_TOOL_WINDOW
)
607 extendedStyle
|= WS_EX_TOOLWINDOW
;
610 if (style
& wxSTAY_ON_TOP
)
611 extendedStyle
|= WS_EX_TOPMOST
;
614 if ( !wxWindow::MSWCreate(id
, parent
, wclass
, wx_win
, title
, x
, y
, width
, height
,
615 msflags
, NULL
, extendedStyle
) )
618 // Seems to be necessary if we use WS_POPUP
619 // style instead of WS_OVERLAPPED
620 if (width
> -1 && height
> -1)
621 ::PostMessage((HWND
) GetHWND(), WM_SIZE
, SIZE_RESTORED
, MAKELPARAM(width
, height
));
626 bool wxFrame::MSWOnPaint()
629 if (GetUpdateRect((HWND
) GetHWND(), &rect
, FALSE
))
635 the_icon
= (HICON
) m_icon
.GetHICON();
637 the_icon
= (HICON
) m_defaultIcon
;
640 // Hold a pointer to the dc so long as the OnPaint() message
641 // is being processed
642 HDC cdc
= BeginPaint((HWND
) GetHWND(), &ps
);
644 // Erase background before painting or we get white background
645 this->MSWDefWindowProc(WM_ICONERASEBKGND
,(WORD
)(LONG
) ps
.hdc
,0L);
650 ::GetClientRect((HWND
) GetHWND(), &rect
);
652 int icon_height
= 32;
653 int icon_x
= (int)((rect
.right
- icon_width
)/2);
654 int icon_y
= (int)((rect
.bottom
- icon_height
)/2);
655 DrawIcon(cdc
, icon_x
, icon_y
, the_icon
);
658 EndPaint((HWND
) GetHWND(), &ps
);
662 wxPaintEvent
event(m_windowId
);
663 event
.m_eventObject
= this;
664 if (!GetEventHandler()->ProcessEvent(event
))
672 WXHICON
wxFrame::MSWOnQueryDragIcon()
674 if (m_icon
.Ok() && (m_icon
.GetHICON() != 0))
675 return m_icon
.GetHICON();
677 return m_defaultIcon
;
680 bool wxFrame::MSWOnSize(int x
, int y
, WXUINT id
)
682 bool processed
= FALSE
;
687 // only do it it if we were iconized before, otherwise resizing the
688 // parent frame has a curious side effect of bringing it under it's
693 // restore all child frames too
694 IconizeChildFrames(FALSE
);
703 // iconize all child frames too
704 IconizeChildFrames(TRUE
);
712 // forward WM_SIZE to status bar control
713 #if wxUSE_NATIVE_STATUSBAR
714 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
716 wxSizeEvent
event(wxSize(x
, y
), m_frameStatusBar
->GetId());
717 event
.SetEventObject( m_frameStatusBar
);
719 ((wxStatusBar95
*)m_frameStatusBar
)->OnSize(event
);
721 #endif // wxUSE_NATIVE_STATUSBAR
726 wxSizeEvent
event(wxSize(x
, y
), m_windowId
);
727 event
.SetEventObject( this );
728 processed
= GetEventHandler()->ProcessEvent(event
);
734 bool wxFrame::MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
736 if (cmd
== 0 || cmd
== 1 ) // Can be either a menu command or an accelerator.
738 // In case it's e.g. a toolbar.
739 wxWindow
*win
= wxFindWinFromHandle(control
);
741 return win
->MSWCommand(cmd
, id
);
743 if (wxCurrentPopupMenu
)
745 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
746 wxCurrentPopupMenu
= NULL
;
747 if (popupMenu
->MSWCommand(cmd
, id
))
751 if (GetMenuBar() && GetMenuBar()->FindItemForId(id
))
760 return wxWindow::MSWOnCommand(id
, cmd
, control
);
763 bool wxFrame::MSWProcessMessage(WXMSG
* pMsg
)
768 bool wxFrame::MSWTranslateMessage(WXMSG
* pMsg
)
770 if (m_acceleratorTable
.Ok() &&
771 ::TranslateAccelerator((HWND
) GetHWND(), (HACCEL
) m_acceleratorTable
.GetHACCEL(), (MSG
*)pMsg
))
777 // Default resizing behaviour - if only ONE subwindow, resize to client
779 void wxFrame::OnSize(wxSizeEvent
& event
)
781 // if we're using constraints - do use them
782 #if wxUSE_CONSTRAINTS
783 if ( GetAutoLayout() )
790 // do we have _exactly_ one child?
791 wxWindow
*child
= NULL
;
792 for ( wxNode
*node
= GetChildren().First(); node
; node
= node
->Next() )
794 wxWindow
*win
= (wxWindow
*)node
->Data();
795 if ( !win
->IsKindOf(CLASSINFO(wxFrame
)) &&
796 !win
->IsKindOf(CLASSINFO(wxDialog
)) &&
797 (win
!= GetStatusBar()) &&
798 (win
!= GetToolBar()) )
801 return; // it's our second subwindow - nothing to do
807 // we have exactly one child - set it's size to fill the whole frame
808 int clientW
, clientH
;
809 GetClientSize(&clientW
, &clientH
);
814 child
->SetSize(x
, y
, clientW
, clientH
);
818 // Default activation behaviour - set the focus for the first child
820 void wxFrame::OnActivate(wxActivateEvent
& event
)
822 for(wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
824 // Find a child that's a subwindow, but not a dialog box.
825 wxWindow
*child
= (wxWindow
*)node
->Data();
826 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) &&
827 !child
->IsKindOf(CLASSINFO(wxDialog
)))
835 // The default implementation for the close window event.
836 void wxFrame::OnCloseWindow(wxCloseEvent
& event
)
841 // Destroy the window (delayed, if a managed window)
842 bool wxFrame::Destroy()
844 if (!wxPendingDelete
.Member(this))
845 wxPendingDelete
.Append(this);
849 // Default menu selection behaviour - display a help string
850 void wxFrame::OnMenuHighlight(wxMenuEvent
& event
)
854 int menuId
= event
.GetMenuId();
857 wxMenuBar
*menuBar
= GetMenuBar();
858 if (menuBar
&& menuBar
->FindItem(menuId
))
860 // set status text even if the string is empty - this will at
861 // least remove the string from the item which was previously
863 SetStatusText(menuBar
->GetHelpString(menuId
));
869 wxMenuBar
*wxFrame::GetMenuBar() const
871 return m_frameMenuBar
;
874 void wxFrame::Centre(int direction
)
876 int display_width
, display_height
, width
, height
, x
, y
;
877 wxDisplaySize(&display_width
, &display_height
);
879 GetSize(&width
, &height
);
882 if (direction
& wxHORIZONTAL
)
883 x
= (int)((display_width
- width
)/2);
884 if (direction
& wxVERTICAL
)
885 y
= (int)((display_height
- height
)/2);
887 SetSize(x
, y
, width
, height
);
890 // Call this to simulate a menu command
891 void wxFrame::Command(int id
)
896 void wxFrame::ProcessCommand(int id
)
898 wxCommandEvent
commandEvent(wxEVT_COMMAND_MENU_SELECTED
, id
);
899 commandEvent
.SetInt( id
);
900 commandEvent
.SetEventObject( this );
902 wxMenuBar
*bar
= GetMenuBar() ;
906 wxMenuItem
*item
= bar
->FindItemForId(id
) ;
907 if (item
&& item
->IsCheckable())
909 bar
->Check(id
,!bar
->Checked(id
)) ;
913 // Process events starting with the window with the focus, if any.
914 wxWindow* focusWin = wxFindFocusDescendant(this);
916 wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler();
919 wxEvtHandler
* evtHandler
= GetEventHandler();
920 evtHandler
->ProcessEvent(commandEvent
);
923 // Checks if there is a toolbar, and returns the first free client position
924 wxPoint
wxFrame::GetClientAreaOrigin() const
930 GetToolBar()->GetSize(& w
, & h
);
932 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
944 void wxFrame::ScreenToClient(int *x
, int *y
) const
946 wxWindow::ScreenToClient(x
, y
);
948 // We may be faking the client origin.
949 // So a window that's really at (0, 30) may appear
950 // (to wxWin apps) to be at (0, 0).
951 wxPoint
pt(GetClientAreaOrigin());
956 void wxFrame::ClientToScreen(int *x
, int *y
) const
958 // We may be faking the client origin.
959 // So a window that's really at (0, 30) may appear
960 // (to wxWin apps) to be at (0, 0).
961 wxPoint
pt1(GetClientAreaOrigin());
965 wxWindow::ClientToScreen(x
, y
);
968 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
970 wxCHECK_MSG( m_frameToolBar
== NULL
, FALSE
,
971 "recreating toolbar in wxFrame" );
973 wxToolBar
* toolBar
= OnCreateToolBar(style
, id
, name
);
986 wxToolBar
* wxFrame::OnCreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
988 return new wxToolBar(this, id
, wxDefaultPosition
, wxDefaultSize
, style
, name
);
991 void wxFrame::PositionToolBar()
994 ::GetClientRect((HWND
) GetHWND(), &rect
);
996 if ( GetStatusBar() )
998 int statusX
, statusY
;
999 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
1000 rect
.bottom
-= statusY
;
1006 GetToolBar()->GetSize(& tw
, & th
);
1008 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
1010 // Use the 'real' MSW position
1011 GetToolBar()->SetSize(0, 0, tw
, rect
.bottom
, wxSIZE_NO_ADJUSTMENTS
);
1015 // Use the 'real' MSW position
1016 GetToolBar()->SetSize(0, 0, rect
.right
, th
, wxSIZE_NO_ADJUSTMENTS
);
1021 // propagate our state change to all child frames: this allows us to emulate X
1022 // Windows behaviour where child frames float independently of the parent one
1023 // on the desktop, but are iconized/restored with it
1024 void wxFrame::IconizeChildFrames(bool bIconize
)
1026 for ( wxWindowList::Node
*node
= GetChildren().GetFirst();
1028 node
= node
->GetNext() )
1030 wxWindow
*win
= node
->GetData();
1032 if ( win
->IsKindOf(CLASSINFO(wxFrame
)) )
1034 ((wxFrame
*)win
)->Iconize(bIconize
);
1039 // ===========================================================================
1040 // our private (non virtual) message handlers
1041 // ===========================================================================
1043 bool wxFrame::HandleMenuSelect(WXWORD nItem
, WXWORD nFlags
, WXHMENU hMenu
)
1046 if ( nFlags
== 0xFFFF && hMenu
== 0 )
1048 // FIXME: what does this do? does it ever happen?
1051 else if ((nFlags
!= MF_SEPARATOR
) && (nItem
!= 0) && (nItem
!= 65535))
1060 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, item
);
1061 event
.SetEventObject( this );
1063 return GetEventHandler()->ProcessEvent(event
);
1066 // ---------------------------------------------------------------------------
1067 // the window proc for wxFrame
1068 // ---------------------------------------------------------------------------
1070 long wxFrame::MSWWindowProc(WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
)
1073 bool processed
= FALSE
;
1079 WORD item
= (WORD
)wParam
;
1081 WORD flags
= HIWORD(wParam
);
1082 HMENU sysmenu
= (HMENU
)lParam
;
1084 WORD flags
= LOWORD(lParam
);
1085 HMENU sysmenu
= (HMENU
)HIWORD(lParam
);
1087 processed
= HandleMenuSelect(item
, flags
, (WXHMENU
)sysmenu
);
1093 rc
= wxWindow::MSWWindowProc(message
, wParam
, lParam
);