1 // =========================================================================== 2 // Purpose: wxGrid and related classes (Updated using grid.h NOT docs); 3 // Author: J Winwood, John Labenski 4 // Created: 14/11/2001 5 // Copyright: (c) 2001-2002 Lomtick Software. All rights reserved. 6 // Licence: wxWidgets licence 7 // wxWidgets: Updated to 2.8.4 8 // =========================================================================== 9 10 #if wxLUA_USE_wxGrid && wxUSE_GRID 11 12 #include "wx/grid.h" 13 #include "wx/generic/gridctrl.h" 14 15 #define WXGRID_DEFAULT_NUMBER_ROWS 16 #define WXGRID_DEFAULT_NUMBER_COLS 17 #define WXGRID_DEFAULT_ROW_HEIGHT 18 #define WXGRID_DEFAULT_COL_WIDTH 19 #define WXGRID_DEFAULT_COL_LABEL_HEIGHT 20 #define WXGRID_DEFAULT_ROW_LABEL_WIDTH 21 #define WXGRID_LABEL_EDGE_ZONE 22 #define WXGRID_MIN_ROW_HEIGHT 23 #define WXGRID_MIN_COL_WIDTH 24 #define WXGRID_DEFAULT_SCROLLBAR_WIDTH 25 26 #define_wxstring wxGRID_VALUE_STRING 27 #define_wxstring wxGRID_VALUE_BOOL 28 #define_wxstring wxGRID_VALUE_NUMBER 29 #define_wxstring wxGRID_VALUE_FLOAT 30 #define_wxstring wxGRID_VALUE_CHOICE 31 #define_wxstring wxGRID_VALUE_TEXT 32 #define_wxstring wxGRID_VALUE_LONG 33 34 #define_wxstring wxGRID_VALUE_CHOICEINT 35 #define_wxstring wxGRID_VALUE_DATETIME 36 37 %wxchkver_2_8_8 #define wxGRID_AUTOSIZE 38 39 // --------------------------------------------------------------------------- 40 // wxGridCellWorker 41 42 class %delete wxGridCellWorker : public wxClientDataContainer 43 { 44 // wxGridCellWorker() - base class only 45 46 void IncRef(); 47 void DecRef(); 48 49 virtual void SetParameters(const wxString& params); 50 }; 51 52 // --------------------------------------------------------------------------- 53 // wxGridCellRenderer 54 55 class %delete wxGridCellRenderer : public wxGridCellWorker 56 { 57 //wxGridCellRenderer() - no constructor abstract class 58 59 //virtual void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect, int row, int col, bool isSelected); 60 virtual wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, int row, int col); 61 }; 62 63 // --------------------------------------------------------------------------- 64 // wxGridCellStringRenderer 65 66 class %delete wxGridCellStringRenderer : public wxGridCellRenderer 67 { 68 wxGridCellStringRenderer(); 69 }; 70 71 // --------------------------------------------------------------------------- 72 // wxGridCellNumberRenderer 73 74 class %delete wxGridCellNumberRenderer : public wxGridCellStringRenderer 75 { 76 wxGridCellNumberRenderer(); 77 }; 78 79 // --------------------------------------------------------------------------- 80 // wxGridCellFloatRenderer 81 82 class %delete wxGridCellFloatRenderer : public wxGridCellStringRenderer 83 { 84 wxGridCellFloatRenderer(int width = -1, int precision = -1); 85 86 int GetWidth() const; 87 void SetWidth(int width); 88 int GetPrecision() const; 89 void SetPrecision(int precision); 90 }; 91 92 // --------------------------------------------------------------------------- 93 // wxGridCellBoolRenderer 94 95 class %delete wxGridCellBoolRenderer : public wxGridCellRenderer 96 { 97 wxGridCellBoolRenderer(); 98 }; 99 100 // --------------------------------------------------------------------------- 101 // wxGridCellDateTimeRenderer 102 103 class %delete wxGridCellDateTimeRenderer : public wxGridCellStringRenderer 104 { 105 wxGridCellDateTimeRenderer(const wxString& outformat = wxDefaultDateTimeFormat, const wxString& informat = wxDefaultDateTimeFormat); 106 }; 107 108 // --------------------------------------------------------------------------- 109 // wxGridCellEnumRenderer 110 111 class %delete wxGridCellEnumRenderer : public wxGridCellStringRenderer 112 { 113 wxGridCellEnumRenderer(const wxString& choices = ""); 114 }; 115 116 // --------------------------------------------------------------------------- 117 // wxGridCellAutoWrapStringRenderer 118 119 class %delete wxGridCellAutoWrapStringRenderer : public wxGridCellStringRenderer 120 { 121 wxGridCellAutoWrapStringRenderer(); 122 }; 123 124 // --------------------------------------------------------------------------- 125 // wxGridCellEditor 126 127 class %delete wxGridCellEditor : public wxGridCellWorker 128 { 129 // wxGridCellEditor() - no constructor abstract class 130 131 bool IsCreated(); 132 wxControl* GetControl(); 133 // wxLua Note: The attr will delete the control when it is destroyed. 134 void SetControl(%ungc wxControl* control); 135 wxGridCellAttr* GetCellAttr(); 136 // wxLua Note: the attr must exist for the life of this object since it doesn't take ownership nor call DecRef() on it. 137 void SetCellAttr(wxGridCellAttr* attr); 138 139 //virtual void Create(wxWindow* parent, wxWindowID id, wxEvtHandler* evtHandler); 140 virtual void BeginEdit(int row, int col, wxGrid* grid); 141 !%wxchkver_2_9_2 virtual bool EndEdit(int row, int col, wxGrid* grid); 142 %wxchkver_2_9_2 virtual bool EndEdit(int row, int col, const wxGrid *grid, const wxString& oldval, wxString *newval); 143 virtual void Reset(); 144 //virtual wxGridCellEditor *Clone() const; 145 virtual void SetSize(const wxRect& rect); 146 virtual void Show(bool show, wxGridCellAttr *attr = NULL); 147 148 !%wxchkver_2_9_5 virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr); 149 //%wxchkver_2_9_5 virtual void PaintBackground(const wxRect& rectCell, const wxGridCellAttr &attr); // it very briefly had this signature 150 %wxchkver_2_9_5 virtual void PaintBackground(wxDC& dc, const wxRect& rectCell, const wxGridCellAttr &attr); 151 152 virtual bool IsAcceptedKey(wxKeyEvent& event); 153 virtual void StartingKey(wxKeyEvent& event); 154 virtual void StartingClick(); 155 virtual void HandleReturn(wxKeyEvent& event); 156 virtual void Destroy(); 157 }; 158 159 // --------------------------------------------------------------------------- 160 // wxGridCellTextEditor 161 162 class %delete wxGridCellTextEditor : public wxGridCellEditor 163 { 164 wxGridCellTextEditor(); 165 }; 166 167 // --------------------------------------------------------------------------- 168 // wxGridCellNumberEditor 169 170 class %delete wxGridCellNumberEditor : public wxGridCellTextEditor 171 { 172 wxGridCellNumberEditor(int min = -1, int max = -1); 173 }; 174 175 // --------------------------------------------------------------------------- 176 // wxGridCellFloatEditor 177 178 class %delete wxGridCellFloatEditor : public wxGridCellTextEditor 179 { 180 wxGridCellFloatEditor(int width = -1, int precision = -1); 181 }; 182 183 // --------------------------------------------------------------------------- 184 // wxGridCellBoolEditor 185 186 class %delete wxGridCellBoolEditor : public wxGridCellEditor 187 { 188 wxGridCellBoolEditor(); 189 }; 190 191 // --------------------------------------------------------------------------- 192 // wxGridCellChoiceEditor 193 194 class %delete wxGridCellChoiceEditor : public wxGridCellEditor 195 { 196 wxGridCellChoiceEditor(const wxArrayString& choices, bool allowOthers = false); 197 }; 198 199 // --------------------------------------------------------------------------- 200 // wxGridCellEnumEditor 201 202 class %delete wxGridCellEnumEditor : public wxGridCellChoiceEditor 203 { 204 wxGridCellEnumEditor(const wxString& choices = ""); 205 }; 206 207 // --------------------------------------------------------------------------- 208 // wxGridCellAutoWrapStringEditor 209 210 class %delete wxGridCellAutoWrapStringEditor : public wxGridCellTextEditor 211 { 212 wxGridCellAutoWrapStringEditor(); 213 }; 214 215 // --------------------------------------------------------------------------- 216 // wxGridCellAttr 217 218 enum wxGridCellAttr::wxAttrKind 219 { 220 Any, 221 Default, 222 Cell, 223 Row, 224 Col, 225 Merged 226 }; 227 228 class %delete wxGridCellAttr : public wxClientDataContainer 229 { 230 wxGridCellAttr(); 231 wxGridCellAttr(const wxColour& colText, const wxColour& colBack, const wxFont& font, int hAlign, int vAlign); 232 233 void MergeWith(wxGridCellAttr *mergefrom); 234 void IncRef(); 235 void DecRef(); 236 void SetTextColour(const wxColour& colText); 237 void SetBackgroundColour(const wxColour& colBack); 238 void SetFont(const wxFont& font); 239 void SetAlignment(int hAlign, int vAlign); 240 void SetSize(int num_rows, int num_cols); 241 void SetOverflow(bool allow = true); 242 void SetReadOnly(bool isReadOnly = true); 243 244 // wxLua calls IncRef() on the input renderer since the attr will call DecRef() on it. 245 // You should not have to worry about Inc/DecRef() of the renderer as you would in C++. 246 void SetRenderer(%IncRef wxGridCellRenderer *renderer); 247 // wxLua calls IncRef() on the input editor since the attr will call DecRef() on it. 248 // You should not have to worry about Inc/DecRef() of the editor as you would in C++. 249 void SetEditor(%IncRef wxGridCellEditor* editor); 250 251 void SetKind(wxGridCellAttr::wxAttrKind kind); 252 bool HasTextColour() const; 253 bool HasBackgroundColour() const; 254 bool HasFont() const; 255 bool HasAlignment() const; 256 bool HasRenderer() const; 257 bool HasEditor() const; 258 bool HasReadWriteMode() const; 259 bool HasOverflowMode() const; 260 bool HasSize() const; 261 wxColour GetTextColour() const; 262 wxColour GetBackgroundColour() const; 263 wxFont GetFont() const; 264 265 // %override [int horiz, int vert] wxGridCellAttr::GetAlignment() const; 266 // C++ Func: void GetAlignment(int *horz, int *vert) const; 267 void GetAlignment() const; 268 269 // %override [int num_rows, int num_cols] wxGridCellAttr::GetSize() const; 270 // C++ Func: void GetSize(int *num_rows, int *num_cols) const; 271 void GetSize() const; 272 273 bool GetOverflow() const; 274 // wxLua Note: The attr calls IncRef() on the returned renderer so wxLua will garbage collect it. 275 %gc wxGridCellRenderer *GetRenderer(wxGrid* grid, int row, int col) const; 276 // wxLua Note: The attr calls IncRef() on the returned editor so wxLua will garbage collect it. 277 %gc wxGridCellEditor *GetEditor(wxGrid* grid, int row, int col) const; 278 279 bool IsReadOnly() const; 280 wxGridCellAttr::wxAttrKind GetKind(); 281 282 // wxLua Note: the attr must exist for the life of this object and it doesn't take ownership 283 void SetDefAttr(wxGridCellAttr* defAttr); 284 }; 285 286 // --------------------------------------------------------------------------- 287 // wxGridCellAttrProvider 288 289 class %delete wxGridCellAttrProvider : public wxClientDataContainer 290 { 291 wxGridCellAttrProvider(); 292 293 // wxLua Note: The attrprovider calls IncRef() on the returned attribute so wxLua will garbage collect it. 294 %gc wxGridCellAttr *GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind) const; 295 296 // wxLua calls IncRef() on the input attr since the attrprovider will call DecRef() on it. 297 // You should not have to worry about Inc/DecRef() of the attr as you would in C++. 298 void SetAttr(%IncRef wxGridCellAttr *attr, int row, int col); 299 // wxLua calls IncRef() on the input attr since the attrprovider will call DecRef() on it. 300 // You should not have to worry about Inc/DecRef() of the attr as you would in C++. 301 void SetRowAttr(%IncRef wxGridCellAttr *attr, int row); 302 // wxLua calls IncRef() on the input attr since the attrprovider will call DecRef() on it. 303 // You should not have to worry about Inc/DecRef() of the attr as you would in C++. 304 void SetColAttr(%IncRef wxGridCellAttr *attr, int col); 305 306 void UpdateAttrRows(size_t pos, int numRows); 307 void UpdateAttrCols(size_t pos, int numCols); 308 }; 309 310 // --------------------------------------------------------------------------- 311 // wxGridTableBase 312 313 class wxGridTableBase : public wxObject //, public wxClientDataContainer 314 { 315 // no constructor pure virtual base class 316 317 virtual int GetNumberRows(); 318 virtual int GetNumberCols(); 319 virtual bool IsEmptyCell(int row, int col); 320 virtual wxString GetValue(int row, int col); 321 virtual void SetValue(int row, int col, const wxString& value); 322 virtual wxString GetTypeName(int row, int col); 323 virtual bool CanGetValueAs(int row, int col, const wxString& typeName); 324 virtual bool CanSetValueAs(int row, int col, const wxString& typeName); 325 virtual bool GetValueAsBool(int row, int col); 326 virtual long GetValueAsLong(int row, int col); 327 virtual double GetValueAsDouble(int row, int col); 328 virtual void SetValueAsBool(int row, int col, bool value); 329 virtual void SetValueAsLong(int row, int col, long value); 330 virtual void SetValueAsDouble(int row, int col, double value); 331 //virtual void* GetValueAsCustom(int row, int col, const wxString& typeName); 332 //virtual void SetValueAsCustom(int row, int col, const wxString& typeName, void* value); 333 virtual void SetView(wxGrid *grid); 334 virtual wxGrid * GetView() const; 335 virtual void Clear(); 336 virtual bool InsertRows(size_t pos = 0, size_t numRows = 1); 337 virtual bool AppendRows(size_t numRows = 1); 338 virtual bool DeleteRows(size_t pos = 0, size_t numRows = 1); 339 virtual bool InsertCols(size_t pos = 0, size_t numCols = 1); 340 virtual bool AppendCols(size_t numCols = 1); 341 virtual bool DeleteCols(size_t pos = 0, size_t numCols = 1); 342 virtual wxString GetRowLabelValue(int row); 343 virtual wxString GetColLabelValue(int col); 344 virtual void SetRowLabelValue(int row, const wxString& value); 345 virtual void SetColLabelValue(int col, const wxString& value); 346 347 void SetAttrProvider(wxGridCellAttrProvider *attrProvider); 348 wxGridCellAttrProvider *GetAttrProvider() const; 349 virtual bool CanHaveAttributes(); 350 351 // wxLua Note: The table calls IncRef() on the returned attribute so wxLua will garbage collect it. 352 virtual %gc wxGridCellAttr* GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind); 353 354 // wxLua calls IncRef() on the input attr since the table will call DecRef() on it. 355 // You should not have to worry about Inc/DecRef() of the attr as you would in C++. 356 void SetAttr(%IncRef wxGridCellAttr* attr, int row, int col); 357 // wxLua calls IncRef() on the input attr since the table will call DecRef() on it. 358 // You should not have to worry about Inc/DecRef() of the attr as you would in C++. 359 void SetRowAttr(%IncRef wxGridCellAttr *attr, int row); 360 // wxLua calls IncRef() on the input attr since the table will call DecRef() on it. 361 // You should not have to worry about Inc/DecRef() of the attr as you would in C++. 362 void SetColAttr(%IncRef wxGridCellAttr *attr, int col); 363 }; 364 365 // --------------------------------------------------------------------------- 366 // wxLuaGridTableBase 367 368 #include "wxbind/include/wxadv_wxladv.h" 369 370 class %delete wxLuaGridTableBase : public wxGridTableBase 371 { 372 // %override - the C++ function takes the wxLuaState as the first param 373 wxLuaGridTableBase(); 374 375 // The functions below are all virtual functions that you override in Lua. 376 377 // You must override these functions in a derived table class 378 // 379 //virtual int GetNumberRows(); 380 //virtual int GetNumberCols(); 381 //virtual bool IsEmptyCell(int row, int col); 382 //virtual wxString GetValue(int row, int col); 383 //virtual void SetValue(int row, int col, const wxString& value); 384 // 385 // Data type determination and value access 386 //virtual wxString GetTypeName(int row, int col); 387 //virtual bool CanGetValueAs(int row, int col, const wxString& typeName); 388 //virtual bool CanSetValueAs(int row, int col, const wxString& typeName); 389 // 390 //virtual long GetValueAsLong(int row, int col); 391 //virtual double GetValueAsDouble(int row, int col); 392 //virtual bool GetValueAsBool(int row, int col); 393 // 394 //virtual void SetValueAsLong(int row, int col, long value); 395 //virtual void SetValueAsDouble(int row, int col, double value); 396 //virtual void SetValueAsBool(int row, int col, bool value); 397 // 398 // For user defined types - Custom values probably don't make too much sense for wxLua 399 // wxLua NOT overridable - virtual void* GetValueAsCustom(int row, int col, const wxString& typeName); 400 // wxLua NOT overridable - virtual void SetValueAsCustom(int row, int col, const wxString& typeName, void* value); 401 // 402 // Overriding these is optional 403 // 404 // wxLua NOT overridable - virtual void SetView(wxGrid *grid) { m_view = grid; } 405 // wxLua NOT overridable - virtual wxGrid * GetView() const { return m_view; } 406 // 407 //virtual void Clear() {} 408 //virtual bool InsertRows(size_t pos = 0, size_t numRows = 1); 409 //virtual bool AppendRows(size_t numRows = 1); 410 //virtual bool DeleteRows(size_t pos = 0, size_t numRows = 1); 411 //virtual bool InsertCols(size_t pos = 0, size_t numCols = 1); 412 //virtual bool AppendCols(size_t numCols = 1); 413 //virtual bool DeleteCols(size_t pos = 0, size_t numCols = 1); 414 // 415 //virtual wxString GetRowLabelValue(int row); 416 //virtual wxString GetColLabelValue(int col); 417 //virtual void SetRowLabelValue(int WXUNUSED(row), const wxString&) {} 418 //virtual void SetColLabelValue(int WXUNUSED(col), const wxString&) {} 419 // 420 // Attribute handling 421 // 422 // give us the attr provider to use - we take ownership of the pointer 423 // wxLua NOT overridable - void SetAttrProvider(wxGridCellAttrProvider *attrProvider); 424 // 425 // get the currently used attr provider (may be NULL); 426 // wxLua NOT overridable - wxGridCellAttrProvider *GetAttrProvider() const { return m_attrProvider; } 427 // 428 // Does this table allow attributes? Default implementation creates 429 // a wxGridCellAttrProvider if necessary. 430 //virtual bool CanHaveAttributes(); 431 // 432 // by default forwarded to wxGridCellAttrProvider if any. May be 433 // overridden to handle attributes directly in the table. 434 //virtual wxGridCellAttr *GetAttr(int row, int col, 435 // wxGridCellAttr::wxAttrKind kind); 436 // 437 // In wxLua it would be much easier to simply store the attributes in your own Lua table and return them in GetAttr(); 438 // wxLua NOT overridable - virtual void SetAttr(wxGridCellAttr* attr, int row, int col); 439 // wxLua NOT overridable - virtual void SetRowAttr(wxGridCellAttr *attr, int row); 440 // wxLua NOT overridable - virtual void SetColAttr(wxGridCellAttr *attr, int col); 441 }; 442 443 // --------------------------------------------------------------------------- 444 // wxGridStringTable 445 446 class %delete wxGridStringTable : public wxGridTableBase 447 { 448 wxGridStringTable(int numRows=0, int numCols=0); 449 }; 450 451 // --------------------------------------------------------------------------- 452 // wxGridTableMessage 453 454 enum wxGridTableRequest 455 { 456 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES, 457 wxGRIDTABLE_REQUEST_VIEW_SEND_VALUES, 458 wxGRIDTABLE_NOTIFY_ROWS_INSERTED, 459 wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 460 wxGRIDTABLE_NOTIFY_ROWS_DELETED, 461 wxGRIDTABLE_NOTIFY_COLS_INSERTED, 462 wxGRIDTABLE_NOTIFY_COLS_APPENDED, 463 wxGRIDTABLE_NOTIFY_COLS_DELETED 464 }; 465 466 467 class %delete wxGridTableMessage 468 { 469 wxGridTableMessage(wxGridTableBase *table, int id, int comInt1 = -1, int comInt2 = -1); 470 471 void SetTableObject(wxGridTableBase *table); 472 wxGridTableBase * GetTableObject() const; 473 void SetId(int id); 474 int GetId(); 475 void SetCommandInt(int comInt1); 476 int GetCommandInt(); 477 void SetCommandInt2(int comInt2); 478 int GetCommandInt2(); 479 }; 480 481 // --------------------------------------------------------------------------- 482 // wxGridCellCoords 483 484 class %delete wxGridCellCoords 485 { 486 #define_object wxGridNoCellCoords 487 488 wxGridCellCoords(int r = -1, int c = -1); 489 490 int GetRow() const; 491 void SetRow(int n); 492 int GetCol() const; 493 void SetCol(int n); 494 void Set(int row, int col); 495 496 wxGridCellCoords& operator=(const wxGridCellCoords& other); 497 bool operator==(const wxGridCellCoords& other) const; 498 bool operator!() const; 499 }; 500 501 // --------------------------------------------------------------------------- 502 // wxGridCellCoordsArray 503 504 #include "wx/dynarray.h" 505 506 class %delete wxGridCellCoordsArray 507 { 508 wxGridCellCoordsArray(); 509 wxGridCellCoordsArray(const wxGridCellCoordsArray& array); 510 511 void Add(const wxGridCellCoords& c); 512 void Alloc(size_t count); 513 void Clear(); 514 int GetCount() const; 515 bool IsEmpty() const; 516 void Insert(const wxGridCellCoords& c, int n, int copies = 1); 517 wxGridCellCoords Item(int n); 518 void RemoveAt(size_t index); 519 void Shrink(); 520 521 wxGridCellCoords operator[](size_t nIndex); 522 }; 523 524 // --------------------------------------------------------------------------- 525 // wxGrid 526 527 enum wxGrid::wxGridSelectionModes 528 { 529 wxGridSelectCells, 530 wxGridSelectRows, 531 wxGridSelectColumns 532 }; 533 534 class wxGrid : public wxScrolledWindow 535 { 536 wxGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString &name = "wxGrid"); 537 538 bool CreateGrid(int numRows, int numCols, wxGrid::wxGridSelectionModes selmode = wxGrid::wxGridSelectCells); 539 540 void SetSelectionMode(wxGrid::wxGridSelectionModes selmode); 541 wxGrid::wxGridSelectionModes GetSelectionMode() const; 542 int GetNumberRows(); 543 int GetNumberCols(); 544 545 //wxArrayInt CalcRowLabelsExposed(const wxRegion& reg); 546 //wxArrayInt CalcColLabelsExposed(const wxRegion& reg); 547 //wxGridCellCoordsArray CalcCellsExposed(const wxRegion& reg); 548 //void ProcessRowLabelMouseEvent(wxMouseEvent& event); 549 //void ProcessColLabelMouseEvent(wxMouseEvent& event); 550 //void ProcessCornerLabelMouseEvent(wxMouseEvent& event); 551 //void ProcessGridCellMouseEvent(wxMouseEvent& event); 552 bool ProcessTableMessage(wxGridTableMessage& msg); 553 //void DoEndDragResizeRow(); 554 //void DoEndDragResizeCol(); 555 556 wxGridTableBase * GetTable() const; 557 558 // %override so that takeOwnership releases the table from garbage collection by Lua 559 bool SetTable(wxGridTableBase * table, bool takeOwnership = false, wxGrid::wxGridSelectionModes selmode = wxGrid::wxGridSelectCells); 560 561 void ClearGrid(); 562 bool InsertRows(int pos = 0, int numRows = 1, bool updateLabels=true); 563 bool AppendRows(int numRows = 1, bool updateLabels=true); 564 bool DeleteRows(int pos = 0, int numRows = 1, bool updateLabels=true); 565 bool InsertCols(int pos = 0, int numCols = 1, bool updateLabels=true); 566 bool AppendCols(int numCols = 1, bool updateLabels=true); 567 bool DeleteCols(int pos = 0, int numCols = 1, bool updateLabels=true); 568 569 //void DrawGridCellArea(wxDC& dc , const wxGridCellCoordsArray& cells); 570 //void DrawGridSpace(wxDC& dc); 571 //void DrawCellBorder(wxDC& dc, const wxGridCellCoords&); 572 //void DrawAllGridLines(wxDC& dc, const wxRegion& reg); 573 //void DrawCell(wxDC& dc, const wxGridCellCoords&); 574 //void DrawHighlight(wxDC& dc, const wxGridCellCoordsArray& cells); 575 //virtual void DrawCellHighlight(wxDC& dc, const wxGridCellAttr *attr); 576 //virtual void DrawRowLabels(wxDC& dc, const wxArrayInt& rows); 577 //virtual void DrawRowLabel(wxDC& dc, int row); 578 //virtual void DrawColLabels(wxDC& dc, const wxArrayInt& cols); 579 //virtual void DrawColLabel(wxDC& dc, int col); 580 void DrawTextRectangle(wxDC& dc, const wxString&, const wxRect&, int horizontalAlignment = wxALIGN_LEFT, int verticalAlignment = wxALIGN_TOP, int textOrientation = wxHORIZONTAL); 581 //void DrawTextRectangle(wxDC& dc, const wxArrayString& lines, const wxRect&, int horizontalAlignment = wxALIGN_LEFT, int verticalAlignment = wxALIGN_TOP, int textOrientation = wxHORIZONTAL); 582 void StringToLines(const wxString& value, wxArrayString& lines); 583 584 // %override [long width, long height] wxGrid::GetTextBoxSize(wxDC& dc, const wxArrayString& lines); 585 // C++ Func: void GetTextBoxSize(wxDC& dc, const wxArrayString& lines, long *width, long *height); 586 void GetTextBoxSize(wxDC& dc, const wxArrayString& lines); 587 588 void BeginBatch(); 589 void EndBatch(); 590 int GetBatchCount(); 591 void ForceRefresh(); 592 593 bool IsEditable(); 594 void EnableEditing(bool edit); 595 void EnableCellEditControl(bool enable = true); 596 void DisableCellEditControl(); 597 bool CanEnableCellControl() const; 598 bool IsCellEditControlEnabled() const; 599 bool IsCellEditControlShown() const; 600 bool IsCurrentCellReadOnly() const; 601 void ShowCellEditControl(); 602 void HideCellEditControl(); 603 void SaveEditControlValue(); 604 605 void XYToCell(int x, int y, wxGridCellCoords& coords); 606 int XToCol(int x); 607 int YToRow(int y); 608 int XToEdgeOfCol(int x); 609 int YToEdgeOfRow(int y); 610 wxRect CellToRect(int row, int col); 611 //wxRect CellToRect(const wxGridCellCoords& coords); 612 int GetGridCursorRow(); 613 int GetGridCursorCol(); 614 bool IsVisible(int row, int col, bool wholeCellVisible = true); 615 //bool IsVisible(const wxGridCellCoords& coords, bool wholeCellVisible = true); 616 void MakeCellVisible(int row, int col); 617 //void MakeCellVisible(const wxGridCellCoords& coords); 618 619 void SetGridCursor(int row, int col); 620 bool MoveCursorUp(bool expandSelection); 621 bool MoveCursorDown(bool expandSelection); 622 bool MoveCursorLeft(bool expandSelection); 623 bool MoveCursorRight(bool expandSelection); 624 bool MovePageDown(); 625 bool MovePageUp(); 626 bool MoveCursorUpBlock(bool expandSelection); 627 bool MoveCursorDownBlock(bool expandSelection); 628 bool MoveCursorLeftBlock(bool expandSelection); 629 bool MoveCursorRightBlock(bool expandSelection); 630 631 int GetDefaultRowLabelSize(); 632 int GetRowLabelSize(); 633 int GetDefaultColLabelSize(); 634 int GetColLabelSize(); 635 wxColour GetLabelBackgroundColour(); 636 wxColour GetLabelTextColour(); 637 wxFont GetLabelFont(); 638 639 // %override [int horiz, int vert] wxGrid::GetRowLabelAlignment(); 640 // C++ Func: void GetRowLabelAlignment(int *horiz, int *vert); 641 void GetRowLabelAlignment(int *horz, int *vert); 642 // %override [int horiz, int vert] wxGrid::GetColLabelAlignment(); 643 // C++ Func: void GetColLabelAlignment(int *horiz, int *vert); 644 void GetColLabelAlignment(int *horz, int *vert); 645 646 int GetColLabelTextOrientation(); 647 wxString GetRowLabelValue(int row); 648 wxString GetColLabelValue(int col); 649 wxColour GetGridLineColour(); 650 wxColour GetCellHighlightColour(); 651 int GetCellHighlightPenWidth(); 652 int GetCellHighlightROPenWidth(); 653 void SetRowLabelSize(int width); 654 void SetColLabelSize(int height); 655 void SetLabelBackgroundColour(const wxColour& backColour); 656 void SetLabelTextColour(const wxColour& textColour); 657 void SetLabelFont(const wxFont& labelFont); 658 void SetRowLabelAlignment(int horiz, int vert); 659 void SetColLabelAlignment(int horiz, int vert); 660 void SetRowLabelValue(int row, const wxString& value); 661 void SetColLabelValue(int col, const wxString& value); 662 void SetGridLineColour(const wxColour& lineColour); 663 void SetCellHighlightColour(const wxColour& highlightColour); 664 void SetCellHighlightPenWidth(int width); 665 void SetCellHighlightROPenWidth(int width); 666 667 void EnableDragRowSize(bool enable = true); 668 void DisableDragRowSize(); 669 670 #if !%wxchkver_3_0 || %wxcompat_2_8 671 bool CanDragColSize(); 672 bool CanDragRowSize(); 673 #endif 674 #if %wxchkver_3_0 675 bool CanDragColSize(int col); 676 bool CanDragRowSize(int row); 677 #endif 678 679 void EnableDragColSize(bool enable = true); 680 void DisableDragColSize(); 681 void EnableDragGridSize(bool enable = true); 682 void DisableDragGridSize(); 683 bool CanDragGridSize(); 684 void EnableDragCell(bool enable = true); 685 void DisableDragCell(); 686 bool CanDragCell(); 687 688 // wxLua calls IncRef() on the input attr since the table will call DecRef() on it. 689 // You should not have to worry about Inc/DecRef() of the attr as you would in C++. 690 void SetAttr(int row, int col, %IncRef wxGridCellAttr *attr); 691 // wxLua calls IncRef() on the input attr since the table will call DecRef() on it. 692 // You should not have to worry about Inc/DecRef() of the attr as you would in C++. 693 void SetRowAttr(int row, %IncRef wxGridCellAttr *attr); 694 // wxLua calls IncRef() on the input attr since the table will call DecRef() on it. 695 // You should not have to worry about Inc/DecRef() of the attr as you would in C++. 696 void SetColAttr(int col, %IncRef wxGridCellAttr *attr); 697 698 // wxLua Note: The grid calls IncRef() on the returned attribute so wxLua will garbage collect it. 699 %gc wxGridCellAttr *GetOrCreateCellAttr(int row, int col) const; 700 701 void SetColFormatBool(int col); 702 void SetColFormatNumber(int col); 703 void SetColFormatFloat(int col, int width = -1, int precision = -1); 704 void SetColFormatCustom(int col, const wxString& typeName); 705 706 void EnableGridLines(bool enable = true); 707 bool GridLinesEnabled(); 708 709 int GetDefaultRowSize(); 710 int GetRowSize(int row); 711 int GetDefaultColSize(); 712 int GetColSize(int col); 713 wxColour GetDefaultCellBackgroundColour(); 714 wxColour GetCellBackgroundColour(int row, int col); 715 wxColour GetDefaultCellTextColour(); 716 wxColour GetCellTextColour(int row, int col); 717 wxFont GetDefaultCellFont(); 718 wxFont GetCellFont(int row, int col); 719 720 // %override [int horiz, int vert] wxGrid::GetDefaultCellAlignment(); 721 // C++ Func: void GetDefaultCellAlignment(int *horiz, int *vert); 722 void GetDefaultCellAlignment(int *horiz, int *vert); 723 724 // %override [int horiz, int vert] wxGrid::GetCellAlignment(int row, int col); 725 // C++ Func: void GetCellAlignment(int row, int col, int *horiz, int *vert); 726 void GetCellAlignment(int row, int col); 727 728 bool GetDefaultCellOverflow(); 729 bool GetCellOverflow(int row, int col); 730 731 // %override [int num_rows, int num_cols] wxGrid::GetCellSize(int row, int col); 732 // C++ Func: void GetCellSize(int row, int col, int *num_rows, int *num_cols); 733 void GetCellSize(int row, int col); 734 735 void SetDefaultRowSize(int height, bool resizeExistingRows = false); 736 void SetRowSize(int row, int height); 737 void SetDefaultColSize(int width, bool resizeExistingCols = false); 738 void SetColSize(int col, int width); 739 void AutoSize(); 740 void AutoSizeRow(int row, bool setAsMin = true); 741 void AutoSizeColumn(int col, bool setAsMin = true); 742 void AutoSizeRows(bool setAsMin = true); 743 void AutoSizeColumns(bool setAsMin = true); 744 void AutoSizeRowLabelSize(int row); 745 void AutoSizeColLabelSize(int col); 746 747 void SetColMinimalWidth(int col, int width); 748 void SetRowMinimalHeight(int row, int width); 749 void SetColMinimalAcceptableWidth(int width); 750 void SetRowMinimalAcceptableHeight(int width); 751 int GetColMinimalAcceptableWidth() const; 752 int GetRowMinimalAcceptableHeight() const; 753 754 void SetDefaultCellBackgroundColour(const wxColour& backColour); 755 void SetCellBackgroundColour(int row, int col, const wxColour& backColour); 756 void SetDefaultCellTextColour(const wxColour& textColour); 757 void SetCellTextColour(int row, int col, const wxColour& textColour); 758 void SetDefaultCellFont(const wxFont& cellFont); 759 void SetCellFont(int row, int col, const wxFont& cellFont); 760 void SetDefaultCellAlignment(int horiz, int vert); 761 void SetCellAlignment(int row, int col, int horiz, int vert); 762 void SetDefaultCellOverflow(bool allow); 763 void SetCellOverflow(int row, int col, bool allow); 764 void SetCellSize(int row, int col, int num_rows, int num_cols); 765 766 // wxLua calls IncRef() on the input renderer since the table will call DecRef() on it. 767 // You should not have to worry about Inc/DecRef() of the attr as you would in C++. 768 void SetDefaultRenderer(%IncRef wxGridCellRenderer *renderer); 769 // wxLua calls IncRef() on the input renderer since the table will call DecRef() on it. 770 // You should not have to worry about Inc/DecRef() of the attr as you would in C++. 771 void SetCellRenderer(int row, int col, %IncRef wxGridCellRenderer *renderer); 772 773 // wxLua Note: The grid calls IncRef() on the returned renderer so wxLua will garbage collect it. 774 %gc wxGridCellRenderer* GetDefaultRenderer() const; 775 // wxLua Note: The grid calls IncRef() on the returned renderer so wxLua will garbage collect it. 776 %gc wxGridCellRenderer* GetCellRenderer(int row, int col); 777 778 // wxLua calls IncRef() on the input editor since the table will call DecRef() on it. 779 // You should not have to worry about Inc/DecRef() of the attr as you would in C++. 780 void SetDefaultEditor(%IncRef wxGridCellEditor *editor); 781 // wxLua calls IncRef() on the input editor since the table will call DecRef() on it. 782 // You should not have to worry about Inc/DecRef() of the attr as you would in C++. 783 void SetCellEditor(int row, int col, %IncRef wxGridCellEditor *editor); 784 785 // wxLua Note: The grid calls IncRef() on the returned editor so wxLua will garbage collect it. 786 %gc wxGridCellEditor* GetDefaultEditor() const; 787 // wxLua Note: The grid calls IncRef() on the returned editor so wxLua will garbage collect it. 788 %gc wxGridCellEditor* GetCellEditor(int row, int col); 789 790 wxString GetCellValue(int row, int col); 791 // wxString GetCellValue(const wxGridCellCoords& coords); 792 void SetCellValue(int row, int col, const wxString& s); 793 // void SetCellValue(const wxGridCellCoords& coords, const wxString& s); 794 795 bool IsReadOnly(int row, int col) const; 796 void SetReadOnly(int row, int col, bool isReadOnly = true); 797 798 void SelectRow(int row, bool addToSelected = false); 799 void SelectCol(int col, bool addToSelected = false); 800 void SelectBlock(int topRow, int leftCol, int bottomRow, int rightCol, bool addToSelected = false); 801 // void SelectBlock(const wxGridCellCoords& topLeft, const wxGridCellCoords& bottomRight); 802 void SelectAll(); 803 bool IsSelection(); 804 void DeselectRow(int row); 805 void DeselectCol(int col); 806 void DeselectCell(int row, int col); 807 void ClearSelection(); 808 bool IsInSelection(int row, int col); 809 // bool IsInSelection(const wxGridCellCoords& coords); 810 811 wxGridCellCoordsArray GetSelectedCells() const; 812 wxGridCellCoordsArray GetSelectionBlockTopLeft() const; 813 wxGridCellCoordsArray GetSelectionBlockBottomRight() const; 814 wxArrayInt GetSelectedRows() const; 815 wxArrayInt GetSelectedCols() const; 816 817 wxRect BlockToDeviceRect(const wxGridCellCoords& topLeft, const wxGridCellCoords& bottomRight); 818 819 wxColour GetSelectionBackground() const; 820 wxColour GetSelectionForeground() const; 821 void SetSelectionBackground(const wxColour& c); 822 void SetSelectionForeground(const wxColour& c); 823 824 // wxLua calls IncRef() on the input renderer and editor since the table will call DecRef() on it. 825 // You should not have to worry about Inc/DecRef() of the attr as you would in C++. 826 void RegisterDataType(const wxString& typeName, %IncRef wxGridCellRenderer* renderer, %IncRef wxGridCellEditor* editor); 827 828 // wxLua Note: The grid calls IncRef() on the returned editor so wxLua will garbage collect it. 829 %gc wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const; 830 //wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& coords) const; 831 // wxLua Note: The grid calls IncRef() on the returned renderer so wxLua will garbage collect it. 832 %gc wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const; 833 // wxLua Note: The grid calls IncRef() on the returned editor so wxLua will garbage collect it. 834 %gc wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const; 835 // wxLua Note: The grid calls IncRef() on the returned renderer so wxLua will garbage collect it. 836 %gc wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const; 837 838 void SetMargins(int extraWidth, int extraHeight); 839 840 wxWindow* GetGridWindow(); 841 wxWindow* GetGridRowLabelWindow(); 842 wxWindow* GetGridColLabelWindow(); 843 wxWindow* GetGridCornerLabelWindow(); 844 845 //void SetScrollLineX(int x); 846 //void SetScrollLineY(int y); 847 //int GetScrollLineX() const; 848 //int GetScrollLineY() const; 849 //int GetScrollX(int x) const; 850 //int GetScrollY(int y) const; 851 }; 852 853 // --------------------------------------------------------------------------- 854 // wxGridEvent 855 856 class %delete wxGridEvent : public wxNotifyEvent 857 { 858 %wxEventType wxEVT_GRID_CELL_LEFT_CLICK // EVT_GRID_CELL_LEFT_CLICK(fn); // FIXME! wxEVT_CMD_GRID_XXX in > 2.6 859 %wxEventType wxEVT_GRID_CELL_RIGHT_CLICK // EVT_GRID_CELL_RIGHT_CLICK(fn); 860 %wxEventType wxEVT_GRID_CELL_LEFT_DCLICK // EVT_GRID_CELL_LEFT_DCLICK(fn); 861 %wxEventType wxEVT_GRID_CELL_RIGHT_DCLICK // EVT_GRID_CELL_RIGHT_DCLICK(fn); 862 %wxEventType wxEVT_GRID_LABEL_LEFT_CLICK // EVT_GRID_LABEL_LEFT_CLICK(fn); 863 %wxEventType wxEVT_GRID_LABEL_RIGHT_CLICK // EVT_GRID_LABEL_RIGHT_CLICK(fn); 864 %wxEventType wxEVT_GRID_LABEL_LEFT_DCLICK // EVT_GRID_LABEL_LEFT_DCLICK(fn); 865 %wxEventType wxEVT_GRID_LABEL_RIGHT_DCLICK // EVT_GRID_LABEL_RIGHT_DCLICK(fn); 866 %wxEventType wxEVT_GRID_SELECT_CELL // EVT_GRID_SELECT_CELL(fn); 867 %wxEventType wxEVT_GRID_EDITOR_SHOWN // EVT_GRID_EDITOR_SHOWN(fn); 868 %wxEventType wxEVT_GRID_EDITOR_HIDDEN // EVT_GRID_EDITOR_HIDDEN(fn); 869 %wxEventType wxEVT_GRID_CELL_BEGIN_DRAG // EVT_GRID_CELL_BEGIN_DRAG(fn); 870 871 #if !%wxchkver_3_0 || %wxcompat_2_8 872 %wxEventType wxEVT_GRID_CELL_CHANGE // EVT_GRID_CELL_CHANGE(fn); 873 #endif 874 #if %wxchkver_3_0 875 %wxEventType wxEVT_GRID_CELL_CHANGING // EVT_GRID_CELL_CHANGE(fn); 876 %wxEventType wxEVT_GRID_CELL_CHANGED // EVT_GRID_CELL_CHANGE(fn); 877 #endif 878 879 !%wxchkver_2_9_0 wxGridEvent(int id, wxEventType type, wxObject* obj, int row = -1, int col = -1, int x = -1, int y = -1, bool sel = true, bool control = false, bool shift = false, bool alt = false, bool meta = false); 880 881 virtual int GetRow(); 882 virtual int GetCol(); 883 wxPoint GetPosition(); 884 bool Selecting(); 885 bool ControlDown(); 886 bool MetaDown(); 887 bool ShiftDown(); 888 bool AltDown(); 889 }; 890 891 // --------------------------------------------------------------------------- 892 // wxGridSizeEvent 893 894 class %delete wxGridSizeEvent : public wxNotifyEvent 895 { 896 %wxEventType wxEVT_GRID_ROW_SIZE // EVT_GRID_CMD_ROW_SIZE(id, fn); 897 %wxEventType wxEVT_GRID_COL_SIZE // EVT_GRID_CMD_COL_SIZE(id, fn); 898 899 !%wxchkver_2_9_0 wxGridSizeEvent(int id, wxEventType type, wxObject* obj, int rowOrCol = -1, int x = -1, int y = -1, bool control = false, bool shift = false, bool alt = false, bool meta = false); 900 901 int GetRowOrCol(); 902 wxPoint GetPosition(); 903 bool ShiftDown(); 904 bool ControlDown(); 905 bool AltDown(); 906 bool MetaDown(); 907 }; 908 909 // --------------------------------------------------------------------------- 910 // wxGridRangeSelectEvent 911 912 class %delete wxGridRangeSelectEvent : public wxNotifyEvent 913 { 914 %wxEventType wxEVT_GRID_RANGE_SELECT // EVT_GRID_CMD_RANGE_SELECT(id, fn); 915 916 !%wxchkver_2_9_0 wxGridRangeSelectEvent(int id, wxEventType type, wxObject* obj, const wxGridCellCoords& topLeft, const wxGridCellCoords& bottomRight, bool sel = true, bool control = false, bool shift = false, bool alt = false, bool meta = false); 917 918 wxGridCellCoords GetTopLeftCoords(); 919 wxGridCellCoords GetBottomRightCoords(); 920 int GetTopRow(); 921 int GetBottomRow(); 922 int GetLeftCol(); 923 int GetRightCol(); 924 bool Selecting(); 925 bool ControlDown(); 926 bool ShiftDown(); 927 bool MetaDown(); 928 bool AltDown(); 929 }; 930 931 // --------------------------------------------------------------------------- 932 // wxGridEditorCreatedEvent 933 934 class %delete wxGridEditorCreatedEvent : public wxCommandEvent 935 { 936 %wxEventType wxEVT_GRID_EDITOR_CREATED // EVT_GRID_EDITOR_CREATED(fn); 937 938 wxGridEditorCreatedEvent(int id, wxEventType type, wxObject* obj, int row, int col, wxControl* ctrl); 939 940 int GetRow(); 941 int GetCol(); 942 wxControl* GetControl(); 943 void SetRow(int row); 944 void SetCol(int col); 945 void SetControl(wxControl * ctrl); 946 }; 947 948 #endif //wxLUA_USE_wxGrid && wxUSE_GRID 949