61 GetClientRect( myHandle, &r );
62 int height = r.bottom - (r.bottom - r.top ) * myPosition / myMax;
64 if( abs(m.y - height) > 10 )
79 s.cbSize =
sizeof( s );
80 s.hwndTrack = myHandle;
81 s.dwFlags = TME_LEAVE;
82 TrackMouseEvent( & s );
92 GetClientRect( myHandle, &r );
97 if( m.y > r.bottom || m.y < r.top )
99 myPosition = myMax * ( r.bottom - m.y ) / ( r.bottom - r.top );
103 if( m.x < r.left || m.x > r.right )
105 myPosition = myMax * ( m.x - r.left ) / ( r.right - r.left );
107 if( myPosition > myMax )
111 events().onSlid( myPosition );
129 throw std::runtime_error(
130 "wex::slider positions must be positive");
132 throw std::runtime_error(
133 "wex::slider bad range parameters");
137 myPosition = ( myMax + myMin ) / 2;
143 void draw( PAINTSTRUCT& ps )
146 GetClientRect( myHandle, &r );
154 int center = r.left+(r.right-r.left)/2;
155 s.line( {center-1,r.top+5,center-1,r.bottom-5});
156 s.line( {center+1,r.top+5,center+1,r.bottom-5});
160 int center = r.top+(r.bottom-r.top)/2;
161 s.line({r.left+5,center-1,r.right-5,center-1});
162 s.line({r.left+5,center+1,r.right-5,center+1});
167 SelectObject(ps.hdc, GetStockObject(BLACK_BRUSH));
169 SelectObject(ps.hdc, GetStockObject(GRAY_BRUSH));
172 int height = r.bottom - (r.bottom - r.top ) * myPosition / myMax;
180 int height = r.left + (r.right - r.left ) * myPosition / myMax;
183 height + 4, r.bottom,
187 void vertical(
bool f =
true)
192 double position()
const
196 void position(
double v )
200 void maximum(
double max )
void click(std::function< void(void)> f, bool propogate=false)
register click event handler
Definition: wex.h:280
The base class for all windex gui elements.
Definition: wex.h:900
void update()
force widget to redraw completely
Definition: wex.h:1668
eventhandler & events()
Get event handler.
Definition: wex.h:1742
bool myfEnabled
true if not disabled
Definition: wex.h:1791
sMouse getMouseStatus()
Get mouse status.
Definition: wex.h:1247
gui()
Construct top level window with no parent.
Definition: wex.h:907
A class that offers application code methods to draw on a window.
Definition: wex.h:529
A widget which user can drag to change a value.
Definition: slider.h:46
void range(int min, int max)
Specify the range of values used.
Definition: slider.h:126
A structure containing the mouse status for event handlers.
Definition: wex.h:29