3
* Purpose: wxMultiCellSizer and wxMultiCellCanvas test
4
* Author: Alex Andruschak
8
* License: wxWindows licence
11
#if defined(__GNUG__) && !defined(__APPLE__)
12
#pragma implementation
16
#include "wx/wxprec.h"
26
#include "wx/gizmos/multicell.h"
28
class MyApp: public wxApp
33
class MyFrame: public wxFrame
37
MyFrame(int type, wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size);
39
void OnCloseWindow(wxCloseEvent& event);
40
void OnPaint(wxPaintEvent& event);
41
wxMultiCellSizer *sizer;
48
bool MyApp::OnInit(void)
50
MyFrame *frame = new MyFrame(1, (wxFrame *) NULL, wxT("wxMultiCellSizer Sample"), wxPoint(50, 50), wxDefaultSize); //, wxSize(600, 500));
55
frame = new MyFrame(2, (wxFrame *) NULL, wxT("wxMultiCellCanvas Sample"), wxPoint(100, 100), wxSize(600, 500));
65
MyFrame::MyFrame(int type, wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size):
66
wxFrame(frame, wxID_ANY, title, pos, size, wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL)
70
#endif // wxUSE_STATUSBAR
74
// create sizer 4 columns 5 rows
76
sizer = new wxMultiCellSizer(aa);
77
sizer->SetDefaultCellSize(wxSize(15,15));
78
sizer->SetRowHeight(7,5,true);
79
sizer->SetRowHeight(8,5,false);
82
new wxButton( this, wxID_ANY, wxT( "B1 - 0,0, horizontal resizable")),
83
0, 0, 0, new wxMultiCellItemHandle(0,0,1,1, wxDefaultSize, wxHORIZONTAL_RESIZABLE, wxSize(2,2)));
85
new wxButton( this, wxID_ANY, wxT("B2 - 0,1, vertical resizable")),
86
0, 0, 0, new wxMultiCellItemHandle(0,1,1,1, wxDefaultSize, wxVERTICAL_RESIZABLE, wxSize(2, 2)));
88
new wxButton( this, wxID_ANY, wxT("B3 - 0,2")),
89
0, 0, 0, new wxMultiCellItemHandle(0,2,1,1, wxDefaultSize, wxNOT_RESIZABLE, wxSize(1,1), wxALIGN_CENTER_HORIZONTAL)); //, wxALIGN_CENTER));
91
new wxStaticText(this, wxID_ANY, wxT("jbb 0,3, lower-right")),
92
0, 0, 0, new wxMultiCellItemHandle(0,3,1,1, wxDefaultSize, wxNOT_RESIZABLE, wxSize(1,1), wxALIGN_BOTTOM | wxALIGN_RIGHT));
94
// add button for secord row
96
new wxTextCtrl(this, wxID_ANY, wxT("Text control - 1,0, 4 cols wide")),
97
0, 0, 0, new wxMultiCellItemHandle(1,0,1,4));
99
// add buttons for next row
101
new wxButton( this, wxID_ANY, wxT("B6 - 2,0, 2 cols wide")),
102
0, 0, 0, new wxMultiCellItemHandle(2,0,1,2));
104
new wxButton( this, wxID_ANY, wxT("B7 - 2,3")),
105
0, 0, 0, new wxMultiCellItemHandle(2,3,1,1));
107
// and last additions
109
new wxButton( this, wxID_ANY, wxT("B8 - 3,0, 4 rows high, vert resizable")),
110
0, 0, 0, new wxMultiCellItemHandle(3,0,4,1,wxDefaultSize, wxVERTICAL_RESIZABLE));
112
new wxButton( this, wxID_ANY, wxT("B9 - 3,2, 2 cols wide, vert resizable")),
113
0, 0, 0, new wxMultiCellItemHandle(3,2,1,2,wxDefaultSize, wxVERTICAL_RESIZABLE));
115
new wxButton( this, wxID_ANY, wxT("B10 - 4,1, 3 cols wide, vert resizable")),
116
0, 0, 0, new wxMultiCellItemHandle(4,1,1,3,wxDefaultSize, wxVERTICAL_RESIZABLE));
119
new wxButton( this, wxID_ANY, wxT("B11 - 5,1, 3 cols wide")),
120
0, 0, 0, new wxMultiCellItemHandle(5,1,1,3));
123
new wxButton( this, wxID_ANY, wxT("B12 - 6,1, 3 cols wide")),
124
0, 0, 0, new wxMultiCellItemHandle(6,1,1,3));
127
new wxButton( this, wxID_ANY, wxT("B13 - 7,1, 2 cols wide")),
128
0, 0, 0, new wxMultiCellItemHandle(7,1,1,2));
131
new wxButton( this, wxID_ANY, wxT("B14 - 8,1, 3 cols wide")),
132
0, 0, 0, new wxMultiCellItemHandle(8,1,1,3));
134
SetAutoLayout( true );
135
// sizer->SetMinSize(sizer->CalcMin());
137
wxSize s = sizer->CalcMin();
138
wxSize c = GetSize() - GetClientSize();
139
SetSizeHints(s.GetWidth() + c.GetWidth() , s.GetHeight() + c.GetHeight());
140
sizer->EnableGridLines(this);
144
// create sizer 4 columns 5 rows
145
wxMultiCellCanvas *sizer = new wxMultiCellCanvas(this, 5,5);
149
new wxButton( this, wxID_ANY, wxT("Button 1")),
152
new wxButton( this, wxID_ANY, wxT("Button 2")),
155
new wxButton( this, wxID_ANY, wxT("Button 3")),
158
new wxStaticText(this, wxID_ANY, wxT("jbb test")),
162
new wxStaticText(this, wxID_ANY, wxT("jbb test 2")),
165
// add button for secord row
167
new wxTextCtrl(this, wxID_ANY, wxT("Text control")),
170
// add buttons for next row
172
new wxButton( this, wxID_ANY, wxT("Button 6")),
175
new wxButton( this, wxID_ANY, wxT("Button 7")),
178
// and last additions
180
new wxButton( this, wxID_ANY, wxT("Button 8")),
183
new wxButton( this, wxID_ANY, wxT("Button 9")),
186
new wxButton( this, wxID_ANY, wxT("Button 10")),
189
sizer->CalculateConstraints();
191
SetAutoLayout( true );
194
// Define the repainting behaviour
197
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
198
EVT_PAINT(MyFrame::OnPaint)
199
EVT_CLOSE(MyFrame::OnCloseWindow)
202
void MyFrame::OnPaint(wxPaintEvent& WXUNUSED(event) )
212
void MyFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))