Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CEGUIFalComponentBase.cpp

Go to the documentation of this file.
00001 /************************************************************************
00002     filename:   CEGUIFalComponentBase.cpp
00003     created:    Mon Jul 18 2005
00004     author:     Paul D Turner <paul@cegui.org.uk>
00005 *************************************************************************/
00006 /*************************************************************************
00007     Crazy Eddie's GUI System (http://www.cegui.org.uk)
00008     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
00009  
00010     This library is free software; you can redistribute it and/or
00011     modify it under the terms of the GNU Lesser General Public
00012     License as published by the Free Software Foundation; either
00013     version 2.1 of the License, or (at your option) any later version.
00014  
00015     This library is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018     Lesser General Public License for more details.
00019  
00020     You should have received a copy of the GNU Lesser General Public
00021     License along with this library; if not, write to the Free Software
00022     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 *************************************************************************/
00024 #include "falagard/CEGUIFalComponentBase.h"
00025 #include "CEGUIExceptions.h"
00026 #include "CEGUIPropertyHelper.h"
00027 #include <iostream>
00028 
00029 // Start of CEGUI namespace section
00030 namespace CEGUI
00031 {
00032     FalagardComponentBase::FalagardComponentBase() :
00033         d_colours(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF),
00034         d_colourProperyIsRect(false)
00035     {}
00036 
00037     FalagardComponentBase::~ FalagardComponentBase()
00038     {}
00039 
00040     void FalagardComponentBase::render(Window& srcWindow, float base_z, const CEGUI::ColourRect* modColours, const Rect* clipper, bool clipToDisplay) const
00041     {
00042         Rect destRect(d_area.getPixelRect(srcWindow));
00043         render_impl(srcWindow, destRect, base_z, modColours, clipper, clipToDisplay);
00044     }
00045 
00046     void FalagardComponentBase::render(Window& srcWindow, const Rect& baseRect, float base_z, const CEGUI::ColourRect* modColours, const Rect* clipper, bool clipToDisplay) const
00047     {
00048         Rect destRect(d_area.getPixelRect(srcWindow, baseRect));
00049         render_impl(srcWindow, destRect, base_z, modColours, clipper, clipToDisplay);
00050     }
00051 
00052     const ComponentArea& FalagardComponentBase::getComponentArea() const
00053     {
00054         return d_area;
00055     }
00056 
00057     void FalagardComponentBase::setComponentArea(const ComponentArea& area)
00058     {
00059         d_area = area;
00060     }
00061 
00062     const ColourRect& FalagardComponentBase::getColours() const
00063     {
00064         return d_colours;
00065     }
00066 
00067     void FalagardComponentBase::setColours(const ColourRect& cols)
00068     {
00069         d_colours = cols;
00070     }
00071 
00072     void FalagardComponentBase::setColoursPropertySource(const String& property)
00073     {
00074         d_colourPropertyName = property;
00075     }
00076 
00077     void FalagardComponentBase::setColoursPropertyIsColourRect(bool setting)
00078     {
00079         d_colourProperyIsRect = setting;
00080     }
00081 
00082     void FalagardComponentBase::initColoursRect(const Window& wnd, const ColourRect* modCols, ColourRect& cr) const
00083     {
00084         // if colours come via a colour property
00085         if (!d_colourPropertyName.empty())
00086         {
00087             // if property accesses a ColourRect
00088             if (d_colourProperyIsRect)
00089             {
00090                 cr = PropertyHelper::stringToColourRect(wnd.getProperty(d_colourPropertyName));
00091             }
00092             // property accesses a colour
00093             else
00094             {
00095                 colour val(PropertyHelper::stringToColour(wnd.getProperty(d_colourPropertyName)));
00096                 cr.d_top_left     = val;
00097                 cr.d_top_right    = val;
00098                 cr.d_bottom_left  = val;
00099                 cr.d_bottom_right = val;
00100             }
00101         }
00102         // use explicit ColourRect.
00103         else
00104         {
00105             cr = d_colours;
00106         }
00107 
00108         if (modCols)
00109         {
00110             cr *= *modCols;
00111         }
00112     }
00113 
00114 
00115     void FalagardComponentBase::setVertFormattingPropertySource(const String& property)
00116     {
00117         d_vertFormatPropertyName = property;
00118     }
00119 
00120     void FalagardComponentBase::setHorzFormattingPropertySource(const String& property)
00121     {
00122         d_horzFormatPropertyName = property;
00123     }
00124 
00125     bool FalagardComponentBase::writeColoursXML(OutStream& out_stream) const
00126     {
00127         if (!d_colourPropertyName.empty())
00128         {
00129             if (d_colourProperyIsRect)
00130                 out_stream << "<ColourRectProperty ";
00131             else
00132                 out_stream << "<ColourProperty ";
00133 
00134             out_stream << "name=\"" << d_colourPropertyName << "\" />" << std::endl;
00135         }
00136         else if (!d_colours.isMonochromatic() || d_colours.d_top_left != colour(1,1,1,1))
00137         {
00138             out_stream << "<Colours ";
00139             out_stream << "topLeft=\"" << PropertyHelper::colourToString(d_colours.d_top_left) << "\" ";
00140             out_stream << "topRight=\"" << PropertyHelper::colourToString(d_colours.d_top_right) << "\" ";
00141             out_stream << "bottomLeft=\"" << PropertyHelper::colourToString(d_colours.d_bottom_left) << "\" ";
00142             out_stream << "bottomRight=\"" << PropertyHelper::colourToString(d_colours.d_bottom_right) << "\" />" << std::endl;
00143         }
00144         else
00145         {
00146             return false;
00147         }
00148 
00149         return true;
00150     }
00151 
00152     bool FalagardComponentBase::writeVertFormatXML(OutStream& out_stream) const
00153     {
00154         if (!d_vertFormatPropertyName.empty())
00155         {
00156             out_stream << "<VertFormatProperty name=\"" << d_vertFormatPropertyName << "\" />" << std::endl;
00157             return true;
00158         }
00159 
00160         return false;
00161     }
00162 
00163     bool FalagardComponentBase::writeHorzFormatXML(OutStream& out_stream) const
00164     {
00165         if (!d_horzFormatPropertyName.empty())
00166         {
00167             out_stream << "<HorzFormatProperty name=\"" << d_horzFormatPropertyName << "\" />" << std::endl;
00168             return true;
00169         }
00170 
00171         return false;
00172     }
00173 
00174 } // End of  CEGUI namespace section

Generated on Wed Sep 7 09:56:31 2005 for Crazy Eddies GUI System by  doxygen 1.4.3