Basic Image AlgorithmS Library 2.8.0

ZoomFrame.cpp

00001 #include <Base/Common/W32Compat.hh>
00002 #include "ZoomFrame.hh"
00003 #include <Base/Image/Image.hh>
00004 #include <Gui/ZoomImageCanvas.hh>
00005 #include <Gui/StringConv.hh>
00006 
00007 
00008 using namespace BIAS;
00009 using namespace std;
00010 
00011 ZoomFrame::
00012 ~ZoomFrame()
00013 {}
00014 
00015 
00016 ZoomFrame::
00017 ZoomFrame(wxWindow* parent, const wxString& title)
00018   : wxFrame(parent, -1, title)
00019 {
00020   Setup();
00021   Show();
00022 }
00023 
00024 
00025 void ZoomFrame::
00026 Setup()
00027 {
00028   int widths[] = { -1, 280 };
00029   CreateStatusBar(2);
00030   SetStatusWidths(2, widths);
00031 
00032   QuitButton_ = new wxButton(this, MIA_ZoomQuitButton, wxT("Close"));
00033 
00034   Window_ = new ZoomImageCanvas(this, GetStatusBar(), 1);
00035 
00036   SLScale_ = new wxSlider(this, -1, 10, 1, 25, wxDefaultPosition,
00037     wxSize(-1, -1), wxSL_HORIZONTAL);
00038 
00039   wxBoxSizer *box = new wxBoxSizer(wxVERTICAL);
00040   wxBoxSizer *hbox = new wxBoxSizer(wxHORIZONTAL);
00041 
00042   box->Add(QuitButton_, 0, wxALL | wxGROW, 3);
00043   box->Add(Window_, 1, wxALL | wxGROW, 3);
00044   hbox->Add(new wxStaticText( this, -1, _T("Zoom") ), 0, wxALL, 5);
00045   hbox->Add(SLScale_, 1, wxALL | wxGROW, 5);
00046   box->Add(hbox, 0, wxGROW, 0);
00047 
00048   box->SetSizeHints(this);
00049   SetSizer(box);
00050 }
00051 
00052 void ZoomFrame::
00053 NewImage(BIAS::ImageBase& im,
00054          BIAS::Image<unsigned char>& ucim,
00055          const wxString& name)
00056 {
00057   Window_->NewImage(im, ucim);
00058   if(GetStatusBar()!=NULL)
00059     SetStatusText(name, 0);
00060 }
00061 
00062 
00063 void ZoomFrame::
00064 NewCoo(unsigned x, unsigned y)
00065 { Window_->NewCoo(x, y); }
00066 
00067 
00068 
00069 BEGIN_EVENT_TABLE (ZoomFrame, wxFrame)
00070 EVT_BUTTON      (MIA_ZoomQuitButton, ZoomFrame::OnQuit)
00071 EVT_SCROLL      (ZoomFrame::OnZoomFactor)
00072 EVT_CLOSE       (ZoomFrame::OnClose)
00073 //EVT_KEY_DOWN    (ZoomFrame::OnKeyPress)
00074 END_EVENT_TABLE()
00075 
00076 //void ZoomFrame::OnQuit(wxCommandEvent & event)
00077 void ZoomFrame::OnQuit(wxCommandEvent &)
00078 {
00079   Close(true);
00080 }
00081 
00082 //void ZoomFrame::OnClose(wxCloseEvent & event)
00083 void ZoomFrame::OnClose(wxCloseEvent &)
00084 {
00085   /*
00086   ((ImageCanvas*)GetParent())->SetZoomed(false);
00087   Destroy();
00088   */
00089   Hide();
00090 }
00091 
00092 void ZoomFrame::SetZoom(unsigned z)
00093 {
00094   BIASASSERT(z>=1);
00095   BIASASSERT(z<=25);
00096   SLScale_->SetValue(z);
00097   Window_->NewZoom(SLScale_->GetValue());
00098 }
00099 
00100 //void ZoomFrame::OnZoomFactor(wxScrollEvent & event)
00101 void ZoomFrame::OnZoomFactor(wxScrollEvent&)
00102 { Window_->NewZoom(SLScale_->GetValue()); }
00103 
00104 // void ZoomFrame::OnKeyPress(wxKeyEvent &event)
00105 // {
00106 //   cerr <<"ZoomFrame::OnKeyPress\n";
00107 //   event.Skip();
00108 // }
00109 
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends