• 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., 59 Temple Place - Suite 330, Boston, MA
00020  * 02111-1307, 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 
00037 #include "ut_string.h"
00038 
00039 #include "xap_Dialog.h"
00040 #include "xap_Preview.h"
00041 #include "gr_Graphics.h"
00042 
00043 class GR_Graphics;
00044 class XAP_Preview_FontPreview; //forward, see below
00045 
00046 /*****************************************************************/
00047 
00048 class ABI_EXPORT XAP_Dialog_FontChooser : public XAP_Dialog_NonPersistent
00049 {
00050 public:
00051     typedef std::map<std::string,std::string> PropMap;
00052 
00053     XAP_Dialog_FontChooser(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id);
00054     virtual ~XAP_Dialog_FontChooser(void);
00055 
00056     virtual void                    runModal(XAP_Frame * pFrame) = 0;
00057 
00058     typedef enum { a_OK, a_CANCEL, a_YES, a_NO }    tAnswer;
00059 
00060     void setDrawString (const UT_UCSChar * str);
00061 
00062     const UT_UCSChar * getDrawString ()
00063       {
00064         return m_drawString;
00065       }
00066 
00067     void                            addOrReplaceVecProp(const std::string & pszProp,
00068                                                         const std::string & pszVal);
00069     void                            event_previewExposed(const UT_UCSChar * pszChars);
00070     void                            event_previewClear(void);
00071     const std::string               getVal(const std::string & sProp) const;
00072     void                            setAllPropsFromVec(const UT_Vector & vProps);
00073 
00074     void                            setGraphicsContext(GR_Graphics * pGraphics);
00075     void                            setFontFamily(const std::string& sFontFamily);
00076     void                            setFontSize(const std::string& sFontSize);
00077     void                            setFontWeight(const std::string& sFontWeight);
00078     void                            setFontStyle(const std::string& sFontStyle);
00079     void                            setColor(const std::string& sColor);
00080     void                            setBGColor(const std::string& sBGColor);
00081     void                            setFontDecoration(bool bUnderline, bool bOverline, bool bStrikeOut, bool bTopline, bool bBottomline);
00082     void                            setHidden(bool bHidden);
00083     void                            setSuperScript(bool bSuperScript);
00084     void                            setSubScript(bool bSubScript);
00085     void                            setBackGroundColor (const gchar * pBackGroundColor);
00086     void                            setTextTransform (const std::string& pTextTransform);
00087 
00088     XAP_Dialog_FontChooser::tAnswer getAnswer(void) const;
00089 
00090     // the following return TRUE iff the user changed the value
00091     // of the control in the dialog.  they also return the value
00092     // of the field in the supplied argument w/o regard to whether
00093     // they changed it or not.  this value is a static string in
00094     // the dialog and must be valid only until the dialog is released.
00095     bool                            didPropChange(const std::string & v1, const std::string & v2) const;
00096     bool                            getChangedTextTransform(const gchar ** pszTextTransform) const;
00097     bool                            getChangedFontFamily(const gchar ** pszFontFamily) const;
00098     bool                            getChangedFontSize(const gchar ** pszFontSize) const;
00099     bool                            getChangedFontWeight(const gchar ** pszFontWeight) const;
00100     bool                            getChangedFontStyle(const gchar ** pszFontStyle) const;
00101     bool                            getChangedColor(const gchar ** pszColor) const;
00102     bool                            getChangedBGColor(const gchar ** pszColor) const;
00103     bool                            getChangedUnderline(bool * pbUnderline) const;
00104     bool                            getChangedOverline(bool * pbOverline) const;
00105     bool                            getChangedStrikeOut(bool * pbStrikeOut) const;
00106     bool                            getChangedTopline(bool * pbTopline) const;
00107     bool                            getChangedBottomline(bool * pbBottomline) const;
00108     bool                            getChangedHidden(bool * pbHidden) const;
00109     bool                            getChangedSuperScript(bool * pbSuperScript) const;
00110     bool                            getChangedSubScript(bool * pbSubScript) const;
00111 
00112 protected:
00113     void                            _createFontPreviewFromGC(GR_Graphics * gc,
00114                                                              UT_uint32 width,
00115                                                              UT_uint32 height);
00116 
00117     XAP_Dialog_FontChooser::tAnswer m_answer;
00118     GR_Graphics *                   m_pGraphics;            /* input */
00119     std::string                     m_sColorBackground;
00120     std::string                     m_sFontFamily;          /* input/output */
00121     std::string                     m_sFontSize;            /* input/output */
00122     std::string                     m_sFontWeight;          /* input/output */
00123     std::string                     m_sFontStyle;           /* input/output */
00124     std::string                     m_sColor;               /* input/output */
00125     std::string                     m_sBGColor;             /* input/output */
00126     bool                            m_bUnderline;           /* input/output */
00127     bool                            m_bOverline;            /* input/output */
00128     bool                            m_bStrikeout;           /* input/output */
00129     bool                            m_bTopline;             /* input/output */
00130     bool                            m_bBottomline;          /* input/output */
00131     bool                            m_bHidden;              /* input/output */
00132     bool                            m_bSuperScript;         /* input/output */
00133     bool                            m_bSubScript;           /* input/output */
00134     std::string                     m_sTextTransform;       /* input/output */
00135 
00136     PropMap                         m_mapProps; // Holds the current
00137     XAP_Preview_FontPreview *       m_pFontPreview;
00138 
00139     bool                            m_bChangedFontFamily;   /* output */
00140     bool                            m_bChangedFontSize;     /* output */
00141     bool                            m_bChangedFontWeight;   /* output */
00142     bool                            m_bChangedFontStyle;    /* output */
00143     bool                            m_bChangedColor;        /* output */
00144     bool                            m_bChangedBGColor;      /* output */
00145     bool                            m_bChangedUnderline;    /* output */
00146     bool                            m_bChangedOverline;     /* output */
00147     bool                            m_bChangedStrikeOut;    /* output */
00148     bool                            m_bChangedTopline;      /* output */
00149     bool                            m_bChangedBottomline;   /* output */
00150     bool                            m_bChangedHidden;       /* output */
00151     bool                            m_bChangedSuperScript;  /* output */
00152     bool                            m_bChangedSubScript;    /* output */
00153     bool                            m_bChangedTextTransform;    /* output */
00154 
00155     UT_UCSChar *                    m_drawString;
00156 };
00157 
00158 class ABI_EXPORT XAP_Preview_FontPreview  : public XAP_Preview
00159 {
00160 public:
00161     explicit XAP_Preview_FontPreview(GR_Graphics * gc, const gchar * pszClrBackgound);
00162     virtual ~XAP_Preview_FontPreview(void);
00163     void setVecProperties( const XAP_Dialog_FontChooser::PropMap * vFontProps);
00164     const std::string getVal(const std::string &);
00165     void draw(const UT_Rect *clip=NULL);
00166     void setDrawString( const UT_UCSChar * pszChars) {m_pszChars = pszChars;}
00167     void clearScreen(void);
00168 
00169 
00170 protected:
00171     const XAP_Dialog_FontChooser::PropMap * m_mapProps;
00172     UT_RGBColor m_clrBackground;
00173     const UT_UCSChar * m_pszChars;
00174 
00175 private:
00176 
00177     XAP_Preview_FontPreview();
00178     XAP_Preview_FontPreview(const XAP_Preview_FontPreview &other);
00179     XAP_Preview_FontPreview& operator=(const XAP_Preview_FontPreview & other);
00180 
00181     GR_Font * m_pFont;
00182 
00183     UT_sint32 m_iAscent;
00184     UT_sint32 m_iDescent;
00185     UT_sint32 m_iHeight;
00186 };
00187 
00188 #endif /* XAP_DIALOG_FONTCHOOSER_H */

Generated on Mon May 28 2012 for AbiWord by  doxygen 1.7.1