-MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
- wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) )
-{
- m_text = new wxTextCtrl( this, -1, "This is the log window.\n", wxPoint(0,50), wxSize(100,50), wxTE_MULTILINE );
-
- m_notebook = new wxNotebook( this, ID_NOTEBOOK, wxPoint(0,0), wxSize(200,150) );
-
- wxString choices[] =
- {
- "This",
- "is a",
- "wonderful",
- "example.",
- };
-
- wxPanel *panel = new wxPanel(m_notebook);
- m_listbox = new wxListBox( panel, ID_LISTBOX, wxPoint(10,10), wxSize(120,70), 4, choices );
- (void)new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(100,30) );
- (void)new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(300,30), wxSize(100,30) );
- (void)new wxButton( panel, ID_LISTBOX_CLEAR, "Clear", wxPoint(180,80), wxSize(100,30) );
- (void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(300,80), wxSize(100,30) );
- (void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) );
- m_notebook->AddPage(panel, "wxList");
-
- panel = new wxPanel(m_notebook);
- m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 4, choices );
- (void)new wxButton( panel, ID_CHOICE_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(100,30) );
- (void)new wxButton( panel, ID_CHOICE_SEL_STR, "Select 'This'", wxPoint(300,30), wxSize(100,30) );
- (void)new wxButton( panel, ID_CHOICE_CLEAR, "Clear", wxPoint(180,80), wxSize(100,30) );
- (void)new wxButton( panel, ID_CHOICE_APPEND, "Append 'Hi!'", wxPoint(300,80), wxSize(100,30) );
- (void)new wxButton( panel, ID_CHOICE_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) );
- m_notebook->AddPage(panel, "wxChoice");
-
- panel = new wxPanel(m_notebook);
- m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(10,10), wxSize(170,-1), 4, choices );
- (void)new wxButton( panel, ID_COMBO_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(100,30) );
- (void)new wxButton( panel, ID_COMBO_SEL_STR, "Select 'This'", wxPoint(300,30), wxSize(100,30) );
- (void)new wxButton( panel, ID_COMBO_CLEAR, "Clear", wxPoint(180,80), wxSize(100,30) );
- (void)new wxButton( panel, ID_COMBO_APPEND, "Append 'Hi!'", wxPoint(300,80), wxSize(100,30) );
- (void)new wxButton( panel, ID_COMBO_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) );
- m_notebook->AddPage(panel, "wxComboBox");
-
- wxTextCtrl *text = new wxTextCtrl( m_notebook, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(120,100), wxTE_MULTILINE );
- m_notebook->AddPage( text, "wxTextCtrl" );
-
- panel = new wxPanel(m_notebook);
- m_radio = new wxRadioBox( panel, ID_RADIOBOX, "This", wxPoint(10,10), wxSize(-1,-1), 4, choices );
- (void)new wxButton( panel, ID_RADIOBOX_SEL_NUM, "Select #2", wxPoint(200,30), wxSize(100,30) );
- (void)new wxButton( panel, ID_RADIOBOX_SEL_STR, "Select 'This'", wxPoint(200,80), wxSize(100,30) );
- m_notebook->AddPage(panel, "wxRadioBox");
-}
-
-void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) )
-{
- int x = 0;
- int y = 0;
- GetClientSize( &x, &y );
-
- if (m_notebook) m_notebook->SetSize( 2, 2, x-4, y*2/3-4 );
- if (m_text) m_text->SetSize( 2, y*2/3+2, x-4, y/3-4 );
+BEGIN_EVENT_TABLE(MyRadioBox, wxRadioBox)
+ EVT_SET_FOCUS(MyRadioBox::OnFocusGot)
+ EVT_KILL_FOCUS(MyRadioBox::OnFocusLost)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(MyChoice, wxChoice)
+ EVT_SET_FOCUS(MyChoice::OnFocusGot)
+ EVT_KILL_FOCUS(MyChoice::OnFocusLost)
+END_EVENT_TABLE()
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
+ : wxPanel( frame, wxID_ANY, wxPoint(x, y), wxSize(w, h) )
+{
+ m_listbox = NULL;
+ m_listboxSorted = NULL;
+#if wxUSE_CHOICE
+ m_choice = NULL;
+ m_choiceSorted = NULL;
+#endif // wxUSE_CHOICE
+ m_combo = NULL;
+ m_radio = NULL;
+#if wxUSE_GAUGE
+ m_gauge = NULL;
+ m_gaugeVert = NULL;
+#endif // wxUSE_GAUGE
+#if wxUSE_SLIDER
+ m_slider = NULL;
+#endif // wxUSE_SLIDER
+ m_fontButton = NULL;
+ m_lbSelectNum = NULL;
+ m_lbSelectThis = NULL;
+#if wxUSE_SPINBTN
+ m_spinbutton = NULL;
+#if wxUSE_PROGRESSDLG
+ m_btnProgress = NULL;
+#endif // wxUSE_PROGRESSDLG
+#endif // wxUSE_SPINBTN
+#if wxUSE_SPINCTRL
+ m_spinctrl = NULL;
+#endif // wxUSE_SPINCTRL
+ m_spintext = NULL;
+ m_checkbox = NULL;
+ m_text = NULL;
+ m_book = NULL;
+ m_label = NULL;
+
+ m_text = new wxTextCtrl(this, wxID_ANY, wxT("This is the log window.\n"),
+ wxPoint(0, 250), wxSize(100, 50), wxTE_MULTILINE);
+
+ m_logTargetOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_text));
+
+ m_book = new wxBookCtrl(this, ID_BOOK);
+
+ wxString choices[] =
+ {
+ wxT("This"),
+ wxT("is"),
+ wxT("one of my long and"),
+ wxT("wonderful"),
+ wxT("examples.")
+ };
+
+#ifndef __WXMSW__
+ // image ids
+ enum
+ {
+ Image_List,
+ Image_Choice,
+ Image_Combo,
+ Image_Text,
+ Image_Radio,
+#if wxUSE_GAUGE
+ Image_Gauge,
+#endif // wxUSE_GAUGE
+ Image_Max
+ };
+
+ // fill the image list
+ wxBitmap bmp(list_xpm);
+
+ wxImageList *imagelist = new wxImageList(bmp.GetWidth(), bmp.GetHeight());
+
+ imagelist-> Add( bmp );
+ imagelist-> Add( wxBitmap( choice_xpm ));
+ imagelist-> Add( wxBitmap( combo_xpm ));
+ imagelist-> Add( wxBitmap( text_xpm ));
+ imagelist-> Add( wxBitmap( radio_xpm ));
+#if wxUSE_GAUGE
+ imagelist-> Add( wxBitmap( gauge_xpm ));
+#endif // wxUSE_GAUGE
+ m_book->SetImageList(imagelist);
+#else
+ // load images from resources
+ enum
+ {
+ Image_List,
+ Image_Choice,
+ Image_Combo,
+ Image_Text,
+ Image_Radio,
+#if wxUSE_GAUGE
+ Image_Gauge,
+#endif // wxUSE_GAUGE
+ Image_Max
+ };
+ wxImageList *imagelist = new wxImageList(16, 16, false, Image_Max);
+
+ static const wxChar *s_iconNames[Image_Max] =
+ {
+ wxT("list")
+ , wxT("choice")
+ , wxT("combo")
+ , wxT("text")
+ , wxT("radio")
+#if wxUSE_GAUGE
+ , wxT("gauge")
+#endif // wxUSE_GAUGE
+ };
+
+ for ( size_t n = 0; n < Image_Max; n++ )
+ {
+ wxBitmap bmp(s_iconNames[n]);
+ if ( !bmp.IsOk() || (imagelist->Add(bmp) == -1) )
+ {
+ wxLogWarning(wxT("Couldn't load the image '%s' for the book control page %d."),
+ s_iconNames[n], n);
+ }
+ }
+
+ m_book->SetImageList(imagelist);
+#endif
+
+ // ------------------------------------------------------------------------
+ // listbox page
+ // ------------------------------------------------------------------------
+ wxPanel *panel = new wxPanel(m_book);
+ m_listbox = new wxListBox( panel, ID_LISTBOX,
+ wxPoint(10,10), wxSize(120,70),
+ 5, choices, wxLB_MULTIPLE | wxLB_ALWAYS_SB | wxHSCROLL );
+ m_listboxSorted = new wxListBox( panel, ID_LISTBOX_SORTED,
+ wxPoint(10,90), wxSize(120,70),
+ 3, choices, wxLB_SORT );
+
+ SetListboxClientData(wxT("listbox"), m_listbox);
+ SetListboxClientData(wxT("listbox"), m_listboxSorted);
+
+ m_listbox->SetCursor(*wxCROSS_CURSOR);
+
+ m_lbSelectNum = new wxButton( panel, ID_LISTBOX_SEL_NUM, wxT("Select #&2"), wxPoint(180,30), wxSize(140,30) );
+ m_lbSelectThis = new wxButton( panel, ID_LISTBOX_SEL_STR, wxT("&Select 'This'"), wxPoint(340,30), wxSize(140,30) );
+ (void)new wxButton( panel, ID_LISTBOX_CLEAR, wxT("&Clear"), wxPoint(180,80), wxSize(140,30) );
+ (void)new MyButton( panel, ID_LISTBOX_APPEND, wxT("&Append 'Hi!'"), wxPoint(340,80), wxSize(140,30) );
+ (void)new wxButton( panel, ID_LISTBOX_DELETE, wxT("D&elete selected item"), wxPoint(180,130), wxSize(140,30) );
+ wxButton *button = new MyButton( panel, ID_LISTBOX_FONT, wxT("Set &Italic font"), wxPoint(340,130), wxSize(140,30) );
+
+ button->SetDefault();
+
+ m_checkbox = new wxCheckBox( panel, ID_LISTBOX_ENABLE, wxT("&Disable"), wxPoint(20,170) );
+ m_checkbox->SetValue(false);
+ button->MoveAfterInTabOrder(m_checkbox);
+ (void)new wxCheckBox( panel, ID_CHANGE_COLOUR, wxT("&Toggle colour"),
+ wxPoint(110,170) );
+ panel->SetCursor(wxCursor(wxCURSOR_HAND));
+ m_book->AddPage(panel, wxT("wxListBox"), true, Image_List);
+
+ // ------------------------------------------------------------------------
+ // choice page
+ // ------------------------------------------------------------------------
+#if wxUSE_CHOICE
+ panel = new wxPanel(m_book);
+ m_choice = new MyChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,wxDefaultCoord), 5, choices );
+ m_choiceSorted = new MyChoice( panel, ID_CHOICE_SORTED, wxPoint(10,70), wxSize(120,wxDefaultCoord),
+ 5, choices, wxCB_SORT );
+
+ SetChoiceClientData(wxT("choice"), m_choice);
+ SetChoiceClientData(wxT("choice"), m_choiceSorted);
+
+ m_choice->SetSelection(2);
+ (void)new wxButton( panel, ID_CHOICE_SEL_NUM, wxT("Select #&2"), wxPoint(180,30), wxSize(140,30) );
+ (void)new wxButton( panel, ID_CHOICE_SEL_STR, wxT("&Select 'This'"), wxPoint(340,30), wxSize(140,30) );
+ (void)new wxButton( panel, ID_CHOICE_CLEAR, wxT("&Clear"), wxPoint(180,80), wxSize(140,30) );
+ (void)new wxButton( panel, ID_CHOICE_APPEND, wxT("&Append 'Hi!'"), wxPoint(340,80), wxSize(140,30) );
+ (void)new wxButton( panel, ID_CHOICE_DELETE, wxT("D&elete selected item"), wxPoint(180,130), wxSize(140,30) );
+ (void)new wxButton( panel, ID_CHOICE_FONT, wxT("Set &Italic font"), wxPoint(340,130), wxSize(140,30) );
+ (void)new wxCheckBox( panel, ID_CHOICE_ENABLE, wxT("&Disable"), wxPoint(20,130), wxSize(140,30) );
+
+ m_book->AddPage(panel, wxT("wxChoice"), false, Image_Choice);
+#endif // wxUSE_CHOICE
+
+ // ------------------------------------------------------------------------
+ // combo page
+ // ------------------------------------------------------------------------
+ panel = new wxPanel(m_book);
+ (void)new wxStaticBox( panel, wxID_ANY, wxT("&Box around combobox"),
+ wxPoint(5, 5), wxSize(150, 100));
+ m_combo = new MyComboBox( panel, ID_COMBO, wxT("This"),
+ wxPoint(20,25), wxSize(120, wxDefaultCoord),
+ 5, choices,
+ wxTE_PROCESS_ENTER);
+
+ (void)new wxButton( panel, ID_COMBO_SEL_NUM, wxT("Select #&2"), wxPoint(180,30), wxSize(140,30) );
+ (void)new wxButton( panel, ID_COMBO_SEL_STR, wxT("&Select 'This'"), wxPoint(340,30), wxSize(140,30) );
+ (void)new wxButton( panel, ID_COMBO_CLEAR, wxT("&Clear"), wxPoint(180,80), wxSize(140,30) );
+ (void)new wxButton( panel, ID_COMBO_APPEND, wxT("&Append 'Hi!'"), wxPoint(340,80), wxSize(140,30) );
+ (void)new wxButton( panel, ID_COMBO_DELETE, wxT("D&elete selected item"), wxPoint(180,130), wxSize(140,30) );
+ (void)new wxButton( panel, ID_COMBO_FONT, wxT("Set &Italic font"), wxPoint(340,130), wxSize(140,30) );
+ (void)new wxButton( panel, ID_COMBO_SET_TEXT, wxT("Set 'Hi!' at #2"), wxPoint(340,180), wxSize(140,30) );
+ (void)new wxCheckBox( panel, ID_COMBO_ENABLE, wxT("&Disable"), wxPoint(20,130), wxSize(140,30) );
+ m_book->AddPage(panel, wxT("wxComboBox"), false, Image_Combo);
+
+ // ------------------------------------------------------------------------
+ // radio box
+ // ------------------------------------------------------------------------
+ wxString choices2[] =
+ {
+ wxT("First"), wxT("Second"),
+ /* "Third",
+ "Fourth", "Fifth", "Sixth",
+ "Seventh", "Eighth", "Nineth", "Tenth" */
+ };
+
+ panel = new wxPanel(m_book);
+ wxGridBagSizer* radio_page_sizer = new wxGridBagSizer(5, 5);
+
+ m_radio = new wxRadioBox(panel, ID_RADIOBOX, wxT("T&his"),
+ wxPoint(10,10), wxDefaultSize,
+ WXSIZEOF(choices), choices,
+ 1, wxRA_SPECIFY_COLS );
+ MyRadioBox* mybox = new MyRadioBox(panel, ID_RADIOBOX2, wxT("&That"),
+ wxPoint(10,160), wxDefaultSize,
+ WXSIZEOF(choices2), choices2,
+ 1, wxRA_SPECIFY_ROWS );
+
+ radio_page_sizer->Add( m_radio, wxGBPosition(0,0), wxGBSpan(2,1) );
+ radio_page_sizer->Add( mybox, wxGBPosition(2,0), wxGBSpan(2,1) );
+
+#if wxUSE_HELP
+ for (unsigned int item = 0; item < WXSIZEOF(choices); ++item)
+ m_radio->SetItemHelpText( item, wxString::Format( wxT("Help text for \"%s\""),
+ choices[item].c_str() ) );
+
+ // erase help text for the second item
+ m_radio->SetItemHelpText( 1, wxT("") );
+ // set default help text for control
+ m_radio->SetHelpText( wxT("Default helptext for wxRadioBox") );
+#endif // wxUSE_HELP
+
+ wxButton* select_two = new wxButton ( panel, ID_RADIOBOX_SEL_NUM, wxT("Select #&2") );
+ wxButton* select_this = new wxButton ( panel, ID_RADIOBOX_SEL_STR, wxT("&Select 'This'") );
+ m_fontButton = new wxButton ( panel, ID_SET_FONT, wxT("Set &more Italic font") );
+ wxButton* set_italic = new wxButton ( panel, ID_RADIOBOX_FONT, wxT("Set &Italic font") );
+ wxCheckBox* disable_cb = new wxCheckBox( panel, ID_RADIOBOX_ENABLE, wxT("&Disable") );
+ wxRadioButton *rb = new wxRadioButton( panel, ID_RADIOBUTTON_1, wxT("Radiobutton1"),
+ wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
+ wxRadioButton *rb2 = new wxRadioButton( panel, ID_RADIOBUTTON_2, wxT("&Radiobutton2"),
+ wxDefaultPosition, wxDefaultSize );
+ rb->SetValue( false );
+
+ radio_page_sizer->Add( select_two, wxGBPosition(0, 1), wxDefaultSpan, wxALL , 10 );
+ radio_page_sizer->Add( select_this, wxGBPosition(1, 1), wxDefaultSpan, wxALL , 10 );
+ radio_page_sizer->Add( m_fontButton, wxGBPosition(0, 2), wxDefaultSpan, wxALL , 10 );
+ radio_page_sizer->Add( set_italic, wxGBPosition(1, 2), wxDefaultSpan, wxALL , 10 );
+ radio_page_sizer->Add( disable_cb, wxGBPosition(2, 2), wxDefaultSpan, wxLEFT | wxRIGHT, 10 );
+ radio_page_sizer->Add( rb, wxGBPosition(3, 1), wxDefaultSpan, wxLEFT | wxRIGHT, 10 );
+ radio_page_sizer->Add( rb2, wxGBPosition(3, 2), wxDefaultSpan, wxLEFT | wxRIGHT, 10 );
+
+ panel->SetSizer( radio_page_sizer );
+
+ m_book->AddPage(panel, wxT("wxRadioBox"), false, Image_Radio);
+
+ // ------------------------------------------------------------------------
+ // gauge and slider
+ // ------------------------------------------------------------------------
+
+#if wxUSE_SLIDER && wxUSE_GAUGE
+ panel = new wxPanel(m_book);
+
+ wxBoxSizer *gauge_page_vsizer = new wxBoxSizer( wxVERTICAL );
+
+ wxBoxSizer *gauge_page_first_row_sizer = new wxBoxSizer( wxHORIZONTAL );
+
+ wxStaticBoxSizer *gauge_sizer = new wxStaticBoxSizer( wxHORIZONTAL, panel, wxT("&wxGauge and wxSlider") );
+ gauge_page_first_row_sizer->Add( gauge_sizer, 0, wxALL, 5 );
+ wxBoxSizer *sz = new wxBoxSizer( wxVERTICAL );
+ gauge_sizer->Add( sz );
+ m_gauge = new wxGauge( panel, wxID_ANY, 200, wxDefaultPosition, wxSize(155, 30), wxGA_HORIZONTAL|wxNO_BORDER );
+ sz->Add( m_gauge, 0, wxALL, 10 );
+ m_slider = new wxSlider( panel, ID_SLIDER, 0, 0, 200,
+ wxDefaultPosition, wxSize(155,wxDefaultCoord),
+ wxSL_AUTOTICKS | wxSL_LABELS);
+ m_slider->SetTickFreq(40);
+ sz->Add( m_slider, 0, wxALL, 10 );
+
+ m_gaugeVert = new wxGauge( panel, wxID_ANY, 100,
+ wxDefaultPosition, wxSize(wxDefaultCoord, 90),
+ wxGA_VERTICAL | wxGA_SMOOTH | wxNO_BORDER );
+ gauge_sizer->Add( m_gaugeVert, 0, wxALL, 10 );
+
+
+
+ wxStaticBox *sb = new wxStaticBox( panel, wxID_ANY, wxT("&Explanation"),
+ wxDefaultPosition, wxDefaultSize ); //, wxALIGN_CENTER );
+ wxStaticBoxSizer *wrapping_sizer = new wxStaticBoxSizer( sb, wxVERTICAL );
+ gauge_page_first_row_sizer->Add( wrapping_sizer, 0, wxALL, 5 );
+
+#ifdef __WXMOTIF__
+ // No wrapping text in wxStaticText yet :-(
+ m_wrappingText = new wxStaticText( panel, wxID_ANY,
+ wxT("Drag the slider!"),
+ wxPoint(250,30),
+ wxSize(240, wxDefaultCoord)
+ );
+#else
+ m_wrappingText = new wxStaticText( panel, wxID_ANY,
+ wxT("In order see the gauge (aka progress bar) ")
+ wxT("control do something you have to drag the ")
+ wxT("handle of the slider to the right.")
+ wxT("\n\n")
+ wxT("This is also supposed to demonstrate how ")
+ wxT("to use static controls with line wrapping."),
+ wxDefaultPosition,
+ wxSize(240, wxDefaultCoord)
+ );
+#endif
+ wrapping_sizer->Add( m_wrappingText );
+
+ wxStaticBoxSizer *non_wrapping_sizer = new wxStaticBoxSizer( wxVERTICAL, panel, wxT("Non-wrapping") );
+ gauge_page_first_row_sizer->Add( non_wrapping_sizer, 0, wxALL, 5 );
+
+ m_nonWrappingText = new wxStaticText( panel, wxID_ANY,
+ wxT("This static text has two lines.\nThey do not wrap."),
+ wxDefaultPosition,
+ wxDefaultSize
+ );
+ non_wrapping_sizer->Add( m_nonWrappingText );
+
+ gauge_page_vsizer->Add( gauge_page_first_row_sizer, 1 );
+ wxBoxSizer *gauge_page_second_row_sizer = new wxBoxSizer( wxHORIZONTAL );
+
+
+ int initialSpinValue = -5;
+ wxString s;
+ s << initialSpinValue;
+ m_spintext = new wxTextCtrl( panel, wxID_ANY, s );
+ gauge_page_second_row_sizer->Add( m_spintext, 0, wxALL, 5 );
+
+#if wxUSE_SPINBTN
+ m_spinbutton = new wxSpinButton( panel, ID_SPIN );
+ m_spinbutton->SetRange(-40,30);
+ m_spinbutton->SetValue(initialSpinValue);
+ gauge_page_second_row_sizer->Add( m_spinbutton, 0, wxALL, 5 );
+#endif // wxUSE_SPINBTN
+
+#if wxUSE_SPINCTRL
+ m_spinctrl = new wxSpinCtrl( panel, ID_SPINCTRL, wxEmptyString );
+ m_spinctrl->SetRange(-10,30);
+ m_spinctrl->SetValue(15);
+ gauge_page_second_row_sizer->Add( m_spinctrl, 0, wxALL, 5 );
+#endif // wxUSE_SPINCTRL
+
+#if wxUSE_SPINBTN
+#if wxUSE_PROGRESSDLG
+ m_btnProgress = new wxButton( panel, ID_BTNPROGRESS, wxT("&Show progress dialog") );
+ gauge_page_second_row_sizer->Add( m_btnProgress, 0, wxALL, 5 );
+#endif // wxUSE_PROGRESSDLG
+#endif // wxUSE_SPINBTN
+
+ wxButton* newTextButton = new wxButton( panel, ID_BTNNEWTEXT, wxT("New text"));
+ gauge_page_second_row_sizer->Add( newTextButton, 0, wxALL, 5 );
+
+ gauge_page_vsizer->Add(gauge_page_second_row_sizer, 1);
+ panel->SetSizer( gauge_page_vsizer );
+
+ m_book->AddPage(panel, wxT("wxGauge"), false, Image_Gauge);
+#endif // wxUSE_SLIDER && wxUSE_GAUGE
+
+
+ // ------------------------------------------------------------------------
+ // wxBitmapXXX
+ // ------------------------------------------------------------------------
+
+ panel = new wxPanel(m_book);
+
+#if !defined(__WXMOTIF__) // wxStaticBitmap not working under Motif yet.
+ wxIcon icon = wxArtProvider::GetIcon(wxART_INFORMATION);
+ (void) new wxStaticBitmap( panel, wxID_ANY, icon, wxPoint(10, 10) );
+
+ // VZ: don't leak memory
+ // bmpStatic = new wxStaticBitmap(panel, wxID_ANY, wxNullIcon, wxPoint(50, 10));
+ // bmpStatic->SetIcon(wxArtProvider::GetIcon(wxART_QUESTION));
+#endif // !Motif
+
+ wxBitmap bitmap( 100, 100 );
+ wxMemoryDC dc;
+ dc.SelectObject( bitmap );
+ dc.SetBackground(*wxGREEN);
+ dc.SetPen(*wxRED_PEN);
+ dc.Clear();
+ dc.DrawEllipse(5, 5, 90, 90);
+ dc.DrawText(wxT("Bitmap"), 30, 40);
+ dc.SelectObject( wxNullBitmap );
+
+ wxPanel *panel2 = new wxPanel(panel, -1, wxPoint(100, 0), wxSize(100, 200));
+ (void)new wxBitmapButton(panel2, ID_BITMAP_BTN, bitmap, wxPoint(0, 20));
+ (void)new wxToggleButton(panel2, ID_BITMAP_BTN_ENABLE,
+ wxT("Enable/disable &bitmap"), wxPoint(0, 140));
+
+#if defined(__WXMSW__) || defined(__WXMOTIF__)
+ // test for masked bitmap display
+ bitmap = wxBitmap(wxT("test2.bmp"), wxBITMAP_TYPE_BMP);
+ if (bitmap.IsOk())
+ {
+ bitmap.SetMask(new wxMask(bitmap, *wxBLUE));
+
+ (void)new wxStaticBitmap(panel, wxID_ANY, bitmap, wxPoint(300, 120));
+ }
+#endif
+
+ wxBitmap bmp1(wxArtProvider::GetBitmap(wxART_INFORMATION)),
+ bmp2(wxArtProvider::GetBitmap(wxART_WARNING)),
+ bmp3(wxArtProvider::GetBitmap(wxART_QUESTION));
+ wxBitmapButton *bmpBtn = new wxBitmapButton
+ (
+ panel, wxID_ANY,
+ bmp1,
+ wxPoint(30, 70)
+ );
+
+ bmpBtn->SetBitmapSelected(bmp2);
+ bmpBtn->SetBitmapFocus(bmp3);
+
+ (void)new wxToggleButton(panel, ID_BUTTON_LABEL,
+ wxT("&Toggle label"), wxPoint(250, 20));
+
+ m_label = new wxStaticText(panel, wxID_ANY, wxT("Label with some long text"),
+ wxPoint(250, 60), wxDefaultSize,
+ wxALIGN_RIGHT /*| wxST_NO_AUTORESIZE*/);
+ m_label->SetForegroundColour( *wxBLUE );
+
+ m_book->AddPage(panel, wxT("wxBitmapXXX"));
+
+ // ------------------------------------------------------------------------
+ // sizer page
+ // ------------------------------------------------------------------------
+
+ panel = new wxPanel(m_book);
+
+ wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
+
+ wxStaticBoxSizer *csizer =
+ new wxStaticBoxSizer (new wxStaticBox (panel, wxID_ANY, wxT("Show Buttons")), wxHORIZONTAL );
+
+ wxCheckBox *check1, *check2, *check3, *check4, *check14, *checkBig;
+ check1 = new wxCheckBox (panel, ID_SIZER_CHECK1, wxT("1"));
+ check1->SetValue (true);
+ csizer->Add (check1);
+ check2 = new wxCheckBox (panel, ID_SIZER_CHECK2, wxT("2"));
+ check2->SetValue (true);
+ csizer->Add (check2);
+ check3 = new wxCheckBox (panel, ID_SIZER_CHECK3, wxT("3"));
+ check3->SetValue (true);
+ csizer->Add (check3);
+ check4 = new wxCheckBox (panel, ID_SIZER_CHECK4, wxT("4"));
+ check4->SetValue (true);
+ csizer->Add (check4);
+ check14 = new wxCheckBox (panel, ID_SIZER_CHECK14, wxT("1-4"));
+ check14->SetValue (true);
+ csizer->Add (check14);
+ checkBig = new wxCheckBox (panel, ID_SIZER_CHECKBIG, wxT("Big"));
+ checkBig->SetValue (true);
+ csizer->Add (checkBig);
+
+ sizer->Add (csizer);
+
+ m_hsizer = new wxBoxSizer( wxHORIZONTAL );
+
+ m_buttonSizer = new wxBoxSizer (wxVERTICAL);
+
+ m_sizerBtn1 = new wxButton(panel, wxID_ANY, wxT("Test Button &1 (tab order 1)") );
+ m_buttonSizer->Add( m_sizerBtn1, 0, wxALL, 10 );
+ m_sizerBtn2 = new wxButton(panel, wxID_ANY, wxT("Test Button &2 (tab order 3)") );
+ m_buttonSizer->Add( m_sizerBtn2, 0, wxALL, 10 );
+ m_sizerBtn3 = new wxButton(panel, wxID_ANY, wxT("Test Button &3 (tab order 2)") );
+ m_buttonSizer->Add( m_sizerBtn3, 0, wxALL, 10 );
+ m_sizerBtn4 = new wxButton(panel, wxID_ANY, wxT("Test Button &4 (tab order 4)") );
+ m_buttonSizer->Add( m_sizerBtn4, 0, wxALL, 10 );
+
+ m_sizerBtn3->MoveBeforeInTabOrder(m_sizerBtn2);
+
+ m_hsizer->Add (m_buttonSizer);
+ m_hsizer->Add( 20,20, 1 );
+ m_bigBtn = new wxButton(panel, wxID_ANY, wxT("Multiline\nbutton") );
+ m_hsizer->Add( m_bigBtn , 3, wxGROW|wxALL, 10 );
+
+ sizer->Add (m_hsizer, 1, wxGROW);
+
+ panel->SetSizer( sizer );
+
+ m_book->AddPage(panel, wxT("wxSizer"));
+
+ // set the sizer for the panel itself
+ sizer = new wxBoxSizer(wxVERTICAL);
+ sizer->Add(m_book, wxSizerFlags().Border().Expand());
+ sizer->Add(m_text, wxSizerFlags(1).Border().Expand());
+ SetSizer(sizer);
+
+#if wxUSE_TOOLTIPS
+ SetAllToolTips();
+#endif // wxUSE_TOOLTIPS