home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------------------------------------------------------*\
- | DevUI.h - DevUI(tm) library header file |
- | From Developing User Interfaces for Microsoft Windows |
- | Copyright (c) 1999, Everett N. McKay |
- \*---------------------------------------------------------------------------*/
-
- #include "resource.h"
-
- // constants and structures
-
- const int MaxRGB = 255;
- const int MaxHSL = 240;
- const int MaxPropSheetButtons = 16;
-
- enum ZoomSpeed { ZoomSlow, ZoomMedium, ZoomFast };
-
- struct McButtonList
- {
- CString Name;
- int ID;
- BOOL IsDefault;
- };
-
- struct McHSL
- {
- int Hue;
- int Saturation;
- int Luminosity;
- };
-
- // classes
-
- class CMcPropertySheet : public CPropertySheet
- {
- DECLARE_DYNCREATE(CMcPropertySheet)
-
- public:
- CMcPropertySheet ();
- CMcPropertySheet (UINT titleID, CWnd* pParent = 0, UINT selectPage = 0);
- CMcPropertySheet (LPCTSTR titleText, CWnd* pParent = 0, UINT selectPage = 0);
- virtual BOOL OnInitDialog ();
- void RemoveApplyButton () { m_RemoveApply = TRUE; }
- void RemoveCancelButton() { m_RemoveCancel = TRUE; }
- void SetButtons (McButtonList *pButtonList) { m_pButtonList = pButtonList; }
-
- protected:
- BOOL m_RemoveApply;
- BOOL m_RemoveCancel;
- McButtonList *m_pButtonList;
- CButton m_Buttons[MaxPropSheetButtons];
-
- DECLARE_MESSAGE_MAP()
- };
-
- class CMcMRUList : public CStringList
- {
- public:
- CMcMRUList (int maxSize = -1, BOOL isCaseSensitive = FALSE);
- void AddString (LPCTSTR newString);
- BOOL GetClosestMatch (LPCTSTR text, LPTSTR match, int matchBufSize);
- HRESULT SetProfile (LPCTSTR section, LPCTSTR entryPrefix);
- HRESULT GetProfile (LPCTSTR section, LPCTSTR entryPrefix);
-
- int m_MaxSize;
- BOOL m_IsCaseSensitive;
- protected:
- BOOL GetClosestMatchOffset (LPCTSTR text, POSITION &pos, BOOL &exactMatch);
- };
-
- class CMcColor
- {
- public:
- CMcColor (UINT value1, UINT value2, UINT value3, BOOL useRGB);
- CMcColor (COLORREF rgb);
- CMcColor (McHSL hsl);
-
- void SetRGB (UINT red, UINT green, UINT blue);
- void SetRGB (COLORREF rgb);
- void GetRGB (UINT &red, UINT &green, UINT &blue);
- void GetRGB (COLORREF &rgb);
-
- void SetHSL (UINT hue, UINT saturation, UINT luminosity);
- void SetHSL (McHSL hsl);
- void GetHSL (UINT &hue, UINT &saturation, UINT &luminosity);
- void GetHSL (McHSL &hsl);
-
- static HRESULT RGBtoHSL (COLORREF rgb, McHSL &hsl);
- static HRESULT HSLtoRGB (McHSL hsl, COLORREF &rgb);
-
- protected:
- static int HueToRGB (int n1, int n2, int hue);
- COLORREF m_RGB;
- McHSL m_HSL;
- };
-
- class CMcWindowPlacement : public WINDOWPLACEMENT
- {
- public:
- HRESULT SetProfile (LPCTSTR section, LPCTSTR entry);
- HRESULT GetProfile (LPCTSTR section, LPCTSTR entry, BOOL checkValues = TRUE);
- HRESULT SaveWindowPlacement (LPCTSTR section, LPCTSTR entry,
- CWnd *pWnd);
- HRESULT RestoreWindowPlacement (LPCTSTR section, LPCTSTR entry,
- CWnd *pWnd, BOOL checkValues = TRUE);
- };
-
- class CMcTooltip : public CWnd
- {
- DECLARE_DYNCREATE(CMcTooltip)
-
- public:
- CMcTooltip (const CPoint &cursorPos, LPCTSTR tipText,
- const CRect &boundingRect, CWnd *pParent = 0,
- int timeoutSeconds = 10);
- CMcTooltip (const CPoint &cursorPos, UINT tipID,
- const CRect &boundingRect, CWnd *pParent = 0,
- int timeoutSeconds = 10);
- void Create ();
- void SetTipText (LPCTSTR tipText, BOOL resetTimer = TRUE);
-
- protected:
- void SetWindowRect ();
- virtual void SetClientRect (const CRect &screenRect, CRect &clientRect);
- virtual void PostNcDestroy ();
-
- afx_msg void OnDestroy ();
- afx_msg void OnTimer (UINT eventID);
- afx_msg void OnPaint ();
-
- CPtrList m_TextList;
- CPtrList m_FormatList;
- CRect m_WindowRect;
- CTime m_StartTime;
- CPoint m_CursorPos;
- CString m_TipText;
- CRect m_BoundingRect;
- CWnd *m_pParent;
- int m_TimeoutSeconds;
- BOOL m_UseHtml;
- BOOL m_InitFont;
- CFont m_Font;
-
- DECLARE_MESSAGE_MAP()
- };
-
- class CMcProgressDialog : public CDialog
- {
- DECLARE_DYNCREATE(CMcProgressDialog)
-
- public:
- CMcProgressDialog (BOOL &wasCanceled, LPCTSTR messageText,
- LPCTSTR titleText = 0, CWnd *pParent = 0);
- CMcProgressDialog (BOOL &wasCanceled, UINT messageID,
- UINT titleID = 0, CWnd *pParent = 0);
- virtual ~CMcProgressDialog ();
- void Close ();
- void SetPercentComplete (UINT percentComplete);
- void SetMessageText (LPCTSTR messageText);
- BOOL Pump ();
-
- protected:
- void CommonConstruct (LPCTSTR messageText, LPCTSTR titleText,
- CWnd *pParent);
- virtual void OnCancel ();
-
- CWnd *m_pParent;
- BOOL &m_WasCanceled;
-
- DECLARE_MESSAGE_MAP()
- };
-
- class CMcProgressStatusBar
- {
- public:
- CMcProgressStatusBar (BOOL &wasCanceled, CStatusBar *pStatusBar,
- LPCTSTR messageText, UINT statusBarPane = 0,
- int paneTextSize = -1);
- CMcProgressStatusBar (BOOL &wasCanceled, CStatusBar *pStatusBar,
- UINT messageID, UINT statusBarPane = 0,
- int paneTextSize = -1);
- virtual ~CMcProgressStatusBar ();
- void Close ();
- void SetPercentComplete (UINT percentComplete);
- void SetMessageText (LPCTSTR messageText);
- BOOL Pump ();
-
- protected:
- void CommonConstruct (LPCTSTR messageText, int paneTextSize);
-
- BOOL &m_WasCanceled;
- CProgressCtrl m_Progress;
- CStatusBar *m_pStatusBar;
- UINT m_StatusBarPane;
- };
-
- void McShowZoomRect (const CRect &startRect, const CRect &endRect, ZoomSpeed speed);
-
- HRESULT McSetProfileStringList (LPCTSTR section, LPCTSTR entryPrefix,
- const CStringList &list);
- HRESULT McGetProfileStringList (LPCTSTR section, LPCTSTR entryPrefix,
- CStringList &list);
-
- // global variable access functions
-
- void McSetMessageBoxZoomRect (const CRect &zoomRect);
- void McSetMessageBoxZoomSpeed (ZoomSpeed zoomSpeed);
- CMcTooltip ** McGetTooltipPtrAddress ();
-