]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/odcombo.cpp
Fix for scroll position being changed when partial layout is done
[wxWidgets.git] / src / generic / odcombo.cpp
index ee33e004824f7404f28e7fdd43a187442763a86c..353790fe1955f4424543b4e6a128d2bc7288d22e 100644 (file)
@@ -163,7 +163,7 @@ wxCoord wxVListBoxComboPopup::OnMeasureItem(size_t n) const
 {
     wxOwnerDrawnComboBox* combo = (wxOwnerDrawnComboBox*) m_combo;
 
-    wxASSERT_MSG( combo->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)),
+    wxASSERT_MSG( wxDynamicCast(combo, wxOwnerDrawnComboBox),
                   wxT("you must subclass wxVListBoxComboPopup for drawing and measuring methods") );
 
     wxCoord h = combo->OnMeasureItem(n);
@@ -176,7 +176,7 @@ wxCoord wxVListBoxComboPopup::OnMeasureItemWidth(size_t n) const
 {
     wxOwnerDrawnComboBox* combo = (wxOwnerDrawnComboBox*) m_combo;
 
-    wxASSERT_MSG( combo->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)),
+    wxASSERT_MSG( wxDynamicCast(combo, wxOwnerDrawnComboBox),
                   wxT("you must subclass wxVListBoxComboPopup for drawing and measuring methods") );
 
     return combo->OnMeasureItemWidth(n);
@@ -189,7 +189,7 @@ void wxVListBoxComboPopup::OnDrawBg( wxDC& dc,
 {
     wxOwnerDrawnComboBox* combo = (wxOwnerDrawnComboBox*) m_combo;
 
-    wxASSERT_MSG( combo->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)),
+    wxASSERT_MSG( wxDynamicCast(combo, wxOwnerDrawnComboBox),
                   wxT("you must subclass wxVListBoxComboPopup for drawing and measuring methods") );
 
     if ( IsCurrent((size_t)item) && !(flags & wxODCB_PAINTING_CONTROL) )
@@ -208,7 +208,7 @@ void wxVListBoxComboPopup::OnDrawItem( wxDC& dc, const wxRect& rect, int item, i
 {
     wxOwnerDrawnComboBox* combo = (wxOwnerDrawnComboBox*) m_combo;
 
-    wxASSERT_MSG( combo->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)),
+    wxASSERT_MSG( wxDynamicCast(combo, wxOwnerDrawnComboBox),
                   wxT("you must subclass wxVListBoxComboPopup for drawing and measuring methods") );
 
     combo->OnDrawItem(dc,rect,item,flags);
@@ -375,7 +375,7 @@ bool wxVListBoxComboPopup::HandleKey( int keycode, bool saturate, wxChar keychar
 
     // The m_combo->SetValue() call above sets m_value to the index of this
     // string. But if there are more identical string, the index is of the
-    // first occurence, which may be wrong, so set the index explicitly here,
+    // first occurrence, which may be wrong, so set the index explicitly here,
     // _after_ the SetValue() call.
     m_value = value;
 
@@ -545,7 +545,7 @@ int wxVListBoxComboPopup::Append(const wxString& item)
 
         for ( i=0; i<strings.GetCount(); i++ )
         {
-            if ( item.CmpNoCase(strings.Item(i)) < 0 )
+            if ( item.CmpNoCase(strings.Item(i)) <= 0 )
             {
                 pos = (int)i;
                 break;
@@ -642,6 +642,16 @@ int wxVListBoxComboPopup::FindString(const wxString& s, bool bCase) const
     return m_strings.Index(s, bCase);
 }
 
+bool wxVListBoxComboPopup::FindItem(const wxString& item, wxString* trueItem)
+{
+    int idx = m_strings.Index(item, false);
+    if ( idx == wxNOT_FOUND )
+        return false;
+    if ( trueItem != NULL )
+        *trueItem = m_strings[idx];
+    return true;
+}
+
 unsigned int wxVListBoxComboPopup::GetCount() const
 {
     return m_strings.GetCount();
@@ -855,7 +865,7 @@ void wxVListBoxComboPopup::Populate( const wxArrayString& choices )
 
     // Find initial selection
     wxString strValue = m_combo->GetValue();
-    if ( strValue.length() )
+    if ( !strValue.empty() )
         m_value = m_strings.Index(strValue);
 }
 
@@ -867,21 +877,6 @@ void wxVListBoxComboPopup::Populate( const wxArrayString& choices )
 BEGIN_EVENT_TABLE(wxOwnerDrawnComboBox, wxComboCtrl)
 END_EVENT_TABLE()
 
-
-#if wxUSE_EXTENDED_RTTI
-IMPLEMENT_DYNAMIC_CLASS2_XTI(wxOwnerDrawnComboBox, wxComboCtrl, wxControlWithItems, "wx/odcombo.h")
-
-wxBEGIN_PROPERTIES_TABLE(wxOwnerDrawnComboBox)
-wxEND_PROPERTIES_TABLE()
-
-wxBEGIN_HANDLERS_TABLE(wxOwnerDrawnComboBox)
-wxEND_HANDLERS_TABLE()
-
-wxCONSTRUCTOR_5( wxOwnerDrawnComboBox , wxWindow* , Parent , wxWindowID , Id , wxString , Value , wxPoint , Position , wxSize , Size )
-#else
-IMPLEMENT_DYNAMIC_CLASS2(wxOwnerDrawnComboBox, wxComboCtrl, wxControlWithItems)
-#endif
-
 void wxOwnerDrawnComboBox::Init()
 {
 }
@@ -907,7 +902,6 @@ wxOwnerDrawnComboBox::wxOwnerDrawnComboBox(wxWindow *parent,
                                            long style,
                                            const wxValidator& validator,
                                            const wxString& name)
-    : wxComboCtrl()
 {
     Init();