Nana - a C++ framework project  

The Programmer's Guide 
nana::gui::slider

Description

A slider widget user can drag it for tracking.

Model of

Widget Window 

Public base classes

class widget_object<widget_tag, DrawerTrigger>: public widget

Typedefs

renderer The interface for user-defined renderer.
provider The interface for user-defined provider.
seekdir Defines the slider seek direction.

Members

slider() The default constructor
slider(window wd, bool visible) Creates a slider.
slider(window wd, const rectangle& r = rectangle(), bool visible = true) Ditto.
nana::pat::cloneable<renderer>& ext_renderer() Refers to the current renderer that slider is useing.
void ext_renderer(const nana::pat::cloneable<renderer>&) Set a new renderer.
void ext_provider(const nana::pat::cloneable<provider>&) Set a new provider.
void move_step(bool forward) Increase or decrease the value of slider.
void seek(seekdir::type) Define the direction that user can seek by using mouse.
bool transparent() const Returns true if the widget is transparent.
void transparent(bool) Enable/disable the transparent of widget.
unsigned value() const Return the value of slider.
void value(unsigned) Set the value of slider.
bool vertical() const Return true if the slider is vertical.
void vertical(bool) Set the slider whether is vertical or horizontal.
unsigned vmax() const Return the max value of slider.
void vmax(unsigned) Set the max value of slider.


File

nana/gui/widgets/slider.hpp

Notes

1, Definition of renderer.

class renderer
{
public:
    typedef nana::paint::graphics & graph_reference;

    struct bar_t
    {
        bool horizontal;
        nana::rectangle r; //the rectangle of bar
        unsigned border_size; //border size of bar
    };

    struct slider_t
    {
        bool horizontal;
        int pos;
        unsigned border;
        unsigned scale;
    };

    struct adorn_t
    {
        bool horizontal;
        nana::point bound;
        int fixedpos;
        unsigned block;
        unsigned vcur_scale; //pixels of vcur scale.
    };

    virtual ~renderer() = 0;
    virtual void background(nana::gui::window, graph_reference, bool isglass) = 0;
    virtual void adorn(nana::gui::window, graph_reference, const adorn_t&) = 0;
    virtual void adorn_textbox(nana::gui::window, graph_reference, const nana::string&, const nana::rectangle&) = 0;
    virtual void bar(nana::gui::window, graph_reference, const bar_t&) = 0;
    virtual void slider(nana::gui::window, graph_reference, const slider_t&) = 0;
};


2, Definition of provider, it provides a string that used to display a tip label when user move the mouse in a slider.

class provider
{
public:
    virtual ~provider() = 0;
    virtual nana::string adorn_trace(unsigned vmax, unsigned vadorn) const = 0;
};

3, Refer to this artical for understanding how to write a user-defined renderer.

See also

None.


Move to The Nana Programmer's Guide Main Page