]>
Commit | Line | Data |
---|---|---|
da87a1ca | 1 | ///////////////////////////////////////////////////////////////////////////// |
f6bcfd97 | 2 | // Name: src/msw/gauge95.cpp |
da87a1ca JS |
3 | // Purpose: wxGauge95 class |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
6c9a19aa | 8 | // Copyright: (c) Julian Smart |
f6bcfd97 | 9 | // Licence: wxWindows licence |
da87a1ca JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
f6bcfd97 BP |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
14f355c2 | 20 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
f6bcfd97 | 21 | #pragma implementation "gauge95.h" |
da87a1ca JS |
22 | #endif |
23 | ||
24 | // For compilers that support precompilation, includes "wx.h". | |
25 | #include "wx/wxprec.h" | |
26 | ||
27 | #ifdef __BORLANDC__ | |
28 | #pragma hdrstop | |
29 | #endif | |
30 | ||
31 | #ifndef WX_PRECOMP | |
f6bcfd97 | 32 | #include "wx/defs.h" |
da87a1ca JS |
33 | #endif |
34 | ||
47d67540 | 35 | #if wxUSE_GAUGE && defined(__WIN95__) |
da87a1ca JS |
36 | |
37 | #include "wx/msw/gauge95.h" | |
38 | #include "wx/msw/private.h" | |
39 | ||
b39dbf34 | 40 | #if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__)) |
c42404a5 | 41 | #include <commctrl.h> |
da87a1ca JS |
42 | #endif |
43 | ||
f6bcfd97 BP |
44 | // ---------------------------------------------------------------------------- |
45 | // constants | |
46 | // ---------------------------------------------------------------------------- | |
47 | ||
48 | // old commctrl.h (< 4.71) don't have those | |
49 | #ifndef PBS_SMOOTH | |
50 | #define PBS_SMOOTH 0x01 | |
51 | #endif | |
52 | ||
53 | #ifndef PBS_VERTICAL | |
54 | #define PBS_VERTICAL 0x04 | |
55 | #endif | |
56 | ||
57 | #ifndef PBM_SETBARCOLOR | |
58 | #define PBM_SETBARCOLOR (WM_USER+9) | |
59 | #endif | |
60 | ||
61 | #ifndef PBM_SETBKCOLOR | |
62 | #define PBM_SETBKCOLOR 0x2001 | |
63 | #endif | |
64 | ||
65 | // ---------------------------------------------------------------------------- | |
66 | // wxWin macros | |
67 | // ---------------------------------------------------------------------------- | |
68 | ||
51741307 | 69 | #if wxUSE_EXTENDED_RTTI |
bc9fb572 JS |
70 | WX_DEFINE_FLAGS( wxGaugeStyle ) |
71 | ||
72 | WX_BEGIN_FLAGS( wxGaugeStyle ) | |
73 | // new style border flags, we put them first to | |
74 | // use them for streaming out | |
75 | WX_FLAGS_MEMBER(wxBORDER_SIMPLE) | |
76 | WX_FLAGS_MEMBER(wxBORDER_SUNKEN) | |
77 | WX_FLAGS_MEMBER(wxBORDER_DOUBLE) | |
78 | WX_FLAGS_MEMBER(wxBORDER_RAISED) | |
79 | WX_FLAGS_MEMBER(wxBORDER_STATIC) | |
80 | WX_FLAGS_MEMBER(wxBORDER_NONE) | |
81 | ||
82 | // old style border flags | |
83 | WX_FLAGS_MEMBER(wxSIMPLE_BORDER) | |
84 | WX_FLAGS_MEMBER(wxSUNKEN_BORDER) | |
85 | WX_FLAGS_MEMBER(wxDOUBLE_BORDER) | |
86 | WX_FLAGS_MEMBER(wxRAISED_BORDER) | |
87 | WX_FLAGS_MEMBER(wxSTATIC_BORDER) | |
88 | WX_FLAGS_MEMBER(wxNO_BORDER) | |
89 | ||
90 | // standard window styles | |
91 | WX_FLAGS_MEMBER(wxTAB_TRAVERSAL) | |
92 | WX_FLAGS_MEMBER(wxCLIP_CHILDREN) | |
93 | WX_FLAGS_MEMBER(wxTRANSPARENT_WINDOW) | |
94 | WX_FLAGS_MEMBER(wxWANTS_CHARS) | |
95 | WX_FLAGS_MEMBER(wxNO_FULL_REPAINT_ON_RESIZE) | |
96 | WX_FLAGS_MEMBER(wxALWAYS_SHOW_SB ) | |
97 | WX_FLAGS_MEMBER(wxVSCROLL) | |
98 | WX_FLAGS_MEMBER(wxHSCROLL) | |
99 | ||
100 | WX_FLAGS_MEMBER(wxGA_HORIZONTAL) | |
101 | WX_FLAGS_MEMBER(wxGA_VERTICAL) | |
102 | WX_FLAGS_MEMBER(wxGA_PROGRESSBAR) | |
103 | WX_FLAGS_MEMBER(wxGA_SMOOTH) | |
104 | ||
105 | WX_END_FLAGS( wxGaugeStyle ) | |
106 | ||
f0a126fe | 107 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxGauge, wxControl,"wx/gauge.h") |
51741307 SC |
108 | |
109 | WX_BEGIN_PROPERTIES_TABLE(wxGauge95) | |
067e9be6 SC |
110 | WX_PROPERTY( Value , int , SetValue, GetValue, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) |
111 | WX_PROPERTY( Range , int , SetRange, GetRange, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
112 | WX_PROPERTY( ShadowWidth , int , SetShadowWidth, GetShadowWidth, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
113 | WX_PROPERTY( BezelFace , int , SetBezelFace, GetBezelFace, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
bc9fb572 | 114 | WX_PROPERTY_FLAGS( WindowStyle , wxGaugeStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style |
51741307 SC |
115 | WX_END_PROPERTIES_TABLE() |
116 | ||
117 | WX_BEGIN_HANDLERS_TABLE(wxGauge95) | |
118 | WX_END_HANDLERS_TABLE() | |
119 | ||
120 | WX_CONSTRUCTOR_6( wxGauge95 , wxWindow* , Parent , wxWindowID , Id , int , Range , wxPoint , Position , wxSize , Size , long , WindowStyle ) | |
121 | #else | |
122 | IMPLEMENT_DYNAMIC_CLASS(wxGauge95, wxControl) | |
123 | #endif | |
066f1b7a | 124 | |
f6bcfd97 BP |
125 | // ============================================================================ |
126 | // implementation | |
127 | // ============================================================================ | |
128 | ||
debe6624 JS |
129 | bool wxGauge95::Create(wxWindow *parent, wxWindowID id, |
130 | int range, | |
da87a1ca JS |
131 | const wxPoint& pos, |
132 | const wxSize& size, | |
debe6624 | 133 | long style, |
da87a1ca JS |
134 | const wxValidator& validator, |
135 | const wxString& name) | |
136 | { | |
137 | SetName(name); | |
11b6a93b | 138 | #if wxUSE_VALIDATORS |
da87a1ca | 139 | SetValidator(validator); |
11b6a93b | 140 | #endif // wxUSE_VALIDATORS |
da87a1ca JS |
141 | |
142 | if (parent) parent->AddChild(this); | |
143 | m_rangeMax = range; | |
9c331ded | 144 | m_gaugePos = 0; |
da87a1ca | 145 | |
da87a1ca JS |
146 | m_windowStyle = style; |
147 | ||
148 | if ( id == -1 ) | |
4438caf4 | 149 | m_windowId = (int)NewControlId(); |
da87a1ca | 150 | else |
4438caf4 | 151 | m_windowId = id; |
da87a1ca JS |
152 | |
153 | int x = pos.x; | |
154 | int y = pos.y; | |
155 | int width = size.x; | |
156 | int height = size.y; | |
157 | ||
fe3d9123 JS |
158 | WXDWORD exStyle = 0; |
159 | long msFlags = MSWGetStyle(style, & exStyle) ; | |
04a65123 | 160 | |
aeab10d0 JS |
161 | if (m_windowStyle & wxGA_VERTICAL) |
162 | msFlags |= PBS_VERTICAL; | |
163 | ||
164 | if (m_windowStyle & wxGA_SMOOTH) | |
165 | msFlags |= PBS_SMOOTH; | |
da87a1ca JS |
166 | |
167 | HWND wx_button = | |
fe3d9123 | 168 | CreateWindowEx(exStyle, PROGRESS_CLASS, NULL, msFlags, |
da87a1ca JS |
169 | 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, |
170 | wxGetInstance(), NULL); | |
171 | ||
172 | m_hWnd = (WXHWND)wx_button; | |
173 | ||
31334ecb GT |
174 | SetBackgroundColour(parent->GetBackgroundColour()); |
175 | SetForegroundColour(parent->GetForegroundColour()); | |
176 | ||
da87a1ca JS |
177 | // Subclass again for purposes of dialog editing mode |
178 | SubclassWin((WXHWND) wx_button); | |
179 | ||
180 | SendMessage((HWND) GetHWND(), PBM_SETRANGE, 0, MAKELPARAM(0, range)); | |
181 | ||
c0ed460c | 182 | SetFont(parent->GetFont()); |
da87a1ca JS |
183 | |
184 | if (width == -1) | |
185 | width = 50; | |
186 | if (height == -1) | |
92976ab6 | 187 | height = 28; |
da87a1ca JS |
188 | SetSize(x, y, width, height); |
189 | ||
190 | ShowWindow((HWND) GetHWND(), SW_SHOW); | |
191 | ||
192 | return TRUE; | |
193 | } | |
194 | ||
33ac7e6f | 195 | void wxGauge95::SetShadowWidth(int WXUNUSED(w)) |
da87a1ca JS |
196 | { |
197 | } | |
198 | ||
33ac7e6f | 199 | void wxGauge95::SetBezelFace(int WXUNUSED(w)) |
da87a1ca JS |
200 | { |
201 | } | |
202 | ||
debe6624 | 203 | void wxGauge95::SetRange(int r) |
da87a1ca JS |
204 | { |
205 | m_rangeMax = r; | |
206 | ||
207 | SendMessage((HWND) GetHWND(), PBM_SETRANGE, 0, MAKELPARAM(0, r)); | |
208 | } | |
209 | ||
debe6624 | 210 | void wxGauge95::SetValue(int pos) |
da87a1ca JS |
211 | { |
212 | m_gaugePos = pos; | |
213 | ||
214 | SendMessage((HWND) GetHWND(), PBM_SETPOS, pos, 0); | |
215 | } | |
216 | ||
f6bcfd97 | 217 | int wxGauge95::GetShadowWidth() const |
da87a1ca JS |
218 | { |
219 | return 0; | |
220 | } | |
221 | ||
f6bcfd97 | 222 | int wxGauge95::GetBezelFace() const |
da87a1ca JS |
223 | { |
224 | return 0; | |
225 | } | |
226 | ||
f6bcfd97 | 227 | int wxGauge95::GetRange() const |
da87a1ca JS |
228 | { |
229 | return m_rangeMax; | |
230 | } | |
231 | ||
f6bcfd97 | 232 | int wxGauge95::GetValue() const |
da87a1ca JS |
233 | { |
234 | return m_gaugePos; | |
235 | } | |
236 | ||
cc2b7472 | 237 | bool wxGauge95::SetForegroundColour(const wxColour& col) |
da87a1ca | 238 | { |
cc2b7472 VZ |
239 | if ( !wxControl::SetForegroundColour(col) ) |
240 | return FALSE; | |
241 | ||
f6bcfd97 | 242 | SendMessage(GetHwnd(), PBM_SETBARCOLOR, 0, (LPARAM)wxColourToRGB(col)); |
cc2b7472 VZ |
243 | |
244 | return TRUE; | |
da87a1ca JS |
245 | } |
246 | ||
cc2b7472 | 247 | bool wxGauge95::SetBackgroundColour(const wxColour& col) |
da87a1ca | 248 | { |
cc2b7472 VZ |
249 | if ( !wxControl::SetBackgroundColour(col) ) |
250 | return FALSE; | |
251 | ||
f6bcfd97 | 252 | SendMessage(GetHwnd(), PBM_SETBKCOLOR, 0, (LPARAM)wxColourToRGB(col)); |
cc2b7472 VZ |
253 | |
254 | return TRUE; | |
da87a1ca JS |
255 | } |
256 | ||
47d67540 | 257 | #endif // wxUSE_GAUGE |