]> git.saurik.com Git - wxWidgets.git/blame - src/msw/gauge95.cpp
Misc warning fixes by ABX
[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
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__
28#pragma hdrstop
29#endif
30
31#ifndef WX_PRECOMP
f6bcfd97 32 #include "wx/defs.h"
da87a1ca
JS
33#endif
34
47d67540 35#if wxUSE_GAUGE && defined(__WIN95__)
da87a1ca
JS
36
37#include "wx/msw/gauge95.h"
38#include "wx/msw/private.h"
39
b39dbf34 40#if defined(__WIN95__) && !(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
da87a1ca 69IMPLEMENT_DYNAMIC_CLASS(wxGauge95, wxControl)
da87a1ca 70
066f1b7a
SC
71/*
72 TODO PROPERTIES
73 range (long)
74 value (long)
75 shadow (ShadowWidth)
76 bezel (BezelFace)
77*/
78
f6bcfd97
BP
79// ============================================================================
80// implementation
81// ============================================================================
82
debe6624
JS
83bool wxGauge95::Create(wxWindow *parent, wxWindowID id,
84 int range,
da87a1ca
JS
85 const wxPoint& pos,
86 const wxSize& size,
debe6624 87 long style,
da87a1ca
JS
88 const wxValidator& validator,
89 const wxString& name)
90{
91 SetName(name);
11b6a93b 92#if wxUSE_VALIDATORS
da87a1ca 93 SetValidator(validator);
11b6a93b 94#endif // wxUSE_VALIDATORS
da87a1ca
JS
95
96 if (parent) parent->AddChild(this);
97 m_rangeMax = range;
9c331ded 98 m_gaugePos = 0;
da87a1ca 99
da87a1ca
JS
100 m_windowStyle = style;
101
102 if ( id == -1 )
4438caf4 103 m_windowId = (int)NewControlId();
da87a1ca 104 else
4438caf4 105 m_windowId = id;
da87a1ca
JS
106
107 int x = pos.x;
108 int y = pos.y;
109 int width = size.x;
110 int height = size.y;
111
fe3d9123
JS
112 WXDWORD exStyle = 0;
113 long msFlags = MSWGetStyle(style, & exStyle) ;
04a65123 114
aeab10d0
JS
115 if (m_windowStyle & wxGA_VERTICAL)
116 msFlags |= PBS_VERTICAL;
117
118 if (m_windowStyle & wxGA_SMOOTH)
119 msFlags |= PBS_SMOOTH;
da87a1ca
JS
120
121 HWND wx_button =
fe3d9123 122 CreateWindowEx(exStyle, PROGRESS_CLASS, NULL, msFlags,
da87a1ca
JS
123 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
124 wxGetInstance(), NULL);
125
126 m_hWnd = (WXHWND)wx_button;
127
31334ecb
GT
128 SetBackgroundColour(parent->GetBackgroundColour());
129 SetForegroundColour(parent->GetForegroundColour());
130
da87a1ca
JS
131 // Subclass again for purposes of dialog editing mode
132 SubclassWin((WXHWND) wx_button);
133
134 SendMessage((HWND) GetHWND(), PBM_SETRANGE, 0, MAKELPARAM(0, range));
135
c0ed460c 136 SetFont(parent->GetFont());
da87a1ca
JS
137
138 if (width == -1)
139 width = 50;
140 if (height == -1)
92976ab6 141 height = 28;
da87a1ca
JS
142 SetSize(x, y, width, height);
143
144 ShowWindow((HWND) GetHWND(), SW_SHOW);
145
146 return TRUE;
147}
148
33ac7e6f 149void wxGauge95::SetShadowWidth(int WXUNUSED(w))
da87a1ca
JS
150{
151}
152
33ac7e6f 153void wxGauge95::SetBezelFace(int WXUNUSED(w))
da87a1ca
JS
154{
155}
156
debe6624 157void wxGauge95::SetRange(int r)
da87a1ca
JS
158{
159 m_rangeMax = r;
160
161 SendMessage((HWND) GetHWND(), PBM_SETRANGE, 0, MAKELPARAM(0, r));
162}
163
debe6624 164void wxGauge95::SetValue(int pos)
da87a1ca
JS
165{
166 m_gaugePos = pos;
167
168 SendMessage((HWND) GetHWND(), PBM_SETPOS, pos, 0);
169}
170
f6bcfd97 171int wxGauge95::GetShadowWidth() const
da87a1ca
JS
172{
173 return 0;
174}
175
f6bcfd97 176int wxGauge95::GetBezelFace() const
da87a1ca
JS
177{
178 return 0;
179}
180
f6bcfd97 181int wxGauge95::GetRange() const
da87a1ca
JS
182{
183 return m_rangeMax;
184}
185
f6bcfd97 186int wxGauge95::GetValue() const
da87a1ca
JS
187{
188 return m_gaugePos;
189}
190
cc2b7472 191bool wxGauge95::SetForegroundColour(const wxColour& col)
da87a1ca 192{
cc2b7472
VZ
193 if ( !wxControl::SetForegroundColour(col) )
194 return FALSE;
195
f6bcfd97 196 SendMessage(GetHwnd(), PBM_SETBARCOLOR, 0, (LPARAM)wxColourToRGB(col));
cc2b7472
VZ
197
198 return TRUE;
da87a1ca
JS
199}
200
cc2b7472 201bool wxGauge95::SetBackgroundColour(const wxColour& col)
da87a1ca 202{
cc2b7472
VZ
203 if ( !wxControl::SetBackgroundColour(col) )
204 return FALSE;
205
f6bcfd97 206 SendMessage(GetHwnd(), PBM_SETBKCOLOR, 0, (LPARAM)wxColourToRGB(col));
cc2b7472
VZ
207
208 return TRUE;
da87a1ca
JS
209}
210
47d67540 211#endif // wxUSE_GAUGE