From 517444edb1bc2f1b001816f04f19670ad678c20b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 10 Aug 2000 08:42:34 +0000 Subject: [PATCH] added more tests for MDI frame size/position git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@8003 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/mdi/mdi.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++- samples/mdi/mdi.h | 6 ++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/samples/mdi/mdi.cpp b/samples/mdi/mdi.cpp index 423a2447be..6ccae6ba4f 100644 --- a/samples/mdi/mdi.cpp +++ b/samples/mdi/mdi.cpp @@ -81,6 +81,11 @@ BEGIN_EVENT_TABLE(MyChild, wxMDIChildFrame) EVT_MENU(MDI_CHILD_QUIT, MyChild::OnQuit) EVT_MENU(MDI_REFRESH, MyChild::OnRefresh) EVT_MENU(MDI_CHANGE_TITLE, MyChild::OnChangeTitle) + EVT_MENU(MDI_CHANGE_POSITION, MyChild::OnChangePosition) + EVT_MENU(MDI_CHANGE_SIZE, MyChild::OnChangeSize) + + EVT_SIZE(MyChild::OnSize) + EVT_MOVE(MyChild::OnMove) EVT_CLOSE(MyChild::OnClose) END_EVENT_TABLE() @@ -236,6 +241,9 @@ void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) ) option_menu->Append(MDI_REFRESH, "&Refresh picture"); option_menu->Append(MDI_CHANGE_TITLE, "Change &title...\tCtrl-T"); + option_menu->AppendSeparator(); + option_menu->Append(MDI_CHANGE_POSITION, "Move frame\tCtrl-M"); + option_menu->Append(MDI_CHANGE_SIZE, "Resize frame\tCtrl-S"); wxMenu *help_menu = new wxMenu; help_menu->Append(MDI_ABOUT, "&About"); @@ -243,7 +251,7 @@ void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) ) wxMenuBar *menu_bar = new wxMenuBar; menu_bar->Append(file_menu, "&File"); - menu_bar->Append(option_menu, "&Options"); + menu_bar->Append(option_menu, "&Child"); menu_bar->Append(help_menu, "&Help"); // Associate the menu bar with the frame @@ -422,6 +430,16 @@ void MyChild::OnRefresh(wxCommandEvent& WXUNUSED(event)) canvas->Refresh(); } +void MyChild::OnChangePosition(wxCommandEvent& WXUNUSED(event)) +{ + Move(10, 10); +} + +void MyChild::OnChangeSize(wxCommandEvent& WXUNUSED(event)) +{ + SetClientSize(100, 100); +} + void MyChild::OnChangeTitle(wxCommandEvent& WXUNUSED(event)) { static wxString s_title = _T("Canvas Frame"); @@ -443,6 +461,33 @@ void MyChild::OnActivate(wxActivateEvent& event) canvas->SetFocus(); } +void MyChild::OnMove(wxMoveEvent& event) +{ + // VZ: here everything is totally wrong under MSW, the positions are + // different and both wrong (pos2 is off by 2 pixels for me which seems + // to be the width of the MDI canvas border) + wxPoint pos1 = event.GetPosition(), + pos2 = GetPosition(); + wxLogStatus("position from event: (%d, %d), from frame (%d, %d)", + pos1.x, pos1.y, pos2.x, pos2.y); + + event.Skip(); +} + +void MyChild::OnSize(wxSizeEvent& event) +{ + // VZ: under MSW the size event carries the client size (quite + // unexpectedly) *except* for the very first one which has the full + // size... what should it really be? TODO: check under wxGTK + wxSize size1 = event.GetSize(), + size2 = GetSize(), + size3 = GetClientSize(); + wxLogStatus("size from event: %dx%d, from frame %dx%d, client %dx%d", + size1.x, size1.y, size2.x, size2.y, size3.x, size3.y); + + event.Skip(); +} + void MyChild::OnClose(wxCloseEvent& event) { if ( canvas && canvas->IsDirty() ) diff --git a/samples/mdi/mdi.h b/samples/mdi/mdi.h index b05f205a02..079289e4a0 100644 --- a/samples/mdi/mdi.h +++ b/samples/mdi/mdi.h @@ -65,7 +65,11 @@ public: void OnRefresh(wxCommandEvent& event); void OnChangeTitle(wxCommandEvent& event); + void OnChangePosition(wxCommandEvent& event); + void OnChangeSize(wxCommandEvent& event); void OnQuit(wxCommandEvent& event); + void OnSize(wxSizeEvent& event); + void OnMove(wxMoveEvent& event); void OnClose(wxCloseEvent& event); DECLARE_EVENT_TABLE() @@ -78,6 +82,8 @@ enum MDI_NEW_WINDOW, MDI_REFRESH, MDI_CHANGE_TITLE, + MDI_CHANGE_POSITION, + MDI_CHANGE_SIZE, MDI_CHILD_QUIT, MDI_ABOUT };