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 #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;
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
00092
00093
00094
00095
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;
00120 std::string m_sColorBackground;
00121 std::string m_sFontFamily;
00122 std::string m_sFontSize;
00123 std::string m_sFontWeight;
00124 std::string m_sFontStyle;
00125 std::string m_sColor;
00126 std::string m_sBGColor;
00127 bool m_bUnderline;
00128 bool m_bOverline;
00129 bool m_bStrikeout;
00130 bool m_bTopline;
00131 bool m_bBottomline;
00132 bool m_bHidden;
00133 bool m_bSuperScript;
00134 bool m_bSubScript;
00135 std::string m_sTextTransform;
00136
00137 PropMap m_mapProps;
00138 XAP_Preview_FontPreview * m_pFontPreview;
00139
00140 bool m_bChangedFontFamily;
00141 bool m_bChangedFontSize;
00142 bool m_bChangedFontWeight;
00143 bool m_bChangedFontStyle;
00144 bool m_bChangedColor;
00145 bool m_bChangedBGColor;
00146 bool m_bChangedUnderline;
00147 bool m_bChangedOverline;
00148 bool m_bChangedStrikeOut;
00149 bool m_bChangedTopline;
00150 bool m_bChangedBottomline;
00151 bool m_bChangedHidden;
00152 bool m_bChangedSuperScript;
00153 bool m_bChangedSubScript;
00154 bool m_bChangedTextTransform;
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