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 // 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::GetClientSize(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::GetSize(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::GetPosition(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 void 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 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()
625 if (GetUpdateRect((HWND
) GetHWND(), &rect
, FALSE
))
631 the_icon
= (HICON
) m_icon
.GetHICON();
633 the_icon
= (HICON
) m_defaultIcon
;
636 // Hold a pointer to the dc so long as the OnPaint() message
637 // is being processed
638 HDC cdc
= BeginPaint((HWND
) GetHWND(), &ps
);
640 // Erase background before painting or we get white background
641 this->MSWDefWindowProc(WM_ICONERASEBKGND
,(WORD
)(LONG
) ps
.hdc
,0L);
646 ::GetClientRect((HWND
) GetHWND(), &rect
);
648 int icon_height
= 32;
649 int icon_x
= (int)((rect
.right
- icon_width
)/2);
650 int icon_y
= (int)((rect
.bottom
- icon_height
)/2);
651 DrawIcon(cdc
, icon_x
, icon_y
, the_icon
);
654 EndPaint((HWND
) GetHWND(), &ps
);
658 wxPaintEvent
event(m_windowId
);
659 event
.m_eventObject
= this;
660 if (!GetEventHandler()->ProcessEvent(event
))
668 WXHICON
wxFrame::MSWOnQueryDragIcon()
670 if (m_icon
.Ok() && (m_icon
.GetHICON() != 0))
671 return m_icon
.GetHICON();
673 return m_defaultIcon
;
676 void wxFrame::MSWOnSize(int x
, int y
, WXUINT id
)
681 // only do it it if we were iconized before, otherwise resizing the
682 // parent frame has a curious side effect of bringing it under it's
687 // restore all child frames too
688 IconizeChildFrames(FALSE
);
697 // iconize all child frames too
698 IconizeChildFrames(TRUE
);
706 // forward WM_SIZE to status bar control
707 #if wxUSE_NATIVE_STATUSBAR
708 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
710 wxSizeEvent
event(wxSize(x
, y
), m_frameStatusBar
->GetId());
711 event
.SetEventObject( m_frameStatusBar
);
713 ((wxStatusBar95
*)m_frameStatusBar
)->OnSize(event
);
720 wxSizeEvent
event(wxSize(x
, y
), m_windowId
);
721 event
.SetEventObject( this );
722 if (!GetEventHandler()->ProcessEvent(event
))
727 bool wxFrame::MSWOnClose()
732 bool wxFrame::MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
734 if (cmd
== 0 || cmd
== 1 ) // Can be either a menu command or an accelerator.
736 // In case it's e.g. a toolbar.
737 wxWindow
*win
= wxFindWinFromHandle(control
);
739 return win
->MSWCommand(cmd
, id
);
741 if (wxCurrentPopupMenu
)
743 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
744 wxCurrentPopupMenu
= NULL
;
745 if (popupMenu
->MSWCommand(cmd
, id
))
749 if (GetMenuBar() && GetMenuBar()->FindItemForId(id
))
758 return wxWindow::MSWOnCommand(id
, cmd
, control
);
761 void wxFrame::MSWOnMenuHighlight(WXWORD nItem
, WXWORD nFlags
, WXHMENU hSysMenu
)
763 if (nFlags
== 0xFFFF && hSysMenu
== 0)
765 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, -1);
766 event
.SetEventObject( this );
767 GetEventHandler()->ProcessEvent(event
);
769 else if ((nFlags
!= MF_SEPARATOR
) && (nItem
!= 0) && (nItem
!= 65535))
771 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, nItem
);
772 event
.SetEventObject( this );
773 GetEventHandler()->ProcessEvent(event
);
777 bool wxFrame::MSWProcessMessage(WXMSG
* pMsg
)
782 bool wxFrame::MSWTranslateMessage(WXMSG
* pMsg
)
784 if (m_acceleratorTable
.Ok() &&
785 ::TranslateAccelerator((HWND
) GetHWND(), (HACCEL
) m_acceleratorTable
.GetHACCEL(), (MSG
*)pMsg
))
791 // Default resizing behaviour - if only ONE subwindow,
792 // resize to client rectangle size
793 void wxFrame::OnSize(wxSizeEvent
& event
)
795 // if we're using constraints - do use them
796 #if wxUSE_CONSTRAINTS
797 if ( GetAutoLayout() ) {
803 // do we have _exactly_ one child?
804 wxWindow
*child
= NULL
;
805 for ( wxNode
*node
= GetChildren().First(); node
; node
= node
->Next() )
807 wxWindow
*win
= (wxWindow
*)node
->Data();
808 if ( !win
->IsKindOf(CLASSINFO(wxFrame
)) &&
809 !win
->IsKindOf(CLASSINFO(wxDialog
)) &&
810 (win
!= GetStatusBar()) &&
811 (win
!= GetToolBar()) )
814 return; // it's our second subwindow - nothing to do
820 // we have exactly one child - set it's size to fill the whole frame
821 int clientW
, clientH
;
822 GetClientSize(&clientW
, &clientH
);
827 child
->SetSize(x
, y
, clientW
, clientH
);
831 // Default activation behaviour - set the focus for the first child
833 void wxFrame::OnActivate(wxActivateEvent
& event
)
835 for(wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
837 // Find a child that's a subwindow, but not a dialog box.
838 wxWindow
*child
= (wxWindow
*)node
->Data();
839 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) &&
840 !child
->IsKindOf(CLASSINFO(wxDialog
)))
848 // The default implementation for the close window event.
849 void wxFrame::OnCloseWindow(wxCloseEvent
& event
)
854 // Destroy the window (delayed, if a managed window)
855 bool wxFrame::Destroy()
857 if (!wxPendingDelete
.Member(this))
858 wxPendingDelete
.Append(this);
862 // Default menu selection behaviour - display a help string
863 void wxFrame::OnMenuHighlight(wxMenuEvent
& event
)
867 int menuId
= event
.GetMenuId();
870 wxMenuBar
*menuBar
= GetMenuBar();
871 if (menuBar
&& menuBar
->FindItem(menuId
))
873 // set status text even if the string is empty - this will at
874 // least remove the string from the item which was previously
876 SetStatusText(menuBar
->GetHelpString(menuId
));
882 wxMenuBar
*wxFrame::GetMenuBar() const
884 return m_frameMenuBar
;
887 void wxFrame::Centre(int direction
)
889 int display_width
, display_height
, width
, height
, x
, y
;
890 wxDisplaySize(&display_width
, &display_height
);
892 GetSize(&width
, &height
);
895 if (direction
& wxHORIZONTAL
)
896 x
= (int)((display_width
- width
)/2);
897 if (direction
& wxVERTICAL
)
898 y
= (int)((display_height
- height
)/2);
900 SetSize(x
, y
, width
, height
);
903 // Call this to simulate a menu command
904 void wxFrame::Command(int id
)
909 void wxFrame::ProcessCommand(int id
)
911 wxCommandEvent
commandEvent(wxEVT_COMMAND_MENU_SELECTED
, id
);
912 commandEvent
.SetInt( id
);
913 commandEvent
.SetEventObject( this );
915 wxMenuBar
*bar
= GetMenuBar() ;
919 wxMenuItem
*item
= bar
->FindItemForId(id
) ;
920 if (item
&& item
->IsCheckable())
922 bar
->Check(id
,!bar
->Checked(id
)) ;
926 // Process events starting with the window with the focus, if any.
927 wxWindow* focusWin = wxFindFocusDescendant(this);
929 wxEvtHandler* evtHandler = focusWin ? focusWin->GetEventHandler() : GetEventHandler();
932 wxEvtHandler
* evtHandler
= GetEventHandler();
933 evtHandler
->ProcessEvent(commandEvent
);
936 // Checks if there is a toolbar, and returns the first free client position
937 wxPoint
wxFrame::GetClientAreaOrigin() const
943 GetToolBar()->GetSize(& w
, & h
);
945 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
957 void wxFrame::ScreenToClient(int *x
, int *y
) const
959 wxWindow::ScreenToClient(x
, y
);
961 // We may be faking the client origin.
962 // So a window that's really at (0, 30) may appear
963 // (to wxWin apps) to be at (0, 0).
964 wxPoint
pt(GetClientAreaOrigin());
969 void wxFrame::ClientToScreen(int *x
, int *y
) const
971 // We may be faking the client origin.
972 // So a window that's really at (0, 30) may appear
973 // (to wxWin apps) to be at (0, 0).
974 wxPoint
pt1(GetClientAreaOrigin());
978 wxWindow::ClientToScreen(x
, y
);
981 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
983 wxCHECK_MSG( m_frameToolBar
== NULL
, FALSE
,
984 "recreating toolbar in wxFrame" );
986 wxToolBar
* toolBar
= OnCreateToolBar(style
, id
, name
);
999 wxToolBar
* wxFrame::OnCreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
1001 return new wxToolBar(this, id
, wxDefaultPosition
, wxDefaultSize
, style
, name
);
1004 void wxFrame::PositionToolBar()
1007 ::GetClientRect((HWND
) GetHWND(), &rect
);
1009 if ( GetStatusBar() )
1011 int statusX
, statusY
;
1012 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
1013 rect
.bottom
-= statusY
;
1019 GetToolBar()->GetSize(& tw
, & th
);
1021 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
1023 // Use the 'real' MSW position
1024 GetToolBar()->SetSize(0, 0, tw
, rect
.bottom
, wxSIZE_NO_ADJUSTMENTS
);
1028 // Use the 'real' MSW position
1029 GetToolBar()->SetSize(0, 0, rect
.right
, th
, wxSIZE_NO_ADJUSTMENTS
);
1034 // propagate our state change to all child frames
1035 void wxFrame::IconizeChildFrames(bool bIconize
)
1037 for ( wxNode
*node
= GetChildren().First(); node
; node
= node
->Next() ) {
1038 wxWindow
*win
= (wxWindow
*)node
->Data();
1039 if ( win
->IsKindOf(CLASSINFO(wxFrame
)) ) {
1040 ((wxFrame
*)win
)->Iconize(bIconize
);