Main Page | Class Hierarchy | Class List | File List | Class Members

ImageBox.h

00001 00002 // Name: ImageBox.h 00003 // Purpose: wxImageBox class 00004 // Author: Alex Thuering 00005 // Created: 8.10.2003 00006 // RCS-ID: $Id: ImageBox.h,v 1.4 2003/11/06 12:46:59 ntalex Exp $ 00007 // Copyright: (c) Alex Thuering 00008 // Licence: wxWindows licence 00010 00011 #ifndef WXVILLALIB_IMAGEBOX_H 00012 #define WXVILLALIB_IMAGEBOX_H 00013 00014 #include <wx/wx.h> 00015 #include <wx/image.h> 00016 #include <wx/filename.h> 00017 00019 class wxPaintBox: public wxScrolledWindow 00020 { 00021 public: 00022 wxPaintBox(wxWindow *parent, wxWindowID id = -1); 00023 ~wxPaintBox() {} 00024 wxBitmap& GetBuffer() { return *m_buffer; } 00025 virtual void Update() {} 00026 00027 protected: 00028 wxBitmap *m_buffer; 00029 int m_bufferX, m_bufferY; 00030 int m_imageWidth, m_imageHeight; 00031 virtual void OnPaint(wxPaintEvent &event); 00032 void OnEraseBackground(wxEraseEvent &event); 00033 DECLARE_EVENT_TABLE() 00034 }; 00035 00036 const int scFIT_TO_PAGE = -1; 00037 const int scFIT_TO_WIDTH = -2; 00038 const int scFIT_TO_HEIGHT = -3; 00039 00041 class wxImageBox: public wxPaintBox 00042 { 00043 public: 00045 wxImageBox(wxWindow *parent, wxWindowID id = -1); 00047 bool LoadFile(wxString fname); 00049 virtual void Clear(); 00051 virtual bool IsEmpty(); 00052 00054 virtual void Update(); 00056 virtual void UpdatePaintBox(); 00057 00064 void SetScale(double scale = scFIT_TO_PAGE); 00066 float GetScale() { return m_scaleV; } 00068 float GetScaleValue() { return m_scale; } 00070 wxImage& GetImage() { return m_image; } 00071 00073 void SetPopupMenu(wxMenu* menu) { m_pmenu = menu; } 00075 wxMenu* GetPopupMenu() { return m_pmenu; } 00076 00077 protected: 00078 wxImage m_image; 00079 double m_scale; 00080 double m_scaleV; 00081 bool m_repaint; 00082 wxMenu* m_pmenu; 00083 bool UpdateScaleValue(); 00084 wxRect getPaintRect(); 00085 virtual void Paint(); 00086 virtual void PaintImg(wxImage& img); 00087 void OnPaint(wxPaintEvent &event); 00088 void OnResize(wxSizeEvent &event); 00089 virtual void OnMouseRightButton(wxMouseEvent &event); 00090 DECLARE_EVENT_TABLE() 00091 }; 00092 00093 wxRect ScaleRect(wxRect rect, double scale); 00094 00095 BEGIN_DECLARE_EVENT_TYPES() 00096 DECLARE_EVENT_TYPE(EVT_COMMAND_IMAGEBOX_IMAGE_CHANGED, 3300) 00097 END_DECLARE_EVENT_TYPES() 00098 00099 #define EVT_IMAGEBOX_IMAGE_CHANGED(id, fn)\ 00100 DECLARE_EVENT_TABLE_ENTRY(EVT_COMMAND_IMAGEBOX_IMAGE_CHANGED, id,\ 00101 wxID_ANY,\ 00102 (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction)& fn, NULL), 00103 00104 #endif // WXVILLALIB_IMAGEBOX_H

Generated on Mon Nov 19 21:06:44 2007 for wxVillaLib by doxygen 1.3.7