]>
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 SC |
69 | #if wxUSE_EXTENDED_RTTI |
70 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxGauge95, wxControl,"wx/gauge.h") | |
71 | ||
72 | WX_BEGIN_PROPERTIES_TABLE(wxGauge95) | |
73 | WX_PROPERTY( Value , int , SetValue, GetValue, 0 ) | |
74 | WX_PROPERTY( Range , int , SetRange, GetRange, 0 ) | |
75 | WX_PROPERTY( ShadowWidth , int , SetShadowWidth, GetShadowWidth, 0 ) | |
76 | WX_PROPERTY( BezelFace , int , SetBezelFace, GetBezelFace, 0 ) | |
066f1b7a SC |
77 | /* |
78 | TODO PROPERTIES | |
51741307 | 79 | style wxGA_HORIZONTAL |
066f1b7a | 80 | */ |
51741307 SC |
81 | WX_END_PROPERTIES_TABLE() |
82 | ||
83 | WX_BEGIN_HANDLERS_TABLE(wxGauge95) | |
84 | WX_END_HANDLERS_TABLE() | |
85 | ||
86 | WX_CONSTRUCTOR_6( wxGauge95 , wxWindow* , Parent , wxWindowID , Id , int , Range , wxPoint , Position , wxSize , Size , long , WindowStyle ) | |
87 | #else | |
88 | IMPLEMENT_DYNAMIC_CLASS(wxGauge95, wxControl) | |
89 | #endif | |
066f1b7a | 90 | |
f6bcfd97 BP |
91 | // ============================================================================ |
92 | // implementation | |
93 | // ============================================================================ | |
94 | ||
debe6624 JS |
95 | bool wxGauge95::Create(wxWindow *parent, wxWindowID id, |
96 | int range, | |
da87a1ca JS |
97 | const wxPoint& pos, |
98 | const wxSize& size, | |
debe6624 | 99 | long style, |
da87a1ca JS |
100 | const wxValidator& validator, |
101 | const wxString& name) | |
102 | { | |
103 | SetName(name); | |
11b6a93b | 104 | #if wxUSE_VALIDATORS |
da87a1ca | 105 | SetValidator(validator); |
11b6a93b | 106 | #endif // wxUSE_VALIDATORS |
da87a1ca JS |
107 | |
108 | if (parent) parent->AddChild(this); | |
109 | m_rangeMax = range; | |
9c331ded | 110 | m_gaugePos = 0; |
da87a1ca | 111 | |
da87a1ca JS |
112 | m_windowStyle = style; |
113 | ||
114 | if ( id == -1 ) | |
4438caf4 | 115 | m_windowId = (int)NewControlId(); |
da87a1ca | 116 | else |
4438caf4 | 117 | m_windowId = id; |
da87a1ca JS |
118 | |
119 | int x = pos.x; | |
120 | int y = pos.y; | |
121 | int width = size.x; | |
122 | int height = size.y; | |
123 | ||
fe3d9123 JS |
124 | WXDWORD exStyle = 0; |
125 | long msFlags = MSWGetStyle(style, & exStyle) ; | |
04a65123 | 126 | |
aeab10d0 JS |
127 | if (m_windowStyle & wxGA_VERTICAL) |
128 | msFlags |= PBS_VERTICAL; | |
129 | ||
130 | if (m_windowStyle & wxGA_SMOOTH) | |
131 | msFlags |= PBS_SMOOTH; | |
da87a1ca JS |
132 | |
133 | HWND wx_button = | |
fe3d9123 | 134 | CreateWindowEx(exStyle, PROGRESS_CLASS, NULL, msFlags, |
da87a1ca JS |
135 | 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, |
136 | wxGetInstance(), NULL); | |
137 | ||
138 | m_hWnd = (WXHWND)wx_button; | |
139 | ||
31334ecb GT |
140 | SetBackgroundColour(parent->GetBackgroundColour()); |
141 | SetForegroundColour(parent->GetForegroundColour()); | |
142 | ||
da87a1ca JS |
143 | // Subclass again for purposes of dialog editing mode |
144 | SubclassWin((WXHWND) wx_button); | |
145 | ||
146 | SendMessage((HWND) GetHWND(), PBM_SETRANGE, 0, MAKELPARAM(0, range)); | |
147 | ||
c0ed460c | 148 | SetFont(parent->GetFont()); |
da87a1ca JS |
149 | |
150 | if (width == -1) | |
151 | width = 50; | |
152 | if (height == -1) | |
92976ab6 | 153 | height = 28; |
da87a1ca JS |
154 | SetSize(x, y, width, height); |
155 | ||
156 | ShowWindow((HWND) GetHWND(), SW_SHOW); | |
157 | ||
158 | return TRUE; | |
159 | } | |
160 | ||
33ac7e6f | 161 | void wxGauge95::SetShadowWidth(int WXUNUSED(w)) |
da87a1ca JS |
162 | { |
163 | } | |
164 | ||
33ac7e6f | 165 | void wxGauge95::SetBezelFace(int WXUNUSED(w)) |
da87a1ca JS |
166 | { |
167 | } | |
168 | ||
debe6624 | 169 | void wxGauge95::SetRange(int r) |
da87a1ca JS |
170 | { |
171 | m_rangeMax = r; | |
172 | ||
173 | SendMessage((HWND) GetHWND(), PBM_SETRANGE, 0, MAKELPARAM(0, r)); | |
174 | } | |
175 | ||
debe6624 | 176 | void wxGauge95::SetValue(int pos) |
da87a1ca JS |
177 | { |
178 | m_gaugePos = pos; | |
179 | ||
180 | SendMessage((HWND) GetHWND(), PBM_SETPOS, pos, 0); | |
181 | } | |
182 | ||
f6bcfd97 | 183 | int wxGauge95::GetShadowWidth() const |
da87a1ca JS |
184 | { |
185 | return 0; | |
186 | } | |
187 | ||
f6bcfd97 | 188 | int wxGauge95::GetBezelFace() const |
da87a1ca JS |
189 | { |
190 | return 0; | |
191 | } | |
192 | ||
f6bcfd97 | 193 | int wxGauge95::GetRange() const |
da87a1ca JS |
194 | { |
195 | return m_rangeMax; | |
196 | } | |
197 | ||
f6bcfd97 | 198 | int wxGauge95::GetValue() const |
da87a1ca JS |
199 | { |
200 | return m_gaugePos; | |
201 | } | |
202 | ||
cc2b7472 | 203 | bool wxGauge95::SetForegroundColour(const wxColour& col) |
da87a1ca | 204 | { |
cc2b7472 VZ |
205 | if ( !wxControl::SetForegroundColour(col) ) |
206 | return FALSE; | |
207 | ||
f6bcfd97 | 208 | SendMessage(GetHwnd(), PBM_SETBARCOLOR, 0, (LPARAM)wxColourToRGB(col)); |
cc2b7472 VZ |
209 | |
210 | return TRUE; | |
da87a1ca JS |
211 | } |
212 | ||
cc2b7472 | 213 | bool wxGauge95::SetBackgroundColour(const wxColour& col) |
da87a1ca | 214 | { |
cc2b7472 VZ |
215 | if ( !wxControl::SetBackgroundColour(col) ) |
216 | return FALSE; | |
217 | ||
f6bcfd97 | 218 | SendMessage(GetHwnd(), PBM_SETBKCOLOR, 0, (LPARAM)wxColourToRGB(col)); |
cc2b7472 VZ |
219 | |
220 | return TRUE; | |
da87a1ca JS |
221 | } |
222 | ||
47d67540 | 223 | #endif // wxUSE_GAUGE |