X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/56f33b5ecd90f52c0929b8adf8c05dd4fbf1c35b..9fd47c4847543f8d16d262c6c17c9777aa7bfa4f:/samples/combo/combo.cpp diff --git a/samples/combo/combo.cpp b/samples/combo/combo.cpp index 6b5ced6c6e..3ce2870d17 100644 --- a/samples/combo/combo.cpp +++ b/samples/combo/combo.cpp @@ -228,8 +228,9 @@ public: int item, int flags ) const { - // If item is selected or even, use the default rendering. - if ( GetVListBoxComboPopup()->IsCurrent((size_t)item) || + // If item is selected or even, or we are painting the + // combo control itself, use the default rendering. + if ( (flags & (wxODCB_PAINTING_CONTROL|wxODCB_PAINTING_SELECTED)) || (item & 1) == 0 ) { wxOwnerDrawnComboBox::OnDrawBackground(dc,rect,item,flags); @@ -557,6 +558,11 @@ public: } } + // Implement empty DoSetPopupControl to prevent assertion failure. + virtual void DoSetPopupControl(wxComboPopup* WXUNUSED(popup)) + { + } + private: void Init() { @@ -621,7 +627,7 @@ MyFrame::MyFrame(const wxString& title) wxComboCtrl* cc; - wxGenericComboControl* gcc; + wxGenericComboCtrl* gcc; wxOwnerDrawnComboBox* odc; // Create common strings array @@ -694,8 +700,11 @@ MyFrame::MyFrame(const wxString& title) odc->SetSelection(0); - odc->SetButtonPosition(-2, // width adjustment - -6, // height adjustment + + // Use button size that is slightly smaller than the default. + wxSize butSize = odc->GetButtonSize(); + odc->SetButtonPosition(butSize.x - 2, // button width + butSize.y - 6, // button height wxLEFT, // side 2 // horizontal spacing ); @@ -736,9 +745,9 @@ MyFrame::MyFrame(const wxString& title) // Tree Ctrl wxComboCtrl // - // Note that we test that wxGenericComboControl works - gcc = new wxGenericComboControl(panel,wxID_ANY,wxEmptyString, - wxDefaultPosition, wxDefaultSize); + // Note that we test that wxGenericComboCtrl works + gcc = new wxGenericComboCtrl(panel,wxID_ANY,wxEmptyString, + wxDefaultPosition, wxDefaultSize); // Set popup interface right away, otherwise some of the calls // below may fail @@ -764,8 +773,8 @@ MyFrame::MyFrame(const wxString& title) gcc->SetValue(wxT("Subitem 05")); // Move button to left - it makes more sense for a tree ctrl - gcc->SetButtonPosition(0, // width adjustment - 0, // height adjustment + gcc->SetButtonPosition(-1, // button width + -1, // button height wxLEFT, // side 0 // horizontal spacing ); @@ -808,7 +817,7 @@ MyFrame::MyFrame(const wxString& title) wxImage imgPressed(wxT("dropbutp.png")); wxImage imgHover(wxT("dropbuth.png")); - if ( imgNormal.Ok() && imgPressed.Ok() && imgHover.Ok() ) + if ( imgNormal.IsOk() && imgPressed.IsOk() && imgHover.IsOk() ) { wxBitmap bmpNormal(imgNormal); wxBitmap bmpPressed(imgPressed);