]>
Commit | Line | Data |
---|---|---|
fca36d9a JS |
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 | ||
fca36d9a JS |
15 | #include "wx/control.h" |
16 | ||
17 | #include "wx/icon.h" | |
18 | #include "wx/bitmap.h" | |
19 | #include "wx/image.h" | |
20 | ||
6a9e7de9 RD |
21 | #include "wx/gizmos/gizmos.h" |
22 | ||
fca36d9a JS |
23 | enum |
24 | { | |
25 | wxSCALE_HORIZONTAL = 0x1, | |
26 | wxSCALE_VERTICAL = 0x2, | |
27 | wxSCALE_UNIFORM = 0x4, | |
28 | wxSCALE_CUSTOM = 0x8 | |
29 | }; | |
30 | ||
b75c49d1 | 31 | WXDLLIMPEXP_GIZMOS extern const wxChar* wxStaticPictureNameStr; |
fca36d9a | 32 | |
ac73c6c1 | 33 | class WXDLLIMPEXP_GIZMOS wxStaticPicture : public wxControl |
fca36d9a JS |
34 | { |
35 | DECLARE_DYNAMIC_CLASS(wxStaticPicture) | |
36 | ||
37 | public: | |
38 | wxStaticPicture() {} | |
39 | ||
40 | wxStaticPicture( wxWindow* parent, wxWindowID id, | |
41 | const wxBitmap& label, | |
42 | const wxPoint& pos = wxDefaultPosition, | |
43 | const wxSize& size = wxDefaultSize, | |
44 | long style = 0, | |
45 | const wxString& name = wxStaticPictureNameStr ) | |
46 | { | |
47 | Create( parent, id, label, pos, size, style, name ); | |
48 | } | |
49 | ||
50 | bool Create( wxWindow* parent, wxWindowID id, | |
51 | const wxBitmap& label, | |
52 | const wxPoint& pos = wxDefaultPosition, | |
53 | const wxSize& size = wxDefaultSize, | |
54 | long style = 0, | |
55 | const wxString& name = wxStaticPictureNameStr ); | |
56 | ||
a4d72b94 VS |
57 | virtual void Command(wxCommandEvent& WXUNUSED(event)) {} |
58 | virtual bool ProcessCommand(wxCommandEvent& WXUNUSED(event)) {return true;} | |
fca36d9a JS |
59 | void OnPaint(wxPaintEvent& event); |
60 | ||
61 | void SetBitmap( const wxBitmap& bmp ); | |
62 | ||
63 | wxBitmap GetBitmap() const | |
64 | { | |
65 | return Bitmap; | |
66 | } | |
67 | ||
68 | // Icon interface for compatibility with wxStaticBitmap. | |
69 | void SetIcon( const wxIcon& icon ) | |
70 | { | |
71 | wxBitmap bmp; | |
72 | bmp.CopyFromIcon( icon ); | |
73 | SetBitmap( bmp ); | |
74 | } | |
75 | ||
76 | wxIcon GetIcon() const | |
77 | { | |
78 | wxIcon icon; | |
79 | icon.CopyFromBitmap( Bitmap ); | |
80 | return icon; | |
81 | } | |
82 | ||
83 | void SetAlignment( int align ) | |
84 | { | |
85 | Align = align; | |
86 | } | |
87 | ||
88 | int GetAlignment() const | |
89 | { | |
90 | return Align; | |
91 | } | |
92 | ||
93 | void SetScale( int scale ) | |
94 | { | |
95 | Scale = scale; | |
96 | } | |
97 | ||
98 | int GetScale() const | |
99 | { | |
100 | return Scale; | |
101 | } | |
102 | ||
103 | void SetCustomScale( float sx, float sy ) | |
104 | { | |
105 | ScaleX = sx; | |
106 | ScaleY = sy; | |
107 | } | |
108 | ||
c15fd9fb | 109 | void GetCustomScale( float* sx, float* sy ) const |
fca36d9a JS |
110 | { |
111 | *sx = ScaleX; | |
112 | *sy = ScaleY; | |
113 | } | |
114 | ||
115 | protected: | |
116 | wxBitmap Bitmap; | |
117 | ||
118 | int Align; | |
119 | ||
120 | int Scale; | |
121 | float ScaleX; | |
122 | float ScaleY; | |
123 | ||
124 | #ifndef __WXMSW__ | |
125 | // When scaling is enabled, measures are taken to improve performance on non-Windows platforms. | |
126 | // - The original bitmap is stored as a wxImage, because conversion from wxBitmap to wxImage is slow. | |
127 | // - The latest scaled bitmap is cached, this improves performance when the control is repainted | |
128 | // but the size hasn't changed (overlapping windows, movement, etc). | |
129 | wxImage OriginalImage; | |
130 | float LastScaleX; | |
131 | float LastScaleY; | |
132 | wxBitmap ScaledBitmap; | |
133 | #endif | |
134 | ||
135 | DECLARE_EVENT_TABLE() | |
136 | }; | |
137 | ||
138 | #endif // #ifndef _WX_STATPICT_H_ |