Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes
CBrowserToolTip Class Reference

#include <BrowserToolTip.h>

List of all members.

Public Member Functions

 CBrowserToolTip ()
virtual ~CBrowserToolTip ()
BOOL Create (CWnd *pParentWnd)
void SetTipText (const CString &szTipText)
void Show (CWnd *pOverWnd, long left, long top)
void Hide ()
 CBrowserToolTip ()
virtual ~CBrowserToolTip ()
BOOL Create (CWnd *pParentWnd)
void SetTipText (const CString &szTipText)
void Show (CWnd *pOverWnd, long left, long top)
void Hide ()

Protected Member Functions

virtual BOOL PreCreateWindow (CREATESTRUCT &cs)
afx_msg void OnPaint ()
virtual BOOL PreCreateWindow (CREATESTRUCT &cs)
afx_msg void OnPaint ()

Protected Attributes

CString m_szTipText

Detailed Description

Definition at line 50 of file BrowserToolTip.h.


Constructor & Destructor Documentation

Definition at line 51 of file BrowserToolTip.cpp.

{
}

Definition at line 55 of file BrowserToolTip.cpp.

{
}
virtual CBrowserToolTip::~CBrowserToolTip ( ) [virtual]

Member Function Documentation

BOOL CBrowserToolTip::Create ( CWnd *  pParentWnd)
BOOL CBrowserToolTip::Create ( CWnd *  pParentWnd)

Definition at line 66 of file BrowserToolTip.cpp.

{
    return CWnd::CreateEx(WS_EX_TOOLWINDOW,
        AfxRegisterWndClass(CS_SAVEBITS, NULL, GetSysColorBrush(COLOR_INFOBK), NULL),
        _T("ToolTip"), WS_POPUP | WS_BORDER, 0, 0, 1, 1, pParentWnd->GetSafeHwnd(), NULL);
}

Definition at line 149 of file BrowserToolTip.cpp.

{
    ShowWindow(SW_HIDE);
}
afx_msg void CBrowserToolTip::OnPaint ( ) [protected]
void CBrowserToolTip::OnPaint ( ) [protected]

Definition at line 76 of file BrowserToolTip.cpp.

{
       CPaintDC dc(this); // device context for painting

    CRect rcClient;
    GetClientRect(&rcClient);

    // Draw tip text
    int oldBkMode = dc.SetBkMode(TRANSPARENT);
    COLORREF oldTextColor = dc.SetTextColor(GetSysColor(COLOR_INFOTEXT));
    HGDIOBJ oldFont = dc.SelectObject(GetStockObject(DEFAULT_GUI_FONT));

    dc.DrawText(m_szTipText, -1, rcClient, DT_SINGLELINE | DT_VCENTER | DT_CENTER);

    dc.SetBkMode(oldBkMode);
    dc.SetTextColor(oldTextColor);
    dc.SelectObject(oldFont);
}
virtual BOOL CBrowserToolTip::PreCreateWindow ( CREATESTRUCT &  cs) [protected, virtual]
BOOL CBrowserToolTip::PreCreateWindow ( CREATESTRUCT &  cs) [protected, virtual]

Definition at line 95 of file BrowserToolTip.cpp.

{
       return CWnd::PreCreateWindow(cs);
}
void CBrowserToolTip::SetTipText ( const CString &  szTipText)
void CBrowserToolTip::SetTipText ( const CString &  szTipText)

Definition at line 100 of file BrowserToolTip.cpp.

{
    m_szTipText = szTipText;
}
void CBrowserToolTip::Show ( CWnd *  pOverWnd,
long  left,
long  top 
)
void CBrowserToolTip::Show ( CWnd *  pOverWnd,
long  left,
long  top 
)

Definition at line 105 of file BrowserToolTip.cpp.

{
    // Calculate the client window size
    CRect rcNewClient(0,0,0,0);
    CDC *pdc = GetDC();
    HGDIOBJ oldFont = pdc->SelectObject(GetStockObject(DEFAULT_GUI_FONT));
    rcNewClient.bottom = pdc->DrawText(m_szTipText, -1, rcNewClient,
        DT_SINGLELINE | DT_VCENTER | DT_CENTER | DT_CALCRECT);
    pdc->SelectObject(oldFont);
    ReleaseDC(pdc);
    rcNewClient.right += 8;
    rcNewClient.bottom += 8;
    
    // Adjust the tooltip to new size
    AdjustWindowRectEx(rcNewClient, GetWindowLong(m_hWnd, GWL_STYLE), FALSE, GetWindowLong(m_hWnd, GWL_EXSTYLE));

    // Adjust the left, top position of the tooltip
    CPoint ptTip(left, top);
    pOverWnd->ClientToScreen(&ptTip);

    // Make sure tip is below cursor
    POINT ptCursor;
    GetCursorPos(&ptCursor);
    long cyCursor = GetSystemMetrics(SM_CYCURSOR);
    if (ptTip.y < ptCursor.y + cyCursor)
        ptTip.y = ptCursor.y + cyCursor;

    // Make sure tip is fully visible
    RECT rcScreen;
    GetDesktopWindow()->GetClientRect(&rcScreen);
    if (ptTip.x < 0)
        ptTip.x = 0;
    else if (ptTip.x + rcNewClient.Width() > rcScreen.right)
        ptTip.x = rcScreen.right - rcNewClient.Width();
    if (ptTip.y < 0)
        ptTip.y = 0;
    else if (ptTip.y + rcNewClient.Height() > rcScreen.bottom)
        ptTip.y = rcScreen.bottom - rcNewClient.Height();

    // Position and show the tip
    SetWindowPos(&CWnd::wndTop, ptTip.x, ptTip.y, rcNewClient.Width(), rcNewClient.Height(),
        SWP_NOACTIVATE | SWP_SHOWWINDOW);
}

Member Data Documentation

CString CBrowserToolTip::m_szTipText [protected]

Definition at line 69 of file BrowserToolTip.h.


The documentation for this class was generated from the following files: