]> git.saurik.com Git - wxWidgets.git/blob - contrib/samples/gizmos/multicell/mtest.cpp
removed src/gtk/eggtrayicon.h
[wxWidgets.git] / contrib / samples / gizmos / multicell / mtest.cpp
1 /*
2 * File: mtest.cpp
3 * Purpose: wxMultiCellSizer and wxMultiCellCanvas test
4 * Author: Alex Andruschak
5 * Created: 2000
6 * Updated:
7 * Copyright:
8 */
9
10 static const char sccsid[] = "%W% %G%";
11
12 #if defined(__GNUG__) && !defined(__APPLE__)
13 #pragma implementation
14 #pragma interface
15 #endif
16
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/wx.h"
25 #endif
26
27 #include "wx/gizmos/multicell.h"
28
29 class MyApp: public wxApp
30 {public:
31 bool OnInit(void);
32 };
33
34 class MyFrame: public wxFrame
35 {
36
37 public:
38 MyFrame(int type, wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size);
39
40 void OnCloseWindow(wxCloseEvent& event);
41 void OnPaint(wxPaintEvent& event);
42 wxMultiCellSizer *sizer;
43
44 DECLARE_EVENT_TABLE()
45 };
46
47 IMPLEMENT_APP(MyApp)
48
49 bool MyApp::OnInit(void)
50 {
51 MyFrame *frame = new MyFrame(1, (wxFrame *) NULL, wxT("wxMultiCellSizer Sample"), wxPoint(50, 50), wxDefaultSize); //, wxSize(600, 500));
52
53 frame->Show(true);
54
55 SetTopWindow(frame);
56 frame = new MyFrame(2, (wxFrame *) NULL, wxT("wxMultiCellCanvas Sample"), wxPoint(100, 100), wxSize(600, 500));
57
58 frame->Show(true);
59
60 SetTopWindow(frame);
61 return true;
62 }
63
64
65
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)
68 {
69 #if wxUSE_STATUSBAR
70 CreateStatusBar(1);
71 #endif // wxUSE_STATUSBAR
72 sizer = NULL;
73 if (type == 1)
74 {
75 // create sizer 4 columns 5 rows
76 wxSize aa(4,9);
77 sizer = new wxMultiCellSizer(aa);
78 sizer->SetDefaultCellSize(wxSize(15,15));
79 sizer->SetRowHeight(7,5,true);
80 sizer->SetRowHeight(8,5,false);
81 // add first row
82 sizer->Add(
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)));
85 sizer->Add(
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)));
88 sizer->Add(
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));
91 sizer->Add(
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));
94
95 // add button for secord row
96 sizer->Add(
97 new wxTextCtrl(this, wxID_ANY, wxT("Text control - 1,0, 4 cols wide")),
98 0, 0, 0, new wxMultiCellItemHandle(1,0,1,4));
99
100 // add buttons for next row
101 sizer->Add(
102 new wxButton( this, wxID_ANY, wxT("B6 - 2,0, 2 cols wide")),
103 0, 0, 0, new wxMultiCellItemHandle(2,0,1,2));
104 sizer->Add(
105 new wxButton( this, wxID_ANY, wxT("B7 - 2,3")),
106 0, 0, 0, new wxMultiCellItemHandle(2,3,1,1));
107
108 // and last additions
109 sizer->Add(
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));
112 sizer->Add(
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));
115 sizer->Add(
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));
118
119 sizer->Add(
120 new wxButton( this, wxID_ANY, wxT("B11 - 5,1, 3 cols wide")),
121 0, 0, 0, new wxMultiCellItemHandle(5,1,1,3));
122
123 sizer->Add(
124 new wxButton( this, wxID_ANY, wxT("B12 - 6,1, 3 cols wide")),
125 0, 0, 0, new wxMultiCellItemHandle(6,1,1,3));
126
127 sizer->Add(
128 new wxButton( this, wxID_ANY, wxT("B13 - 7,1, 2 cols wide")),
129 0, 0, 0, new wxMultiCellItemHandle(7,1,1,2));
130
131 sizer->Add(
132 new wxButton( this, wxID_ANY, wxT("B14 - 8,1, 3 cols wide")),
133 0, 0, 0, new wxMultiCellItemHandle(8,1,1,3));
134
135 SetAutoLayout( true );
136 // sizer->SetMinSize(sizer->CalcMin());
137 SetSizer( sizer );
138 wxSize s = sizer->CalcMin();
139 wxSize c = GetSize() - GetClientSize();
140 SetSizeHints(s.GetWidth() + c.GetWidth() , s.GetHeight() + c.GetHeight());
141 sizer->EnableGridLines(this);
142 }
143 else
144 {
145 // create sizer 4 columns 5 rows
146 wxMultiCellCanvas *sizer = new wxMultiCellCanvas(this, 5,5);
147
148 // add first row
149 sizer->Add(
150 new wxButton( this, wxID_ANY, wxT("Button 1")),
151 0, 0);
152 sizer->Add(
153 new wxButton( this, wxID_ANY, wxT("Button 2")),
154 0, 1);
155 sizer->Add(
156 new wxButton( this, wxID_ANY, wxT("Button 3")),
157 0, 2);
158 sizer->Add(
159 new wxStaticText(this, wxID_ANY, wxT("jbb test")),
160 0, 3);
161
162 sizer->Add(
163 new wxStaticText(this, wxID_ANY, wxT("jbb test 2")),
164 0, 4);
165
166 // add button for secord row
167 sizer->Add(
168 new wxTextCtrl(this, wxID_ANY, wxT("Text control")),
169 1, 0);
170
171 // add buttons for next row
172 sizer->Add(
173 new wxButton( this, wxID_ANY, wxT("Button 6")),
174 2, 0);
175 sizer->Add(
176 new wxButton( this, wxID_ANY, wxT("Button 7")),
177 2, 3);
178
179 // and last additions
180 sizer->Add(
181 new wxButton( this, wxID_ANY, wxT("Button 8")),
182 3, 0);
183 sizer->Add(
184 new wxButton( this, wxID_ANY, wxT("Button 9")),
185 3, 1);
186 sizer->Add(
187 new wxButton( this, wxID_ANY, wxT("Button 10")),
188 4, 1);
189
190 sizer->CalculateConstraints();
191 SetSizer( sizer );
192 SetAutoLayout( true );
193 }
194 }
195 // Define the repainting behaviour
196
197
198 BEGIN_EVENT_TABLE(MyFrame, wxFrame)
199 EVT_PAINT(MyFrame::OnPaint)
200 EVT_CLOSE(MyFrame::OnCloseWindow)
201 END_EVENT_TABLE()
202
203 void MyFrame::OnPaint(wxPaintEvent& WXUNUSED(event) )
204 {
205 wxPaintDC dc(this);
206
207 if (sizer)
208 {
209 sizer->OnPaint(dc);
210 }
211 }
212
213 void MyFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
214 {
215 Destroy();
216 }
217