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