3 * Purpose: wxMultiCellSizer and wxMultiCellCanvas test
4 * Author: Alex Andruschak
8 * License: wxWindows licence
11 static const char sccsid
[] = "%W% %G%";
13 #if defined(__GNUG__) && !defined(__APPLE__)
14 #pragma implementation
18 #include "wx/wxprec.h"
28 #include "wx/gizmos/multicell.h"
30 class MyApp
: public wxApp
35 class MyFrame
: public wxFrame
39 MyFrame(int type
, wxFrame
*frame
, const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
);
41 void OnCloseWindow(wxCloseEvent
& event
);
42 void OnPaint(wxPaintEvent
& event
);
43 wxMultiCellSizer
*sizer
;
50 bool MyApp::OnInit(void)
52 MyFrame
*frame
= new MyFrame(1, (wxFrame
*) NULL
, wxT("wxMultiCellSizer Sample"), wxPoint(50, 50), wxDefaultSize
); //, wxSize(600, 500));
57 frame
= new MyFrame(2, (wxFrame
*) NULL
, wxT("wxMultiCellCanvas Sample"), wxPoint(100, 100), wxSize(600, 500));
67 MyFrame::MyFrame(int type
, wxFrame
*frame
, const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
):
68 wxFrame(frame
, wxID_ANY
, title
, pos
, size
, wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
)
72 #endif // wxUSE_STATUSBAR
76 // create sizer 4 columns 5 rows
78 sizer
= new wxMultiCellSizer(aa
);
79 sizer
->SetDefaultCellSize(wxSize(15,15));
80 sizer
->SetRowHeight(7,5,true);
81 sizer
->SetRowHeight(8,5,false);
84 new wxButton( this, wxID_ANY
, wxT( "B1 - 0,0, horizontal resizable")),
85 0, 0, 0, new wxMultiCellItemHandle(0,0,1,1, wxDefaultSize
, wxHORIZONTAL_RESIZABLE
, wxSize(2,2)));
87 new wxButton( this, wxID_ANY
, wxT("B2 - 0,1, vertical resizable")),
88 0, 0, 0, new wxMultiCellItemHandle(0,1,1,1, wxDefaultSize
, wxVERTICAL_RESIZABLE
, wxSize(2, 2)));
90 new wxButton( this, wxID_ANY
, wxT("B3 - 0,2")),
91 0, 0, 0, new wxMultiCellItemHandle(0,2,1,1, wxDefaultSize
, wxNOT_RESIZABLE
, wxSize(1,1), wxALIGN_CENTER_HORIZONTAL
)); //, wxALIGN_CENTER));
93 new wxStaticText(this, wxID_ANY
, wxT("jbb 0,3, lower-right")),
94 0, 0, 0, new wxMultiCellItemHandle(0,3,1,1, wxDefaultSize
, wxNOT_RESIZABLE
, wxSize(1,1), wxALIGN_BOTTOM
| wxALIGN_RIGHT
));
96 // add button for secord row
98 new wxTextCtrl(this, wxID_ANY
, wxT("Text control - 1,0, 4 cols wide")),
99 0, 0, 0, new wxMultiCellItemHandle(1,0,1,4));
101 // add buttons for next row
103 new wxButton( this, wxID_ANY
, wxT("B6 - 2,0, 2 cols wide")),
104 0, 0, 0, new wxMultiCellItemHandle(2,0,1,2));
106 new wxButton( this, wxID_ANY
, wxT("B7 - 2,3")),
107 0, 0, 0, new wxMultiCellItemHandle(2,3,1,1));
109 // and last additions
111 new wxButton( this, wxID_ANY
, wxT("B8 - 3,0, 4 rows high, vert resizable")),
112 0, 0, 0, new wxMultiCellItemHandle(3,0,4,1,wxDefaultSize
, wxVERTICAL_RESIZABLE
));
114 new wxButton( this, wxID_ANY
, wxT("B9 - 3,2, 2 cols wide, vert resizable")),
115 0, 0, 0, new wxMultiCellItemHandle(3,2,1,2,wxDefaultSize
, wxVERTICAL_RESIZABLE
));
117 new wxButton( this, wxID_ANY
, wxT("B10 - 4,1, 3 cols wide, vert resizable")),
118 0, 0, 0, new wxMultiCellItemHandle(4,1,1,3,wxDefaultSize
, wxVERTICAL_RESIZABLE
));
121 new wxButton( this, wxID_ANY
, wxT("B11 - 5,1, 3 cols wide")),
122 0, 0, 0, new wxMultiCellItemHandle(5,1,1,3));
125 new wxButton( this, wxID_ANY
, wxT("B12 - 6,1, 3 cols wide")),
126 0, 0, 0, new wxMultiCellItemHandle(6,1,1,3));
129 new wxButton( this, wxID_ANY
, wxT("B13 - 7,1, 2 cols wide")),
130 0, 0, 0, new wxMultiCellItemHandle(7,1,1,2));
133 new wxButton( this, wxID_ANY
, wxT("B14 - 8,1, 3 cols wide")),
134 0, 0, 0, new wxMultiCellItemHandle(8,1,1,3));
136 SetAutoLayout( true );
137 // sizer->SetMinSize(sizer->CalcMin());
139 wxSize s
= sizer
->CalcMin();
140 wxSize c
= GetSize() - GetClientSize();
141 SetSizeHints(s
.GetWidth() + c
.GetWidth() , s
.GetHeight() + c
.GetHeight());
142 sizer
->EnableGridLines(this);
146 // create sizer 4 columns 5 rows
147 wxMultiCellCanvas
*sizer
= new wxMultiCellCanvas(this, 5,5);
151 new wxButton( this, wxID_ANY
, wxT("Button 1")),
154 new wxButton( this, wxID_ANY
, wxT("Button 2")),
157 new wxButton( this, wxID_ANY
, wxT("Button 3")),
160 new wxStaticText(this, wxID_ANY
, wxT("jbb test")),
164 new wxStaticText(this, wxID_ANY
, wxT("jbb test 2")),
167 // add button for secord row
169 new wxTextCtrl(this, wxID_ANY
, wxT("Text control")),
172 // add buttons for next row
174 new wxButton( this, wxID_ANY
, wxT("Button 6")),
177 new wxButton( this, wxID_ANY
, wxT("Button 7")),
180 // and last additions
182 new wxButton( this, wxID_ANY
, wxT("Button 8")),
185 new wxButton( this, wxID_ANY
, wxT("Button 9")),
188 new wxButton( this, wxID_ANY
, wxT("Button 10")),
191 sizer
->CalculateConstraints();
193 SetAutoLayout( true );
196 // Define the repainting behaviour
199 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
200 EVT_PAINT(MyFrame::OnPaint
)
201 EVT_CLOSE(MyFrame::OnCloseWindow
)
204 void MyFrame::OnPaint(wxPaintEvent
& WXUNUSED(event
) )
214 void MyFrame::OnCloseWindow(wxCloseEvent
& WXUNUSED(event
))