Crazy Eddies GUI System
0.7.6
|
00001 /*********************************************************************** 00002 filename: CEGUIFalDimensions.h 00003 created: Mon Jun 13 2005 00004 author: Paul D Turner <paul@cegui.org.uk> 00005 *************************************************************************/ 00006 /*************************************************************************** 00007 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00008 * 00009 * Permission is hereby granted, free of charge, to any person obtaining 00010 * a copy of this software and associated documentation files (the 00011 * "Software"), to deal in the Software without restriction, including 00012 * without limitation the rights to use, copy, modify, merge, publish, 00013 * distribute, sublicense, and/or sell copies of the Software, and to 00014 * permit persons to whom the Software is furnished to do so, subject to 00015 * the following conditions: 00016 * 00017 * The above copyright notice and this permission notice shall be 00018 * included in all copies or substantial portions of the Software. 00019 * 00020 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00021 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00022 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00023 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00024 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00025 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00026 * OTHER DEALINGS IN THE SOFTWARE. 00027 ***************************************************************************/ 00028 #ifndef _CEGUIFalDimensions_h_ 00029 #define _CEGUIFalDimensions_h_ 00030 00031 #include "CEGUIFalEnums.h" 00032 #include "../CEGUIString.h" 00033 #include "../CEGUIUDim.h" 00034 #include "../CEGUIXMLSerializer.h" 00035 00036 // Start of CEGUI namespace section 00037 namespace CEGUI 00038 { 00043 class CEGUIEXPORT BaseDim 00044 { 00045 public: 00046 BaseDim(); 00047 00048 virtual ~BaseDim(); 00049 00061 float getValue(const Window& wnd) const; 00062 00080 float getValue(const Window& wnd, const Rect& container) const; 00081 00094 BaseDim* clone() const; 00095 00104 DimensionOperator getDimensionOperator() const; 00105 00117 void setDimensionOperator(DimensionOperator op); 00118 00126 const BaseDim* getOperand() const; 00127 00139 void setOperand(const BaseDim& operand); 00140 00151 void writeXMLToStream(XMLSerializer& xml_stream) const; 00152 00153 protected: 00159 virtual float getValue_impl(const Window& wnd) const = 0; 00160 00166 virtual float getValue_impl(const Window& wnd, const Rect& container) const = 0; 00167 00174 virtual BaseDim* clone_impl() const = 0; 00175 00180 virtual void writeXMLElementName_impl(XMLSerializer& xml_stream) const = 0; 00181 00186 virtual void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const = 0; 00187 00188 private: 00189 DimensionOperator d_operator; 00190 BaseDim* d_operand; 00191 }; 00192 00193 00198 class CEGUIEXPORT AbsoluteDim : public BaseDim 00199 { 00200 public: 00208 AbsoluteDim(float val); 00209 00214 void setValue(float val); 00215 00216 protected: 00217 // Implementation of the base class interface 00218 float getValue_impl(const Window& wnd) const; 00219 float getValue_impl(const Window& wnd, const Rect& container) const; 00220 void writeXMLElementName_impl(XMLSerializer& xml_stream) const; 00221 void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const; 00222 00223 BaseDim* clone_impl() const; 00224 00225 private: 00226 float d_val; 00227 }; 00228 00229 00234 class CEGUIEXPORT ImageDim : public BaseDim 00235 { 00236 public: 00251 ImageDim(const String& imageset, const String& image, DimensionType dim); 00252 00266 void setSourceImage(const String& imageset, const String& image); 00267 00279 void setSourceDimension(DimensionType dim); 00280 00281 protected: 00282 // Implementation of the base class interface 00283 float getValue_impl(const Window& wnd) const; 00284 float getValue_impl(const Window& wnd, const Rect& container) const; 00285 void writeXMLElementName_impl(XMLSerializer& xml_stream) const; 00286 void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const; 00287 BaseDim* clone_impl() const; 00288 00289 private: 00290 String d_imageset; 00291 String d_image; 00292 DimensionType d_what; 00293 }; 00294 00295 00305 class CEGUIEXPORT WidgetDim : public BaseDim 00306 { 00307 public: 00319 WidgetDim(const String& name, DimensionType dim); 00320 00331 void setWidgetName(const String& name); 00332 00344 void setSourceDimension(DimensionType dim); 00345 00346 protected: 00347 // Implementation of the base class interface 00348 float getValue_impl(const Window& wnd) const; 00349 float getValue_impl(const Window& wnd, const Rect& container) const; 00350 void writeXMLElementName_impl(XMLSerializer& xml_stream) const; 00351 void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const; 00352 BaseDim* clone_impl() const; 00353 00354 private: 00355 String d_widgetName; 00356 DimensionType d_what; 00357 }; 00358 00359 00364 class CEGUIEXPORT UnifiedDim : public BaseDim 00365 { 00366 public: 00379 UnifiedDim(const UDim& value, DimensionType dim); 00380 00381 protected: 00382 // Implementation of the base class interface 00383 float getValue_impl(const Window& wnd) const; 00384 float getValue_impl(const Window& wnd, const Rect& container) const; 00385 void writeXMLElementName_impl(XMLSerializer& xml_stream) const; 00386 void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const; 00387 BaseDim* clone_impl() const; 00388 00389 private: 00390 UDim d_value; 00391 DimensionType d_what; 00392 }; 00393 00398 class CEGUIEXPORT FontDim : public BaseDim 00399 { 00400 public: 00423 FontDim(const String& name, const String& font, const String& text, FontMetricType metric, float padding = 0); 00424 00425 protected: 00426 // Implementation of the base class interface 00427 float getValue_impl(const Window& wnd) const; 00428 float getValue_impl(const Window& wnd, const Rect& container) const; 00429 void writeXMLElementName_impl(XMLSerializer& xml_stream) const; 00430 void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const; 00431 BaseDim* clone_impl() const; 00432 00433 private: 00434 String d_font; 00435 String d_text; 00436 String d_childSuffix; 00437 FontMetricType d_metric; 00438 float d_padding; 00439 }; 00440 00446 class CEGUIEXPORT PropertyDim : public BaseDim 00447 { 00448 public: 00474 PropertyDim(const String& name, const String& property, DimensionType type); 00475 00476 protected: 00477 // Implementation of the base class interface 00478 float getValue_impl(const Window& wnd) const; 00479 float getValue_impl(const Window& wnd, const Rect& container) const; 00480 void writeXMLElementName_impl(XMLSerializer& xml_stream) const; 00481 void writeXMLElementAttributes_impl(XMLSerializer& xml_stream) const; 00482 BaseDim* clone_impl() const; 00483 00484 private: 00485 String d_property; 00486 String d_childSuffix; 00487 DimensionType d_type; 00488 }; 00489 00498 class CEGUIEXPORT Dimension 00499 { 00500 public: 00505 Dimension(); 00506 00511 ~Dimension(); 00512 00523 Dimension(const BaseDim& dim, DimensionType type); 00524 00529 Dimension(const Dimension& other); 00530 00535 Dimension& operator=(const Dimension& other); 00536 00544 const BaseDim& getBaseDimension() const; 00545 00556 void setBaseDimension(const BaseDim& dim); 00557 00565 DimensionType getDimensionType() const; 00566 00577 void setDimensionType(DimensionType type); 00578 00589 void writeXMLToStream(XMLSerializer& xml_stream) const; 00590 00591 private: 00592 BaseDim* d_value; 00593 DimensionType d_type; 00594 }; 00595 00596 00606 class CEGUIEXPORT ComponentArea 00607 { 00608 public: 00620 Rect getPixelRect(const Window& wnd) const; 00621 00636 Rect getPixelRect(const Window& wnd, const Rect& container) const; 00637 00649 void writeXMLToStream(XMLSerializer& xml_stream) const; 00650 00659 bool isAreaFetchedFromProperty() const; 00660 00668 const String& getAreaPropertySource() const; 00669 00680 void setAreaPropertySource(const String& property); 00681 00682 00683 Dimension d_left; 00684 Dimension d_top; 00685 Dimension d_right_or_width; 00686 Dimension d_bottom_or_height; 00687 00688 private: 00689 String d_areaProperty; 00690 }; 00691 00692 } // End of CEGUI namespace section 00693 00694 00695 #endif // end of guard _CEGUIFalDimensions_h_