Planeshift

pawscontrolwindow.h

Go to the documentation of this file.
00001 /*
00002  * pawscontrolwindow.h - Author: Andrew Craig
00003  *
00004  * Copyright (C) 2003 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00020 
00021 #ifndef PAWS_CONTROL_WINDOW_HEADER
00022 #define PAWS_CONTROL_WINDOW_HEADER
00023 
00024 #include "paws/pawswidget.h"
00025 #include "paws/pawsbutton.h"
00026 #include <iutil/csinput.h>
00027 
00028 class pawsControlledWindow;
00029 
00033 struct WBName
00034 {
00035     csString windowName;
00036     csString buttonName;
00037     int id;
00038 };
00039 
00041 struct Icon
00042 {
00043     pawsControlledWindow* window;
00044     pawsButton* theirButton;
00045     bool IsActive;
00046     bool IsOver;
00047     csString orgRes;
00048 };
00049 
00050 
00055 class pawsControlWindow : public pawsWidget
00056 {
00057 public:
00058     pawsControlWindow();
00059     virtual ~pawsControlWindow();
00060     pawsControlWindow(const pawsControlWindow& origin){}
00064     void Toggle();
00065     bool OnButtonReleased(int mouseButton, int keyModifier, pawsWidget* reporter);
00066     bool OnChildMouseEnter(pawsWidget *child);
00067     bool OnChildMouseExit(pawsWidget *child);
00068     void Hide();
00069     void Show();
00070 
00079     bool HandleWindow(csString widgetStr);
00080 
00087     bool HandleWindowName(csString widgetStr);
00088     
00094     bool showWindow(csString widgetStr);
00100     bool hideWindow(csString widgetStr);
00106     bool showWindowName(csString widgetStr);
00112     bool hideWindowName(csString widgetStr);
00113     
00120     bool setWindowPositionName(csString widgetStr, int x, int y);
00121     
00128     bool setWindowSizeName(csString widgetStr, int width, int height);
00129     
00133     csString getWindowNames();
00134     
00139     csString getWindowInfo(csString widgetStr);
00140 
00144     void HandleQuit();
00145 
00150     void WindowOpen(pawsWidget* wnd);
00151 
00156     void WindowClose(pawsWidget* wnd);
00157 
00161     void Register( pawsControlledWindow* window );
00162 
00167     void AddWindow(csString wndName, csString btnName);
00168 
00169     bool PostSetup();
00170 
00176     pawsControlledWindow* FindWindowFromButton(csString btnName);
00177 
00183     pawsButton* FindButtonFromWindow(csString wndName);
00184 
00188     Icon* GetIcon(csString btnName);
00189 
00193     void NextStyle();
00194 
00195     bool OnMouseEnter();
00196     bool OnMouseExit();
00197 
00198     bool Contains( int x, int y );
00199 
00200 private:
00207     csString translateWidgetName(csString widgetStr);
00208     struct WindowNames
00209     {
00210        csString name;
00211        csArray<csString> alternativeNames;
00212     }; // struct to contain the window names and their alternatives
00213     csArray<WindowNames> controlledWindows;  // array of all window names that are controllable by commands
00214 
00215     unsigned short int style;
00216     bool hidden;
00217     csArray<WBName> wbs;
00218     csPDelArray<Icon> buttons;
00219 
00220     pawsWidget* buttonUp;
00221     pawsWidget* buttonDown;
00222 
00223     Icon* QuitIcon;
00224 
00225     csRef<iKeyboardDriver> keyboard;
00226 
00227     bool alwaysResize;
00228 
00229     int orgw,orgh;
00230 };
00231 
00232 CREATE_PAWS_FACTORY( pawsControlWindow );
00233 
00238 class pawsControlledWindow : public pawsWidget
00239 {
00240 public:
00241 
00242     pawsControlledWindow()
00243     {
00244         registered=false;
00245     }
00246 
00250     virtual void Register()
00251     {
00252         controller = (pawsControlWindow*)PawsManager::GetSingleton().FindWidget("ControlWindow");
00253         controller->Register( this );
00254         registered = true;
00255     }
00256 
00258     virtual void Show()
00259     {
00260         if (!registered)
00261             Register();
00262 
00263         pawsWidget::Show();
00264         controller->WindowOpen( this );
00265     }
00266 
00268     virtual void Hide()
00269     {
00270         if (!registered)
00271             Register();
00272 
00273         pawsWidget::Hide();
00274         controller->WindowClose( this );
00275     }
00276 
00277 private:
00278     pawsControlWindow* controller;
00279     bool registered;
00280 };
00281 
00282 #endif