1999-10-06 00:58:38 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: griddemo.h
|
|
|
|
// Purpose: Grid control wxWindows sample
|
|
|
|
// Author: Michael Bedward
|
|
|
|
// Modified by:
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Michael Bedward, Julian Smart
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
1999-10-06 00:55:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef griddemo_h
|
|
|
|
#define griddemo_h
|
|
|
|
|
2000-02-09 15:30:27 -05:00
|
|
|
#if !defined(wxUSE_NEW_GRID) || !(wxUSE_NEW_GRID)
|
|
|
|
#error "This sample requires the new wxGrid class."
|
|
|
|
#endif
|
1999-10-06 00:55:17 -04:00
|
|
|
|
|
|
|
class wxGrid;
|
|
|
|
|
|
|
|
class GridApp : public wxApp
|
|
|
|
{
|
2000-02-11 14:40:56 -05:00
|
|
|
public:
|
1999-10-06 00:55:17 -04:00
|
|
|
bool OnInit();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class GridFrame : public wxFrame
|
|
|
|
{
|
|
|
|
wxGrid *grid;
|
|
|
|
wxTextCtrl *logWin;
|
|
|
|
wxLogTextCtrl *logger;
|
|
|
|
wxString logBuf;
|
|
|
|
|
|
|
|
void SetDefaults();
|
2000-02-03 01:07:07 -05:00
|
|
|
|
1999-10-06 00:55:17 -04:00
|
|
|
void ToggleRowLabels( wxCommandEvent& );
|
|
|
|
void ToggleColLabels( wxCommandEvent& );
|
2000-02-03 01:07:07 -05:00
|
|
|
void ToggleEditing( wxCommandEvent& );
|
1999-10-06 00:55:17 -04:00
|
|
|
void SetLabelColour( wxCommandEvent& );
|
|
|
|
void SetLabelTextColour( wxCommandEvent& );
|
|
|
|
void SetRowLabelHorizAlignment( wxCommandEvent& );
|
|
|
|
void SetRowLabelVertAlignment( wxCommandEvent& );
|
|
|
|
void SetColLabelHorizAlignment( wxCommandEvent& );
|
|
|
|
void SetColLabelVertAlignment( wxCommandEvent& );
|
|
|
|
void SetGridLineColour( wxCommandEvent& );
|
1999-10-13 07:57:22 -04:00
|
|
|
|
2000-02-11 14:40:56 -05:00
|
|
|
void SetCellFgColour(wxCommandEvent &);
|
|
|
|
void SetCellBgColour(wxCommandEvent &);
|
|
|
|
|
2000-02-09 15:30:27 -05:00
|
|
|
void InsertRow( wxCommandEvent& );
|
|
|
|
void InsertCol( wxCommandEvent& );
|
|
|
|
void DeleteSelectedRows( wxCommandEvent& );
|
|
|
|
void DeleteSelectedCols( wxCommandEvent& );
|
1999-10-06 00:55:17 -04:00
|
|
|
void ClearGrid( wxCommandEvent& );
|
|
|
|
|
|
|
|
void OnLabelLeftClick( wxGridEvent& );
|
|
|
|
void OnCellLeftClick( wxGridEvent& );
|
|
|
|
void OnRowSize( wxGridSizeEvent& );
|
|
|
|
void OnColSize( wxGridSizeEvent& );
|
1999-10-19 03:27:56 -04:00
|
|
|
void OnSelectCell( wxGridEvent& );
|
1999-10-06 00:55:17 -04:00
|
|
|
void OnRangeSelected( wxGridRangeSelectEvent& );
|
|
|
|
void OnCellValueChanged( wxGridEvent& );
|
2000-02-09 15:30:27 -05:00
|
|
|
|
2000-02-17 05:12:48 -05:00
|
|
|
void OnEditorShown(wxGridEvent&);
|
|
|
|
void OnEditorHidden(wxGridEvent&);
|
|
|
|
|
2000-02-11 14:40:56 -05:00
|
|
|
public:
|
1999-10-06 00:55:17 -04:00
|
|
|
GridFrame();
|
|
|
|
~GridFrame();
|
|
|
|
|
|
|
|
void OnQuit( wxCommandEvent& );
|
2000-02-03 01:07:07 -05:00
|
|
|
void About( wxCommandEvent& );
|
2000-02-13 00:38:03 -05:00
|
|
|
void OnVTable( wxCommandEvent& );
|
1999-10-06 00:55:17 -04:00
|
|
|
|
2000-02-11 14:40:56 -05:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
ID_TOGGLEROWLABELS = 100,
|
|
|
|
ID_TOGGLECOLLABELS,
|
|
|
|
ID_TOGGLEEDIT,
|
|
|
|
ID_SETLABELCOLOUR,
|
|
|
|
ID_SETLABELTEXTCOLOUR,
|
|
|
|
ID_ROWLABELALIGN,
|
|
|
|
ID_ROWLABELHORIZALIGN,
|
|
|
|
ID_ROWLABELVERTALIGN,
|
|
|
|
ID_COLLABELALIGN,
|
|
|
|
ID_COLLABELHORIZALIGN,
|
|
|
|
ID_COLLABELVERTALIGN,
|
|
|
|
ID_GRIDLINECOLOUR,
|
|
|
|
ID_INSERTROW,
|
|
|
|
ID_INSERTCOL,
|
|
|
|
ID_DELETEROW,
|
|
|
|
ID_DELETECOL,
|
|
|
|
ID_CLEARGRID,
|
|
|
|
ID_SET_CELL_FG_COLOUR,
|
|
|
|
ID_SET_CELL_BG_COLOUR,
|
|
|
|
ID_ABOUT,
|
2000-02-13 00:38:03 -05:00
|
|
|
ID_VTABLE,
|
2000-02-11 14:40:56 -05:00
|
|
|
|
|
|
|
ID_TESTFUNC
|
|
|
|
};
|
2000-02-09 15:30:27 -05:00
|
|
|
|
1999-10-06 00:55:17 -04:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
2000-02-11 14:40:56 -05:00
|
|
|
class MyGridCellRenderer : public wxGridCellStringRenderer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void Draw(wxGrid& grid,
|
2000-02-13 00:38:03 -05:00
|
|
|
wxGridCellAttr& attr,
|
2000-02-11 14:40:56 -05:00
|
|
|
wxDC& dc,
|
|
|
|
const wxRect& rect,
|
|
|
|
int row, int col,
|
|
|
|
bool isSelected);
|
|
|
|
};
|
1999-10-06 00:55:17 -04:00
|
|
|
|
2000-02-21 12:37:07 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// demonstration of virtual table which doesn't store all of its data in
|
|
|
|
// memory
|
|
|
|
// ----------------------------------------------------------------------------
|
2000-02-13 00:38:03 -05:00
|
|
|
|
2000-02-21 12:37:07 -05:00
|
|
|
class BigGridTable : public wxGridTableBase
|
|
|
|
{
|
2000-02-13 00:38:03 -05:00
|
|
|
public:
|
2000-02-21 12:37:07 -05:00
|
|
|
BigGridTable(long sizeGrid) { m_sizeGrid = sizeGrid; }
|
|
|
|
|
|
|
|
long GetNumberRows() { return m_sizeGrid; }
|
|
|
|
long GetNumberCols() { return m_sizeGrid; }
|
2000-02-13 00:38:03 -05:00
|
|
|
|
2000-02-21 12:37:07 -05:00
|
|
|
wxString GetValue( int row, int col )
|
|
|
|
{
|
|
|
|
return wxString::Format("(%d, %d)", row, col);
|
2000-02-13 00:38:03 -05:00
|
|
|
}
|
|
|
|
|
2000-02-21 12:37:07 -05:00
|
|
|
void SetValue( int , int , const wxString& ) { /* ignore */ }
|
2000-02-13 00:38:03 -05:00
|
|
|
bool IsEmptyCell( int , int ) { return FALSE; }
|
2000-02-21 12:37:07 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
long m_sizeGrid;
|
2000-02-13 00:38:03 -05:00
|
|
|
};
|
|
|
|
|
2000-02-21 12:37:07 -05:00
|
|
|
class BigGridFrame : public wxFrame
|
|
|
|
{
|
2000-02-13 00:38:03 -05:00
|
|
|
public:
|
2000-02-21 12:37:07 -05:00
|
|
|
BigGridFrame(long sizeGrid);
|
2000-02-13 00:38:03 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
wxGrid* m_grid;
|
|
|
|
BigGridTable* m_table;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-02-21 12:37:07 -05:00
|
|
|
#endif // griddemo_h
|
1999-10-06 00:55:17 -04:00
|
|
|
|