Crazy Eddies GUI System: CEGUISystem.h Source File

Crazy Eddies GUI System 0.7.6

- 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 - 2011 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;
    00671
    00680         void setModalTarget(Window* target)             {d_modalTarget = target;}
    00681
    00689         Window* getModalTarget(void) const              {return d_modalTarget;}
    00690
    00735     static void setDefaultXMLParserName(const String& parserName);
    00736
    00746     static const String getDefaultXMLParserName();
    00747
    00762     bool updateWindowContainingMouse();
    00763
    00768     ImageCodec& getImageCodec() const;
    00769
    00774     void setImageCodec(const String& codecName);
    00775
    00786     void setImageCodec(ImageCodec& codec);
    00787
    00792     static void setDefaultImageCodecName(const String& codecName);
    00793
    00798     static const String& getDefaultImageCodecName();
    00799
    00817     void notifyDisplaySizeChanged(const Size& new_size);
    00818
    00832     RenderedStringParser* getDefaultCustomRenderedStringParser() const;
    00833
    00848     void setDefaultCustomRenderedStringParser(RenderedStringParser* parser);
    00849
    00860     void invalidateAllCachedRendering();
    00861
    00862         /*************************************************************************
    00863                 Input injection interface
    00864         *************************************************************************/
    00879         bool    injectMouseMove(float delta_x, float delta_y);
    00880
    00881
    00890         bool    injectMouseLeaves(void);
    00891
    00892
    00904         bool    injectMouseButtonDown(MouseButton button);
    00905
    00906
    00918         bool    injectMouseButtonUp(MouseButton button);
    00919
    00920
    00932         bool    injectKeyDown(uint key_code);
    00933
    00934
    00946         bool    injectKeyUp(uint key_code);
    00947
    00948
    00960         bool    injectChar(utf32 code_point);
    00961
    00962
    00974         bool    injectMouseWheelChange(float delta);
    00975
    00976
    00991         bool    injectMousePosition(float x_pos, float y_pos);
    00992
    00993
    01004         bool    injectTimePulse(float timeElapsed);
    01005
    01030     bool injectMouseButtonClick(const MouseButton button);
    01031
    01056     bool injectMouseButtonDoubleClick(const MouseButton button);
    01057
    01082     bool injectMouseButtonTripleClick(const MouseButton button);
    01083
    01084 private:
    01085     // unimplemented constructors / assignment
    01086     System(const System& obj);
    01087     System& operator=(const System& obj);
    01088
    01089         /*************************************************************************
    01090                 Implementation Functions
    01091         *************************************************************************/
    01121     System(Renderer& renderer, ResourceProvider* resourceProvider,
    01122            XMLParser* xmlParser, ImageCodec* imageCodec,
    01123            ScriptModule* scriptModule, const String& configFile,
    01124            const String& logFile);
    01125
    01130     ~System(void);
    01131
    01145         Window* getTargetWindow(const Point& pt, const bool allow_disabled) const;
    01146
    01147
    01155         Window* getKeyboardTargetWindow(void) const;
    01156
    01157
    01168         Window* getNextTargetWindow(Window* w) const;
    01169
    01170
    01181         SystemKey       mouseButtonToSyskey(MouseButton btn) const;
    01182
    01183
    01199         SystemKey       keyCodeToSyskey(Key::Scan key, bool direction);
    01200
    01202     void outputLogHeader();
    01203
    01205     void addStandardWindowFactories();
    01206
    01208     void createSingletons();
    01209
    01211     void destroySingletons();
    01212
    01214     void setupXMLParser();
    01215
    01217     void cleanupXMLParser();
    01218
    01220     bool mouseMoveInjection_impl(MouseEventArgs& ma);
    01221
    01223     void setupImageCodec(const String& codecName);
    01224
    01226     void cleanupImageCodec();
    01227
    01229     void initialiseVersionString();
    01230
    01232     void invalidateAllWindows();
    01233
    01235     Window* getCommonAncestor(Window* w1, Window* w2);
    01236
    01238     void notifyMouseTransition(Window* top, Window* bottom,
    01239                                void (Window::*func)(MouseEventArgs&),
    01240                                MouseEventArgs& args);
    01242     void createSystemOwnedDefaultTooltipWindow() const;
    01244     void destroySystemOwnedDefaultTooltipWindow();
    01245
    01246         /*************************************************************************
    01247                 Handlers for System events
    01248         *************************************************************************/
    01255         void    onGUISheetChanged(WindowEventArgs& e);
    01256
    01257
    01262         void    onSingleClickTimeoutChanged(EventArgs& e);
    01263
    01264
    01269         void    onMultiClickTimeoutChanged(EventArgs& e);
    01270
    01271
    01276         void    onMultiClickAreaSizeChanged(EventArgs& e);
    01277
    01278
    01283         void    onDefaultFontChanged(EventArgs& e);
    01284
    01285
    01290         void    onDefaultMouseCursorChanged(EventArgs& e);
    01291
    01292
    01297         void    onMouseMoveScalingChanged(EventArgs& e);
    01298
    01299
    01300         /*************************************************************************
    01301                 Implementation Data
    01302         *************************************************************************/
    01303         Renderer*       d_renderer;
    01304     ResourceProvider* d_resourceProvider;
    01305         bool d_ourResourceProvider;
    01306     Font*               d_defaultFont;
    01307         bool            d_gui_redraw;
    01308
    01309         Window*         d_wndWithMouse;
    01310         Window*         d_activeSheet;
    01311         Window*         d_modalTarget;
    01312
    01313         String d_strVersion;
    01314
    01315         uint            d_sysKeys;
    01316         bool            d_lshift;
    01317         bool            d_rshift;
    01318         bool            d_lctrl;
    01319         bool            d_rctrl;
    01320         bool            d_lalt;
    01321         bool            d_ralt;
    01322
    01323         double          d_click_timeout;
    01324         double          d_dblclick_timeout;
    01325         Size            d_dblclick_size;
    01326
    01327         MouseClickTrackerImpl* const    d_clickTrackerPimpl;
    01328
    01329         // mouse cursor related
    01330         const Image*    d_defaultMouseCursor;
    01331
    01332         // scripting
    01333         ScriptModule*   d_scriptModule;
    01334         String                  d_termScriptName;
    01335
    01336         float   d_mouseScalingFactor;
    01337
    01338     XMLParser*  d_xmlParser;
    01339     bool        d_ourXmlParser;
    01340     DynamicModule* d_parserModule;
    01341
    01343     mutable Tooltip* d_defaultTooltip;
    01345     mutable bool d_weOwnTooltip;
    01347     String d_defaultTooltipType;
    01348
    01349     static String   d_defaultXMLParserName;
    01350
    01352     ImageCodec* d_imageCodec;
    01354     bool d_ourImageCodec;
    01358     DynamicModule* d_imageCodecModule;
    01360     static String d_defaultImageCodecName;
    01362     bool d_ourLogger;
    01364     RenderedStringParser* d_customRenderedStringParser;
    01366     bool d_generateMouseClickEvents;
    01367 };
    01368
    01369 } // End of  CEGUI namespace section
    01370
    01371
    01372 #if defined(_MSC_VER)
    01373 #       pragma warning(pop)
    01374 #endif
    01375
    01376 #endif  // end of guard _CEGUISystem_h_