1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/gauge95.cpp
3 // Purpose: wxGauge95 class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "gauge95.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
35 #if wxUSE_GAUGE && defined(__WIN95__)
37 #include "wx/msw/gauge95.h"
38 #include "wx/msw/private.h"
40 #if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__))
44 // ----------------------------------------------------------------------------
46 // ----------------------------------------------------------------------------
48 // old commctrl.h (< 4.71) don't have those
50 #define PBS_SMOOTH 0x01
54 #define PBS_VERTICAL 0x04
57 #ifndef PBM_SETBARCOLOR
58 #define PBM_SETBARCOLOR (WM_USER+9)
61 #ifndef PBM_SETBKCOLOR
62 #define PBM_SETBKCOLOR 0x2001
65 // ----------------------------------------------------------------------------
67 // ----------------------------------------------------------------------------
69 #if wxUSE_EXTENDED_RTTI
70 WX_DEFINE_FLAGS( wxGaugeStyle
)
72 WX_BEGIN_FLAGS( wxGaugeStyle
)
73 // new style border flags, we put them first to
74 // use them for streaming out
75 WX_FLAGS_MEMBER(wxBORDER_SIMPLE
)
76 WX_FLAGS_MEMBER(wxBORDER_SUNKEN
)
77 WX_FLAGS_MEMBER(wxBORDER_DOUBLE
)
78 WX_FLAGS_MEMBER(wxBORDER_RAISED
)
79 WX_FLAGS_MEMBER(wxBORDER_STATIC
)
80 WX_FLAGS_MEMBER(wxBORDER_NONE
)
82 // old style border flags
83 WX_FLAGS_MEMBER(wxSIMPLE_BORDER
)
84 WX_FLAGS_MEMBER(wxSUNKEN_BORDER
)
85 WX_FLAGS_MEMBER(wxDOUBLE_BORDER
)
86 WX_FLAGS_MEMBER(wxRAISED_BORDER
)
87 WX_FLAGS_MEMBER(wxSTATIC_BORDER
)
88 WX_FLAGS_MEMBER(wxNO_BORDER
)
90 // standard window styles
91 WX_FLAGS_MEMBER(wxTAB_TRAVERSAL
)
92 WX_FLAGS_MEMBER(wxCLIP_CHILDREN
)
93 WX_FLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
94 WX_FLAGS_MEMBER(wxWANTS_CHARS
)
95 WX_FLAGS_MEMBER(wxNO_FULL_REPAINT_ON_RESIZE
)
96 WX_FLAGS_MEMBER(wxALWAYS_SHOW_SB
)
97 WX_FLAGS_MEMBER(wxVSCROLL
)
98 WX_FLAGS_MEMBER(wxHSCROLL
)
100 WX_FLAGS_MEMBER(wxGA_HORIZONTAL
)
101 WX_FLAGS_MEMBER(wxGA_VERTICAL
)
102 WX_FLAGS_MEMBER(wxGA_PROGRESSBAR
)
103 WX_FLAGS_MEMBER(wxGA_SMOOTH
)
105 WX_END_FLAGS( wxGaugeStyle
)
107 IMPLEMENT_DYNAMIC_CLASS_XTI(wxGauge
, wxControl
,"wx/gauge.h")
109 WX_BEGIN_PROPERTIES_TABLE(wxGauge95
)
110 WX_PROPERTY( Value
, int , SetValue
, GetValue
, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
111 WX_PROPERTY( Range
, int , SetRange
, GetRange
, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
112 WX_PROPERTY( ShadowWidth
, int , SetShadowWidth
, GetShadowWidth
, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
113 WX_PROPERTY( BezelFace
, int , SetBezelFace
, GetBezelFace
, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
114 WX_PROPERTY_FLAGS( WindowStyle
, wxGaugeStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
115 WX_END_PROPERTIES_TABLE()
117 WX_BEGIN_HANDLERS_TABLE(wxGauge95
)
118 WX_END_HANDLERS_TABLE()
120 WX_CONSTRUCTOR_6( wxGauge95
, wxWindow
* , Parent
, wxWindowID
, Id
, int , Range
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
122 IMPLEMENT_DYNAMIC_CLASS(wxGauge95
, wxControl
)
125 // ============================================================================
127 // ============================================================================
129 bool wxGauge95::Create(wxWindow
*parent
, wxWindowID id
,
134 const wxValidator
& validator
,
135 const wxString
& name
)
139 SetValidator(validator
);
140 #endif // wxUSE_VALIDATORS
142 if (parent
) parent
->AddChild(this);
146 m_windowStyle
= style
;
149 m_windowId
= (int)NewControlId();
159 long msFlags
= MSWGetStyle(style
, & exStyle
) ;
161 if (m_windowStyle
& wxGA_VERTICAL
)
162 msFlags
|= PBS_VERTICAL
;
164 if (m_windowStyle
& wxGA_SMOOTH
)
165 msFlags
|= PBS_SMOOTH
;
168 CreateWindowEx(exStyle
, PROGRESS_CLASS
, NULL
, msFlags
,
169 0, 0, 0, 0, (HWND
) parent
->GetHWND(), (HMENU
)m_windowId
,
170 wxGetInstance(), NULL
);
172 m_hWnd
= (WXHWND
)wx_button
;
174 SetBackgroundColour(parent
->GetBackgroundColour());
175 SetForegroundColour(parent
->GetForegroundColour());
177 // Subclass again for purposes of dialog editing mode
178 SubclassWin((WXHWND
) wx_button
);
180 SendMessage((HWND
) GetHWND(), PBM_SETRANGE
, 0, MAKELPARAM(0, range
));
182 SetFont(parent
->GetFont());
188 SetSize(x
, y
, width
, height
);
190 ShowWindow((HWND
) GetHWND(), SW_SHOW
);
195 void wxGauge95::SetShadowWidth(int WXUNUSED(w
))
199 void wxGauge95::SetBezelFace(int WXUNUSED(w
))
203 void wxGauge95::SetRange(int r
)
207 SendMessage((HWND
) GetHWND(), PBM_SETRANGE
, 0, MAKELPARAM(0, r
));
210 void wxGauge95::SetValue(int pos
)
214 SendMessage((HWND
) GetHWND(), PBM_SETPOS
, pos
, 0);
217 int wxGauge95::GetShadowWidth() const
222 int wxGauge95::GetBezelFace() const
227 int wxGauge95::GetRange() const
232 int wxGauge95::GetValue() const
237 bool wxGauge95::SetForegroundColour(const wxColour
& col
)
239 if ( !wxControl::SetForegroundColour(col
) )
242 SendMessage(GetHwnd(), PBM_SETBARCOLOR
, 0, (LPARAM
)wxColourToRGB(col
));
247 bool wxGauge95::SetBackgroundColour(const wxColour
& col
)
249 if ( !wxControl::SetBackgroundColour(col
) )
252 SendMessage(GetHwnd(), PBM_SETBKCOLOR
, 0, (LPARAM
)wxColourToRGB(col
));
257 #endif // wxUSE_GAUGE