Community Core Vision 1.4
Cross platform, user friendly computer vision.
C:/CCV/1.4/addons/ofxNCore/src/Controls/ofxGuiGlobals.cpp
Go to the documentation of this file.
00001 /*
00002  *  ofxGuiGlobals.cpp
00003  *  openFrameworks
00004  *
00005  *  Created by Stefan Kirch on 18.06.08.
00006  *  Copyright 2008 alphakanal. All rights reserved.
00007  *
00008  */
00009 
00010 //      ----------------------------------------------------------------------------------------------------
00011 
00012 #include "ofxGuiGlobals.h"
00013 
00014 //      ----------------------------------------------------------------------------------------------------
00015 
00016 ofxGuiGlobals* ofxGuiGlobals::Instance()
00017 {
00018         static ofxGuiGlobals globals;   
00019         return &globals;
00020 }
00021 
00022 //      ----------------------------------------------------------------------------------------------------
00023 
00024 ofxGuiGlobals::ofxGuiGlobals()
00025 {
00026         mXmlfile                        = "";
00027         
00028         mHeadFontName           = "verdana.ttf";
00029         mHeadFontSize           = 10;
00030         mHeadFontXOffset        = -2;
00031         mHeadFontYOffset        = 8;
00032         mHeadFontHeight         = 12;
00033         
00034         mParamFontName          = "automat.ttf";
00035         mParamFontSize          = 6;
00036         mParamFontXOffset       = -2;
00037         mParamFontYOffset       = 6;
00038         mParamFontHeight                = 12;
00039 
00040         mButtonXText            = 4;
00041         mButtonYText            = 0;
00042         
00043         mFilesXText                     = 3;
00044         mFilesYText                     = 3;
00045         
00046         mPointSize                      = 6;
00047 
00048         mKnobSize                       = 10;
00049 
00050         mCoverColor                     = ofRGBA(0x00000088);
00051         mTextColor                      = ofRGBA(0xFFFFFFFF);
00052         mBorderColor            = ofRGBA(0xFFFFFFFF);
00053         mFrameColor                     = ofRGBA(0xFFFFFFFF);
00054         mSliderColor            = ofRGBA(0x0099FFFF);
00055         mAxisColor                      = ofRGBA(0x00FF00FF);
00056         mHandleColor            = ofRGBA(0xFFFFFFFF);
00057         mButtonColor            = ofRGBA(0xFFDD00FF);
00058         mCurveColor                     = ofRGBA(0xFF9900FF);
00059         mScopeColor                     = ofRGBA(0xFF9900FF);
00060         mMatrixColor            = ofRGBA(0xFF0000FF);
00061         
00062         loadFonts();
00063 }
00064 
00065 //      ----------------------------------------------------------------------------------------------------
00066 
00067 void ofxGuiGlobals::buildFromXml()
00068 {
00069         int numberOfTags = mXml.getNumTags("STYLE");
00070 
00071         if(numberOfTags != 1)
00072                 return;
00073 
00074         mXml.pushTag("STYLE", 0);
00075         
00076         mHeadFontName           = mXml.getValue("HEADFONT", "verdana.ttf");
00077         mHeadFontSize           = mXml.getValue("HEADSIZE", 10);
00078         mHeadFontXOffset        = mXml.getValue("HEADXOFF", -2);
00079         mHeadFontYOffset        = mXml.getValue("HEADYOFF", 8);
00080         mHeadFontHeight         = mXml.getValue("HEADHEIGHT", 12);
00081         
00082         mParamFontName          = mXml.getValue("PARAMFONT", "automat.ttf");
00083         mParamFontSize          = mXml.getValue("PARAMSIZE", 6);
00084         mParamFontXOffset       = mXml.getValue("PARAMXOFF", -2);
00085         mParamFontYOffset       = mXml.getValue("PARAMYOFF", 6);
00086         mParamFontHeight        = mXml.getValue("PARAMHEIGHT", 12);
00087                 
00088         mButtonXText            = mXml.getValue("BUTTONXTEXT", 4);
00089         mButtonYText            = mXml.getValue("BUTTONYTEXT", 0);
00090         
00091         mFilesXText                     = mXml.getValue("FILESXTEXT", 3);
00092         mFilesYText                     = mXml.getValue("FILESYTEXT", 3);
00093         
00094         mPointSize                      = mXml.getValue("POINTSIZE", 6);
00095         
00096         mKnobSize                       = mXml.getValue("KNOBSIZE", 10);
00097         
00098         mCoverColor                     = ofRGBA(mXml.getValue("COVERCOLOR",    "00000088"));
00099         mTextColor                      = ofRGBA(mXml.getValue("TEXTCOLOR",             "FFFFFFFF"));
00100         mBorderColor            = ofRGBA(mXml.getValue("BORDERCOLOR",   "FFFFFFFF"));
00101         mFrameColor                     = ofRGBA(mXml.getValue("FRAMECOLOR",    "FFFFFFFF"));
00102         mSliderColor            = ofRGBA(mXml.getValue("SLIDERCOLOR",   "0099FFFF"));
00103         mAxisColor                      = ofRGBA(mXml.getValue("AXISCOLOR",             "00FF00FF"));
00104         mHandleColor            = ofRGBA(mXml.getValue("HANDLECOLOR",   "FFFFFFFF"));
00105         mButtonColor            = ofRGBA(mXml.getValue("BUTTONCOLOR",   "FFDD00FF"));
00106         mCurveColor                     = ofRGBA(mXml.getValue("CURVECOLOR",    "FF9900FF"));
00107         mScopeColor                     = ofRGBA(mXml.getValue("SCOPECOLOR",    "FF9900FF"));
00108         mMatrixColor            = ofRGBA(mXml.getValue("ACTIVECOLOR",   "FF0000FF"));
00109 
00110         mXml.popTag();
00111         
00112         loadFonts();
00113 }
00114 
00115 //      ----------------------------------------------------------------------------------------------------
00116 
00117 void ofxGuiGlobals::saveToXml()
00118 {
00119         int id = mXml.addTag("STYLE");
00120 
00121         mXml.setValue("STYLE:HEADFONT",         mHeadFontName, id);
00122         mXml.setValue("STYLE:HEADSIZE",         mHeadFontSize, id);
00123         mXml.setValue("STYLE:HEADXOFF",         mHeadFontXOffset, id);
00124         mXml.setValue("STYLE:HEADYOFF",         mHeadFontYOffset, id);
00125         mXml.setValue("STYLE:HEADHEIGHT",       mHeadFontHeight, id);
00126 
00127         mXml.setValue("STYLE:PARAMFONT",        mParamFontName, id);
00128         mXml.setValue("STYLE:PARAMSIZE",        mParamFontSize, id);
00129         mXml.setValue("STYLE:PARAMXOFF",        mParamFontXOffset, id);
00130         mXml.setValue("STYLE:PARAMYOFF",        mParamFontYOffset, id);
00131         mXml.setValue("STYLE:PARAMHEIGHT",      mParamFontHeight, id);
00132 
00133         mXml.setValue("STYLE:BUTTONXTEXT",      mButtonXText, id);
00134         mXml.setValue("STYLE:BUTTONYTEXT",      mButtonYText, id);
00135         
00136         mXml.setValue("STYLE:FILESXTEXT",       mFilesXText, id);
00137         mXml.setValue("STYLE:FILESYTEXT",       mFilesYText, id);
00138         
00139         mXml.setValue("STYLE:POINTSIZE",        mPointSize, id);
00140         
00141         mXml.setValue("STYLE:KNOBSIZE",         mKnobSize, id);
00142         
00143         mXml.setValue("STYLE:COVERCOLOR",       mCoverColor.toString(kofxGui_Color_RGBA), id);
00144         mXml.setValue("STYLE:TEXTCOLOR",        mTextColor.toString(kofxGui_Color_RGBA), id);
00145         mXml.setValue("STYLE:BORDERCOLOR",      mBorderColor.toString(kofxGui_Color_RGBA), id);
00146         mXml.setValue("STYLE:FRAMECOLOR",       mFrameColor.toString(kofxGui_Color_RGBA), id);
00147         mXml.setValue("STYLE:SLIDERCOLOR",      mSliderColor.toString(kofxGui_Color_RGBA), id);
00148         mXml.setValue("STYLE:AXISCOLOR",        mAxisColor.toString(kofxGui_Color_RGBA), id);
00149         mXml.setValue("STYLE:HANDLECOLOR",      mHandleColor.toString(kofxGui_Color_RGBA), id);
00150         mXml.setValue("STYLE:BUTTONCOLOR",      mButtonColor.toString(kofxGui_Color_RGBA), id);
00151         mXml.setValue("STYLE:CURVECOLOR",       mCurveColor.toString(kofxGui_Color_RGBA), id);
00152         mXml.setValue("STYLE:SCOPECOLOR",       mScopeColor.toString(kofxGui_Color_RGBA), id);
00153         mXml.setValue("STYLE:ACTIVECOLOR",      mMatrixColor.toString(kofxGui_Color_RGBA), id);
00154 }
00155 
00156 //      ----------------------------------------------------------------------------------------------------
00157 
00158 void ofxGuiGlobals::loadFonts()
00159 {
00160         mHeadFont.loadFont(mHeadFontName, mHeadFontSize, true, true);
00161         mParamFont.loadFont(mParamFontName, mParamFontSize, true, true);
00162 }
00163 
00164 //      ----------------------------------------------------------------------------------------------------
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines