Adonthell  0.4
win_base.cc
1 /*
2  (C) Copyright 2000, 2001 Joel Vennin
3  Part of the Adonthell Project <http://adonthell.nongnu.org>
4 
5  Adonthell is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  Adonthell is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with Adonthell. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 
20 #include "win_base.h"
21 #include "win_manager.h"
22 #include "win_container.h"
23 
25 {
26  manager_ = NULL;
27 
28  wb_father_= NULL;
29 
30  pad_y_ = pad_x_ = 0;
31 
32  move(0,0);
33 
34  set_visible(false);
35 
36  set_focus(false);
37 
38  set_activate(false);
39 
40  set_brightness(false);
41 
42  set_trans(false);
43 
44  set_can_be_selected(true);
45 
46  set_align(ALIGN_NONE);
47 }
48 
49 win_base::~win_base()
50 {
51  if (manager_) manager_->remove (this);
52  manager_ = NULL;
53 }
54 
55 void win_base::set_container(win_container * wc)
56 {
57  wb_father_=wc;
58 
59  update_position();
60 
61  update_align();
62 }
63 
64 void win_base::update_position()
65 {
66 
67  if(wb_father_) {
68  drawing_area::move(wb_father_->real_x() + x() + pad_x(), wb_father_->real_y() + y() + pad_y() );
69  }
70  else {
71  drawing_area::move( x() + pad_x(), y() + pad_y() );
72  }
73 }
74 
76 {
77 
78  x_= tx;
79 
80  y_= ty;
81 
82  update_position();
83 }
84 
86 {
87  drawing_area::resize(tl, th);
88 
89  win_border::update();
90 
91  win_background::update();
92 }
93 
95 {
96  if(win_event::update())
97  {
98  // if(focus_) ADDME: ajouter l'appel a update_input
99  on_update();
100 
101  return true;
102  }
103  return false;
104 }
105 
107 {
108  return (focus_ && activate_);
109 }
110 
112 {
113  on_draw();
114 
115  if(visible_) on_draw_visible();
116 
117  return visible_;
118 }
119 
120 
121 
122 void win_base::update_align()
123 {
124  switch(align_)
125  {
126  case ALIGN_LEFT:
127  move((wb_father_) ? ((win_container*)wb_father_)->space_with_border() : 0 , y() );
128  break;
129  case ALIGN_RIGHT:
130  move(((wb_father_) ? wb_father_->length() : screen::length())-((wb_father_)?((win_container*)wb_father_)->space_with_border() : 0 ) - length() , y() );
131  break;
132  case ALIGN_CENTER:
133  if(((wb_father_)?wb_father_->length():screen::length())>length())
134  move((((wb_father_)?wb_father_->length():screen::length()) - length()) >>1,y());
135  break;
136  }
137 }
138 
139 void win_base::set_manager (win_manager *m)
140 {
141  manager_ = m;
142 }
143 
win_base::set_activate
void set_activate(const bool b)
Set the activate parameter When a win_* is setup on, the keys queue is cleared.
Definition: win_base.h:156
win_base::draw
virtual bool draw()
Draw process.
Definition: win_base.cc:111
drawing_area::move
void move(s_int16 nx, s_int16 ny)
Move the drawing_area.
Definition: drawing_area.h:110
win_base::set_visible
void set_visible(const bool b)
Set the visible parameter.
Definition: win_base.h:140
screen::length
static u_int16 length()
Returns the length of the screen.
Definition: screen.h:84
win_base::input_update
virtual bool input_update()
Input Update process .
Definition: win_base.cc:106
win_background
Definition: win_background.h:28
win_base::pad_x
s_int16 & pad_x()
Return the pad horizontal position of the win_*.
Definition: win_base.h:88
win_base::set_focus
void set_focus(const bool b)
Set the focus parameter.
Definition: win_base.h:170
win_base::update
virtual bool update()
Update process.
Definition: win_base.cc:94
s_int16
#define s_int16
16 bits long signed integer
Definition: types.h:47
win_base::resize
virtual void resize(u_int16 tl, u_int16 th)
Rezise the win_*.
Definition: win_base.cc:85
win_base.h
win_base::move
virtual void move(s_int16 tx, s_int16 ty)
Move the win_*.
Definition: win_base.cc:75
win_base::x
s_int16 x() const
Return the relative horizontal position of the win_*.
Definition: win_base.h:72
win_manager
The window manager takes care of basic GUI functions, such as input focus, window state updates and d...
Definition: win_manager.h:65
win_base::real_y
s_int16 real_y() const
Return the vertical position of the win_*.
Definition: win_base.h:112
win_base::set_trans
virtual void set_trans(const bool b)
Set the transluency parameter.
Definition: win_base.h:184
win_base::set_brightness
virtual void set_brightness(const bool b)
Set the transluency parameter.
Definition: win_base.h:198
win_base::set_can_be_selected
void set_can_be_selected(const bool b)
Set the object to be selected A win_obj can be selectable or not when it is inside a win_select.
Definition: win_base.h:226
win_manager.h
Declares the win_manager class.
win_base::win_base
win_base()
Default constructor:
Definition: win_base.cc:24
drawing_area::resize
void resize(u_int16 nl, u_int16 nh)
Resize the drawing_area.
Definition: drawing_area.h:120
win_base::real_x
s_int16 real_x() const
Return the horizontal position of the win_*.
Definition: win_base.h:104
win_base::set_align
void set_align(const u_int8 a)
Set alignement of win_*.
Definition: win_base.h:205
u_int16
#define u_int16
16 bits long unsigned integer
Definition: types.h:38
win_base::pad_y
s_int16 & pad_y()
Return the pad vertical position of the win_*.
Definition: win_base.h:96
win_manager::remove
void remove(win_base *wnd)
Remove a window from the window manager.
Definition: win_manager.cc:128
win_base::y
s_int16 y() const
Return the relative vertical position of the win_*.
Definition: win_base.h:80
drawing_area::length
u_int16 length() const
Returns the length of the drawing_area.
Definition: drawing_area.h:93
win_border
Definition: win_border.h:31
win_container
Definition: win_container.h:29