home *** CD-ROM | disk | FTP | other *** search
- // -------------------------------------------------------------------------
- // Copyright @ 1997 TCK Software, Incorporated
- // All Rights Reserved
- // -------------------------------------------------------------------------
- #ifndef __VFUTIL_H__
- #define __VFUTIL_H__
-
- #include <afxTempl.h>
- #include <afxdisp.h> // MFC OLE automation classes
-
- #ifdef VF_STATIC
- #undef AFX_EXT_CLASS
- #define AFX_EXT_CLASS
- #endif
-
- #ifndef COLOR_CUSTOM
- #define COLOR_CUSTOM -1 // For specifying custom colors
- #endif
-
- // --- Not actually used yet ---
- #ifndef COLOR_DEFAULT
- #define COLOR_DEFAULT -2 // For specifying the default color
- #endif
-
- // -------------------------------------------------------------------------
- // Utility Functions
- // -------------------------------------------------------------------------
- AFX_EXT_CLASS CString VfuGetLastErrorText(DWORD error=0);
- AFX_EXT_CLASS void VfuParseList(LPCTSTR xString, CStringArray &xArray,
- _TCHAR xToken=_T(';'));
- AFX_EXT_CLASS DROPEFFECT VfuDoDragDrop(LPCTSTR szText,
- DROPEFFECT dropEffect=DROPEFFECT_COPY,
- CLIPFORMAT=CF_TEXT);
- AFX_EXT_CLASS BOOL VfuGetDropText(COleDataObject* pDataObject,
- CString &rString, CLIPFORMAT=CF_TEXT);
- AFX_EXT_CLASS DROPEFFECT VfuDoDragDropData(LPVOID pData, int nSize,
- DROPEFFECT dropEffect=DROPEFFECT_COPY,
- CLIPFORMAT=CF_TEXT);
- AFX_EXT_CLASS BOOL VfuGetDropData(COleDataObject* pDataObject,
- LPVOID pData, int nSize,
- CLIPFORMAT=CF_TEXT);
- AFX_EXT_CLASS void VfuDraw3dRect(CDC *pDC, LPCRECT lpRect, COLORREF clrTopLeft,
- COLORREF clrBottomRight);
-
- // -------------------------------------------------------------------------
- // VClipObj makes if easier to add to a clipping region, the revert back
- // -------------------------------------------------------------------------
- class AFX_EXT_CLASS VClipObj
- {
- protected:
- CDC* m_pDC; // Device context
- BOOL m_bClipSet; // Do we have a clip region set by us?
- BOOL m_bHaveOldRgn; // Do we have an old clipping region
- HRGN m_hOldRgn; // Handle to old clipping region
- public:
- VClipObj(); // Constructor
- VClipObj(CDC *pDC, LPRECT pRect); // Constructor with args
- ~VClipObj(); // Destructor
-
- void Set(CDC *pDC, LPRECT pRect); // Set the clipping region
- void Set(CDC *pDC, LPPOINT lpPoints, int nCount, int nMode);
- void Remove(); // Remove/Reset clipping region
- };
-
- // -------------------------------------------------------------------------
- // VColor makes if easier to switch between custom and system colors
- // within your code. Just use a VColor!
- // -------------------------------------------------------------------------
- class AFX_EXT_CLASS VColor : public CObject
- {
- protected:
- int m_nColorIdx; // Id of system color or COLOR_CUSTOM
- COLORREF m_color; // Custom color when using COLOR_CUSTOM
- public:
- DECLARE_SERIAL(VColor);
- VColor() { m_nColorIdx = COLOR_CUSTOM; m_color = RGB(0,0,0); }
- ~VColor() {}; // Destructor
-
- int ColorIdx() { return m_nColorIdx; }
- void ColorIdx(int nClrIdx) { m_nColorIdx = nClrIdx; }
- void CustomRGB(COLORREF clr) { m_color = clr; }
- void UseCustomRGB(COLORREF clr)
- { m_color = clr; m_nColorIdx = COLOR_CUSTOM; }
-
- COLORREF CustomRGB() { return m_color; }
- COLORREF GetRGB()
- { return (m_nColorIdx == COLOR_CUSTOM) ? m_color : GetSysColor(m_nColorIdx); }
-
- void SetColor(LPCTSTR szString); // Sets color using the string value
- CString ColorString(); // Returns red;green;blue or WINDOW, etc.
- CString ColorIdxString() { return ColorIdxString(m_nColorIdx); }
-
- VColor& operator=(VColor& that);
-
- static CString ColorIdxString(int nColorIdx);
- static int StringToColorIdx(LPCTSTR szString);
-
- // Implementation
- public:
- friend CArchive& AFXAPI operator<<(CArchive& ar, const VColor& color);
- friend CArchive& AFXAPI operator>>(CArchive& ar, VColor& color);
-
- virtual void Serialize(CArchive& ar);
- };
-
-
- // -------------------------------------------------------------------------
- // A font helper object
- // -------------------------------------------------------------------------
- class AFX_EXT_CLASS VFont
- {
- public:
- VFont();
- ~VFont();
- // virtual ~VFont();
-
- LOGFONT& Logfont() { return m_lf; }
- CFont* Font() { return m_pFont; }
- BOOL SetFont(LOGFONT &lf);
-
- BOOL operator ==(LOGFONT &lf);
-
- protected:
- LOGFONT m_lf;
- CFont *m_pFont; // pointer to the Font
- };
- typedef CList<VFont, VFont&> VFontList;
-
- // -------------------------------------------------------------------------
- // A collection of fonts
- // -------------------------------------------------------------------------
- class AFX_EXT_CLASS VFonts
- {
- protected:
- VFontList m_fontList; // Font list
-
- public:
- VFonts() {}; // Constructor
-
- CFont* Get(LOGFONT &lf);
- CFont* Get(LPCTSTR szFace, int ptSize=100, BOOL bBold=FALSE,
- BOOL bItalic=FALSE, BOOL bUnderline=FALSE);
- CFont* GetEx(LPCTSTR szFace, int ptSize=100, int nWeight=0,
- BOOL bItalic=FALSE, BOOL bUnderline=FALSE);
-
- CFont* GetOrAdd(LOGFONT &lf);
- CFont* GetOrAdd(LPCTSTR szFace, int ptSize=100, BOOL bBold=FALSE,
- BOOL bItalic=FALSE, BOOL bUnderline=FALSE);
- CFont* GetOrAddEx(LPCTSTR szFace, int ptSize=100, int nWeight=0,
- BOOL bItalic=FALSE, BOOL bUnderline=FALSE);
-
- BOOL Remove(LOGFONT &lf);
- BOOL Remove(LPCTSTR szFace, int ptSize=100, BOOL bBold=FALSE,
- BOOL bItalic=FALSE, BOOL bUnderline=FALSE);
- BOOL RemoveEx(LPCTSTR szFace, int ptSize=100, int nWeight=0,
- BOOL bItalic=FALSE, BOOL bUnderline=FALSE);
-
- void RemoveAll() { m_fontList.RemoveAll(); }
- };
-
-
- #endif
-