3 * Purpose: wxMultiCellSizer and wxMultiCellCanvas test
4 * Author: Alex Andruschak
10 static const char sccsid
[] = "%W% %G%";
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
, (char *) "wxMultiCellSizer Sample", wxPoint(50, 50), wxDefaultSize
); //, wxSize(600, 500));
56 frame
= new MyFrame(2, (wxFrame
*) NULL
, (char *) "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
, -1, title
, pos
, size
, wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
)
73 // create sizer 4 columns 5 rows
75 sizer
= new wxMultiCellSizer(aa
);
76 sizer
->SetDefaultCellSize(wxSize(15,15));
77 sizer
->SetRowHeight(7,5,TRUE
);
78 sizer
->SetRowHeight(8,5,FALSE
);
81 new wxButton( this, -1, "B1 - 0,0, horizontal resizable" ),
82 0, 0, 0, new wxMultiCellItemHandle(0,0,1,1, wxDefaultSize
, wxHORIZENTAL_RESIZABLE
, wxSize(2,2)));
84 new wxButton( this, -1, "B2 - 0,1, vertical resizable" ),
85 0, 0, 0, new wxMultiCellItemHandle(0,1,1,1, wxDefaultSize
, wxVERTICAL_RESIZABLE
, wxSize(2, 2)));
87 new wxButton( this, -1, "B3 - 0,2" ),
88 0, 0, 0, new wxMultiCellItemHandle(0,2,1,1, wxDefaultSize
, wxNOT_RESIZABLE
, wxSize(1,1), wxALIGN_CENTER_HORIZONTAL
)); //, wxALIGN_CENTER));
90 new wxStaticText(this, -1, "jbb 0,3, lower-right"),
91 0, 0, 0, new wxMultiCellItemHandle(0,3,1,1, wxDefaultSize
, wxNOT_RESIZABLE
, wxSize(1,1), wxALIGN_BOTTOM
| wxALIGN_RIGHT
));
93 // add button for secord row
95 new wxTextCtrl(this, -1, "Text control - 1,0, 4 cols wide"),
96 0, 0, 0, new wxMultiCellItemHandle(1,0,1,4));
98 // add buttons for next row
100 new wxButton( this, -1, "B6 - 2,0, 2 cols wide" ),
101 0, 0, 0, new wxMultiCellItemHandle(2,0,1,2));
103 new wxButton( this, -1, "B7 - 2,3" ),
104 0, 0, 0, new wxMultiCellItemHandle(2,3,1,1));
106 // and last additions
108 new wxButton( this, -1, "B8 - 3,0, 4 rows high, vert resizable" ),
109 0, 0, 0, new wxMultiCellItemHandle(3,0,4,1,wxDefaultSize
, wxVERTICAL_RESIZABLE
));
111 new wxButton( this, -1, "B9 - 3,2, 2 cols wide, vert resizable" ),
112 0, 0, 0, new wxMultiCellItemHandle(3,2,1,2,wxDefaultSize
, wxVERTICAL_RESIZABLE
));
114 new wxButton( this, -1, "B10 - 4,1, 3 cols wide, vert resizable" ),
115 0, 0, 0, new wxMultiCellItemHandle(4,1,1,3,wxDefaultSize
, wxVERTICAL_RESIZABLE
));
118 new wxButton( this, -1, "B11 - 5,1, 3 cols wide" ),
119 0, 0, 0, new wxMultiCellItemHandle(5,1,1,3));
122 new wxButton( this, -1, "B12 - 6,1, 3 cols wide" ),
123 0, 0, 0, new wxMultiCellItemHandle(6,1,1,3));
126 new wxButton( this, -1, "B13 - 7,1, 2 cols wide" ),
127 0, 0, 0, new wxMultiCellItemHandle(7,1,1,2));
130 new wxButton( this, -1, "B14 - 8,1, 3 cols wide" ),
131 0, 0, 0, new wxMultiCellItemHandle(8,1,1,3));
133 SetAutoLayout( TRUE
);
134 // sizer->SetMinSize(sizer->CalcMin());
136 wxSize s
= sizer
->CalcMin();
137 wxSize c
= GetSize() - GetClientSize();
138 SetSizeHints(s
.GetWidth() + c
.GetWidth() , s
.GetHeight() + c
.GetHeight());
139 sizer
->EnableGridLines(this);
143 // create sizer 4 columns 5 rows
144 wxMultiCellCanvas
*sizer
= new wxMultiCellCanvas(this, 5,5);
148 new wxButton( this, -1, "Button 1" ),
151 new wxButton( this, -1, "Button 2" ),
154 new wxButton( this, -1, "Button 3" ),
157 new wxStaticText(this, -1, "jbb test"),
161 new wxStaticText(this, -1, "jbb test 2"),
164 // add button for secord row
166 new wxTextCtrl(this, -1, "Text control"),
169 // add buttons for next row
171 new wxButton( this, -1, "Button 6" ),
174 new wxButton( this, -1, "Button 7" ),
177 // and last additions
179 new wxButton( this, -1, "Button 8" ),
182 new wxButton( this, -1, "Button 9" ),
185 new wxButton( this, -1, "Button 10" ),
188 sizer
->CalculateConstraints();
190 SetAutoLayout( TRUE
);
193 // Define the repainting behaviour
196 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
197 EVT_PAINT(MyFrame::OnPaint
)
198 EVT_CLOSE(MyFrame::OnCloseWindow
)
201 void MyFrame::OnPaint(wxPaintEvent
& WXUNUSED(event
) )
211 void MyFrame::OnCloseWindow(wxCloseEvent
& event
)