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 wxUSE_NATIVE_STATUSBAR
44 #include <wx/msw/statbr95.h>
47 extern wxList wxModelessWindows
;
48 extern wxList WXDLLEXPORT wxPendingDelete
;
49 extern char wxFrameClassName
[];
50 extern wxMenu
*wxCurrentPopupMenu
;
52 #if !USE_SHARED_LIBRARY
53 BEGIN_EVENT_TABLE(wxFrame
, wxWindow
)
54 EVT_SIZE(wxFrame::OnSize
)
55 EVT_ACTIVATE(wxFrame::OnActivate
)
56 EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight
)
57 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
58 EVT_IDLE(wxFrame::OnIdle
)
59 EVT_CLOSE(wxFrame::OnCloseWindow
)
62 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
65 #if wxUSE_NATIVE_STATUSBAR
66 bool wxFrame::m_useNativeStatusBar
= TRUE
;
68 bool wxFrame::m_useNativeStatusBar
= FALSE
;
73 m_frameToolBar
= NULL
;
74 m_frameMenuBar
= NULL
;
75 m_frameStatusBar
= NULL
;
77 m_windowParent
= 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 MSWCreate(m_windowId
, NULL
, wxFrameClassName
, this, title
,
123 x
, y
, width
, height
, style
);
125 wxModelessWindows
.Append(this);
131 m_isBeingDeleted
= TRUE
;
132 wxTopLevelWindows
.DeleteObject(this);
134 if (m_frameStatusBar
)
135 delete m_frameStatusBar
;
137 delete m_frameMenuBar
;
139 /* New behaviour March 1998: check if it's the last top-level window */
140 // if (wxTheApp && (this == wxTheApp->GetTopWindow()))
142 if (wxTheApp
&& (wxTopLevelWindows
.Number() == 0))
144 wxTheApp
->SetTopWindow(NULL
);
146 if (wxTheApp
->GetExitOnFrameDelete())
152 wxModelessWindows
.DeleteObject(this);
154 // For some reason, wxWindows can activate another task altogether
155 // when a frame is destroyed after a modal dialog has been invoked.
156 // Try to bring the parent to the top.
157 if (GetParent() && GetParent()->GetHWND())
158 ::BringWindowToTop((HWND
) GetParent()->GetHWND());
161 WXHMENU
wxFrame::GetWinMenu() const
166 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
167 void wxFrame::GetClientSize(int *x
, int *y
) const
170 ::GetClientRect((HWND
) GetHWND(), &rect
);
172 if ( GetStatusBar() )
174 int statusX
, statusY
;
175 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
176 rect
.bottom
-= statusY
;
179 wxPoint
pt(GetClientAreaOrigin());
187 // Set the client size (i.e. leave the calculation of borders etc.
189 void wxFrame::DoSetClientSize(int width
, int height
)
191 HWND hWnd
= (HWND
) GetHWND();
194 ::GetClientRect(hWnd
, &rect
);
197 GetWindowRect(hWnd
, &rect2
);
199 // Find the difference between the entire window (title bar and all)
200 // and the client area; add this to the new client size to move the
202 int actual_width
= rect2
.right
- rect2
.left
- rect
.right
+ width
;
203 int actual_height
= rect2
.bottom
- rect2
.top
- rect
.bottom
+ height
;
205 if ( GetStatusBar() )
207 int statusX
, statusY
;
208 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
209 actual_height
+= statusY
;
212 wxPoint
pt(GetClientAreaOrigin());
213 actual_width
+= pt
.y
;
214 actual_height
+= pt
.x
;
217 point
.x
= rect2
.left
;
220 MoveWindow(hWnd
, point
.x
, point
.y
, actual_width
, actual_height
, (BOOL
)TRUE
);
222 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
223 event
.SetEventObject( this );
224 GetEventHandler()->ProcessEvent(event
);
227 void wxFrame::GetSize(int *width
, int *height
) const
230 GetWindowRect((HWND
) GetHWND(), &rect
);
231 *width
= rect
.right
- rect
.left
;
232 *height
= rect
.bottom
- rect
.top
;
235 void wxFrame::GetPosition(int *x
, int *y
) const
238 GetWindowRect((HWND
) GetHWND(), &rect
);
247 void wxFrame::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
249 int currentX
, currentY
;
255 GetPosition(¤tX
, ¤tY
);
256 if (x
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
258 if (y
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
263 if (width
== -1) w1
= ww
;
264 if (height
==-1) h1
= hh
;
266 MoveWindow((HWND
) GetHWND(), x1
, y1
, w1
, h1
, (BOOL
)TRUE
);
268 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
269 event
.SetEventObject( this );
270 GetEventHandler()->ProcessEvent(event
);
273 bool wxFrame::Show(bool show
)
283 // Try to highlight the correct window (the parent)
287 hWndParent
= (HWND
) GetParent()->GetHWND();
289 ::BringWindowToTop(hWndParent
);
293 ShowWindow((HWND
) GetHWND(), (BOOL
)cshow
);
296 BringWindowToTop((HWND
) GetHWND());
298 wxActivateEvent
event(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
299 event
.SetEventObject( this );
300 GetEventHandler()->ProcessEvent(event
);
305 void wxFrame::Iconize(bool iconize
)
315 ShowWindow((HWND
) GetHWND(), (BOOL
)cshow
);
316 m_iconized
= iconize
;
319 // Equivalent to maximize/restore in Windows
320 void wxFrame::Maximize(bool maximize
)
328 ShowWindow((HWND
) GetHWND(), cshow
);
332 bool wxFrame::IsIconized() const
334 ((wxFrame
*)this)->m_iconized
= (::IsIconic((HWND
) GetHWND()) != 0);
339 bool wxFrame::IsMaximized() const
341 return (::IsZoomed((HWND
) GetHWND()) != 0) ;
344 void wxFrame::SetTitle(const wxString
& title
)
346 SetWindowText((HWND
) GetHWND(), (const char *)title
);
349 wxString
wxFrame::GetTitle() const
351 GetWindowText((HWND
) GetHWND(), wxBuffer
, 1000);
352 return wxString(wxBuffer
);
355 void wxFrame::SetIcon(const wxIcon
& icon
)
358 #if defined(__WIN95__)
360 SendMessage((HWND
) GetHWND(), WM_SETICON
,
361 (WPARAM
)TRUE
, (LPARAM
)(HICON
) m_icon
.GetHICON());
365 wxStatusBar
*wxFrame::OnCreateStatusBar(int number
, long style
, wxWindowID id
,
366 const wxString
& name
)
368 wxStatusBar
*statusBar
= NULL
;
370 #if wxUSE_NATIVE_STATUSBAR
371 if (UsesNativeStatusBar())
373 statusBar
= new wxStatusBar95(this, id
, style
);
378 statusBar
= new wxStatusBar(this, id
, wxPoint(0, 0), wxSize(100, 20),
381 // Set the height according to the font and the border size
382 wxClientDC
dc(statusBar
);
383 dc
.SetFont(statusBar
->GetFont());
386 dc
.GetTextExtent("X", &x
, &y
);
388 int height
= (int)( (y
* 1.1) + 2* statusBar
->GetBorderY());
390 statusBar
->SetSize(-1, -1, 100, height
);
393 statusBar
->SetFieldsCount(number
);
397 wxStatusBar
* wxFrame::CreateStatusBar(int number
, long style
, wxWindowID id
,
398 const wxString
& name
)
400 // VZ: calling CreateStatusBar twice is an error - why anyone would do it?
401 wxCHECK_MSG( m_frameStatusBar
== NULL
, FALSE
,
402 "recreating status bar in wxFrame" );
404 m_frameStatusBar
= OnCreateStatusBar(number
, style
, id
,
406 if ( m_frameStatusBar
)
409 return m_frameStatusBar
;
415 void wxFrame::SetStatusText(const wxString
& text
, int number
)
417 wxCHECK_RET( m_frameStatusBar
!= NULL
, "no statusbar to set text for" );
419 m_frameStatusBar
->SetStatusText(text
, number
);
422 void wxFrame::SetStatusWidths(int n
, const int widths_field
[])
424 wxCHECK_RET( m_frameStatusBar
!= NULL
, "no statusbar to set widths for" );
426 m_frameStatusBar
->SetStatusWidths(n
, widths_field
);
430 void wxFrame::PositionStatusBar()
432 // native status bar positions itself
434 #if wxUSE_NATIVE_STATUSBAR
435 && !m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
))
440 GetClientSize(&w
, &h
);
442 m_frameStatusBar
->GetSize(&sw
, &sh
);
444 // Since we wish the status bar to be directly under the client area,
445 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
446 m_frameStatusBar
->SetSize(0, h
, w
, sh
);
450 void wxFrame::SetMenuBar(wxMenuBar
*menu_bar
)
454 m_frameMenuBar
= NULL
;
458 wxCHECK_RET( !menu_bar
->GetFrame(), "this menubar is already attached" );
461 delete m_frameMenuBar
;
463 m_hMenu
= menu_bar
->Create();
468 if ( !::SetMenu((HWND
)GetHWND(), (HMENU
)m_hMenu
) )
470 wxLogLastError("SetMenu");
473 m_frameMenuBar
= menu_bar
;
474 menu_bar
->Attach(this);
478 bool wxFrame::LoadAccelerators(const wxString
& table
)
480 m_acceleratorTable
= (WXHANDLE
)
483 ::LoadAcceleratorsW(wxGetInstance(), (const char *)table
);
485 ::LoadAcceleratorsA(wxGetInstance(), (const char *)table
);
488 ::LoadAccelerators(wxGetInstance(), (const char *)table
);
491 // The above is necessary because LoadAccelerators is a macro
492 // which we have undefed earlier in the file to avoid confusion
493 // with wxFrame::LoadAccelerators. Ugh!
495 return (m_acceleratorTable
!= (WXHANDLE
) NULL
);
501 // Work out max. size
502 wxNode
*node
= GetChildren().First();
507 // Find a child that's a subwindow, but not a dialog box.
508 wxWindow
*win
= (wxWindow
*)node
->Data();
510 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) &&
511 !win
->IsKindOf(CLASSINFO(wxDialog
)))
515 win
->GetSize(&width
, &height
);
516 win
->GetPosition(&x
, &y
);
518 if ((x
+ width
) > max_width
)
519 max_width
= x
+ width
;
520 if ((y
+ height
) > max_height
)
521 max_height
= y
+ height
;
525 SetClientSize(max_width
, max_height
);
528 // Responds to colour changes, and passes event on to children.
529 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
531 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
534 if ( m_frameStatusBar
)
536 wxSysColourChangedEvent event2
;
537 event2
.SetEventObject( m_frameStatusBar
);
538 m_frameStatusBar
->GetEventHandler()->ProcessEvent(event2
);
541 // Propagate the event to the non-top-level children
542 wxWindow::OnSysColourChanged(event
);
550 void wxFrame::MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
551 int x
, int y
, int width
, int height
, long style
)
554 m_defaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
556 // If child windows aren't properly drawn initially, WS_CLIPCHILDREN
557 // could be the culprit. But without it, you can get a lot of flicker.
560 if ((style
& wxCAPTION
) == wxCAPTION
)
561 msflags
= WS_OVERLAPPED
;
565 if (style
& wxMINIMIZE_BOX
)
566 msflags
|= WS_MINIMIZEBOX
;
567 if (style
& wxMAXIMIZE_BOX
)
568 msflags
|= WS_MAXIMIZEBOX
;
569 if (style
& wxTHICK_FRAME
)
570 msflags
|= WS_THICKFRAME
;
571 if (style
& wxSYSTEM_MENU
)
572 msflags
|= WS_SYSMENU
;
573 if ((style
& wxMINIMIZE
) || (style
& wxICONIZE
))
574 msflags
|= WS_MINIMIZE
;
575 if (style
& wxMAXIMIZE
)
576 msflags
|= WS_MAXIMIZE
;
577 if (style
& wxCAPTION
)
578 msflags
|= WS_CAPTION
;
579 if (style
& wxCLIP_CHILDREN
)
580 msflags
|= WS_CLIPCHILDREN
;
582 // Keep this in wxFrame because it saves recoding this function
585 if (style
& wxTINY_CAPTION_VERT
)
586 msflags
|= IBS_VERTCAPTION
;
587 if (style
& wxTINY_CAPTION_HORIZ
)
588 msflags
|= IBS_HORZCAPTION
;
590 if (style
& wxTINY_CAPTION_VERT
)
591 msflags
|= WS_CAPTION
;
592 if (style
& wxTINY_CAPTION_HORIZ
)
593 msflags
|= WS_CAPTION
;
595 if ((style
& wxTHICK_FRAME
) == 0)
596 msflags
|= WS_BORDER
;
598 WXDWORD extendedStyle
= MakeExtendedStyle(style
);
600 #if !defined(__WIN16__) && !defined(__SC__)
601 if (style
& wxFRAME_TOOL_WINDOW
)
602 extendedStyle
|= WS_EX_TOOLWINDOW
;
605 if (style
& wxSTAY_ON_TOP
)
606 extendedStyle
|= WS_EX_TOPMOST
;
609 wxWindow::MSWCreate(id
, parent
, wclass
, wx_win
, title
, x
, y
, width
, height
,
610 msflags
, NULL
, extendedStyle
);
611 // Seems to be necessary if we use WS_POPUP
612 // style instead of WS_OVERLAPPED
613 if (width
> -1 && height
> -1)
614 ::PostMessage((HWND
) GetHWND(), WM_SIZE
, SIZE_RESTORED
, MAKELPARAM(width
, height
));
617 bool wxFrame::MSWOnPaint()
620 if (GetUpdateRect((HWND
) GetHWND(), &rect
, FALSE
))
626 the_icon
= (HICON
) m_icon
.GetHICON();
628 the_icon
= (HICON
) m_defaultIcon
;
631 // Hold a pointer to the dc so long as the OnPaint() message
632 // is being processed
633 HDC cdc
= BeginPaint((HWND
) GetHWND(), &ps
);
635 // Erase background before painting or we get white background
636 this->MSWDefWindowProc(WM_ICONERASEBKGND
,(WORD
)(LONG
) ps
.hdc
,0L);
641 ::GetClientRect((HWND
) GetHWND(), &rect
);
643 int icon_height
= 32;
644 int icon_x
= (int)((rect
.right
- icon_width
)/2);
645 int icon_y
= (int)((rect
.bottom
- icon_height
)/2);
646 DrawIcon(cdc
, icon_x
, icon_y
, the_icon
);
649 EndPaint((HWND
) GetHWND(), &ps
);
653 wxPaintEvent
event(m_windowId
);
654 event
.m_eventObject
= this;
655 if (!GetEventHandler()->ProcessEvent(event
))
663 WXHICON
wxFrame::MSWOnQueryDragIcon()
665 if (m_icon
.Ok() && (m_icon
.GetHICON() != 0))
666 return m_icon
.GetHICON();
668 return m_defaultIcon
;
671 void wxFrame::MSWOnSize(int x
, int y
, WXUINT id
)
676 // only do it it if we were iconized before, otherwise resizing the
677 // parent frame has a curious side effect of bringing it under it's
682 // restore all child frames too
683 IconizeChildFrames(FALSE
);
692 // iconize all child frames too
693 IconizeChildFrames(TRUE
);
701 // forward WM_SIZE to status bar control
702 #if wxUSE_NATIVE_STATUSBAR
703 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
705 wxSizeEvent
event(wxSize(x
, y
), m_frameStatusBar
->GetId());
706 event
.SetEventObject( m_frameStatusBar
);
708 ((wxStatusBar95
*)m_frameStatusBar
)->OnSize(event
);
715 wxSizeEvent
event(wxSize(x
, y
), m_windowId
);
716 event
.SetEventObject( this );
717 if (!GetEventHandler()->ProcessEvent(event
))
722 bool wxFrame::MSWOnClose()
727 bool wxFrame::MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
729 if (cmd
== 0 || cmd
== 1 ) // Can be either a menu command or an accelerator.
731 // In case it's e.g. a toolbar.
732 wxWindow
*win
= wxFindWinFromHandle(control
);
734 return win
->MSWCommand(cmd
, id
);
736 if (wxCurrentPopupMenu
)
738 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
739 wxCurrentPopupMenu
= NULL
;
740 if (popupMenu
->MSWCommand(cmd
, id
))
744 if (GetMenuBar() && GetMenuBar()->FindItemForId(id
))
753 return wxWindow::MSWOnCommand(id
, cmd
, control
);
756 void wxFrame::MSWOnMenuHighlight(WXWORD nItem
, WXWORD nFlags
, WXHMENU hSysMenu
)
758 if (nFlags
== 0xFFFF && hSysMenu
== 0)
760 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, -1);
761 event
.SetEventObject( this );
762 GetEventHandler()->ProcessEvent(event
);
764 else if ((nFlags
!= MF_SEPARATOR
) && (nItem
!= 0) && (nItem
!= 65535))
766 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, nItem
);
767 event
.SetEventObject( this );
768 GetEventHandler()->ProcessEvent(event
);
772 bool wxFrame::MSWProcessMessage(WXMSG
* pMsg
)
777 bool wxFrame::MSWTranslateMessage(WXMSG
* pMsg
)
779 if (m_acceleratorTable
.Ok() &&
780 ::TranslateAccelerator((HWND
) GetHWND(), (HACCEL
) m_acceleratorTable
.GetHACCEL(), (MSG
*)pMsg
))
786 // Default resizing behaviour - if only ONE subwindow,
787 // resize to client rectangle size
788 void wxFrame::OnSize(wxSizeEvent
& event
)
790 // if we're using constraints - do use them
791 #if wxUSE_CONSTRAINTS
792 if ( GetAutoLayout() ) {
798 // do we have _exactly_ one child?
799 wxWindow
*child
= NULL
;
800 for ( wxNode
*node
= GetChildren().First(); node
; node
= node
->Next() )
802 wxWindow
*win
= (wxWindow
*)node
->Data();
803 if ( !win
->IsKindOf(CLASSINFO(wxFrame
)) &&
804 !win
->IsKindOf(CLASSINFO(wxDialog
)) &&
805 (win
!= GetStatusBar()) &&
806 (win
!= GetToolBar()) )
809 return; // it's our second subwindow - nothing to do
815 // we have exactly one child - set it's size to fill the whole frame
816 int clientW
, clientH
;
817 GetClientSize(&clientW
, &clientH
);
822 child
->SetSize(x
, y
, clientW
, clientH
);
826 // Default activation behaviour - set the focus for the first child
828 void wxFrame::OnActivate(wxActivateEvent
& event
)
830 for(wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
832 // Find a child that's a subwindow, but not a dialog box.
833 wxWindow
*child
= (wxWindow
*)node
->Data();
834 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) &&
835 !child
->IsKindOf(CLASSINFO(wxDialog
)))
843 // The default implementation for the close window event.
844 void wxFrame::OnCloseWindow(wxCloseEvent
& event
)
849 // Destroy the window (delayed, if a managed window)
850 bool wxFrame::Destroy()
852 if (!wxPendingDelete
.Member(this))
853 wxPendingDelete
.Append(this);
857 // Default menu selection behaviour - display a help string
858 void wxFrame::OnMenuHighlight(wxMenuEvent
& event
)
862 int menuId
= event
.GetMenuId();
865 wxMenuBar
*menuBar
= GetMenuBar();
866 if (menuBar
&& menuBar
->FindItem(menuId
))
868 // set status text even if the string is empty - this will at
869 // least remove the string from the item which was previously
871 SetStatusText(menuBar
->GetHelpString(menuId
));
877 wxMenuBar
*wxFrame::GetMenuBar() const
879 return m_frameMenuBar
;
882 void wxFrame::Centre(int direction
)
884 int display_width
, display_height
, width
, height
, x
, y
;
885 wxDisplaySize(&display_width
, &display_height
);
887 GetSize(&width
, &height
);
890 if (direction
& wxHORIZONTAL
)
891 x
= (int)((display_width
- width
)/2);
892 if (direction
& wxVERTICAL
)
893 y
= (int)((display_height
- height
)/2);
895 SetSize(x
, y
, width
, height
);
898 // Call this to simulate a menu command
899 void wxFrame::Command(int id
)
904 void wxFrame::ProcessCommand(int id
)
906 wxCommandEvent
commandEvent(wxEVT_COMMAND_MENU_SELECTED
, id
);
907 commandEvent
.SetInt( id
);
908 commandEvent
.SetEventObject( this );
910 wxMenuBar
*bar
= GetMenuBar() ;
914 wxMenuItem
*item
= bar
->FindItemForId(id
) ;
915 if (item
&& item
->IsCheckable())
917 bar
->Check(id
,!bar
->Checked(id
)) ;
919 GetEventHandler()->ProcessEvent(commandEvent
);
922 // Checks if there is a toolbar, and returns the first free client position
923 wxPoint
wxFrame::GetClientAreaOrigin() const
929 GetToolBar()->GetSize(& w
, & h
);
931 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
943 void wxFrame::ScreenToClient(int *x
, int *y
) const
945 wxWindow::ScreenToClient(x
, y
);
947 // We may be faking the client origin.
948 // So a window that's really at (0, 30) may appear
949 // (to wxWin apps) to be at (0, 0).
950 wxPoint
pt(GetClientAreaOrigin());
955 void wxFrame::ClientToScreen(int *x
, int *y
) const
957 // We may be faking the client origin.
958 // So a window that's really at (0, 30) may appear
959 // (to wxWin apps) to be at (0, 0).
960 wxPoint
pt1(GetClientAreaOrigin());
964 wxWindow::ClientToScreen(x
, y
);
967 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
969 wxCHECK_MSG( m_frameToolBar
== NULL
, FALSE
,
970 "recreating toolbar in wxFrame" );
972 wxToolBar
* toolBar
= OnCreateToolBar(style
, id
, name
);
985 wxToolBar
* wxFrame::OnCreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
987 return new wxToolBar(this, id
, wxDefaultPosition
, wxDefaultSize
, style
, name
);
990 void wxFrame::PositionToolBar()
993 ::GetClientRect((HWND
) GetHWND(), &rect
);
995 if ( GetStatusBar() )
997 int statusX
, statusY
;
998 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
999 rect
.bottom
-= statusY
;
1005 GetToolBar()->GetSize(& tw
, & th
);
1007 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
1009 // Use the 'real' MSW position
1010 GetToolBar()->SetSize(0, 0, tw
, rect
.bottom
, wxSIZE_NO_ADJUSTMENTS
);
1014 // Use the 'real' MSW position
1015 GetToolBar()->SetSize(0, 0, rect
.right
, th
, wxSIZE_NO_ADJUSTMENTS
);
1020 // propagate our state change to all child frames
1021 void wxFrame::IconizeChildFrames(bool bIconize
)
1023 for ( wxNode
*node
= GetChildren().First(); node
; node
= node
->Next() ) {
1024 wxWindow
*win
= (wxWindow
*)node
->Data();
1025 if ( win
->IsKindOf(CLASSINFO(wxFrame
)) ) {
1026 ((wxFrame
*)win
)->Iconize(bIconize
);