]>
Commit | Line | Data |
---|---|---|
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 | ||
47d67540 | 27 | #if wxUSE_GAUGE && defined(__WIN95__) |
da87a1ca JS |
28 | |
29 | #include "wx/msw/gauge95.h" | |
30 | #include "wx/msw/private.h" | |
31 | ||
57c208c5 | 32 | #if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__) |
da87a1ca JS |
33 | #include <commctrl.h> |
34 | #endif | |
35 | ||
36 | #if !USE_SHARED_LIBRARY | |
37 | IMPLEMENT_DYNAMIC_CLASS(wxGauge95, wxControl) | |
38 | #endif | |
39 | ||
debe6624 JS |
40 | bool 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; | |
9c331ded | 53 | m_gaugePos = 0; |
da87a1ca | 54 | |
fd71308f JS |
55 | SetBackgroundColour(parent->GetBackgroundColour()) ; |
56 | SetForegroundColour(parent->GetForegroundColour()) ; | |
da87a1ca JS |
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; | |
aeab10d0 JS |
71 | if (m_windowStyle & wxGA_VERTICAL) |
72 | msFlags |= PBS_VERTICAL; | |
73 | ||
74 | if (m_windowStyle & wxGA_SMOOTH) | |
75 | msFlags |= PBS_SMOOTH; | |
da87a1ca JS |
76 | |
77 | HWND wx_button = | |
78 | CreateWindowEx(MakeExtendedStyle(m_windowStyle), PROGRESS_CLASS, NULL, msFlags, | |
79 | 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, | |
80 | wxGetInstance(), NULL); | |
81 | ||
82 | m_hWnd = (WXHWND)wx_button; | |
83 | ||
84 | // Subclass again for purposes of dialog editing mode | |
85 | SubclassWin((WXHWND) wx_button); | |
86 | ||
87 | SendMessage((HWND) GetHWND(), PBM_SETRANGE, 0, MAKELPARAM(0, range)); | |
88 | ||
c0ed460c | 89 | SetFont(parent->GetFont()); |
da87a1ca JS |
90 | |
91 | if (width == -1) | |
92 | width = 50; | |
93 | if (height == -1) | |
92976ab6 | 94 | height = 28; |
da87a1ca JS |
95 | SetSize(x, y, width, height); |
96 | ||
97 | ShowWindow((HWND) GetHWND(), SW_SHOW); | |
98 | ||
99 | return TRUE; | |
100 | } | |
101 | ||
bfc6fde4 | 102 | void wxGauge95::DoSetSize(int x, int y, int width, int height, int sizeFlags) |
da87a1ca JS |
103 | { |
104 | int currentX, currentY; | |
105 | GetPosition(¤tX, ¤tY); | |
106 | int x1 = x; | |
107 | int y1 = y; | |
108 | int w1 = width; | |
109 | int h1 = height; | |
110 | ||
111 | if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
112 | x1 = currentX; | |
113 | if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
114 | y1 = currentY; | |
115 | ||
81d66cf3 JS |
116 | AdjustForParentClientOrigin(x1, y1, sizeFlags); |
117 | ||
da87a1ca JS |
118 | // If we're prepared to use the existing size, then... |
119 | if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO)) | |
120 | { | |
121 | GetSize(&w1, &h1); | |
122 | } | |
123 | ||
124 | // Deal with default size (using -1 values) | |
125 | if (w1<=0) | |
126 | w1 = DEFAULT_ITEM_WIDTH; | |
127 | ||
128 | if (h1<=0) | |
129 | h1 = DEFAULT_ITEM_HEIGHT; | |
130 | ||
131 | MoveWindow((HWND) GetHWND(), x1, y1, w1, h1, TRUE); | |
da87a1ca JS |
132 | } |
133 | ||
debe6624 | 134 | void wxGauge95::SetShadowWidth(int w) |
da87a1ca JS |
135 | { |
136 | } | |
137 | ||
debe6624 | 138 | void wxGauge95::SetBezelFace(int w) |
da87a1ca JS |
139 | { |
140 | } | |
141 | ||
debe6624 | 142 | void wxGauge95::SetRange(int r) |
da87a1ca JS |
143 | { |
144 | m_rangeMax = r; | |
145 | ||
146 | SendMessage((HWND) GetHWND(), PBM_SETRANGE, 0, MAKELPARAM(0, r)); | |
147 | } | |
148 | ||
debe6624 | 149 | void wxGauge95::SetValue(int pos) |
da87a1ca JS |
150 | { |
151 | m_gaugePos = pos; | |
152 | ||
153 | SendMessage((HWND) GetHWND(), PBM_SETPOS, pos, 0); | |
154 | } | |
155 | ||
156 | int wxGauge95::GetShadowWidth(void) const | |
157 | { | |
158 | return 0; | |
159 | } | |
160 | ||
161 | int wxGauge95::GetBezelFace(void) const | |
162 | { | |
163 | return 0; | |
164 | } | |
165 | ||
166 | int wxGauge95::GetRange(void) const | |
167 | { | |
168 | return m_rangeMax; | |
169 | } | |
170 | ||
171 | int wxGauge95::GetValue(void) const | |
172 | { | |
173 | return m_gaugePos; | |
174 | } | |
175 | ||
176 | void wxGauge95::SetForegroundColour(const wxColour& col) | |
177 | { | |
178 | m_foregroundColour = col ; | |
179 | } | |
180 | ||
181 | void wxGauge95::SetBackgroundColour(const wxColour& col) | |
182 | { | |
183 | m_backgroundColour = col ; | |
184 | } | |
185 | ||
47d67540 | 186 | #endif // wxUSE_GAUGE |