Planeshift
pawscontrolwindow.h
Go to the documentation of this file.
1 /*
2  * pawscontrolwindow.h - Author: Andrew Craig
3  *
4  * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program 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  * 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.
17  *
18  */
20 
21 #ifndef PAWS_CONTROL_WINDOW_HEADER
22 #define PAWS_CONTROL_WINDOW_HEADER
23 
24 #include "paws/pawswidget.h"
25 #include "paws/pawsbutton.h"
26 #include <iutil/csinput.h>
27 
29 
33 struct WBName
34 {
35  csString windowName;
36  csString buttonName;
37  int id;
38 };
39 
41 struct Icon
42 {
45  bool IsActive;
46  bool IsOver;
47  csString orgRes;
48 };
49 
50 
56 {
57 public:
59  virtual ~pawsControlWindow();
64  void Toggle();
65  bool OnButtonReleased(int mouseButton, int keyModifier, pawsWidget* reporter);
66  bool OnChildMouseEnter(pawsWidget *child);
67  bool OnChildMouseExit(pawsWidget *child);
68  void Hide();
69  void Show();
70 
79  bool HandleWindow(csString widgetStr);
80 
87  bool HandleWindowName(csString widgetStr);
88 
94  bool showWindow(csString widgetStr);
100  bool hideWindow(csString widgetStr);
106  bool showWindowName(csString widgetStr);
112  bool hideWindowName(csString widgetStr);
113 
120  bool setWindowPositionName(csString widgetStr, int x, int y);
121 
128  bool setWindowSizeName(csString widgetStr, int width, int height);
129 
133  csString getWindowNames();
134 
139  csString getWindowInfo(csString widgetStr);
140 
144  void HandleQuit();
145 
150  void WindowOpen(pawsWidget* wnd);
151 
156  void WindowClose(pawsWidget* wnd);
157 
161  void Register( pawsControlledWindow* window );
162 
167  void AddWindow(csString wndName, csString btnName);
168 
169  bool PostSetup();
170 
176  pawsControlledWindow* FindWindowFromButton(csString btnName);
177 
183  pawsButton* FindButtonFromWindow(csString wndName);
184 
188  Icon* GetIcon(csString btnName);
189 
193  void NextStyle();
194 
195  bool OnMouseEnter();
196  bool OnMouseExit();
197 
198  bool Contains( int x, int y );
199 
200 private:
207  csString translateWidgetName(csString widgetStr);
208  struct WindowNames
209  {
210  csString name;
211  csArray<csString> alternativeNames;
212  }; // struct to contain the window names and their alternatives
213  csArray<WindowNames> controlledWindows; // array of all window names that are controllable by commands
214 
215  unsigned short int style;
216  bool hidden;
217  csArray<WBName> wbs;
218  csPDelArray<Icon> buttons;
219 
220  pawsWidget* buttonUp;
221  pawsWidget* buttonDown;
222 
223  Icon* QuitIcon;
224 
225  csRef<iKeyboardDriver> keyboard;
226 
227  bool alwaysResize;
228 
229  int orgw,orgh;
230 };
231 
233 
239 {
240 public:
241 
243  {
244  registered=false;
245  }
246 
250  virtual void Register()
251  {
252  controller = (pawsControlWindow*)PawsManager::GetSingleton().FindWidget("ControlWindow");
253  controller->Register( this );
254  registered = true;
255  }
256 
258  virtual void Show()
259  {
260  if (!registered)
261  Register();
262 
264  controller->WindowOpen( this );
265  }
266 
268  virtual void Hide()
269  {
270  if (!registered)
271  Register();
272 
274  controller->WindowClose( this );
275  }
276 
277 private:
278  pawsControlWindow* controller;
279  bool registered;
280 };
281 
282 #endif
This is a window that is controlled by a button on the control bar.
csString buttonName
pawsControlledWindow * window
The main base widget that all other widgets should inherit from.
Definition: pawswidget.h:116
pawsControlWindow(const pawsControlWindow &origin)
csString orgRes
pawsButton * theirButton
virtual void Register()
Called to register new window with the controller window.
pawsWidget * FindWidget(const char *name, bool complain=true)
Locate a widget by name.
static PawsManager & GetSingleton(void)
Definition: singleton.h:49
virtual void Hide()
When the window is closed let the controller window know about it.
Window that drives the main interface.
csString windowName
bool IsOver
CREATE_PAWS_FACTORY(pawsControlWindow)
virtual void Show()
When the window is opened let the controller window know about it.
Structure to relate windows with their buttons for lookup.
A simple button widget.
Definition: pawsbutton.h:43
virtual void Show()
Makes widget visible and brings it to the front.
Map windows to their pawsButtons on the control panel.
bool IsActive
virtual void Hide()
Makes widget invisible and removes focus if widget has current focus.