]>
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 |
65571936 | 9 | // Licence: wxWindows licence |
da87a1ca JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
f6bcfd97 BP |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
da87a1ca JS |
20 | // For compilers that support precompilation, includes "wx.h". |
21 | #include "wx/wxprec.h" | |
22 | ||
23 | #ifdef __BORLANDC__ | |
da0f19f8 | 24 | #pragma hdrstop |
da87a1ca JS |
25 | #endif |
26 | ||
27 | #ifndef WX_PRECOMP | |
f6bcfd97 | 28 | #include "wx/defs.h" |
da87a1ca JS |
29 | #endif |
30 | ||
da0f19f8 | 31 | #if wxUSE_GAUGE |
da87a1ca | 32 | |
f4998a1c | 33 | #include "wx/gauge.h" |
da87a1ca JS |
34 | #include "wx/msw/private.h" |
35 | ||
da0f19f8 | 36 | #if !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__)) |
c42404a5 | 37 | #include <commctrl.h> |
da87a1ca JS |
38 | #endif |
39 | ||
f6bcfd97 BP |
40 | // ---------------------------------------------------------------------------- |
41 | // constants | |
42 | // ---------------------------------------------------------------------------- | |
43 | ||
44 | // old commctrl.h (< 4.71) don't have those | |
45 | #ifndef PBS_SMOOTH | |
46 | #define PBS_SMOOTH 0x01 | |
47 | #endif | |
48 | ||
49 | #ifndef PBS_VERTICAL | |
50 | #define PBS_VERTICAL 0x04 | |
51 | #endif | |
52 | ||
53 | #ifndef PBM_SETBARCOLOR | |
54 | #define PBM_SETBARCOLOR (WM_USER+9) | |
55 | #endif | |
56 | ||
57 | #ifndef PBM_SETBKCOLOR | |
58 | #define PBM_SETBKCOLOR 0x2001 | |
59 | #endif | |
60 | ||
61 | // ---------------------------------------------------------------------------- | |
62 | // wxWin macros | |
63 | // ---------------------------------------------------------------------------- | |
64 | ||
51741307 | 65 | #if wxUSE_EXTENDED_RTTI |
bc9fb572 JS |
66 | WX_DEFINE_FLAGS( wxGaugeStyle ) |
67 | ||
3ff066a4 | 68 | wxBEGIN_FLAGS( wxGaugeStyle ) |
bc9fb572 JS |
69 | // new style border flags, we put them first to |
70 | // use them for streaming out | |
3ff066a4 SC |
71 | wxFLAGS_MEMBER(wxBORDER_SIMPLE) |
72 | wxFLAGS_MEMBER(wxBORDER_SUNKEN) | |
73 | wxFLAGS_MEMBER(wxBORDER_DOUBLE) | |
74 | wxFLAGS_MEMBER(wxBORDER_RAISED) | |
75 | wxFLAGS_MEMBER(wxBORDER_STATIC) | |
76 | wxFLAGS_MEMBER(wxBORDER_NONE) | |
213ceb3f | 77 | |
bc9fb572 | 78 | // old style border flags |
3ff066a4 SC |
79 | wxFLAGS_MEMBER(wxSIMPLE_BORDER) |
80 | wxFLAGS_MEMBER(wxSUNKEN_BORDER) | |
81 | wxFLAGS_MEMBER(wxDOUBLE_BORDER) | |
82 | wxFLAGS_MEMBER(wxRAISED_BORDER) | |
83 | wxFLAGS_MEMBER(wxSTATIC_BORDER) | |
cb0afb26 | 84 | wxFLAGS_MEMBER(wxBORDER) |
bc9fb572 JS |
85 | |
86 | // standard window styles | |
3ff066a4 SC |
87 | wxFLAGS_MEMBER(wxTAB_TRAVERSAL) |
88 | wxFLAGS_MEMBER(wxCLIP_CHILDREN) | |
89 | wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW) | |
90 | wxFLAGS_MEMBER(wxWANTS_CHARS) | |
cb0afb26 | 91 | wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE) |
3ff066a4 SC |
92 | wxFLAGS_MEMBER(wxALWAYS_SHOW_SB ) |
93 | wxFLAGS_MEMBER(wxVSCROLL) | |
94 | wxFLAGS_MEMBER(wxHSCROLL) | |
95 | ||
96 | wxFLAGS_MEMBER(wxGA_HORIZONTAL) | |
97 | wxFLAGS_MEMBER(wxGA_VERTICAL) | |
40ff126a | 98 | #if WXWIN_COMPATIBILITY_2_6 |
3ff066a4 | 99 | wxFLAGS_MEMBER(wxGA_PROGRESSBAR) |
40ff126a | 100 | #endif // WXWIN_COMPATIBILITY_2_6 |
3ff066a4 SC |
101 | wxFLAGS_MEMBER(wxGA_SMOOTH) |
102 | ||
103 | wxEND_FLAGS( wxGaugeStyle ) | |
bc9fb572 | 104 | |
f0a126fe | 105 | IMPLEMENT_DYNAMIC_CLASS_XTI(wxGauge, wxControl,"wx/gauge.h") |
51741307 | 106 | |
3ff066a4 | 107 | wxBEGIN_PROPERTIES_TABLE(wxGauge95) |
da0f19f8 VZ |
108 | wxPROPERTY( Value , int , SetValue, GetValue, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) |
109 | wxPROPERTY( Range , int , SetRange, GetRange, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
110 | wxPROPERTY( ShadowWidth , int , SetShadowWidth, GetShadowWidth, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
111 | wxPROPERTY( BezelFace , int , SetBezelFace, GetBezelFace, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) | |
af498247 | 112 | wxPROPERTY_FLAGS( WindowStyle , wxGaugeStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style |
3ff066a4 | 113 | wxEND_PROPERTIES_TABLE() |
51741307 | 114 | |
3ff066a4 SC |
115 | wxBEGIN_HANDLERS_TABLE(wxGauge95) |
116 | wxEND_HANDLERS_TABLE() | |
51741307 | 117 | |
213ceb3f | 118 | wxCONSTRUCTOR_6( wxGauge95 , wxWindow* , Parent , wxWindowID , Id , int , Range , wxPoint , Position , wxSize , Size , long , WindowStyle ) |
51741307 SC |
119 | #else |
120 | IMPLEMENT_DYNAMIC_CLASS(wxGauge95, wxControl) | |
121 | #endif | |
066f1b7a | 122 | |
f6bcfd97 | 123 | // ============================================================================ |
da0f19f8 | 124 | // wxGauge95 implementation |
f6bcfd97 BP |
125 | // ============================================================================ |
126 | ||
da0f19f8 VZ |
127 | // ---------------------------------------------------------------------------- |
128 | // wxGauge95 creation | |
129 | // ---------------------------------------------------------------------------- | |
da87a1ca | 130 | |
da0f19f8 VZ |
131 | bool wxGauge95::Create(wxWindow *parent, |
132 | wxWindowID id, | |
133 | int range, | |
134 | const wxPoint& pos, | |
135 | const wxSize& size, | |
136 | long style, | |
137 | const wxValidator& validator, | |
138 | const wxString& name) | |
139 | { | |
140 | if ( !CreateControl(parent, id, pos, size, style, validator, name) ) | |
141 | return false; | |
da87a1ca | 142 | |
da0f19f8 VZ |
143 | if ( !MSWCreateControl(PROGRESS_CLASS, wxEmptyString, pos, size) ) |
144 | return false; | |
da87a1ca | 145 | |
da0f19f8 | 146 | SetRange(range); |
da87a1ca | 147 | |
da0f19f8 VZ |
148 | return true; |
149 | } | |
da87a1ca | 150 | |
da0f19f8 VZ |
151 | WXDWORD wxGauge95::MSWGetStyle(long style, WXDWORD *exstyle) const |
152 | { | |
153 | WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle); | |
da87a1ca | 154 | |
da0f19f8 VZ |
155 | if ( style & wxGA_VERTICAL ) |
156 | msStyle |= PBS_VERTICAL; | |
da87a1ca | 157 | |
da0f19f8 VZ |
158 | if ( style & wxGA_SMOOTH ) |
159 | msStyle |= PBS_SMOOTH; | |
da87a1ca | 160 | |
da0f19f8 | 161 | return msStyle; |
da87a1ca JS |
162 | } |
163 | ||
da0f19f8 VZ |
164 | // ---------------------------------------------------------------------------- |
165 | // wxGauge95 geometry | |
166 | // ---------------------------------------------------------------------------- | |
da87a1ca | 167 | |
da0f19f8 | 168 | wxSize wxGauge95::DoGetBestSize() const |
da87a1ca | 169 | { |
da0f19f8 VZ |
170 | // VZ: no idea where does 28 come from, it was there before my changes and |
171 | // as nobody ever complained I guess we can leave it... | |
a04f431b DS |
172 | if (HasFlag(wxGA_VERTICAL)) |
173 | return wxSize(28, 100); | |
7bdfb981 | 174 | else |
a04f431b | 175 | return wxSize(100, 28); |
da87a1ca JS |
176 | } |
177 | ||
da0f19f8 VZ |
178 | // ---------------------------------------------------------------------------- |
179 | // wxGauge95 setters | |
180 | // ---------------------------------------------------------------------------- | |
181 | ||
debe6624 | 182 | void wxGauge95::SetRange(int r) |
da87a1ca | 183 | { |
da0f19f8 | 184 | m_rangeMax = r; |
da87a1ca | 185 | |
9a78988f | 186 | #ifdef PBM_SETRANGE32 |
da0f19f8 | 187 | ::SendMessage(GetHwnd(), PBM_SETRANGE32, 0, r); |
9a78988f | 188 | #else // !PBM_SETRANGE32 |
da0f19f8 VZ |
189 | // fall back to PBM_SETRANGE (limited to 16 bits) |
190 | ::SendMessage(GetHwnd(), PBM_SETRANGE, 0, MAKELPARAM(0, r)); | |
9a78988f | 191 | #endif // PBM_SETRANGE32/!PBM_SETRANGE32 |
da87a1ca JS |
192 | } |
193 | ||
debe6624 | 194 | void wxGauge95::SetValue(int pos) |
da87a1ca | 195 | { |
da0f19f8 | 196 | m_gaugePos = pos; |
da87a1ca | 197 | |
da0f19f8 | 198 | ::SendMessage(GetHwnd(), PBM_SETPOS, pos, 0); |
da87a1ca JS |
199 | } |
200 | ||
cc2b7472 | 201 | bool wxGauge95::SetForegroundColour(const wxColour& col) |
da87a1ca | 202 | { |
cc2b7472 | 203 | if ( !wxControl::SetForegroundColour(col) ) |
da0f19f8 | 204 | return false; |
cc2b7472 | 205 | |
da0f19f8 | 206 | ::SendMessage(GetHwnd(), PBM_SETBARCOLOR, 0, (LPARAM)wxColourToRGB(col)); |
cc2b7472 | 207 | |
da0f19f8 | 208 | return true; |
da87a1ca JS |
209 | } |
210 | ||
cc2b7472 | 211 | bool wxGauge95::SetBackgroundColour(const wxColour& col) |
da87a1ca | 212 | { |
cc2b7472 | 213 | if ( !wxControl::SetBackgroundColour(col) ) |
da0f19f8 | 214 | return false; |
cc2b7472 | 215 | |
da0f19f8 | 216 | ::SendMessage(GetHwnd(), PBM_SETBKCOLOR, 0, (LPARAM)wxColourToRGB(col)); |
cc2b7472 | 217 | |
da0f19f8 | 218 | return true; |
da87a1ca JS |
219 | } |
220 | ||
47d67540 | 221 | #endif // wxUSE_GAUGE |