X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/457e6c54a28bc20cf347ba921755d7d5b296aa2a..89e60357485b3da6e7ed7995fbcf8722d3df7ef4:/samples/controls/controls.cpp diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 91d614bbbf..7255bc38bc 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -111,6 +111,7 @@ public: void OnEnableAll(wxCommandEvent& event); void OnChangeColour(wxCommandEvent& event); void OnTestButton(wxCommandEvent& event); + void OnBmpButton(wxCommandEvent& event); wxListBox *m_listbox, *m_listboxSorted; @@ -263,9 +264,8 @@ bool MyApp::OnInit() frame->SetMenuBar(menu_bar); frame->Show(TRUE); - frame->SetCursor(wxCursor(wxCURSOR_HAND)); - frame->GetPanel()->m_notebook->SetSelection(6); + //frame->GetPanel()->m_notebook->SetSelection(6); SetTopWindow(frame); @@ -328,6 +328,7 @@ const int ID_SPINCTRL = 185; const int ID_BUTTON_TEST1 = 190; const int ID_BUTTON_TEST2 = 191; +const int ID_BITMAP_BTN = 192; const int ID_CHANGE_COLOUR = 200; @@ -383,6 +384,7 @@ EVT_BUTTON (ID_BUTTON_LABEL, MyPanel::OnUpdateLabel) EVT_CHECKBOX (ID_CHANGE_COLOUR, MyPanel::OnChangeColour) EVT_BUTTON (ID_BUTTON_TEST1, MyPanel::OnTestButton) EVT_BUTTON (ID_BUTTON_TEST2, MyPanel::OnTestButton) +EVT_BUTTON (ID_BITMAP_BTN, MyPanel::OnBmpButton) END_EVENT_TABLE() MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) @@ -395,7 +397,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) wxPoint(0, 250), wxSize(100, 50), wxTE_MULTILINE); m_text->SetBackgroundColour("wheat"); - wxLog::AddTraceMask(_T("focus")); + if ( 0 ) + wxLog::AddTraceMask(_T("focus")); m_logTargetOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_text)); m_notebook = new wxNotebook(this, ID_NOTEBOOK); @@ -501,6 +504,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) #endif // wxUSE_TOOLTIPS (void)new wxCheckBox( panel, ID_CHANGE_COLOUR, "&Toggle colour", wxPoint(110,170) ); + panel->SetCursor(wxCursor(wxCURSOR_HAND)); m_notebook->AddPage(panel, "wxListBox", TRUE, Image_List); panel = new wxPanel(m_notebook); @@ -612,7 +616,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) panel = new wxPanel(m_notebook); -#ifndef __WXMOTIF__ // wxStaticBitmap not working under Motif yet. MB +#if !defined(__WXMOTIF__) && !defined(__WIN16__) // wxStaticBitmap not working under Motif yet; and icons not allowed under WIN16. wxIcon icon = wxTheApp->GetStdIcon(wxICON_INFORMATION); wxStaticBitmap *bmpStatic = new wxStaticBitmap(panel, -1, icon, wxPoint(10, 10)); @@ -630,13 +634,17 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) dc.DrawText("Bitmap", 30, 40); dc.SelectObject( wxNullBitmap ); - (void)new wxBitmapButton(panel, -1, bitmap, wxPoint(100, 20)); + (void)new wxBitmapButton(panel, ID_BITMAP_BTN, bitmap, wxPoint(100, 20)); -#if 1 +#ifdef __WXMSW__ // test for masked bitmap display bitmap = wxBitmap("test2.bmp", wxBITMAP_TYPE_BMP); - bitmap.SetMask(new wxMask(bitmap, *wxBLUE)); - (void)new wxStaticBitmap /* wxBitmapButton */ (panel, -1, bitmap, wxPoint(300, 120)); + if (bitmap.Ok()) + { + bitmap.SetMask(new wxMask(bitmap, *wxBLUE)); + + (void)new wxStaticBitmap /* wxBitmapButton */ (panel, -1, bitmap, wxPoint(300, 120)); + } #endif wxBitmap bmp1(wxTheApp->GetStdIcon(wxICON_INFORMATION)), @@ -741,6 +749,11 @@ void MyPanel::OnTestButton(wxCommandEvent& event) event.GetId() == ID_BUTTON_TEST1 ? _T('1') : _T('2')); } +void MyPanel::OnBmpButton(wxCommandEvent& event) +{ + wxLogMessage(_T("Bitmap button clicked.")); +} + void MyPanel::OnChangeColour(wxCommandEvent& WXUNUSED(event)) { static wxColour s_colOld; @@ -829,6 +842,7 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event ) m_lbSelectThis->Enable( event.GetInt() == 0 ); m_lbSelectNum->Enable( event.GetInt() == 0 ); m_listboxSorted->Enable( event.GetInt() == 0 ); + FindWindow(ID_CHANGE_COLOUR)->Enable( event.GetInt() == 0 ); break; } case ID_LISTBOX_SEL_NUM: @@ -1135,6 +1149,7 @@ void MyPanel::OnShowProgress( wxCommandEvent& WXUNUSED(event) ) max, // range this, // parent wxPD_CAN_ABORT | + wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | @@ -1142,16 +1157,16 @@ void MyPanel::OnShowProgress( wxCommandEvent& WXUNUSED(event) ) bool cont = TRUE; - for ( int i = 0; i < max && cont; i++ ) + for ( int i = 0; i <= max && cont; i++ ) { wxSleep(1); - if ( i == max - 1 ) + if ( i == max ) { cont = dialog.Update(i, "That's all, folks!"); } else if ( i == max / 2 ) { - cont = dialog.Update(i, "Only a half left!"); + cont = dialog.Update(i, "Only a half left (very long message)!"); } else { @@ -1215,12 +1230,10 @@ void MyFrame::OnQuit (wxCommandEvent& WXUNUSED(event) ) void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) { - wxBeginBusyCursor(); + wxBusyCursor bc; wxMessageDialog dialog(this, "This is a control sample", "About Controls", wxOK ); dialog.ShowModal(); - - wxEndBusyCursor(); } void MyFrame::OnClearLog(wxCommandEvent& WXUNUSED(event))