]> git.saurik.com Git - wxWidgets.git/blame - src/msw/gauge95.cpp
memdc and bitmap fixes
[wxWidgets.git] / src / msw / gauge95.cpp
CommitLineData
da87a1ca
JS
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 USE_GAUGE && defined(__WIN95__)
28
29#include "wx/msw/gauge95.h"
30#include "wx/msw/private.h"
31
32#if defined(__WIN95__) && !defined(__GNUWIN32__)
33#include <commctrl.h>
34#endif
35
36#if !USE_SHARED_LIBRARY
37IMPLEMENT_DYNAMIC_CLASS(wxGauge95, wxControl)
38#endif
39
debe6624
JS
40bool wxGauge95::Create(wxWindow *parent, wxWindowID id,
41 int range,
da87a1ca
JS
42 const wxPoint& pos,
43 const wxSize& size,
debe6624 44 long style,
da87a1ca
JS
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
54 SetBackgroundColour(parent->GetDefaultBackgroundColour()) ;
55 SetForegroundColour(parent->GetDefaultForegroundColour()) ;
56
57 m_windowStyle = style;
58
59 if ( id == -1 )
60 m_windowId = (int)NewControlId();
61 else
62 m_windowId = id;
63
64 int x = pos.x;
65 int y = pos.y;
66 int width = size.x;
67 int height = size.y;
68
69 long msFlags = WS_CHILD | WS_VISIBLE | WS_TABSTOP;
70
71 HWND wx_button =
72 CreateWindowEx(MakeExtendedStyle(m_windowStyle), PROGRESS_CLASS, NULL, msFlags,
73 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
74 wxGetInstance(), NULL);
75
76 m_hWnd = (WXHWND)wx_button;
77
78 // Subclass again for purposes of dialog editing mode
79 SubclassWin((WXHWND) wx_button);
80
81 SendMessage((HWND) GetHWND(), PBM_SETRANGE, 0, MAKELPARAM(0, range));
82
83 SetFont(* parent->GetFont());
84
85 if (width == -1)
86 width = 50;
87 if (height == -1)
88 height = 50;
89 SetSize(x, y, width, height);
90
91 ShowWindow((HWND) GetHWND(), SW_SHOW);
92
93 return TRUE;
94}
95
debe6624 96void wxGauge95::SetSize(int x, int y, int width, int height, int sizeFlags)
da87a1ca
JS
97{
98 int currentX, currentY;
99 GetPosition(&currentX, &currentY);
100 int x1 = x;
101 int y1 = y;
102 int w1 = width;
103 int h1 = height;
104
105 if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
106 x1 = currentX;
107 if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
108 y1 = currentY;
109
110 // If we're prepared to use the existing size, then...
111 if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
112 {
113 GetSize(&w1, &h1);
114 }
115
116 // Deal with default size (using -1 values)
117 if (w1<=0)
118 w1 = DEFAULT_ITEM_WIDTH;
119
120 if (h1<=0)
121 h1 = DEFAULT_ITEM_HEIGHT;
122
123 MoveWindow((HWND) GetHWND(), x1, y1, w1, h1, TRUE);
da87a1ca
JS
124}
125
debe6624 126void wxGauge95::SetShadowWidth(int w)
da87a1ca
JS
127{
128}
129
debe6624 130void wxGauge95::SetBezelFace(int w)
da87a1ca
JS
131{
132}
133
debe6624 134void wxGauge95::SetRange(int r)
da87a1ca
JS
135{
136 m_rangeMax = r;
137
138 SendMessage((HWND) GetHWND(), PBM_SETRANGE, 0, MAKELPARAM(0, r));
139}
140
debe6624 141void wxGauge95::SetValue(int pos)
da87a1ca
JS
142{
143 m_gaugePos = pos;
144
145 SendMessage((HWND) GetHWND(), PBM_SETPOS, pos, 0);
146}
147
148int wxGauge95::GetShadowWidth(void) const
149{
150 return 0;
151}
152
153int wxGauge95::GetBezelFace(void) const
154{
155 return 0;
156}
157
158int wxGauge95::GetRange(void) const
159{
160 return m_rangeMax;
161}
162
163int wxGauge95::GetValue(void) const
164{
165 return m_gaugePos;
166}
167
168void wxGauge95::SetForegroundColour(const wxColour& col)
169{
170 m_foregroundColour = col ;
171}
172
173void wxGauge95::SetBackgroundColour(const wxColour& col)
174{
175 m_backgroundColour = col ;
176}
177
178#endif // USE_GAUGE