FDOSTUI
FreeDOS Text User Interface
window.hpp
Go to the documentation of this file.
1 /*
2  WINDOW.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 __window_hpp__
11 
12 #include "group.hpp"
13 #include <string.h>
14 #include <stdlib.h>
15 #if defined(__WATCOMC__)
16 #include <malloc.h>
17 #endif
18 
19 class window : public group
20 {
21 
22 public:
23 
25  {
26  EMPTY= (1 << 0),
27  BORDER= (1 << 1),
28  TITLE= (1 << 2),
29  MINMAX= (1 << 3),
30  RESIZE= (1 << 4),
31  SYSTEM= (1 << 5)
32  };
33 
34  window(
35  int const i_pos_x,
36  int const i_pos_y,
37  unsigned int const i_len_x,
38  unsigned int const i_len_y);
39 
40  virtual
41  ~window();
42 
43  virtual void
44  draw() const;
45 
46  enum attributes
47  get_attributes() const;
48 
49  unsigned char const*
50  get_title() const;
51 
52  void
54  unsigned const i_attributes);
55 
56  void
57  set_title(
58  unsigned char const* i_str);
59 
60 protected:
61 
62  unsigned char* m_title;
64 
65 private:
66 
67  window();
68 
69  window(
70  const window&);
71 
72  window&
73  operator=(window const&);
74 
75 };
76 
77 inline window::attributes
79 {
80  return m_attributes;
81 }
82 
83 inline unsigned char const*
85 {
86  return m_title;
87 }
88 
89 inline void
91  unsigned const i_attributes)
92 {
93  m_attributes= static_cast<enum attributes>(i_attributes);
94  return;
95 }
96 
97 inline void
99  unsigned char const* i_str)
100 {
101 
102  free(m_title);
103  m_title= 0;
104 
105  if (i_str && i_str[0])
106  {
107  size_t l_len;
108  l_len= 1+strlen(reinterpret_cast<char const*>(i_str));
109  m_title= reinterpret_cast<unsigned char*>(malloc(l_len));
110  if (m_title)
111  {
112  memcpy(m_title, i_str, l_len);
113  }
114  }
115 
116  return;
117 }
118 
119 #define __window_hpp__
120 #endif
Definition: window.hpp:30
Definition: window.hpp:29
unsigned char const * get_title() const
gets the windows title
Definition: window.hpp:84
virtual ~window()
destructor
Definition: window.cpp:31
Definition: window.hpp:28
Definition: window.hpp:26
attributes
Definition: window.hpp:24
void set_title(unsigned char const *i_str)
sets the windows title
Definition: window.hpp:98
container to hold a collection of widgets
Definition: group.hpp:15
enum attributes m_attributes
Definition: window.hpp:63
Definition: window.hpp:31
virtual void draw() const
draws the widget
Definition: window.cpp:40
void set_attributes(unsigned const i_attributes)
set the window attributes
Definition: window.hpp:90
enum attributes get_attributes() const
gets the window attributes
Definition: window.hpp:78
Definition: window.hpp:27
unsigned char * m_title
Definition: window.hpp:62
top level container widget that can be moved and resized by the user
Definition: window.hpp:19
contains group class