3 * Purpose: wxMultiCellSizer and wxMultiCellCanvas test
4 * Author: Alex Andruschak
8 * License: wxWindows licence
11 #include "wx/wxprec.h"
21 #include "wx/gizmos/multicell.h"
23 class MyApp
: public wxApp
28 class MyFrame
: public wxFrame
32 MyFrame(int type
, wxFrame
*frame
, const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
);
34 void OnCloseWindow(wxCloseEvent
& event
);
35 void OnPaint(wxPaintEvent
& event
);
36 wxMultiCellSizer
*sizer
;
43 bool MyApp::OnInit(void)
45 MyFrame
*frame
= new MyFrame(1, (wxFrame
*) NULL
, wxT("wxMultiCellSizer Sample"), wxPoint(50, 50), wxDefaultSize
); //, wxSize(600, 500));
50 frame
= new MyFrame(2, (wxFrame
*) NULL
, wxT("wxMultiCellCanvas Sample"), wxPoint(100, 100), wxSize(600, 500));
60 MyFrame::MyFrame(int type
, wxFrame
*frame
, const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
):
61 wxFrame(frame
, wxID_ANY
, title
, pos
, size
, wxDEFAULT_FRAME_STYLE
| wxVSCROLL
| wxHSCROLL
)
65 #endif // wxUSE_STATUSBAR
69 // create sizer 4 columns 5 rows
71 sizer
= new wxMultiCellSizer(aa
);
72 sizer
->SetDefaultCellSize(wxSize(15,15));
73 sizer
->SetRowHeight(7,5,true);
74 sizer
->SetRowHeight(8,5,false);
77 new wxButton( this, wxID_ANY
, wxT( "B1 - 0,0, horizontal resizable")),
78 0, 0, 0, new wxMultiCellItemHandle(0,0,1,1, wxDefaultSize
, wxHORIZONTAL_RESIZABLE
, wxSize(2,2)));
80 new wxButton( this, wxID_ANY
, wxT("B2 - 0,1, vertical resizable")),
81 0, 0, 0, new wxMultiCellItemHandle(0,1,1,1, wxDefaultSize
, wxVERTICAL_RESIZABLE
, wxSize(2, 2)));
83 new wxButton( this, wxID_ANY
, wxT("B3 - 0,2")),
84 0, 0, 0, new wxMultiCellItemHandle(0,2,1,1, wxDefaultSize
, wxNOT_RESIZABLE
, wxSize(1,1), wxALIGN_CENTER_HORIZONTAL
)); //, wxALIGN_CENTER));
86 new wxStaticText(this, wxID_ANY
, wxT("jbb 0,3, lower-right")),
87 0, 0, 0, new wxMultiCellItemHandle(0,3,1,1, wxDefaultSize
, wxNOT_RESIZABLE
, wxSize(1,1), wxALIGN_BOTTOM
| wxALIGN_RIGHT
));
89 // add button for secord row
91 new wxTextCtrl(this, wxID_ANY
, wxT("Text control - 1,0, 4 cols wide")),
92 0, 0, 0, new wxMultiCellItemHandle(1,0,1,4));
94 // add buttons for next row
96 new wxButton( this, wxID_ANY
, wxT("B6 - 2,0, 2 cols wide")),
97 0, 0, 0, new wxMultiCellItemHandle(2,0,1,2));
99 new wxButton( this, wxID_ANY
, wxT("B7 - 2,3")),
100 0, 0, 0, new wxMultiCellItemHandle(2,3,1,1));
102 // and last additions
104 new wxButton( this, wxID_ANY
, wxT("B8 - 3,0, 4 rows high, vert resizable")),
105 0, 0, 0, new wxMultiCellItemHandle(3,0,4,1,wxDefaultSize
, wxVERTICAL_RESIZABLE
));
107 new wxButton( this, wxID_ANY
, wxT("B9 - 3,2, 2 cols wide, vert resizable")),
108 0, 0, 0, new wxMultiCellItemHandle(3,2,1,2,wxDefaultSize
, wxVERTICAL_RESIZABLE
));
110 new wxButton( this, wxID_ANY
, wxT("B10 - 4,1, 3 cols wide, vert resizable")),
111 0, 0, 0, new wxMultiCellItemHandle(4,1,1,3,wxDefaultSize
, wxVERTICAL_RESIZABLE
));
114 new wxButton( this, wxID_ANY
, wxT("B11 - 5,1, 3 cols wide")),
115 0, 0, 0, new wxMultiCellItemHandle(5,1,1,3));
118 new wxButton( this, wxID_ANY
, wxT("B12 - 6,1, 3 cols wide")),
119 0, 0, 0, new wxMultiCellItemHandle(6,1,1,3));
122 new wxButton( this, wxID_ANY
, wxT("B13 - 7,1, 2 cols wide")),
123 0, 0, 0, new wxMultiCellItemHandle(7,1,1,2));
126 new wxButton( this, wxID_ANY
, wxT("B14 - 8,1, 3 cols wide")),
127 0, 0, 0, new wxMultiCellItemHandle(8,1,1,3));
129 SetAutoLayout( true );
130 // sizer->SetMinSize(sizer->CalcMin());
132 wxSize s
= sizer
->CalcMin();
133 wxSize c
= GetSize() - GetClientSize();
134 SetSizeHints(s
.GetWidth() + c
.GetWidth() , s
.GetHeight() + c
.GetHeight());
135 sizer
->EnableGridLines(this);
139 // create sizer 4 columns 5 rows
140 wxMultiCellCanvas
*sizer
= new wxMultiCellCanvas(this, 5,5);
144 new wxButton( this, wxID_ANY
, wxT("Button 1")),
147 new wxButton( this, wxID_ANY
, wxT("Button 2")),
150 new wxButton( this, wxID_ANY
, wxT("Button 3")),
153 new wxStaticText(this, wxID_ANY
, wxT("jbb test")),
157 new wxStaticText(this, wxID_ANY
, wxT("jbb test 2")),
160 // add button for secord row
162 new wxTextCtrl(this, wxID_ANY
, wxT("Text control")),
165 // add buttons for next row
167 new wxButton( this, wxID_ANY
, wxT("Button 6")),
170 new wxButton( this, wxID_ANY
, wxT("Button 7")),
173 // and last additions
175 new wxButton( this, wxID_ANY
, wxT("Button 8")),
178 new wxButton( this, wxID_ANY
, wxT("Button 9")),
181 new wxButton( this, wxID_ANY
, wxT("Button 10")),
184 sizer
->CalculateConstraints();
186 SetAutoLayout( true );
189 // Define the repainting behaviour
192 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
193 EVT_PAINT(MyFrame::OnPaint
)
194 EVT_CLOSE(MyFrame::OnCloseWindow
)
197 void MyFrame::OnPaint(wxPaintEvent
& WXUNUSED(event
) )
207 void MyFrame::OnCloseWindow(wxCloseEvent
& WXUNUSED(event
))