]> git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/gizmos/statpict.h
mark slider as being transparent, otherwise it has ugly solid grey background when...
[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 WXDLLIMPEXP_GIZMOS extern const wxChar* wxStaticPictureNameStr;
36
37 class WXDLLIMPEXP_GIZMOS wxStaticPicture : public wxControl
38 {
39 DECLARE_DYNAMIC_CLASS(wxStaticPicture)
40
41 public:
42 wxStaticPicture() {}
43
44 wxStaticPicture( wxWindow* parent, wxWindowID id,
45 const wxBitmap& label,
46 const wxPoint& pos = wxDefaultPosition,
47 const wxSize& size = wxDefaultSize,
48 long style = 0,
49 const wxString& name = wxStaticPictureNameStr )
50 {
51 Create( parent, id, label, pos, size, style, name );
52 }
53
54 bool Create( wxWindow* parent, wxWindowID id,
55 const wxBitmap& label,
56 const wxPoint& pos = wxDefaultPosition,
57 const wxSize& size = wxDefaultSize,
58 long style = 0,
59 const wxString& name = wxStaticPictureNameStr );
60
61 virtual void Command(wxCommandEvent& WXUNUSED(event)) {}
62 virtual bool ProcessCommand(wxCommandEvent& WXUNUSED(event)) {return true;}
63 void OnPaint(wxPaintEvent& event);
64
65 void SetBitmap( const wxBitmap& bmp );
66
67 wxBitmap GetBitmap() const
68 {
69 return Bitmap;
70 }
71
72 // Icon interface for compatibility with wxStaticBitmap.
73 void SetIcon( const wxIcon& icon )
74 {
75 wxBitmap bmp;
76 bmp.CopyFromIcon( icon );
77 SetBitmap( bmp );
78 }
79
80 wxIcon GetIcon() const
81 {
82 wxIcon icon;
83 icon.CopyFromBitmap( Bitmap );
84 return icon;
85 }
86
87 void SetAlignment( int align )
88 {
89 Align = align;
90 }
91
92 int GetAlignment() const
93 {
94 return Align;
95 }
96
97 void SetScale( int scale )
98 {
99 Scale = scale;
100 }
101
102 int GetScale() const
103 {
104 return Scale;
105 }
106
107 void SetCustomScale( float sx, float sy )
108 {
109 ScaleX = sx;
110 ScaleY = sy;
111 }
112
113 void GetCustomScale( float* sx, float* sy ) const
114 {
115 *sx = ScaleX;
116 *sy = ScaleY;
117 }
118
119 protected:
120 wxBitmap Bitmap;
121
122 int Align;
123
124 int Scale;
125 float ScaleX;
126 float ScaleY;
127
128 #ifndef __WXMSW__
129 // When scaling is enabled, measures are taken to improve performance on non-Windows platforms.
130 // - The original bitmap is stored as a wxImage, because conversion from wxBitmap to wxImage is slow.
131 // - The latest scaled bitmap is cached, this improves performance when the control is repainted
132 // but the size hasn't changed (overlapping windows, movement, etc).
133 wxImage OriginalImage;
134 float LastScaleX;
135 float LastScaleY;
136 wxBitmap ScaledBitmap;
137 #endif
138
139 DECLARE_EVENT_TABLE()
140 };
141
142 #endif // #ifndef _WX_STATPICT_H_