00001
00002
00003
00004
00005
00006
00007
00008 #ifndef DecoratorUtil_h
00009 #define DecoratorUtil_h
00010
00011 #pragma warning( disable : 4786 )
00012
00013 #include "StdAfx.h"
00014
00015 #include <vector>
00016 #include <map>
00017
00018 #include <GmeApi.h>
00019
00020 #include <DecoratorDefs.h>
00021
00022 #include "PathUtil.h"
00023
00024 namespace DecoratorSDK
00025 {
00026 class BitmapBase;
00027 class Facilities;
00028
00029 class BackgroundTile;
00030 typedef std::vector<BackgroundTile> TileVector;
00031
00032 Facilities& getFacilities();
00033
00034
00035
00036
00037
00038
00039
00040 class Facilities
00041 {
00042 private :
00043 CComPtr<IMgaProject> m_spProject;
00044 PathUtil m_pathUtil;
00045 CDC m_nullDC;
00046 Gdiplus::Graphics* m_gdip;
00047 Gdiplus::SmoothingMode m_eEdgeAntiAlias;
00048 Gdiplus::TextRenderingHint m_eFontAntiAlias;
00049
00050 std::map<CString,BitmapBase*> m_mapBitmaps;
00051 std::map<CString,TileVector*> m_mapTileVectors;
00052 std::map<int,GdipFont*> m_mapFonts;
00053 std::map<CString,Gdiplus::Pen*> m_mapPens;
00054 std::map<CString,Gdiplus::SolidBrush*> m_mapBrushes;
00055
00056 public :
00057 Facilities();
00058 ~Facilities();
00059
00060 bool loadPathes(IMgaProject* pProject, bool bRefresh = false);
00061 bool arePathesValid() const;
00062 std::vector<CString> getPathes(void) const;
00063 Gdiplus::Graphics* getGraphics(void) const;
00064 CDC* getCDC(void);
00065
00066 BitmapBase* getBitmap( const CString& strName );
00067 BitmapBase* getBitmapT( const CString& strName, COLORREF crTransparent );
00068 BitmapBase* getBitmapB( const CString& strName, COLORREF crBackground );
00069 BitmapBase* getBitmapTB( const CString& strName, COLORREF crTransparent, COLORREF crBackground );
00070 BitmapBase* getMaskedBitmap( const CString& strName, COLORREF crTransparent, COLORREF crBackground );
00071 BitmapBase* getMaskedBitmap( UINT nResID, COLORREF crTransparent, COLORREF crBackground );
00072
00073 void addTileVector( const CString& strName, TileVector* vecTiles );
00074 TileVector* getTileVector( const CString& strName ) const;
00075
00076 void createFont( int iFontKey, const CString& strKind, int iBoldness, bool bItalics, int iSize );
00077 GdipFont* GetFont( int iFontKey ) const;
00078 Gdiplus::Pen* GetPen( COLORREF crColor, int iWidth = 1 );
00079 Gdiplus::SolidBrush* GetBrush( COLORREF crColor );
00080
00081 bool getPreference( CComPtr<IMgaFCO> spFCO, const CString& strName, CString& strValue ) const;
00082 bool getPreference( CComPtr<IMgaFCO> spFCO, const CString& strName, long& lValue, bool bInHexa = false ) const;
00083 bool getPreference( CComPtr<IMgaFCO> spFCO, const CString& strName, COLORREF& crValue ) const;
00084 bool getPreference( CComPtr<IMgaFCO> spFCO, const CString& strName, ELocation& eValue ) const;
00085 bool getPreference( CComPtr<IMgaFCO> spFCO, const CString& strName, bool& bValue ) const;
00086 bool getPreference( CComPtr<IMgaMetaFCO> spMetaFCO, const CString& strName, CString& strValue ) const;
00087 bool getPreference( CComPtr<IMgaMetaFCO> spMetaFCO, const CString& strName, long& lValue, bool bInHexa = false ) const;
00088 bool getPreference( CComPtr<IMgaMetaFCO> spMetaFCO, const CString& strName, COLORREF& crValue ) const;
00089 bool getPreference( CComPtr<IMgaMetaFCO> spMetaFCO, const CString& strName, ELocation& eValue ) const;
00090 bool getPreference( CComPtr<IMgaMetaFCO> spMetaFCO, const CString& strName, bool& bValue ) const;
00091 bool getPreference( CComPtr<IMgaFCO> spFCO, CComPtr<IMgaMetaFCO> spMetaFCO, const CString& strName, CString& strValue ) const;
00092 bool getPreference( CComPtr<IMgaFCO> spFCO, CComPtr<IMgaMetaFCO> spMetaFCO, const CString& strName, long& lValue, bool bInHexa = false ) const;
00093 bool getPreference( CComPtr<IMgaFCO> spFCO, CComPtr<IMgaMetaFCO> spMetaFCO, const CString& strName, COLORREF& crValue ) const;
00094 bool getPreference( CComPtr<IMgaFCO> spFCO, CComPtr<IMgaMetaFCO> spMetaFCO, const CString& strName, ELocation& eValue ) const;
00095 bool getPreference( CComPtr<IMgaFCO> spFCO, CComPtr<IMgaMetaFCO> spMetaFCO, const CString& strName, bool& bValue ) const;
00096
00097 EPrefStatus getPreferenceStatus( CComPtr<IMgaFCO> spFCO, const CString& strName ) const;
00098
00099 bool getAttribute( CComPtr<IMgaFCO> spFCO, const CString& strName, CString& strValue ) const;
00100 bool getAttribute( CComPtr<IMgaFCO> spFCO, const CString& strName, bool& bValue ) const;
00101 bool getAttribute( CComPtr<IMgaFCO> spFCO, const CString& strName, long& lValue ) const;
00102 bool getAttribute( CComPtr<IMgaFCO> spFCO, const CString& strName, double& fValue ) const;
00103 bool setAttribute( CComPtr<IMgaFCO> spFCO, const CString& strName, const CString& strValue ) const;
00104 bool setAttribute( CComPtr<IMgaFCO> spFCO, const CString& strName, bool bValue ) const;
00105 bool setAttribute( CComPtr<IMgaFCO> spFCO, const CString& strName, long lValue ) const;
00106 bool setAttribute( CComPtr<IMgaFCO> spFCO, const CString& strName, double fValue ) const;
00107
00108 bool getMetaFCO(const CComPtr<IMgaMetaPart> &metaPart, CComPtr<IMgaMetaFCO> &metaFco) const;
00109
00110 CSize MeasureText( Gdiplus::Graphics* gdip, GdipFont* pFont, const CString& strText) const;
00111 CSize MeasureText( Gdiplus::Graphics* gdip, Gdiplus::Font* pFont, const CString& strText) const;
00112 void DrawString( Gdiplus::Graphics* gdip, const CString& strText, const CRect& crBounds, GdipFont* pFont,
00113 COLORREF crColor, int iAlign, int iLength = -1, const CString& strPre = "",
00114 const CString& strPost = "", bool bPeriods = true ) const;
00115 void DrawString( Gdiplus::Graphics* gdip, const CString& strText, const CRect& crBounds, Gdiplus::Font* pFont,
00116 COLORREF crColor, int iAlign, int iLength = -1, const CString& strPre = "",
00117 const CString& strPost = "", bool bPeriods = true ) const;
00118 void DrawRect( Gdiplus::Graphics* gdip, const CRect& cRect, COLORREF crColor, int iWidth = 1,
00119 bool bRoundRect = false, int iCornerRadius = 0 ) const;
00120 void DrawBox( Gdiplus::Graphics* gdip, const CRect& cRect, COLORREF crColor, int iDepth,
00121 bool bRoundRect = false, int iCornerRadius = 0 ) const;
00122 COLORREF ShiftColor( COLORREF crColor, int iShift ) const;
00123 double Deg2Rad( long deg ) const;
00124
00125 std::vector<CString> wrapString( const CString& str, int iWrap, int iMax ) const;
00126 CString getStereotyped( const CString& str ) const;
00127
00128 private :
00129 BitmapBase* getBitmap( const CString& strName, bool bhasTC, COLORREF crTC, bool bhasBC, COLORREF crBC,
00130 bool masked = false, UINT nResID = 0 );
00131
00132 };
00133
00134 };
00135
00136 #endif // DecoratorUtil_h