X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a75124d0da255513e83d2e62f963dd849829466b..2036bdd30368d117918b565ae990a89841281f33:/include/wx/dataview.h diff --git a/include/wx/dataview.h b/include/wx/dataview.h index 4a5e4f8893..fc800bcea4 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -24,6 +24,8 @@ #include "wx/icon.h" #include "wx/imaglist.h" +class WXDLLIMPEXP_FWD_CORE wxDataFormat; + #if defined(__WXGTK20__) // for testing // #define wxUSE_GENERICDATAVIEWCTRL 1 @@ -96,7 +98,7 @@ WX_DEFINE_ARRAY(wxDataViewItem, wxDataViewItemArray); class WXDLLIMPEXP_ADV wxDataViewModelNotifier { public: - wxDataViewModelNotifier() { } + wxDataViewModelNotifier() { m_owner = NULL; } virtual ~wxDataViewModelNotifier() { m_owner = NULL; } virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0; @@ -129,8 +131,8 @@ class WXDLLIMPEXP_ADV wxDataViewItemAttr { public: // ctors - wxDataViewItemAttr() - { + wxDataViewItemAttr() + { m_bold = false; m_italic = false; } @@ -139,11 +141,11 @@ public: void SetColour(const wxColour& colour) { m_colour = colour; } void SetBold( bool set ) { m_bold = set; } void SetItalic( bool set ) { m_italic = set; } - + // accessors bool HasColour() const { return m_colour.Ok(); } const wxColour& GetColour() const { return m_colour; } - + bool GetBold() const { return m_bold; } bool GetItalic() const { return m_italic; } @@ -191,6 +193,15 @@ public: { return false; } virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const = 0; + // define DnD capabilities + virtual bool IsDraggable( const wxDataViewItem &WXUNUSED(item) ) + { return false; } + virtual size_t GetDragDataSize( const wxDataViewItem &WXUNUSED(item), const wxDataFormat &WXUNUSED(format) ) + { return 0; } + virtual bool GetDragData( const wxDataViewItem &WXUNUSED(item), const wxDataFormat &WXUNUSED(format), + void* WXUNUSED(data), size_t WXUNUSED(size) ) + { return FALSE; } + // delegated notifiers virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ); virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items ); @@ -211,7 +222,7 @@ public: virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, unsigned int column, bool ascending ); virtual bool HasDefaultCompare() const { return false; } - + // internal virtual bool IsIndexListModel() const { return false; } @@ -240,13 +251,15 @@ public: virtual bool GetAttr( unsigned int WXUNUSED(row), unsigned int WXUNUSED(col), wxDataViewItemAttr &WXUNUSED(attr) ) { return false; } - + void RowPrepended(); void RowInserted( unsigned int before ); void RowAppended(); void RowDeleted( unsigned int row ); + void RowsDeleted( const wxArrayInt &rows ); void RowChanged( unsigned int row ); void RowValueChanged( unsigned int row, unsigned int col ); + void Reset( unsigned int new_size ); // convert to/from row/wxDataViewItem @@ -273,7 +286,7 @@ public: // internal virtual bool IsIndexListModel() const { return true; } unsigned int GetLastIndex() const { return m_lastIndex; } - + private: wxDataViewItemArray m_hash; unsigned int m_lastIndex; @@ -395,7 +408,8 @@ class WXDLLIMPEXP_ADV wxDataViewIconText: public wxObject { public: wxDataViewIconText( const wxString &text = wxEmptyString, const wxIcon& icon = wxNullIcon ) - { m_icon = icon; m_text = text; } + : m_text(text), m_icon(icon) + { } wxDataViewIconText( const wxDataViewIconText &other ) { m_icon = other.m_icon; m_text = other.m_text; } @@ -422,9 +436,10 @@ DECLARE_VARIANT_OBJECT_EXPORTED(wxDataViewIconText, WXDLLIMPEXP_ADV) enum wxDataViewColumnFlags { - wxDATAVIEW_COL_RESIZABLE = 1, - wxDATAVIEW_COL_SORTABLE = 2, - wxDATAVIEW_COL_HIDDEN = 4 + wxDATAVIEW_COL_RESIZABLE = 1, + wxDATAVIEW_COL_SORTABLE = 2, + wxDATAVIEW_COL_REORDERABLE = 4, + wxDATAVIEW_COL_HIDDEN = 8 }; class WXDLLIMPEXP_ADV wxDataViewColumnBase: public wxObject @@ -445,6 +460,7 @@ public: virtual void SetTitle( const wxString &title ) = 0; virtual void SetAlignment( wxAlignment align ) = 0; virtual void SetSortable( bool sortable ) = 0; + virtual void SetReorderable(bool reorderable) = 0; virtual void SetResizeable( bool resizeable ) = 0; virtual void SetHidden( bool hidden ) = 0; virtual void SetSortOrder( bool ascending ) = 0; @@ -467,9 +483,10 @@ public: virtual int GetFlags() const; - virtual bool IsSortable() const = 0; - virtual bool IsResizeable() const = 0; virtual bool IsHidden() const = 0; + virtual bool IsReorderable() const = 0; + virtual bool IsResizeable() const = 0; + virtual bool IsSortable() const = 0; virtual bool IsSortOrderAscending() const = 0; const wxBitmap &GetBitmap() const { return m_bitmap; } @@ -499,6 +516,8 @@ protected: #define wxDV_HORIZ_RULES 0x0004 // light horizontal rules between rows #define wxDV_VERT_RULES 0x0008 // light vertical rules between columns +#define wxDV_ROW_LINES 0x0010 // alternating colour in rows + class WXDLLIMPEXP_ADV wxDataViewCtrlBase: public wxControl { public: @@ -675,7 +694,8 @@ public: m_col(-1), m_model(NULL), m_value(wxNullVariant), - m_column(NULL) + m_column(NULL), + m_pos(-1,-1) { } wxDataViewEvent(const wxDataViewEvent& event) @@ -684,7 +704,8 @@ public: m_col(event.m_col), m_model(event.m_model), m_value(event.m_value), - m_column(event.m_column) + m_column(event.m_column), + m_pos(m_pos) { } wxDataViewItem GetItem() const { return m_item; } @@ -703,6 +724,10 @@ public: void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; } wxDataViewColumn *GetDataViewColumn() const { return m_column; } + // for wxEVT_DATAVIEW_CONTEXT_MENU only + wxPoint GetPosition() const; + void SetPosition( int x, int y ) { m_pos.x = x; m_pos.y = y; } + virtual wxEvent *Clone() const { return new wxDataViewEvent(*this); } protected: @@ -711,27 +736,29 @@ protected: wxDataViewModel *m_model; wxVariant m_value; wxDataViewColumn *m_column; + wxPoint m_pos; private: DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewEvent) }; -BEGIN_DECLARE_EVENT_TYPES() - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, -1) +extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED; + +extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED; +extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED; +extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED; +extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING; +extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING; +extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED; +extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE; +extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED; - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, -1) - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSED, -1) - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDED, -1) - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_COLLAPSING, -1) - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EXPANDING, -1) - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_STARTED, -1) - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, -1) - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, -1) +extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU; - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK, -1) - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, -1) - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED, -1) -END_DECLARE_EVENT_TYPES() +extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_CLICK; +extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK; +extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_SORTED; +extern WXDLLIMPEXP_ADV const wxEventType wxEVT_COMMAND_DATAVIEW_COLUMN_REORDERED; typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); @@ -752,9 +779,12 @@ typedef void (wxEvtHandler::*wxDataViewEventFunction)(wxDataViewEvent&); #define EVT_DATAVIEW_ITEM_EDITING_DONE(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_EDITING_DONE, id, fn) #define EVT_DATAVIEW_ITEM_VALUE_CHANGED(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_VALUE_CHANGED, id, fn) +#define EVT_DATAVIEW_ITEM_CONTEXT_MENU(id, fn) wx__DECLARE_DATAVIEWEVT(ITEM_CONTEXT_MENU, id, fn) + #define EVT_DATAVIEW_COLUMN_HEADER_CLICK(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_CLICK, id, fn) #define EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICKED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_HEADER_RIGHT_CLICK, id, fn) #define EVT_DATAVIEW_COLUMN_SORTED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_SORTED, id, fn) +#define EVT_DATAVIEW_COLUMN_REORDERED(id, fn) wx__DECLARE_DATAVIEWEVT(COLUMN_REORDERED, id, fn) #if defined(wxUSE_GENERICDATAVIEWCTRL) #include "wx/generic/dataview.h" @@ -939,13 +969,13 @@ public: wxDataViewTreeCtrl(); wxDataViewTreeCtrl( wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER, + const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES, const wxValidator& validator = wxDefaultValidator ); ~wxDataViewTreeCtrl(); bool Create( wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER, + const wxSize& size = wxDefaultSize, long style = wxDV_NO_HEADER | wxDV_ROW_LINES, const wxValidator& validator = wxDefaultValidator ); wxDataViewTreeStore *GetStore() @@ -955,7 +985,7 @@ public: void SetImageList( wxImageList *imagelist ); wxImageList* GetImageList() { return m_imageList; } - + wxDataViewItem AppendItem( const wxDataViewItem& parent, const wxString &text, int icon = -1, wxClientData *data = NULL ); wxDataViewItem PrependItem( const wxDataViewItem& parent, @@ -1004,6 +1034,7 @@ public: void OnExpanded( wxDataViewEvent &event ); void OnCollapsed( wxDataViewEvent &event ); + void OnSize( wxSizeEvent &event ); private: wxImageList *m_imageList;