]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/gizmos/statpict.h
More WXDLLIMPEXP_GIZMOS fixes
[wxWidgets.git] / contrib / include / wx / gizmos / statpict.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: statpict.h
3 // Purpose: wxStaticPicture class
4 // Author: Wade Brainerd
5 // Modified by:
6 // Created: 2003-05-01
7 // RCS-ID:
8 // Copyright: (c) Wade Brainerd
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_STATPICT_H_
13 #define _WX_STATPICT_H_
14
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "statpict.h"
17 #endif
18
19 #include "wx/control.h"
20
21 #include "wx/icon.h"
22 #include "wx/bitmap.h"
23 #include "wx/image.h"
24
25 #include "wx/gizmos/gizmos.h"
26
27 enum
28 {
29 wxSCALE_HORIZONTAL = 0x1,
30 wxSCALE_VERTICAL = 0x2,
31 wxSCALE_UNIFORM = 0x4,
32 wxSCALE_CUSTOM = 0x8
33 };
34
35 //WXDLLEXPORT_DATA(extern const wxChar*) wxStaticBitmapNameStr;
36 extern const wxChar* wxStaticPictureNameStr;
37
38 class WXDLLIMPEXP_GIZMOS wxStaticPicture : public wxControl
39 {
40 DECLARE_DYNAMIC_CLASS(wxStaticPicture)
41
42 public:
43 wxStaticPicture() {}
44
45 wxStaticPicture( wxWindow* parent, wxWindowID id,
46 const wxBitmap& label,
47 const wxPoint& pos = wxDefaultPosition,
48 const wxSize& size = wxDefaultSize,
49 long style = 0,
50 const wxString& name = wxStaticPictureNameStr )
51 {
52 Create( parent, id, label, pos, size, style, name );
53 }
54
55 bool Create( wxWindow* parent, wxWindowID id,
56 const wxBitmap& label,
57 const wxPoint& pos = wxDefaultPosition,
58 const wxSize& size = wxDefaultSize,
59 long style = 0,
60 const wxString& name = wxStaticPictureNameStr );
61
62 virtual void Command(wxCommandEvent& WXUNUSED(event)) {}
63 virtual bool ProcessCommand(wxCommandEvent& WXUNUSED(event)) {return true;}
64 void OnPaint(wxPaintEvent& event);
65
66 void SetBitmap( const wxBitmap& bmp );
67
68 wxBitmap GetBitmap() const
69 {
70 return Bitmap;
71 }
72
73 // Icon interface for compatibility with wxStaticBitmap.
74 void SetIcon( const wxIcon& icon )
75 {
76 wxBitmap bmp;
77 bmp.CopyFromIcon( icon );
78 SetBitmap( bmp );
79 }
80
81 wxIcon GetIcon() const
82 {
83 wxIcon icon;
84 icon.CopyFromBitmap( Bitmap );
85 return icon;
86 }
87
88 void SetAlignment( int align )
89 {
90 Align = align;
91 }
92
93 int GetAlignment() const
94 {
95 return Align;
96 }
97
98 void SetScale( int scale )
99 {
100 Scale = scale;
101 }
102
103 int GetScale() const
104 {
105 return Scale;
106 }
107
108 void SetCustomScale( float sx, float sy )
109 {
110 ScaleX = sx;
111 ScaleY = sy;
112 }
113
114 void GetCustomScale( float* sx, float* sy ) const
115 {
116 *sx = ScaleX;
117 *sy = ScaleY;
118 }
119
120 protected:
121 wxBitmap Bitmap;
122
123 int Align;
124
125 int Scale;
126 float ScaleX;
127 float ScaleY;
128
129 #ifndef __WXMSW__
130 // When scaling is enabled, measures are taken to improve performance on non-Windows platforms.
131 // - The original bitmap is stored as a wxImage, because conversion from wxBitmap to wxImage is slow.
132 // - The latest scaled bitmap is cached, this improves performance when the control is repainted
133 // but the size hasn't changed (overlapping windows, movement, etc).
134 wxImage OriginalImage;
135 float LastScaleX;
136 float LastScaleY;
137 wxBitmap ScaledBitmap;
138 #endif
139
140 DECLARE_EVENT_TABLE()
141 };
142
143 #endif // #ifndef _WX_STATPICT_H_