/////////////////////////////////////////////////////////////////////////////
// Name: griddemo.cpp
-// Purpose: Grid control wxWindows sample
+// Purpose: Grid control wxWidgets sample
// Author: Michael Bedward
// Modified by:
// RCS-ID: $Id$
// headers
// ----------------------------------------------------------------------------
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(__APPLE__)
#pragma implementation
#pragma interface
#endif
#include "wx/colordlg.h"
#include "wx/fontdlg.h"
+#include "wx/numdlg.h"
#include "wx/grid.h"
#include "wx/generic/gridctrl.h"
bool GridApp::OnInit()
{
GridFrame *frame = new GridFrame;
- frame->Show( TRUE );
+ frame->Show(true);
- return TRUE;
+ return true;
}
// ----------------------------------------------------------------------------
GridFrame::GridFrame()
- : wxFrame( (wxFrame *)NULL, -1, _T("wxWindows grid class demo"),
+ : wxFrame( (wxFrame *)NULL, wxID_ANY, _T("wxWidgets grid class demo"),
wxDefaultPosition,
wxDefaultSize )
{
SetMenuBar( menuBar );
- m_addToSel = FALSE;
+ m_addToSel = false;
grid = new wxGrid( this,
- -1,
+ wxID_ANY,
wxPoint( 0, 0 ),
wxSize( 400, 300 ) );
logWin = new wxTextCtrl( this,
- -1,
+ wxID_ANY,
wxEmptyString,
wxPoint( 0, gridH + 20 ),
wxSize( logW, logH ),
grid->SetCellEditor(4, 0, new wxGridCellChoiceEditor(WXSIZEOF(choices), choices));
grid->SetCellSize(4, 0, 1, 2);
grid->SetCellValue(4, 0, choices[0]);
- grid->SetCellOverflow(4, 0, FALSE);
+ grid->SetCellOverflow(4, 0, false);
grid->SetCellSize(7, 1, 3, 4);
grid->SetCellAlignment(7, 1, wxALIGN_CENTRE, wxALIGN_CENTRE);
0,
wxEXPAND );
- SetAutoLayout( TRUE );
+ SetAutoLayout(true);
SetSizer( topSizer );
topSizer->Fit( this );
void GridFrame::SetDefaults()
{
- GetMenuBar()->Check( ID_TOGGLEROWLABELS, TRUE );
- GetMenuBar()->Check( ID_TOGGLECOLLABELS, TRUE );
- GetMenuBar()->Check( ID_TOGGLEEDIT, TRUE );
- GetMenuBar()->Check( ID_TOGGLEROWSIZING, TRUE );
- GetMenuBar()->Check( ID_TOGGLECOLSIZING, TRUE );
- GetMenuBar()->Check( ID_TOGGLEGRIDSIZING, TRUE );
- GetMenuBar()->Check( ID_TOGGLEGRIDLINES, TRUE );
- GetMenuBar()->Check( ID_CELLOVERFLOW, TRUE );
+ GetMenuBar()->Check( ID_TOGGLEROWLABELS, true );
+ GetMenuBar()->Check( ID_TOGGLECOLLABELS, true );
+ GetMenuBar()->Check( ID_TOGGLEEDIT, true );
+ GetMenuBar()->Check( ID_TOGGLEROWSIZING, true );
+ GetMenuBar()->Check( ID_TOGGLECOLSIZING, true );
+ GetMenuBar()->Check( ID_TOGGLEGRIDSIZING, true );
+ GetMenuBar()->Check( ID_TOGGLEGRIDLINES, true );
+ GetMenuBar()->Check( ID_CELLOVERFLOW, true );
}
break;
}
- grid->SetRowLabelAlignment( horiz, -1 );
+ grid->SetRowLabelAlignment( horiz, vert );
}
void GridFrame::SetRowLabelVertAlignment( wxCommandEvent& WXUNUSED(ev) )
break;
}
- grid->SetRowLabelAlignment( -1, vert );
+ grid->SetRowLabelAlignment( horiz, vert );
}
break;
}
- grid->SetColLabelAlignment( horiz, -1 );
+ grid->SetColLabelAlignment( horiz, vert );
}
break;
}
- grid->SetColLabelAlignment( -1, vert );
+ grid->SetColLabelAlignment( horiz, vert );
}
// which exactly fits the grid.
wxRect r(wxPoint(0, 0), grid->GetSize());
grid->SetDefaultCellBackgroundColour(col);
- grid->Refresh(TRUE, &r);
+ grid->Refresh(true, &r);
}
}
void GridFrame::OnQuit( wxCommandEvent& WXUNUSED(ev) )
{
- Close( TRUE );
+ Close( true );
}
void GridFrame::OnBugsTable(wxCommandEvent& )
{
BugsGridFrame *frame = new BugsGridFrame;
- frame->Show(TRUE);
+ frame->Show(true);
}
void GridFrame::OnSmallGrid(wxCommandEvent& )
{
- wxFrame* frame = new wxFrame(NULL, -1, _T("A Small Grid"),
+ wxFrame* frame = new wxFrame(NULL, wxID_ANY, _T("A Small Grid"),
wxDefaultPosition, wxSize(640, 480));
- wxPanel* panel = new wxPanel(frame, -1);
- wxGrid* grid = new wxGrid(panel, -1, wxPoint(10,10), wxSize(400,400),
+ wxPanel* panel = new wxPanel(frame, wxID_ANY);
+ wxGrid* grid = new wxGrid(panel, wxID_ANY, wxPoint(10,10), wxSize(400,400),
wxWANTS_CHARS | wxSIMPLE_BORDER);
grid->CreateGrid(3,3);
- frame->Show(TRUE);
+ frame->Show(true);
}
void GridFrame::OnVTable(wxCommandEvent& )
if ( s_sizeGrid != -1 )
{
BigGridFrame* win = new BigGridFrame(s_sizeGrid);
- win->Show(TRUE);
+ win->Show(true);
}
}
// ============================================================================
BigGridFrame::BigGridFrame(long sizeGrid)
- : wxFrame(NULL, -1, _T("Plugin Virtual Table"),
+ : wxFrame(NULL, wxID_ANY, _T("Plugin Virtual Table"),
wxDefaultPosition, wxSize(500, 450))
{
- m_grid = new wxGrid(this, -1, wxDefaultPosition, wxDefaultSize);
+ m_grid = new wxGrid(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
m_table = new BigGridTable(sizeGrid);
// VZ: I don't understand why this slows down the display that much,
// must profile it...
//m_table->SetAttrProvider(new MyGridCellAttrProvider);
- m_grid->SetTable(m_table, TRUE);
+ m_grid->SetTable(m_table, true);
#if defined __WXMOTIF__
// MB: the grid isn't getting a sensible default size under wxMotif
bool opened;
} gs_dataBugsGrid [] =
{
- { 18, _T("foo doesn't work"), Sev_Major, 1, _T("wxMSW"), TRUE },
- { 27, _T("bar crashes"), Sev_Critical, 1, _T("all"), FALSE },
- { 45, _T("printing is slow"), Sev_Minor, 3, _T("wxMSW"), TRUE },
- { 68, _T("Rectangle() fails"), Sev_Normal, 1, _T("wxMSW"), FALSE },
+ { 18, _T("foo doesn't work"), Sev_Major, 1, _T("wxMSW"), true },
+ { 27, _T("bar crashes"), Sev_Critical, 1, _T("all"), false },
+ { 45, _T("printing is slow"), Sev_Minor, 3, _T("wxMSW"), true },
+ { 68, _T("Rectangle() fails"), Sev_Normal, 1, _T("wxMSW"), false },
};
static const wxChar *headers[Col_Max] =
return Col_Max;
}
-bool BugsGridTable::IsEmptyCell( int row, int col )
+bool BugsGridTable::IsEmptyCell( int WXUNUSED(row), int WXUNUSED(col) )
{
- return FALSE;
+ return false;
}
wxString BugsGridTable::GetValue( int row, int col )
{
if ( typeName == wxGRID_VALUE_STRING )
{
- return TRUE;
+ return true;
}
else if ( typeName == wxGRID_VALUE_BOOL )
{
}
else
{
- return FALSE;
+ return false;
}
}
{
wxFAIL_MSG(_T("unexpected column"));
- return FALSE;
+ return false;
}
}
// ----------------------------------------------------------------------------
BugsGridFrame::BugsGridFrame()
- : wxFrame(NULL, -1, _T("Bugs table"),
+ : wxFrame(NULL, wxID_ANY, _T("Bugs table"),
wxDefaultPosition, wxSize(500, 300))
{
- wxGrid *grid = new wxGrid(this, -1, wxDefaultPosition);
+ wxGrid *grid = new wxGrid(this, wxID_ANY, wxDefaultPosition);
wxGridTableBase *table = new BugsGridTable();
table->SetAttrProvider(new MyGridCellAttrProvider);
- grid->SetTable(table, TRUE);
+ grid->SetTable(table, true);
wxGridCellAttr *attrRO = new wxGridCellAttr,
*attrRangeEditor = new wxGridCellAttr,