• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

xap_Dlg_FontChooser.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 
00003 /* AbiSource Application Framework
00004  * Copyright (C) 1998 AbiSource, Inc.
00005  * Copyright (C) 2009 Hubert Figuiere
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020  * 02110-1301 USA.
00021  */
00022 
00023 #ifndef XAP_DIALOG_FONTCHOOSER_H
00024 #define XAP_DIALOG_FONTCHOOSER_H
00025 
00026 /* pre-emptive dismissal; ut_types.h is needed by just about everything,
00027  * so even if it's commented out in-file that's still a lot of work for
00028  * the preprocessor to do...
00029  */
00030 #ifndef UT_TYPES_H
00031 #include "ut_types.h"
00032 #endif
00033 
00034 #include <map>
00035 #include <string>
00036 #include <vector>
00037 
00038 #include "ut_string.h"
00039 
00040 #include "xap_Dialog.h"
00041 #include "xap_Preview.h"
00042 #include "gr_Graphics.h"
00043 
00044 class GR_Graphics;
00045 class XAP_Preview_FontPreview; //forward, see below
00046 
00047 /*****************************************************************/
00048 
00049 class ABI_EXPORT XAP_Dialog_FontChooser : public XAP_Dialog_NonPersistent
00050 {
00051 public:
00052     typedef std::map<std::string,std::string> PropMap;
00053 
00054     XAP_Dialog_FontChooser(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id);
00055     virtual ~XAP_Dialog_FontChooser(void);
00056 
00057     virtual void                    runModal(XAP_Frame * pFrame) = 0;
00058 
00059     typedef enum { a_OK, a_CANCEL, a_YES, a_NO }    tAnswer;
00060 
00061     void setDrawString (const UT_UCSChar * str);
00062 
00063     const UT_UCSChar * getDrawString () const
00064       {
00065         return m_drawString;
00066       }
00067 
00068     void                            addOrReplaceVecProp(const std::string & pszProp,
00069                                                         const std::string & pszVal);
00070     void                            event_previewExposed(const UT_UCSChar * pszChars);
00071     void                            event_previewClear(void);
00072     std::string                     getVal(const std::string & sProp) const;
00073     void                            setAllPropsFromVec(const std::vector<std::string> & vProps);
00074 
00075     void                            setGraphicsContext(GR_Graphics * pGraphics);
00076     void                            setFontFamily(const std::string& sFontFamily);
00077     void                            setFontSize(const std::string& sFontSize);
00078     void                            setFontWeight(const std::string& sFontWeight);
00079     void                            setFontStyle(const std::string& sFontStyle);
00080     void                            setColor(const std::string& sColor);
00081     void                            setBGColor(const std::string& sBGColor);
00082     void                            setFontDecoration(bool bUnderline, bool bOverline, bool bStrikeOut, bool bTopline, bool bBottomline);
00083     void                            setHidden(bool bHidden);
00084     void                            setSuperScript(bool bSuperScript);
00085     void                            setSubScript(bool bSubScript);
00086     void                            setBackGroundColor (const gchar * pBackGroundColor);
00087     void                            setTextTransform (const std::string& pTextTransform);
00088 
00089     XAP_Dialog_FontChooser::tAnswer getAnswer(void) const;
00090 
00091     // the following return TRUE iff the user changed the value
00092     // of the control in the dialog.  they also return the value
00093     // of the field in the supplied argument w/o regard to whether
00094     // they changed it or not.  this value is a static string in
00095     // the dialog and must be valid only until the dialog is released.
00096     bool                            didPropChange(const std::string & v1, const std::string & v2) const;
00097     bool                            getChangedTextTransform(std::string&) const;
00098     bool                            getChangedFontFamily(std::string&) const;
00099     bool                            getChangedFontSize(std::string&) const;
00100     bool                            getChangedFontWeight(std::string&) const;
00101     bool                            getChangedFontStyle(std::string&) const;
00102     bool                            getChangedColor(std::string&) const;
00103     bool                            getChangedBGColor(std::string&) const;
00104     bool                            getChangedUnderline(bool * pbUnderline) const;
00105     bool                            getChangedOverline(bool * pbOverline) const;
00106     bool                            getChangedStrikeOut(bool * pbStrikeOut) const;
00107     bool                            getChangedTopline(bool * pbTopline) const;
00108     bool                            getChangedBottomline(bool * pbBottomline) const;
00109     bool                            getChangedHidden(bool * pbHidden) const;
00110     bool                            getChangedSuperScript(bool * pbSuperScript) const;
00111     bool                            getChangedSubScript(bool * pbSubScript) const;
00112 
00113 protected:
00114     void                            _createFontPreviewFromGC(GR_Graphics * gc,
00115                                                              UT_uint32 width,
00116                                                              UT_uint32 height);
00117 
00118     XAP_Dialog_FontChooser::tAnswer m_answer;
00119     GR_Graphics *                   m_pGraphics;            /* input */
00120     std::string                     m_sColorBackground;
00121     std::string                     m_sFontFamily;          /* input/output */
00122     std::string                     m_sFontSize;            /* input/output */
00123     std::string                     m_sFontWeight;          /* input/output */
00124     std::string                     m_sFontStyle;           /* input/output */
00125     std::string                     m_sColor;               /* input/output */
00126     std::string                     m_sBGColor;             /* input/output */
00127     bool                            m_bUnderline;           /* input/output */
00128     bool                            m_bOverline;            /* input/output */
00129     bool                            m_bStrikeout;           /* input/output */
00130     bool                            m_bTopline;             /* input/output */
00131     bool                            m_bBottomline;          /* input/output */
00132     bool                            m_bHidden;              /* input/output */
00133     bool                            m_bSuperScript;         /* input/output */
00134     bool                            m_bSubScript;           /* input/output */
00135     std::string                     m_sTextTransform;       /* input/output */
00136 
00137     PropMap                         m_mapProps; // Holds the current
00138     XAP_Preview_FontPreview *       m_pFontPreview;
00139 
00140     bool                            m_bChangedFontFamily;   /* output */
00141     bool                            m_bChangedFontSize;     /* output */
00142     bool                            m_bChangedFontWeight;   /* output */
00143     bool                            m_bChangedFontStyle;    /* output */
00144     bool                            m_bChangedColor;        /* output */
00145     bool                            m_bChangedBGColor;      /* output */
00146     bool                            m_bChangedUnderline;    /* output */
00147     bool                            m_bChangedOverline;     /* output */
00148     bool                            m_bChangedStrikeOut;    /* output */
00149     bool                            m_bChangedTopline;      /* output */
00150     bool                            m_bChangedBottomline;   /* output */
00151     bool                            m_bChangedHidden;       /* output */
00152     bool                            m_bChangedSuperScript;  /* output */
00153     bool                            m_bChangedSubScript;    /* output */
00154     bool                            m_bChangedTextTransform;    /* output */
00155 
00156     UT_UCSChar *                    m_drawString;
00157 };
00158 
00159 class ABI_EXPORT XAP_Preview_FontPreview  : public XAP_Preview
00160 {
00161 public:
00162     explicit XAP_Preview_FontPreview(GR_Graphics * gc, const gchar * pszClrBackgound);
00163     virtual ~XAP_Preview_FontPreview(void);
00164     void setVecProperties( const XAP_Dialog_FontChooser::PropMap * vFontProps);
00165     std::string getVal(const std::string &) const;
00166     void draw(const UT_Rect *clip=NULL);
00167     void setDrawString( const UT_UCSChar * pszChars) {m_pszChars = pszChars;}
00168     void clearScreen(void);
00169 
00170 
00171 protected:
00172     const XAP_Dialog_FontChooser::PropMap * m_mapProps;
00173     UT_RGBColor m_clrBackground;
00174     const UT_UCSChar * m_pszChars;
00175 
00176 private:
00177 
00178     XAP_Preview_FontPreview();
00179     XAP_Preview_FontPreview(const XAP_Preview_FontPreview &other);
00180     XAP_Preview_FontPreview& operator=(const XAP_Preview_FontPreview & other);
00181 
00182     GR_Font * m_pFont;
00183 
00184     UT_sint32 m_iAscent;
00185     UT_sint32 m_iDescent;
00186     UT_sint32 m_iHeight;
00187 };
00188 
00189 #endif /* XAP_DIALOG_FONTCHOOSER_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1