]> git.saurik.com Git - wxWidgets.git/blob - src/msw/gauge95.cpp
wxGTK compile fixes for my wxMSW changes
[wxWidgets.git] / src / msw / gauge95.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "gauge95.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/defs.h"
25 #endif
26
27 #if wxUSE_GAUGE && defined(__WIN95__)
28
29 #include "wx/msw/gauge95.h"
30 #include "wx/msw/private.h"
31
32 #if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__)
33 #include <commctrl.h>
34 #endif
35
36 #if !USE_SHARED_LIBRARY
37 IMPLEMENT_DYNAMIC_CLASS(wxGauge95, wxControl)
38 #endif
39
40 bool wxGauge95::Create(wxWindow *parent, wxWindowID id,
41 int range,
42 const wxPoint& pos,
43 const wxSize& size,
44 long style,
45 const wxValidator& validator,
46 const wxString& name)
47 {
48 SetName(name);
49 SetValidator(validator);
50
51 if (parent) parent->AddChild(this);
52 m_rangeMax = range;
53 m_gaugePos = 0;
54
55 SetBackgroundColour(parent->GetBackgroundColour()) ;
56 SetForegroundColour(parent->GetForegroundColour()) ;
57
58 m_windowStyle = style;
59
60 if ( id == -1 )
61 m_windowId = (int)NewControlId();
62 else
63 m_windowId = id;
64
65 int x = pos.x;
66 int y = pos.y;
67 int width = size.x;
68 int height = size.y;
69
70 long msFlags = WS_CHILD | WS_VISIBLE | WS_TABSTOP;
71
72 #ifndef PBS_VERTICAL
73 #define PBS_VERTICAL 0x04
74 #endif
75
76 if (m_windowStyle & wxGA_VERTICAL)
77 msFlags |= PBS_VERTICAL;
78
79 #ifndef PBS_SMOOTH
80 #define PBS_SMOOTH 0x01
81 #endif
82
83 if (m_windowStyle & wxGA_SMOOTH)
84 msFlags |= PBS_SMOOTH;
85
86 HWND wx_button =
87 CreateWindowEx(MakeExtendedStyle(m_windowStyle), PROGRESS_CLASS, NULL, msFlags,
88 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
89 wxGetInstance(), NULL);
90
91 m_hWnd = (WXHWND)wx_button;
92
93 // Subclass again for purposes of dialog editing mode
94 SubclassWin((WXHWND) wx_button);
95
96 SendMessage((HWND) GetHWND(), PBM_SETRANGE, 0, MAKELPARAM(0, range));
97
98 SetFont(parent->GetFont());
99
100 if (width == -1)
101 width = 50;
102 if (height == -1)
103 height = 28;
104 SetSize(x, y, width, height);
105
106 ShowWindow((HWND) GetHWND(), SW_SHOW);
107
108 return TRUE;
109 }
110
111 void wxGauge95::DoSetSize(int x, int y, int width, int height, int sizeFlags)
112 {
113 int currentX, currentY;
114 GetPosition(&currentX, &currentY);
115 int x1 = x;
116 int y1 = y;
117 int w1 = width;
118 int h1 = height;
119
120 if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
121 x1 = currentX;
122 if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
123 y1 = currentY;
124
125 AdjustForParentClientOrigin(x1, y1, sizeFlags);
126
127 // If we're prepared to use the existing size, then...
128 if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
129 {
130 GetSize(&w1, &h1);
131 }
132
133 // Deal with default size (using -1 values)
134 if (w1<=0)
135 w1 = DEFAULT_ITEM_WIDTH;
136
137 if (h1<=0)
138 h1 = DEFAULT_ITEM_HEIGHT;
139
140 MoveWindow((HWND) GetHWND(), x1, y1, w1, h1, TRUE);
141 }
142
143 void wxGauge95::SetShadowWidth(int w)
144 {
145 }
146
147 void wxGauge95::SetBezelFace(int w)
148 {
149 }
150
151 void wxGauge95::SetRange(int r)
152 {
153 m_rangeMax = r;
154
155 SendMessage((HWND) GetHWND(), PBM_SETRANGE, 0, MAKELPARAM(0, r));
156 }
157
158 void wxGauge95::SetValue(int pos)
159 {
160 m_gaugePos = pos;
161
162 SendMessage((HWND) GetHWND(), PBM_SETPOS, pos, 0);
163 }
164
165 int wxGauge95::GetShadowWidth(void) const
166 {
167 return 0;
168 }
169
170 int wxGauge95::GetBezelFace(void) const
171 {
172 return 0;
173 }
174
175 int wxGauge95::GetRange(void) const
176 {
177 return m_rangeMax;
178 }
179
180 int wxGauge95::GetValue(void) const
181 {
182 return m_gaugePos;
183 }
184
185 bool wxGauge95::SetForegroundColour(const wxColour& col)
186 {
187 if ( !wxControl::SetForegroundColour(col) )
188 return FALSE;
189
190 m_foregroundColour = col ;
191
192 return TRUE;
193 }
194
195 bool wxGauge95::SetBackgroundColour(const wxColour& col)
196 {
197 if ( !wxControl::SetBackgroundColour(col) )
198 return FALSE;
199
200 m_backgroundColour = col ;
201
202 return TRUE;
203 }
204
205 #endif // wxUSE_GAUGE