• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List

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 - 2009 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
00082         static const String EventGUISheetChanged;
00086         static const String EventSingleClickTimeoutChanged;
00090         static const String EventMultiClickTimeoutChanged;
00094         static const String EventMultiClickAreaSizeChanged;
00098         static const String EventDefaultFontChanged;
00102         static const String EventDefaultMouseCursorChanged;
00106         static const String EventMouseMoveScalingChanged;
00112     static const String EventDisplaySizeChanged;
00116     static const String EventRenderedStringParserChanged;
00117 
00118         /*************************************************************************
00119                 Construction and Destruction
00120         *************************************************************************/
00150     static System& create(Renderer& renderer,
00151                           ResourceProvider* resourceProvider = 0,
00152                           XMLParser* xmlParser = 0,
00153                           ImageCodec* imageCodec = 0,
00154                           ScriptModule* scriptModule = 0,
00155                           const String& configFile = "",
00156                           const String& logFile = "CEGUI.log");
00157 
00159     static void destroy();
00160 
00168         Renderer*       getRenderer(void) const                 {return d_renderer;}
00169 
00170 
00178         static  System& getSingleton(void);
00179 
00180 
00188         static  System* getSingletonPtr(void);
00189 
00190 
00201         void    setDefaultFont(const String& name);
00202 
00203 
00214         void    setDefaultFont(Font* font);
00215 
00216 
00224         Font*   getDefaultFont(void) const                              {return d_defaultFont;}
00225 
00226 
00234         void    signalRedraw()          {d_gui_redraw = true;}
00235 
00236 
00244         bool    isRedrawRequested() const               {return d_gui_redraw;}
00245 
00246 
00256         void    renderGUI(void);
00257 
00258 
00269         Window* setGUISheet(Window* sheet);
00270 
00271 
00279         Window* getGUISheet(void) const         {return d_activeSheet;}
00280 
00281 
00291         double  getSingleClickTimeout(void) const               {return d_click_timeout;}
00292 
00293 
00305         double  getMultiClickTimeout(void) const                {return d_dblclick_timeout;}
00306 
00307 
00318         const Size&     getMultiClickToleranceAreaSize(void) const              {return d_dblclick_size;}
00319 
00320 
00340         void    setSingleClickTimeout(double timeout);
00341 
00342 
00363         void setMultiClickTimeout(double timeout);
00364 
00365 
00379         void setMultiClickToleranceAreaSize(const Size& sz);
00380 
00394     bool isMouseClickEventGenerationEnabled() const;
00395     
00409     void setMouseClickEventGenerationEnabled(const bool enable);
00410 
00419         const Image*    getDefaultMouseCursor(void) const       {return d_defaultMouseCursor;}
00420 
00421 
00433         void    setDefaultMouseCursor(const Image* image);
00434 
00435 
00446         void    setDefaultMouseCursor(MouseCursorImage image)           {setDefaultMouseCursor((const Image*)image);}
00447 
00448 
00464         void    setDefaultMouseCursor(const String& imageset, const String& image_name);
00465 
00466 
00474         Window* getWindowContainingMouse(void) const    {return d_wndWithMouse;}
00475 
00476 
00484         ScriptModule*   getScriptingModule(void) const;
00485 
00496     void setScriptingModule(ScriptModule* scriptModule);
00497 
00505         ResourceProvider* getResourceProvider(void) const;
00506 
00517         void    executeScriptFile(const String& filename, const String& resourceGroup = "") const;
00518 
00519 
00531         int             executeScriptGlobal(const String& function_name) const;
00532 
00533 
00544     void executeScriptString(const String& str) const;
00545 
00546 
00554         float   getMouseMoveScaling(void) const;
00555 
00556 
00567         void    setMouseMoveScaling(float scaling);
00568 
00569 
00578         void    notifyWindowDestroyed(const Window* window);
00579 
00580 
00588     uint    getSystemKeys(void) const   { return d_sysKeys; }
00589 
00602     void setXMLParser(const String& parserName);
00603 
00621     void setXMLParser(XMLParser* parser);
00622 
00627     XMLParser* getXMLParser(void) const     { return d_xmlParser; }
00628 
00629 
00643     void setDefaultTooltip(Tooltip* tooltip);
00644 
00660     void setDefaultTooltip(const String& tooltipType);
00661 
00670     Tooltip* getDefaultTooltip(void) const  { return d_defaultTooltip; }
00671 
00672 
00681         void setModalTarget(Window* target)             {d_modalTarget = target;}
00682 
00690         Window* getModalTarget(void) const              {return d_modalTarget;}
00691 
00736     static void setDefaultXMLParserName(const String& parserName);
00737 
00747     static const String getDefaultXMLParserName();
00748     
00763     bool updateWindowContainingMouse();
00764 
00769     ImageCodec& getImageCodec() const;
00770 
00775     void setImageCodec(const String& codecName);
00776 
00787     void setImageCodec(ImageCodec& codec);
00788 
00793     static void setDefaultImageCodecName(const String& codecName);
00794 
00799     static const String& getDefaultImageCodecName();
00800 
00818     void notifyDisplaySizeChanged(const Size& new_size);
00819 
00833     RenderedStringParser* getDefaultCustomRenderedStringParser() const;
00834 
00849     void setDefaultCustomRenderedStringParser(RenderedStringParser* parser);
00850 
00861     void invalidateAllCachedRendering();
00862 
00863         /*************************************************************************
00864                 Input injection interface
00865         *************************************************************************/
00880         bool    injectMouseMove(float delta_x, float delta_y);
00881 
00882 
00891         bool    injectMouseLeaves(void);
00892 
00893 
00905         bool    injectMouseButtonDown(MouseButton button);
00906 
00907 
00919         bool    injectMouseButtonUp(MouseButton button);
00920 
00921 
00933         bool    injectKeyDown(uint key_code);
00934 
00935 
00947         bool    injectKeyUp(uint key_code);
00948 
00949 
00961         bool    injectChar(utf32 code_point);
00962 
00963 
00975         bool    injectMouseWheelChange(float delta);
00976 
00977 
00992         bool    injectMousePosition(float x_pos, float y_pos);
00993 
00994 
01005         bool    injectTimePulse(float timeElapsed);
01006 
01031     bool injectMouseButtonClick(const MouseButton button);
01032 
01057     bool injectMouseButtonDoubleClick(const MouseButton button);
01058 
01083     bool injectMouseButtonTripleClick(const MouseButton button);
01084 
01085 private:
01086     // unimplemented constructors / assignment
01087     System(const System& obj);
01088     System& operator=(const System& obj);
01089 
01090         /*************************************************************************
01091                 Implementation Functions
01092         *************************************************************************/
01122     System(Renderer& renderer, ResourceProvider* resourceProvider,
01123            XMLParser* xmlParser, ImageCodec* imageCodec,
01124            ScriptModule* scriptModule, const String& configFile,
01125            const String& logFile);
01126 
01131     ~System(void);
01132 
01146         Window* getTargetWindow(const Point& pt, const bool allow_disabled) const;
01147 
01148 
01156         Window* getKeyboardTargetWindow(void) const;
01157 
01158 
01169         Window* getNextTargetWindow(Window* w) const;
01170 
01171 
01182         SystemKey       mouseButtonToSyskey(MouseButton btn) const;
01183 
01184 
01200         SystemKey       keyCodeToSyskey(Key::Scan key, bool direction);
01201 
01203     void outputLogHeader();
01204 
01206     void addStandardWindowFactories();
01207 
01209     void createSingletons();
01210 
01212     void destroySingletons();
01213 
01215     void setupXMLParser();
01216 
01218     void cleanupXMLParser();
01219 
01221     bool mouseMoveInjection_impl(MouseEventArgs& ma);
01222 
01224     void setupImageCodec(const String& codecName);
01225 
01227     void cleanupImageCodec();
01228 
01230     void initialiseVersionString();
01231 
01233     void invalidateAllWindows();
01234 
01236     Window* getCommonAncestor(Window* w1, Window* w2);
01237 
01239     void notifyMouseTransition(Window* top, Window* bottom,
01240                                void (Window::*func)(MouseEventArgs&),
01241                                MouseEventArgs& args);
01242 
01243         /*************************************************************************
01244                 Handlers for System events
01245         *************************************************************************/
01252         void    onGUISheetChanged(WindowEventArgs& e);
01253 
01254 
01259         void    onSingleClickTimeoutChanged(EventArgs& e);
01260 
01261 
01266         void    onMultiClickTimeoutChanged(EventArgs& e);
01267 
01268 
01273         void    onMultiClickAreaSizeChanged(EventArgs& e);
01274 
01275 
01280         void    onDefaultFontChanged(EventArgs& e);
01281 
01282 
01287         void    onDefaultMouseCursorChanged(EventArgs& e);
01288 
01289 
01294         void    onMouseMoveScalingChanged(EventArgs& e);
01295 
01296 
01297         /*************************************************************************
01298                 Implementation Data
01299         *************************************************************************/
01300         Renderer*       d_renderer;                     
01301     ResourceProvider* d_resourceProvider;      
01302         bool d_ourResourceProvider;
01303     Font*               d_defaultFont;          
01304         bool            d_gui_redraw;           
01305 
01306         Window*         d_wndWithMouse;         
01307         Window*         d_activeSheet;          
01308         Window*         d_modalTarget;          
01309 
01310         String d_strVersion;    
01311 
01312         uint            d_sysKeys;                      
01313         bool            d_lshift;                       
01314         bool            d_rshift;                       
01315         bool            d_lctrl;                        
01316         bool            d_rctrl;                        
01317         bool            d_lalt;                         
01318         bool            d_ralt;                         
01319 
01320         double          d_click_timeout;        
01321         double          d_dblclick_timeout;     
01322         Size            d_dblclick_size;        
01323 
01324         MouseClickTrackerImpl* const    d_clickTrackerPimpl;            
01325 
01326         // mouse cursor related
01327         const Image*    d_defaultMouseCursor;           
01328 
01329         // scripting
01330         ScriptModule*   d_scriptModule;                 
01331         String                  d_termScriptName;               
01332 
01333         float   d_mouseScalingFactor;                   
01334 
01335     XMLParser*  d_xmlParser;        
01336     bool        d_ourXmlParser;     
01337     DynamicModule* d_parserModule;  
01338 
01339     Tooltip* d_defaultTooltip;      
01340     bool     d_weOwnTooltip;        
01341 
01342     static String   d_defaultXMLParserName; 
01343 
01345     ImageCodec* d_imageCodec;
01347     bool d_ourImageCodec;
01351     DynamicModule* d_imageCodecModule;
01353     static String d_defaultImageCodecName;
01355     bool d_ourLogger;
01357     RenderedStringParser* d_customRenderedStringParser;
01359     bool d_generateMouseClickEvents;
01360 };
01361 
01362 } // End of  CEGUI namespace section
01363 
01364 
01365 #if defined(_MSC_VER)
01366 #       pragma warning(pop)
01367 #endif
01368 
01369 #endif  // end of guard _CEGUISystem_h_

Generated on Sat Sep 25 2010 02:10:34 for Crazy Eddies GUI System by  doxygen 1.7.1