Sort include order.
[gemrb.git] / gemrb / core / Window.h
blobfe015c65cf317fdd87ca0586b4ba0c0dbabfb6c1
1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 /**
22 * @file Window.h
23 * Declares Window, class serving as a container for Control/widget objects
24 * and displaying windows in GUI
25 * @author The GemRB Project
28 #ifndef WINDOW_H
29 #define WINDOW_H
31 #include "exports.h"
33 #include "Control.h"
34 #include "ScrollBar.h"
35 #include "Sprite2D.h"
36 #include "TextArea.h"
38 #include <vector>
40 // Window Flags
41 #define WF_CHANGED 1 //window changed
42 #define WF_FRAME 2 //window has frame
43 #define WF_FLOAT 4 //floating window
44 #define WF_CHILD 8 //if invalidated, it invalidates all windows on top of it
46 // Window position anchors (actually flags for WindowSetPos())
47 // !!! Keep these synchronized with GUIDefines.py !!!
48 #define WINDOW_TOPLEFT 0x00
49 #define WINDOW_CENTER 0x01
50 #define WINDOW_ABSCENTER 0x02
51 #define WINDOW_RELATIVE 0x04
52 #define WINDOW_SCALE 0x08
53 #define WINDOW_BOUNDED 0x10
55 // IE specific cursor types
57 #define IE_CURSOR_INVALID -1
58 #define IE_CURSOR_NORMAL 0
59 #define IE_CURSOR_TAKE 2 //over pile type containers
60 #define IE_CURSOR_WALK 4
61 #define IE_CURSOR_BLOCKED 6
62 #define IE_CURSOR_USE 8 //never hardcoded
63 #define IE_CURSOR_WAIT 10 //hourglass
64 #define IE_CURSOR_ATTACK 12
65 #define IE_CURSOR_SWAP 14 //dragging portraits
66 #define IE_CURSOR_DEFEND 16
67 #define IE_CURSOR_TALK 18
68 #define IE_CURSOR_CAST 20 //targeting with non weapon
69 #define IE_CURSOR_INFO 22 //never hardcoded
70 #define IE_CURSOR_LOCK 24 //locked door
71 #define IE_CURSOR_LOCK2 26 //locked container
72 #define IE_CURSOR_STAIR 28 //never hardcoded
73 #define IE_CURSOR_DOOR 30 //doors
74 #define IE_CURSOR_CHEST 32
75 #define IE_CURSOR_TRAVEL 34
76 #define IE_CURSOR_STEALTH 36
77 #define IE_CURSOR_TRAP 38
78 #define IE_CURSOR_PICK 40 //pickpocket
79 #define IE_CURSOR_PASS 42 //never hardcoded
80 #define IE_CURSOR_GRAB 44
81 #define IE_CURSOR_WAY 46 //waypoint (not in PST)
82 #define IE_CURSOR_INFO2 46 //PST
83 #define IE_CURSOR_PORTAL 48 //PST
84 #define IE_CURSOR_STAIR2 50 //PST
85 #define IE_CURSOR_EXTRA 52 //PST
87 #define IE_CURSOR_MASK 127
88 #define IE_CURSOR_GRAY 128
89 /**
90 * @class Window
91 * Class serving as a container for Control/widget objects
92 * and displaying windows in GUI.
95 class GEM_EXPORT Window {
96 public:
97 Window(unsigned short WindowID, unsigned short XPos, unsigned short YPos,
98 unsigned short Width, unsigned short Height);
99 ~Window();
100 /** Set the Window's BackGround Image.
101 * If 'img' is NULL, no background will be set. If the 'clean' parameter is true (default is false) the old background image will be deleted. */
102 void SetBackGround(Sprite2D* img, bool clean = false);
103 /** Add a Control in the Window */
104 void AddControl(Control* ctrl);
105 /** This function Draws the Window on the Output Screen */
106 void DrawWindow();
107 /** Set window frame used to fill screen on higher resolutions*/
108 void SetFrame();
109 /** Returns the Control at X,Y Coordinates */
110 Control* GetControl(unsigned short x, unsigned short y, bool ignore=0);
111 /** Returns the Control by Index */
112 Control* GetControl(unsigned short i) const;
113 /** Returns the number of Controls */
114 unsigned int GetControlCount() const;
115 /** Returns true if ctrl is valid and ctrl->ControlID is ID */
116 bool IsValidControl(unsigned short ID, Control *ctrl) const;
117 /** Deletes the xth. Control */
118 void DelControl(unsigned short i);
119 /** Returns the Default Control which may be a button/gamecontrol atm */
120 Control* GetDefaultControl(unsigned int ctrltype) const;
121 /** Returns the Control which should get mouse scroll events */
122 Control* GetScrollControl() const;
123 /** Sets 'ctrl' as currently under mouse */
124 void SetOver(Control* ctrl);
125 /** Returns last control under mouse */
126 Control* GetOver() const;
127 /** Sets 'ctrl' as Focused */
128 void SetFocused(Control* ctrl);
129 /** Sets 'ctrl' as mouse event Focused */
130 void SetMouseFocused(Control* ctrl);
131 /** Returns last focused control */
132 Control* GetFocus() const;
133 /** Returns last mouse event focused control */
134 Control* GetMouseFocus() const;
135 /** Redraw all the Window */
136 void Invalidate();
137 /** Redraw enough to update the specified Control */
138 void InvalidateForControl(Control *ctrl);
139 /** Redraw controls of the same group */
140 void RedrawControls(const char* VarName, unsigned int Sum);
141 /** Links a scrollbar to a text area */
142 void Link(unsigned short SBID, unsigned short TAID);
143 /** Mouse entered a new control's rectangle */
144 void OnMouseEnter(unsigned short x, unsigned short y, Control *ctrl);
145 /** Mouse left the current control */
146 void OnMouseLeave(unsigned short x, unsigned short y);
147 /** Mouse is over the current control */
148 void OnMouseOver(unsigned short x, unsigned short y);
149 public: //Public attributes
150 /** WinPack */
151 char WindowPack[10];
152 /** Window ID */
153 unsigned short WindowID;
154 /** X Position */
155 unsigned short XPos;
156 /** Y Position */
157 unsigned short YPos;
158 /** Width */
159 unsigned short Width;
160 /** Height */
161 unsigned short Height;
162 /** Visible value: deleted, invisible, visible, grayed */
163 signed char Visible; //-1,0,1,2
164 /** Window flags: Changed, Floating, Framed, Child */
165 int Flags;
166 int Cursor;
167 int DefaultControl[2]; //default enter and cancel
168 int ScrollControl;
169 private: // Private attributes
170 /** BackGround Image. No BackGround if this variable is NULL. */
171 Sprite2D* BackGround;
172 /** Controls Array */
173 std::vector< Control*> Controls;
174 /** Last Control returned by GetControl */
175 Control* lastC;
176 /** Last Focused Control */
177 Control* lastFocus;
178 /** Last mouse event Focused Control */
179 Control* lastMouseFocus;
180 /** Last Control under mouse */
181 Control* lastOver;
182 /** Regions which need to be redrawn */
183 std::vector< Region> clip_regions;
185 public:
186 void release(void);
189 #endif