1
/* Hexwars - A Hexagonal Turn Based Strategy Game
2
* Copyright (C) 2009-2011 Patrik Schönfeldt
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
#ifndef __AL4UI__HPP__
19
#define __AL4UI__HPP__
24
#include "../../definitions/Coordinates.hpp"
25
#include "../MenuItem.hpp"
26
#include "../GraphicSet.hpp"
30
/** \brief UIs are responsable for representing interaction
31
* entities (like menus) to the user. UIs can be seen as an
32
* abstraction layer for several user interface solutions
33
* (like allegro, X11, etc.)
35
class Al4UI : public VirtualUI {
39
/** \brief Constructor needs parent UI, input will be set to NULL
41
* size defines the size of the
42
* UI on screen, the constructor will create
43
* a BITMAP for buffering in the given
46
* pos defines the position of the
47
* UI on the parents input
49
* UI needs a GraphicSet* to be able to print
50
* graphics, link one with gs
52
* UI* par defines a parent UI, that this
53
* UI will be printed on
55
* WARNING: input is set to NULL by constructor
56
* because it is only needed if there are child
59
Al4UI(Coordinates size, Coordinates pos, GraphicSet* gs, Al4UI* par);
61
/** \brief destroys bitmaps
65
void setGraphicSet(GraphicSet* gs);
67
/** \brief Locks or unlocks the double buffer.
69
* With some graphic libs a higher drawing performance may be
70
* accomplished when drawing on a locked bitmap. Locked bitmaps
71
* in allegro can not be read but only written.
73
void lockScreen(bool doit);
75
/** \brief Returns the position of the pointer.
77
* Returns where the mouse points at in the current UI.
78
* Will return Coordinates(-1,-1) when mouse does not point
79
* in into the area of this UI. Uses allegro
80
* (mouse_x, mouse_y) position and size of the UI.
82
* \returns Coordinates of the mouse on the current UI
84
Coordinates getPointerPos();
86
/** \brief Prints buffer and input on parents input.
88
* First of all it prints scrollbuffer, the
89
* staticbuffer (the one with transparency)
90
* and the pointer on the screenbuffer. Then
91
* the screenbuffer is printed on screen.
97
/** \brief Clears the screen.
99
* Clears the buffer to magic pink.
103
/** \brief clears top layer buffer
108
/** \brief This method analyzes if user input is importent
111
* It will return NOINPUT if nothing important happened.
112
* This basic implementation just returns the return HOVER
113
* if pointer is above UI.
115
* \returns code for user input: HOVER or NOINPUT
117
virtual INPUTTYPE getInput(INPUTTYPE currinput);
119
/** \brief moves UI around on parent UI
122
void changePos(Coordinates dp);
124
/** \brief Returns the size of the window.
126
* Returns the size of the window that is
127
* currently displayed.
129
* \returns size of the UI
131
Coordinates getSize();
133
/** \brief change size on screen
136
void setSize(Coordinates s);
138
/** \brief Children will draw their buffers onto this BITMAP.
140
* This is the top layer buffer. If there are child UIs they
141
* will use this buffer to draw on parent UIs. After printing
142
* its own doublebuffer on screen (or onto the parent TLB) this
143
* input will be printed. This means that only contents that
144
* really need a refresh will be refreshed.
148
void printText(std::string text, Coordinates pos);
151
/** \brief function for initialization
152
* it is a good idea to use this in your constructor of child classes
154
void init(Coordinates size, Coordinates pos, GraphicSet* gs, Al4UI* par);
156
/** \brief internal buffer — only redraw contents if refresh is needed
160
/** \brief every UI has a parent UI (parent window)
162
* Every UI is nested in anoter UI. The basis of this is a special
163
* implementation of UI, the BasicUserInterface. It has no parent
164
* but will use pure allegro routines.
169
#endif /* __AL4UI__HPP__ */