From 9230b62136ee786760375bf59292dabff6277aeb Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sat, 28 Feb 2004 10:46:36 +0000 Subject: [PATCH] applied patch to remove use of deprecated constraints API git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25985 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/calendar/calendar.cpp | 55 +++++----- samples/controls/controls.cpp | 126 +++++++++-------------- samples/dnd/dnd.cpp | 131 ++++++++++-------------- samples/layout/layout.cpp | 187 ++++++++-------------------------- samples/layout/layout.h | 9 -- 5 files changed, 170 insertions(+), 338 deletions(-) diff --git a/samples/calendar/calendar.cpp b/samples/calendar/calendar.cpp index c4e285b754..b3c275c946 100644 --- a/samples/calendar/calendar.cpp +++ b/samples/calendar/calendar.cpp @@ -41,6 +41,7 @@ #include "wx/msgdlg.h" #endif +#include "wx/sizer.h" #include "wx/calctrl.h" // ---------------------------------------------------------------------------- @@ -201,12 +202,12 @@ bool MyApp::OnInit() MyFrame *frame = new MyFrame(_T("Calendar wxWindows sample"), wxPoint(50, 50), wxSize(450, 340)); - frame->Show(TRUE); + frame->Show(true); // success: wxApp::OnRun() will be called which will enter the main message // loop and the application will run. If we returned FALSE here, the // application would exit immediately. - return TRUE; + return true; } // ---------------------------------------------------------------------------- @@ -215,7 +216,7 @@ bool MyApp::OnInit() // frame constructor MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) - : wxFrame((wxFrame *)NULL, -1, title, pos, size) + : wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size) { // create a menu bar wxMenu *menuFile = new wxMenu; @@ -228,28 +229,28 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) menuCal->Append(Calendar_Cal_Monday, _T("Monday &first weekday\tCtrl-F"), _T("Toggle between Mon and Sun as the first week day"), - TRUE); + true); menuCal->Append(Calendar_Cal_Holidays, _T("Show &holidays\tCtrl-H"), _T("Toggle highlighting the holidays"), - TRUE); + true); menuCal->Append(Calendar_Cal_Special, _T("Highlight &special dates\tCtrl-S"), _T("Test custom highlighting"), - TRUE); + true); menuCal->Append(Calendar_Cal_SurroundWeeks, _T("Show s&urrounding weeks\tCtrl-W"), _T("Show the neighbouring weeks in the prev/next month"), - TRUE); + true); menuCal->AppendSeparator(); menuCal->Append(Calendar_Cal_SeqMonth, _T("To&ggle month selector style\tCtrl-G"), _T("Use another style for the calendar controls"), - TRUE); + true); menuCal->Append(Calendar_Cal_Month, _T("&Month can be changed\tCtrl-M"), _T("Allow changing the month in the calendar"), - TRUE); + true); menuCal->Append(Calendar_Cal_Year, _T("&Year can be changed\tCtrl-Y"), _T("Allow changing the year in the calendar"), - TRUE); + true); menuCal->AppendSeparator(); menuCal->Append(Calendar_Cal_SetDate, _T("SetDate()"), _T("Set date to 2005-12-24.")); menuCal->Append(Calendar_Cal_Today, _T("Today()"), _T("Set the current date.")); @@ -259,10 +260,10 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) menuBar->Append(menuFile, _T("&File")); menuBar->Append(menuCal, _T("&Calendar")); - menuBar->Check(Calendar_Cal_Monday, TRUE); - menuBar->Check(Calendar_Cal_Holidays, TRUE); - menuBar->Check(Calendar_Cal_Month, TRUE); - menuBar->Check(Calendar_Cal_Year, TRUE); + menuBar->Check(Calendar_Cal_Monday, true); + menuBar->Check(Calendar_Cal_Holidays, true); + menuBar->Check(Calendar_Cal_Month, true); + menuBar->Check(Calendar_Cal_Year, true); // ... and attach this menu bar to the frame SetMenuBar(menuBar); @@ -279,7 +280,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) { // TRUE is to force the frame to close - Close(TRUE); + Close(true); } void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) @@ -355,14 +356,12 @@ void MyFrame::OnToday(wxCommandEvent &WXUNUSED(event)) // ---------------------------------------------------------------------------- MyPanel::MyPanel(wxFrame *frame) - : wxPanel(frame, -1) + : wxPanel(frame, wxID_ANY) { - SetAutoLayout(TRUE); - wxString date; date.Printf(wxT("Selected date: %s"), wxDateTime::Today().FormatISODate().c_str()); - m_date = new wxStaticText(this, -1, date); + m_date = new wxStaticText(this, wxID_ANY, date); m_calendar = new wxCalendarCtrl(this, Calendar_CalCtrl, wxDefaultDateTime, wxDefaultPosition, @@ -371,21 +370,13 @@ MyPanel::MyPanel(wxFrame *frame) wxCAL_SHOW_HOLIDAYS | wxRAISED_BORDER); - wxLayoutConstraints *c = new wxLayoutConstraints; - c->left.SameAs(this, wxLeft, 10); - c->centreY.SameAs(this, wxCentreY); - c->height.AsIs(); - c->width.AsIs(); - - m_date->SetConstraints(c); + wxBoxSizer *m_sizer = new wxBoxSizer( wxHORIZONTAL ); - c = new wxLayoutConstraints; - c->left.SameAs(m_date, wxRight, 20); - c->centreY.SameAs(this, wxCentreY); - c->height.AsIs(); - c->width.AsIs(); + m_sizer->Add(m_date, 0, wxALIGN_CENTER | wxALL, 10 ); + m_sizer->Add(m_calendar, 0, wxALIGN_CENTER | wxALIGN_LEFT); - m_calendar->SetConstraints(c); + SetSizer( m_sizer ); + m_sizer->SetSizeHints( this ); } void MyPanel::OnCalendar(wxCalendarEvent& event) diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index f8e67d62b7..489ed36f65 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -337,7 +337,7 @@ bool MyApp::OnInit() { // use standard command line handling: if ( !wxApp::OnInit() ) - return FALSE; + return false; // parse the cmd line int x = 50, @@ -350,9 +350,9 @@ bool MyApp::OnInit() // Create the main frame window MyFrame *frame = new MyFrame(_T("Controls wxWindows App"), x, y); - frame->Show(TRUE); + frame->Show(true); - return TRUE; + return true; } //---------------------------------------------------------------------- @@ -520,7 +520,7 @@ END_EVENT_TABLE() // ============================================================================ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) - : wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) ) + : wxPanel( frame, wxID_ANY, wxPoint(x, y), wxSize(w, h) ) { m_listbox = NULL; m_listboxSorted = NULL; @@ -549,7 +549,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) m_notebook = NULL; m_label = NULL; - m_text = new wxTextCtrl(this, -1, _T("This is the log window.\n"), + m_text = new wxTextCtrl(this, wxID_ANY, _T("This is the log window.\n"), wxPoint(0, 250), wxSize(100, 50), wxTE_MULTILINE); m_text->SetBackgroundColour(wxT("wheat")); @@ -591,7 +591,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) { Image_List, Image_Choice, Image_Combo, Image_Text, Image_Radio, Image_Gauge, Image_Max }; - wxImageList *imagelist = new wxImageList(16, 16, FALSE, Image_Max); + wxImageList *imagelist = new wxImageList(16, 16, false, Image_Max); static const wxChar *s_iconNames[Image_Max] = { @@ -655,14 +655,14 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) #endif // wxUSE_TOOLTIPS m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, _T("&Disable"), wxPoint(20,170) ); - m_checkbox->SetValue(FALSE); + m_checkbox->SetValue(false); #if wxUSE_TOOLTIPS m_checkbox->SetToolTip( _T("Click here to disable the listbox") ); #endif // wxUSE_TOOLTIPS (void)new wxCheckBox( panel, ID_CHANGE_COLOUR, _T("&Toggle colour"), wxPoint(110,170) ); panel->SetCursor(wxCursor(wxCURSOR_HAND)); - m_notebook->AddPage(panel, _T("wxListBox"), TRUE, Image_List); + m_notebook->AddPage(panel, _T("wxListBox"), true, Image_List); #if wxUSE_CHOICE panel = new wxPanel(m_notebook); @@ -683,11 +683,11 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) (void)new wxButton( panel, ID_CHOICE_FONT, _T("Set &Italic font"), wxPoint(340,130), wxSize(140,30) ); (void)new wxCheckBox( panel, ID_CHOICE_ENABLE, _T("&Disable"), wxPoint(20,130), wxSize(140,30) ); - m_notebook->AddPage(panel, _T("wxChoice"), FALSE, Image_Choice); + m_notebook->AddPage(panel, _T("wxChoice"), false, Image_Choice); #endif // wxUSE_CHOICE panel = new wxPanel(m_notebook); - (void)new wxStaticBox( panel, -1, _T("&Box around combobox"), + (void)new wxStaticBox( panel, wxID_ANY, _T("&Box around combobox"), wxPoint(5, 5), wxSize(150, 100)); m_combo = new MyComboBox( panel, ID_COMBO, _T("This"), wxPoint(20,25), wxSize(120, -1), @@ -702,7 +702,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) (void)new wxButton( panel, ID_COMBO_DELETE, _T("D&elete selected item"), wxPoint(180,130), wxSize(140,30) ); (void)new wxButton( panel, ID_COMBO_FONT, _T("Set &Italic font"), wxPoint(340,130), wxSize(140,30) ); (void)new wxCheckBox( panel, ID_COMBO_ENABLE, _T("&Disable"), wxPoint(20,130), wxSize(140,30) ); - m_notebook->AddPage(panel, _T("wxComboBox"), FALSE, Image_Combo); + m_notebook->AddPage(panel, _T("wxComboBox"), false, Image_Combo); wxString choices2[] = { @@ -713,8 +713,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) }; panel = new wxPanel(m_notebook); - (void)new MyRadioBox( panel, ID_RADIOBOX, _T("&That"), wxPoint(10,160), wxSize(-1,-1), WXSIZEOF(choices2), choices2, 1, wxRA_SPECIFY_ROWS ); - m_radio = new wxRadioBox( panel, ID_RADIOBOX, _T("T&his"), wxPoint(10,10), wxSize(-1,-1), WXSIZEOF(choices), choices, 1, wxRA_SPECIFY_COLS ); + (void)new MyRadioBox( panel, ID_RADIOBOX, _T("&That"), wxPoint(10,160), wxDefaultSize, WXSIZEOF(choices2), choices2, 1, wxRA_SPECIFY_ROWS ); + m_radio = new wxRadioBox( panel, ID_RADIOBOX, _T("T&his"), wxPoint(10,10), wxDefaultSize, WXSIZEOF(choices), choices, 1, wxRA_SPECIFY_COLS ); m_radio->SetForegroundColour(*wxRED); #if wxUSE_TOOLTIPS @@ -728,16 +728,16 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) (void)new wxButton( panel, ID_RADIOBOX_FONT, _T("Set &Italic font"), wxPoint(340,80), wxSize(140,30) ); (void)new wxCheckBox( panel, ID_RADIOBOX_ENABLE, _T("&Disable"), wxPoint(340,130), wxDefaultSize ); wxRadioButton *rb = new wxRadioButton( panel, ID_RADIOBUTTON_1, _T("Radiobutton1"), wxPoint(210,170), wxDefaultSize, wxRB_GROUP ); - rb->SetValue( FALSE ); + rb->SetValue( false ); (void)new wxRadioButton( panel, ID_RADIOBUTTON_2, _T("&Radiobutton2"), wxPoint(340,170), wxDefaultSize ); - m_notebook->AddPage(panel, _T("wxRadioBox"), FALSE, Image_Radio); + m_notebook->AddPage(panel, _T("wxRadioBox"), false, Image_Radio); panel = new wxPanel(m_notebook); - (void)new wxStaticBox( panel, -1, _T("&wxGauge and wxSlider"), wxPoint(10,10), wxSize(222,130) ); - m_gauge = new wxGauge( panel, -1, 200, wxPoint(18,50), wxSize(155, 30), wxGA_HORIZONTAL|wxNO_BORDER ); + (void)new wxStaticBox( panel, wxID_ANY, _T("&wxGauge and wxSlider"), wxPoint(10,10), wxSize(222,130) ); + m_gauge = new wxGauge( panel, wxID_ANY, 200, wxPoint(18,50), wxSize(155, 30), wxGA_HORIZONTAL|wxNO_BORDER ); m_gauge->SetBackgroundColour(*wxGREEN); m_gauge->SetForegroundColour(*wxRED); - m_gaugeVert = new wxGauge( panel, -1, 100, + m_gaugeVert = new wxGauge( panel, wxID_ANY, 100, wxPoint(195,35), wxSize(30, 90), wxGA_VERTICAL | wxGA_SMOOTH | wxNO_BORDER ); m_slider = new wxSlider( panel, ID_SLIDER, 0, 0, 200, wxPoint(18,90), wxSize(155,-1), @@ -747,19 +747,19 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) m_slider->SetToolTip(_T("This is a sliding slider")); #endif // wxUSE_TOOLTIPS - (void)new wxStaticBox( panel, -1, _T("&Explanation"), + (void)new wxStaticBox( panel, wxID_ANY, _T("&Explanation"), wxPoint(230,10), wxSize(270,130), wxALIGN_CENTER ); #ifdef __WXMOTIF__ // No wrapping text in wxStaticText yet :-( - (void)new wxStaticText( panel, -1, + (void)new wxStaticText( panel, wxID_ANY, _T("Drag the slider!"), wxPoint(250,30), wxSize(240, -1) ); #else - (void)new wxStaticText( panel, -1, + (void)new wxStaticText( panel, wxID_ANY, _T("In order see the gauge (aka progress bar)\n") _T("control do something you have to drag the\n") _T("handle of the slider to the right.\n") @@ -773,7 +773,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) int initialSpinValue = -5; wxString s; s << initialSpinValue; - m_spintext = new wxTextCtrl( panel, -1, s, wxPoint(20,160), wxSize(80,-1) ); + m_spintext = new wxTextCtrl( panel, wxID_ANY, s, wxPoint(20,160), wxSize(80,-1) ); #if wxUSE_SPINBTN m_spinbutton = new wxSpinButton( panel, ID_SPIN, wxPoint(103,160), wxSize(80, -1) ); m_spinbutton->SetRange(-40,30); @@ -789,16 +789,16 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) m_spinctrl->SetValue(15); #endif // wxUSE_SPINCTRL - m_notebook->AddPage(panel, _T("wxGauge"), FALSE, Image_Gauge); + m_notebook->AddPage(panel, _T("wxGauge"), false, Image_Gauge); panel = new wxPanel(m_notebook); #if !defined(__WXMOTIF__) && !defined(__WIN16__) // wxStaticBitmap not working under Motif yet; and icons not allowed under WIN16. wxIcon icon = wxArtProvider::GetIcon(wxART_INFORMATION); - (void) new wxStaticBitmap( panel, -1, icon, wxPoint(10, 10) ); + (void) new wxStaticBitmap( panel, wxID_ANY, icon, wxPoint(10, 10) ); // VZ: don't leak memory - // bmpStatic = new wxStaticBitmap(panel, -1, wxNullIcon, wxPoint(50, 10)); + // bmpStatic = new wxStaticBitmap(panel, wxID_ANY, wxNullIcon, wxPoint(50, 10)); // bmpStatic->SetIcon(wxArtProvider::GetIcon(wxART_QUESTION)); #endif // !Motif @@ -820,7 +820,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) { bitmap.SetMask(new wxMask(bitmap, *wxBLUE)); - (void)new wxStaticBitmap /* wxBitmapButton */ (panel, -1, bitmap, wxPoint(300, 120)); + (void)new wxStaticBitmap /* wxBitmapButton */ (panel, wxID_ANY, bitmap, wxPoint(300, 120)); } #endif @@ -829,7 +829,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) bmp3(wxArtProvider::GetBitmap(wxART_QUESTION)); wxBitmapButton *bmpBtn = new wxBitmapButton ( - panel, -1, + panel, wxID_ANY, bmp1, wxPoint(30, 70) ); @@ -845,70 +845,42 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) _T("&Toggle label"), wxPoint(250, 20)); #endif // wxUSE_TOGGLEBTN - m_label = new wxStaticText(panel, -1, _T("Label with some long text"), + m_label = new wxStaticText(panel, wxID_ANY, _T("Label with some long text"), wxPoint(250, 60), wxDefaultSize, wxALIGN_RIGHT /*| wxST_NO_AUTORESIZE*/); m_label->SetForegroundColour( *wxBLUE ); m_notebook->AddPage(panel, _T("wxBitmapXXX")); - // layout constraints -#if wxUSE_CONSTRAINTS - wxLayoutConstraints *c; - - panel = new wxPanel(m_notebook); - panel->SetAutoLayout( TRUE ); - - c = new wxLayoutConstraints; - c->top.SameAs( panel, wxTop, 10 ); - c->height.AsIs( ); - c->left.SameAs( panel, wxLeft, 10 ); - c->width.PercentOf( panel, wxWidth, 40 ); - - wxButton *pMyButton = new wxButton(panel, ID_BUTTON_TEST1, _T("Test Button &1") ); - pMyButton->SetConstraints( c ); - - c = new wxLayoutConstraints; - c->top.SameAs( panel, wxTop, 10 ); - c->bottom.SameAs( panel, wxBottom, 10 ); - c->right.SameAs( panel, wxRight, 10 ); - c->width.PercentOf( panel, wxWidth, 40 ); - - wxButton *pMyButton2 = new wxButton(panel, ID_BUTTON_TEST2, _T("Test Button &2") ); - pMyButton2->SetConstraints( c ); - - m_notebook->AddPage(panel, _T("wxLayoutConstraint")); -#endif - // sizer panel = new wxPanel(m_notebook); - panel->SetAutoLayout( TRUE ); + panel->SetAutoLayout( true ); wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL ); wxStaticBoxSizer *csizer = - new wxStaticBoxSizer (new wxStaticBox (panel, -1, _T("Show Buttons")), + new wxStaticBoxSizer (new wxStaticBox (panel, wxID_ANY, _T("Show Buttons")), wxHORIZONTAL ); wxCheckBox *check1, *check2, *check3, *check4, *check14, *checkBig; check1 = new wxCheckBox (panel, ID_SIZER_CHECK1, _T("1")); - check1->SetValue (TRUE); + check1->SetValue (true); csizer->Add (check1); check2 = new wxCheckBox (panel, ID_SIZER_CHECK2, _T("2")); - check2->SetValue (TRUE); + check2->SetValue (true); csizer->Add (check2); check3 = new wxCheckBox (panel, ID_SIZER_CHECK3, _T("3")); - check3->SetValue (TRUE); + check3->SetValue (true); csizer->Add (check3); check4 = new wxCheckBox (panel, ID_SIZER_CHECK4, _T("4")); - check4->SetValue (TRUE); + check4->SetValue (true); csizer->Add (check4); check14 = new wxCheckBox (panel, ID_SIZER_CHECK14, _T("1-4")); - check14->SetValue (TRUE); + check14->SetValue (true); csizer->Add (check14); checkBig = new wxCheckBox (panel, ID_SIZER_CHECKBIG, _T("Big")); - checkBig->SetValue (TRUE); + checkBig->SetValue (true); csizer->Add (checkBig); sizer->Add (csizer); @@ -917,18 +889,18 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) m_buttonSizer = new wxBoxSizer (wxVERTICAL); - m_sizerBtn1 = new wxButton(panel, -1, _T("Test Button &1") ); + m_sizerBtn1 = new wxButton(panel, wxID_ANY, _T("Test Button &1") ); m_buttonSizer->Add( m_sizerBtn1, 0, wxALL, 10 ); - m_sizerBtn2 = new wxButton(panel, -1, _T("Test Button &2") ); + m_sizerBtn2 = new wxButton(panel, wxID_ANY, _T("Test Button &2") ); m_buttonSizer->Add( m_sizerBtn2, 0, wxALL, 10 ); - m_sizerBtn3 = new wxButton(panel, -1, _T("Test Button &3") ); + m_sizerBtn3 = new wxButton(panel, wxID_ANY, _T("Test Button &3") ); m_buttonSizer->Add( m_sizerBtn3, 0, wxALL, 10 ); - m_sizerBtn4 = new wxButton(panel, -1, _T("Test Button &4") ); + m_sizerBtn4 = new wxButton(panel, wxID_ANY, _T("Test Button &4") ); m_buttonSizer->Add( m_sizerBtn4, 0, wxALL, 10 ); m_hsizer->Add (m_buttonSizer); m_hsizer->Add( 20,20, 1 ); - m_bigBtn = new wxButton(panel, -1, _T("Multiline\nbutton") ); + m_bigBtn = new wxButton(panel, wxID_ANY, _T("Multiline\nbutton") ); m_hsizer->Add( m_bigBtn , 3, wxGROW|wxALL, 10 ); sizer->Add (m_hsizer, 1, wxGROW); @@ -1467,7 +1439,7 @@ void MyPanel::OnShowProgress( wxCommandEvent& WXUNUSED(event) ) wxPD_REMAINING_TIME); - bool cont = TRUE; + bool cont = true; for ( int i = 0; i <= max && cont; i++ ) { wxSleep(1); @@ -1558,7 +1530,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) END_EVENT_TABLE() MyFrame::MyFrame(const wxChar *title, int x, int y) - : wxFrame(NULL, -1, title, wxPoint(x, y), wxSize(500, 430)) + : wxFrame(NULL, wxID_ANY, title, wxPoint(x, y), wxSize(500, 430)) { // Give it an icon // The wxICON() macros loads an icon from a resource under Windows @@ -1584,14 +1556,14 @@ MyFrame::MyFrame(const wxChar *title, int x, int y) tooltip_menu->Append(CONTROLS_SET_TOOLTIP_DELAY, _T("Set &delay\tCtrl-D")); tooltip_menu->AppendSeparator(); tooltip_menu->Append(CONTROLS_ENABLE_TOOLTIPS, _T("&Toggle tooltips\tCtrl-T"), - _T("enable/disable tooltips"), TRUE); - tooltip_menu->Check(CONTROLS_ENABLE_TOOLTIPS, TRUE); + _T("enable/disable tooltips"), true); + tooltip_menu->Check(CONTROLS_ENABLE_TOOLTIPS, true); menu_bar->Append(tooltip_menu, _T("&Tooltips")); #endif // wxUSE_TOOLTIPS wxMenu *panel_menu = new wxMenu; panel_menu->Append(CONTROLS_ENABLE_ALL, _T("&Disable all\tCtrl-E"), - _T("Enable/disable all panel controls"), TRUE); + _T("Enable/disable all panel controls"), true); menu_bar->Append(panel_menu, _T("&Panel")); SetMenuBar(menu_bar); @@ -1605,7 +1577,7 @@ MyFrame::MyFrame(const wxChar *title, int x, int y) void MyFrame::OnQuit (wxCommandEvent& WXUNUSED(event) ) { - Close(TRUE); + Close(true); } void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) @@ -1645,7 +1617,7 @@ void MyFrame::OnSetTooltipDelay(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnToggleTooltips(wxCommandEvent& WXUNUSED(event)) { - static bool s_enabled = TRUE; + static bool s_enabled = true; s_enabled = !s_enabled; @@ -1657,7 +1629,7 @@ void MyFrame::OnToggleTooltips(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnEnableAll(wxCommandEvent& WXUNUSED(event)) { - static bool s_enable = TRUE; + static bool s_enable = true; s_enable = !s_enable; m_panel->Enable(s_enable); diff --git a/samples/dnd/dnd.cpp b/samples/dnd/dnd.cpp index f2c9da7f78..e08ee8377c 100644 --- a/samples/dnd/dnd.cpp +++ b/samples/dnd/dnd.cpp @@ -484,9 +484,9 @@ public: // we don't draw the shape to a bitmap until it's really needed (i.e. // we're asked to do so) - m_hasBitmap = FALSE; + m_hasBitmap = false; #if wxUSE_METAFILES - m_hasMetaFile = FALSE; + m_hasMetaFile = false; #endif // wxUSE_METAFILES } @@ -503,9 +503,9 @@ public: DnDShape *shape = m_shape; m_shape = (DnDShape *)NULL; - m_hasBitmap = FALSE; + m_hasBitmap = false; #if wxUSE_METAFILES - m_hasMetaFile = FALSE; + m_hasMetaFile = false; #endif // wxUSE_METAFILES return shape; @@ -586,7 +586,7 @@ public: { m_shape->GetDataHere(pBuf); - return TRUE; + return true; } #if wxUSE_METAFILES else if ( m_dobjMetaFile.IsSupported(format) ) @@ -612,20 +612,20 @@ public: virtual bool SetData(const wxDataFormat& format, size_t len, const void *buf) { - wxCHECK_MSG( format == m_formatShape, FALSE, + wxCHECK_MSG( format == m_formatShape, false, wxT( "unsupported format") ); delete m_shape; m_shape = DnDShape::New(buf); // the shape has changed - m_hasBitmap = FALSE; + m_hasBitmap = false; #if wxUSE_METAFILES - m_hasMetaFile = FALSE; + m_hasMetaFile = false; #endif // wxUSE_METAFILES - return TRUE; + return true; } private: @@ -888,21 +888,21 @@ bool DnDApp::OnInit() 10, 100, 650, 340); // activate it - frame->Show(TRUE); + frame->Show(true); SetTopWindow(frame); - return TRUE; + return true; #else wxMessageBox( _T("This sample has to be compiled with wxUSE_DRAG_AND_DROP"), _T("Building error"), wxOK); - return FALSE; + return false; #endif // wxUSE_DRAG_AND_DROP } #if wxUSE_DRAG_AND_DROP DnDFrame::DnDFrame(wxFrame *frame, wxChar *title, int x, int y, int w, int h) - : wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h)), + : wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h)), m_strText(_T("wxWindows drag & drop works :-)")) { @@ -951,17 +951,14 @@ DnDFrame::DnDFrame(wxFrame *frame, wxChar *title, int x, int y, int w, int h) SetMenuBar(menu_bar); // make a panel with 3 subwindows - wxPoint pos(0, 0); - wxSize size(400, 200); - wxString strFile(_T("Drop files here!")), strText(_T("Drop text on me")); - m_ctrlFile = new wxListBox(this, -1, pos, size, 1, &strFile, + m_ctrlFile = new wxListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 1, &strFile, wxLB_HSCROLL | wxLB_ALWAYS_SB ); - m_ctrlText = new wxListBox(this, -1, pos, size, 1, &strText, + m_ctrlText = new wxListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 1, &strText, wxLB_HSCROLL | wxLB_ALWAYS_SB ); - m_ctrlLog = new wxTextCtrl(this, -1, _T(""), pos, size, + m_ctrlLog = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY | wxSUNKEN_BORDER ); @@ -974,43 +971,26 @@ DnDFrame::DnDFrame(wxFrame *frame, wxChar *title, int x, int y, int w, int h) m_ctrlText->SetDropTarget(new DnDText(m_ctrlText)); m_ctrlLog->SetDropTarget(new URLDropTarget); - wxLayoutConstraints *c; - - // Top-left listbox - c = new wxLayoutConstraints; - c->left.SameAs(this, wxLeft); - c->top.SameAs(this, wxTop); - c->right.PercentOf(this, wxRight, 50); - c->height.PercentOf(this, wxHeight, 30); - m_ctrlFile->SetConstraints(c); - - // Top-right listbox - c = new wxLayoutConstraints; - c->left.SameAs (m_ctrlFile, wxRight); - c->top.SameAs (this, wxTop); - c->right.SameAs (this, wxRight); - c->height.PercentOf(this, wxHeight, 30); - m_ctrlText->SetConstraints(c); - - // Lower text control - c = new wxLayoutConstraints; - c->left.SameAs (this, wxLeft); - c->right.SameAs (this, wxRight); - c->height.PercentOf(this, wxHeight, 50); - c->top.SameAs(m_ctrlText, wxBottom); - m_ctrlLog->SetConstraints(c); - - SetAutoLayout(TRUE); + wxBoxSizer *m_sizer_top = new wxBoxSizer( wxHORIZONTAL ); + m_sizer_top->Add(m_ctrlFile, 1, wxEXPAND ); + m_sizer_top->Add(m_ctrlText, 1, wxEXPAND ); + + wxBoxSizer *m_sizer = new wxBoxSizer( wxVERTICAL ); + m_sizer->Add(m_sizer_top, 1, wxEXPAND ); + m_sizer->Add(m_ctrlLog, 1, wxEXPAND | wxBOTTOM, 50); + + SetSizer( m_sizer ); + m_sizer->SetSizeHints( this ); // copy data by default but allow moving it as well - m_moveByDefault = FALSE; - m_moveAllow = TRUE; - menu_bar->Check(Menu_DragMoveAllow, TRUE); + m_moveByDefault = false; + m_moveAllow = true; + menu_bar->Check(Menu_DragMoveAllow, true); } void DnDFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) { - Close(TRUE); + Close(true); } void DnDFrame::OnSize(wxSizeEvent& event) @@ -1028,7 +1008,7 @@ void DnDFrame::OnPaint(wxPaintEvent& WXUNUSED(event)) wxPaintDC dc(this); // dc.Clear(); -- this kills wxGTK - dc.SetFont( wxFont( 24, wxDECORATIVE, wxNORMAL, wxNORMAL, FALSE, _T("charter") ) ); + dc.SetFont( wxFont( 24, wxDECORATIVE, wxNORMAL, wxNORMAL, false, _T("charter") ) ); dc.DrawText( _T("Drag text from here!"), 100, h-50 ); } @@ -1062,7 +1042,7 @@ void DnDFrame::OnUpdateUIPasteBitmap(wxUpdateUIEvent& event) void DnDFrame::OnNewFrame(wxCommandEvent& WXUNUSED(event)) { - (new DnDShapeFrame(this))->Show(TRUE); + (new DnDShapeFrame(this))->Show(true); wxLogStatus(this, wxT("Double click the new frame to select a shape for it")); } @@ -1453,7 +1433,7 @@ bool DnDText::OnDropText(wxCoord, wxCoord, const wxString& text) { m_pOwner->Append(text); - return TRUE; + return true; } bool DnDFile::OnDropFiles(wxCoord, wxCoord, const wxArrayString& filenames) @@ -1466,7 +1446,7 @@ bool DnDFile::OnDropFiles(wxCoord, wxCoord, const wxArrayString& filenames) m_pOwner->Append(filenames[n]); } - return TRUE; + return true; } // ---------------------------------------------------------------------------- @@ -1486,39 +1466,39 @@ DnDShapeDialog::DnDShapeDialog(wxFrame *parent, DnDShape *shape) const wxString choices[] = { wxT("None"), wxT("Triangle"), wxT("Rectangle"), wxT("Ellipse") }; - m_radio = new wxRadioBox( this, -1, wxT("&Shape"), + m_radio = new wxRadioBox( this, wxID_ANY, wxT("&Shape"), wxDefaultPosition, wxDefaultSize, 4, choices, 4, wxRA_SPECIFY_COLS ); shapesSizer->Add( m_radio, 0, wxGROW|wxALL, 5 ); topSizer->Add( shapesSizer, 0, wxALL, 2 ); // attributes - wxStaticBox* box = new wxStaticBox( this, -1, wxT("&Attributes") ); + wxStaticBox* box = new wxStaticBox( this, wxID_ANY, wxT("&Attributes") ); wxStaticBoxSizer* attrSizer = new wxStaticBoxSizer( box, wxHORIZONTAL ); wxFlexGridSizer* xywhSizer = new wxFlexGridSizer( 4, 2 ); wxStaticText* st; - st = new wxStaticText( this, -1, wxT("Position &X:") ); - m_textX = new wxTextCtrl( this, -1, wxEmptyString, wxDefaultPosition, + st = new wxStaticText( this, wxID_ANY, wxT("Position &X:") ); + m_textX = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 30, 20 ) ); xywhSizer->Add( st, 1, wxGROW|wxALL, 2 ); xywhSizer->Add( m_textX, 1, wxGROW|wxALL, 2 ); - st = new wxStaticText( this, -1, wxT("Size &width:") ); - m_textW = new wxTextCtrl( this, -1, wxEmptyString, wxDefaultPosition, + st = new wxStaticText( this, wxID_ANY, wxT("Size &width:") ); + m_textW = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 30, 20 ) ); xywhSizer->Add( st, 1, wxGROW|wxALL, 2 ); xywhSizer->Add( m_textW, 1, wxGROW|wxALL, 2 ); - st = new wxStaticText( this, -1, wxT("&Y:") ); - m_textY = new wxTextCtrl( this, -1, wxEmptyString, wxDefaultPosition, + st = new wxStaticText( this, wxID_ANY, wxT("&Y:") ); + m_textY = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 30, 20 ) ); xywhSizer->Add( st, 1, wxALL|wxALIGN_RIGHT, 2 ); xywhSizer->Add( m_textY, 1, wxGROW|wxALL, 2 ); - st = new wxStaticText( this, -1, wxT("&height:") ); - m_textH = new wxTextCtrl( this, -1, wxEmptyString, wxDefaultPosition, + st = new wxStaticText( this, wxID_ANY, wxT("&height:") ); + m_textH = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 30, 20 ) ); xywhSizer->Add( st, 1, wxALL|wxALIGN_RIGHT, 2 ); xywhSizer->Add( m_textH, 1, wxGROW|wxALL, 2 ); @@ -1537,7 +1517,6 @@ DnDShapeDialog::DnDShapeDialog(wxFrame *parent, DnDShape *shape) buttonSizer->Add( bt, 0, wxALL, 2 ); topSizer->Add( buttonSizer, 0, wxALL|wxALIGN_RIGHT, 2 ); - SetAutoLayout( TRUE ); SetSizer( topSizer ); topSizer->Fit( this ); } @@ -1576,7 +1555,7 @@ bool DnDShapeDialog::TransferDataToWindow() m_textW->SetValue(wxString() << m_size.x); m_textH->SetValue(wxString() << m_size.y); - return TRUE; + return true; } bool DnDShapeDialog::TransferDataFromWindow() @@ -1593,16 +1572,16 @@ bool DnDShapeDialog::TransferDataFromWindow() wxMessageBox(_T("All sizes and positions should be non null!"), _T("Invalid shape"), wxICON_HAND | wxOK, this); - return FALSE; + return false; } - return TRUE; + return true; } void DnDShapeDialog::OnColour(wxCommandEvent& WXUNUSED(event)) { wxColourData data; - data.SetChooseFull(TRUE); + data.SetChooseFull(true); for (int i = 0; i < 16; i++) { wxColour colour(i*16, i*16, i*16); @@ -1623,7 +1602,7 @@ void DnDShapeDialog::OnColour(wxCommandEvent& WXUNUSED(event)) DnDShapeFrame *DnDShapeFrame::ms_lastDropTarget = NULL; DnDShapeFrame::DnDShapeFrame(wxFrame *parent) - : wxFrame(parent, -1, _T("Shape Frame"), + : wxFrame(parent, wxID_ANY, _T("Shape Frame"), wxDefaultPosition, wxSize(250, 150)) { CreateStatusBar(); @@ -1682,7 +1661,7 @@ void DnDShapeFrame::OnDrag(wxMouseEvent& event) wxDropSource source(shapeData, this); const wxChar *pc = NULL; - switch ( source.DoDragDrop(TRUE) ) + switch ( source.DoDragDrop(true) ) { default: case wxDragError: @@ -1868,7 +1847,7 @@ void DnDShapeDataObject::CreateMetaFile() const DnDShapeDataObject *self = (DnDShapeDataObject *)this; // const_cast self->m_dobjMetaFile.SetMetafile(*mf); - self->m_hasMetaFile = TRUE; + self->m_hasMetaFile = true; delete mf; } @@ -1891,7 +1870,7 @@ void DnDShapeDataObject::CreateBitmap() const DnDShapeDataObject *self = (DnDShapeDataObject *)this; // const_cast self->m_dobjBitmap.SetBitmap(bitmap); - self->m_hasBitmap = TRUE; + self->m_hasBitmap = true; } // ---------------------------------------------------------------------------- @@ -1900,7 +1879,7 @@ void DnDShapeDataObject::CreateBitmap() const static void ShowBitmap(const wxBitmap& bitmap) { - wxFrame *frame = new wxFrame(NULL, -1, _T("Bitmap view")); + wxFrame *frame = new wxFrame(NULL, wxID_ANY, _T("Bitmap view")); frame->CreateStatusBar(); DnDCanvasBitmap *canvas = new DnDCanvasBitmap(frame); canvas->SetBitmap(bitmap); @@ -1910,14 +1889,14 @@ static void ShowBitmap(const wxBitmap& bitmap) frame->SetStatusText(wxString::Format(_T("%dx%d"), w, h)); frame->SetClientSize(w > 100 ? 100 : w, h > 100 ? 100 : h); - frame->Show(TRUE); + frame->Show(true); } #if wxUSE_METAFILES static void ShowMetaFile(const wxMetaFile& metafile) { - wxFrame *frame = new wxFrame(NULL, -1, _T("Metafile view")); + wxFrame *frame = new wxFrame(NULL, wxID_ANY, _T("Metafile view")); frame->CreateStatusBar(); DnDCanvasMetafile *canvas = new DnDCanvasMetafile(frame); canvas->SetMetafile(metafile); diff --git a/samples/layout/layout.cpp b/samples/layout/layout.cpp index cde64a3c99..ce576a3c1d 100644 --- a/samples/layout/layout.cpp +++ b/samples/layout/layout.cpp @@ -24,10 +24,6 @@ #include "wx/wx.h" #endif -#if !wxUSE_CONSTRAINTS -#error You must set wxUSE_CONSTRAINTS to 1 in setup.h! -#endif - #include "wx/sizer.h" #include "wx/gbsizer.h" #include "wx/statline.h" @@ -50,9 +46,9 @@ bool MyApp::OnInit() // Create the main frame window MyFrame *frame = new MyFrame; - frame->Show(TRUE); + frame->Show(true); - return TRUE; + return true; } // ---------------------------------------------------------------------------- @@ -63,7 +59,6 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(LAYOUT_ABOUT, MyFrame::OnAbout) EVT_MENU(LAYOUT_QUIT, MyFrame::OnQuit) - EVT_MENU(LAYOUT_TEST_CONSTRAINTS, MyFrame::TestConstraints) EVT_MENU(LAYOUT_TEST_SIZER, MyFrame::TestFlexSizers) EVT_MENU(LAYOUT_TEST_NB_SIZER, MyFrame::TestNotebookSizers) EVT_MENU(LAYOUT_TEST_GB_SIZER, MyFrame::TestGridBagSizer) @@ -71,14 +66,13 @@ END_EVENT_TABLE() // Define my frame constructor MyFrame::MyFrame() - : wxFrame(NULL, -1, _T("wxWindows Layout Demo"), + : wxFrame(NULL, wxID_ANY, _T("wxWindows Layout Demo"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE) { // Make a menubar wxMenu *file_menu = new wxMenu; - file_menu->Append(LAYOUT_TEST_CONSTRAINTS, _T("Test &constraints")); file_menu->Append(LAYOUT_TEST_SIZER, _T("Test wx&FlexSizer")); file_menu->Append(LAYOUT_TEST_NB_SIZER, _T("&Test notebook sizers")); file_menu->Append(LAYOUT_TEST_GB_SIZER, _T("Test &gridbag sizer")); @@ -109,7 +103,7 @@ MyFrame::MyFrame() // 1) top: create wxStaticText with minimum size equal to its default size topsizer->Add( - new wxStaticText( this, -1, _T("An explanation (wxALIGN_RIGHT).") ), + new wxStaticText( this, wxID_ANY, _T("An explanation (wxALIGN_RIGHT).") ), 0, // make vertically unstretchable wxALIGN_RIGHT | // right align text wxTOP | wxLEFT | wxRIGHT, // make border all around except wxBOTTOM @@ -117,7 +111,7 @@ MyFrame::MyFrame() // 2) top: create wxTextCtrl with minimum size (100x60) topsizer->Add( - new wxTextCtrl( this, -1, _T("My text (wxEXPAND)."), wxDefaultPosition, wxSize(100,60), wxTE_MULTILINE), + new wxTextCtrl( this, wxID_ANY, _T("My text (wxEXPAND)."), wxDefaultPosition, wxSize(100,60), wxTE_MULTILINE), 1, // make vertically stretchable wxEXPAND | // make horizontally stretchable wxALL, // and make border all around @@ -125,10 +119,10 @@ MyFrame::MyFrame() // 2.5) Gratuitous test of wxStaticBoxSizers wxBoxSizer *statsizer = new wxStaticBoxSizer( - new wxStaticBox(this, -1, _T("A wxStaticBoxSizer")), + new wxStaticBox(this, wxID_ANY, _T("A wxStaticBoxSizer")), wxVERTICAL ); statsizer->Add( - new wxStaticText(this, -1, _T("And some TEXT inside it")), + new wxStaticText(this, wxID_ANY, _T("And some TEXT inside it")), 0, wxCENTER | wxALL, @@ -137,24 +131,24 @@ MyFrame::MyFrame() // 2.7) And a test of wxGridSizer wxGridSizer *gridsizer = new wxGridSizer(2, 5, 5); - gridsizer->Add(new wxStaticText(this, -1, _T("Label")), 0, + gridsizer->Add(new wxStaticText(this, wxID_ANY, _T("Label")), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - gridsizer->Add(new wxTextCtrl(this, -1, _T("Grid sizer demo")), 1, + gridsizer->Add(new wxTextCtrl(this, wxID_ANY, _T("Grid sizer demo")), 1, wxGROW | wxALIGN_CENTER_VERTICAL); - gridsizer->Add(new wxStaticText(this, -1, _T("Another label")), 0, + gridsizer->Add(new wxStaticText(this, wxID_ANY, _T("Another label")), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - gridsizer->Add(new wxTextCtrl(this, -1, _T("More text")), 1, + gridsizer->Add(new wxTextCtrl(this, wxID_ANY, _T("More text")), 1, wxGROW | wxALIGN_CENTER_VERTICAL); - gridsizer->Add(new wxStaticText(this, -1, _T("Final label")), 0, + gridsizer->Add(new wxStaticText(this, wxID_ANY, _T("Final label")), 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL); - gridsizer->Add(new wxTextCtrl(this, -1, _T("And yet more text")), 1, + gridsizer->Add(new wxTextCtrl(this, wxID_ANY, _T("And yet more text")), 1, wxGROW | wxALIGN_CENTER_VERTICAL); topsizer->Add(gridsizer, 1, wxGROW | wxALL, 10); // 3) middle: create wxStaticLine with minimum size (3x3) topsizer->Add( - new wxStaticLine( this, -1, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), + new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxSize(3,3), wxHORIZONTAL), 0, // make vertically unstretchable wxEXPAND | // make horizontally stretchable wxALL, // and make border all around @@ -164,12 +158,12 @@ MyFrame::MyFrame() // 4) bottom: create two centred wxButtons wxBoxSizer *button_box = new wxBoxSizer( wxHORIZONTAL ); button_box->Add( - new wxButton( this, -1, _T("Two buttons in a box") ), + new wxButton( this, wxID_ANY, _T("Two buttons in a box") ), 0, // make horizontally unstretchable wxALL, // make border all around 7 ); // set border width to 7 button_box->Add( - new wxButton( this, -1, _T("(wxCENTER)") ), + new wxButton( this, wxID_ANY, _T("(wxCENTER)") ), 0, // make horizontally unstretchable wxALL, // make border all around 7 ); // set border width to 7 @@ -188,20 +182,13 @@ MyFrame::MyFrame() void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) ) { - Close(TRUE); -} - -void MyFrame::TestConstraints(wxCommandEvent& WXUNUSED(event) ) -{ - MyConstraintsFrame * - newFrame = new MyConstraintsFrame(_T("Constraints Test Frame"), 100, 100); - newFrame->Show(TRUE); + Close(true); } void MyFrame::TestFlexSizers(wxCommandEvent& WXUNUSED(event) ) { MyFlexSizerFrame *newFrame = new MyFlexSizerFrame(_T("Flex Sizer Test Frame"), 50, 50); - newFrame->Show(TRUE); + newFrame->Show(true); } void MyFrame::TestNotebookSizers(wxCommandEvent& WXUNUSED(event) ) @@ -222,98 +209,10 @@ void MyFrame::TestGridBagSizer(wxCommandEvent& WXUNUSED(event) ) { MyGridBagSizerFrame *newFrame = new MyGridBagSizerFrame(_T("wxGridBagSizer Test Frame"), 50, 50); - newFrame->Show(TRUE); + newFrame->Show(true); } -// ---------------------------------------------------------------------------- -// MyConstraintsFrame -// ---------------------------------------------------------------------------- - -MyConstraintsFrame::MyConstraintsFrame(const wxChar *title, int x, int y) - : wxFrame(NULL, -1, title, wxPoint(x, y) ) -{ - // Make a panel - wxPanel *panel = new wxPanel(this); - - // Create some panel items - wxButton *btn1 = new wxButton(panel, -1, _T("A button (1)")) ; - - wxLayoutConstraints *b1 = new wxLayoutConstraints; - b1->centreX.SameAs (panel, wxCentreX); - b1->top.SameAs (panel, wxTop, 5); - b1->width.PercentOf (panel, wxWidth, 80); - b1->height.AsIs (); - btn1->SetConstraints(b1); - - wxListBox *list = new wxListBox(panel, -1, - wxPoint(-1, -1), wxSize(200, 100)); - list->Append(_T("Apple")); - list->Append(_T("Pear")); - list->Append(_T("Orange")); - list->Append(_T("Banana")); - list->Append(_T("Fruit")); - - wxLayoutConstraints *b2 = new wxLayoutConstraints; - b2->top.Below (btn1, 5); - b2->left.SameAs (panel, wxLeft, 5); - b2->width.PercentOf (panel, wxWidth, 40); - b2->bottom.SameAs (panel, wxBottom, 5); - list->SetConstraints(b2); - - wxTextCtrl *mtext = new wxTextCtrl(panel, -1, - _T("This frame is laid out using\nconstraints, but the preferred\nlayout mechanism now are sizers."), - wxDefaultPosition, - wxDefaultSize, - wxTE_MULTILINE); - - wxLayoutConstraints *b3 = new wxLayoutConstraints; - b3->top.Below (btn1, 5); - b3->left.RightOf (list, 5); - b3->right.SameAs (panel, wxRight, 5); - b3->bottom.SameAs (panel, wxBottom, 5); - mtext->SetConstraints(b3); - - wxTextCtrl *canvas = new wxTextCtrl(this, -1, _T("yet another window")); - - // Make a text window - wxTextCtrl *text_window = new wxTextCtrl(this, -1, _T(""), - wxDefaultPosition, - wxDefaultSize, - wxTE_MULTILINE); - - // Set constraints for panel subwindow - wxLayoutConstraints *c1 = new wxLayoutConstraints; - - c1->left.SameAs (this, wxLeft); - c1->top.SameAs (this, wxTop); - c1->right.PercentOf (this, wxWidth, 50); - c1->height.PercentOf (this, wxHeight, 50); - - panel->SetConstraints(c1); - - // Set constraints for canvas subwindow - wxLayoutConstraints *c2 = new wxLayoutConstraints; - - c2->left.SameAs (panel, wxRight); - c2->top.SameAs (this, wxTop); - c2->right.SameAs (this, wxRight); - c2->height.PercentOf (this, wxHeight, 50); - - canvas->SetConstraints(c2); - - // Set constraints for text subwindow - wxLayoutConstraints *c3 = new wxLayoutConstraints; - c3->left.SameAs (this, wxLeft); - c3->top.Below (panel); - c3->right.SameAs (this, wxRight); - c3->bottom.SameAs (this, wxBottom); - - text_window->SetConstraints(c3); - - SetAutoLayout(TRUE); -} - // ---------------------------------------------------------------------------- // MyFlexSizerFrame // ---------------------------------------------------------------------------- @@ -327,7 +226,7 @@ void MyFlexSizerFrame::InitFlexSizer(wxFlexGridSizer *sizer) sizer->Add(new wxStaticText ( this, - -1, + wxID_ANY, wxString::Format(_T("(%d, %d)"), i + 1, j + 1), wxDefaultPosition, wxDefaultSize, @@ -339,30 +238,30 @@ void MyFlexSizerFrame::InitFlexSizer(wxFlexGridSizer *sizer) } MyFlexSizerFrame::MyFlexSizerFrame(const wxChar *title, int x, int y ) - : wxFrame(NULL, -1, title, wxPoint(x, y) ) + : wxFrame(NULL, wxID_ANY, title, wxPoint(x, y) ) { wxFlexGridSizer *sizerFlex; // consttuct the first column wxSizer *sizerCol1 = new wxBoxSizer(wxVERTICAL); - sizerCol1->Add(new wxStaticText(this, -1, _T("Ungrowable:")), 0, wxCENTER | wxTOP, 20); + sizerCol1->Add(new wxStaticText(this, wxID_ANY, _T("Ungrowable:")), 0, wxCENTER | wxTOP, 20); sizerFlex = new wxFlexGridSizer(3, 3); InitFlexSizer(sizerFlex); sizerCol1->Add(sizerFlex, 1, wxALL | wxEXPAND, 10); - sizerCol1->Add(new wxStaticText(this, -1, _T("Growable middle column:")), 0, wxCENTER | wxTOP, 20); + sizerCol1->Add(new wxStaticText(this, wxID_ANY, _T("Growable middle column:")), 0, wxCENTER | wxTOP, 20); sizerFlex = new wxFlexGridSizer(3, 3); InitFlexSizer(sizerFlex); sizerFlex->AddGrowableCol(1); sizerCol1->Add(sizerFlex, 1, wxALL | wxEXPAND, 10); - sizerCol1->Add(new wxStaticText(this, -1, _T("Growable middle row:")), 0, wxCENTER | wxTOP, 20); + sizerCol1->Add(new wxStaticText(this, wxID_ANY, _T("Growable middle row:")), 0, wxCENTER | wxTOP, 20); sizerFlex = new wxFlexGridSizer(3, 3); InitFlexSizer(sizerFlex); sizerFlex->AddGrowableRow(1); sizerCol1->Add(sizerFlex, 1, wxALL | wxEXPAND, 10); - sizerCol1->Add(new wxStaticText(this, -1, _T("All growable columns:")), 0, wxCENTER | wxTOP, 20); + sizerCol1->Add(new wxStaticText(this, wxID_ANY, _T("All growable columns:")), 0, wxCENTER | wxTOP, 20); sizerFlex = new wxFlexGridSizer(3, 3); InitFlexSizer(sizerFlex); sizerFlex->AddGrowableCol(0, 1); @@ -372,14 +271,14 @@ MyFlexSizerFrame::MyFlexSizerFrame(const wxChar *title, int x, int y ) // the second one wxSizer *sizerCol2 = new wxBoxSizer(wxVERTICAL); - sizerCol2->Add(new wxStaticText(this, -1, _T("Growable middle row and column:")), 0, wxCENTER | wxTOP, 20); + sizerCol2->Add(new wxStaticText(this, wxID_ANY, _T("Growable middle row and column:")), 0, wxCENTER | wxTOP, 20); sizerFlex = new wxFlexGridSizer(3, 3); InitFlexSizer(sizerFlex); sizerFlex->AddGrowableCol(1); sizerFlex->AddGrowableRow(1); sizerCol2->Add(sizerFlex, 1, wxALL | wxEXPAND, 10); - sizerCol2->Add(new wxStaticText(this, -1, _T("Same with horz flex direction")), 0, wxCENTER | wxTOP, 20); + sizerCol2->Add(new wxStaticText(this, wxID_ANY, _T("Same with horz flex direction")), 0, wxCENTER | wxTOP, 20); sizerFlex = new wxFlexGridSizer(3, 3); InitFlexSizer(sizerFlex); sizerFlex->AddGrowableCol(1); @@ -387,7 +286,7 @@ MyFlexSizerFrame::MyFlexSizerFrame(const wxChar *title, int x, int y ) sizerFlex->SetFlexibleDirection(wxHORIZONTAL); sizerCol2->Add(sizerFlex, 1, wxALL | wxEXPAND, 10); - sizerCol2->Add(new wxStaticText(this, -1, _T("Same with grow mode == \"none\"")), 0, wxCENTER | wxTOP, 20); + sizerCol2->Add(new wxStaticText(this, wxID_ANY, _T("Same with grow mode == \"none\"")), 0, wxCENTER | wxTOP, 20); sizerFlex = new wxFlexGridSizer(3, 3); InitFlexSizer(sizerFlex); sizerFlex->AddGrowableCol(1); @@ -396,7 +295,7 @@ MyFlexSizerFrame::MyFlexSizerFrame(const wxChar *title, int x, int y ) sizerFlex->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_NONE); sizerCol2->Add(sizerFlex, 1, wxALL | wxEXPAND, 10); - sizerCol2->Add(new wxStaticText(this, -1, _T("Same with grow mode == \"all\"")), 0, wxCENTER | wxTOP, 20); + sizerCol2->Add(new wxStaticText(this, wxID_ANY, _T("Same with grow mode == \"all\"")), 0, wxCENTER | wxTOP, 20); sizerFlex = new wxFlexGridSizer(3, 3); InitFlexSizer(sizerFlex); sizerFlex->AddGrowableCol(1); @@ -419,14 +318,14 @@ MyFlexSizerFrame::MyFlexSizerFrame(const wxChar *title, int x, int y ) // ---------------------------------------------------------------------------- MySizerDialog::MySizerDialog(wxWindow *parent, const wxChar *title) - : wxDialog(parent, -1, wxString(title)) + : wxDialog(parent, wxID_ANY, wxString(title)) { // Begin with first hierarchy: a notebook at the top and // and OK button at the bottom. wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); - wxNotebook *notebook = new wxNotebook( this, -1 ); + wxNotebook *notebook = new wxNotebook( this, wxID_ANY ); wxNotebookSizer *nbs = new wxNotebookSizer( notebook ); topsizer->Add( nbs, 1, wxGROW ); @@ -434,23 +333,23 @@ MySizerDialog::MySizerDialog(wxWindow *parent, const wxChar *title) topsizer->Add( button, 0, wxALIGN_RIGHT | wxALL, 10 ); // First page: one big text ctrl - wxTextCtrl *multi = new wxTextCtrl( notebook, -1, _T("TextCtrl."), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); + wxTextCtrl *multi = new wxTextCtrl( notebook, wxID_ANY, _T("TextCtrl."), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); notebook->AddPage( multi, _T("Page One") ); // Second page: a text ctrl and a button - wxPanel *panel = new wxPanel( notebook, -1 ); + wxPanel *panel = new wxPanel( notebook, wxID_ANY ); notebook->AddPage( panel, _T("Page Two") ); wxSizer *panelsizer = new wxBoxSizer( wxVERTICAL ); - wxTextCtrl *text = new wxTextCtrl( panel, -1, _T("TextLine 1."), wxDefaultPosition, wxSize(250,-1) ); + wxTextCtrl *text = new wxTextCtrl( panel, wxID_ANY, _T("TextLine 1."), wxDefaultPosition, wxSize(250,-1) ); panelsizer->Add( text, 0, wxGROW|wxALL, 30 ); - text = new wxTextCtrl( panel, -1, _T("TextLine 2."), wxDefaultPosition, wxSize(250,-1) ); + text = new wxTextCtrl( panel, wxID_ANY, _T("TextLine 2."), wxDefaultPosition, wxSize(250,-1) ); panelsizer->Add( text, 0, wxGROW|wxALL, 30 ); - wxButton *button2 = new wxButton( panel, -1, _T("Hallo") ); + wxButton *button2 = new wxButton( panel, wxID_ANY, _T("Hallo") ); panelsizer->Add( button2, 0, wxALIGN_RIGHT | wxLEFT|wxRIGHT|wxBOTTOM, 30 ); - panel->SetAutoLayout( TRUE ); + panel->SetAutoLayout( true ); panel->SetSizer( panelsizer ); // Tell dialog to use sizer @@ -463,8 +362,8 @@ MySizerDialog::MySizerDialog(wxWindow *parent, const wxChar *title) // ---------------------------------------------------------------------------- // some simple macros to help make the sample code below more clear -#define TEXTCTRL(text) new wxTextCtrl(p, -1, _T(text)) -#define MLTEXTCTRL(text) new wxTextCtrl(p, -1, _T(text), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE) +#define TEXTCTRL(text) new wxTextCtrl(p, wxID_ANY, _T(text)) +#define MLTEXTCTRL(text) new wxTextCtrl(p, wxID_ANY, _T(text), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE) #define POS(r, c) wxGBPosition(r,c) #define SPAN(r, c) wxGBSpan(r,c) @@ -494,14 +393,14 @@ END_EVENT_TABLE() MyGridBagSizerFrame::MyGridBagSizerFrame(const wxChar *title, int x, int y ) - : wxFrame( NULL, -1, title, wxPoint(x, y) ) + : wxFrame( NULL, wxID_ANY, title, wxPoint(x, y) ) { - wxPanel* p = new wxPanel(this, -1); + wxPanel* p = new wxPanel(this, wxID_ANY); m_panel = p; m_gbs = new wxGridBagSizer(); - m_gbs->Add( new wxStaticText(p, -1, gbsDescription), + m_gbs->Add( new wxStaticText(p, wxID_ANY, gbsDescription), POS(0,0), SPAN(1, 7), wxALIGN_CENTER | wxALL, 5); @@ -529,7 +428,7 @@ MyGridBagSizerFrame::MyGridBagSizerFrame(const wxChar *title, int x, int y ) m_hideBtn = new wxButton(p, GBS_HIDE_BTN, _T("Hide this item -->")); m_gbs->Add(m_hideBtn, POS(12, 3)); - m_hideTxt = new wxTextCtrl(p, -1, _T("pos(12,4), size(150, -1)"), + m_hideTxt = new wxTextCtrl(p, wxID_ANY, _T("pos(12,4), size(150, -1)"), wxDefaultPosition, wxSize(150,-1)); m_gbs->Add( m_hideTxt, POS(12,4) ); diff --git a/samples/layout/layout.h b/samples/layout/layout.h index 5090116476..1a4923d4e9 100644 --- a/samples/layout/layout.h +++ b/samples/layout/layout.h @@ -23,7 +23,6 @@ class MyFrame : public wxFrame public: MyFrame(); - void TestConstraints(wxCommandEvent& event); void TestFlexSizers(wxCommandEvent& event); void TestNotebookSizers(wxCommandEvent& event); void TestGridBagSizer(wxCommandEvent& event); @@ -35,13 +34,6 @@ private: DECLARE_EVENT_TABLE() }; -// a frame using constraints for layout -class MyConstraintsFrame : public wxFrame -{ -public: - MyConstraintsFrame(const wxChar *title, int x, int y ); -}; - // a frame using flex sizers for layout class MyFlexSizerFrame : public wxFrame { @@ -94,7 +86,6 @@ enum { LAYOUT_QUIT = 100, LAYOUT_ABOUT, - LAYOUT_TEST_CONSTRAINTS, LAYOUT_TEST_SIZER, LAYOUT_TEST_NB_SIZER, LAYOUT_TEST_GB_SIZER -- 2.45.2