Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef XAP_DIALOG_FONTCHOOSER_H
00024 #define XAP_DIALOG_FONTCHOOSER_H
00025
00026
00027
00028
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;
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
00091
00092
00093
00094
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;
00119 std::string m_sColorBackground;
00120 std::string m_sFontFamily;
00121 std::string m_sFontSize;
00122 std::string m_sFontWeight;
00123 std::string m_sFontStyle;
00124 std::string m_sColor;
00125 std::string m_sBGColor;
00126 bool m_bUnderline;
00127 bool m_bOverline;
00128 bool m_bStrikeout;
00129 bool m_bTopline;
00130 bool m_bBottomline;
00131 bool m_bHidden;
00132 bool m_bSuperScript;
00133 bool m_bSubScript;
00134 std::string m_sTextTransform;
00135
00136 PropMap m_mapProps;
00137 XAP_Preview_FontPreview * m_pFontPreview;
00138
00139 bool m_bChangedFontFamily;
00140 bool m_bChangedFontSize;
00141 bool m_bChangedFontWeight;
00142 bool m_bChangedFontStyle;
00143 bool m_bChangedColor;
00144 bool m_bChangedBGColor;
00145 bool m_bChangedUnderline;
00146 bool m_bChangedOverline;
00147 bool m_bChangedStrikeOut;
00148 bool m_bChangedTopline;
00149 bool m_bChangedBottomline;
00150 bool m_bChangedHidden;
00151 bool m_bChangedSuperScript;
00152 bool m_bChangedSubScript;
00153 bool m_bChangedTextTransform;
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