34 #include <Base/Common/BIASpragmaStart.hh>
36 #include <wx/aboutdlg.h>
37 #include <wx/artprov.h>
38 #include <wx/filename.h>
39 #include <Base/Common/BIASpragmaEnd.hh>
41 #include <Base/Image/Image.hh>
42 #include <Base/Image/ImageIO.hh>
43 #include <Base/Common/FileHandling.hh>
44 #include <Gui/StringConv.hh>
53 class SizingFrame :
public wxFrame
57 SizingFrame(
wxWindow *parent,
const wxString& title);
58 void OnOpen(wxCommandEvent &event);
59 void OnQuit(wxCommandEvent &event);
60 void OnScreenshot(wxCommandEvent& event);
61 void OnViewSize(wxCommandEvent& event);
62 void OnAbout(wxCommandEvent &event);
63 void OnScreenInfo(wxCommandEvent &event);
64 void OnResize(wxSizeEvent &event);
70 wxStaticBitmap* StaticBitmap_;
76 ID_Whatever = wxID_HIGHEST + 42,
89 void FitToImageSize_();
93 wxStatusBar* Statusbar_;
98 BEGIN_EVENT_TABLE(SizingFrame, wxFrame)
99 EVT_MENU(wxID_OPEN, SizingFrame::OnOpen)
100 EVT_MENU(wxID_EXIT, SizingFrame::OnQuit)
101 EVT_MENU(wxID_ABOUT, SizingFrame::OnAbout)
102 EVT_MENU(ID_Screenshot, SizingFrame::OnScreenshot)
103 EVT_MENU(ID_VS_Free, SizingFrame::OnViewSize)
104 EVT_MENU(ID_VS_640, SizingFrame::OnViewSize)
105 EVT_MENU(ID_VS_800, SizingFrame::OnViewSize)
106 EVT_MENU(ID_VS_16_9, SizingFrame::OnViewSize)
107 EVT_MENU(ID_VS_16_10, SizingFrame::OnViewSize)
108 EVT_MENU(ID_ScreenInfo, SizingFrame::OnScreenInfo)
109 EVT_SIZE(SizingFrame::OnResize)
112 SizingFrame::SizingFrame(
wxWindow *parent, const wxString& title)
113 : wxFrame(parent, wxID_ANY, title),
116 Img_ =
new wxImage(640, 480);
117 Img_->SetRGB(wxRect(50,50,100,100), 255, 255, 0);
118 StaticBitmap_ =
new wxStaticBitmap(
this, wxID_ANY, wxBitmap(*Img_));
120 Statusbar_ = this->CreateStatusBar( 2, wxST_SIZEGRIP, wxID_ANY );
121 const int numFields = 2;
122 Statusbar_->SetFieldsCount(numFields);
123 const int widths[numFields] = { -1, 170 };
124 Statusbar_->SetStatusWidths(numFields, widths);
127 Toolbar_ = this->CreateToolBar( wxTB_HORIZONTAL, wxID_ANY );
128 Toolbar_->SetToolBitmapSize( wxSize( 24,24 ) );
129 Toolbar_->SetToolSeparation( 0 );
130 Toolbar_->SetToolPacking( 0 );
131 Toolbar_->AddTool( ID_ScreenInfo, wxT(
"Screen Info"),
132 wxArtProvider::GetIcon(wxART_INFORMATION,wxART_TOOLBAR) );
136 wxMenu *menuFile =
new wxMenu;
137 menuFile->Append(wxID_OPEN);
138 menuFile->AppendSeparator();
139 menuFile->Append(wxID_EXIT);
140 wxMenu *menuEdit =
new wxMenu;
141 menuEdit->Append(ID_Screenshot, wxString(wxT(
"&Screenshot")) + wxT(
'\t') + wxT(
"F3"));
142 wxMenu *menuView =
new wxMenu;
143 menuView->AppendRadioItem(ID_VS_Free, wxString(wxT(
"View Size &Free")) + wxT(
'\t') + wxT(
"CTRL-SHIFT-0"));
144 menuView->AppendRadioItem(ID_VS_640, wxString(wxT(
"View Size 4:3 &small")) + wxT(
'\t') + wxT(
"CTRL-SHIFT-1"));
145 menuView->AppendRadioItem(ID_VS_800, wxString(wxT(
"View Size 4:3 &medium")) + wxT(
'\t') + wxT(
"CTRL-SHIFT-2"));
146 menuView->AppendRadioItem(ID_VS_16_9, wxString(wxT(
"View Size 16:&9 medium")) + wxT(
'\t') + wxT(
"CTRL-SHIFT-3"));
147 menuView->AppendRadioItem(ID_VS_16_10, wxString(wxT(
"View Size 16:&10 medium")) + wxT(
'\t') + wxT(
"CTRL-SHIFT-4"));
148 wxMenu *menuHelp =
new wxMenu;
149 menuHelp->Append(wxID_ABOUT);
150 Menubar_ =
new wxMenuBar;
151 Menubar_->Append(menuFile, wxT(
"&File"));
152 Menubar_->Append(menuEdit, wxT(
"&Edit"));
153 Menubar_->Append(menuView, wxT(
"&View"));
154 Menubar_->Append(menuHelp, wxT(
"&Help"));
156 SetMenuBar(Menubar_);
157 wxBoxSizer* mainSizer =
new wxBoxSizer(wxVERTICAL);
158 mainSizer->Add(StaticBitmap_, 1, wxEXPAND|wxALL|wxALIGN_CENTRE, 0);
159 SetMinSize(wxSize(555,333));
161 mainSizer->Fit(
this);
173 OnScreenInfo(wxCommandEvent &event)
175 wxString msg = wxT(
"Window size is ");
176 msg << GetSize().GetWidth() << wxT(
" x ")
177 << GetSize().GetHeight();
178 msg << wxT(
"\n") << wxT(
"Client size is ");
179 msg << GetClientSize().GetWidth() << wxT(
" x ")
180 << GetClientSize().GetHeight();
182 wxMessageBox(msg, wxT(
"Example Sizing - Screen Info"),
183 wxOK | wxICON_INFORMATION,
this);
188 OnResize(wxSizeEvent &event)
190 cout <<
"size event: window size \t("
191 << GetSize().GetWidth() <<
" x " << GetSize().GetHeight() <<
")\n";
197 OnOpen(wxCommandEvent &event)
203 OnQuit(wxCommandEvent &event)
209 OnViewSize(wxCommandEvent& event)
216 OnScreenshot(wxCommandEvent& event)
218 wxMessageBox(wxT(
"Saving screenshot not implemented!"), wxT(
"Information"),
219 wxOK | wxICON_INFORMATION,
this);
224 OnAbout(wxCommandEvent &event)
227 desc << wxT(
" This example is part of the\n");
228 desc << wxT(
" BIAS library (Basic ImageAlgorithmS)\n") << wxT(
"\n\n");
229 wxString lic = wxT(
"BIAS is free software; you can redistribute it and/or modify\n \
230 it under the terms of the GNU Lesser General Public Licence as published by\n \
231 the Free Software Foundation; either version 2.1 of the Licence, or\n \
232 (at your option) any later version.\n \
234 BIAS is distributed in the hope that it will be useful,\n \
235 but WITHOUT ANY WARRANTY; without even the implied warranty of\n \
236 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n \
237 GNU Lesser General Public Licence for more details.\n \
239 You should have received a copy of the GNU Lesser General Public Licence\n \
240 along with BIAS; if not, write to the Free Software\n \
241 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n");
243 wxAboutDialogInfo aboutdlg;
244 aboutdlg.SetDescription( desc );
245 aboutdlg.SetLicence( lic );
246 aboutdlg.SetCopyright( wxT(
"Copyright (C) 2003-2009\n \
247 Multimediale Systeme der Informationsverarbeitung\n \
248 Institut fuer Informatik\n \
249 Christian-Albrechts-Universitaet Kiel") );
250 aboutdlg.SetWebSite( wxT(
"http://www.mip.informatik.uni-kiel.de/") );
252 wxAboutBox( aboutdlg );
259 static unsigned run = 0;
260 cout <<
"****** loads of sizes (no. " << run++ <<
") *****\n";
261 cout <<
"size locked? " << boolalpha << SizeLocked_ << endl;
262 cout <<
"window size \t(" << GetSize().GetWidth() <<
" x " << GetSize().GetHeight() <<
")\n";
263 cout <<
"client size \t(" << GetClientSize().GetWidth() <<
" x " << GetClientSize().GetHeight() <<
")\n";
267 cout <<
"static bitmap size \t(" << StaticBitmap_->GetSize().GetWidth() <<
" x " << StaticBitmap_->GetSize().GetHeight() <<
")\n\n";
277 wxSize clientSize = this->GetClientSize();
278 wxSize staticBitmapSize = StaticBitmap_->GetSize();
281 if ( Menubar_->IsChecked(ID_VS_640) ) {
283 Img_->Resize(wxSize(640, 480), wxPoint(0,0), 0, 255, 0);
284 StaticBitmap_->SetBitmap(wxBitmap(*Img_));
287 if ( Menubar_->IsChecked(ID_VS_800) ) {
289 Img_->Resize(wxSize(800, 600), wxPoint(0,0), 255, 0, 0);
290 StaticBitmap_->SetBitmap(wxBitmap(*Img_));
293 if ( Menubar_->IsChecked(ID_VS_16_9) ) {
295 Img_->Resize(wxSize(800, 450), wxPoint(0,0), 0, 0, 255);
296 StaticBitmap_->SetBitmap(wxBitmap(*Img_));
299 if ( Menubar_->IsChecked(ID_VS_16_10) ) {
301 Img_->Resize(wxSize(800, 500), wxPoint(0,0), 0, 255, 255);
302 StaticBitmap_->SetBitmap(wxBitmap(*Img_));
305 if ( Menubar_->IsChecked(ID_VS_Free) ) {
306 Img_->Resize(clientSize, wxPoint(0,0), 255, 0, 255);
307 StaticBitmap_->SetBitmap(wxBitmap(*Img_));
316 StaticBitmap_->SetSize(staticBitmapSize);
322 clientSize = StaticBitmap_->GetSize();
323 this->SetClientSize(clientSize);
324 cout <<
"++++ before fitting ++++" << endl;
329 cout <<
"++++ after fitting ++++" << endl;
338 class SizingApp :
public wxApp
345 bool SizingApp::OnInit()
347 wxInitAllImageHandlers();
348 SizingFrame* mainFrame =
349 new SizingFrame(NULL, wxT(
"Example Sizing"));
351 mainFrame->LateInit();
355 IMPLEMENT_APP(SizingApp)