class WXDLLEXPORT wxGridTypeRegistry;
class WXDLLEXPORT wxCheckBox;
+class WXDLLEXPORT wxComboBox;
class WXDLLEXPORT wxTextCtrl;
class WXDLLEXPORT wxSpinCtrl;
int row, int col,
bool isSelected) = 0;
+ // get the preferred size of the cell for its contents
+ virtual wxSize GetBestSize(wxGrid& grid,
+ wxGridCellAttr& attr,
+ wxDC& dc,
+ int row, int col) = 0;
+
// virtual dtor for any base class
virtual ~wxGridCellRenderer();
};
int row, int col,
bool isSelected);
+ // return the string extent
+ virtual wxSize GetBestSize(wxGrid& grid,
+ wxGridCellAttr& attr,
+ wxDC& dc,
+ int row, int col);
+
protected:
// set the text colours before drawing
void SetTextColoursAndFont(wxGrid& grid,
wxGridCellAttr& attr,
wxDC& dc,
bool isSelected);
+
+ // calc the string extent for given string/font
+ wxSize DoGetBestSize(wxGridCellAttr& attr,
+ wxDC& dc,
+ const wxString& text);
};
// the default renderer for the cells containing numeric (long) data
const wxRect& rect,
int row, int col,
bool isSelected);
+
+ virtual wxSize GetBestSize(wxGrid& grid,
+ wxGridCellAttr& attr,
+ wxDC& dc,
+ int row, int col);
+
+protected:
+ wxString GetString(wxGrid& grid, int row, int col);
};
class WXDLLEXPORT wxGridCellFloatRenderer : public wxGridCellStringRenderer
int row, int col,
bool isSelected);
+ virtual wxSize GetBestSize(wxGrid& grid,
+ wxGridCellAttr& attr,
+ wxDC& dc,
+ int row, int col);
+protected:
+ wxString GetString(wxGrid& grid, int row, int col);
+
private:
// formatting parameters
int m_width,
const wxRect& rect,
int row, int col,
bool isSelected);
+
+ // return the checkmark size
+ virtual wxSize GetBestSize(wxGrid& grid,
+ wxGridCellAttr& attr,
+ wxDC& dc,
+ int row, int col);
+
+private:
+ static wxSize ms_sizeCheckMark;
};
// ----------------------------------------------------------------------------
// to begin editing. Set the focus to the edit control.
virtual void BeginEdit(int row, int col, wxGrid* grid) = 0;
- // Complete the editing of the current cell. If saveValue is
- // true then send the new value back to the table. Returns true
- // if the value has changed. If necessary, the control may be
- // destroyed.
- virtual bool EndEdit(int row, int col, bool saveValue, wxGrid* grid) = 0;
+ // Complete the editing of the current cell. Returns true if the value has
+ // changed. If necessary, the control may be destroyed.
+ virtual bool EndEdit(int row, int col, wxGrid* grid) = 0;
// Reset the value in the control back to its starting value
virtual void Reset() = 0;
virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
virtual void BeginEdit(int row, int col, wxGrid* grid);
- virtual bool EndEdit(int row, int col, bool saveValue, wxGrid* grid);
+ virtual bool EndEdit(int row, int col, wxGrid* grid);
virtual void Reset();
virtual void StartingKey(wxKeyEvent& event);
wxEvtHandler* evtHandler);
virtual void BeginEdit(int row, int col, wxGrid* grid);
- virtual bool EndEdit(int row, int col, bool saveValue, wxGrid* grid);
+ virtual bool EndEdit(int row, int col, wxGrid* grid);
virtual void Reset();
virtual void StartingKey(wxKeyEvent& event);
wxEvtHandler* evtHandler);
virtual void BeginEdit(int row, int col, wxGrid* grid);
- virtual bool EndEdit(int row, int col, bool saveValue, wxGrid* grid);
+ virtual bool EndEdit(int row, int col, wxGrid* grid);
virtual void Reset();
virtual void StartingKey(wxKeyEvent& event);
virtual void Show(bool show, wxGridCellAttr *attr = (wxGridCellAttr *)NULL);
virtual void BeginEdit(int row, int col, wxGrid* grid);
- virtual bool EndEdit(int row, int col, bool saveValue, wxGrid* grid);
+ virtual bool EndEdit(int row, int col, wxGrid* grid);
virtual void Reset();
virtual void StartingClick();
bool m_startValue;
};
+// the editor for string data allowing to choose from the list of strings
+class WXDLLEXPORT wxGridCellChoiceEditor : public wxGridCellEditor
+{
+public:
+ // if !allowOthers, user can't type a string not in choices array
+ wxGridCellChoiceEditor(size_t count, const wxChar* choices[],
+ bool allowOthers = FALSE);
+
+ virtual void Create(wxWindow* parent,
+ wxWindowID id,
+ wxEvtHandler* evtHandler);
+
+ virtual void PaintBackground(const wxRect& rectCell, wxGridCellAttr *attr);
+
+ virtual void BeginEdit(int row, int col, wxGrid* grid);
+ virtual bool EndEdit(int row, int col, wxGrid* grid);
+
+ virtual void Reset();
+
+protected:
+ wxComboBox *Combo() const { return (wxComboBox *)m_control; }
+
+private:
+ wxString m_startValue;
+ wxArrayString m_choices;
+ bool m_allowOthers;
+};
// ----------------------------------------------------------------------------
// wxGridCellAttr: this class can be used to alter the cells appearance in
// the grid by changing their colour/font/... from default. An object of this
const wxColour& GetBackgroundColour() const;
const wxFont& GetFont() const;
void GetAlignment(int *hAlign, int *vAlign) const;
- wxGridCellRenderer *GetRenderer(wxGridCellRenderer* def) const;
- wxGridCellEditor *GetEditor(wxGridCellEditor* def) const;
+ wxGridCellRenderer *GetRenderer(wxGrid* grid, int row, int col) const;
+ wxGridCellEditor *GetEditor(wxGrid* grid, int row, int col) const;
bool IsReadOnly() const { return m_isReadOnly; }
bool DeleteCols( int pos = 0, int numCols = 1, bool updateLabels=TRUE );
void DrawGridCellArea( wxDC& dc );
+ void DrawGridSpace( wxDC& dc );
void DrawCellBorder( wxDC& dc, const wxGridCellCoords& );
void DrawAllGridLines( wxDC& dc, const wxRegion & reg );
void DrawCell( wxDC& dc, const wxGridCellCoords& );
void ShowCellEditControl();
void HideCellEditControl();
- void SetEditControlValue( const wxString& s = wxEmptyString );
void SaveEditControlValue();
void SetRowLabelValue( int row, const wxString& );
void SetColLabelValue( int col, const wxString& );
void SetGridLineColour( const wxColour& );
-
+
void EnableDragRowSize( bool enable = TRUE );
void DisableDragRowSize() { EnableDragRowSize( FALSE ); }
bool CanDragRowSize() { return m_canDragRowSize; }
void EnableDragColSize( bool enable = TRUE );
void DisableDragColSize() { EnableDragColSize( FALSE ); }
bool CanDragColSize() { return m_canDragColSize; }
+ void EnableDragGridSize(bool enable = TRUE);
+ void DisableDragGridSize() { EnableDragGridSize(FALSE); }
+ bool CanDragGridSize() { return m_canDragGridSize; }
+
// this sets the specified attribute for all cells in this row/col
void SetRowAttr(int row, wxGridCellAttr *attr);
void SetColSize( int col, int width );
+ // automatically size the column to fit to its contents, if setAsMin is
+ // TRUE, this optimal width will also be set as minimal width for this
+ // column
+ void AutoSizeColumn( int col, bool setAsMin = TRUE );
+
+ // auto size all columns (very ineffective for big grids!)
+ void AutoSizeColumns( bool setAsMin = TRUE );
+
// column won't be resized to be lesser width - this must be called during
// the grid creation because it won't resize the column if it's already
// narrower than the minimal width
bool m_canDragRowSize;
bool m_canDragColSize;
+ bool m_canDragGridSize;
int m_dragLastPos;
int m_dragRowOrCol;
bool m_isDragging;
DECLARE_EVENT_TABLE()
};
-
-
// ----------------------------------------------------------------------------
// Grid event class and event types
// ----------------------------------------------------------------------------