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  *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
00010  *
00011  *   Permission is hereby granted, free of charge, to any person obtaining
00012  *   a copy of this software and associated documentation files (the
00013  *   "Software"), to deal in the Software without restriction, including
00014  *   without limitation the rights to use, copy, modify, merge, publish,
00015  *   distribute, sublicense, and/or sell copies of the Software, and to
00016  *   permit persons to whom the Software is furnished to do so, subject to
00017  *   the following conditions:
00018  *
00019  *   The above copyright notice and this permission notice shall be
00020  *   included in all copies or substantial portions of the Software.
00021  *
00022  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00023  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00024  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00025  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00026  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00027  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00028  *   OTHER DEALINGS IN THE SOFTWARE.
00029  ***************************************************************************/
00030 #ifndef _CEGUISystem_h_
00031 #define _CEGUISystem_h_
00032 
00033 #include "CEGUIBase.h"
00034 #include "CEGUIString.h"
00035 #include "CEGUISingleton.h"
00036 #include "CEGUIRenderer.h"
00037 #include "CEGUIMouseCursor.h"
00038 #include "CEGUIInputEvent.h"
00039 #include "CEGUIResourceProvider.h"
00040 
00041 
00042 #if defined(_MSC_VER)
00043 #       pragma warning(push)
00044 #       pragma warning(disable : 4275)
00045 #       pragma warning(disable : 4251)
00046 #endif
00047 
00048 
00049 // Start of CEGUI namespace section
00050 namespace CEGUI
00051 {
00053 struct MouseClickTrackerImpl;
00054 
00055 
00064 class CEGUIEXPORT System : public Singleton<System>, public EventSet
00065 {
00066 public:
00067         static const String EventNamespace;                             
00068 
00069         /*************************************************************************
00070                 Constants
00071         *************************************************************************/
00072         static const double             DefaultSingleClickTimeout;              
00073         static const double             DefaultMultiClickTimeout;               
00074         static const Size               DefaultMultiClickAreaSize;              
00075 
00076         // event names
00077         static const String EventGUISheetChanged;                               
00078         static const String EventSingleClickTimeoutChanged;     
00079         static const String EventMultiClickTimeoutChanged;      
00080         static const String EventMultiClickAreaSizeChanged;     
00081         static const String EventDefaultFontChanged;                    
00082         static const String EventDefaultMouseCursorChanged;     
00083         static const String EventMouseMoveScalingChanged;               
00084 
00085 
00086         /*************************************************************************
00087                 Construction and Destruction
00088         *************************************************************************/
00114     System(Renderer* renderer, ResourceProvider* resourceProvider = 0, XMLParser* xmlParser = 0, ScriptModule* scriptModule = 0, const String& configFile = "", const String& logFile = "CEGUI.log");
00115 
00120         ~System(void);
00121 
00122 
00130         Renderer*       getRenderer(void) const                 {return d_renderer;}
00131 
00132 
00140         static  System& getSingleton(void);
00141 
00142 
00150         static  System* getSingletonPtr(void);
00151 
00152 
00163         void    setDefaultFont(const String& name);
00164 
00165 
00176         void    setDefaultFont(Font* font);
00177 
00178 
00186         Font*   getDefaultFont(void) const                              {return d_defaultFont;}
00187 
00188 
00196         void    signalRedraw()          {d_gui_redraw = true;}
00197 
00198 
00206         bool    isRedrawRequested() const               {return d_gui_redraw;}
00207 
00208 
00218         void    renderGUI(void);
00219 
00220 
00231         Window* setGUISheet(Window* sheet);
00232 
00233 
00241         Window* getGUISheet(void) const         {return d_activeSheet;}
00242 
00243 
00253         double  getSingleClickTimeout(void) const               {return d_click_timeout;}
00254 
00255 
00267         double  getMultiClickTimeout(void) const                {return d_dblclick_timeout;}
00268 
00269 
00280         const Size&     getMultiClickToleranceAreaSize(void) const              {return d_dblclick_size;}
00281 
00282 
00302         void    setSingleClickTimeout(double timeout);
00303 
00304 
00325         void setMultiClickTimeout(double timeout);
00326 
00327 
00341         void setMultiClickToleranceAreaSize(const Size& sz);
00342 
00343 
00352         const Image*    getDefaultMouseCursor(void) const       {return d_defaultMouseCursor;}
00353 
00354 
00366         void    setDefaultMouseCursor(const Image* image);
00367 
00368 
00379         void    setDefaultMouseCursor(MouseCursorImage image)           {setDefaultMouseCursor((const Image*)image);}
00380 
00381 
00397         void    setDefaultMouseCursor(const String& imageset, const String& image_name);
00398 
00399 
00407         Window* getWindowContainingMouse(void) const    {return d_wndWithMouse;}
00408 
00409 
00417         ScriptModule*   getScriptingModule(void) const;
00418 
00429     void setScriptingModule(ScriptModule* scriptModule);
00430 
00438         ResourceProvider* getResourceProvider(void) const;
00439 
00450         void    executeScriptFile(const String& filename, const String& resourceGroup = "") const;
00451 
00452 
00464         int             executeScriptGlobal(const String& function_name) const;
00465 
00466 
00477     void executeScriptString(const String& str) const;
00478 
00479 
00487         float   getMouseMoveScaling(void) const;
00488 
00489 
00500         void    setMouseMoveScaling(float scaling);
00501 
00502 
00511         void    notifyWindowDestroyed(const Window* window);
00512 
00513 
00521     uint    getSystemKeys(void) const   { return d_sysKeys; }
00522 
00535     void setXMLParser(const String& parserName);
00536 
00554     void setXMLParser(XMLParser* parser);
00555 
00560     XMLParser* getXMLParser(void) const     { return d_xmlParser; }
00561 
00562 
00576     void setDefaultTooltip(Tooltip* tooltip);
00577 
00593     void setDefaultTooltip(const String& tooltipType);
00594 
00603     Tooltip* getDefaultTooltip(void) const  { return d_defaultTooltip; }
00604 
00605 
00614         void setModalTarget(Window* target)             {d_modalTarget = target;}
00615 
00623         Window* getModalTarget(void) const              {return d_modalTarget;}
00624 
00669     static void setDefaultXMLParserName(const String& parserName);
00670 
00680     static const String getDefaultXMLParserName();
00681 
00682         /*************************************************************************
00683                 Input injection interface
00684         *************************************************************************/
00699         bool    injectMouseMove(float delta_x, float delta_y);
00700 
00701 
00710         bool    injectMouseLeaves(void);
00711 
00712 
00724         bool    injectMouseButtonDown(MouseButton button);
00725 
00726 
00738         bool    injectMouseButtonUp(MouseButton button);
00739 
00740 
00752         bool    injectKeyDown(uint key_code);
00753 
00754 
00766         bool    injectKeyUp(uint key_code);
00767 
00768 
00780         bool    injectChar(utf32 code_point);
00781 
00782 
00794         bool    injectMouseWheelChange(float delta);
00795 
00796 
00811         bool    injectMousePosition(float x_pos, float y_pos);
00812 
00813 
00824         bool    injectTimePulse(float timeElapsed);
00825 
00826 
00827 private:
00828     // unimplemented constructors / assignment
00829     System(const System& obj);
00830     System& operator=(const System& obj);
00831 
00832         /*************************************************************************
00833                 Implementation Constants
00834         *************************************************************************/
00835         static const char       CEGUIConfigSchemaName[];                        
00836 
00837 
00838         /*************************************************************************
00839                 Implementation Functions
00840         *************************************************************************/
00851         Window* getTargetWindow(const Point& pt) const;
00852 
00853 
00861         Window* getKeyboardTargetWindow(void) const;
00862 
00863 
00874         Window* getNextTargetWindow(Window* w) const;
00875 
00876 
00887         SystemKey       mouseButtonToSyskey(MouseButton btn) const;
00888 
00889 
00905         SystemKey       keyCodeToSyskey(Key::Scan key, bool direction);
00906 
00907 
00912         bool    handleDisplaySizeChange(const EventArgs& e);
00913 
00915     void outputLogHeader();
00916 
00918     void addStandardWindowFactories();
00919 
00921     void createSingletons();
00922 
00924     void destroySingletons();
00925 
00927     void setupXMLParser();
00928 
00930     void cleanupXMLParser();
00931 
00933     bool mouseMoveInjection_impl(MouseEventArgs& ma);
00934 
00935         /*************************************************************************
00936                 Handlers for System events
00937         *************************************************************************/
00944         void    onGUISheetChanged(WindowEventArgs& e);
00945 
00946 
00951         void    onSingleClickTimeoutChanged(EventArgs& e);
00952 
00953 
00958         void    onMultiClickTimeoutChanged(EventArgs& e);
00959 
00960 
00965         void    onMultiClickAreaSizeChanged(EventArgs& e);
00966 
00967 
00972         void    onDefaultFontChanged(EventArgs& e);
00973 
00974 
00979         void    onDefaultMouseCursorChanged(EventArgs& e);
00980 
00981 
00986         void    onMouseMoveScalingChanged(EventArgs& e);
00987 
00988 
00989         /*************************************************************************
00990                 Implementation Data
00991         *************************************************************************/
00992         Renderer*       d_renderer;                     
00993     ResourceProvider* d_resourceProvider;      
00994         Font*           d_defaultFont;          
00995         bool            d_gui_redraw;           
00996 
00997         Window*         d_wndWithMouse;         
00998         Window*         d_activeSheet;          
00999         Window*         d_modalTarget;          
01000 
01001         String d_strVersion;    
01002 
01003         uint            d_sysKeys;                      
01004         bool            d_lshift;                       
01005         bool            d_rshift;                       
01006         bool            d_lctrl;                        
01007         bool            d_rctrl;                        
01008         bool            d_lalt;                         
01009         bool            d_ralt;                         
01010 
01011         double          d_click_timeout;        
01012         double          d_dblclick_timeout;     
01013         Size            d_dblclick_size;        
01014 
01015         MouseClickTrackerImpl* const    d_clickTrackerPimpl;            
01016 
01017         // mouse cursor related
01018         const Image*    d_defaultMouseCursor;           
01019 
01020         // scripting
01021         ScriptModule*   d_scriptModule;                 
01022         String                  d_termScriptName;               
01023 
01024         float   d_mouseScalingFactor;                   
01025 
01026     XMLParser*  d_xmlParser;        
01027     bool        d_ourXmlParser;     
01028     DynamicModule* d_parserModule;  
01029 
01030     Tooltip* d_defaultTooltip;      
01031     bool     d_weOwnTooltip;        
01032 
01034     Event::Connection d_rendererCon;
01035 
01036     static String   d_defaultXMLParserName; 
01037 };
01038 
01039 } // End of  CEGUI namespace section
01040 
01041 
01042 #if defined(_MSC_VER)
01043 #       pragma warning(pop)
01044 #endif
01045 
01046 #endif  // end of guard _CEGUISystem_h_

Generated on Sat Jun 28 14:35:44 2008 for Crazy Eddies GUI System by  doxygen 1.5.4