]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/minifram/minifram.cpp
Added DetachOldLog to avoid destruction of old log target
[wxWidgets.git] / samples / minifram / minifram.cpp
index 96d41ad7e333e19523e63ba3dd65c203009e2738..9cd56f413e2e02016d504c06dda01e1c30af1719 100644 (file)
@@ -48,14 +48,44 @@ MyMiniFrame   *mini_frame = (MyMiniFrame*) NULL;
 bool           mini_frame_exists = false;
 wxButton      *button     = (wxButton*) NULL;
 
+#define ID_SET_SIZE_TO_150_150      100
+#define ID_SET_SIZE_TO_200_200      101
+#define ID_SET_MAX_SIZE_TO_150_150  102
+#define ID_SET_MAX_SIZE_TO_300_300  103
+
 // The `main program' equivalent, creating the windows and returning the
 // main frame
 bool MyApp::OnInit()
 {
+  if ( !wxApp::OnInit() )
+    return false;
+
   // Create the main frame window
   main_frame = new MyMainFrame((wxFrame *) NULL, wxID_ANY, _T("wxFrame sample"),
      wxPoint(100, 100), wxSize(300, 200));
 
+  main_frame->SetSizeHints( 100,100, 400,400 );
+
+  wxMenu *file_menu = new wxMenu;
+  file_menu->Append(wxID_EXIT, _T("E&xit\tAlt-Q"));
+  file_menu->Append(ID_SET_SIZE_TO_150_150, _T("Set frame size to 150,150\tF2"));
+  file_menu->Append(ID_SET_SIZE_TO_200_200, _T("Set frame size to 200,200\tF3"));
+  file_menu->Append(ID_SET_MAX_SIZE_TO_150_150, _T("Set frame max size to 150,150\tF4"));
+  file_menu->Append(ID_SET_MAX_SIZE_TO_300_300, _T("Set frame max size to 300,300\tF5"));
+  
+  wxMenuBar *menu_bar = new wxMenuBar;
+  menu_bar->Append(file_menu, _T("&File"));
+  main_frame->SetMenuBar(menu_bar);
+
+  main_frame->Connect( ID_SET_SIZE_TO_150_150,  wxID_ANY,
+                    wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyMainFrame::OnSetSize_150_150) );
+  main_frame->Connect( ID_SET_SIZE_TO_200_200, wxID_ANY,
+                    wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyMainFrame::OnSetSize_200_200) );
+  main_frame->Connect( ID_SET_MAX_SIZE_TO_150_150,  wxID_ANY,
+                    wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyMainFrame::OnSetMaxSize_150_150) );
+  main_frame->Connect( ID_SET_MAX_SIZE_TO_300_300, wxID_ANY,
+                    wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyMainFrame::OnSetMaxSize_300_300) );
+
   main_frame->CreateToolBar(wxNO_BORDER|wxTB_VERTICAL, ID_TOOLBAR);
   InitToolbar(main_frame->GetToolBar());
 
@@ -134,7 +164,6 @@ bool MyApp::InitToolbar(wxToolBar* toolBar)
 // MyMiniFrame
 
 BEGIN_EVENT_TABLE(MyMiniFrame, wxMiniFrame)
-    EVT_CLOSE  (              MyMiniFrame::OnCloseWindow)
     EVT_BUTTON (ID_REPARENT,  MyMiniFrame::OnReparent)
     EVT_MENU   (wxID_PRINT,   MyMiniFrame::OnReparent)
 END_EVENT_TABLE()
@@ -145,11 +174,11 @@ MyMiniFrame::MyMiniFrame(wxFrame* parent, wxWindowID id, const wxString& title,
 {
 }
 
-void MyMiniFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
+bool MyMiniFrame::Destroy()
 {
   // make it known that the miniframe is no more
   mini_frame_exists = false;
-  Destroy();
+  return wxMiniFrame::Destroy();
 }
 
 void MyMiniFrame::OnReparent(wxCommandEvent& WXUNUSED(event))
@@ -163,7 +192,7 @@ void MyMiniFrame::OnReparent(wxCommandEvent& WXUNUSED(event))
 // MyMainFrame
 
 BEGIN_EVENT_TABLE(MyMainFrame, wxFrame)
-    EVT_CLOSE  (              MyMainFrame::OnCloseWindow)
+    EVT_MENU   (wxID_EXIT,    MyMainFrame::OnExit)
     EVT_BUTTON (ID_REPARENT,  MyMainFrame::OnReparent)
     EVT_MENU   (wxID_PRINT,   MyMainFrame::OnReparent)
 END_EVENT_TABLE()
@@ -174,9 +203,9 @@ MyMainFrame::MyMainFrame(wxFrame* parent, wxWindowID id, const wxString& title,
 {
 }
 
-void MyMainFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
+void MyMainFrame::OnExit(wxCommandEvent&)
 {
-  Destroy();
+    Close();
 }
 
 void MyMainFrame::OnReparent(wxCommandEvent& WXUNUSED(event))
@@ -195,3 +224,23 @@ void MyMainFrame::OnReparent(wxCommandEvent& WXUNUSED(event))
     mini_frame->SendSizeEvent();
   }
 }
+
+void MyMainFrame::OnSetSize_150_150(wxCommandEvent& WXUNUSED(event))
+{
+    SetSize( 150, 150 );
+}
+
+void MyMainFrame::OnSetSize_200_200(wxCommandEvent& WXUNUSED(event))
+{
+    SetSize( 200, 200 );
+}
+
+void MyMainFrame::OnSetMaxSize_150_150(wxCommandEvent& WXUNUSED(event))
+{
+    SetSizeHints( -1, -1, 150, 150 );
+}
+
+void MyMainFrame::OnSetMaxSize_300_300(wxCommandEvent& WXUNUSED(event))
+{
+    SetSizeHints( -1, -1, 300, 300 );
+}