]> git.saurik.com Git - wxWidgets.git/blob - src/msw/gauge95.cpp
wxPalette unified. Source cleaning.
[wxWidgets.git] / src / msw / gauge95.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/gauge95.cpp
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
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #ifndef WX_PRECOMP
28 #include "wx/defs.h"
29 #endif
30
31 #if wxUSE_GAUGE
32
33 #include "wx/gauge.h"
34 #include "wx/msw/private.h"
35
36 #if !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__))
37 #include <commctrl.h>
38 #endif
39
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
65 #if wxUSE_EXTENDED_RTTI
66 WX_DEFINE_FLAGS( wxGaugeStyle )
67
68 wxBEGIN_FLAGS( wxGaugeStyle )
69 // new style border flags, we put them first to
70 // use them for streaming out
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)
77
78 // old style border flags
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)
84 wxFLAGS_MEMBER(wxBORDER)
85
86 // standard window styles
87 wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
88 wxFLAGS_MEMBER(wxCLIP_CHILDREN)
89 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
90 wxFLAGS_MEMBER(wxWANTS_CHARS)
91 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
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)
98 wxFLAGS_MEMBER(wxGA_PROGRESSBAR)
99 wxFLAGS_MEMBER(wxGA_SMOOTH)
100
101 wxEND_FLAGS( wxGaugeStyle )
102
103 IMPLEMENT_DYNAMIC_CLASS_XTI(wxGauge, wxControl,"wx/gauge.h")
104
105 wxBEGIN_PROPERTIES_TABLE(wxGauge95)
106 wxPROPERTY( Value , int , SetValue, GetValue, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
107 wxPROPERTY( Range , int , SetRange, GetRange, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
108 wxPROPERTY( ShadowWidth , int , SetShadowWidth, GetShadowWidth, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
109 wxPROPERTY( BezelFace , int , SetBezelFace, GetBezelFace, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
110 wxPROPERTY_FLAGS( WindowStyle , wxGaugeStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
111 wxEND_PROPERTIES_TABLE()
112
113 wxBEGIN_HANDLERS_TABLE(wxGauge95)
114 wxEND_HANDLERS_TABLE()
115
116 wxCONSTRUCTOR_6( wxGauge95 , wxWindow* , Parent , wxWindowID , Id , int , Range , wxPoint , Position , wxSize , Size , long , WindowStyle )
117 #else
118 IMPLEMENT_DYNAMIC_CLASS(wxGauge95, wxControl)
119 #endif
120
121 // ============================================================================
122 // wxGauge95 implementation
123 // ============================================================================
124
125 // ----------------------------------------------------------------------------
126 // wxGauge95 creation
127 // ----------------------------------------------------------------------------
128
129 bool wxGauge95::Create(wxWindow *parent,
130 wxWindowID id,
131 int range,
132 const wxPoint& pos,
133 const wxSize& size,
134 long style,
135 const wxValidator& validator,
136 const wxString& name)
137 {
138 if ( !CreateControl(parent, id, pos, size, style, validator, name) )
139 return false;
140
141 if ( !MSWCreateControl(PROGRESS_CLASS, wxEmptyString, pos, size) )
142 return false;
143
144 SetRange(range);
145
146 return true;
147 }
148
149 WXDWORD wxGauge95::MSWGetStyle(long style, WXDWORD *exstyle) const
150 {
151 WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle);
152
153 if ( style & wxGA_VERTICAL )
154 msStyle |= PBS_VERTICAL;
155
156 if ( style & wxGA_SMOOTH )
157 msStyle |= PBS_SMOOTH;
158
159 return msStyle;
160 }
161
162 // ----------------------------------------------------------------------------
163 // wxGauge95 geometry
164 // ----------------------------------------------------------------------------
165
166 wxSize wxGauge95::DoGetBestSize() const
167 {
168 // VZ: no idea where does 28 come from, it was there before my changes and
169 // as nobody ever complained I guess we can leave it...
170 if (HasFlag(wxGA_VERTICAL))
171 return wxSize(28, 100);
172 else
173 return wxSize(100, 28);
174 }
175
176 // ----------------------------------------------------------------------------
177 // wxGauge95 setters
178 // ----------------------------------------------------------------------------
179
180 void wxGauge95::SetRange(int r)
181 {
182 m_rangeMax = r;
183
184 #ifdef PBM_SETRANGE32
185 ::SendMessage(GetHwnd(), PBM_SETRANGE32, 0, r);
186 #else // !PBM_SETRANGE32
187 // fall back to PBM_SETRANGE (limited to 16 bits)
188 ::SendMessage(GetHwnd(), PBM_SETRANGE, 0, MAKELPARAM(0, r));
189 #endif // PBM_SETRANGE32/!PBM_SETRANGE32
190 }
191
192 void wxGauge95::SetValue(int pos)
193 {
194 m_gaugePos = pos;
195
196 ::SendMessage(GetHwnd(), PBM_SETPOS, pos, 0);
197 }
198
199 bool wxGauge95::SetForegroundColour(const wxColour& col)
200 {
201 if ( !wxControl::SetForegroundColour(col) )
202 return false;
203
204 ::SendMessage(GetHwnd(), PBM_SETBARCOLOR, 0, (LPARAM)wxColourToRGB(col));
205
206 return true;
207 }
208
209 bool wxGauge95::SetBackgroundColour(const wxColour& col)
210 {
211 if ( !wxControl::SetBackgroundColour(col) )
212 return false;
213
214 ::SendMessage(GetHwnd(), PBM_SETBKCOLOR, 0, (LPARAM)wxColourToRGB(col));
215
216 return true;
217 }
218
219 #endif // wxUSE_GAUGE
220