Adonthell
0.4
Main Page
Related Pages
Classes
Files
File List
File Members
win_base.cc
1
/*
2
$Id: win_base.cc,v 1.4 2004/10/25 06:55:01 ksterker Exp $
3
4
(C) Copyright 2000, 2001 Joel Vennin
5
Part of the Adonthell Project http://adonthell.linuxgames.com
6
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY.
11
12
See the COPYING file for more details
13
*/
14
15
16
#include "
win_base.h
"
17
#include "
win_manager.h
"
18
#include "win_container.h"
19
20
win_base::win_base
():
win_border
(this),
win_background
(this)
21
{
22
manager_ = NULL;
23
24
wb_father_= NULL;
25
26
pad_y_ = pad_x_ = 0;
27
28
move
(0,0);
29
30
set_visible
(
false
);
31
32
set_focus
(
false
);
33
34
set_activate
(
false
);
35
36
set_brightness
(
false
);
37
38
set_trans
(
false
);
39
40
set_can_be_selected
(
true
);
41
42
set_align
(ALIGN_NONE);
43
}
44
45
win_base::~win_base()
46
{
47
if
(manager_) manager_->
remove
(
this
);
48
manager_ = NULL;
49
}
50
51
void
win_base::set_container(
win_container
* wc)
52
{
53
wb_father_=wc;
54
55
update_position();
56
57
update_align();
58
}
59
60
void
win_base::update_position()
61
{
62
63
if
(wb_father_) {
64
drawing_area::move
(wb_father_->
real_x
() +
x
() +
pad_x
(), wb_father_->
real_y
() +
y
() +
pad_y
() );
65
}
66
else
{
67
drawing_area::move
(
x
() +
pad_x
(),
y
() +
pad_y
() );
68
}
69
}
70
71
void
win_base::move
(
s_int16
tx,
s_int16
ty)
72
{
73
74
x_= tx;
75
76
y_= ty;
77
78
update_position();
79
}
80
81
void
win_base::resize
(
u_int16
tl,
u_int16
th)
82
{
83
drawing_area::resize
(tl, th);
84
85
win_border::update
();
86
87
win_background::update
();
88
}
89
90
bool
win_base::update
()
91
{
92
if
(win_event::update())
93
{
94
// if(focus_) ADDME: ajouter l'appel a update_input
95
on_update();
96
97
return
true
;
98
}
99
return
false
;
100
}
101
102
bool
win_base::input_update
()
103
{
104
return
(focus_ && activate_);
105
}
106
107
bool
win_base::draw
()
108
{
109
on_draw();
110
111
if
(visible_) on_draw_visible();
112
113
return
visible_;
114
}
115
116
117
118
void
win_base::update_align()
119
{
120
switch
(align_)
121
{
122
case
ALIGN_LEFT:
123
move
((wb_father_) ? ((
win_container
*)wb_father_)->space_with_border() : 0 ,
y
() );
124
break
;
125
case
ALIGN_RIGHT:
126
move
(((wb_father_) ? wb_father_->
length
() :
screen::length
())-((wb_father_)?((
win_container
*)wb_father_)->space_with_border() : 0 ) -
length
() ,
y
() );
127
break
;
128
case
ALIGN_CENTER:
129
if
(((wb_father_)?wb_father_->
length
():
screen::length
())>
length
())
130
move
((((wb_father_)?wb_father_->
length
():
screen::length
()) -
length
()) >>1,
y
());
131
break
;
132
}
133
}
134
135
void
win_base::set_manager (
win_manager
*m)
136
{
137
manager_ = m;
138
}
139
src
win_base.cc
Generated by
1.8.1.1