]>
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__ | |
da0f19f8 | 28 | #pragma hdrstop |
da87a1ca JS |
29 | #endif |
30 | ||
31 | #ifndef WX_PRECOMP | |
f6bcfd97 | 32 | #include "wx/defs.h" |
da87a1ca JS |
33 | #endif |
34 | ||
da0f19f8 | 35 | #if wxUSE_GAUGE |
da87a1ca | 36 | |
f4998a1c | 37 | #include "wx/gauge.h" |
da87a1ca JS |
38 | #include "wx/msw/private.h" |
39 | ||
da0f19f8 | 40 | #if !(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 | ||
3ff066a4 | 72 | wxBEGIN_FLAGS( wxGaugeStyle ) |
bc9fb572 JS |
73 | // new style border flags, we put them first to |
74 | // use them for streaming out | |
3ff066a4 SC |
75 | wxFLAGS_MEMBER(wxBORDER_SIMPLE) |
76 | wxFLAGS_MEMBER(wxBORDER_SUNKEN) | |
77 | wxFLAGS_MEMBER(wxBORDER_DOUBLE) | |
78 | wxFLAGS_MEMBER(wxBORDER_RAISED) | |
79 | wxFLAGS_MEMBER(wxBORDER_STATIC) | |
80 | wxFLAGS_MEMBER(wxBORDER_NONE) | |
bc9fb572 JS |
81 | |
82 | // old style border flags | |
3ff066a4 SC |
83 | wxFLAGS_MEMBER(wxSIMPLE_BORDER) |
84 | wxFLAGS_MEMBER(wxSUNKEN_BORDER) | |
85 | wxFLAGS_MEMBER(wxDOUBLE_BORDER) | |
86 | wxFLAGS_MEMBER(wxRAISED_BORDER) | |
87 | wxFLAGS_MEMBER(wxSTATIC_BORDER) | |
cb0afb26 | 88 | wxFLAGS_MEMBER(wxBORDER) |
bc9fb572 JS |
89 | |
90 | // standard window styles | |
3ff066a4 SC |
91 | wxFLAGS_MEMBER(wxTAB_TRAVERSAL) |
92 | wxFLAGS_MEMBER(wxCLIP_CHILDREN) | |
93 | wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) | |
94 | wxFLAGS_MEMBER(wxWANTS_CHARS) | |
cb0afb26 | 95 | wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) |
3ff066a4 SC |
96 | wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) |
97 | wxFLAGS_MEMBER(wxVSCROLL) | |
98 | wxFLAGS_MEMBER(wxHSCROLL) | |
99 | ||
100 | wxFLAGS_MEMBER(wxGA_HORIZONTAL) | |
101 | wxFLAGS_MEMBER(wxGA_VERTICAL) | |
102 | wxFLAGS_MEMBER(wxGA_PROGRESSBAR) | |
103 | wxFLAGS_MEMBER(wxGA_SMOOTH) | |
104 | ||
105 | wxEND_FLAGS( wxGaugeStyle ) | |
bc9fb572 | 106 | |
f0a126fe | 107 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxGauge, wxControl,"wx/gauge.h") |
51741307 | 108 | |
3ff066a4 | 109 | wxBEGIN_PROPERTIES_TABLE(wxGauge95) |
da0f19f8 VZ |
110 | wxPROPERTY( Value , int , SetValue, GetValue, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) |
111 | wxPROPERTY( Range , int , SetRange, GetRange, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
112 | wxPROPERTY( ShadowWidth , int , SetShadowWidth, GetShadowWidth, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
113 | wxPROPERTY( BezelFace , int , SetBezelFace, GetBezelFace, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
3ff066a4 SC |
114 | wxPROPERTY_FLAGS( WindowStyle , wxGaugeStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style |
115 | wxEND_PROPERTIES_TABLE() | |
51741307 | 116 | |
3ff066a4 SC |
117 | wxBEGIN_HANDLERS_TABLE(wxGauge95) |
118 | wxEND_HANDLERS_TABLE() | |
51741307 | 119 | |
3ff066a4 | 120 | wxCONSTRUCTOR_6( wxGauge95 , wxWindow* , Parent , wxWindowID , Id , int , Range , wxPoint , Position , wxSize , Size , long , WindowStyle ) |
51741307 SC |
121 | #else |
122 | IMPLEMENT_DYNAMIC_CLASS(wxGauge95, wxControl) | |
123 | #endif | |
066f1b7a | 124 | |
f6bcfd97 | 125 | // ============================================================================ |
da0f19f8 | 126 | // wxGauge95 implementation |
f6bcfd97 BP |
127 | // ============================================================================ |
128 | ||
da0f19f8 VZ |
129 | // ---------------------------------------------------------------------------- |
130 | // wxGauge95 creation | |
131 | // ---------------------------------------------------------------------------- | |
da87a1ca | 132 | |
da0f19f8 VZ |
133 | bool wxGauge95::Create(wxWindow *parent, |
134 | wxWindowID id, | |
135 | int range, | |
136 | const wxPoint& pos, | |
137 | const wxSize& size, | |
138 | long style, | |
139 | const wxValidator& validator, | |
140 | const wxString& name) | |
141 | { | |
142 | if ( !CreateControl(parent, id, pos, size, style, validator, name) ) | |
143 | return false; | |
da87a1ca | 144 | |
da0f19f8 VZ |
145 | if ( !MSWCreateControl(PROGRESS_CLASS, wxEmptyString, pos, size) ) |
146 | return false; | |
da87a1ca | 147 | |
da0f19f8 VZ |
148 | SetBackgroundColour(parent->GetBackgroundColour()); |
149 | SetForegroundColour(parent->GetForegroundColour()); | |
31334ecb | 150 | |
da0f19f8 | 151 | SetRange(range); |
da87a1ca | 152 | |
da0f19f8 VZ |
153 | return true; |
154 | } | |
da87a1ca | 155 | |
da0f19f8 VZ |
156 | WXDWORD wxGauge95::MSWGetStyle(long style, WXDWORD *exstyle) const |
157 | { | |
158 | WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle); | |
da87a1ca | 159 | |
da0f19f8 VZ |
160 | if ( style & wxGA_VERTICAL ) |
161 | msStyle |= PBS_VERTICAL; | |
da87a1ca | 162 | |
da0f19f8 VZ |
163 | if ( style & wxGA_SMOOTH ) |
164 | msStyle |= PBS_SMOOTH; | |
da87a1ca | 165 | |
da0f19f8 | 166 | return msStyle; |
da87a1ca JS |
167 | } |
168 | ||
da0f19f8 VZ |
169 | // ---------------------------------------------------------------------------- |
170 | // wxGauge95 geometry | |
171 | // ---------------------------------------------------------------------------- | |
da87a1ca | 172 | |
da0f19f8 | 173 | wxSize wxGauge95::DoGetBestSize() const |
da87a1ca | 174 | { |
da0f19f8 VZ |
175 | // VZ: no idea where does 28 come from, it was there before my changes and |
176 | // as nobody ever complained I guess we can leave it... | |
177 | return wxSize(100, 28); | |
da87a1ca JS |
178 | } |
179 | ||
da0f19f8 VZ |
180 | // ---------------------------------------------------------------------------- |
181 | // wxGauge95 setters | |
182 | // ---------------------------------------------------------------------------- | |
183 | ||
debe6624 | 184 | void wxGauge95::SetRange(int r) |
da87a1ca | 185 | { |
da0f19f8 | 186 | m_rangeMax = r; |
da87a1ca | 187 | |
9a78988f | 188 | #ifdef PBM_SETRANGE32 |
da0f19f8 | 189 | ::SendMessage(GetHwnd(), PBM_SETRANGE32, 0, r); |
9a78988f | 190 | #else // !PBM_SETRANGE32 |
da0f19f8 VZ |
191 | // fall back to PBM_SETRANGE (limited to 16 bits) |
192 | ::SendMessage(GetHwnd(), PBM_SETRANGE, 0, MAKELPARAM(0, r)); | |
9a78988f | 193 | #endif // PBM_SETRANGE32/!PBM_SETRANGE32 |
da87a1ca JS |
194 | } |
195 | ||
debe6624 | 196 | void wxGauge95::SetValue(int pos) |
da87a1ca | 197 | { |
da0f19f8 | 198 | m_gaugePos = pos; |
da87a1ca | 199 | |
da0f19f8 | 200 | ::SendMessage(GetHwnd(), PBM_SETPOS, pos, 0); |
da87a1ca JS |
201 | } |
202 | ||
cc2b7472 | 203 | bool wxGauge95::SetForegroundColour(const wxColour& col) |
da87a1ca | 204 | { |
cc2b7472 | 205 | if ( !wxControl::SetForegroundColour(col) ) |
da0f19f8 | 206 | return false; |
cc2b7472 | 207 | |
da0f19f8 | 208 | ::SendMessage(GetHwnd(), PBM_SETBARCOLOR, 0, (LPARAM)wxColourToRGB(col)); |
cc2b7472 | 209 | |
da0f19f8 | 210 | return true; |
da87a1ca JS |
211 | } |
212 | ||
cc2b7472 | 213 | bool wxGauge95::SetBackgroundColour(const wxColour& col) |
da87a1ca | 214 | { |
cc2b7472 | 215 | if ( !wxControl::SetBackgroundColour(col) ) |
da0f19f8 | 216 | return false; |
cc2b7472 | 217 | |
da0f19f8 | 218 | ::SendMessage(GetHwnd(), PBM_SETBKCOLOR, 0, (LPARAM)wxColourToRGB(col)); |
cc2b7472 | 219 | |
da0f19f8 | 220 | return true; |
da87a1ca JS |
221 | } |
222 | ||
47d67540 | 223 | #endif // wxUSE_GAUGE |
da0f19f8 | 224 |