spinner.hpp 1.67 KB
Newer Older
Ercan Ersoy's avatar
Ercan Ersoy committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
/*
 SPINNER.HPP

 License CC0 PUBLIC DOMAIN

 To the extent possible under law, Mark J. Olesen has waived all copyright 
 and related or neighboring rights to FDOSTUI Library. This work is published 
 from: United States.
*/
#ifndef __spinner_hpp__

#include "valuator.hpp"
#include "entry.hpp"
#include <stdlib.h>

class spinner : public entry, public valuator
{

public:

    spinner(
        int const                       i_pos_x,
        int const                       i_pos_y,
        unsigned int const              i_len_x,
        unsigned int const              i_len_y);
    
    virtual
    ~spinner();

    virtual void
    draw() const;

    virtual double
    get_value() const;

    virtual bool
    set_value(
        double const                    i_value);

    virtual enum event_response
    event_key(
        struct event_key const&         i_event);
    
    virtual enum event_response
    event_mouse(
    struct event_mouse const&       i_event);

protected:

    virtual void
    get_bbox(
        struct box&                     o_bbox) const;

private:

    spinner();
    
    spinner(
    const spinner&);

    spinner&
    operator=(spinner const&);

};

inline void
spinner::get_bbox(
    struct box&                         o_bbox) const
{
    o_bbox= m_box;
    if (3 <= m_box.m_len_x)
    {
        o_bbox.m_len_x--;
        o_bbox.m_len_x--;
    }
}

inline double
spinner::get_value() const
{
    double                              l_value;

    m_block[m_length]= 0;
    l_value= strtod(reinterpret_cast<char*>(m_block), 0);

    return l_value;
}

#define __spinner_hpp__
#endif