/////////////////////////////////////////////////////////////////////////////
// Name: wx/mac/carbon/dataview.h
// Purpose: wxDataViewCtrl native implementation header
-// Author:
+// Author:
// Id: $Id$
// Copyright: (c) 2007
// Licence: wxWindows licence
// constructors / destructor
//
wxDataViewCustomRenderer(wxString const& varianttype=wxT("string"), wxDataViewCellMode mode=wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
-
+
virtual ~wxDataViewCustomRenderer();
void RenderText( const wxString &text, int xoffset, wxRect cell, wxDC *dc, int state );
//
// methods handling user actions
-//
+//
virtual bool Render(wxRect cell, wxDC* dc, int state) = 0;
virtual bool Activate( wxRect WXUNUSED(cell),
wxDataViewModel *WXUNUSED(model),
- const wxDataViewItem & WXUNUSED(item),
+ const wxDataViewItem & WXUNUSED(item),
unsigned int WXUNUSED(col) )
{ return false; }
virtual bool LeftClick( wxPoint WXUNUSED(cursor),
wxRect WXUNUSED(cell),
wxDataViewModel *WXUNUSED(model),
- const wxDataViewItem & WXUNUSED(item),
+ const wxDataViewItem & WXUNUSED(item),
unsigned int WXUNUSED(col) )
{ return false; }
-
+
virtual bool StartDrag( wxPoint WXUNUSED(cursor),
wxRect WXUNUSED(cell),
wxDataViewModel *WXUNUSED(model),
- const wxDataViewItem & WXUNUSED(item),
+ const wxDataViewItem & WXUNUSED(item),
unsigned int WXUNUSED(col) )
{ return false; }
-
+
//
// device context handling
//
{
public:
wxDataViewIconTextRenderer(wxString const& varianttype = wxT("wxDataViewIconText"), wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int align=wxDVR_DEFAULT_ALIGNMENT);
-
+
//
// inherited functions from wxDataViewRenderer
//
virtual bool Render();
-
+
//
// implementation
//
virtual WXDataBrowserPropertyType GetPropertyType() const;
-
+
protected:
private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewIconTextRenderer)
class WXDLLIMPEXP_ADV wxDataViewColumn: public wxDataViewColumnBase
{
public:
-//
-// constructors / destructor
-//
- wxDataViewColumn(wxString const& title, wxDataViewRenderer* renderer, unsigned int model_column, int width=80, wxAlignment align=wxALIGN_CENTER,
- int flags=wxDATAVIEW_COL_RESIZABLE);
- wxDataViewColumn(wxBitmap const& bitmap, wxDataViewRenderer* renderer, unsigned int model_column, int width=80, wxAlignment align=wxALIGN_CENTER,
- int flags=wxDATAVIEW_COL_RESIZABLE);
-
-//
-// inherited methods from wxDataViewColumnBase
-//
- virtual wxAlignment GetAlignment() const
- {
- return this->m_alignment;
- }
- virtual int GetFlags() const
- {
- return this->m_flags;
- }
- virtual int GetMaxWidth() const
- {
- return this->m_maxWidth;
- }
- virtual int GetMinWidth() const
- {
- return this->m_minWidth;
- }
- virtual wxString GetTitle() const
- {
- return this->m_title;
- }
- virtual int GetWidth() const
- {
- return this->m_width;
- }
-
- virtual bool IsHidden() const
- {
- return false; // not implemented
- }
- virtual bool IsReorderable() const
- {
- return ((this->m_flags & wxDATAVIEW_COL_REORDERABLE) != 0);
- }
- virtual bool IsResizeable() const
- {
- return ((this->m_flags & wxDATAVIEW_COL_RESIZABLE) != 0);
- }
- virtual bool IsSortable() const
- {
- return ((this->m_flags & wxDATAVIEW_COL_SORTABLE) != 0);
- }
- virtual bool IsSortOrderAscending() const
- {
- return this->m_ascending;
- }
-
- virtual void SetAlignment(wxAlignment align);
- virtual void SetBitmap (wxBitmap const& bitmap);
- virtual void SetFlags (int flags);
- virtual void SetHidden(bool WXUNUSED(hidden))
- {
- }
- virtual void SetMaxWidth (int maxWidth);
- virtual void SetMinWidth (int minWidth);
- virtual void SetReorderable(bool reorderable);
- virtual void SetResizeable (bool resizeable);
- virtual void SetSortable (bool sortable);
- virtual void SetSortOrder (bool ascending);
- virtual void SetTitle (wxString const& title);
- virtual void SetWidth (int width);
-
-//
-// implementation
-//
- WXDataBrowserPropertyID GetPropertyID() const
- {
- return this->m_propertyID;
- }
-
- void SetPropertyID(WXDataBrowserPropertyID newID)
- {
- this->m_propertyID = newID;
- }
- void SetWidthVariable(int NewWidth)
- {
- this->m_width = NewWidth;
- }
+ // constructors / destructor
+ wxDataViewColumn(const wxString& title,
+ wxDataViewRenderer* renderer,
+ unsigned int model_column,
+ int width = wxDVC_DEFAULT_WIDTH,
+ wxAlignment align = wxALIGN_CENTER,
+ int flags = wxDATAVIEW_COL_RESIZABLE)
+ : wxDataViewColumnBase(renderer, model_column),
+ m_title(title)
+ {
+ Init(width, align, flags);
+ }
+
+ wxDataViewColumn(const wxBitmap& bitmap,
+ wxDataViewRenderer* renderer,
+ unsigned int model_column,
+ int width = wxDVC_DEFAULT_WIDTH,
+ wxAlignment align = wxALIGN_CENTER,
+ int flags = wxDATAVIEW_COL_RESIZABLE)
+ : wxDataViewColumnBase(bitmap, renderer, model_column)
+ {
+ Init(width, align, flags);
+ }
+
+ // implement wxHeaderColumnBase pure virtual methods
+ virtual wxAlignment GetAlignment() const { return m_alignment; }
+ virtual int GetFlags() const { return m_flags; }
+ virtual int GetMaxWidth() const { return m_maxWidth; }
+ virtual int GetMinWidth() const { return m_minWidth; }
+ virtual wxString GetTitle() const { return m_title; }
+ virtual int GetWidth() const { return m_width; }
+ virtual bool IsHidden() const { return false; } // TODO
+ virtual bool IsSortOrderAscending() const { return m_ascending; }
+ virtual bool IsSortKey() const;
+
+ virtual void SetAlignment(wxAlignment align);
+ virtual void SetBitmap (wxBitmap const& bitmap);
+ virtual void SetFlags (int flags) { SetIndividualFlags(flags); }
+ virtual void SetHidden(bool WXUNUSED(hidden)) { } // TODO
+ virtual void SetMaxWidth (int maxWidth);
+ virtual void SetMinWidth (int minWidth);
+ virtual void SetReorderable(bool reorderable);
+ virtual void SetResizeable (bool resizeable);
+ virtual void SetSortable (bool sortable);
+ virtual void SetSortOrder (bool ascending);
+ virtual void SetTitle (wxString const& title);
+ virtual void SetWidth (int width);
+ virtual void SetAsSortKey(bool sort = true);
+
+ // implementation only
+ WXDataBrowserPropertyID GetPropertyID() const
+ {
+ return m_propertyID;
+ }
+
+ void SetPropertyID(WXDataBrowserPropertyID newID)
+ {
+ m_propertyID = newID;
+ }
+ void SetWidthVariable(int NewWidth)
+ {
+ m_width = NewWidth;
+ }
-protected:
private:
-//
-// variables
-//
- bool m_ascending; // sorting order
-
- WXDataBrowserPropertyID m_propertyID; // each column is identified by its unique property ID (NOT by the column index)
-
- int m_flags; // flags for the column
- int m_maxWidth; // maximum width for the column
- int m_minWidth; // minimum width for the column
- int m_width; // column width
-
- wxAlignment m_alignment; // column header alignment
-
- wxString m_title; // column title
-
- // wxWidget internal stuff:
- DECLARE_DYNAMIC_CLASS_NO_COPY(wxDataViewColumn)
+ // common part of all ctors
+ void Init(int width, wxAlignment align, int flags)
+ {
+ m_ascending = true;
+ m_flags = flags & ~wxDATAVIEW_COL_HIDDEN; // TODO
+ m_maxWidth = 30000;
+ m_minWidth = 0;
+ m_width = width >= 0 ? width : wxDVC_DEFAULT_WIDTH;
+ m_alignment = align;
+ }
+
+ bool m_ascending; // sorting order
+
+ // each column is identified by its unique property ID (NOT by the column
+ // index)
+ WXDataBrowserPropertyID m_propertyID;
+
+ int m_flags; // flags for the column
+ int m_maxWidth; // maximum width for the column
+ int m_minWidth; // minimum width for the column
+ int m_width; // column width
+
+ wxAlignment m_alignment; // column header alignment
+
+ wxString m_title; // column title
};
// ---------------------------------------------------------
{
this->Init();
}
- wxDataViewCtrl(wxWindow *parent, wxWindowID id, wxPoint const& pos = wxDefaultPosition, wxSize const& size = wxDefaultSize, long style = 0,
- wxValidator const& validator = wxDefaultValidator)
+ wxDataViewCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0,
+ const wxValidator& validator = wxDefaultValidator)
{
this->Init();
this->Create(parent, id, pos, size, style, validator );
~wxDataViewCtrl();
// explicit control creation
- bool Create(wxWindow *parent, wxWindowID id, wxPoint const& pos=wxDefaultPosition, wxSize const& size=wxDefaultSize, long style=0,
- wxValidator const& validator=wxDefaultValidator);
+ bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos=wxDefaultPosition, const wxSize& size=wxDefaultSize, long style=0,
+ const wxValidator& validator=wxDefaultValidator);
virtual wxControl* GetMainWindow() // should disappear as it is not of any use for the native implementation
{
return this;
}
-
+
// inherited methods from 'wxDataViewCtrlBase':
virtual bool AssociateModel(wxDataViewModel* model);
virtual bool AppendColumn(wxDataViewColumn* columnPtr);
virtual bool PrependColumn(wxDataViewColumn* columnPtr);
- virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *col );
-
+ virtual bool InsertColumn(unsigned int pos, wxDataViewColumn *col);
+
virtual bool ClearColumns();
virtual bool DeleteColumn(wxDataViewColumn* columnPtr);
virtual wxDataViewColumn* GetColumn(unsigned int pos) const;
virtual unsigned int GetColumnCount() const;
- virtual int GetColumnPosition(wxDataViewColumn const* columnPtr) const;
+ virtual int GetColumnPosition(const wxDataViewColumn* columnPtr) const;
+
+ virtual void Collapse( const wxDataViewItem& item);
+ virtual void EnsureVisible(const wxDataViewItem& item, const wxDataViewColumn* columnPtr=NULL);
+ virtual void Expand(const wxDataViewItem& item);
+ virtual bool IsExpanded(const wxDataViewItem & item) const;
- virtual void Collapse(wxDataViewItem const& item);
- virtual void EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr=NULL);
- virtual void Expand(wxDataViewItem const& item);
-
virtual wxDataViewColumn* GetSortingColumn() const;
virtual unsigned int GetCount() const;
- virtual wxRect GetItemRect(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) const;
+ virtual wxRect GetItemRect(const wxDataViewItem& item, const wxDataViewColumn* columnPtr) const;
virtual wxDataViewItem GetSelection() const;
virtual int GetSelections(wxDataViewItemArray& sel) const;
-
- virtual void HitTest(wxPoint const& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const;
- virtual bool IsSelected(wxDataViewItem const& item) const;
+ virtual void HitTest(const wxPoint& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const;
+
+ virtual bool IsSelected(const wxDataViewItem& item) const;
virtual void SelectAll();
- virtual void Select(wxDataViewItem const& item);
- virtual void SetSelections(wxDataViewItemArray const& sel);
+ virtual void Select(const wxDataViewItem& item);
+ virtual void SetSelections(const wxDataViewItemArray& sel);
- virtual void Unselect(wxDataViewItem const& item);
+ virtual void Unselect(const wxDataViewItem& item);
virtual void UnselectAll();
//
// with CG, we need to get the context from an kEventControlDraw event
// unfortunately, the DataBrowser callbacks don't provide the context
- // and we need it, so we need to set/remove it before and after draw
+ // and we need it, so we need to set/remove it before and after draw
// events so we can access it in the callbacks.
void MacSetDrawingContext(void* context)
{
// event handling:
void OnSize(wxSizeEvent &event);
+ void OnMouse(wxMouseEvent &event);
private:
// type definitions:
void* m_cgContext; // pointer to core graphics context
wxDataViewCustomRenderer* m_CustomRendererPtr; // pointer to a valid custom renderer while editing; this class does NOT own the pointer
-
+
wxDataViewItem m_CustomRendererItem; // currently edited item by the customerenderer; it is invalid while not editing
ColumnPointerHashMapType m_ColumnPointers; // all column pointers are stored in a hash map with the property ID as a key