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);
335 bool wxFrame::IsMaximized(void) const
337 return (::IsZoomed((HWND
) GetHWND()) != 0) ;
340 void wxFrame::SetTitle(const wxString
& title
)
342 SetWindowText((HWND
) GetHWND(), (const char *)title
);
345 wxString
wxFrame::GetTitle(void) const
347 GetWindowText((HWND
) GetHWND(), wxBuffer
, 1000);
348 return wxString(wxBuffer
);
351 void wxFrame::SetIcon(const wxIcon
& icon
)
354 #if defined(__WIN95__)
356 SendMessage((HWND
) GetHWND(), WM_SETICON
,
357 (WPARAM
)TRUE
, (LPARAM
)(HICON
) m_icon
.GetHICON());
361 wxStatusBar
*wxFrame::OnCreateStatusBar(int number
, long style
, wxWindowID id
,
362 const wxString
& name
)
364 wxStatusBar
*statusBar
= NULL
;
366 #if wxUSE_NATIVE_STATUSBAR
367 if (UsesNativeStatusBar())
369 statusBar
= new wxStatusBar95(this, id
, style
);
374 statusBar
= new wxStatusBar(this, id
, wxPoint(0, 0), wxSize(100, 20),
377 // Set the height according to the font and the border size
378 wxClientDC
dc(statusBar
);
379 dc
.SetFont(statusBar
->GetFont());
382 dc
.GetTextExtent("X", &x
, &y
);
384 int height
= (int)( (y
* 1.1) + 2* statusBar
->GetBorderY());
386 statusBar
->SetSize(-1, -1, 100, height
);
389 statusBar
->SetFieldsCount(number
);
393 wxStatusBar
* wxFrame::CreateStatusBar(int number
, long style
, wxWindowID id
,
394 const wxString
& name
)
396 // VZ: calling CreateStatusBar twice is an error - why anyone would do it?
397 wxCHECK_MSG( m_frameStatusBar
== NULL
, FALSE
,
398 "recreating status bar in wxFrame" );
400 m_frameStatusBar
= OnCreateStatusBar(number
, style
, id
,
402 if ( m_frameStatusBar
)
405 return m_frameStatusBar
;
411 void wxFrame::SetStatusText(const wxString
& text
, int number
)
413 wxCHECK_RET( m_frameStatusBar
!= NULL
, "no statusbar to set text for" );
415 m_frameStatusBar
->SetStatusText(text
, number
);
418 void wxFrame::SetStatusWidths(int n
, const int widths_field
[])
420 wxCHECK_RET( m_frameStatusBar
!= NULL
, "no statusbar to set widths for" );
422 m_frameStatusBar
->SetStatusWidths(n
, widths_field
);
426 void wxFrame::PositionStatusBar(void)
428 // native status bar positions itself
430 #if wxUSE_NATIVE_STATUSBAR
431 && !m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
))
436 GetClientSize(&w
, &h
);
438 m_frameStatusBar
->GetSize(&sw
, &sh
);
440 // Since we wish the status bar to be directly under the client area,
441 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
442 m_frameStatusBar
->SetSize(0, h
, w
, sh
);
446 void wxFrame::SetMenuBar(wxMenuBar
*menu_bar
)
450 m_frameMenuBar
= NULL
;
454 if (menu_bar
->m_menuBarFrame
)
458 HMENU menu
= CreateMenu();
460 for (i
= 0; i
< menu_bar
->m_menuCount
; i
++)
462 HMENU popup
= (HMENU
)menu_bar
->m_menus
[i
]->m_hMenu
;
464 // After looking Bounds Checker result, it seems that all
465 // menus must be individually destroyed. So, don't reset m_hMenu,
466 // to allow ~wxMenu to do the job.
468 menu_bar
->m_menus
[i
]->m_savehMenu
= (WXHMENU
) popup
;
469 // Uncommenting for the moment... JACS
470 menu_bar
->m_menus
[i
]->m_hMenu
= 0;
471 AppendMenu(menu
, MF_POPUP
| MF_STRING
, (UINT
)popup
, menu_bar
->m_titles
[i
]);
474 menu_bar
->m_hMenu
= (WXHMENU
)menu
;
476 delete m_frameMenuBar
;
478 this->m_hMenu
= (WXHMENU
) menu
;
481 if (!SetMenu((HWND
) GetHWND(), menu
))
484 err
= GetLastError();
488 m_frameMenuBar
= menu_bar
;
489 menu_bar
->m_menuBarFrame
= this;
493 bool wxFrame::LoadAccelerators(const wxString
& table
)
495 m_acceleratorTable
= (WXHANDLE
)
498 ::LoadAcceleratorsW(wxGetInstance(), (const char *)table
);
500 ::LoadAcceleratorsA(wxGetInstance(), (const char *)table
);
503 ::LoadAccelerators(wxGetInstance(), (const char *)table
);
506 // The above is necessary because LoadAccelerators is a macro
507 // which we have undefed earlier in the file to avoid confusion
508 // with wxFrame::LoadAccelerators. Ugh!
510 return (m_acceleratorTable
!= (WXHANDLE
) NULL
);
514 void wxFrame::Fit(void)
516 // Work out max. size
517 wxNode
*node
= GetChildren().First();
522 // Find a child that's a subwindow, but not a dialog box.
523 wxWindow
*win
= (wxWindow
*)node
->Data();
525 if (!win
->IsKindOf(CLASSINFO(wxFrame
)) &&
526 !win
->IsKindOf(CLASSINFO(wxDialog
)))
530 win
->GetSize(&width
, &height
);
531 win
->GetPosition(&x
, &y
);
533 if ((x
+ width
) > max_width
)
534 max_width
= x
+ width
;
535 if ((y
+ height
) > max_height
)
536 max_height
= y
+ height
;
540 SetClientSize(max_width
, max_height
);
543 // Responds to colour changes, and passes event on to children.
544 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
546 SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE
));
549 if ( m_frameStatusBar
)
551 wxSysColourChangedEvent event2
;
552 event2
.SetEventObject( m_frameStatusBar
);
553 m_frameStatusBar
->GetEventHandler()->ProcessEvent(event2
);
556 // Propagate the event to the non-top-level children
557 wxWindow::OnSysColourChanged(event
);
565 void wxFrame::MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
566 int x
, int y
, int width
, int height
, long style
)
569 m_defaultIcon
= (WXHICON
) (wxSTD_FRAME_ICON
? wxSTD_FRAME_ICON
: wxDEFAULT_FRAME_ICON
);
571 // If child windows aren't properly drawn initially, WS_CLIPCHILDREN
572 // could be the culprit. But without it, you can get a lot of flicker.
575 if ((style
& wxCAPTION
) == wxCAPTION
)
576 msflags
= WS_OVERLAPPED
;
580 if (style
& wxMINIMIZE_BOX
)
581 msflags
|= WS_MINIMIZEBOX
;
582 if (style
& wxMAXIMIZE_BOX
)
583 msflags
|= WS_MAXIMIZEBOX
;
584 if (style
& wxTHICK_FRAME
)
585 msflags
|= WS_THICKFRAME
;
586 if (style
& wxSYSTEM_MENU
)
587 msflags
|= WS_SYSMENU
;
588 if ((style
& wxMINIMIZE
) || (style
& wxICONIZE
))
589 msflags
|= WS_MINIMIZE
;
590 if (style
& wxMAXIMIZE
)
591 msflags
|= WS_MAXIMIZE
;
592 if (style
& wxCAPTION
)
593 msflags
|= WS_CAPTION
;
594 if (style
& wxCLIP_CHILDREN
)
595 msflags
|= WS_CLIPCHILDREN
;
597 // Keep this in wxFrame because it saves recoding this function
600 if (style
& wxTINY_CAPTION_VERT
)
601 msflags
|= IBS_VERTCAPTION
;
602 if (style
& wxTINY_CAPTION_HORIZ
)
603 msflags
|= IBS_HORZCAPTION
;
605 if (style
& wxTINY_CAPTION_VERT
)
606 msflags
|= WS_CAPTION
;
607 if (style
& wxTINY_CAPTION_HORIZ
)
608 msflags
|= WS_CAPTION
;
610 if ((style
& wxTHICK_FRAME
) == 0)
611 msflags
|= WS_BORDER
;
613 WXDWORD extendedStyle
= MakeExtendedStyle(style
);
615 if (style
& wxFRAME_TOOL_WINDOW
)
616 extendedStyle
|= WS_EX_TOOLWINDOW
;
618 if (style
& wxSTAY_ON_TOP
)
619 extendedStyle
|= WS_EX_TOPMOST
;
622 wxWindow::MSWCreate(id
, parent
, wclass
, wx_win
, title
, x
, y
, width
, height
,
623 msflags
, NULL
, extendedStyle
);
624 // Seems to be necessary if we use WS_POPUP
625 // style instead of WS_OVERLAPPED
626 if (width
> -1 && height
> -1)
627 ::PostMessage((HWND
) GetHWND(), WM_SIZE
, SIZE_RESTORED
, MAKELPARAM(width
, height
));
630 bool wxFrame::MSWOnPaint(void)
633 if (GetUpdateRect((HWND
) GetHWND(), &rect
, FALSE
))
639 the_icon
= (HICON
) m_icon
.GetHICON();
641 the_icon
= (HICON
) m_defaultIcon
;
644 // Hold a pointer to the dc so long as the OnPaint() message
645 // is being processed
646 HDC cdc
= BeginPaint((HWND
) GetHWND(), &ps
);
648 // Erase background before painting or we get white background
649 this->MSWDefWindowProc(WM_ICONERASEBKGND
,(WORD
)ps
.hdc
,0L);
654 GetClientRect((HWND
) GetHWND(), &rect
);
656 int icon_height
= 32;
657 int icon_x
= (int)((rect
.right
- icon_width
)/2);
658 int icon_y
= (int)((rect
.bottom
- icon_height
)/2);
659 DrawIcon(cdc
, icon_x
, icon_y
, the_icon
);
662 EndPaint((HWND
) GetHWND(), &ps
);
666 wxPaintEvent
event(m_windowId
);
667 event
.m_eventObject
= this;
668 if (!GetEventHandler()->ProcessEvent(event
))
676 WXHICON
wxFrame::MSWOnQueryDragIcon(void)
678 if (m_icon
.Ok() && (m_icon
.GetHICON() != 0))
679 return m_icon
.GetHICON();
681 return m_defaultIcon
;
684 void wxFrame::MSWOnSize(int x
, int y
, WXUINT id
)
689 // only do it it if we were iconized before, otherwise resizing the
690 // parent frame has a curious side effect of bringing it under it's
695 // restore all child frames too
696 IconizeChildFrames(FALSE
);
705 // iconize all child frames too
706 IconizeChildFrames(TRUE
);
714 // forward WM_SIZE to status bar control
715 #if wxUSE_NATIVE_STATUSBAR
716 if (m_frameStatusBar
&& m_frameStatusBar
->IsKindOf(CLASSINFO(wxStatusBar95
)))
718 wxSizeEvent
event(wxSize(x
, y
), m_frameStatusBar
->GetId());
719 event
.SetEventObject( m_frameStatusBar
);
721 ((wxStatusBar95
*)m_frameStatusBar
)->OnSize(event
);
728 wxSizeEvent
event(wxSize(x
, y
), m_windowId
);
729 event
.SetEventObject( this );
730 if (!GetEventHandler()->ProcessEvent(event
))
735 bool wxFrame::MSWOnClose(void)
740 bool wxFrame::MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
)
742 if (cmd
== 0 || cmd
== 1 ) // Can be either a menu command or an accelerator.
744 // In case it's e.g. a toolbar.
745 wxWindow
*win
= wxFindWinFromHandle(control
);
747 return win
->MSWCommand(cmd
, id
);
749 if (wxCurrentPopupMenu
)
751 wxMenu
*popupMenu
= wxCurrentPopupMenu
;
752 wxCurrentPopupMenu
= NULL
;
753 if (popupMenu
->MSWCommand(cmd
, id
))
757 if (GetMenuBar() && GetMenuBar()->FindItemForId(id
))
769 void wxFrame::MSWOnMenuHighlight(WXWORD nItem
, WXWORD nFlags
, WXHMENU hSysMenu
)
771 if (nFlags
== 0xFFFF && hSysMenu
== 0)
773 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, -1);
774 event
.SetEventObject( this );
775 GetEventHandler()->ProcessEvent(event
);
777 else if (nFlags
!= MF_SEPARATOR
)
779 wxMenuEvent
event(wxEVT_MENU_HIGHLIGHT
, nItem
);
780 event
.SetEventObject( this );
781 GetEventHandler()->ProcessEvent(event
);
785 bool wxFrame::MSWProcessMessage(WXMSG
* pMsg
)
790 bool wxFrame::MSWTranslateMessage(WXMSG
* pMsg
)
792 if (m_acceleratorTable
.Ok() &&
793 ::TranslateAccelerator((HWND
) GetHWND(), (HACCEL
) m_acceleratorTable
.GetHACCEL(), (MSG
*)pMsg
))
799 // Default resizing behaviour - if only ONE subwindow,
800 // resize to client rectangle size
801 void wxFrame::OnSize(wxSizeEvent
& event
)
803 // if we're using constraints - do use them
804 #if wxUSE_CONSTRAINTS
805 if ( GetAutoLayout() ) {
811 // do we have _exactly_ one child?
812 wxWindow
*child
= NULL
;
813 for ( wxNode
*node
= GetChildren().First(); node
; node
= node
->Next() )
815 wxWindow
*win
= (wxWindow
*)node
->Data();
816 if ( !win
->IsKindOf(CLASSINFO(wxFrame
)) &&
817 !win
->IsKindOf(CLASSINFO(wxDialog
)) &&
818 (win
!= GetStatusBar()) &&
819 (win
!= GetToolBar()) )
822 return; // it's our second subwindow - nothing to do
828 // we have exactly one child - set it's size to fill the whole frame
829 int clientW
, clientH
;
830 GetClientSize(&clientW
, &clientH
);
835 child
->SetSize(x
, y
, clientW
, clientH
);
839 // Default activation behaviour - set the focus for the first child
841 void wxFrame::OnActivate(wxActivateEvent
& event
)
843 for(wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
845 // Find a child that's a subwindow, but not a dialog box.
846 wxWindow
*child
= (wxWindow
*)node
->Data();
847 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) &&
848 !child
->IsKindOf(CLASSINFO(wxDialog
)))
856 // The default implementation for the close window event - calls
857 // OnClose for backward compatibility.
859 void wxFrame::OnCloseWindow(wxCloseEvent
& event
)
862 if ( GetEventHandler()->OnClose() || event
.GetForce())
870 bool wxFrame::OnClose(void)
875 // Destroy the window (delayed, if a managed window)
876 bool wxFrame::Destroy(void)
878 if (!wxPendingDelete
.Member(this))
879 wxPendingDelete
.Append(this);
883 // Default menu selection behaviour - display a help string
884 void wxFrame::OnMenuHighlight(wxMenuEvent
& event
)
888 if (event
.GetMenuId() == -1)
892 wxMenuBar
*menuBar
= GetMenuBar();
895 wxString
helpString(menuBar
->GetHelpString(event
.GetMenuId()));
896 if (helpString
!= "")
897 SetStatusText(helpString
);
903 wxMenuBar
*wxFrame::GetMenuBar(void) const
905 return m_frameMenuBar
;
908 void wxFrame::Centre(int direction
)
910 int display_width
, display_height
, width
, height
, x
, y
;
911 wxDisplaySize(&display_width
, &display_height
);
913 GetSize(&width
, &height
);
916 if (direction
& wxHORIZONTAL
)
917 x
= (int)((display_width
- width
)/2);
918 if (direction
& wxVERTICAL
)
919 y
= (int)((display_height
- height
)/2);
921 SetSize(x
, y
, width
, height
);
924 // Call this to simulate a menu command
925 void wxFrame::Command(int id
)
930 void wxFrame::ProcessCommand(int id
)
932 wxCommandEvent
commandEvent(wxEVT_COMMAND_MENU_SELECTED
, id
);
933 commandEvent
.SetInt( id
);
934 commandEvent
.SetEventObject( this );
936 wxMenuBar
*bar
= GetMenuBar() ;
940 wxMenuItem
*item
= bar
->FindItemForId(id
) ;
941 if (item
&& item
->IsCheckable())
943 bar
->Check(id
,!bar
->Checked(id
)) ;
945 GetEventHandler()->ProcessEvent(commandEvent
);
948 // Checks if there is a toolbar, and returns the first free client position
949 wxPoint
wxFrame::GetClientAreaOrigin() const
955 GetToolBar()->GetSize(& w
, & h
);
957 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
969 void wxFrame::ScreenToClient(int *x
, int *y
) const
971 wxWindow::ScreenToClient(x
, y
);
973 // We may be faking the client origin.
974 // So a window that's really at (0, 30) may appear
975 // (to wxWin apps) to be at (0, 0).
976 wxPoint
pt(GetClientAreaOrigin());
981 void wxFrame::ClientToScreen(int *x
, int *y
) const
983 // We may be faking the client origin.
984 // So a window that's really at (0, 30) may appear
985 // (to wxWin apps) to be at (0, 0).
986 wxPoint
pt1(GetClientAreaOrigin());
990 wxWindow::ClientToScreen(x
, y
);
993 wxToolBar
* wxFrame::CreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
995 wxCHECK_MSG( m_frameToolBar
== NULL
, FALSE
,
996 "recreating toolbar in wxFrame" );
998 wxToolBar
* toolBar
= OnCreateToolBar(style
, id
, name
);
1001 SetToolBar(toolBar
);
1011 wxToolBar
* wxFrame::OnCreateToolBar(long style
, wxWindowID id
, const wxString
& name
)
1013 return new wxToolBar(this, id
, wxDefaultPosition
, wxDefaultSize
, style
, name
);
1016 void wxFrame::PositionToolBar(void)
1019 ::GetClientRect((HWND
) GetHWND(), &rect
);
1021 if ( GetStatusBar() )
1023 int statusX
, statusY
;
1024 GetStatusBar()->GetClientSize(&statusX
, &statusY
);
1025 rect
.bottom
-= statusY
;
1031 GetToolBar()->GetSize(& tw
, & th
);
1033 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
1035 // Use the 'real' MSW position
1036 GetToolBar()->SetSize(0, 0, tw
, rect
.bottom
, wxSIZE_NO_ADJUSTMENTS
);
1040 // Use the 'real' MSW position
1041 GetToolBar()->SetSize(0, 0, rect
.right
, th
, wxSIZE_NO_ADJUSTMENTS
);
1046 // propagate our state change to all child frames
1047 void wxFrame::IconizeChildFrames(bool bIconize
)
1049 for ( wxNode
*node
= GetChildren().First(); node
; node
= node
->Next() ) {
1050 wxWindow
*win
= (wxWindow
*)node
->Data();
1051 if ( win
->IsKindOf(CLASSINFO(wxFrame
)) ) {
1052 ((wxFrame
*)win
)->Iconize(bIconize
);