]>
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$ | |
8 | // Copyright: (c) Julian Smart and Markus Holzem | |
f6bcfd97 | 9 | // Licence: wxWindows licence |
da87a1ca JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
f6bcfd97 BP |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
da87a1ca | 20 | #ifdef __GNUG__ |
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 | ||
c42404a5 VZ |
40 | #if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) || defined(__TWIN32__)) |
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 | ||
da87a1ca | 69 | IMPLEMENT_DYNAMIC_CLASS(wxGauge95, wxControl) |
da87a1ca | 70 | |
f6bcfd97 BP |
71 | // ============================================================================ |
72 | // implementation | |
73 | // ============================================================================ | |
74 | ||
debe6624 JS |
75 | bool wxGauge95::Create(wxWindow *parent, wxWindowID id, |
76 | int range, | |
da87a1ca JS |
77 | const wxPoint& pos, |
78 | const wxSize& size, | |
debe6624 | 79 | long style, |
da87a1ca JS |
80 | const wxValidator& validator, |
81 | const wxString& name) | |
82 | { | |
83 | SetName(name); | |
11b6a93b | 84 | #if wxUSE_VALIDATORS |
da87a1ca | 85 | SetValidator(validator); |
11b6a93b | 86 | #endif // wxUSE_VALIDATORS |
da87a1ca JS |
87 | |
88 | if (parent) parent->AddChild(this); | |
89 | m_rangeMax = range; | |
9c331ded | 90 | m_gaugePos = 0; |
da87a1ca | 91 | |
da87a1ca JS |
92 | m_windowStyle = style; |
93 | ||
94 | if ( id == -1 ) | |
4438caf4 | 95 | m_windowId = (int)NewControlId(); |
da87a1ca | 96 | else |
4438caf4 | 97 | m_windowId = id; |
da87a1ca JS |
98 | |
99 | int x = pos.x; | |
100 | int y = pos.y; | |
101 | int width = size.x; | |
102 | int height = size.y; | |
103 | ||
f6bcfd97 | 104 | long msFlags = WS_CHILD | WS_VISIBLE /* | WS_CLIPSIBLINGS */; |
04a65123 | 105 | |
aeab10d0 JS |
106 | if (m_windowStyle & wxGA_VERTICAL) |
107 | msFlags |= PBS_VERTICAL; | |
108 | ||
109 | if (m_windowStyle & wxGA_SMOOTH) | |
110 | msFlags |= PBS_SMOOTH; | |
da87a1ca JS |
111 | |
112 | HWND wx_button = | |
113 | CreateWindowEx(MakeExtendedStyle(m_windowStyle), PROGRESS_CLASS, NULL, msFlags, | |
114 | 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, | |
115 | wxGetInstance(), NULL); | |
116 | ||
117 | m_hWnd = (WXHWND)wx_button; | |
118 | ||
31334ecb GT |
119 | SetBackgroundColour(parent->GetBackgroundColour()); |
120 | SetForegroundColour(parent->GetForegroundColour()); | |
121 | ||
da87a1ca JS |
122 | // Subclass again for purposes of dialog editing mode |
123 | SubclassWin((WXHWND) wx_button); | |
124 | ||
125 | SendMessage((HWND) GetHWND(), PBM_SETRANGE, 0, MAKELPARAM(0, range)); | |
126 | ||
c0ed460c | 127 | SetFont(parent->GetFont()); |
da87a1ca JS |
128 | |
129 | if (width == -1) | |
130 | width = 50; | |
131 | if (height == -1) | |
92976ab6 | 132 | height = 28; |
da87a1ca JS |
133 | SetSize(x, y, width, height); |
134 | ||
135 | ShowWindow((HWND) GetHWND(), SW_SHOW); | |
136 | ||
137 | return TRUE; | |
138 | } | |
139 | ||
33ac7e6f | 140 | void wxGauge95::SetShadowWidth(int WXUNUSED(w)) |
da87a1ca JS |
141 | { |
142 | } | |
143 | ||
33ac7e6f | 144 | void wxGauge95::SetBezelFace(int WXUNUSED(w)) |
da87a1ca JS |
145 | { |
146 | } | |
147 | ||
debe6624 | 148 | void wxGauge95::SetRange(int r) |
da87a1ca JS |
149 | { |
150 | m_rangeMax = r; | |
151 | ||
152 | SendMessage((HWND) GetHWND(), PBM_SETRANGE, 0, MAKELPARAM(0, r)); | |
153 | } | |
154 | ||
debe6624 | 155 | void wxGauge95::SetValue(int pos) |
da87a1ca JS |
156 | { |
157 | m_gaugePos = pos; | |
158 | ||
159 | SendMessage((HWND) GetHWND(), PBM_SETPOS, pos, 0); | |
160 | } | |
161 | ||
f6bcfd97 | 162 | int wxGauge95::GetShadowWidth() const |
da87a1ca JS |
163 | { |
164 | return 0; | |
165 | } | |
166 | ||
f6bcfd97 | 167 | int wxGauge95::GetBezelFace() const |
da87a1ca JS |
168 | { |
169 | return 0; | |
170 | } | |
171 | ||
f6bcfd97 | 172 | int wxGauge95::GetRange() const |
da87a1ca JS |
173 | { |
174 | return m_rangeMax; | |
175 | } | |
176 | ||
f6bcfd97 | 177 | int wxGauge95::GetValue() const |
da87a1ca JS |
178 | { |
179 | return m_gaugePos; | |
180 | } | |
181 | ||
cc2b7472 | 182 | bool wxGauge95::SetForegroundColour(const wxColour& col) |
da87a1ca | 183 | { |
cc2b7472 VZ |
184 | if ( !wxControl::SetForegroundColour(col) ) |
185 | return FALSE; | |
186 | ||
f6bcfd97 | 187 | SendMessage(GetHwnd(), PBM_SETBARCOLOR, 0, (LPARAM)wxColourToRGB(col)); |
cc2b7472 VZ |
188 | |
189 | return TRUE; | |
da87a1ca JS |
190 | } |
191 | ||
cc2b7472 | 192 | bool wxGauge95::SetBackgroundColour(const wxColour& col) |
da87a1ca | 193 | { |
cc2b7472 VZ |
194 | if ( !wxControl::SetBackgroundColour(col) ) |
195 | return FALSE; | |
196 | ||
f6bcfd97 | 197 | SendMessage(GetHwnd(), PBM_SETBKCOLOR, 0, (LPARAM)wxColourToRGB(col)); |
cc2b7472 VZ |
198 | |
199 | return TRUE; | |
da87a1ca JS |
200 | } |
201 | ||
47d67540 | 202 | #endif // wxUSE_GAUGE |