- Added wxUIActionSimulator (Steven Lamerton, GSoC 2010 project).
- wxAUI: support auto-orientable toolbars (wsu).
- Added wxDataViewCtrl::Set/GetCurrentItem().
+- Added possibility to disable individual wxDataViewCtrl items (Neno Ganchev).
- wxHTML: render in RTL order inside RTL window (Richard Bullington-McGuire).
- wxRibbon: added EVT_RIBBONGALLERY_CLICKED event (John Roberts).
- Add support for CP-866 encoding to wxEncodingConverter (madnut).
return false;
}
+ // Override this if you want to disable specific items
+ virtual bool IsEnabled(const wxDataViewItem &WXUNUSED(item),
+ unsigned int WXUNUSED(col)) const
+ {
+ return true;
+ }
+
// define hierachy
virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0;
virtual bool IsContainer( const wxDataViewItem &item ) const = 0;
return false;
}
+ virtual bool IsEnabledByRow(unsigned int WXUNUSED(row),
+ unsigned int WXUNUSED(col)) const
+ {
+ return true;
+ }
+
// helper methods provided by list models only
virtual unsigned GetRow( const wxDataViewItem &item ) const = 0;
return GetAttrByRow( GetRow(item), col, attr );
}
+ virtual bool IsEnabled(const wxDataViewItem &item, unsigned int col) const
+ {
+ return IsEnabledByRow( GetRow(item), col );
+ }
+
virtual bool IsListModel() const { return true; }
};
virtual void SetAttr(const wxDataViewItemAttr& WXUNUSED(attr)) { }
+ virtual void SetEnabled(bool WXUNUSED(enabled)) { }
+
wxString GetVariantType() const { return m_variantType; }
// helper that calls SetValue and SetAttr:
virtual void SetAttr(const wxDataViewItemAttr& attr) { m_attr = attr; }
const wxDataViewItemAttr& GetAttr() const { return m_attr; }
+ // Store the enabled state of the item so that it can be accessed from
+ // Render() via GetEnabled() if needed.
+ virtual void SetEnabled(bool enabled) { m_enabled = enabled; }
+ bool GetEnabled() const { return m_enabled; }
+
// Implementation only from now on
private:
wxDataViewItemAttr m_attr;
+ bool m_enabled;
wxDECLARE_NO_COPY_CLASS(wxDataViewCustomRendererBase);
};
// called to ensure that the given attribute will be used for rendering the
// next cell (which had been already associated with this renderer before)
virtual void OSXApplyAttr(const wxDataViewItemAttr& attr);
+
+ // called to set the state of the next cell to be rendered
+ virtual void OSXApplyEnabled(bool enabled);
#endif // Cocoa
private:
virtual bool GetAttr(const wxDataViewItem& item, unsigned int col,
wxDataViewItemAttr& attr) const;
+ /**
+ Override this to indicate that the item should be disabled.
+
+ Disabled items are displayed differently (e.g. grayed out) and cannot
+ be interacted with.
+
+ The base class version always returns @true, thus making all items
+ enabled by default.
+
+ @param item
+ The item whose enabled status is requested.
+ @param col
+ The column of the item whose enabled status is requested.
+ @return
+ @true if this item should be enabled, @false otherwise.
+
+ @note Currently disabling items is fully implemented only for the
+ native control implementation in wxOSX/Cocoa. This feature is
+ partially supported in the generic version but not in wxGTK or
+ wxOSX/Carbon native implementations.
+
+ @since 2.9.2
+ */
+ virtual bool IsEnabled(const wxDataViewItem &item,
+ unsigned int col) const;
+
/**
Override this so the control can query the child items of an item.
Returns the number of items.
virtual bool GetAttrByRow(unsigned int row, unsigned int col,
wxDataViewItemAttr& attr) const;
+ /**
+ Override this if you want to disable specific items.
+
+ The base class version always returns @true, thus making all items
+ enabled by default.
+
+ @param row
+ The row of the item whose enabled status is requested.
+ @param col
+ The column of the item whose enabled status is requested.
+ @return
+ @true if the item at this row and column should be enabled,
+ @false otherwise.
+
+ @note See wxDataViewModel::IsEnabled() for the current status of
+ support for disabling the items under different platforms.
+
+ @since 2.9.2
+ */
+ virtual bool IsEnabledByRow(unsigned int row,
+ unsigned int col) const;
+
/**
Returns the number of items (i.e. rows) in the list.
*/
wxDefaultSize, style );
m_ctrl[2] = lc;
+ MyListStoreDerivedModel* page2_model = new MyListStoreDerivedModel();
+ lc->AssociateModel(page2_model);
+ page2_model->DecRef();
+
lc->AppendToggleColumn( "Toggle" );
lc->AppendTextColumn( "Text" );
lc->AppendProgressColumn( "Progress" );
return false;
}
+bool MyMusicTreeModel::IsEnabled( const wxDataViewItem &item,
+ unsigned int col ) const
+{
+ wxASSERT(item.IsOk());
+
+ MyMusicTreeModelNode *node = (MyMusicTreeModelNode*) item.GetID();
+
+ // disable Beethoven's ratings, his pieces can only be good
+ return !(col == 3 && node->m_artist.EndsWith("Beethoven"));
+}
+
wxDataViewItem MyMusicTreeModel::GetParent( const wxDataViewItem &item ) const
{
// the invisible root node has no parent
return false;
}
+
+
+// ----------------------------------------------------------------------------
+// MyListStoreDerivedModel
+// ----------------------------------------------------------------------------
+
+bool MyListStoreDerivedModel::IsEnabledByRow(unsigned int row, unsigned int col) const
+{
+ // disabled the last two checkboxes
+ return !(col == 0 && 8 <= row && row <= 9);
+}
virtual bool SetValue( const wxVariant &variant,
const wxDataViewItem &item, unsigned int col );
+ virtual bool IsEnabled( const wxDataViewItem &item,
+ unsigned int col ) const;
+
virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const;
virtual bool IsContainer( const wxDataViewItem &item ) const;
virtual unsigned int GetChildren( const wxDataViewItem &parent,
wxIcon m_icon[2];
};
+// ----------------------------------------------------------------------------
+// MyListStoreDerivedModel
+// ----------------------------------------------------------------------------
+
+class MyListStoreDerivedModel : public wxDataViewListStore
+{
+public:
+ virtual bool IsEnabledByRow(unsigned int row, unsigned int col) const;
+};
wxDataViewItemAttr attr;
model->GetAttr(item, column, attr);
SetAttr(attr);
+
+ SetEnabled(model->IsEnabled(item, column));
}
int flags = 0;
if (m_toggle)
flags |= wxCONTROL_CHECKED;
- if (GetMode() != wxDATAVIEW_CELL_ACTIVATABLE)
+ if (GetMode() != wxDATAVIEW_CELL_ACTIVATABLE ||
+ GetEnabled() == false)
flags |= wxCONTROL_DISABLED;
// check boxes we draw must always have the same, standard size (if it's
const wxDataViewItem & item,
unsigned int col)
{
- model->ChangeValue(!valueOld.GetBool(), item, col);
+ if (model->IsEnabled(item, col))
+ {
+ model->ChangeValue(!valueOld.GetBool(), item, col);
+ }
}
wxSize wxDataViewToggleRenderer::GetSize() const
model->GetAttr(dvItem, colIdx, attr);
renderer->OSXApplyAttr(attr);
+ // set the state (enabled/disabled) of the item
+ renderer->OSXApplyEnabled(model->IsEnabled(dvItem, colIdx));
+
// and finally do draw it
renderer->MacRender();
}
[(id)cell setTextColor:colText];
}
+void wxDataViewRenderer::OSXApplyEnabled(bool enabled)
+{
+ [GetNativeData()->GetItemCell() setEnabled:enabled];
+}
+
IMPLEMENT_ABSTRACT_CLASS(wxDataViewRenderer,wxDataViewRendererBase)
// ---------------------------------------------------------