X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1a8b677e3b0b588eb85ba61d9928cfe4069b14a3..59c516a34ad204cf096798b9176425655aaa0d18:/samples/controls/controls.cpp diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 6db4496179..a3ec62f705 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -59,9 +59,6 @@ #define EVT_TOGGLEBUTTON EVT_CHECKBOX #endif -#include "wx/hyperlink.h" -#include "wx/utils.h" - //---------------------------------------------------------------------- // class definitions //---------------------------------------------------------------------- @@ -124,10 +121,6 @@ public: void OnSizerCheck (wxCommandEvent &event); -#if wxUSE_HYPERLINKCTRL - void OnHyperlink(wxHyperlinkEvent& event); -#endif - wxListBox *m_listbox, *m_listboxSorted; #if wxUSE_CHOICE @@ -176,10 +169,6 @@ public: wxBoxSizer *m_hsizer; wxButton *m_bigBtn; -#if wxUSE_HYPERLINKCTRL - wxHyperlinkCtrl *m_hyperlink; -#endif - private: wxLog *m_logTargetOld; @@ -569,9 +558,6 @@ EVT_BUTTON (ID_BUTTON_TEST1, MyPanel::OnTestButton) EVT_BUTTON (ID_BUTTON_TEST2, MyPanel::OnTestButton) EVT_BUTTON (ID_BITMAP_BTN, MyPanel::OnBmpButton) EVT_TOGGLEBUTTON(ID_BITMAP_BTN_ENABLE, MyPanel::OnBmpButtonToggle) -#if wxUSE_HYPERLINKCTRL -EVT_HYPERLINK (ID_HYPERLINK, MyPanel::OnHyperlink) -#endif EVT_CHECKBOX (ID_SIZER_CHECK1, MyPanel::OnSizerCheck) EVT_CHECKBOX (ID_SIZER_CHECK2, MyPanel::OnSizerCheck) @@ -953,7 +939,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) #if wxUSE_SPINCTRL m_spinctrl = new wxSpinCtrl( panel, ID_SPINCTRL, wxEmptyString, wxPoint(200, 160), wxSize(80, wxDefaultCoord) ); - //m_spinctrl->SetRange(10,30); + m_spinctrl->SetRange(-10,30); m_spinctrl->SetValue(15); #endif // wxUSE_SPINCTRL @@ -974,9 +960,9 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) wxBitmap bitmap( 100, 100 ); wxMemoryDC dc; - dc.SetBackground(*wxGREEN); dc.SelectObject( bitmap ); - dc.SetPen(*wxGREEN_PEN); + dc.SetBackground(*wxGREEN); + dc.SetPen(*wxRED_PEN); dc.Clear(); dc.DrawEllipse(5, 5, 90, 90); dc.DrawText(_T("Bitmap"), 30, 40); @@ -1020,26 +1006,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) m_book->AddPage(panel, _T("wxBitmapXXX")); - // hyperlink -#if wxUSE_HYPERLINKCTRL - panel = new wxPanel(m_book); - m_hyperlink = new wxHyperlinkCtrl(panel, ID_HYPERLINK, - _T("Click here to go to Google!"), - _T("http://www.google.com"), - wxPoint(20, 20)); - m_hyperlink->SetVisitedColour(m_hyperlink->GetNormalColour()); - m_hyperlink->SetFont(*wxITALIC_FONT); - m_hyperlink->SetBackgroundColour(*wxWHITE); - - // this hyperlink will automatically call wxLaunchDefaultBrowser on user's clicks - new wxHyperlinkCtrl(panel, wxID_ANY, wxT("http://www.test.com"), - wxEmptyString, wxPoint(20, 50)); - - m_book->AddPage(panel, _T("wxHyperlinkCtrl")); -#endif - // sizer - panel = new wxPanel(m_book); panel->SetAutoLayout( true ); @@ -1218,8 +1185,6 @@ void MyPanel::OnChangeColour(wxCommandEvent& WXUNUSED(event)) void MyPanel::OnListBox( wxCommandEvent &event ) { -// GetParent()->Move(100, 100); - if (event.GetInt() == -1) { m_text->AppendText( _T("ListBox has no selections anymore\n") ); @@ -1232,9 +1197,15 @@ void MyPanel::OnListBox( wxCommandEvent &event ) m_text->AppendText( _T("ListBox event selection string is: '") ); m_text->AppendText( event.GetString() ); m_text->AppendText( _T("'\n") ); - m_text->AppendText( _T("ListBox control selection string is: '") ); - m_text->AppendText( listbox->GetStringSelection() ); - m_text->AppendText( _T("'\n") ); + + // can't use GetStringSelection() with multiple selections, there could be + // more than one of them + if ( !listbox->HasFlag(wxLB_MULTIPLE) ) + { + m_text->AppendText( _T("ListBox control selection string is: '") ); + m_text->AppendText( listbox->GetStringSelection() ); + m_text->AppendText( _T("'\n") ); + } wxStringClientData *obj = ((wxStringClientData *)event.GetClientObject()); m_text->AppendText( _T("ListBox event client data string is: '") ); @@ -1245,7 +1216,7 @@ void MyPanel::OnListBox( wxCommandEvent &event ) m_text->AppendText( _T("'\n") ); m_text->AppendText( _T("ListBox control client data string is: '") ); - obj = (wxStringClientData *)listbox->GetClientObject(listbox->GetSelection()); + obj = (wxStringClientData *)listbox->GetClientObject(event.GetInt()); if (obj) m_text->AppendText( obj->GetData() ); else @@ -1712,15 +1683,6 @@ void MyPanel::OnShowProgress( wxCommandEvent& WXUNUSED(event) ) #endif // wxUSE_PROGRESSDLG #endif // wxUSE_SPINBTN -#if wxUSE_HYPERLINKCTRL -void MyPanel::OnHyperlink(wxHyperlinkEvent& event) -{ - wxLogMessage(wxT("Clicked on hyperlink with url '%s'"), event.GetURL().c_str()); - if (!wxLaunchDefaultBrowser(event.GetURL())) - wxMessageBox(_T("Could not launch the default browser!")); -} -#endif //wxUSE_HYPERLINK - void MyPanel::OnSizerCheck( wxCommandEvent &event) { switch (event.GetId ()) { @@ -1785,11 +1747,8 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) END_EVENT_TABLE() MyFrame::MyFrame(const wxChar *title, int x, int y) + : wxFrame(NULL, wxID_ANY, title, wxPoint(x, y), wxSize(700, 450)) { - // give it a context help button - SetExtraStyle(wxFRAME_EX_CONTEXTHELP); - wxFrame::Create(NULL, wxID_ANY, title, wxPoint(x, y), wxSize(500, 430), - wxDEFAULT_FRAME_STYLE & ~ (wxMINIMIZE_BOX | wxMAXIMIZE_BOX)); SetHelpText( _T("Controls sample demonstrating various widgets") ); // Give it an icon @@ -1835,8 +1794,6 @@ MyFrame::MyFrame(const wxChar *title, int x, int y) #endif // wxUSE_STATUSBAR m_panel = new MyPanel( this, 10, 10, 300, 100 ); - - SetSizeHints( 500, 425 ); } void MyFrame::OnQuit (wxCommandEvent& WXUNUSED(event) )