Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PreviewWindow.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
10 /* This is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This software is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public
21  * License along with this software. If not, see
22  * <http://www.gnu.org/licenses/>.
23  *
24  */
25 
26 #ifndef PREVIEWWINDOW_H
27 #define PREVIEWWINDOW_H
28 
29 #include <wx/scrolwin.h>
30 #include <wx/bitmap.h>
31 #include <wx/image.h>
32 #include "base_wx/wxcms.h"
33 
38 class PreviewWindow : public wxScrolledWindow
39 {
40 public:
42  bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL, const wxString& name = "panel");
44  void setImage (const wxString& filename);
49  void setScale(double factor);
51  double getScale();
53  void update();
55  virtual void OnDraw(wxDC& dc) wxOVERRIDE;
56 protected:
58  void OnSize(wxSizeEvent & e);
60  double getScaleFactor() const;
62  double calcAutoScaleFactor(wxSize size);
64  void rescaleImage();
65  private:
66  //orignal image
67  wxImage m_image;
68  // scaled bitmap
69  wxBitmap m_bitmap;
71  int scale(int x) const;
72  double scale(double x) const;
74  double m_scaleFactor{ 1.0 };
75  bool m_fitToWindow{ false };
77  vigra::ImageImportInfo::ICCProfile m_iccProfile;
78  DECLARE_DYNAMIC_CLASS(PreviewWindow)
79 };
80 
81 #endif // PREVIEWWINDOW_H
double m_scaleFactor
store current scale factor
Definition: PreviewWindow.h:74
void update()
initiate redraw
double calcAutoScaleFactor(wxSize size)
calculate new scale factor for this image
double getScaleFactor() const
get scale factor (calculates factor when fit to window is active)
virtual void OnDraw(wxDC &dc) wxOVERRIDE
drawing routine
int scale(int x) const
helper function to scale of width/height
vigra::ImageImportInfo::ICCProfile m_iccProfile
remember icc profile of currently loaded file
Definition: PreviewWindow.h:77
void setImage(const wxString &filename)
set the current image and mask list, this loads also the image from cache
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name="panel")
create the control
void OnSize(wxSizeEvent &e)
handler called when size of control was changed
wxBitmap m_bitmap
Definition: PreviewWindow.h:69
void setScale(double factor)
set the scaling factor f.
preview window
Definition: PreviewWindow.h:38
void rescaleImage()
rescale the image
double getScale()
return scale factor, 0 for autoscale
wxImage m_image
Definition: PreviewWindow.h:67