FDOSTUI
FreeDOS Text User Interface
label.hpp
Go to the documentation of this file.
1 /*
2  LABEL.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 __label_hpp__
11 
12 #include "draw.h"
13 #include "widget.hpp"
14 #include <stddef.h>
15 #include <stdlib.h>
16 #include <string.h>
17 #if defined(__WATCOMC__)
18 #include <malloc.h>
19 #endif
20 
21 class label : public widget
22 {
23 public:
24 
25  label(
26  int const i_pos_x,
27  int const i_pos_y,
28  unsigned int const i_len_x,
29  unsigned int const i_len_y);
30 
31  virtual
32  ~label();
33 
34  virtual void
35  draw() const;
36 
37  unsigned char const*
38  get_text() const;
39 
40  void
41  set_text(
42  unsigned char const* i_str);
43 
44 protected:
45 
46  unsigned char* m_label;
47 
48 private:
49 
50  label();
51 
52  label(
53  const label&);
54 
55  label&
56  operator=(label const&);
57 
58 };
59 
60 inline unsigned char const*
62 {
63  return m_label;
64 }
65 
66 inline void
68  unsigned char const* i_str)
69 {
70 
71  free(m_label);
72  m_label= 0;
73 
74  if (i_str && i_str[0])
75  {
76  size_t l_len;
77  l_len= 1+strlen(reinterpret_cast<char const*>(i_str));
78  m_label= reinterpret_cast<unsigned char*>(malloc(l_len));
79  if (m_label)
80  {
81  memcpy(m_label, i_str, l_len);
82  }
83  }
84 
85  return;
86 }
87 
88 #define __label_hpp__
89 #endif
drawing routines that applies clipping
contains widget class
virtual ~label()
destructor
Definition: label.cpp:25
base class for all derived widgets
Definition: widget.hpp:19
unsigned char * m_label
buffer to hold label
Definition: label.hpp:46
virtual void draw() const
draws the widget
Definition: label.cpp:69
Allows display of text.
Definition: label.hpp:21
void set_text(unsigned char const *i_str)
set label text
Definition: label.hpp:67
unsigned char const * get_text() const
returns label text
Definition: label.hpp:61