Crazy Eddie's GUI System  0.8.4
XMLEnumHelper.h
00001 /***********************************************************************
00002     created:    Mon Jul 18 2005
00003     author:     Paul D Turner <paul@cegui.org.uk>
00004 *************************************************************************/
00005 /***************************************************************************
00006  *   Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team
00007  *
00008  *   Permission is hereby granted, free of charge, to any person obtaining
00009  *   a copy of this software and associated documentation files (the
00010  *   "Software, to deal in the Software without restriction, including
00011  *   without limitation the rights to use, copy, modify, merge, publish,
00012  *   distribute, sublicense, and/or sell copies of the Software, and to
00013  *   permit persons to whom the Software is furnished to do so, subject to
00014  *   the following conditions:
00015  *
00016  *   The above copyright notice and this permission notice shall be
00017  *   included in all copies or substantial portions of the Software.
00018  *
00019  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00020  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00021  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00022  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00023  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00024  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00025  *   OTHER DEALINGS IN THE SOFTWARE.
00026  ***************************************************************************/
00027 #ifndef _CEGUIFalXMLEnumHelper_h_
00028 #define _CEGUIFalXMLEnumHelper_h_
00029 
00030 #include "../String.h"
00031 #include "../Window.h"
00032 #include "CEGUI/falagard/Enums.h"
00033 
00034 namespace CEGUI
00035 {
00036 template<typename T>
00037 class FalagardXMLHelper;
00038 
00039 template<>
00040 class CEGUIEXPORT FalagardXMLHelper<VerticalFormatting>
00041 {
00042 public:
00043     typedef VerticalFormatting return_type;
00044     typedef VerticalFormatting pass_type;
00045 
00046     static String toString(pass_type val)
00047     {
00048         switch (val)
00049         {
00050         case VF_BOTTOM_ALIGNED:
00051             return BottomAligned;
00052 
00053         case VF_CENTRE_ALIGNED:
00054             return CentreAligned;
00055 
00056         case VF_TILED:
00057             return Tiled;
00058 
00059         case VF_STRETCHED:
00060             return Stretched;
00061 
00062         default:
00063             return TopAligned;
00064         }
00065     }
00066 
00067     static return_type fromString(const String& str)
00068     {
00069         if (str == CentreAligned)
00070             return VF_CENTRE_ALIGNED;
00071 
00072         else if (str == BottomAligned)
00073             return VF_BOTTOM_ALIGNED;
00074 
00075         else if (str == Tiled)
00076             return VF_TILED;
00077 
00078         else if (str == Stretched)
00079             return VF_STRETCHED;
00080 
00081         else
00082             return VF_TOP_ALIGNED;
00083     }
00084 
00086     static const CEGUI::String Stretched;
00087     static const CEGUI::String Tiled;
00088     static const CEGUI::String TopAligned;
00089     static const CEGUI::String BottomAligned;
00090     static const CEGUI::String CentreAligned;
00091 };
00092 
00093 template<>
00094 class CEGUIEXPORT FalagardXMLHelper<HorizontalFormatting>
00095 {
00096 public:
00097     typedef HorizontalFormatting return_type;
00098     typedef HorizontalFormatting pass_type;
00099 
00100     static String toString(pass_type val)
00101     {
00102         switch (val)
00103         {
00104         case HF_RIGHT_ALIGNED:
00105             return RightAligned;
00106 
00107         case HF_CENTRE_ALIGNED:
00108             return CentreAligned;
00109 
00110         case HF_TILED:
00111             return Tiled;
00112 
00113         case HF_STRETCHED:
00114             return Stretched;
00115 
00116         default:
00117             return LeftAligned;
00118         }
00119     }
00120 
00121     static return_type fromString(const String& str)
00122     {
00123         if (str == CentreAligned)
00124             return HF_CENTRE_ALIGNED;
00125 
00126         else if (str == RightAligned)
00127             return HF_RIGHT_ALIGNED;
00128 
00129         else if (str == Tiled)
00130             return HF_TILED;
00131 
00132         else if (str == Stretched)
00133             return HF_STRETCHED;
00134 
00135         else
00136             return HF_LEFT_ALIGNED;
00137     }
00138 
00140     static const CEGUI::String Stretched;
00141     static const CEGUI::String Tiled;
00142     static const CEGUI::String LeftAligned;
00143     static const CEGUI::String RightAligned;
00144     static const CEGUI::String CentreAligned;
00145 };
00146 
00147 template<>
00148 class CEGUIEXPORT FalagardXMLHelper<VerticalAlignment>
00149 {
00150 public:
00151     typedef VerticalAlignment return_type;
00152     typedef VerticalAlignment pass_type;
00153 
00154     static String toString(pass_type val)
00155     {
00156         switch (val)
00157         {
00158         case VA_BOTTOM:
00159             return BottomAligned;
00160 
00161         case VA_CENTRE:
00162             return CentreAligned;
00163 
00164         default:
00165             return TopAligned;
00166         }
00167     }
00168 
00169     static return_type fromString(const String& str)
00170     {
00171         if (str == CentreAligned)
00172             return VA_CENTRE;
00173 
00174         else if (str == BottomAligned)
00175             return VA_BOTTOM;
00176 
00177         else
00178             return VA_TOP;
00179     }
00180 
00182     static const CEGUI::String TopAligned;
00183     static const CEGUI::String BottomAligned;
00184     static const CEGUI::String CentreAligned;
00185 };
00186 
00187 template<>
00188 class CEGUIEXPORT FalagardXMLHelper<HorizontalAlignment>
00189 {
00190 public:
00191     typedef HorizontalAlignment return_type;
00192     typedef HorizontalAlignment pass_type;
00193 
00194     static String toString(pass_type val)
00195     {
00196         switch (val)
00197         {
00198         case HA_RIGHT:
00199             return RightAligned;
00200 
00201         case HA_CENTRE:
00202             return CentreAligned;
00203 
00204         default:
00205             return LeftAligned;
00206         }
00207     }
00208 
00209     static return_type fromString(const String& str)
00210     {
00211         if (str == CentreAligned)
00212             return HA_CENTRE;
00213 
00214         else if (str == RightAligned)
00215             return HA_RIGHT;
00216 
00217         else
00218             return HA_LEFT;
00219     }
00220 
00222     static const CEGUI::String LeftAligned;
00223     static const CEGUI::String RightAligned;
00224     static const CEGUI::String CentreAligned;
00225 };
00226 
00227 template<>
00228 class CEGUIEXPORT FalagardXMLHelper<DimensionType>
00229 {
00230 public:
00231     typedef DimensionType return_type;
00232     typedef DimensionType pass_type;
00233 
00234     static String toString(pass_type val)
00235     {
00236         switch (val)
00237         {
00238         case DT_LEFT_EDGE:
00239             return LeftEdge;
00240 
00241         case DT_X_POSITION:
00242             return XPosition;
00243 
00244         case DT_TOP_EDGE:
00245             return TopEdge;
00246 
00247         case DT_Y_POSITION:
00248             return YPosition;
00249 
00250         case DT_RIGHT_EDGE:
00251             return RightEdge;
00252 
00253         case DT_BOTTOM_EDGE:
00254             return BottomEdge;
00255 
00256         case DT_WIDTH:
00257             return Width;
00258 
00259         case DT_HEIGHT:
00260             return Height;
00261 
00262         case DT_X_OFFSET:
00263             return XOffset;
00264 
00265         case DT_Y_OFFSET:
00266             return YOffset;
00267 
00268         default:
00269             return Invalid;
00270         }
00271     }
00272 
00273     static return_type fromString(const String& str)
00274     {
00275         if (str == LeftEdge)
00276             return DT_LEFT_EDGE;
00277 
00278         else if (str == XPosition)
00279             return DT_X_POSITION;
00280 
00281         else if (str == TopEdge)
00282             return DT_TOP_EDGE;
00283 
00284         else if (str == YPosition)
00285             return DT_Y_POSITION;
00286 
00287         else if (str == RightEdge)
00288             return DT_RIGHT_EDGE;
00289 
00290         else if (str == BottomEdge)
00291             return DT_BOTTOM_EDGE;
00292 
00293         else if (str == Width)
00294             return DT_WIDTH;
00295 
00296         else if (str == Height)
00297             return DT_HEIGHT;
00298 
00299         else if (str == XOffset)
00300             return DT_X_OFFSET;
00301 
00302         else if (str == YOffset)
00303             return DT_Y_OFFSET;
00304 
00305         else
00306             return DT_INVALID;
00307     }
00308 
00310     static const CEGUI::String LeftEdge;
00311     static const CEGUI::String RightEdge;
00312     static const CEGUI::String BottomEdge;
00313     static const CEGUI::String TopEdge;
00314     static const CEGUI::String XPosition;
00315     static const CEGUI::String YPosition;
00316     static const CEGUI::String Width;
00317     static const CEGUI::String Height;
00318     static const CEGUI::String XOffset;
00319     static const CEGUI::String YOffset;
00320     static const CEGUI::String Invalid;
00321 };
00322 
00323 template<>
00324 class CEGUIEXPORT FalagardXMLHelper<VerticalTextFormatting>
00325 {
00326 public:
00327     typedef VerticalTextFormatting return_type;
00328     typedef VerticalTextFormatting pass_type;
00329 
00330     static String toString(pass_type val)
00331     {
00332         switch (val)
00333         {
00334         case VTF_BOTTOM_ALIGNED:
00335             return BottomAligned;
00336 
00337         case VTF_CENTRE_ALIGNED:
00338             return CentreAligned;
00339 
00340         default:
00341             return TopAligned;
00342         }
00343     }
00344 
00345     static return_type fromString(const String& str)
00346     {
00347         if (str == CentreAligned)
00348             return VTF_CENTRE_ALIGNED;
00349 
00350         else if (str == BottomAligned)
00351             return VTF_BOTTOM_ALIGNED;
00352 
00353         else
00354             return VTF_TOP_ALIGNED;
00355     }
00356 
00358     static const CEGUI::String TopAligned;
00359     static const CEGUI::String BottomAligned;
00360     static const CEGUI::String CentreAligned;
00361 };
00362 
00363 template<>
00364 class CEGUIEXPORT FalagardXMLHelper<HorizontalTextFormatting>
00365 {
00366 public:
00367     typedef HorizontalTextFormatting return_type;
00368     typedef HorizontalTextFormatting pass_type;
00369 
00370     static String toString(pass_type val)
00371     {
00372         switch (val)
00373         {
00374         case HTF_RIGHT_ALIGNED:
00375             return RightAligned;
00376 
00377         case HTF_CENTRE_ALIGNED:
00378             return CentreAligned;
00379 
00380         case HTF_JUSTIFIED:
00381             return Justified;
00382 
00383         case HTF_WORDWRAP_LEFT_ALIGNED:
00384             return WordWrapLeftAligned;
00385 
00386         case HTF_WORDWRAP_RIGHT_ALIGNED:
00387             return WordWrapRightAligned;
00388 
00389         case HTF_WORDWRAP_CENTRE_ALIGNED:
00390             return WordWrapCentreAligned;
00391 
00392         case HTF_WORDWRAP_JUSTIFIED:
00393             return WordWrapJustified;
00394 
00395         default:
00396             return LeftAligned;
00397         }
00398     }
00399 
00400     static return_type fromString(const String& str)
00401     {
00402         if (str == CentreAligned)
00403             return HTF_CENTRE_ALIGNED;
00404 
00405         else if (str == RightAligned)
00406             return HTF_RIGHT_ALIGNED;
00407 
00408         else if (str == Justified)
00409             return HTF_JUSTIFIED;
00410 
00411         else if (str == WordWrapLeftAligned)
00412             return HTF_WORDWRAP_LEFT_ALIGNED;
00413 
00414         else if (str == WordWrapCentreAligned)
00415             return HTF_WORDWRAP_CENTRE_ALIGNED;
00416 
00417         else if (str == WordWrapRightAligned)
00418             return HTF_WORDWRAP_RIGHT_ALIGNED;
00419 
00420         else if (str == WordWrapJustified)
00421             return HTF_WORDWRAP_JUSTIFIED;
00422 
00423         else
00424             return HTF_LEFT_ALIGNED;
00425     }
00426 
00428     static const CEGUI::String CentreAligned;
00429     static const CEGUI::String RightAligned;
00430     static const CEGUI::String LeftAligned;
00431     static const CEGUI::String Justified;
00432     static const CEGUI::String WordWrapLeftAligned;
00433     static const CEGUI::String WordWrapCentreAligned;
00434     static const CEGUI::String WordWrapRightAligned;
00435     static const CEGUI::String WordWrapJustified;
00436 };
00437 
00438 template<>
00439 class CEGUIEXPORT FalagardXMLHelper<FontMetricType>
00440 {
00441 public:
00442     typedef FontMetricType return_type;
00443     typedef FontMetricType pass_type;
00444 
00445     static String toString(pass_type val)
00446     {
00447         switch (val)
00448         {
00449         case FMT_BASELINE:
00450             return Baseline;
00451 
00452         case FMT_HORZ_EXTENT:
00453             return HorzExtent;
00454 
00455         default:
00456             return LineSpacing;
00457         }
00458     }
00459 
00460     static return_type fromString(const String& str)
00461     {
00462         if (str == LineSpacing)
00463             return FMT_LINE_SPACING;
00464 
00465         else if (str == Baseline)
00466             return FMT_BASELINE;
00467 
00468         else
00469             return FMT_HORZ_EXTENT;
00470     }
00471 
00472     static const CEGUI::String LineSpacing;
00473     static const CEGUI::String HorzExtent;
00474     static const CEGUI::String Baseline;
00475 };
00476 
00477 template<>
00478 class CEGUIEXPORT FalagardXMLHelper<DimensionOperator>
00479 {
00480 public:
00481     typedef DimensionOperator return_type;
00482     typedef DimensionOperator pass_type;
00483 
00484     static String toString(pass_type val)
00485     {
00486         switch (val)
00487         {
00488         case DOP_ADD:
00489             return Add;
00490 
00491         case DOP_SUBTRACT:
00492             return Subtract;
00493 
00494         case DOP_MULTIPLY:
00495             return Multiply;
00496 
00497         case DOP_DIVIDE:
00498             return Divide;
00499 
00500         default:
00501             return Noop;
00502         }
00503     }
00504 
00505     static return_type fromString(const String& str)
00506     {
00507         if (str == Add)
00508             return DOP_ADD;
00509 
00510         else if (str == Subtract)
00511             return DOP_SUBTRACT;
00512 
00513         else if (str == Multiply)
00514             return DOP_MULTIPLY;
00515 
00516         else if (str == Divide)
00517             return DOP_DIVIDE;
00518 
00519         else
00520             return DOP_NOOP;
00521     }
00522 
00523     static const CEGUI::String Add;
00524     static const CEGUI::String Subtract;
00525     static const CEGUI::String Multiply;
00526     static const CEGUI::String Divide;
00527     static const CEGUI::String Noop;
00528 };
00529 
00530 template<>
00531 class CEGUIEXPORT FalagardXMLHelper<FrameImageComponent>
00532 {
00533 public:
00534     typedef FrameImageComponent return_type;
00535     typedef FrameImageComponent pass_type;
00536 
00537     static String toString(pass_type val)
00538     {
00539         switch (val)
00540         {
00541         case FIC_TOP_LEFT_CORNER:
00542             return TopLeftCorner;
00543 
00544         case FIC_TOP_RIGHT_CORNER:
00545             return TopRightCorner;
00546 
00547         case FIC_BOTTOM_LEFT_CORNER:
00548             return BottomLeftCorner;
00549 
00550         case FIC_BOTTOM_RIGHT_CORNER:
00551             return BottomRightCorner;
00552 
00553         case FIC_LEFT_EDGE:
00554             return LeftEdge;
00555 
00556         case FIC_RIGHT_EDGE:
00557             return RightEdge;
00558 
00559         case FIC_TOP_EDGE:
00560             return TopEdge;
00561 
00562         case FIC_BOTTOM_EDGE:
00563             return BottomEdge;
00564 
00565         default:
00566             return Background;
00567         }
00568     }
00569 
00570     static return_type fromString(const String& str)
00571     {
00572         if (str == TopLeftCorner)
00573             return FIC_TOP_LEFT_CORNER;
00574 
00575         if (str == TopRightCorner)
00576             return FIC_TOP_RIGHT_CORNER;
00577 
00578         if (str == BottomLeftCorner)
00579             return FIC_BOTTOM_LEFT_CORNER;
00580 
00581         if (str == BottomRightCorner)
00582             return FIC_BOTTOM_RIGHT_CORNER;
00583 
00584         if (str == LeftEdge)
00585             return FIC_LEFT_EDGE;
00586 
00587         if (str == RightEdge)
00588             return FIC_RIGHT_EDGE;
00589 
00590         if (str == TopEdge)
00591             return FIC_TOP_EDGE;
00592 
00593         if (str == BottomEdge)
00594             return FIC_BOTTOM_EDGE;
00595 
00596         else
00597             return FIC_BACKGROUND;
00598     }
00599 
00600     static const CEGUI::String TopLeftCorner;
00601     static const CEGUI::String TopRightCorner;
00602     static const CEGUI::String BottomLeftCorner;
00603     static const CEGUI::String BottomRightCorner;
00604     static const CEGUI::String TopEdge;
00605     static const CEGUI::String LeftEdge;
00606     static const CEGUI::String RightEdge;
00607     static const CEGUI::String BottomEdge;
00608     static const CEGUI::String Background;
00609 };
00610 
00611 template<>
00612 class CEGUIEXPORT FalagardXMLHelper<ChildEventAction>
00613 {
00614 public:
00615     typedef ChildEventAction return_type;
00616     typedef ChildEventAction pass_type;
00617 
00618     static String toString(pass_type val)
00619     {
00620         switch (val)
00621         {
00622         case CEA_REDRAW:
00623             return Redraw;
00624 
00625         case CEA_LAYOUT:
00626             return Layout;
00627 
00628         default:
00629             CEGUI_THROW(InvalidRequestException(
00630                 "Invalid enumeration value given."));
00631         }
00632     }
00633 
00634     static return_type fromString(const String& str)
00635     {
00636         if (str == Redraw)
00637             return CEA_REDRAW;
00638 
00639         if (str == Layout)
00640             return CEA_LAYOUT;
00641 
00642         CEGUI_THROW(InvalidRequestException(
00643             "'" + str +
00644             "' does not represent a ChildEventAction enumerated value."));
00645     }
00646 
00647     static const CEGUI::String Redraw;
00648     static const CEGUI::String Layout;
00649 };
00650 
00653 //
00654 // PropertyHelper specialisations
00655 //
00658 
00659 template<>
00660 class PropertyHelper<VerticalFormatting>
00661 {
00662 public:
00663     typedef VerticalFormatting return_type;
00664     typedef return_type safe_method_return_type;
00665     typedef VerticalFormatting pass_type;
00666     typedef String string_return_type;
00667 
00668     static const String& getDataTypeName()
00669     {
00670         static String type("VerticalFormatting");
00671 
00672         return type;
00673     }
00674 
00675     static return_type fromString(const String& str)
00676     {
00677         return FalagardXMLHelper<return_type>::fromString(str);
00678     }
00679 
00680     static string_return_type toString(pass_type val)
00681     {
00682         return FalagardXMLHelper<return_type>::toString(val);
00683     }
00684 };
00685 
00686 template<>
00687 class PropertyHelper<HorizontalFormatting>
00688 {
00689 public:
00690     typedef HorizontalFormatting return_type;
00691     typedef return_type safe_method_return_type;
00692     typedef HorizontalFormatting pass_type;
00693     typedef String string_return_type;
00694 
00695     static const String& getDataTypeName()
00696     {
00697         static String type("HorizontalFormatting");
00698 
00699         return type;
00700     }
00701 
00702     static return_type fromString(const String& str)
00703     {
00704         return FalagardXMLHelper<return_type>::fromString(str);
00705     }
00706 
00707     static string_return_type toString(pass_type val)
00708     {
00709         return FalagardXMLHelper<return_type>::toString(val);
00710     }
00711 };
00712 
00713 template<>
00714 class PropertyHelper<VerticalTextFormatting>
00715 {
00716 public:
00717     typedef VerticalTextFormatting return_type;
00718     typedef return_type safe_method_return_type;
00719     typedef VerticalTextFormatting pass_type;
00720     typedef String string_return_type;
00721 
00722     static const String& getDataTypeName()
00723     {
00724         static String type("VerticalTextFormatting");
00725 
00726         return type;
00727     }
00728 
00729     static return_type fromString(const String& str)
00730     {
00731         return FalagardXMLHelper<return_type>::fromString(str);
00732     }
00733 
00734     static string_return_type toString(pass_type val)
00735     {
00736         return FalagardXMLHelper<return_type>::toString(val);
00737     }
00738 };
00739 
00740 template<>
00741 class PropertyHelper<HorizontalTextFormatting>
00742 {
00743 public:
00744     typedef HorizontalTextFormatting return_type;
00745     typedef return_type safe_method_return_type;
00746     typedef HorizontalTextFormatting pass_type;
00747     typedef String string_return_type;
00748 
00749     static const String& getDataTypeName()
00750     {
00751         static String type("HorizontalTextFormatting");
00752 
00753         return type;
00754     }
00755 
00756     static return_type fromString(const String& str)
00757     {
00758         return FalagardXMLHelper<return_type>::fromString(str);
00759     }
00760 
00761     static string_return_type toString(pass_type val)
00762     {
00763         return FalagardXMLHelper<return_type>::toString(val);
00764     }
00765 };
00766 
00767 }
00768 
00769 
00770 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends