Adonthell
0.4
Main Page
Related Pages
Classes
Files
File List
File Members
drawable.h
Go to the documentation of this file.
1
/*
2
$Id: drawable.h,v 1.6 2001/07/28 20:34:49 gnurou Exp $
3
4
Copyright (C) 1999/2000/2001 Alexandre Courbot
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
/**
17
* @file drawable.h
18
* @author Alexandre Courbot <alexandrecourbot@linuxgames.com>
19
*
20
* @brief Declares the drawable class.
21
*
22
*/
23
24
25
#ifndef DRAWABLE_H_
26
#define DRAWABLE_H_
27
28
#include "
drawing_area.h
"
29
30
class
surface
;
31
32
/**
33
* Abstract class for drawable %objects manipulation.
34
*
35
* This class is designed to allow flexibility in
36
* drawable %objects manipulation. It also serves as
37
* a template when creating your own classes.
38
*
39
* It defines the basic virtual methods every drawable
40
* object is required to have. When you design such drawable
41
* object, make it inherit from this class and overload the virtual
42
* functions you wish to use.
43
*
44
* The main advantage of this class is that it allows you to manipulate
45
* any drawable object (image, animation, mapview...) without caring
46
* about it's type, at the little cost of having to use virtual methods.
47
*
48
* There are a few methods that are required to be overloaded
49
* in your class. The draw method is a must-have. Your object must also
50
* take care to set the size of the drawable correctly (the best thing
51
* being that it should use the drawable's size as it's own and don't
52
* overload the length () and height () methods).
53
*
54
*/
55
class
drawable
56
{
57
public
:
58
59
/**
60
* Default constructor.
61
*
62
*/
63
drawable
();
64
65
/**
66
* Destructor.
67
*/
68
virtual
~drawable
();
69
70
/**
71
* Returns the length of the drawable.
72
*
73
*
74
* @return length of the drawable.
75
*/
76
u_int16
length
()
const
77
{
78
return
length_;
79
}
80
81
/**
82
* Returns the height of the drawable.
83
*
84
*
85
* @return height of the drawable.
86
*/
87
u_int16
height
()
const
88
{
89
return
height_;
90
}
91
92
/**
93
* Virtual update function, provided for %objects which
94
* doesn't need one.
95
*
96
*/
97
virtual
bool
update
();
98
99
/**
100
* Virtual input update function, provided for %objects which
101
* doesn't need one.
102
*
103
*/
104
virtual
bool
input_update
();
105
106
/**
107
* Draw the object on the %screen.
108
*
109
* @param x X position where to draw.
110
* @param y Y position where to draw.
111
* @param da_opt optional drawing_area to use during the drawing operation.
112
* @param target pointer to the surface where to draw the drawable. If NULL,
113
* draw on the screen.
114
*/
115
virtual
void
draw
(
s_int16
x,
s_int16
y,
const
drawing_area
* da_opt = NULL,
116
surface
* target = NULL)
const
= 0;
117
118
protected
:
119
120
/**
121
* Sets the length of the drawable.
122
*
123
* @param l new length.
124
*/
125
void
set_length
(
u_int16
l)
126
{
127
length_ = l;
128
}
129
130
/**
131
* Sets the height of the drawable.
132
*
133
* @param h new height.
134
*/
135
void
set_height
(
u_int16
h)
136
{
137
height_ = h;
138
}
139
140
private
:
141
u_int16
length_;
142
u_int16
height_;
143
};
144
145
#endif
src
drawable.h
Generated by
1.8.4