FDOSTUI
FreeDOS Text User Interface
spinner.hpp
Go to the documentation of this file.
1 /*
2  SPINNER.HPP
3 
4  License CC0 PUBLIC DOMAIN
5 
6  To the extent possible under law, Mark J. Olesen has waived all copyright
7  and related or neighboring rights to FDOSTUI Library. This work is published
8  from: United States.
9 */
10 #ifndef __spinner_hpp__
11 
12 #include "valuator.hpp"
13 #include "entry.hpp"
14 #include <stdlib.h>
15 
16 class spinner : public entry, public valuator
17 {
18 
19 public:
20 
21  spinner(
22  int const i_pos_x,
23  int const i_pos_y,
24  unsigned int const i_len_x,
25  unsigned int const i_len_y);
26 
27  virtual
28  ~spinner();
29 
30  virtual void
31  draw() const;
32 
33  virtual double
34  get_value() const;
35 
36  virtual bool
37  set_value(
38  double const i_value);
39 
40  virtual enum event_response
41  event_key(
42  struct event_key const& i_event);
43 
44  virtual enum event_response
46  struct event_mouse const& i_event);
47 
48 protected:
49 
50  virtual void
51  get_bbox(
52  struct box& o_bbox) const;
53 
54 private:
55 
56  spinner();
57 
58  spinner(
59  const spinner&);
60 
61  spinner&
62  operator=(spinner const&);
63 
64 };
65 
66 inline void
68  struct box& o_bbox) const
69 {
70  o_bbox= m_box;
71  if (3 <= m_box.m_len_x)
72  {
73  o_bbox.m_len_x--;
74  o_bbox.m_len_x--;
75  }
76 }
77 
78 inline double
80 {
81  double l_value;
82 
83  m_block[m_length]= 0;
84  l_value= strtod(reinterpret_cast<char*>(m_block), 0);
85 
86  return l_value;
87 }
88 
89 #define __spinner_hpp__
90 #endif
contains entry class
virtual bool set_value(double const i_value)
sets the value
Definition: spinner.cpp:149
virtual ~spinner()
destructor
Definition: spinner.cpp:28
struct box m_box
Definition: widget.hpp:171
Allows the user to enter a numeric value. The value can be adjusted through the use of repeat buttons...
Definition: spinner.hpp:16
virtual void draw() const
draws the widget
Definition: spinner.cpp:34
virtual enum event_response event_mouse(struct event_mouse const &i_event)
handle mouse event
Definition: spinner.cpp:109
size_t m_length
Definition: entry.hpp:86
contains valuator class
Allows a user to enter text.
Definition: entry.hpp:14
virtual double get_value() const
gets the value
Definition: spinner.hpp:79
event_response
response
Definition: event.h:14
virtual enum event_response event_key(struct event_key const &i_event)
handle key event
Definition: spinner.cpp:72
virtual void get_bbox(struct box &o_bbox) const
get the inner bounding box
Definition: spinner.hpp:67
unsigned int m_len_x
Definition: box.h:16
interface to control a floating point value
Definition: valuator.hpp:28
unsigned char * m_block
Definition: entry.hpp:88
container for a mouse event
Definition: event.h:37
defines a rectangular region
Definition: box.h:12
container for a keyboard event
Definition: event.h:23