Crazy Eddies GUI System: CEGUISystem.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

# CEGUISystem.h

    00001 /************************************************************************
    00002         filename:       CEGUISystem.h
    00003         created:        20/2/2004
    00004         author:         Paul D Turner
    00005
    00006         purpose:        Defines interface for main GUI system class
    00007 *************************************************************************/
    00008 /*************************************************************************
    00009     Crazy Eddie's GUI System (http://www.cegui.org.uk)
    00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
    00011
    00012     This library is free software; you can redistribute it and/or
    00013     modify it under the terms of the GNU Lesser General Public
    00014     License as published by the Free Software Foundation; either
    00015     version 2.1 of the License, or (at your option) any later version.
    00016
    00017     This library is distributed in the hope that it will be useful,
    00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00020     Lesser General Public License for more details.
    00021
    00022     You should have received a copy of the GNU Lesser General Public
    00023     License along with this library; if not, write to the Free Software
    00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00025 *************************************************************************/
    00026 #ifndef _CEGUISystem_h_
    00027 #define _CEGUISystem_h_
    00028
    00029 #include "CEGUIBase.h"
    00030 #include "CEGUIString.h"
    00031 #include "CEGUISingleton.h"
    00032 #include "CEGUIRenderer.h"
    00033 #include "CEGUIMouseCursor.h"
    00034 #include "CEGUIInputEvent.h"
    00035 #include "CEGUIResourceProvider.h"
    00036
    00037
    00038 #if defined(_MSC_VER)
    00039 #       pragma warning(push)
    00040 #       pragma warning(disable : 4275)
    00041 #       pragma warning(disable : 4251)
    00042 #endif
    00043
    00044
    00045 // Start of CEGUI namespace section
    00046 namespace CEGUI
    00047 {
    00049 struct MouseClickTrackerImpl;
    00050
    00051
    00060 class CEGUIEXPORT System : public Singleton<System>, public EventSet
    00061 {
    00062 public:
    00063         static const String EventNamespace;
    00064
    00065         /*************************************************************************
    00066                 Constants
    00067         *************************************************************************/
    00068         static const double             DefaultSingleClickTimeout;
    00069         static const double             DefaultMultiClickTimeout;
    00070         static const Size               DefaultMultiClickAreaSize;
    00071
    00072         // event names
    00073         static const String EventGUISheetChanged;
    00074         static const String EventSingleClickTimeoutChanged;
    00075         static const String EventMultiClickTimeoutChanged;
    00076         static const String EventMultiClickAreaSizeChanged;
    00077         static const String EventDefaultFontChanged;
    00078         static const String EventDefaultMouseCursorChanged;
    00079         static const String EventMouseMoveScalingChanged;
    00080
    00081
    00082         /*************************************************************************
    00083                 Construction and Destruction
    00084         *************************************************************************/
    00095         System(Renderer* renderer, const utf8* logFile = (const utf8*)"CEGUI.log");
    00096
    00110     System(Renderer* renderer, ResourceProvider* resourceProvider, const utf8* logFile = (const utf8*)"CEGUI.log");
    00111
    00112
    00126         System(Renderer* renderer, ScriptModule* scriptModule, const utf8* configFile = (const utf8*)"cegui.config");
    00127
    00128
    00145         System(Renderer* renderer, ScriptModule* scriptModule, ResourceProvider* resourceProvider, const utf8* configFile = (const utf8*)"cegui.config");
    00146
    00147
    00161     System(Renderer* renderer, XMLParser* xmlParser, const utf8* logFile = (const utf8*)"CEGUI.log");
    00162
    00163
    00180     System(Renderer* renderer, ResourceProvider* resourceProvider, XMLParser* xmlParser, const utf8* logFile = (const utf8*)"CEGUI.log");
    00181
    00182
    00199     System(Renderer* renderer, XMLParser* xmlParser, ScriptModule* scriptModule, const utf8* configFile = (const utf8*)"cegui.config");
    00200
    00201
    00221     System(Renderer* renderer, ResourceProvider* resourceProvider, XMLParser* xmlParser, ScriptModule* scriptModule, const utf8* configFile = (const utf8*)"cegui.config");
    00222
    00223
    00228         ~System(void);
    00229
    00230
    00238         Renderer*       getRenderer(void) const                 {return d_renderer;}
    00239
    00240
    00248         static  System& getSingleton(void);
    00249
    00250
    00258         static  System* getSingletonPtr(void);
    00259
    00260
    00271         void    setDefaultFont(const String& name);
    00272
    00273
    00284         void    setDefaultFont(Font* font);
    00285
    00286
    00294         Font*   getDefaultFont(void) const                              {return d_defaultFont;}
    00295
    00296
    00304         void    signalRedraw()          {d_gui_redraw = true;}
    00305
    00306
    00314         bool    isRedrawRequested() const               {return d_gui_redraw;}
    00315
    00316
    00326         void    renderGUI(void);
    00327
    00328
    00339         Window* setGUISheet(Window* sheet);
    00340
    00341
    00349         Window* getGUISheet(void) const         {return d_activeSheet;}
    00350
    00351
    00361         double  getSingleClickTimeout(void) const               {return d_click_timeout;}
    00362
    00363
    00375         double  getMultiClickTimeout(void) const                {return d_dblclick_timeout;}
    00376
    00377
    00388         const Size&     getMultiClickToleranceAreaSize(void) const              {return d_dblclick_size;}
    00389
    00390
    00403         void    setSingleClickTimeout(double timeout);
    00404
    00405
    00420         void setMultiClickTimeout(double timeout);
    00421
    00422
    00436         void setMultiClickToleranceAreaSize(const Size& sz);
    00437
    00438
    00447         const Image*    getDefaultMouseCursor(void) const       {return d_defaultMouseCursor;}
    00448
    00449
    00461         void    setDefaultMouseCursor(const Image* image);
    00462
    00463
    00474         void    setDefaultMouseCursor(MouseCursorImage image)           {setDefaultMouseCursor((const Image*)image);}
    00475
    00476
    00492         void    setDefaultMouseCursor(const String& imageset, const String& image_name);
    00493
    00494
    00502         Window* getWindowContainingMouse(void) const    {return d_wndWithMouse;}
    00503
    00504
    00512         ScriptModule*   getScriptingModule(void) const;
    00513
    00521         ResourceProvider* getResourceProvider(void) const;
    00522
    00533         void    executeScriptFile(const String& filename, const String& resourceGroup = "") const;
    00534
    00535
    00547         int             executeScriptGlobal(const String& function_name) const;
    00548
    00549
    00560     void executeScriptString(const String& str) const;
    00561
    00562
    00570         float   getMouseMoveScaling(void) const;
    00571
    00572
    00583         void    setMouseMoveScaling(float scaling);
    00584
    00585
    00594         void    notifyWindowDestroyed(const Window* window);
    00595
    00596
    00604     uint    getSystemKeys(void) const   { return d_sysKeys; }
    00605
    00610     XMLParser* getXMLParser(void) const     { return d_xmlParser; }
    00611
    00612
    00626     void setTooltip(Tooltip* tooltip);
    00627
    00643     void setTooltip(const String& tooltipType);
    00644
    00653     Tooltip* getDefaultTooltip(void) const  { return d_defaultTooltip; }
    00654
    00655
    00664         void setModalTarget(Window* target)             {d_modalTarget = target;}
    00665
    00673         Window* getModalTarget(void) const              {return d_modalTarget;}
    00674
    00675
    00676         /*************************************************************************
    00677                 Input injection interface
    00678         *************************************************************************/
    00693         bool    injectMouseMove(float delta_x, float delta_y);
    00694
    00695
    00704         bool    injectMouseLeaves(void);
    00705
    00706
    00718         bool    injectMouseButtonDown(MouseButton button);
    00719
    00720
    00732         bool    injectMouseButtonUp(MouseButton button);
    00733
    00734
    00746         bool    injectKeyDown(uint key_code);
    00747
    00748
    00760         bool    injectKeyUp(uint key_code);
    00761
    00762
    00774         bool    injectChar(utf32 code_point);
    00775
    00776
    00788         bool    injectMouseWheelChange(float delta);
    00789
    00790
    00805         bool    injectMousePosition(float x_pos, float y_pos);
    00806
    00807
    00818         bool    injectTimePulse(float timeElapsed);
    00819
    00820
    00821 private:
    00822     // unimplemented constructors / assignment
    00823     System(const System& obj);
    00824     System& operator=(const System& obj);
    00825
    00826         /*************************************************************************
    00827                 Implementation Constants
    00828         *************************************************************************/
    00829         static const char       CEGUIConfigSchemaName[];
    00830
    00831
    00832         /*************************************************************************
    00833                 Implementation Functions
    00834         *************************************************************************/
    00845         Window* getTargetWindow(const Point& pt) const;
    00846
    00847
    00855         Window* getKeyboardTargetWindow(void) const;
    00856
    00857
    00868         Window* getNextTargetWindow(Window* w) const;
    00869
    00870
    00881         SystemKey       mouseButtonToSyskey(MouseButton btn) const;
    00882
    00883
    00899         SystemKey       keyCodeToSyskey(Key::Scan key, bool direction);
    00900
    00901
    00906        void     constructor_impl(Renderer* renderer, ResourceProvider* resourceProvider, XMLParser* xmlParser, ScriptModule* scriptModule, const String& configFile, const String& logFile);
    00907
    00908
    00913         void    addSystemEvents(void);
    00914
    00915
    00920         bool    handleDisplaySizeChange(const EventArgs& e);
    00921
    00922
    00923         /*************************************************************************
    00924                 Handlers for System events
    00925         *************************************************************************/
    00932         void    onGUISheetChanged(WindowEventArgs& e);
    00933
    00934
    00939         void    onSingleClickTimeoutChanged(EventArgs& e);
    00940
    00941
    00946         void    onMultiClickTimeoutChanged(EventArgs& e);
    00947
    00948
    00953         void    onMultiClickAreaSizeChanged(EventArgs& e);
    00954
    00955
    00960         void    onDefaultFontChanged(EventArgs& e);
    00961
    00962
    00967         void    onDefaultMouseCursorChanged(EventArgs& e);
    00968
    00969
    00974         void    onMouseMoveScalingChanged(EventArgs& e);
    00975
    00976
    00977         /*************************************************************************
    00978                 Implementation Data
    00979         *************************************************************************/
    00980         Renderer*       d_renderer;
    00981     ResourceProvider* d_resourceProvider;
    00982         Font*           d_defaultFont;
    00983         bool            d_gui_redraw;
    00984
    00985         Window*         d_wndWithMouse;
    00986         Window*         d_activeSheet;
    00987         Window*         d_modalTarget;
    00988
    00989         String d_strVersion;
    00990
    00991         uint            d_sysKeys;
    00992         bool            d_lshift;
    00993         bool            d_rshift;
    00994         bool            d_lctrl;
    00995         bool            d_rctrl;
    00996         bool            d_lalt;
    00997         bool            d_ralt;
    00998
    00999         double          d_click_timeout;
    01000         double          d_dblclick_timeout;
    01001         Size            d_dblclick_size;
    01002
    01003         MouseClickTrackerImpl* const    d_clickTrackerPimpl;
    01004
    01005         // mouse cursor related
    01006         const Image*    d_defaultMouseCursor;
    01007
    01008         // scripting
    01009         ScriptModule*   d_scriptModule;
    01010         String                  d_termScriptName;
    01011
    01012         float   d_mouseScalingFactor;
    01013
    01014     XMLParser*  d_xmlParser;
    01015     bool        d_ourXmlParser;
    01016
    01017     Tooltip* d_defaultTooltip;
    01018     bool     d_weOwnTooltip;
    01019 };
    01020
    01021 } // End of  CEGUI namespace section
    01022
    01023
    01024 #if defined(_MSC_VER)
    01025 #       pragma warning(pop)
    01026 #endif
    01027
    01028 #endif  // end of guard _CEGUISystem_h_