64 GetClientRect( myHandle, &r );
65 int height = r.bottom - (r.bottom - r.top ) * myPosition / myMax;
67 if( abs(m.y - height) > 10 )
82 s.cbSize =
sizeof( s );
83 s.hwndTrack = myHandle;
84 s.dwFlags = TME_LEAVE;
85 TrackMouseEvent( & s );
95 GetClientRect( myHandle, &r );
100 if( m.y > r.bottom || m.y < r.top )
102 myPosition = myMax * ( r.bottom - m.y ) / ( r.bottom - r.top );
106 if( m.x < r.left || m.x > r.right )
108 myPosition = myMax * ( m.x - r.left ) / ( r.right - r.left );
110 if( myPosition > myMax )
113 myPosition = std::round( myPosition);
117 events().onSlid( myPosition );
135 throw std::runtime_error(
136 "wex::slider positions must be positive");
138 throw std::runtime_error(
139 "wex::slider bad range parameters");
143 myPosition = ( myMax + myMin ) / 2;
149 void draw( PAINTSTRUCT& ps )
152 GetClientRect( myHandle, &r );
160 int center = r.left+(r.right-r.left)/2;
161 s.line( {center-1,r.top+5,center-1,r.bottom-5});
162 s.line( {center+1,r.top+5,center+1,r.bottom-5});
166 int center = r.top+(r.bottom-r.top)/2;
167 s.line({r.left+5,center-1,r.right-5,center-1});
168 s.line({r.left+5,center+1,r.right-5,center+1});
173 SelectObject(ps.hdc, GetStockObject(BLACK_BRUSH));
175 SelectObject(ps.hdc, GetStockObject(GRAY_BRUSH));
179 int height = r.bottom - (r.bottom - r.top ) * myPosition / myMax;
187 int height = r.left + (r.right - r.left ) * myPosition / myMax;
190 height + 4, r.bottom,
194 void vertical(
bool f =
true)
199 double position()
const
203 void position(
double v )
207 void maximum(
double max )
void click(std::function< void(void)> f, bool propogate=false)
register click event handler
Definition: wex.h:276
The base class for all windex gui elements.
Definition: wex.h:824
void update()
force widget to redraw completely
Definition: wex.h:1575
eventhandler & events()
Get event handler.
Definition: wex.h:1649
bool myfEnabled
true if not disabled
Definition: wex.h:1698
sMouse getMouseStatus()
Get mouse status.
Definition: wex.h:1171
gui()
Construct top level window with no parent.
Definition: wex.h:831
A class that offers application code methods to draw on a window.
Definition: wex.h:525
A widget which user can drag to change a value.
Definition: slider.h:48
void steps(bool f=true)
Specify slider moves in steps to integer positions.
Definition: slider.h:213
void range(int min, int max)
Specify the range of values used.
Definition: slider.h:132
A structure containing the mouse status for event handlers.
Definition: wex.h:28