1 // =========================================================================== 2 // Purpose: wxDataView classes 3 // Author: Konstantin S. Matveyev 4 // Created: 28/03/2020 5 // Copyright: (c) 2020 EligoVision. Interactive Technologies 6 // Licence: wxWidgets licence 7 // wxWidgets: Updated to 3.1.4 8 // =========================================================================== 9 10 #include "wx/dataview.h" 11 12 #if %wxchkver_3_1 && wxUSE_DATAVIEWCTRL && wxLUA_USE_wxDataViewCtrl 13 14 #define wxDVC_DEFAULT_RENDERER_SIZE 15 #define wxDVC_DEFAULT_WIDTH 16 #define wxDVC_TOGGLE_DEFAULT_WIDTH 17 #define wxDVC_DEFAULT_MINWIDTH 18 #define wxDVR_DEFAULT_ALIGNMENT 19 20 enum wxDataViewColumnFlags 21 { 22 wxDATAVIEW_COL_RESIZABLE, 23 wxDATAVIEW_COL_SORTABLE, 24 wxDATAVIEW_COL_REORDERABLE, 25 wxDATAVIEW_COL_HIDDEN 26 }; 27 28 // TODO: in base 29 // class %delete wxVariant : public wxObject 30 // { 31 // wxVariant(const wxString& val, const wxString& name = wxEmptyString); 32 // }; 33 34 35 // class wxDataViewItem 36 class %delete wxDataViewItem 37 { 38 wxDataViewItem(); 39 wxDataViewItem(const wxDataViewItem &item); 40 wxDataViewItem(void *id); 41 42 void* GetID() const; 43 bool IsOk() const; 44 }; 45 46 47 // class wxDataViewItemArray 48 class %delete wxDataViewItemArray 49 { 50 wxDataViewItemArray(); 51 wxDataViewItemArray(const wxDataViewItemArray& array); 52 53 // TODO: 54 // %override [Lua table] wxDataViewItemArray::ToLuaTable() const; 55 // returns a table array of the wxDataViewItem 56 // int ToLuaTable() const; 57 58 void Add(wxDataViewItem num); 59 void Alloc(size_t count); 60 void Clear(); 61 void Empty(); 62 int GetCount() const; 63 bool IsEmpty() const; 64 int Index(wxDataViewItem n, bool searchFromEnd = false); 65 void Insert(wxDataViewItem num, int n, int copies = 1); 66 wxDataViewItem Item(int n); 67 void Remove(wxDataViewItem n); 68 void RemoveAt(size_t index); 69 void Shrink(); 70 71 wxDataViewItem operator[](size_t nIndex); 72 }; 73 74 75 // class wxDataViewModelNotifier 76 class %delete wxDataViewModelNotifier 77 { 78 wxDataViewModelNotifier(); 79 80 virtual bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0; 81 virtual bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ) = 0; 82 virtual bool ItemChanged( const wxDataViewItem &item ) = 0; 83 virtual bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items ); 84 virtual bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items ); 85 virtual bool ItemsChanged( const wxDataViewItemArray &items ); 86 virtual bool ValueChanged( const wxDataViewItem &item, unsigned int col ) = 0; 87 virtual bool Cleared() = 0; 88 89 virtual bool BeforeReset(); 90 virtual bool AfterReset(); 91 92 virtual void Resort() = 0; 93 94 void SetOwner(wxDataViewModel *owner) %ungc_this; // NOTE: valid owner must be presented 95 wxDataViewModel *GetOwner() const; 96 }; 97 98 99 // class wxDataViewItemAttr 100 class %delete wxDataViewItemAttr 101 { 102 wxDataViewItemAttr(); 103 104 // setters 105 void SetColour(const wxColour& colour); 106 void SetBold( bool set ); 107 void SetItalic( bool set ); 108 void SetStrikethrough( bool set ); 109 void SetBackgroundColour(const wxColour& colour); 110 111 // accessors 112 bool HasColour() const; 113 const wxColour& GetColour() const; 114 115 bool HasFont() const; 116 bool GetBold() const; 117 bool GetItalic() const; 118 bool GetStrikethrough() const; 119 120 bool HasBackgroundColour() const; 121 const wxColour& GetBackgroundColour(); 122 123 bool IsDefault() const; 124 125 // Return the font based on the given one with this attribute applied to it. 126 wxFont GetEffectiveFont(const wxFont& font) const; 127 }; 128 129 130 /*typedef wxVector<wxDataViewModelNotifier*> wxDataViewModelNotifiers;*/ 131 132 // class wxDataViewModel 133 class %delete wxDataViewModel // : public wxRefCounter 134 { 135 // wxRefCounter memory managment 136 void DecRef(); 137 int GetRefCount() const; 138 void IncRef(); 139 140 virtual unsigned int GetColumnCount(); 141 142 // return type as reported by wxVariant 143 virtual wxString GetColumnType( unsigned int col ) const = 0; 144 145 // get value into a wxVariant 146 // virtual void GetValue( wxVariant &variant, const wxDataViewItem &item, unsigned int col ) const = 0; 147 bool HasValue(const wxDataViewItem& item, unsigned int col) const; 148 // virtual bool SetValue(const wxVariant &variant, const wxDataViewItem &item, unsigned int col) = 0; 149 150 // bool ChangeValue(const wxVariant& variant, const wxDataViewItem& item, unsigned int col); 151 virtual bool GetAttr(const wxDataViewItem &item, unsigned int col, wxDataViewItemAttr &attr) const; 152 virtual bool IsEnabled(const wxDataViewItem &item, unsigned int col) const; 153 154 virtual wxDataViewItem GetParent( const wxDataViewItem &item ) const = 0; 155 virtual bool IsContainer( const wxDataViewItem &item ) const = 0; 156 157 virtual bool HasContainerColumns(const wxDataViewItem& item) const; 158 virtual unsigned int GetChildren( const wxDataViewItem &item, wxDataViewItemArray &children ) const = 0; 159 160 bool ItemAdded( const wxDataViewItem &parent, const wxDataViewItem &item ); 161 bool ItemsAdded( const wxDataViewItem &parent, const wxDataViewItemArray &items ); 162 bool ItemDeleted( const wxDataViewItem &parent, const wxDataViewItem &item ); 163 bool ItemsDeleted( const wxDataViewItem &parent, const wxDataViewItemArray &items ); 164 bool ItemChanged( const wxDataViewItem &item ); 165 bool ItemsChanged( const wxDataViewItemArray &items ); 166 bool ValueChanged( const wxDataViewItem &item, unsigned int col ); 167 bool Cleared(); 168 169 // some platforms, such as GTK+, may need a two step procedure for ::Reset() 170 bool BeforeReset(); 171 bool AfterReset(); 172 173 // delegated action 174 virtual void Resort(); 175 176 void AddNotifier( wxDataViewModelNotifier *notifier ); 177 void RemoveNotifier( wxDataViewModelNotifier *notifier ); 178 179 // default compare function 180 virtual int Compare( const wxDataViewItem &item1, const wxDataViewItem &item2, 181 unsigned int column, bool ascending ) const; 182 virtual bool HasDefaultCompare() const; 183 184 // internal 185 virtual bool IsListModel() const; 186 virtual bool IsVirtualListModel() const; 187 }; 188 189 190 // class wxDataViewListModel 191 class %delete wxDataViewListModel : public wxDataViewModel 192 { 193 // virtual void GetValueByRow(wxVariant &variant, unsigned row, unsigned col) const = 0; 194 // virtual bool SetValueByRow(const wxVariant &variant, unsigned row, unsigned col) = 0; 195 virtual bool GetAttrByRow(unsigned int row, unsigned int col, wxDataViewItemAttr &attr) const; 196 virtual bool IsEnabledByRow(unsigned int row, unsigned int col) const; 197 virtual unsigned int GetRow( const wxDataViewItem &item ) const = 0; 198 virtual unsigned int GetCount() const = 0; 199 }; 200 201 202 // class wxDataViewIndexListModel 203 class %delete wxDataViewIndexListModel : public wxDataViewListModel 204 { 205 void RowPrepended(); 206 void RowInserted( unsigned int before ); 207 void RowAppended(); 208 void RowDeleted( unsigned int row ); 209 void RowsDeleted( const wxArrayInt &rows ); 210 void RowChanged( unsigned int row ); 211 void RowValueChanged( unsigned int row, unsigned int col ); 212 void Reset( unsigned int new_size ); 213 214 wxDataViewItem GetItem( unsigned int row ) const; 215 }; 216 217 218 // class wxDataViewListStore 219 class %delete wxDataViewListStoreLine 220 { 221 wxDataViewListStoreLine( wxUIntPtr data = 0 ); 222 223 void SetData( wxUIntPtr data ); 224 wxUIntPtr GetData() const; 225 226 // wxVector<wxVariant> m_values; 227 }; 228 229 230 // class wxDataViewListStore 231 class %delete wxDataViewListStore : public wxDataViewIndexListModel 232 { 233 public: 234 wxDataViewListStore(); 235 236 void PrependColumn( const wxString &varianttype ); 237 void InsertColumn( unsigned int pos, const wxString &varianttype ); 238 void AppendColumn( const wxString &varianttype ); 239 240 // void AppendItem( const wxVector<wxVariant> &values, wxUIntPtr data = 0 ); 241 // void PrependItem( const wxVector<wxVariant> &values, wxUIntPtr data = 0 ); 242 // void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxUIntPtr data = 0 ); 243 void DeleteItem( unsigned int pos ); 244 void DeleteAllItems(); 245 void ClearColumns(); 246 247 unsigned int GetItemCount() const; 248 249 void SetItemData( const wxDataViewItem& item, wxUIntPtr data ); 250 wxUIntPtr GetItemData( const wxDataViewItem& item ) const; 251 }; 252 253 254 255 // TODO: wxDataViewVirtualListModel 256 257 258 // class wxDataViewTreeStoreNode 259 class %delete wxDataViewTreeStoreNode 260 { 261 public: 262 wxDataViewTreeStoreNode(wxDataViewTreeStoreNode *parent, const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); 263 264 void SetText( const wxString &text ); 265 wxString GetText() const; 266 void SetIcon( const wxIcon &icon ); 267 const wxIcon &GetIcon() const; 268 void SetData( wxClientData *data ); 269 wxClientData *GetData() const; 270 271 wxDataViewItem GetItem() const; 272 273 virtual bool IsContainer(); 274 275 wxDataViewTreeStoreNode *GetParent(); 276 }; 277 // typedef wxVector<wxDataViewTreeStoreNode*> wxDataViewTreeStoreNodes; 278 279 280 // class wxDataViewTreeStoreContainerNode 281 class %delete wxDataViewTreeStoreContainerNode : public wxDataViewTreeStoreNode 282 { 283 wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent, const wxString &text, 284 const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, wxClientData *data = NULL ); 285 286 // const wxDataViewTreeStoreNodes &GetChildren() const 287 // wxDataViewTreeStoreNodes &GetChildren() 288 289 // wxDataViewTreeStoreNodes::iterator FindChild(wxDataViewTreeStoreNode* node); 290 291 void SetExpandedIcon( const wxIcon &icon ); 292 const wxIcon &GetExpandedIcon() const; 293 294 void SetExpanded( bool expanded = true ); 295 bool IsExpanded() const; 296 297 void DestroyChildren(); 298 }; 299 300 301 // class wxDataViewTreeStore 302 class %delete wxDataViewTreeStore : public wxDataViewModel 303 { 304 wxDataViewTreeStore(); 305 306 wxDataViewItem AppendItem( const wxDataViewItem& parent, 307 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); 308 wxDataViewItem PrependItem( const wxDataViewItem& parent, 309 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); 310 wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous, 311 const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL ); 312 313 wxDataViewItem PrependContainer( const wxDataViewItem& parent, 314 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, 315 wxClientData *data = NULL ); 316 wxDataViewItem AppendContainer( const wxDataViewItem& parent, 317 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, 318 wxClientData *data = NULL ); 319 wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous, 320 const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon, 321 wxClientData *data = NULL ); 322 323 wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const; 324 int GetChildCount( const wxDataViewItem& parent ) const; 325 326 void SetItemText( const wxDataViewItem& item, const wxString &text ); 327 wxString GetItemText( const wxDataViewItem& item ) const; 328 void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon ); 329 const wxIcon &GetItemIcon( const wxDataViewItem& item ) const; 330 void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon ); 331 const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const; 332 void SetItemData( const wxDataViewItem& item, wxClientData *data ); 333 wxClientData *GetItemData( const wxDataViewItem& item ) const; 334 335 void DeleteItem( const wxDataViewItem& item ); 336 void DeleteChildren( const wxDataViewItem& item ); 337 void DeleteAllItems(); // FIXME: segfault 338 339 wxDataViewTreeStoreNode *FindNode( const wxDataViewItem &item ) const; 340 wxDataViewTreeStoreContainerNode *FindContainerNode( const wxDataViewItem &item ) const; 341 wxDataViewTreeStoreNode *GetRoot() const; 342 343 // wxDataViewTreeStoreNode *m_root; 344 }; 345 346 347 // class wxDataViewRenderer and related classes 348 class wxDataViewRenderer : public wxDataViewCustomRendererBase 349 { 350 // wxDataViewRenderer( const wxString &varianttype, 351 // wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, 352 // int align = wxDVR_DEFAULT_ALIGNMENT ); 353 }; 354 355 356 // From wx/headercol.h [begin] 357 358 enum 359 { 360 wxCOL_WIDTH_DEFAULT, 361 wxCOL_WIDTH_AUTOSIZE 362 }; 363 364 enum 365 { 366 wxCOL_RESIZABLE, 367 wxCOL_SORTABLE, 368 wxCOL_REORDERABLE, 369 wxCOL_HIDDEN, 370 wxCOL_DEFAULT_FLAGS 371 }; 372 373 374 // class wxHeaderColumn 375 class %delete wxHeaderColumn 376 { 377 virtual wxString GetTitle() const = 0; 378 virtual wxBitmap GetBitmap() const = 0; 379 virtual int GetWidth() const = 0; 380 virtual int GetMinWidth() const = 0; 381 virtual wxAlignment GetAlignment() const = 0; 382 383 virtual int GetFlags() const = 0; 384 bool HasFlag(int flag) const; 385 386 virtual bool IsResizeable() const; 387 virtual bool IsSortable() const 388 virtual bool IsReorderable() const; 389 virtual bool IsHidden() const; 390 bool IsShown() const; 391 392 virtual bool IsSortKey() const; 393 virtual bool IsSortOrderAscending() const; 394 }; 395 396 397 // class wxSettableHeaderColumn 398 class wxSettableHeaderColumn : public wxHeaderColumn 399 { 400 virtual void SetTitle(const wxString& title) = 0; 401 virtual void SetBitmap(const wxBitmap& bitmap) = 0; 402 virtual void SetWidth(int width) = 0; 403 virtual void SetMinWidth(int minWidth) = 0; 404 virtual void SetAlignment(wxAlignment align) = 0; 405 406 virtual void SetFlags(int flags) = 0; 407 void ChangeFlag(int flag, bool set); 408 void SetFlag(int flag); 409 void ClearFlag(int flag); 410 void ToggleFlag(int flag); 411 412 virtual void SetResizeable(bool resizable); 413 virtual void SetSortable(bool sortable); 414 virtual void SetReorderable(bool reorderable); 415 virtual void SetHidden(bool hidden); 416 417 virtual void UnsetAsSortKey(); 418 419 virtual void SetSortOrder(bool ascending) = 0; 420 void ToggleSortOrder(); 421 }; 422 423 // From wx/headercol.h [end] 424 425 426 // class wxDataViewColumnBase 427 class wxDataViewColumnBase : public wxSettableHeaderColumn 428 { 429 virtual void SetOwner(wxDataViewCtrl *owner) %ungc_this; // NOTE: valid owner must be presented 430 431 unsigned int GetModelColumn() const; 432 wxDataViewCtrl *GetOwner() const; 433 wxDataViewRenderer* GetRenderer() const; 434 435 virtual void SetBitmap(const wxBitmap& bitmap); 436 virtual wxBitmap GetBitmap() const; 437 }; 438 439 440 // class wxDataViewColumn 441 class wxDataViewColumn : public wxDataViewColumnBase 442 { 443 wxDataViewColumn( const wxString &title, wxDataViewRenderer *renderer, 444 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, 445 wxAlignment align = wxALIGN_CENTER, 446 int flags = wxDATAVIEW_COL_RESIZABLE ); 447 wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *renderer, 448 unsigned int model_column, int width = wxDVC_DEFAULT_WIDTH, 449 wxAlignment align = wxALIGN_CENTER, 450 int flags = wxDATAVIEW_COL_RESIZABLE ); 451 }; 452 453 454 #define wxDV_SINGLE 455 #define wxDV_MULTIPLE 456 457 #define wxDV_NO_HEADER 458 #define wxDV_HORIZ_RULES 459 #define wxDV_VERT_RULES 460 461 #define wxDV_ROW_LINES 462 #define wxDV_VARIABLE_LINE_HEIGHT 463 464 465 // class wxDataViewCtrlBase 466 class wxDataViewCtrlBase : public wxControl //: public wxSystemThemedControl<wxControl> 467 { 468 virtual bool AssociateModel( wxDataViewModel *model ); 469 wxDataViewModel* GetModel(); 470 471 wxDataViewColumn *PrependTextColumn( const wxString &label, unsigned int model_column, 472 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, 473 wxAlignment align = wxALIGN_NOT, 474 int flags = wxDATAVIEW_COL_RESIZABLE ); 475 wxDataViewColumn *PrependIconTextColumn( const wxString &label, unsigned int model_column, 476 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, 477 wxAlignment align = wxALIGN_NOT, 478 int flags = wxDATAVIEW_COL_RESIZABLE ); 479 wxDataViewColumn *PrependToggleColumn( const wxString &label, unsigned int model_column, 480 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, 481 wxAlignment align = wxALIGN_CENTER, 482 int flags = wxDATAVIEW_COL_RESIZABLE ); 483 wxDataViewColumn *PrependProgressColumn( const wxString &label, unsigned int model_column, 484 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, 485 wxAlignment align = wxALIGN_CENTER, 486 int flags = wxDATAVIEW_COL_RESIZABLE ); 487 wxDataViewColumn *PrependDateColumn( const wxString &label, unsigned int model_column, 488 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, 489 wxAlignment align = wxALIGN_NOT, 490 int flags = wxDATAVIEW_COL_RESIZABLE ); 491 wxDataViewColumn *PrependBitmapColumn( const wxString &label, unsigned int model_column, 492 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, 493 wxAlignment align = wxALIGN_CENTER, 494 int flags = wxDATAVIEW_COL_RESIZABLE ); 495 wxDataViewColumn *PrependTextColumn( const wxBitmap &label, unsigned int model_column, 496 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, 497 wxAlignment align = wxALIGN_NOT, 498 int flags = wxDATAVIEW_COL_RESIZABLE ); 499 wxDataViewColumn *PrependIconTextColumn( const wxBitmap &label, unsigned int model_column, 500 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, 501 wxAlignment align = wxALIGN_NOT, 502 int flags = wxDATAVIEW_COL_RESIZABLE ); 503 wxDataViewColumn *PrependToggleColumn( const wxBitmap &label, unsigned int model_column, 504 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, 505 wxAlignment align = wxALIGN_CENTER, 506 int flags = wxDATAVIEW_COL_RESIZABLE ); 507 wxDataViewColumn *PrependProgressColumn( const wxBitmap &label, unsigned int model_column, 508 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, 509 wxAlignment align = wxALIGN_CENTER, 510 int flags = wxDATAVIEW_COL_RESIZABLE ); 511 wxDataViewColumn *PrependDateColumn( const wxBitmap &label, unsigned int model_column, 512 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, 513 wxAlignment align = wxALIGN_NOT, 514 int flags = wxDATAVIEW_COL_RESIZABLE ); 515 wxDataViewColumn *PrependBitmapColumn( const wxBitmap &label, unsigned int model_column, 516 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, 517 wxAlignment align = wxALIGN_CENTER, 518 int flags = wxDATAVIEW_COL_RESIZABLE ); 519 520 wxDataViewColumn *AppendTextColumn( const wxString &label, unsigned int model_column, 521 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, 522 wxAlignment align = wxALIGN_NOT, 523 int flags = wxDATAVIEW_COL_RESIZABLE ); 524 wxDataViewColumn *AppendIconTextColumn( const wxString &label, unsigned int model_column, 525 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, 526 wxAlignment align = wxALIGN_NOT, 527 int flags = wxDATAVIEW_COL_RESIZABLE ); 528 wxDataViewColumn *AppendToggleColumn( const wxString &label, unsigned int model_column, 529 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, 530 wxAlignment align = wxALIGN_CENTER, 531 int flags = wxDATAVIEW_COL_RESIZABLE ); 532 wxDataViewColumn *AppendProgressColumn( const wxString &label, unsigned int model_column, 533 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, 534 wxAlignment align = wxALIGN_CENTER, 535 int flags = wxDATAVIEW_COL_RESIZABLE ); 536 wxDataViewColumn *AppendDateColumn( const wxString &label, unsigned int model_column, 537 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, 538 wxAlignment align = wxALIGN_NOT, 539 int flags = wxDATAVIEW_COL_RESIZABLE ); 540 wxDataViewColumn *AppendBitmapColumn( const wxString &label, unsigned int model_column, 541 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, 542 wxAlignment align = wxALIGN_CENTER, 543 int flags = wxDATAVIEW_COL_RESIZABLE ); 544 wxDataViewColumn *AppendTextColumn( const wxBitmap &label, unsigned int model_column, 545 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, 546 wxAlignment align = wxALIGN_NOT, 547 int flags = wxDATAVIEW_COL_RESIZABLE ); 548 wxDataViewColumn *AppendIconTextColumn( const wxBitmap &label, unsigned int model_column, 549 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, 550 wxAlignment align = wxALIGN_NOT, 551 int flags = wxDATAVIEW_COL_RESIZABLE ); 552 wxDataViewColumn *AppendToggleColumn( const wxBitmap &label, unsigned int model_column, 553 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_TOGGLE_DEFAULT_WIDTH, 554 wxAlignment align = wxALIGN_CENTER, 555 int flags = wxDATAVIEW_COL_RESIZABLE ); 556 wxDataViewColumn *AppendProgressColumn( const wxBitmap &label, unsigned int model_column, 557 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = wxDVC_DEFAULT_WIDTH, 558 wxAlignment align = wxALIGN_CENTER, 559 int flags = wxDATAVIEW_COL_RESIZABLE ); 560 wxDataViewColumn *AppendDateColumn( const wxBitmap &label, unsigned int model_column, 561 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, int width = -1, 562 wxAlignment align = wxALIGN_NOT, 563 int flags = wxDATAVIEW_COL_RESIZABLE ); 564 wxDataViewColumn *AppendBitmapColumn( const wxBitmap &label, unsigned int model_column, 565 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, int width = -1, 566 wxAlignment align = wxALIGN_CENTER, 567 int flags = wxDATAVIEW_COL_RESIZABLE ); 568 569 virtual bool PrependColumn(%ungc wxDataViewColumn *col ); 570 virtual bool InsertColumn(unsigned int pos, %ungc wxDataViewColumn *col); 571 virtual bool AppendColumn(%ungc wxDataViewColumn *col ); 572 573 virtual unsigned int GetColumnCount() const = 0; 574 virtual wxDataViewColumn* GetColumn( unsigned int pos ) const = 0; 575 virtual int GetColumnPosition(const wxDataViewColumn *column ) const = 0; 576 577 virtual bool DeleteColumn( wxDataViewColumn *column ) = 0; 578 virtual bool ClearColumns() = 0; 579 580 void SetExpanderColumn( wxDataViewColumn *col ); 581 wxDataViewColumn *GetExpanderColumn() const; 582 583 virtual wxDataViewColumn *GetSortingColumn() const = 0; 584 // virtual wxVector<wxDataViewColumn *> GetSortingColumns() const; 585 586 virtual bool AllowMultiColumnSort(bool allow); 587 virtual bool IsMultiColumnSortAllowed() const; 588 virtual void ToggleSortByColumn(int column); 589 590 void SetIndent( int indent ); 591 int GetIndent() const; 592 593 wxDataViewItem GetCurrentItem() const; 594 void SetCurrentItem(const wxDataViewItem& item); 595 596 virtual wxDataViewItem GetTopItem() const; 597 virtual int GetCountPerPage() const; 598 599 virtual wxDataViewColumn *GetCurrentColumn() const = 0; 600 601 virtual int GetSelectedItemsCount() const = 0; 602 bool HasSelection() const; 603 wxDataViewItem GetSelection() const; 604 virtual int GetSelections( wxDataViewItemArray & sel ) const = 0; 605 virtual void SetSelections( const wxDataViewItemArray & sel ) = 0; 606 virtual void Select( const wxDataViewItem & item ) = 0; 607 virtual void Unselect( const wxDataViewItem & item ) = 0; 608 virtual bool IsSelected( const wxDataViewItem & item ) const = 0; 609 610 virtual void SelectAll() = 0; 611 virtual void UnselectAll() = 0; 612 613 void Expand( const wxDataViewItem & item ); 614 void ExpandAncestors( const wxDataViewItem & item ); 615 virtual void Collapse( const wxDataViewItem & item ) = 0; 616 virtual bool IsExpanded( const wxDataViewItem & item ) const = 0; 617 618 virtual void EnsureVisible( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) = 0; 619 // virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ) const = 0; 620 virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ) const = 0; 621 622 virtual bool SetRowHeight( int rowHeight ); 623 624 virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column) = 0; 625 626 #if wxUSE_DRAG_AND_DROP 627 virtual bool EnableDragSource(const wxDataFormat& format); 628 virtual bool EnableDropTarget(const wxDataFormat& format); 629 #endif // wxUSE_DRAG_AND_DROP 630 631 // virtual bool SetHeaderAttr(const wxItemAttr& attr); 632 virtual bool SetAlternateRowColour(const wxColour& colour); 633 634 virtual wxVisualAttributes GetDefaultAttributes() const; 635 636 static wxVisualAttributes GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); 637 }; 638 639 640 // class wxDataViewCtrl 641 class wxDataViewCtrl : public wxDataViewCtrlBase 642 { 643 wxDataViewCtrl(wxWindow *parent, wxWindowID id, 644 const wxPoint& pos = wxDefaultPosition, 645 const wxSize& size = wxDefaultSize, long style = 0, 646 const wxValidator& validator = wxDefaultValidator, 647 const wxString& name = wxDataViewCtrlNameStr ); 648 649 bool Create(wxWindow *parent, wxWindowID id, 650 const wxPoint& pos = wxDefaultPosition, 651 const wxSize& size = wxDefaultSize, long style = 0, 652 const wxValidator& validator = wxDefaultValidator, 653 const wxString& name = wxDataViewCtrlNameStr); 654 655 virtual unsigned int GetColumnCount() const; 656 virtual wxDataViewColumn* GetColumn( unsigned int pos ) const; 657 virtual int GetColumnPosition( const wxDataViewColumn *column ); 658 659 virtual bool DeleteColumn( wxDataViewColumn *column ); 660 virtual bool ClearColumns(); 661 662 virtual wxDataViewColumn *GetSortingColumn() const; 663 virtual wxDataViewColumn *GetCurrentColumn() const; 664 665 virtual int GetSelectedItemsCount() const; 666 virtual int GetSelections( wxDataViewItemArray & sel ) const; 667 virtual void SetSelections( const wxDataViewItemArray & sel ); 668 virtual void Select( const wxDataViewItem & item ); 669 virtual void Unselect( const wxDataViewItem & item ); 670 virtual bool IsSelected( const wxDataViewItem & item ) const; 671 672 virtual void SelectAll(); 673 virtual void UnselectAll(); 674 675 virtual void Collapse( const wxDataViewItem & item ); 676 virtual bool IsExpanded( const wxDataViewItem & item ) const; 677 678 virtual void EnsureVisible( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ); 679 // virtual void HitTest( const wxPoint & point, wxDataViewItem &item, wxDataViewColumn* &column ); 680 virtual wxRect GetItemRect( const wxDataViewItem & item, const wxDataViewColumn *column = NULL ); 681 virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column); 682 683 #if defined(wxHAS_GENERIC_DATAVIEWCTRL) 684 // The returned pointer is null if the control has wxDV_NO_HEADER style. 685 // 686 // This method is only available in the generic versions. 687 %wxchkver_3_1_1 wxHeaderCtrl* GenericGetHeader() const; 688 #endif 689 }; 690 691 // class wxDataViewListCtrl 692 class wxDataViewListCtrl: public wxDataViewCtrl 693 { 694 public: 695 wxDataViewListCtrl(); 696 697 wxDataViewListCtrl( wxWindow *parent, wxWindowID id, 698 const wxPoint& pos = wxDefaultPosition, 699 const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES, 700 const wxValidator& validator = wxDefaultValidator ); 701 702 bool Create( wxWindow *parent, wxWindowID id, 703 const wxPoint& pos = wxDefaultPosition, 704 const wxSize& size = wxDefaultSize, long style = wxDV_ROW_LINES, 705 const wxValidator& validator = wxDefaultValidator ); 706 707 wxDataViewListStore *GetStore(); 708 const wxDataViewListStore *GetStore() const; 709 710 int ItemToRow(const wxDataViewItem &item) const; 711 wxDataViewItem RowToItem(int row) const; 712 713 int GetSelectedRow() const; 714 void SelectRow(unsigned int row); 715 void UnselectRow(unsigned int row); 716 bool IsRowSelected(unsigned int row) const; 717 718 virtual bool AppendColumn( wxDataViewColumn *column ); 719 void AppendColumn( wxDataViewColumn *column, const wxString &varianttype ); 720 721 wxDataViewColumn *AppendTextColumn( const wxString &label, 722 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, 723 int width = -1, wxAlignment align = wxALIGN_LEFT, 724 int flags = wxDATAVIEW_COL_RESIZABLE ); 725 726 wxDataViewColumn *AppendToggleColumn( const wxString &label, 727 wxDataViewCellMode mode = wxDATAVIEW_CELL_ACTIVATABLE, 728 int width = -1, wxAlignment align = wxALIGN_LEFT, 729 int flags = wxDATAVIEW_COL_RESIZABLE ); 730 731 wxDataViewColumn *AppendProgressColumn( const wxString &label, 732 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, 733 int width = -1, wxAlignment align = wxALIGN_LEFT, 734 int flags = wxDATAVIEW_COL_RESIZABLE ); 735 736 wxDataViewColumn *AppendIconTextColumn( const wxString &label, 737 wxDataViewCellMode mode = wxDATAVIEW_CELL_INERT, 738 int width = -1, wxAlignment align = wxALIGN_LEFT, 739 int flags = wxDATAVIEW_COL_RESIZABLE ); 740 741 virtual bool InsertColumn( unsigned int pos, wxDataViewColumn *column ); 742 void InsertColumn( unsigned int pos, wxDataViewColumn *column, const wxString &varianttype ); 743 virtual bool PrependColumn( wxDataViewColumn *column ); 744 void PrependColumn( wxDataViewColumn *column, const wxString &varianttype ); 745 // void AppendItem( const wxVector<wxVariant> &values, wxUIntPtr data = NULL ); 746 // void PrependItem( const wxVector<wxVariant> &values, wxUIntPtr data = NULL ); 747 // void InsertItem( unsigned int row, const wxVector<wxVariant> &values, wxUIntPtr data = NULL ); 748 void DeleteItem( unsigned int row ); 749 void DeleteAllItems(); 750 unsigned int GetItemCount() const; 751 wxUIntPtr GetItemData(const wxDataViewItem& item) const; 752 // void SetValue( const wxVariant &value, unsigned int row, unsigned int col ); 753 // void GetValue( wxVariant &value, unsigned int row, unsigned int col ); 754 void SetTextValue( const wxString &value, unsigned int row, unsigned int col ); 755 wxString GetTextValue( unsigned int row, unsigned int col ) const; 756 void SetToggleValue( bool value, unsigned int row, unsigned int col ); 757 bool GetToggleValue( unsigned int row, unsigned int col ) const; 758 void SetItemData(const wxDataViewItem& item, wxUIntPtr data); 759 }; 760 761 // class wxDataViewEvent 762 class %delete wxDataViewEvent : public wxNotifyEvent 763 { 764 %wxEventType wxEVT_DATAVIEW_SELECTION_CHANGED 765 766 %wxEventType wxEVT_DATAVIEW_ITEM_ACTIVATED 767 %wxEventType wxEVT_DATAVIEW_ITEM_COLLAPSED 768 %wxEventType wxEVT_DATAVIEW_ITEM_EXPANDED 769 %wxEventType wxEVT_DATAVIEW_ITEM_COLLAPSING 770 %wxEventType wxEVT_DATAVIEW_ITEM_EXPANDING 771 %wxEventType wxEVT_DATAVIEW_ITEM_START_EDITING 772 %wxEventType wxEVT_DATAVIEW_ITEM_EDITING_STARTED 773 %wxEventType wxEVT_DATAVIEW_ITEM_EDITING_DONE 774 %wxEventType wxEVT_DATAVIEW_ITEM_VALUE_CHANGED 775 776 %wxEventType wxEVT_DATAVIEW_ITEM_CONTEXT_MENU 777 778 %wxEventType wxEVT_DATAVIEW_COLUMN_HEADER_CLICK 779 %wxEventType wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK 780 %wxEventType wxEVT_DATAVIEW_COLUMN_SORTED 781 %wxEventType wxEVT_DATAVIEW_COLUMN_REORDERED 782 783 %wxEventType wxEVT_DATAVIEW_CACHE_HINT 784 785 %wxEventType wxEVT_DATAVIEW_ITEM_BEGIN_DRAG 786 %wxEventType wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE 787 %wxEventType wxEVT_DATAVIEW_ITEM_DROP 788 789 790 wxDataViewEvent(); 791 wxDataViewEvent(wxEventType evtType, wxDataViewCtrlBase* dvc, wxDataViewColumn* column); 792 wxDataViewEvent(wxEventType evtType, wxDataViewCtrlBase* dvc, wxDataViewColumn* column, const wxDataViewItem& item); 793 wxDataViewEvent(wxEventType evtType, wxDataViewCtrlBase* dvc, const wxDataViewItem& item); 794 795 wxDataViewEvent(const wxDataViewEvent& event); 796 797 wxDataViewItem GetItem() const; 798 int GetColumn() const; 799 wxDataViewModel* GetModel() const; 800 801 // const wxVariant &GetValue() const; 802 // void SetValue( const wxVariant &value ); 803 804 bool IsEditCancelled() const; 805 806 wxDataViewColumn *GetDataViewColumn() const; 807 808 wxPoint GetPosition() const; 809 void SetPosition( int x, int y ); 810 811 // For wxEVT_DATAVIEW_CACHE_HINT 812 int GetCacheFrom() const; 813 int GetCacheTo() const; 814 void SetCache(int from, int to); 815 816 817 #if wxUSE_DRAG_AND_DROP 818 void SetDataObject(%ungc wxDataObject *obj); 819 wxDataObject *GetDataObject() const; 820 821 void SetDataFormat( const wxDataFormat &format ); 822 wxDataFormat GetDataFormat() const; 823 void SetDataSize( size_t size ); 824 size_t GetDataSize() const; 825 void SetDataBuffer( void* buf ); 826 void *GetDataBuffer() const; 827 void SetDragFlags( int flags ); 828 int GetDragFlags() const; 829 void SetDropEffect( wxDragResult effect ); 830 wxDragResult GetDropEffect() const; 831 void SetProposedDropIndex(int index); 832 int GetProposedDropIndex() const; 833 #endif // wxUSE_DRAG_AND_DROP 834 835 virtual wxEvent *Clone() const; 836 837 void SetColumn( int col ); 838 void SetEditCancelled(); 839 }; 840 841 #endif 842