oxttctrl.h

Go to the documentation of this file.
00001 /**
00002  * \file mgui/oxttctrl.h
00003  * \brief Tool Tip control for MFC
00004  *
00005  * This should be moved to mi32p or contrib, but mi32/mdisp.h includes it,
00006  * so we have to distribute it.
00007  *
00008  * \if NODOC
00009  * $Log: oxttctrl.h_v $
00010  * Revision 1.6  2004/04/30 14:05:05  mju
00011  * Include stdafx if not already.
00012  *
00013  * Revision 1.5  2003/10/03 19:58:19  linux32build!build
00014  * Doxygen
00015  *
00016  * Revision 1.4  2003/09/15 16:11:18  dwilliss
00017  * Fixed mismatched ifdefs from doxygen
00018  *
00019  * Revision 1.3  2003/09/15 13:49:32  fileserver!dwilliss
00020  * Doxygen
00021  *
00022  * Revision 1.2  2003/04/09 20:52:09  dwilliss
00023  * Don't use _T in templates.  Mac's ctype.h defines a global _T
00024  *
00025  * Revision 1.1  2002/12/11 15:22:17  mju
00026  * Initial revision
00027  *
00028  * 
00029  * 3     2/01/01 2:44p Mju
00030  * Add IsCreated()
00031  * 
00032  * 2     2/01/01 2:02p Mju
00033  * Keep track of whether to use full client rect.
00034  * Retain bounding rectangle in client coordinates.
00035  * \endif
00036  */
00037 
00038 #ifndef INC_MGUI_OXTTCTRL_H
00039 #define INC_MGUI_OXTTCTRL_H
00040 
00041 #if !defined(INC_MI32_STDAFX_H) && defined(WIN32_MFC)
00042 #include <mi32/stdafx.h>
00043 #endif
00044 
00045 #ifndef GENERATING_DOXYGEN_OUTPUT
00046 //! ==========================================================================
00047 //!                    Class Specification : COXToolTipCtrl
00048 //! ==========================================================================
00049 //! //////////////////////////////////////////////////////////////////////////
00050 //! Header file : OXToolTipCtrl.h
00051 
00052 //! Copyright © Dundas Software Ltd. 1997 - 1999, All Rights Reserved
00053 
00054 //! //////////////////////////////////////////////////////////////////////////
00055 
00056 
00057 //! Properties:
00058 //!   NO Abstract class (does not have any objects)
00059 //!   YES   Derived from CWnd
00060 
00061 //!   YES   Is a Cwnd.                     
00062 //!   YES   Two stage creation (constructor & Create())
00063 //!   YES   Has a message map
00064 //!   NO    Needs a resource (template)
00065 
00066 //!   NO Persistent objects (saveable on disk)      
00067 //!   NO Uses exceptions
00068 
00069 //! //////////////////////////////////////////////////////////////////////////
00070 
00071 
00072 /*
00073    DESCRIPTION         
00074 
00075 COXToolTipCtrl is an extended tooltip control that allows multiline tooltips,
00076 plus extended tooltip text. Extended tooltip text is extra text that is 
00077 displayed if the user clicks on the tooltip window. If the tooltip contains
00078 extended text (as well as a standard tooltip string) then the info window
00079 will contain a small arrow that prompts the user to click on the window. Once
00080 the window is clicked, the extended text is shown. If the window is clicked 
00081 again then the window reduces to showing just the standard text.
00082 
00083 The maximum width of the tooltips can be specified, and if the info text is
00084 too big to fit within these bounds then the text will be wrapped over multiple
00085 lines. The control also allows you to specify a different text and background 
00086 colors for the tooltips, and the display font can also be changed.
00087 
00088 Using ToolTipCtrlEx :
00089 
00090 This class is a direct replacement for the CToolTipCtrl class. It incorporates
00091 the entire API of the standard CToolTipCtrl, and introduces new features not
00092 found in the standard tooltip.
00093 
00094 The control is used just like any other tooltip control. To use the tool simply
00095 call Create(...) and specify the parent window of the tool, then add tools to
00096 the control using the AddTool(...) member function. 
00097 
00098 eg. (In a formview or dialog)
00099 
00100      tooltip.Create(this)
00101      tooltip.AddTool(GetDlgItem(IDC_CONTROL), 
00102          _CT("Tooltip text\rThis is the extended\ntooltip text"));
00103 
00104 where ID_CONTROL is the ID of a control.
00105 
00106 To specify extended text for a tooltip, simply append a '\r' after your tooltip 
00107 text, and then append the extended tooltip info.
00108 
00109 As with the standard tooltip control you can specify the actual text for the tool 
00110 at creation time (as shown above), or you can specify the LPSTR_TEXTCALLBACK value 
00111 and provide a TTN_NEEDTEXT handler to return the text dynamically at runtime.
00112 
00113 To handle the TTN_NEEDTEXT message, you will need to add a message handler in the
00114 parent window, and an entry in the message map;
00115 
00116 eg. In you view or form
00117 
00118    BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
00119    ...
00120    ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify)
00121    END_MESSAGE_MAP()
00122 
00123    BOOL CMyDlg::OnInitDialog()
00124    {
00125          CDialog::OnInitDialog();
00126 
00127        tooltip.Create(this)
00128        tooltip.AddTool(GetDlgItem(IDC_CONTROL), LPSTR_TEXTCALLBACK);
00129        ...
00130     }
00131 
00132     BOOL CMyDlg::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
00133     {    
00134         TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;    
00135         UINT nID = pNMHDR->idFrom;
00136         
00137         if (nID == IDC_CONTROL) Fill in the text buffer
00138         {
00139             _tcscpy(pTTT->szText, _CT("Tooltip text\rExtended tooltip text"));
00140             return TRUE;
00141         }
00142         
00143         return FALSE;
00144     }
00145 
00146 You can also supply text two alternate ways, either by supplying a string 
00147 resource
00148 
00149             pTTT->lpszText = MAKEINTRESOURCE(nID);
00150             pTTT->hinst    = AfxGetResourceHandle();            
00151             return TRUE;
00152 
00153 or by supplying a pointer to the text:
00154         
00155             pTTT->lpszText = _CT("Tooltip text\rExtended tooltip text");
00156             return TRUE;
00157 
00158 Newline characters ('\n') can be embedded anywhere within the text or extended
00159 text to produce a multiline tooltip. If the width of the tooltip window is
00160 specified using SetMaxTipWidth() then the tooltip text will be wrapped to this
00161 length, and if necessary displayed on more than one line.
00162 
00163 To change the font of the tooltips simply use the SetFont member function. 
00164 
00165 The GetToolInfo/SetToolInfo functions, and the HitTest functions are very
00166 similar to the CToolTipCtrl versions except that they use a OXTOOLINFO
00167 structure instead of a TOOLINFO structure. This structure is defined as
00168 
00169     struct OXTOOLINFO : public TOOLINFO
00170     {
00171     #if (_WIN32_IE < 0x0300)
00172        LPARAM    lParam;       Application defined value that is associated with the tool
00173     #endif
00174        int       nWidth;       Width of box, or 0 for default
00175        COLORREF  clrTextColor; text color
00176        COLORREF  clrBackColor; background color
00177     }
00178 
00179 and so is very similar to the standard TOOLINFO, and is used in the same way,
00180 with the exception that the uFlags member is not (yet) used.
00181 
00182 To change the color of an individual tip, use the GetToolInfo/SetToolInfo
00183 functions
00184 
00185    OXTOOLINFO ToolInfo;
00186    if (m_toolTip.GetToolInfo(ToolInfo, GetDlgItem(IDC_CONTROL)))
00187    {
00188        ToolInfo.clrBackColor = RGB(255, 255, 255);
00189        ToolInfo.clrTextColor = RGB(  0,   0, 255);
00190        m_toolTip.SetToolInfo(&ToolInfo);
00191    }
00192 
00193 
00194 
00195 The ToolTipEx sample that demonstrate the functionality of the COXToolTipCtrl class 
00196 can be found in the .\Samples\gui\ToolTipEx subdirectory of your Ultimate Toolbox 
00197 directory.
00198 
00199 
00200 
00201 Dependencies:
00202 
00203 #include "OXToolTipCtrl.h"
00204 
00205 
00206 Source code files:
00207 
00208 "OXToolTipCtrl.cpp"     -  COXToolTipCtrl implementation
00209 
00210 
00211 */
00212 //!
00213 //!
00214 //////////////////////////////////////////////////////////////////////////!
00215 
00216 
00217 #if !defined(_OXTOOLTIPCTRL_H__) && defined(WIN32_MFC)
00218 #define _OXTOOLTIPCTRL_H__
00219 
00220 #if _MSC_VER > 1000
00221 #pragma once
00222 #endif //!< _MSC_VER > 1000
00223 
00224 #include <mgui/OXDllExt.h>
00225 
00226 class COXToolTipInfo;
00227 
00228 struct OXTOOLINFO : public TOOLINFO
00229 {
00230  #if (_WIN32_IE < 0x0300)
00231    //! Application defined value that is associated with the tool
00232     LPARAM    lParam;       
00233 #endif
00234    //! Width of box, or 0 for default
00235     int       nWidth;
00236    //! Set to use full client rectangle
00237     bool      bUseFullRect;
00238    //! text color
00239     COLORREF  clrTextColor; 
00240    //! background color
00241     COLORREF  clrBackColor; 
00242 
00243 
00244     OXTOOLINFO::OXTOOLINFO()
00245     {
00246         cbSize = sizeof(OXTOOLINFO);
00247     }
00248 
00249     void operator=(COXToolTipInfo& RHS);
00250 };
00251 
00252 //! this structure holds all the tooltip information internall
00253 class OX_CLASS_DECL COXToolTipInfo : public CObject
00254 {
00255 public:
00256     UINT      uFlags;       //!< Not used
00257     HWND      hWnd;         //!< Window handle of the control
00258     UINT      nIDTool;      //!< ID of tool   
00259     CRect     rectBounds;   //!< Bounding rect for toolinfo to be displayed relative to upper left corner of hWnd
00260     LPCTSTR   szText;       //!< Either LPSTR_TEXTCALLBACK or NULL
00261     CString   strText;      //!< Tooltip text if szText is NULL, or empty.
00262     int       nWidth;       //!< Width of box, or 0 for default
00263     bool      bUseFullRect; //!< Use full client rectangle, ignoring 'rectBounds'
00264     COLORREF  clrTextColor; //!< text color
00265     COLORREF  clrBackColor; //!< background color
00266     LPARAM    lParam;       //!< Application defined value that is associated 
00267                      //! with the tool
00268 
00269 
00270     void operator=(OXTOOLINFO& RHS)
00271     {
00272         uFlags     = RHS.uFlags;
00273         hWnd       = RHS.hwnd;
00274         nIDTool    = RHS.uId;
00275         rectBounds = RHS.rect;
00276         if (RHS.lpszText == LPSTR_TEXTCALLBACK)
00277         {
00278             szText = RHS.lpszText;
00279             strText.Empty();
00280         }
00281         else
00282         {
00283             szText = NULL;
00284             strText = RHS.lpszText;
00285         }
00286         nWidth       = RHS.nWidth;
00287         bUseFullRect = RHS.bUseFullRect;
00288         clrTextColor = RHS.clrTextColor;
00289         clrBackColor = RHS.clrBackColor;
00290         lParam       = RHS.lParam;
00291     }
00292 
00293     void operator=(COXToolTipInfo& RHS)
00294     {
00295         uFlags     = RHS.uFlags;
00296         hWnd         = RHS.hWnd;
00297         nIDTool      = RHS.nIDTool;
00298         rectBounds   = RHS.rectBounds;
00299         strText      = RHS.strText;
00300         nWidth       = RHS.nWidth;
00301         bUseFullRect = RHS.bUseFullRect;
00302         clrTextColor = RHS.clrTextColor;
00303         clrBackColor = RHS.clrBackColor;
00304         lParam       = RHS.lParam;
00305     }
00306 };
00307 
00308 inline void OXTOOLINFO::operator=(COXToolTipInfo& RHS)
00309 {
00310     cbSize = sizeof(OXTOOLINFO);
00311     uFlags = RHS.uFlags;
00312     hwnd   = RHS.hWnd;
00313     uId    = RHS.nIDTool;
00314     rect   = RHS.rectBounds;
00315     hinst  = AfxGetResourceHandle(); 
00316     if (RHS.szText == LPSTR_TEXTCALLBACK)
00317         lpszText = LPSTR_TEXTCALLBACK;
00318     else
00319         lpszText = (LPTSTR)(LPCTSTR) RHS.strText;
00320     lParam       = RHS.lParam;
00321     nWidth       = RHS.nWidth;
00322     bUseFullRect = RHS.bUseFullRect;
00323     clrTextColor = RHS.clrTextColor;
00324     clrBackColor = RHS.clrBackColor;
00325 }
00326 
00327 
00328 /////////////////////////////////////////////////////////////////////////////!
00329 //! COXToolTipCtrl window
00330 
00331 class OX_CLASS_DECL COXToolTipCtrl : public CWnd
00332 {
00333 //! Construction
00334 public:
00335    //! --- In  :
00336    //! --- Out :
00337    //! --- Returns:
00338    //! --- Effect : The constructor - all relevant variables initialized
00339    COXToolTipCtrl();
00340 
00341 //! Attributes
00342 public:
00343    //! --- In:    ToolInfo -  Reference to a TOOLINFO object that receives the 
00344    //!                        tool’s text.
00345    //!            pWnd     -  Pointer to the window that contains the tool.
00346    //!            nIDTool     -  ID of the tool.
00347    //! --- Out :
00348    //! --- Returns:  TRUE on success, FALSE otherwise
00349    //! --- Effect :  Call this function to retrieve the information that a tool tip 
00350    //!            control maintains about a tool. If the control has information 
00351    //!            on the tool identified by the window and ID, then the 
00352    //!            COXToolTipInfo structure is filled with that information.
00353     BOOL GetToolInfo(OXTOOLINFO& ToolInfo, CWnd* pWnd, UINT nIDTool = 0);
00354 
00355    //! --- In:    pToolInfo   -  A pointer to a OXTOOLINFO structure that 
00356    //!                        specifies the information to set. 
00357    //! --- Out :
00358    //! --- Returns:
00359    //! --- Effect:   Sets the information that a tool tip maintains for a tool
00360     void SetToolInfo(OXTOOLINFO* pToolInfo);
00361 
00362 
00363    //! --- In: 
00364    //! --- Out:      lprc  -  Address of a RECT structure that will receive the 
00365    //!                     margin information
00366    //! --- Returns: 
00367    //! --- Effect:   Retrieves the margins used for drawing the text in the tooltip. 
00368    //!            The rectangle does not specify a bounding rect, but rather the 
00369    //!            top, bottom, left and right distances (in pixels) between the 
00370    //!            text and the the edge of the toltip window.
00371     void GetMargin(LPRECT lprc) const;
00372 
00373 
00374    //! --- In:    pWnd  -  Pointer to the window that contains the tool.
00375    //!            nIDTool  -  ID of the tool.
00376    //! --- Out:      str      -  Reference to a CString object that receives the 
00377    //!                     tool’s text
00378    //! --- Returns : 
00379    //! --- Effect : Retrieves the text that a tool tip control maintains for a tool.
00380    //!              If pWnd and nIDTool specify a valid tool that has been previously
00381    //!              registered, then str is filled with the tooltip's text.
00382     void GetText(CString& str, CWnd* pWnd, UINT nIDTool = 0);
00383 
00384 
00385    //! --- In:    nTime    -  Specifies the new delay time, in milliseconds
00386    //!            dwDuration  -  Flag that specifies which duration value will 
00387    //!                        be set. This is either:
00388    //!
00389    //!               TTDT_AUTOPOP   -  The length of time the tool tip window 
00390    //!                              remains visible if the pointer is 
00391    //!                              stationary within a tool's bounding 
00392    //!                              rectangle. 
00393    //!               TTDT_INITIAL   -  The length of time the pointer must 
00394    //!                              remain stationary within a tool's 
00395    //!                              bounding rectangle before the tool tip 
00396    //!                              window appears.
00397    //!            nDelay      -  Specifies the new delay time, in milliseconds
00398    //! --- Out : 
00399    //! --- Returns:
00400    //! --- Effect:   Sets the delay times for the tooltip in milliseconds
00401     void SetDelayTime(DWORD dwDuration, int nTime);
00402    inline void SetDelayTime(UINT nDelay) { m_nDisplayDelay = nDelay; }
00403 
00404    //! --- In:    dwDuration  -  Flag that specifies which duration value will 
00405    //!                        be retrieved. This is either:
00406    //!
00407    //!               TTDT_AUTOPOP   -  The length of time the tool tip window 
00408    //!                              remains visible if the pointer is 
00409    //!                              stationary within a tool's bounding 
00410    //!                              rectangle. 
00411    //!               TTDT_INITIAL   -  The length of time the pointer must 
00412    //!                              remain stationary within a tool's 
00413    //!                              bounding rectangle before the tool tip 
00414    //!                              window appears.
00415    //! --- Out :
00416    //! --- Returns:  The delay times for the tooltip in milliseconds
00417    //! --- Effect:   Retrieves the initial, pop-up, and reshow durations currently 
00418    //!            set for a tooltip control
00419     int  GetDelayTime(DWORD dwDuration) const;
00420 
00421 
00422    //! --- In  :
00423    //! --- Out :
00424    //! --- Returns:  The maximum width for a tool tip window, or 0 if this width is 
00425    //!            calculated automatically
00426    //! --- Effect:   Retrieves the maximum width of the tool tip window 
00427     int  GetMaxTipWidth() const;
00428 
00429    //! --- In:    nWidth   -  The maximum width for a tool tip window, or 0 if this 
00430    //!                     width is calculated automatically. The maximum 
00431    //!                     tooltip width value does not indicate a tooltip 
00432    //!                     window's actual width. Rather, if a tooltip string 
00433    //!                     exceeds the maximum width, the control breaks the 
00434    //!                     text into multiple lines, using spaces to determine 
00435    //!                     line breaks. If the text cannot be segmented into 
00436    //!                     multiple lines, it will be displayed on a single line. 
00437    //!                     The length of this line may exceed the maximum 
00438    //!                     tooltip width. 
00439    //! --- Out :
00440    //! --- Returns:  The previous maximum tool tip window width.
00441    //! --- Effect:   Sets the maximum tool tip window width
00442     int  SetMaxTipWidth(int nWidth);
00443 
00444    //! --- In  : 
00445    //! --- Out :
00446    //! --- Returns:  A COLORREF value that represents the background color of the
00447    //!            tool tip window
00448    //! --- Effect:   Retrieves the background color
00449     COLORREF GetTipBkColor() const;
00450 
00451    //! --- In:    clr - The new background color
00452    //! --- Out :
00453    //! --- Returns:
00454    //! --- Effect:   Sets the background colour for all tools maintained by this 
00455    //!            control. If the value is CLR_DEFAULT then the default system 
00456    //!            colour is used
00457     void     SetTipBkColor(COLORREF clr);
00458 
00459     
00460    //! --- In  : 
00461    //! --- Out :
00462    //! --- Returns: A COLORREF value that represents the text color
00463    //! --- Effect:   Retrieves the text color 
00464    COLORREF GetTipTextColor() const;
00465 
00466    //! --- In:    clr   -  The new text color
00467    //! --- Out :
00468    //! --- Returns:
00469    //! --- Effect:   Sets the text colour for all tools maintained by this control.
00470    //!              If the value is CLR_DEFAULT then the default system colour is 
00471    //!            used
00472     void     SetTipTextColor(COLORREF clr);
00473 
00474 //! Attributes - inline
00475 public:
00476 
00477    //! --- In:    bActivate   -  Specifies whether the tool tip control is to be 
00478    //!                        activated or deactivated.
00479    //! --- Out :
00480    //! --- Returns: 
00481    //! --- Effect:   Call this function to activate or deactivate a tool tip control. 
00482    //!            If bActivate is TRUE, the control is activated; if FALSE, it is 
00483    //!            deactivated. When a tool tip control is active, the tool tip 
00484    //!            information appears when the cursor is on a tool that is 
00485    //!            registered with the control; when it is inactive, the tool tip 
00486    //!            information does not appear, even when the cursor is on a tool.
00487     inline void Activate(BOOL bActivate) { m_bActivated = bActivate; }
00488 
00489     
00490    //! --- In  : 
00491    //! --- Out :
00492    //! --- Returns: A count of tools registered with the tool tip control
00493    //! --- Effect:   Retrieves a count of the tools registered with the 
00494    //!            tool tip control
00495     inline int  GetToolCount() const { return m_arrTools.GetSize(); }
00496 
00497     //! Determine if Create() has been performed.
00498     inline bool IsCreated () const { return (m_pParentWnd != 0); }
00499 
00500     
00501    //! --- In  :  lprc  -  Address of a RECT structure that contains the margin 
00502    //!                     information to be set. The members of the RECT 
00503    //!                     structure do not define a bounding rectangle, 
00504    //!                     but rather the top, bottom, left and right distances 
00505    //!                     (in pixels) between the text and the the edge of the 
00506    //!                     toltip window.
00507    //! --- Out :
00508    //! --- Returns: 
00509    //! --- Effect:   Sets the top, left, bottom, and right margins for a tooltip 
00510    //!            window. A margin is the distance, in pixels, between the tooltip 
00511    //!            window border and the text contained within the tooltip window. 
00512     inline void SetMargin(LPRECT lprc) { m_rectMargin = lprc; }
00513 
00514 
00515 //! Operations
00516 public:
00517    
00518    //! --- In:    pParentWnd  -  A pointer to the tool tip control parent
00519    //! --- Out :
00520    //! --- Returns:  TRUE on success, FALSE otherwise
00521    //! --- Effect:   Creates the tooltip window, initially invisible
00522     BOOL Create(CWnd* pParentWnd);
00523 
00524 
00525    //! --- In  :  pWnd     -  Pointer to the window that contains the tool.
00526    //!            nIDText     -  ID of the string resource that contains the text 
00527    //!                        for the tool. If the text contains a '\r' 
00528    //!                        character, then all text before the \r is the 
00529    //!                        standard tooltip text, and all text after the \r 
00530    //!                        will be displayed as extended test if the use 
00531    //!                        clicks on the tooltip
00532    //!            lpszText -  Pointer to the text for the tool. If the text 
00533    //!                        contains a '\r' character, then all text before 
00534    //!                        the \r is the standard tooltip text, and all text 
00535    //!                        after the \r will be displayed as extended test if 
00536    //!                        the use clicks on the tooltip. If the text is 
00537    //!                        LPSTR_TEXTCALLBACK then the control will send the 
00538    //!                        TTN_NEEDTEXT notification message to the parent 
00539    //!                        window to retrieve the text.
00540    //!            lpRectTool  -  Pointer to a RECT structure containing coordinates 
00541    //!                        of the tool's bounding rectangle, using client 
00542    //!                        coordinates relative to the window identified 
00543    //!                        by pWnd.
00544    //!            nIDTool     -  ID of the tool.
00545    //! --- Out :
00546    //! --- Returns:  TRUE on success, FALSE otherwise
00547    //! --- Effect : Registers a tool with the tool tip control, so that the 
00548    //!            information stored in the tool tip is displayed when the cursor 
00549    //!            is on the tool.
00550     BOOL AddTool(CWnd* pWnd, UINT nIDText, 
00551                  LPCRECT lpRectTool = NULL, UINT nIDTool = 0);
00552     BOOL AddTool(CWnd* pWnd, LPCTSTR lpszText, 
00553                  LPCRECT lpRectTool = NULL, UINT nIDTool = 0);
00554     
00555    //! --- In:    pWnd  -  Pointer to the window that contains the tool
00556    //!            nIDTool  -  ID of the tool
00557    //! --- Out :
00558    //! --- Returns:
00559    //! --- Effect:   Removes the tool specified by pWnd and nIDTool from the 
00560    //!              collection of tools supported by a tool tip control.
00561    void DelTool(CWnd* pWnd, UINT nIDTool = 0);
00562     
00563    
00564    //! --- In:    pMsg  -  Pointer to a MSG structure that contains the 
00565    //!                     message to relay
00566    //! --- Out :
00567    //! --- Returns:
00568    //! --- Effect:   Call this function to pass a mouse message to a tool tip 
00569    //!            control for processing. 
00570    void RelayEvent(MSG* pMsg);
00571     
00572    
00573    //! --- In:    pWnd     -  Pointer to the window that contains the tool.
00574    //!            pt       -  Pointer to a CPoint object containing the 
00575    //!                        coordinates of the point to be tested.
00576    //!            lpToolInfo  -  Pointer to a OXTOOLINFO structure that contains 
00577    //!                        information about the tool.
00578    //! --- Out :
00579    //! --- Returns:  TRUE if the point specified by the hit-test information is 
00580    //!            within the tool’s bounding rectangle; otherwise FALSE.
00581    //! --- Effect:   Returns TRUE if the given pt is in the windows toolinfo bounding 
00582    //!            rectangle (pt is in client coords relative to the parent window). 
00583    //!            If this function returns a TRUE, the structure pointed to by 
00584    //!            pToolInfo is filled with information on the corresponding tool.
00585    BOOL HitTest(CWnd* pWnd, POINT pt, OXTOOLINFO* pToolInfo) const;
00586     
00587    
00588    //! --- In  :
00589    //! --- Out :
00590    //! --- Returns:
00591    //! --- Effect:   Hides the tooltip.
00592    void Pop();
00593 
00594 //! Overrides
00595    //! ClassWizard generated virtual function overrides
00596    //!{{AFX_VIRTUAL(COXToolTipCtrl)
00597    //!}}AFX_VIRTUAL
00598 
00599 protected:
00600 
00601    //! --- In:    pt          -  the topleft corner of the region
00602    //!            pToolTip    -  information on the tooltip
00603    //!            rectTextBounds -  the minimum rectangle needed to contain the 
00604    //!                           text
00605    //! --- Out : 
00606    //! --- Returns:  A rectangle containing the bounds of the tooltip
00607    //! --- Effect:   Given the bounding rect of some text, this returns the rectangle 
00608    //!              (in screen coords) that is best suited to displaying the tooltip 
00609    //!              info (uses current mouse position)
00610     virtual CRect CalculateInfoBoxRect(const CPoint& pt, COXToolTipInfo* pToolTip, 
00611                                        CRect& rectTextBounds) const;
00612 
00613    //! --- In:    strText  -  the text to be displayed (may be multiline)
00614    //!            nWidth   -  the desired width. If this is 0, then the width 
00615    //!                     will be calculated
00616    //! --- Out :
00617    //! --- Returns: The bounding rect for the text (with topleft at 0,0)
00618    //! --- Effect : Returns the smallest possible rectangle that will contain 
00619    //!              the text (inc. margins)
00620     virtual CRect GetBoundsRect(CString strText, int nWidth) const;
00621 
00622 //! Implementation
00623 public:
00624    //! --- In  :
00625    //! --- Out :
00626    //! --- Returns:
00627    //! --- Effect:   The destructor - cleanup and memory release
00628    virtual ~COXToolTipCtrl();
00629 
00630 protected:
00631     inline BOOL IsVisible() const { return ((GetStyle() & WS_VISIBLE) == WS_VISIBLE); }
00632 
00633    //! --- In:    pToolTip -  A pointer to a COXToolTipInfo structure 
00634    //!                        describing the tooltip
00635    //! --- Out :
00636    //! --- Returns: A CString containing the tooltip text
00637    //! --- Effect:   Returns the tooltip text for the tool. If the tooltip is
00638    //!              currently displaying extended text, then the extended
00639    //!              text, if available, will be returned. Otherwise the standard
00640    //!              tooltip text will be returned.
00641     CString GetTooltipText(COXToolTipInfo *pToolTip);
00642 
00643     
00644    //! --- In:    pWnd  -  a window containing a tool
00645    //!            nIDTool  -  the ID of the tool
00646    //! --- Out :
00647    //! --- Returns:  A pointer to the internal storage of the tooltip for the given
00648    //!            window and ID
00649    //! --- Effect:   Retrieves the internal info about a tool 
00650    COXToolTipInfo*   GetToolInfoPtr(CWnd* pWnd, UINT nIDTool /*=0*/);
00651 
00652 
00653    //! --- In:    point -  a point (in parent window client coords) to test.
00654    //! --- Out :
00655    //! --- Returns:  The child window (of the parent window) from the supplied point.
00656    //! --- Effect : Retrieves to a child window of the tool tip control parent 
00657    //!            window that contains the specified point
00658     CWnd* GetChildWindowFromPoint(const POINT& point) const;
00659 
00660 
00661    //! --- In:    pToolInfo   -  a tooltip
00662    //! --- Out:
00663    //! --- Returns:
00664    //! --- Effect:   Initiates the display of a tooltip. The tip will not actually
00665    //!              be displayed until the preset delay (m_nDisplayDelay) is up.
00666     void StartNewTool(COXToolTipInfo* pToolInfo);
00667 
00668    //! --- In:    pt       -  the topleft corner where the tooltip should be 
00669    //!                        displayed
00670    //!            bExtended   -  if TRUE, then the extended text is displayed.
00671    //! --- Out :
00672    //! --- Returns :
00673    //! --- Effect : Displays the current tooltip, either as a normal tooltip or as an
00674    //!              extended tooltip
00675     void DisplayToolTip(const CPoint& pt, BOOL bExtended = FALSE);
00676 
00677 
00678    //! --- In:    pt -  a point (in parent window client coords) to test
00679    //! --- Out :
00680    //! --- Returns:  Eeither a pointer to the COXToolTipInfo, or NULL if failed
00681    //! --- Effect : Searches through the list of tools looking for the first tool 
00682    //!            whose bounding rect contains pt.
00683     COXToolTipInfo* FindToolFromPoint(const POINT& pt);
00684 
00685 
00686    //! --- In:    pToolInfo   -  a tool tip info
00687    //! --- Out :
00688    //! --- Returns:  Returns TRUE if the cursor is in the tool given by pToolInfo
00689    //! --- Effect:   Retrieves the flag that specifies if cursor is over the 
00690    //!            specified tool
00691     BOOL IsCursorInTool(COXToolTipInfo* pToolInfo) const;
00692 
00693    //! --- In  :
00694    //! --- Out :
00695    //! --- Returns:  Returns TRUE if the cursor is in the current tooltip window
00696    //! --- Effect:   Retrieves the flag that specifies if cursor is over the 
00697    //!            current tooltip window
00698     BOOL IsCursorInToolTip() const;
00699 
00700     
00701    //! --- In:    ref      -  the string to parse
00702    //!            nIndex   -  the field number to return (0 based)
00703    //!            ch    -  the separator character
00704    //! --- Out :
00705    //! --- Returns:  The substring of ref delimted by ch
00706    //! --- Effect:   This routine breaks a supplied string into substrings, 
00707    //!            each delimited by 'ch', and returns the substring number given 
00708    //!            by nIndex
00709    CString GetFieldFromString(CString ref, int nIndex, TCHAR ch) const;
00710 
00711     
00712    //! --- In:    lpLogFont   -  A pointer to a LOGFONT structure (the new font)
00713    //!            bRedraw     -  If TRUE then the tooltip should be immediately 
00714    //!                        redrawn
00715    //! --- Out :
00716    //! --- Returns:  TRUE on success, FALSE otherwise
00717    //! --- Effect:   Sets the font to be used in the tooltip
00718    BOOL SetLogFont(LPLOGFONT lpLogFont, BOOL bRedraw = TRUE);
00719 
00720    //! --- In  :
00721    //! --- Out :
00722    //! --- Returns: A pointer to a LOGFONT structure that contains default font 
00723    //!            used in tool tips
00724    //! --- Effect : Returns the system tool tip font
00725     LPLOGFONT GetSystemToolTipFont() const;
00726 
00727 protected:
00728     CWnd*   m_pParentWnd;               //!< Parent window of all the tools
00729     CRect   m_rectMargin;               //!< Margin between text and tooltip window edge
00730     int     m_nMaxWidth;                //!< Max tooltip width
00731     CPoint  m_ptOffset;                 //!< offset from the cursor to the topleft of 
00732     CFont   m_Font;
00733     LOGFONT m_LogFont;                  //!< Current font in use
00734     DWORD   m_dwTextStyle;              //!< The style in which to draw the text
00735     BOOL    m_bUsingSystemFont;         //!< Use system tooltip font?
00736     COXToolTipInfo *m_pCurrentToolTip; //!< Current tooltip information
00737     UINT   m_nCheckInterval;            //!< Time in ms between check of the tip
00738     UINT   m_nDisplayTime;              //!< Time in ms to display the tip
00739     UINT   m_nElapsedTime;              //!< Elapsed display time of the tip
00740     UINT   m_nDisplayDelay;             //!< Delay in ms before the tip is displayed
00741     BOOL   m_bActivated;                //!< Are tips activated?
00742     BOOL   m_bTipCancelled;             //!< Has the current tooltip been cancelled?
00743     BOOL   m_bHasExtendedText;          //!< TRUE if the tooltip contains extended text
00744     BOOL   m_bExtended;                 //!< Is the tip displaying extended info?
00745 
00746     COLORREF m_crBackColor;             //!< Default background color of tips
00747     COLORREF m_crTextColor;             //!< Default foreground color of tips
00748 
00749     HWND   m_hOldFocusWnd;              //!< window that had focus before the tooltip
00750                                         //! was clicked on
00751 
00752     static LPCTSTR m_szArrowSpace;      //!< Spaces (' ') added to allow room for arrow in text
00753 
00754 protected:
00755     enum { eIDDisplayToolEvent = 1, eIDCheckToolEvent = 2};
00756 
00757 private:
00758     #ifndef GENERATING_DOXYGEN_OUTPUT
00759     CObArray m_arrTools;                  //!< Collection of all tools
00760 
00761    //! Generated message map functions
00762 protected:
00763    //!{{AFX_MSG(COXToolTipCtrl)
00764    afx_msg void OnPaint();
00765    afx_msg void OnTimer(UINT nIDEvent);
00766    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
00767    afx_msg void OnSetFocus(CWnd* pOldWnd);
00768    afx_msg void OnDestroy();
00769    afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
00770    afx_msg int OnMouseActivate(CWnd* pDesktopWnd, UINT nHitTest, UINT message);
00771    //!}}AFX_MSG
00772     afx_msg LRESULT OnSetFont(WPARAM hFont, LPARAM lParam);
00773     afx_msg LRESULT OnGetFont(WPARAM hFont, LPARAM lParam);
00774    DECLARE_MESSAGE_MAP()
00775    #endif // GENERATING_DOXYGEN_OUTPUT
00776 };
00777 
00778 /////////////////////////////////////////////////////////////////////////////!
00779 
00780 //!{{AFX_INSERT_LOCATION}}
00781 //! Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00782 
00783 #endif //!< !defined(_OXTOOLTIPCTRL_H__)
00784 
00785 #endif // GENERATING_DOXYGEN_OUTPUT
00786 #endif  // INC_MGUI_OXTTCTRL_H

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