GME  13
GraphicsUtil.h
Go to the documentation of this file.
00001 #ifndef GME_GraphicsUtil_h
00002 #define GME_GraphicsUtil_h
00003 
00004 #include <map>
00005 #include <vector>
00006 
00007 typedef CTypedPtrList<CPtrList, Gdiplus::Font*>                                 GdipFontList;
00008 typedef CTypedPtrMap<CMapPtrToPtr, void*, Gdiplus::Pen*>                GdipPenTable;
00009 typedef CTypedPtrMap<CMapPtrToPtr, void*, Gdiplus::SolidBrush*> GdipBrushTable;
00010 
00011 
00012 class CArrowHead
00013 {
00014 public:
00015         CArrowHead(int dir, const std::vector<CPoint>& coords);
00016         virtual ~CArrowHead();
00017 public:
00018         std::vector<CPoint> path;
00019         int dir;
00020 
00021 public:
00022         CRect GetLineCoords(long index1, long index2, double angle, bool skew);
00023         virtual void Draw(Gdiplus::Graphics* gdip, Gdiplus::Pen* pen, Gdiplus::Brush* brush, const CPoint& tip, bool bPen,
00024                                           double angle, bool bold);
00025 };
00026 
00027 class CBulletArrowHead: public CArrowHead
00028 {
00029 public:
00030         CBulletArrowHead(int dir, const std::vector<CPoint>& coords);
00031         virtual ~CBulletArrowHead();
00032 
00033 public:
00034         virtual void Draw(Gdiplus::Graphics* gdip, Gdiplus::Pen* pen, Gdiplus::Brush* brush, const CPoint& tip, bool bPen,
00035                                           double angle, bool bold);
00036 };
00037 
00038 class CGraphics
00039 {
00040 public:
00041         CGraphics();
00042         ~CGraphics();
00043 
00044 public:
00045         std::map<CString,Gdiplus::Pen*> m_mapGdipPens;
00046         GdipBrushTable gdipBrushes;
00047         CFont* normalFonts[GME_FONT_KIND_NUM];
00048         CFont* semiboldFonts[GME_FONT_KIND_NUM];
00049         CFont* boldFonts[GME_FONT_KIND_NUM];
00050         Gdiplus::Font* normalGdipFonts[GME_FONT_KIND_NUM];
00051         Gdiplus::Font* semiboldGdipFonts[GME_FONT_KIND_NUM];
00052         Gdiplus::Font* boldGdipFonts[GME_FONT_KIND_NUM];
00053         CArrowHead* arrows[GME_DIRECTION_NUM];
00054         CArrowHead* diamonds[GME_DIRECTION_NUM];
00055         CArrowHead* apexes[GME_DIRECTION_NUM];
00056         CArrowHead* bullets[GME_DIRECTION_NUM];
00057         CArrowHead* leftHalfArrows[GME_DIRECTION_NUM];
00058         CArrowHead* rightHalfArrows[GME_DIRECTION_NUM];
00059 
00060 public:
00061         void    Initialize(void);
00062         void    Uninitialize(void);
00063 
00064         Gdiplus::Pen* GetGdipPen2(Gdiplus::Graphics* gdip, COLORREF color, GMEConnLineType lineType = GME_LINE_SOLID,
00065                                                           bool isViewMagnified = false, int width = 1);
00066         Gdiplus::Pen* GetGdipPen(Gdiplus::Graphics* gdip, COLORREF color, bool isPrinting, GMEConnLineType lineType = GME_LINE_SOLID,
00067                                                          bool isViewMagnified = false, int width = 1);
00068         Gdiplus::SolidBrush* GetGdipBrush(COLORREF color);
00069         Gdiplus::Font* GetGdipFont(GMEFontKind kind);
00070         Gdiplus::Font* GetGdipFont(int kindsize, bool bold = false, bool semibold = false);
00071         void DeleteBrushes(GdipBrushTable& gdipBrushTable);
00072         void CreateFonts(CFont** font, Gdiplus::Font** gdipFont, int boldness);
00073         void DrawGrid(Gdiplus::Graphics* gdip, int xSpace, int ySpace, int maxx, int maxy, COLORREF color = GME_GRID_COLOR);
00074         void DrawConnection(Gdiplus::Graphics* gdip, const CPointList& points, const std::vector<long>& customizedEdgeIndexes,
00075                                                 COLORREF color, GMEConnLineType lineType, int srcEnd, int dstEnd, bool isViewMagnified,
00076                                                 bool drawBullets, int width = 1);
00077         void DrawArrow(Gdiplus::Graphics* gdip, Gdiplus::Pen* pen, Gdiplus::Brush* brush,
00078                                    const CPoint& beforeLast, const CPoint& last, int iEnd, bool bold);
00079         void DrawGdipText(Gdiplus::Graphics* gdip, const CString& txt, const CPoint& pt, Gdiplus::Font* font, COLORREF color,
00080                                           int align);
00081         Gdiplus::RectF MeasureText2(Gdiplus::Graphics* gdip, const CString& txt, const CPoint& pt, Gdiplus::Font* font);
00082         CSize MeasureText(Gdiplus::Graphics* gdip, const CString& txt, const CPoint& pt, Gdiplus::Font* font);
00083 };
00084 
00085 extern CGraphics graphics;
00086 
00087 #endif // whole file
00088