- // Make a menubar
- wxMenu *file_menu = new wxMenu;
- file_menu->Append(GRID_QUIT, "E&xit");
-
- wxMenu *settings_menu = new wxMenu;
- settings_menu->Append(GRID_TOGGLE_EDITABLE, "&Toggle editable");
- settings_menu->Append(GRID_TOGGLE_EDITINPLACE, "&Toggle edit in place");
- settings_menu->Append(GRID_TOGGLE_ROW_LABEL, "Toggle ro&w label");
- settings_menu->Append(GRID_TOGGLE_COL_LABEL, "Toggle co&l label");
- settings_menu->Append(GRID_TOGGLE_DIVIDERS, "Toggle ÷rs");
- settings_menu->AppendSeparator();
- settings_menu->Append(GRID_LEFT_CELL, "&Left cell alignment ");
- settings_menu->Append(GRID_CENTRE_CELL, "&Centre cell alignment ");
- settings_menu->Append(GRID_RIGHT_CELL, "&Right cell alignment ");
- settings_menu->AppendSeparator();
- settings_menu->Append(GRID_COLOUR_LABEL_BACKGROUND, "Choose a label &background colour");
- settings_menu->Append(GRID_COLOUR_LABEL_TEXT, "Choose a label fore&ground colour");
- settings_menu->Append(GRID_NORMAL_LABEL_COLOURING, "&Normal label colouring");
- settings_menu->AppendSeparator();
- settings_menu->Append(GRID_COLOUR_CELL_BACKGROUND, "Choo&se a cell &background colour");
- settings_menu->Append(GRID_COLOUR_CELL_TEXT, "Choose &a cell foreground colour");
- settings_menu->Append(GRID_NORMAL_CELL_COLOURING, "N&ormal cell colouring");
-
- wxMenuBar *menu_bar = new wxMenuBar;
- menu_bar->Append(file_menu, "&File");
- menu_bar->Append(settings_menu, "&Settings");
- frame->SetMenuBar(menu_bar);
-
- // Make a grid
- frame->grid = new wxGrid(frame, 0, 0, 400, 400);
-
- frame->grid->CreateGrid(10, 8);
- frame->grid->SetColumnWidth(3, 200);
- frame->grid->SetRowHeight(4, 45);
- frame->grid->SetCellValue("First cell", 0, 0);
- frame->grid->SetCellValue("Another cell", 1, 1);
- frame->grid->SetCellValue("Yet another cell", 2, 2);
- frame->grid->SetCellTextFont(wxFont(10, wxROMAN, wxITALIC, wxNORMAL), 0, 0);
- frame->grid->SetCellTextColour(*wxRED, 1, 1);
- frame->grid->SetCellBackgroundColour(*wxCYAN, 2, 2);
- if (cellBitmap1 && cellBitmap2)
- {
- frame->grid->SetCellAlignment(wxCENTRE, 5, 0);
- frame->grid->SetCellAlignment(wxCENTRE, 6, 0);
- frame->grid->SetCellBitmap(cellBitmap1, 5, 0);
- frame->grid->SetCellBitmap(cellBitmap2, 6, 0);
- }
-
- frame->grid->UpdateDimensions();
-
- // Show the frame
- frame->Show(TRUE);
-
- SetTopWindow(frame);
- return TRUE;
+ // Make a menubar
+ wxMenu *file_menu = new wxMenu;
+ file_menu->Append(GRID_QUIT, "E&xit");
+
+ wxMenu *settings_menu = new wxMenu;
+ settings_menu->Append(GRID_TOGGLE_EDITABLE, "&Toggle editable");
+ settings_menu->Append(GRID_TOGGLE_EDITINPLACE, "&Toggle edit in place");
+ settings_menu->Append(GRID_TOGGLE_ROW_LABEL, "Toggle ro&w label");
+ settings_menu->Append(GRID_TOGGLE_COL_LABEL, "Toggle co&l label");
+ settings_menu->Append(GRID_TOGGLE_DIVIDERS, "Toggle ÷rs");
+ settings_menu->AppendSeparator();
+ settings_menu->Append(GRID_LEFT_CELL, "&Left cell alignment ");
+ settings_menu->Append(GRID_CENTRE_CELL, "&Centre cell alignment ");
+ settings_menu->Append(GRID_RIGHT_CELL, "&Right cell alignment ");
+ settings_menu->AppendSeparator();
+ settings_menu->Append(GRID_COLOUR_LABEL_BACKGROUND, "Choose a label &background colour");
+ settings_menu->Append(GRID_COLOUR_LABEL_TEXT, "Choose a label fore&ground colour");
+ settings_menu->Append(GRID_NORMAL_LABEL_COLOURING, "&Normal label colouring");
+ settings_menu->AppendSeparator();
+ settings_menu->Append(GRID_COLOUR_CELL_BACKGROUND, "Choo&se a cell &background colour");
+ settings_menu->Append(GRID_COLOUR_CELL_TEXT, "Choose &a cell foreground colour");
+ settings_menu->Append(GRID_NORMAL_CELL_COLOURING, "N&ormal cell colouring");
+
+ wxMenuBar *menu_bar = new wxMenuBar;
+ menu_bar->Append(file_menu, "&File");
+ menu_bar->Append(settings_menu, "&Settings");
+ frame->SetMenuBar(menu_bar);
+
+ // Make a grid
+ frame->grid = new wxGrid(frame, 0, 0, 400, 400);
+
+ frame->grid->CreateGrid(10, 8);
+ frame->grid->SetColumnWidth(3, 200);
+ frame->grid->SetRowHeight(4, 45);
+ frame->grid->SetCellValue("First cell", 0, 0);
+ frame->grid->SetCellValue("Another cell", 1, 1);
+ frame->grid->SetCellValue("Yet another cell", 2, 2);
+ frame->grid->SetCellTextFont(wxFont(10, wxROMAN, wxITALIC, wxNORMAL), 0, 0);
+ frame->grid->SetCellTextColour(*wxRED, 1, 1);
+ frame->grid->SetCellBackgroundColour(*wxCYAN, 2, 2);
+ if (cellBitmap1 && cellBitmap2)
+ {
+ frame->grid->SetCellAlignment(wxCENTRE, 5, 0);
+ frame->grid->SetCellAlignment(wxCENTRE, 6, 0);
+ frame->grid->SetCellBitmap(cellBitmap1, 5, 0);
+ frame->grid->SetCellBitmap(cellBitmap2, 6, 0);
+ }
+
+ frame->grid->UpdateDimensions();
+
+ // Show the frame
+ frame->Show(TRUE);
+
+ SetTopWindow(frame);
+ return TRUE;
+}
+
+int MyApp::OnExit()
+{
+ if (cellBitmap1)
+ {
+ delete cellBitmap1;
+ cellBitmap1 = (wxBitmap *) NULL;
+ }
+
+ if (cellBitmap2)
+ {
+ delete cellBitmap2;
+ cellBitmap1 = (wxBitmap *) NULL;
+ }
+
+ // exit code is 0, everything is ok
+ return 0;