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 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
;
71 wxFrame::wxFrame(void)
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
,
90 wxTopLevelWindows
.Append(this);
93 // m_modalShowing = FALSE;
94 m_windowStyle
= style
;
95 m_frameMenuBar
= NULL
;
96 m_frameToolBar
= NULL
;
97 m_frameStatusBar
= NULL
;
99 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
105 m_windowId
= (int)NewControlId();
107 if (parent
) parent
->AddChild(this);
116 // we pass NULL as parent to MSWCreate because frames with parents behave
117 // very strangely under Win95 shell
118 MSWCreate(m_windowId
, NULL
, wxFrameClassName
, this, title
,
119 x
, y
, width
, height
, style
);
121 wxModelessWindows
.Append(this);
125 wxFrame::~wxFrame(void)
127 m_isBeingDeleted
= TRUE
;
128 wxTopLevelWindows
.DeleteObject(this);
130 if (m_frameStatusBar
)
131 delete m_frameStatusBar
;
133 delete m_frameMenuBar
;
135 /* New behaviour March 1998: check if it's the last top-level window */
136 // if (wxTheApp && (this == wxTheApp->GetTopWindow()))
138 if (wxTheApp
&& (wxTopLevelWindows
.Number() == 0))
140 wxTheApp
->SetTopWindow(NULL
);
142 if (wxTheApp
->GetExitOnFrameDelete())
148 wxModelessWindows
.DeleteObject(this);
150 // For some reason, wxWindows can activate another task altogether
151 // when a frame is destroyed after a modal dialog has been invoked.
152 // Try to bring the parent to the top.
153 if (GetParent() && GetParent()->GetHWND())
154 ::BringWindowToTop((HWND
) GetParent()->GetHWND());
157 WXHMENU
wxFrame::GetWinMenu(void) const
162 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
163 void wxFrame::GetClientSize(int *x
, int *y
) const
166 GetClientRect((HWND
) GetHWND(), &rect
);
168 if ( GetStatusBar() )
170 int statusX
, statusY
;
171 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
172 rect
.bottom
-= statusY
;
175 wxPoint
pt(GetClientAreaOrigin());
183 // Set the client size (i.e. leave the calculation of borders etc.
185 void wxFrame::SetClientSize(int width
, int height
)
187 HWND hWnd
= (HWND
) GetHWND();
190 GetClientRect(hWnd
, &rect
);
193 GetWindowRect(hWnd
, &rect2
);
195 // Find the difference between the entire window (title bar and all)
196 // and the client area; add this to the new client size to move the
198 int actual_width
= rect2
.right
- rect2
.left
- rect
.right
+ width
;
199 int actual_height
= rect2
.bottom
- rect2
.top
- rect
.bottom
+ height
;
201 if ( GetStatusBar() )
203 int statusX
, statusY
;
204 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
205 actual_height
+= statusY
;
208 wxPoint
pt(GetClientAreaOrigin());
209 actual_width
+= pt
.y
;
210 actual_height
+= pt
.x
;
213 point
.x
= rect2
.left
;
216 MoveWindow(hWnd
, point
.x
, point
.y
, actual_width
, actual_height
, (BOOL
)TRUE
);
218 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
219 event
.SetEventObject( this );
220 GetEventHandler()->ProcessEvent(event
);
223 void wxFrame::GetSize(int *width
, int *height
) const
226 GetWindowRect((HWND
) GetHWND(), &rect
);
227 *width
= rect
.right
- rect
.left
;
228 *height
= rect
.bottom
- rect
.top
;
231 void wxFrame::GetPosition(int *x
, int *y
) const
234 GetWindowRect((HWND
) GetHWND(), &rect
);
243 void wxFrame::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
245 int currentX
, currentY
;
251 GetPosition(¤tX
, ¤tY
);
252 if (x
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
254 if (y
== -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
259 if (width
== -1) w1
= ww
;
260 if (height
==-1) h1
= hh
;
262 MoveWindow((HWND
) GetHWND(), x1
, y1
, w1
, h1
, (BOOL
)TRUE
);
264 wxSizeEvent
event(wxSize(width
, height
), m_windowId
);
265 event
.SetEventObject( this );
266 GetEventHandler()->ProcessEvent(event
);
269 bool wxFrame::Show(bool show
)
279 // Try to highlight the correct window (the parent)
283 hWndParent
= (HWND
) GetParent()->GetHWND();
285 ::BringWindowToTop(hWndParent
);
289 ShowWindow((HWND
) GetHWND(), (BOOL
)cshow
);
292 BringWindowToTop((HWND
) GetHWND());
294 wxActivateEvent
event(wxEVT_ACTIVATE
, TRUE
, m_windowId
);
295 event
.SetEventObject( this );
296 GetEventHandler()->ProcessEvent(event
);
301 void wxFrame::Iconize(bool iconize
)
311 ShowWindow((HWND
) GetHWND(), (BOOL
)cshow
);
312 m_iconized
= iconize
;
315 // Equivalent to maximize/restore in Windows
316 void wxFrame::Maximize(bool maximize
)
324 ShowWindow((HWND
) GetHWND(), cshow
);
328 bool wxFrame::IsIconized(void) const
330 ((wxFrame
*)this)->m_iconized
= (::IsIconic((HWND
) GetHWND()) != 0);
334 void wxFrame::SetTitle(const wxString
& title
)
336 SetWindowText((HWND
) GetHWND(), (const char *)title
);
339 wxString
wxFrame::GetTitle(void) const
341 GetWindowText((HWND
) GetHWND(), wxBuffer
, 1000);
342 return wxString(wxBuffer
);
345 void wxFrame::SetIcon(const wxIcon
& icon
)
348 #if defined(__WIN95__)
350 SendMessage((HWND
) GetHWND(), WM_SETICON
,
351 (WPARAM
)TRUE
, (LPARAM
)(HICON
) m_icon
.GetHICON());
355 wxStatusBar
*wxFrame::OnCreateStatusBar(int number
, long style
, wxWindowID id
,
356 const wxString
& name
)
358 wxStatusBar
*statusBar
= NULL
;
360 #if wxUSE_NATIVE_STATUSBAR
361 if (UsesNativeStatusBar())
363 statusBar
= new wxStatusBar95(this, id
, style
);
368 statusBar
= new wxStatusBar(this, id
, wxPoint(0, 0), wxSize(100, 20),
371 // Set the height according to the font and the border size
372 wxClientDC
dc(statusBar
);
373 dc
.SetFont(statusBar
->GetFont());
376 dc
.GetTextExtent("X", &x
, &y
);
378 int height
= (int)( (y
* 1.1) + 2* statusBar
->GetBorderY());
380 statusBar
->SetSize(-1, -1, 100, height
);
383 statusBar
->SetFieldsCount(number
);
387 wxStatusBar
* wxFrame::CreateStatusBar(int number
, long style
, wxWindowID id
,
388 const wxString
& name
)
390 // VZ: calling CreateStatusBar twice is an error - why anyone would do it?
391 wxCHECK_MSG( m_frameStatusBar
== NULL
, FALSE
,
392 "recreating status bar in wxFrame" );
394 m_frameStatusBar
= OnCreateStatusBar(number
, style
, id
,
396 if ( m_frameStatusBar
)
399 return m_frameStatusBar
;
405 void wxFrame::SetStatusText(const wxString
& text
, int number
)
407 wxCHECK_RET( m_frameStatusBar
!= NULL
, "no statusbar to set text for" );
409 m_frameStatusBar
->SetStatusText(text
, number
);
412 void wxFrame::SetStatusWidths(int n
, const int widths_field
[])
414 wxCHECK_RET( m_frameStatusBar
!= NULL
, "no statusbar to set widths for" );
416 m_frameStatusBar
->SetStatusWidths(n
, widths_field
);
420 void wxFrame::PositionStatusBar(void)
422 // native status bar positions itself
424 #if wxUSE_NATIVE_STATUSBAR
425 && !m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
))
430 GetClientSize(&w
, &h
);
432 m_frameStatusBar
->GetSize(&sw
, &sh
);
434 // Since we wish the status bar to be directly under the client area,
435 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
436 m_frameStatusBar
->SetSize(0, h
, w
, sh
);
440 void wxFrame::SetMenuBar(wxMenuBar
*menu_bar
)
444 m_frameMenuBar
= NULL
;
448 if (menu_bar
->m_menuBarFrame
)
452 HMENU menu
= CreateMenu();
454 for (i
= 0; i
< menu_bar
->m_menuCount
; i
++)
456 HMENU popup
= (HMENU
)menu_bar
->m_menus
[i
]->m_hMenu
;
458 // After looking Bounds Checker result, it seems that all
459 // menus must be individually destroyed. So, don't reset m_hMenu,
460 // to allow ~wxMenu to do the job.
462 menu_bar
->m_menus
[i
]->m_savehMenu
= (WXHMENU
) popup
;
463 // Uncommenting for the moment... JACS
464 menu_bar
->m_menus
[i
]->m_hMenu
= 0;
465 AppendMenu(menu
, MF_POPUP
| MF_STRING
, (UINT
)popup
, menu_bar
->m_titles
[i
]);
468 menu_bar
->m_hMenu
= (WXHMENU
)menu
;
470 delete m_frameMenuBar
;
472 this->m_hMenu
= (WXHMENU
) menu
;
475 if (!SetMenu((HWND
) GetHWND(), menu
))
478 err
= GetLastError();
482 m_frameMenuBar
= menu_bar
;
483 menu_bar
->m_menuBarFrame
= this;
487 bool wxFrame::LoadAccelerators(const wxString
& table
)
489 m_acceleratorTable
= (WXHANDLE
)
492 ::LoadAcceleratorsW(wxGetInstance(), (const char *)table
);
494 ::LoadAcceleratorsA(wxGetInstance(), (const char *)table
);
497 ::LoadAccelerators(wxGetInstance(), (const char *)table
);
500 // The above is necessary because LoadAccelerators is a macro
501 // which we have undefed earlier in the file to avoid confusion
502 // with wxFrame::LoadAccelerators. Ugh!
504 return (m_acceleratorTable
!= (WXHANDLE
) NULL
);
508 void wxFrame::Fit(void)
510 // Work out max. size
511 wxNode
*node
= GetChildren().First();
516 // Find a child that's a subwindow, but not a dialog box.
517 wxWindow
*win
= (wxWindow
*)node
->Data();
519 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) &&
520 !win
->IsKindOf(CLASSINFO(wxDialog
)))
524 win
->GetSize(&width
, &height
);
525 win
->GetPosition(&x
, &y
);
527 if ((x
+ width
) > max_width
)
528 max_width
= x
+ width
;
529 if ((y
+ height
) > max_height
)
530 max_height
= y
+ height
;
534 SetClientSize(max_width
, max_height
);
537 // Responds to colour changes, and passes event on to children.
538 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
540 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
543 if ( m_frameStatusBar
)
545 wxSysColourChangedEvent event2
;
546 event2
.SetEventObject( m_frameStatusBar
);
547 m_frameStatusBar
->GetEventHandler()->ProcessEvent(event2
);
550 // Propagate the event to the non-top-level children
551 wxWindow::OnSysColourChanged(event
);
559 void wxFrame::MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
560 int x
, int y
, int width
, int height
, long style
)
563 m_defaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
565 // If child windows aren't properly drawn initially, WS_CLIPCHILDREN
566 // could be the culprit. But without it, you can get a lot of flicker.
569 if ((style
& wxCAPTION
) == wxCAPTION
)
570 msflags
= WS_OVERLAPPED
;
574 if (style
& wxMINIMIZE_BOX
)
575 msflags
|= WS_MINIMIZEBOX
;
576 if (style
& wxMAXIMIZE_BOX
)
577 msflags
|= WS_MAXIMIZEBOX
;
578 if (style
& wxTHICK_FRAME
)
579 msflags
|= WS_THICKFRAME
;
580 if (style
& wxSYSTEM_MENU
)
581 msflags
|= WS_SYSMENU
;
582 if ((style
& wxMINIMIZE
) || (style
& wxICONIZE
))
583 msflags
|= WS_MINIMIZE
;
584 if (style
& wxMAXIMIZE
)
585 msflags
|= WS_MAXIMIZE
;
586 if (style
& wxCAPTION
)
587 msflags
|= WS_CAPTION
;
588 if (style
& wxCLIP_CHILDREN
)
589 msflags
|= WS_CLIPCHILDREN
;
591 // Keep this in wxFrame because it saves recoding this function
594 if (style
& wxTINY_CAPTION_VERT
)
595 msflags
|= IBS_VERTCAPTION
;
596 if (style
& wxTINY_CAPTION_HORIZ
)
597 msflags
|= IBS_HORZCAPTION
;
599 if (style
& wxTINY_CAPTION_VERT
)
600 msflags
|= WS_CAPTION
;
601 if (style
& wxTINY_CAPTION_HORIZ
)
602 msflags
|= WS_CAPTION
;
604 if ((style
& wxTHICK_FRAME
) == 0)
605 msflags
|= WS_BORDER
;
607 WXDWORD extendedStyle
= MakeExtendedStyle(style
);
609 if (style
& wxFRAME_TOOL_WINDOW
)
610 extendedStyle
|= WS_EX_TOOLWINDOW
;
612 if (style
& wxSTAY_ON_TOP
)
613 extendedStyle
|= WS_EX_TOPMOST
;
616 wxWindow::MSWCreate(id
, parent
, wclass
, wx_win
, title
, x
, y
, width
, height
,
617 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
));
624 bool wxFrame::MSWOnPaint(void)
627 if (GetUpdateRect((HWND
) GetHWND(), &rect
, FALSE
))
633 the_icon
= (HICON
) m_icon
.GetHICON();
635 the_icon
= (HICON
) m_defaultIcon
;
638 // Hold a pointer to the dc so long as the OnPaint() message
639 // is being processed
640 HDC cdc
= BeginPaint((HWND
) GetHWND(), &ps
);
642 // Erase background before painting or we get white background
643 this->MSWDefWindowProc(WM_ICONERASEBKGND
,(WORD
)ps
.hdc
,0L);
648 GetClientRect((HWND
) GetHWND(), &rect
);
650 int icon_height
= 32;
651 int icon_x
= (int)((rect
.right
- icon_width
)/2);
652 int icon_y
= (int)((rect
.bottom
- icon_height
)/2);
653 DrawIcon(cdc
, icon_x
, icon_y
, the_icon
);
656 EndPaint((HWND
) GetHWND(), &ps
);
660 wxPaintEvent
event(m_windowId
);
661 event
.m_eventObject
= this;
662 if (!GetEventHandler()->ProcessEvent(event
))
670 WXHICON
wxFrame::MSWOnQueryDragIcon(void)
672 if (m_icon
.Ok() && (m_icon
.GetHICON() != 0))
673 return m_icon
.GetHICON();
675 return m_defaultIcon
;
678 void wxFrame::MSWOnSize(int x
, int y
, WXUINT id
)
683 // only do it it if we were iconized before, otherwise resizing the
684 // parent frame has a curious side effect of bringing it under it's
689 // restore all child frames too
690 IconizeChildFrames(FALSE
);
699 // iconize all child frames too
700 IconizeChildFrames(TRUE
);
708 // forward WM_SIZE to status bar control
709 #if wxUSE_NATIVE_STATUSBAR
710 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
712 wxSizeEvent
event(wxSize(x
, y
), m_frameStatusBar
->GetId());
713 event
.SetEventObject( m_frameStatusBar
);
715 ((wxStatusBar95
*)m_frameStatusBar
)->OnSize(event
);
722 wxSizeEvent
event(wxSize(x
, y
), m_windowId
);
723 event
.SetEventObject( this );
724 if (!GetEventHandler()->ProcessEvent(event
))
729 bool wxFrame::MSWOnClose(void)
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
))
763 void wxFrame::MSWOnMenuHighlight(WXWORD nItem
, WXWORD nFlags
, WXHMENU hSysMenu
)
765 if (nFlags
== 0xFFFF && hSysMenu
== 0)
767 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, -1);
768 event
.SetEventObject( this );
769 GetEventHandler()->ProcessEvent(event
);
771 else if (nFlags
!= MF_SEPARATOR
)
773 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, nItem
);
774 event
.SetEventObject( this );
775 GetEventHandler()->ProcessEvent(event
);
779 bool wxFrame::MSWProcessMessage(WXMSG
* pMsg
)
784 bool wxFrame::MSWTranslateMessage(WXMSG
* pMsg
)
786 if (m_acceleratorTable
.Ok() &&
787 ::TranslateAccelerator((HWND
) GetHWND(), (HACCEL
) m_acceleratorTable
.GetHACCEL(), (MSG
*)pMsg
))
793 // Default resizing behaviour - if only ONE subwindow,
794 // resize to client rectangle size
795 void wxFrame::OnSize(wxSizeEvent
& event
)
797 // if we're using constraints - do use them
798 #if wxUSE_CONSTRAINTS
799 if ( GetAutoLayout() ) {
805 // do we have _exactly_ one child?
806 wxWindow
*child
= NULL
;
807 for ( wxNode
*node
= GetChildren().First(); node
; node
= node
->Next() )
809 wxWindow
*win
= (wxWindow
*)node
->Data();
810 if ( !win
->IsKindOf(CLASSINFO(wxFrame
)) &&
811 !win
->IsKindOf(CLASSINFO(wxDialog
)) &&
812 (win
!= GetStatusBar()) &&
813 (win
!= GetToolBar()) )
816 return; // it's our second subwindow - nothing to do
822 // we have exactly one child - set it's size to fill the whole frame
823 int clientW
, clientH
;
824 GetClientSize(&clientW
, &clientH
);
829 child
->SetSize(x
, y
, clientW
, clientH
);
833 // Default activation behaviour - set the focus for the first child
835 void wxFrame::OnActivate(wxActivateEvent
& event
)
837 for(wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
839 // Find a child that's a subwindow, but not a dialog box.
840 wxWindow
*child
= (wxWindow
*)node
->Data();
841 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) &&
842 !child
->IsKindOf(CLASSINFO(wxDialog
)))
850 // The default implementation for the close window event - calls
851 // OnClose for backward compatibility.
853 void wxFrame::OnCloseWindow(wxCloseEvent
& event
)
856 if ( GetEventHandler()->OnClose() || event
.GetForce())
864 bool wxFrame::OnClose(void)
869 // Destroy the window (delayed, if a managed window)
870 bool wxFrame::Destroy(void)
872 if (!wxPendingDelete
.Member(this))
873 wxPendingDelete
.Append(this);
877 // Default menu selection behaviour - display a help string
878 void wxFrame::OnMenuHighlight(wxMenuEvent
& event
)
882 if (event
.GetMenuId() == -1)
886 wxMenuBar
*menuBar
= GetMenuBar();
889 wxString
helpString(menuBar
->GetHelpString(event
.GetMenuId()));
890 if (helpString
!= "")
891 SetStatusText(helpString
);
897 wxMenuBar
*wxFrame::GetMenuBar(void) const
899 return m_frameMenuBar
;
902 void wxFrame::Centre(int direction
)
904 int display_width
, display_height
, width
, height
, x
, y
;
905 wxDisplaySize(&display_width
, &display_height
);
907 GetSize(&width
, &height
);
910 if (direction
& wxHORIZONTAL
)
911 x
= (int)((display_width
- width
)/2);
912 if (direction
& wxVERTICAL
)
913 y
= (int)((display_height
- height
)/2);
915 SetSize(x
, y
, width
, height
);
918 // Call this to simulate a menu command
919 void wxFrame::Command(int id
)
924 void wxFrame::ProcessCommand(int id
)
926 wxCommandEvent
commandEvent(wxEVT_COMMAND_MENU_SELECTED
, id
);
927 commandEvent
.SetInt( id
);
928 commandEvent
.SetEventObject( this );
930 wxMenuBar
*bar
= GetMenuBar() ;
934 wxMenuItem
*item
= bar
->FindItemForId(id
) ;
935 if (item
&& item
->IsCheckable())
937 bar
->Check(id
,!bar
->Checked(id
)) ;
939 GetEventHandler()->ProcessEvent(commandEvent
);
942 // Checks if there is a toolbar, and returns the first free client position
943 wxPoint
wxFrame::GetClientAreaOrigin() const
949 GetToolBar()->GetSize(& w
, & h
);
951 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
963 void wxFrame::ScreenToClient(int *x
, int *y
) const
965 wxWindow::ScreenToClient(x
, y
);
967 // We may be faking the client origin.
968 // So a window that's really at (0, 30) may appear
969 // (to wxWin apps) to be at (0, 0).
970 wxPoint
pt(GetClientAreaOrigin());
975 void wxFrame::ClientToScreen(int *x
, int *y
) const
977 // We may be faking the client origin.
978 // So a window that's really at (0, 30) may appear
979 // (to wxWin apps) to be at (0, 0).
980 wxPoint
pt1(GetClientAreaOrigin());
984 wxWindow::ClientToScreen(x
, y
);
987 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
989 wxCHECK_MSG( m_frameToolBar
== NULL
, FALSE
,
990 "recreating toolbar in wxFrame" );
992 wxToolBar
* toolBar
= OnCreateToolBar(style
, id
, name
);
1005 wxToolBar
* wxFrame::OnCreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
1007 return new wxToolBar(this, id
, wxDefaultPosition
, wxDefaultSize
, style
, name
);
1010 void wxFrame::PositionToolBar(void)
1013 ::GetClientRect((HWND
) GetHWND(), &rect
);
1015 if ( GetStatusBar() )
1017 int statusX
, statusY
;
1018 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
1019 rect
.bottom
-= statusY
;
1025 GetToolBar()->GetSize(& tw
, & th
);
1027 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
1029 // Use the 'real' MSW position
1030 GetToolBar()->SetSize(0, 0, tw
, rect
.bottom
, wxSIZE_NO_ADJUSTMENTS
);
1034 // Use the 'real' MSW position
1035 GetToolBar()->SetSize(0, 0, rect
.right
, th
, wxSIZE_NO_ADJUSTMENTS
);
1040 // propagate our state change to all child frames
1041 void wxFrame::IconizeChildFrames(bool bIconize
)
1043 for ( wxNode
*node
= GetChildren().First(); node
; node
= node
->Next() ) {
1044 wxWindow
*win
= (wxWindow
*)node
->Data();
1045 if ( win
->IsKindOf(CLASSINFO(wxFrame
)) ) {
1046 ((wxFrame
*)win
)->Iconize(bIconize
);