]>
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 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
34 #include "wx/msw/private.h"
36 // include <commctrl.h> "properly"
37 #include "wx/msw/wrapcctl.h"
39 // ----------------------------------------------------------------------------
41 // ----------------------------------------------------------------------------
43 // old commctrl.h (< 4.71) don't have those
45 #define PBS_SMOOTH 0x01
49 #define PBS_VERTICAL 0x04
52 #ifndef PBM_SETBARCOLOR
53 #define PBM_SETBARCOLOR (WM_USER+9)
56 #ifndef PBM_SETBKCOLOR
57 #define PBM_SETBKCOLOR 0x2001
60 // ----------------------------------------------------------------------------
62 // ----------------------------------------------------------------------------
64 #if wxUSE_EXTENDED_RTTI
65 WX_DEFINE_FLAGS( wxGaugeStyle
)
67 wxBEGIN_FLAGS( wxGaugeStyle
)
68 // new style border flags, we put them first to
69 // use them for streaming out
70 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
71 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
72 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
73 wxFLAGS_MEMBER(wxBORDER_RAISED
)
74 wxFLAGS_MEMBER(wxBORDER_STATIC
)
75 wxFLAGS_MEMBER(wxBORDER_NONE
)
77 // old style border flags
78 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
79 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
80 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
81 wxFLAGS_MEMBER(wxRAISED_BORDER
)
82 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
83 wxFLAGS_MEMBER(wxBORDER
)
85 // standard window styles
86 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
87 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
88 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
89 wxFLAGS_MEMBER(wxWANTS_CHARS
)
90 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
91 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
92 wxFLAGS_MEMBER(wxVSCROLL
)
93 wxFLAGS_MEMBER(wxHSCROLL
)
95 wxFLAGS_MEMBER(wxGA_HORIZONTAL
)
96 wxFLAGS_MEMBER(wxGA_VERTICAL
)
97 #if WXWIN_COMPATIBILITY_2_6
98 wxFLAGS_MEMBER(wxGA_PROGRESSBAR
)
99 #endif // WXWIN_COMPATIBILITY_2_6
100 wxFLAGS_MEMBER(wxGA_SMOOTH
)
102 wxEND_FLAGS( wxGaugeStyle
)
104 IMPLEMENT_DYNAMIC_CLASS_XTI(wxGauge
, wxControl
,"wx/gauge.h")
106 wxBEGIN_PROPERTIES_TABLE(wxGauge95
)
107 wxPROPERTY( Value
, int , SetValue
, GetValue
, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
108 wxPROPERTY( Range
, int , SetRange
, GetRange
, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
109 wxPROPERTY( ShadowWidth
, int , SetShadowWidth
, GetShadowWidth
, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
110 wxPROPERTY( BezelFace
, int , SetBezelFace
, GetBezelFace
, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
111 wxPROPERTY_FLAGS( WindowStyle
, wxGaugeStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
112 wxEND_PROPERTIES_TABLE()
114 wxBEGIN_HANDLERS_TABLE(wxGauge95
)
115 wxEND_HANDLERS_TABLE()
117 wxCONSTRUCTOR_6( wxGauge95
, wxWindow
* , Parent
, wxWindowID
, Id
, int , Range
, wxPoint
, Position
, wxSize
, Size
, long , WindowStyle
)
119 IMPLEMENT_DYNAMIC_CLASS(wxGauge95
, wxControl
)
122 // ============================================================================
123 // wxGauge95 implementation
124 // ============================================================================
126 // ----------------------------------------------------------------------------
127 // wxGauge95 creation
128 // ----------------------------------------------------------------------------
130 bool wxGauge95::Create(wxWindow
*parent
,
136 const wxValidator
& validator
,
137 const wxString
& name
)
139 if ( !CreateControl(parent
, id
, pos
, size
, style
, validator
, name
) )
142 if ( !MSWCreateControl(PROGRESS_CLASS
, wxEmptyString
, pos
, size
) )
150 WXDWORD
wxGauge95::MSWGetStyle(long style
, WXDWORD
*exstyle
) const
152 WXDWORD msStyle
= wxControl::MSWGetStyle(style
, exstyle
);
154 if ( style
& wxGA_VERTICAL
)
155 msStyle
|= PBS_VERTICAL
;
157 if ( style
& wxGA_SMOOTH
)
158 msStyle
|= PBS_SMOOTH
;
163 // ----------------------------------------------------------------------------
164 // wxGauge95 geometry
165 // ----------------------------------------------------------------------------
167 wxSize
wxGauge95::DoGetBestSize() const
169 // VZ: no idea where does 28 come from, it was there before my changes and
170 // as nobody ever complained I guess we can leave it...
171 if (HasFlag(wxGA_VERTICAL
))
172 return wxSize(28, 100);
174 return wxSize(100, 28);
177 // ----------------------------------------------------------------------------
179 // ----------------------------------------------------------------------------
181 void wxGauge95::SetRange(int r
)
185 #ifdef PBM_SETRANGE32
186 ::SendMessage(GetHwnd(), PBM_SETRANGE32
, 0, r
);
187 #else // !PBM_SETRANGE32
188 // fall back to PBM_SETRANGE (limited to 16 bits)
189 ::SendMessage(GetHwnd(), PBM_SETRANGE
, 0, MAKELPARAM(0, r
));
190 #endif // PBM_SETRANGE32/!PBM_SETRANGE32
193 void wxGauge95::SetValue(int pos
)
197 ::SendMessage(GetHwnd(), PBM_SETPOS
, pos
, 0);
200 bool wxGauge95::SetForegroundColour(const wxColour
& col
)
202 if ( !wxControl::SetForegroundColour(col
) )
205 ::SendMessage(GetHwnd(), PBM_SETBARCOLOR
, 0, (LPARAM
)wxColourToRGB(col
));
210 bool wxGauge95::SetBackgroundColour(const wxColour
& col
)
212 if ( !wxControl::SetBackgroundColour(col
) )
215 ::SendMessage(GetHwnd(), PBM_SETBKCOLOR
, 0, (LPARAM
)wxColourToRGB(col
));
220 #endif // wxUSE_GAUGE