]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/datavcmn.cpp
Fix several bugs in generic text entry hints implementation.
[wxWidgets.git] / src / common / datavcmn.cpp
index 1b2d20cdce980f0f7c248dc8e90f33791e3a3ea2..6c9423bc386e71364c5e462aaded2056fd256393 100644 (file)
@@ -235,6 +235,36 @@ bool wxDataViewModel::Cleared()
     return ret;
 }
 
+bool wxDataViewModel::BeforeReset()
+{
+    bool ret = true;
+
+    wxDataViewModelNotifiers::iterator iter;
+    for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter)
+    {
+        wxDataViewModelNotifier* notifier = *iter;
+        if (!notifier->BeforeReset())
+            ret = false;
+    }
+
+    return ret;
+}
+
+bool wxDataViewModel::AfterReset()
+{
+    bool ret = true;
+
+    wxDataViewModelNotifiers::iterator iter;
+    for (iter = m_notifiers.begin(); iter != m_notifiers.end(); ++iter)
+    {
+        wxDataViewModelNotifier* notifier = *iter;
+        if (!notifier->AfterReset())
+            ret = false;
+    }
+
+    return ret;
+}
+
 void wxDataViewModel::Resort()
 {
     wxDataViewModelNotifiers::iterator iter;
@@ -345,6 +375,8 @@ wxDataViewIndexListModel::wxDataViewIndexListModel( unsigned int initial_size )
 
 void wxDataViewIndexListModel::Reset( unsigned int new_size )
 {
+    /* wxDataViewModel:: */ BeforeReset();
+    
     m_hash.Clear();
 
     // IDs are ordered until an item gets deleted or inserted
@@ -357,7 +389,7 @@ void wxDataViewIndexListModel::Reset( unsigned int new_size )
 
     m_nextFreeID = new_size + 1;
 
-    /* wxDataViewModel:: */ Cleared();
+    /* wxDataViewModel:: */ AfterReset();
 }
 
 void wxDataViewIndexListModel::RowPrepended()
@@ -499,9 +531,11 @@ wxDataViewVirtualListModel::wxDataViewVirtualListModel( unsigned int initial_siz
 
 void wxDataViewVirtualListModel::Reset( unsigned int new_size )
 {
-    m_size = new_size;
+    /* wxDataViewModel:: */ BeforeReset();
 
-    /* wxDataViewModel:: */ Cleared();
+    m_size = new_size;
+    
+    /* wxDataViewModel:: */ AfterReset();
 }
 
 void wxDataViewVirtualListModel::RowPrepended()
@@ -994,6 +1028,22 @@ void wxDataViewCtrlBase::ExpandAncestors( const wxDataViewItem & item )
     }
 }
 
+wxDataViewItem wxDataViewCtrlBase::GetCurrentItem() const
+{
+    return HasFlag(wxDV_MULTIPLE) ? DoGetCurrentItem()
+                                  : GetSelection();
+}
+
+void wxDataViewCtrlBase::SetCurrentItem(const wxDataViewItem& item)
+{
+    wxCHECK_RET( item.IsOk(), "Can't make current an invalid item." );
+
+    if ( HasFlag(wxDV_MULTIPLE) )
+        DoSetCurrentItem(item);
+    else
+        Select(item);
+}
+
 wxDataViewColumn *
 wxDataViewCtrlBase::AppendTextColumn( const wxString &label, unsigned int model_column,
                             wxDataViewCellMode mode, int width, wxAlignment align, int flags )
@@ -1391,14 +1441,9 @@ wxDataViewChoiceRenderer::wxDataViewChoiceRenderer( const wxArrayString& choices
 
 wxControl* wxDataViewChoiceRenderer::CreateEditorCtrl( wxWindow *parent, wxRect labelRect, const wxVariant &value )
 {
-    wxString s = value;
-    wxSize size = labelRect.GetSize();
-#ifdef __WXMAC__
-    size = wxSize( wxMax(70,labelRect.width ), -1 );
-#endif
-    wxChoice *c = new wxChoice( parent, wxID_ANY, labelRect.GetTopLeft(), size, m_choices );
+    wxChoice* c = new wxChoice(parent, wxID_ANY, labelRect.GetTopLeft(), wxDefaultSize, m_choices );
+    c->Move(labelRect.GetRight() - c->GetRect().width, wxDefaultCoord);
     c->SetStringSelection( value.GetString() );
-
     return c;
 }
 
@@ -1605,10 +1650,6 @@ wxDataViewListCtrl::wxDataViewListCtrl( wxWindow *parent, wxWindowID id,
            const wxValidator& validator )
 {
     Create( parent, id, pos, size, style, validator );
-
-    wxDataViewListStore *store = new wxDataViewListStore;
-    AssociateModel( store );
-    store->DecRef();
 }
 
 wxDataViewListCtrl::~wxDataViewListCtrl()
@@ -1620,7 +1661,14 @@ bool wxDataViewListCtrl::Create( wxWindow *parent, wxWindowID id,
            const wxPoint& pos, const wxSize& size, long style,
            const wxValidator& validator )
 {
-    return wxDataViewCtrl::Create( parent, id, pos, size, style, validator );
+    if ( !wxDataViewCtrl::Create( parent, id, pos, size, style, validator ) )
+        return false;
+
+    wxDataViewListStore *store = new wxDataViewListStore;
+    AssociateModel( store );
+    store->DecRef();
+
+    return true;
 }
 
 bool wxDataViewListCtrl::AppendColumn( wxDataViewColumn *column, const wxString &varianttype )