customdraw.h

Go to the documentation of this file.
00001 /**
00002  * \file customdraw.h <mgui/customdraw.h>
00003  * \brief Definitions for MGUI::CUSTOMDRAW.
00004  *
00005  * \if NODOC
00006  * $Id: customdraw.h_v 1.2 2004/05/12 17:43:53 mju Exp $
00007  *
00008  * $Log: customdraw.h_v $
00009  * Revision 1.2  2004/05/12 17:43:53  mju
00010  * Change setbase to not have drawing stage.
00011  * Add setdrawstage.
00012  *
00013  * Revision 1.1  2004/05/03 20:39:55  mju
00014  * Initial revision
00015  *
00016  * \endif
00017 **/
00018 
00019 #ifndef  INC_MGUI_CUSTOMDRAW_H
00020 #define  INC_MGUI_CUSTOMDRAW_H
00021 
00022 #if !defined(INC_MI32_STDAFX_H) && defined(WIN32_MFC)
00023 #include <mi32/stdafx.h>
00024 #endif
00025 
00026 #ifndef  INC_MI32_RECT_H
00027 #include <mi32/rect.h>
00028 #endif
00029 
00030 
00031 #ifndef GENERATING_DOXYGEN_OUTPUT
00032 namespace MGD {
00033    class CONTEXT;
00034    }
00035 #endif
00036 
00037 
00038 namespace MGUI {
00039 
00040 //! Base class for custom draw notification supported by selected controls.
00041 //!
00042 //! Custom draw allows an application to easily change selected drawing aspects or manually draw
00043 //! selected items without having to do a full owner draw.
00044 //!
00045 //! At the beginning of each 'paint' cycle, the control's v_OnCustomDraw function will be called with
00046 //! a CUSTOMDRAW-derived class instance having its drawing stage set to DRAWSTAGE_PrePaint.  The value
00047 //! the application returns from this first notification dictates how and when the control sends
00048 //! subsequent custom draw notifications fo rthe rest of that paint cycle.  The application can return
00049 //! a combination of the following flags in response to this first notification.
00050 //! 
00051 //!   RETVALUE_DoDefault         Control will draw itself, no additional notifications will be sent for this paint cycle.
00052 //!   RETVALUE_NotifyItemDraw    v_OnCustomDraw will be called for any item-specific drawing, before and after items are drawn.
00053 //!   RETVALUE_NotifyPostPaint   v_OnCustomDraw will be called when painting cycle for entire control is complete
00054 //!   RETVALUE_SkipDefault       Control will not perform any painting at all
00055 //!
00056 //! If the application returns RETVALUE_NotifyItemDraw for the initial prepaint notification, notifications will be sent
00057 //! for each items it draws during that paint cycle.  These item-specific notifications will have a drawing stage of
00058 //! DRAWSTAGE_ItemPrePaint.  Notification for when it it finished drawing the item may then be requested by returning
00059 //! RETVALUE_NotifyPostPaint.  Otherwise return RETVALUE_DoDefault and no post-paint notification will be sent.  If the
00060 //! application draws the entire item, return RETVALUE_SkipDefault and the control will not draw any portion of the item.
00061 class CUSTOMDRAW {
00062    public:
00063 
00064       //! Drawing stage.
00065       //  Values chosen to match Windows common controls.
00066       enum DRAWSTAGE {
00067          DRAWSTAGE_PrePaint =                0x00000001,
00068          DRAWSTAGE_PostPaint =               0x00000002,
00069          DRAWSTAGE_PreErase =                0x00000003,
00070          DRAWSTAGE_PostErase =               0x00000004,
00071          DRAWSTAGE_CtrlPrePaint =            DRAWSTAGE_PrePaint,
00072          DRAWSTAGE_CtrlPostPaint =           DRAWSTAGE_PostPaint,
00073          DRAWSTAGE_CtrlPreErase =            DRAWSTAGE_PreErase,
00074          DRAWSTAGE_CtrlPostErase =           DRAWSTAGE_PostErase,
00075          DRAWSTAGE_Item =                    0x00010000,
00076          DRAWSTAGE_ItemPrePaint =            DRAWSTAGE_Item | DRAWSTAGE_PrePaint,
00077          DRAWSTAGE_ItemPostPaint =           DRAWSTAGE_Item | DRAWSTAGE_PostPaint,
00078          DRAWSTAGE_ItemPreErase =            DRAWSTAGE_Item | DRAWSTAGE_PreErase,
00079          DRAWSTAGE_ItemPostErase =           DRAWSTAGE_Item | DRAWSTAGE_PostErase,
00080          DRAWSTAGE_SubItem =                 0x00020000,
00081          DRAWSTAGE_SubItemPrePaint =         DRAWSTAGE_SubItem | DRAWSTAGE_ItemPrePaint,
00082          DRAWSTAGE_SubItemPostPaint =        DRAWSTAGE_SubItem | DRAWSTAGE_ItemPostPaint,
00083          };
00084 
00085       //! Item state
00086       //  Values chosen to match Windows common controls.
00087       enum ITEMSTATE {
00088          ITEMSTATE_Normal =            0x0000,
00089          ITEMSTATE_Selected =          0x0001,
00090          ITEMSTATE_Grayed =            0x0002,
00091          ITEMSTATE_Disabled =          0x0004,
00092          ITEMSTATE_Checked =           0x0008,
00093          ITEMSTATE_Focus =             0x0010,
00094          ITEMSTATE_Default =           0x0020,
00095          ITEMSTATE_Hot =               0x0040,
00096          ITEMSTATE_Marked =            0x0080,
00097          ITEMSTATE_Indeterminant =     0x0100,
00098          };
00099 
00100       //! Values to return from control-specific v_OnCustomDraw override.
00101       //! The values the application can return depend on the current drawing stage.
00102       enum RETVALUE {
00103          RETVALUE_DoDefault =          0x00, //!< Let control do all drawing, valid for DRAWSTAGE_...PrePaint
00104          RETVALUE_SkipDefault =        0x04, //!< Indicate item was completely drawn manually, valid for DRAWSTAGE_...PrePaint
00105          RETVALUE_NotifyPostPaint =    0x10, //!< Request notification after painting item, valid for DRAWSTAGE_...PrePaint
00106          RETVALUE_NotifyItemDraw =     0x20, //!< Request notification before/after drawing each item, valid for DRAWSTAGE_CtrlPrePaint
00107          RETVALUE_NotifySubItemDraw =  0x20, //!< Request notification before/after drawing each subitem, valid for DRAWSTAGE_CtrlPrePaint
00108          RETVALUE_NotifyPostErase =    0x40, //!< Request notification after erasing item, valid for DRAWSTAGE_CtrlPrePaint
00109          };
00110 
00111       MGD::CONTEXT* GetDrawingContext (
00112          ) const { return (m_pDC); }
00113 
00114       DRAWSTAGE GetDrawStage (
00115          ) const { return (m_drawstage); }
00116 
00117       ID GetID (
00118          ) const { return (m_id); }
00119 
00120       ITEMSTATE GetItemState (
00121          ) const { return (m_itemstate); }
00122 
00123       const LRECT2D& GetRect (
00124          ) const { return (m_rect); }
00125 
00126       void SetDrawStage (
00127          DRAWSTAGE drawstage
00128          ) { m_drawstage = drawstage; }
00129 
00130    protected:
00131 
00132       CUSTOMDRAW (
00133          );
00134 
00135       CUSTOMDRAW (
00136          DRAWSTAGE drawstage,
00137          ITEMSTATE itemstate,
00138          INT32 ItemNumber,
00139          ID id,
00140          const LRECT2D& rect
00141          );
00142 
00143       ~CUSTOMDRAW ()
00144          { }
00145 
00146       INT32 GetItemNumber (
00147          ) const { return (m_ItemNumber); }
00148 
00149       void SetBase (
00150          ITEMSTATE itemstate,
00151          INT32 ItemNumber,
00152          ID id,
00153          const LRECT2D& rect
00154          );
00155 
00156    #ifdef WIN32_MFC
00157       void SetBase (
00158          const NMCUSTOMDRAW *pNM
00159          );
00160    #endif
00161 
00162       void SetDrawingContext (
00163          MGD::CONTEXT *pDC
00164          ) { m_pDC = pDC; }
00165 
00166    private:
00167       #ifndef GENERATING_DOXYGEN_OUTPUT
00168       DRAWSTAGE m_drawstage;
00169       ITEMSTATE m_itemstate;
00170       INT32 m_ItemNumber;
00171       ID m_id;
00172       LRECT2D m_rect;
00173       MGD::CONTEXT *m_pDC;
00174       #endif // GENERATING_DOXYGEN_OUTPUT
00175 
00176    };
00177 
00178 DEFINE_ENUM_OP_BITWISE(CUSTOMDRAW::ITEMSTATE)
00179 DEFINE_ENUM_OP_BITWISE(CUSTOMDRAW::RETVALUE)
00180 
00181 }  // End namespace MGUI
00182 
00183 #endif   // INC_MGUI_CUSTOMDRAW_H
00184 

Generated on Tue Dec 14 13:18:16 2004 for TNTsdk by  doxygen 1.3.8-20040913