X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7bfc22f6147622df9625b8cda141383f2d8a919c..af01f1ba0d697c07173f436ab661b4c833258a91:/samples/controls/controls.cpp diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 8f984f0bd6..8c696f260e 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -34,7 +34,7 @@ #include "wx/tooltip.h" #endif -#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) +#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) #define USE_XPM #endif @@ -291,8 +291,8 @@ private: // other //---------------------------------------------------------------------- -static void SetControlClientData(const wxChar *name, - wxControlWithItems *control); +static void SetListboxClientData(const wxChar *name, wxListBox *control); +static void SetChoiceClientData(const wxChar *name, wxChoice *control); IMPLEMENT_APP(MyApp) @@ -326,8 +326,8 @@ bool MyApp::OnInit() y = 50; if ( argc == 3 ) { - wxSscanf(argv[1], "%d", &x); - wxSscanf(argv[2], "%d", &y); + wxSscanf(wxString(argv[1]), wxT("%d"), &x); + wxSscanf(wxString(argv[2]), wxT("%d"), &y); } // Create the main frame window @@ -487,7 +487,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) m_text = new wxTextCtrl(this, -1, "This is the log window.\n", wxPoint(0, 250), wxSize(100, 50), wxTE_MULTILINE); - m_text->SetBackgroundColour("wheat"); + m_text->SetBackgroundColour(wxT("wheat")); if ( 0 ) wxLog::AddTraceMask(_T("focus")); @@ -566,8 +566,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) wxPoint(10,90), wxSize(120,70), 5, choices, wxLB_SORT ); - SetControlClientData(wxT("listbox"), m_listbox); - SetControlClientData(wxT("listbox"), m_listboxSorted); + SetListboxClientData(wxT("listbox"), m_listbox); + SetListboxClientData(wxT("listbox"), m_listboxSorted); m_listbox->SetCursor(*wxCROSS_CURSOR); #if wxUSE_TOOLTIPS @@ -605,11 +605,11 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) m_choiceSorted = new wxChoice( panel, ID_CHOICE_SORTED, wxPoint(10,70), wxSize(120,-1), 5, choices, wxCB_SORT ); - SetControlClientData(wxT("choice"), m_choice); - SetControlClientData(wxT("choice"), m_choiceSorted); + SetChoiceClientData(wxT("choice"), m_choice); + SetChoiceClientData(wxT("choice"), m_choiceSorted); m_choice->SetSelection(2); - m_choice->SetBackgroundColour( "red" ); + m_choice->SetBackgroundColour( wxT("red") ); (void)new wxButton( panel, ID_CHOICE_SEL_NUM, "Select #&2", wxPoint(180,30), wxSize(140,30) ); (void)new wxButton( panel, ID_CHOICE_SEL_STR, "&Select 'This'", wxPoint(340,30), wxSize(140,30) ); (void)new wxButton( panel, ID_CHOICE_CLEAR, "&Clear", wxPoint(180,80), wxSize(140,30) ); @@ -876,16 +876,16 @@ void MyPanel::OnChangeColour(wxCommandEvent& WXUNUSED(event)) SetBackgroundColour(s_colOld); s_colOld = wxNullColour; - m_lbSelectThis->SetForegroundColour("red"); - m_lbSelectThis->SetBackgroundColour("white"); + m_lbSelectThis->SetForegroundColour(wxT("red")); + m_lbSelectThis->SetBackgroundColour(wxT("white")); } else { - s_colOld = wxColour("red"); - SetBackgroundColour("white"); + s_colOld = wxColour(wxT("red")); + SetBackgroundColour(wxT("white")); - m_lbSelectThis->SetForegroundColour("white"); - m_lbSelectThis->SetBackgroundColour("red"); + m_lbSelectThis->SetForegroundColour(wxT("white")); + m_lbSelectThis->SetBackgroundColour(wxT("red")); } m_lbSelectThis->Refresh(); @@ -943,8 +943,8 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event ) case ID_LISTBOX_ENABLE: { m_text->AppendText("Checkbox clicked.\n"); - wxCheckBox *cb = (wxCheckBox*)event.GetEventObject(); #if wxUSE_TOOLTIPS + wxCheckBox *cb = (wxCheckBox*)event.GetEventObject(); if (event.GetInt()) cb->SetToolTip( "Click to enable listbox" ); else @@ -1515,8 +1515,20 @@ void MyComboBox::OnKeyUp(wxKeyEvent& event) event.Skip(); } -static void SetControlClientData(const wxChar *name, - wxControlWithItems *control) +static void SetListboxClientData(const wxChar *name, wxListBox *control) +{ + size_t count = control->GetCount(); + for ( size_t n = 0; n < count; n++ ) + { + wxString s; + s.Printf(wxT("%s client data for '%s'"), + name, control->GetString(n).c_str()); + + control->SetClientObject(n, new wxStringClientData(s)); + } +} + +static void SetChoiceClientData(const wxChar *name, wxChoice *control) { size_t count = control->GetCount(); for ( size_t n = 0; n < count; n++ )