Crazy Eddies GUI System: CEGUIStatic.h Source File

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

# CEGUIStatic.h

    00001 /************************************************************************
    00002         filename:       CEGUIStatic.h
    00003         created:        13/4/2004
    00004         author:         Paul D Turner
    00005
    00006         purpose:        Interface to base class for Static widget
    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 _CEGUIStatic_h_
    00027 #define _CEGUIStatic_h_
    00028
    00029 #include "CEGUIBase.h"
    00030 #include "CEGUIWindow.h"
    00031 #include "CEGUIRenderableFrame.h"
    00032 #include "elements/CEGUIStaticProperties.h"
    00033
    00034
    00035 #if defined(_MSC_VER)
    00036 #       pragma warning(push)
    00037 #       pragma warning(disable : 4251)
    00038 #endif
    00039
    00040
    00041 // Start of CEGUI namespace section
    00042 namespace CEGUI
    00043 {
    00048 class CEGUIEXPORT Static : public Window
    00049 {
    00050 public:
    00051         static const String EventNamespace;
    00052
    00053
    00054         /*************************************************************************
    00055                 Accessors
    00056         *************************************************************************/
    00064         bool    isFrameEnabled(void) const              {return d_frameEnabled;}
    00065
    00066
    00074         bool    isBackgroundEnabled(void) const         {return d_backgroundEnabled;}
    00075
    00076
    00084         ColourRect      getFrameColours(void) const             {return d_frameCols;}
    00085
    00086
    00094         ColourRect      getBackgroundColours(void) const                {return d_backgroundCols;}
    00095
    00096
    00097         // overridden so derived classes are auto-clipped to within the inner area of the frame when it's active.
    00098         virtual Rect    getUnclippedInnerRect(void) const;
    00099
    00100
    00112         const Image*    getImageForFrameLocation(FrameLocation location) const;
    00113
    00114
    00123         const Image* getBackgroundImage(void) const;
    00124
    00125
    00126         /*************************************************************************
    00127                 Manipulators
    00128         *************************************************************************/
    00138         void    setFrameEnabled(bool setting);
    00139
    00140
    00172         void    setFrameImages(const Image* topleft, const Image* topright, const Image* bottomleft, const Image* bottomright, const Image* left, const Image* top, const Image* right, const Image* bottom);
    00173
    00174
    00185         void    setFrameColours(const ColourRect& colours);
    00186
    00187
    00207         void    setFrameColours(const colour& top_left_colour, const colour& top_right_colour, const colour& bottom_left_colour, const colour& bottom_right_colour);
    00208
    00209
    00220         void    setFrameColours(const colour& col)              {setFrameColours(col, col, col, col);}
    00221
    00222
    00230         void    setBackgroundEnabled(bool setting);
    00231
    00232
    00243         void    setBackgroundImage(const Image* image);
    00244
    00245
    00261         void    setBackgroundImage(const String& imageset, const String& image);
    00262
    00263
    00274         void    setBackgroundColours(const ColourRect& colours);
    00275
    00276
    00296         void    setBackgroundColours(const colour& top_left_colour, const colour& top_right_colour, const colour& bottom_left_colour, const colour& bottom_right_colour);
    00297
    00298
    00309         void    setBackgroundColours(const colour& col)         {setBackgroundColours(col, col, col, col);}
    00310
    00311
    00326         void    setImageForFrameLocation(FrameLocation location, const Image* image);
    00327
    00328
    00329         /*************************************************************************
    00330                 Construction and Destruction
    00331         *************************************************************************/
    00336         Static(const String& type, const String& name);
    00337
    00338
    00343         virtual ~Static(void);
    00344
    00345
    00346 protected:
    00347         /*************************************************************************
    00348                 Overridden from base class
    00349         *************************************************************************/
    00350         virtual void populateRenderCache();
    00351
    00352
    00353         /*************************************************************************
    00354                 Event handling
    00355         *************************************************************************/
    00356         virtual void    onSized(WindowEventArgs& e);
    00357         virtual void    onAlphaChanged(WindowEventArgs& e);
    00358
    00359
    00360         /*************************************************************************
    00361                 Implementation methods
    00362         *************************************************************************/
    00368         void    updateRenderableFrameColours(void);
    00369
    00370
    00375         colour  calculateModulatedAlphaColour(const colour& col, float alpha) const;
    00376
    00377
    00385         virtual void    onStaticFrameChanged(WindowEventArgs& e)        {}
    00386
    00387
    00398         virtual bool    testClassName_impl(const String& class_name) const
    00399         {
    00400                 if (class_name==(const utf8*)"Static")  return true;
    00401                 return Window::testClassName_impl(class_name);
    00402         }
    00403
    00404         /*************************************************************************
    00405                 Implementation Data
    00406         *************************************************************************/
    00407         bool                            d_frameEnabled;
    00408         ColourRect                      d_frameCols;
    00409         RenderableFrame         d_frame;
    00410         bool                            d_backgroundEnabled;
    00411         ColourRect                      d_backgroundCols;
    00412         const Image*            d_background;
    00413
    00414         // cache of frame edge sizes
    00415         float   d_left_width;
    00416         float   d_right_width;
    00417         float   d_top_height;
    00418         float   d_bottom_height;
    00419
    00420
    00421 private:
    00422         /*************************************************************************
    00423                 Static Properties for this class
    00424         *************************************************************************/
    00425         static StaticProperties::FrameEnabled                           d_frameEnabledProperty;
    00426         static StaticProperties::BackgroundEnabled                      d_backgroundEnabledProperty;
    00427         static StaticProperties::FrameColours                           d_frameColoursProperty;
    00428         static StaticProperties::BackgroundColours                      d_backgroundColoursProperty;
    00429         static StaticProperties::BackgroundImage                        d_backgroundImageProperty;
    00430         static StaticProperties::TopLeftFrameImage                      d_topLeftFrameProperty;
    00431         static StaticProperties::TopRightFrameImage                     d_topRightFrameProperty;
    00432         static StaticProperties::BottomLeftFrameImage           d_bottomLeftFrameProperty;
    00433         static StaticProperties::BottomRightFrameImage          d_bottomRightFrameProperty;
    00434         static StaticProperties::LeftFrameImage                         d_leftFrameProperty;
    00435         static StaticProperties::RightFrameImage                        d_rightFrameProperty;
    00436         static StaticProperties::TopFrameImage                          d_topFrameProperty;
    00437         static StaticProperties::BottomFrameImage                       d_bottomFrameProperty;
    00438
    00439
    00440         /*************************************************************************
    00441                 Private methods
    00442         *************************************************************************/
    00443         void    addStaticProperties(void);
    00444 };
    00445
    00446
    00447 } // End of  CEGUI namespace section
    00448
    00449 #if defined(_MSC_VER)
    00450 #       pragma warning(pop)
    00451 #endif
    00452
    00453 #endif  // end of guard _CEGUIStatic_h_