3 * Purpose: wxMultiCellSizer and wxMultiCellCanvas test
4 * Author: Alex Andruschak
10 static const char sccsid
[] = "%W% %G%";
12 #if defined(__GNUG__) && !defined(__APPLE__)
13 #pragma implementation
17 #include "wx/wxprec.h"
27 #include "wx/gizmos/multicell.h"
29 class MyApp
: public wxApp
34 class MyFrame
: public wxFrame
38 MyFrame(int type
, wxFrame
*frame
, const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
);
40 void OnCloseWindow(wxCloseEvent
& event
);
41 void OnPaint(wxPaintEvent
& event
);
42 wxMultiCellSizer
*sizer
;
49 bool MyApp::OnInit(void)
51 MyFrame
*frame
= new MyFrame(1, (wxFrame
*) NULL
, wxT("wxMultiCellSizer Sample"), wxPoint(50, 50), wxDefaultSize
); //, wxSize(600, 500));
56 frame
= new MyFrame(2, (wxFrame
*) NULL
, wxT("wxMultiCellCanvas Sample"), wxPoint(100, 100), wxSize(600, 500));
66 MyFrame::MyFrame(int type
, wxFrame
*frame
, const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
):
67 wxFrame(frame
, wxID_ANY
, title
, pos
, size
, wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
)
71 #endif // wxUSE_STATUSBAR
75 // create sizer 4 columns 5 rows
77 sizer
= new wxMultiCellSizer(aa
);
78 sizer
->SetDefaultCellSize(wxSize(15,15));
79 sizer
->SetRowHeight(7,5,true);
80 sizer
->SetRowHeight(8,5,false);
83 new wxButton( this, wxID_ANY
, wxT( "B1 - 0,0, horizontal resizable")),
84 0, 0, 0, new wxMultiCellItemHandle(0,0,1,1, wxDefaultSize
, wxHORIZONTAL_RESIZABLE
, wxSize(2,2)));
86 new wxButton( this, wxID_ANY
, wxT("B2 - 0,1, vertical resizable")),
87 0, 0, 0, new wxMultiCellItemHandle(0,1,1,1, wxDefaultSize
, wxVERTICAL_RESIZABLE
, wxSize(2, 2)));
89 new wxButton( this, wxID_ANY
, wxT("B3 - 0,2")),
90 0, 0, 0, new wxMultiCellItemHandle(0,2,1,1, wxDefaultSize
, wxNOT_RESIZABLE
, wxSize(1,1), wxALIGN_CENTER_HORIZONTAL
)); //, wxALIGN_CENTER));
92 new wxStaticText(this, wxID_ANY
, wxT("jbb 0,3, lower-right")),
93 0, 0, 0, new wxMultiCellItemHandle(0,3,1,1, wxDefaultSize
, wxNOT_RESIZABLE
, wxSize(1,1), wxALIGN_BOTTOM
| wxALIGN_RIGHT
));
95 // add button for secord row
97 new wxTextCtrl(this, wxID_ANY
, wxT("Text control - 1,0, 4 cols wide")),
98 0, 0, 0, new wxMultiCellItemHandle(1,0,1,4));
100 // add buttons for next row
102 new wxButton( this, wxID_ANY
, wxT("B6 - 2,0, 2 cols wide")),
103 0, 0, 0, new wxMultiCellItemHandle(2,0,1,2));
105 new wxButton( this, wxID_ANY
, wxT("B7 - 2,3")),
106 0, 0, 0, new wxMultiCellItemHandle(2,3,1,1));
108 // and last additions
110 new wxButton( this, wxID_ANY
, wxT("B8 - 3,0, 4 rows high, vert resizable")),
111 0, 0, 0, new wxMultiCellItemHandle(3,0,4,1,wxDefaultSize
, wxVERTICAL_RESIZABLE
));
113 new wxButton( this, wxID_ANY
, wxT("B9 - 3,2, 2 cols wide, vert resizable")),
114 0, 0, 0, new wxMultiCellItemHandle(3,2,1,2,wxDefaultSize
, wxVERTICAL_RESIZABLE
));
116 new wxButton( this, wxID_ANY
, wxT("B10 - 4,1, 3 cols wide, vert resizable")),
117 0, 0, 0, new wxMultiCellItemHandle(4,1,1,3,wxDefaultSize
, wxVERTICAL_RESIZABLE
));
120 new wxButton( this, wxID_ANY
, wxT("B11 - 5,1, 3 cols wide")),
121 0, 0, 0, new wxMultiCellItemHandle(5,1,1,3));
124 new wxButton( this, wxID_ANY
, wxT("B12 - 6,1, 3 cols wide")),
125 0, 0, 0, new wxMultiCellItemHandle(6,1,1,3));
128 new wxButton( this, wxID_ANY
, wxT("B13 - 7,1, 2 cols wide")),
129 0, 0, 0, new wxMultiCellItemHandle(7,1,1,2));
132 new wxButton( this, wxID_ANY
, wxT("B14 - 8,1, 3 cols wide")),
133 0, 0, 0, new wxMultiCellItemHandle(8,1,1,3));
135 SetAutoLayout( true );
136 // sizer->SetMinSize(sizer->CalcMin());
138 wxSize s
= sizer
->CalcMin();
139 wxSize c
= GetSize() - GetClientSize();
140 SetSizeHints(s
.GetWidth() + c
.GetWidth() , s
.GetHeight() + c
.GetHeight());
141 sizer
->EnableGridLines(this);
145 // create sizer 4 columns 5 rows
146 wxMultiCellCanvas
*sizer
= new wxMultiCellCanvas(this, 5,5);
150 new wxButton( this, wxID_ANY
, wxT("Button 1")),
153 new wxButton( this, wxID_ANY
, wxT("Button 2")),
156 new wxButton( this, wxID_ANY
, wxT("Button 3")),
159 new wxStaticText(this, wxID_ANY
, wxT("jbb test")),
163 new wxStaticText(this, wxID_ANY
, wxT("jbb test 2")),
166 // add button for secord row
168 new wxTextCtrl(this, wxID_ANY
, wxT("Text control")),
171 // add buttons for next row
173 new wxButton( this, wxID_ANY
, wxT("Button 6")),
176 new wxButton( this, wxID_ANY
, wxT("Button 7")),
179 // and last additions
181 new wxButton( this, wxID_ANY
, wxT("Button 8")),
184 new wxButton( this, wxID_ANY
, wxT("Button 9")),
187 new wxButton( this, wxID_ANY
, wxT("Button 10")),
190 sizer
->CalculateConstraints();
192 SetAutoLayout( true );
195 // Define the repainting behaviour
198 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
199 EVT_PAINT(MyFrame::OnPaint
)
200 EVT_CLOSE(MyFrame::OnCloseWindow
)
203 void MyFrame::OnPaint(wxPaintEvent
& WXUNUSED(event
) )
213 void MyFrame::OnCloseWindow(wxCloseEvent
& WXUNUSED(event
))