]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/gauge95.cpp
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"
38 #include "wx/msw/private.h"
40 #if !(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 wxBEGIN_FLAGS( wxGaugeStyle
)
73 // new style border flags, we put them first to
74 // use them for streaming out
75 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
76 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
77 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
78 wxFLAGS_MEMBER(wxBORDER_RAISED
)
79 wxFLAGS_MEMBER(wxBORDER_STATIC
)
80 wxFLAGS_MEMBER(wxBORDER_NONE
)
82 // old style border flags
83 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
84 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
85 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
86 wxFLAGS_MEMBER(wxRAISED_BORDER
)
87 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
88 wxFLAGS_MEMBER(wxBORDER
)
90 // standard window styles
91 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
92 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
93 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
94 wxFLAGS_MEMBER(wxWANTS_CHARS
)
95 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
96 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
97 wxFLAGS_MEMBER(wxVSCROLL
)
98 wxFLAGS_MEMBER(wxHSCROLL
)
100 wxFLAGS_MEMBER(wxGA_HORIZONTAL
)
101 wxFLAGS_MEMBER(wxGA_VERTICAL
)
102 wxFLAGS_MEMBER(wxGA_PROGRESSBAR
)
103 wxFLAGS_MEMBER(wxGA_SMOOTH
)
105 wxEND_FLAGS( wxGaugeStyle
)
107 IMPLEMENT_DYNAMIC_CLASS_XTI(wxGauge
, wxControl
,"wx/gauge.h")
109 wxBEGIN_PROPERTIES_TABLE(wxGauge95
)
110 wxPROPERTY( Value
, int , SetValue
, GetValue
, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
111 wxPROPERTY( Range
, int , SetRange
, GetRange
, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
112 wxPROPERTY( ShadowWidth
, int , SetShadowWidth
, GetShadowWidth
, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
113 wxPROPERTY( BezelFace
, int , SetBezelFace
, GetBezelFace
, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
114 wxPROPERTY_FLAGS( WindowStyle
, wxGaugeStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
115 wxEND_PROPERTIES_TABLE()
117 wxBEGIN_HANDLERS_TABLE(wxGauge95
)
118 wxEND_HANDLERS_TABLE()
120 wxCONSTRUCTOR_6( wxGauge95
, wxWindow
* , Parent
, wxWindowID
, Id
, int , Range
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
122 IMPLEMENT_DYNAMIC_CLASS(wxGauge95
, wxControl
)
125 // ============================================================================
126 // wxGauge95 implementation
127 // ============================================================================
129 // ----------------------------------------------------------------------------
130 // wxGauge95 creation
131 // ----------------------------------------------------------------------------
133 bool wxGauge95::Create(wxWindow
*parent
,
139 const wxValidator
& validator
,
140 const wxString
& name
)
142 if ( !CreateControl(parent
, id
, pos
, size
, style
, validator
, name
) )
145 if ( !MSWCreateControl(PROGRESS_CLASS
, wxEmptyString
, pos
, size
) )
153 WXDWORD
wxGauge95::MSWGetStyle(long style
, WXDWORD
*exstyle
) const
155 WXDWORD msStyle
= wxControl::MSWGetStyle(style
, exstyle
);
157 if ( style
& wxGA_VERTICAL
)
158 msStyle
|= PBS_VERTICAL
;
160 if ( style
& wxGA_SMOOTH
)
161 msStyle
|= PBS_SMOOTH
;
166 // ----------------------------------------------------------------------------
167 // wxGauge95 geometry
168 // ----------------------------------------------------------------------------
170 wxSize
wxGauge95::DoGetBestSize() const
172 // VZ: no idea where does 28 come from, it was there before my changes and
173 // as nobody ever complained I guess we can leave it...
174 if (HasFlag(wxGA_HORIZONTAL
))
175 return wxSize(100, 28);
177 return wxSize(28,100);
180 // ----------------------------------------------------------------------------
182 // ----------------------------------------------------------------------------
184 void wxGauge95::SetRange(int r
)
188 #ifdef PBM_SETRANGE32
189 ::SendMessage(GetHwnd(), PBM_SETRANGE32
, 0, r
);
190 #else // !PBM_SETRANGE32
191 // fall back to PBM_SETRANGE (limited to 16 bits)
192 ::SendMessage(GetHwnd(), PBM_SETRANGE
, 0, MAKELPARAM(0, r
));
193 #endif // PBM_SETRANGE32/!PBM_SETRANGE32
196 void wxGauge95::SetValue(int pos
)
200 ::SendMessage(GetHwnd(), PBM_SETPOS
, pos
, 0);
203 bool wxGauge95::SetForegroundColour(const wxColour
& col
)
205 if ( !wxControl::SetForegroundColour(col
) )
208 ::SendMessage(GetHwnd(), PBM_SETBARCOLOR
, 0, (LPARAM
)wxColourToRGB(col
));
213 bool wxGauge95::SetBackgroundColour(const wxColour
& col
)
215 if ( !wxControl::SetBackgroundColour(col
) )
218 ::SendMessage(GetHwnd(), PBM_SETBKCOLOR
, 0, (LPARAM
)wxColourToRGB(col
));
223 #endif // wxUSE_GAUGE