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