Example #1
0
//----偏移一个窗口--------------------------------------------------------------
//描述: 偏移一个窗口位置,不包括子窗口.该函数为内部调用,非线程安全
//参数:hwnd:窗口句柄.
//      dx,dy: 水平和垂直方向的偏移量.
//返回:无.
//------------------------------------------------------------------------------
static  void    _OffsetWindowRect(HWND hwnd,int dx,int dy)
{
    _OffsetRect(&hwnd->WinRect,dx,dy);
    _OffsetRect(&hwnd->CliRect,dx,dy);

    GK_ApiMoveWin(  hwnd->pGkWin,
                    hwnd->WinRect.left,hwnd->WinRect.top,
                    0*mS);
    PostMessage(hwnd,MSG_PAINT,0,0);

}
Example #2
0
BOOL    OffsetRect(RECT *prc,int dx,int dy)
{
    if(NULL!=prc)
    {
        _OffsetRect(prc,dx,dy);
        return TRUE;
    }
    return FALSE;
}
Example #3
0
int BBDrawText(HDC hDC, const char *lpString, int nCount, LPRECT lpRect, UINT uFormat, StyleItem* pSI){
    bool bShadow = (pSI->validated & V_SHADOWCOLOR) && (pSI->ShadowColor != (CLR_INVALID));
    bool bOutline = (pSI->validated & V_OUTLINECOLOR) && (pSI->OutlineColor != (CLR_INVALID));
	
	if (bShadow){ // draw shadow
        RECT rcShadow;
		rcShadow.top = lpRect->top + pSI->ShadowY;
		rcShadow.bottom = lpRect->bottom + pSI->ShadowY;
		rcShadow.left = lpRect->left + pSI->ShadowX;
		rcShadow.right = lpRect->right + pSI->ShadowX;

        //SetTextColor(hDC, pSI->ShadowColor);
		bbDrawText(hDC, lpString, &rcShadow, uFormat, pSI->ShadowColor);
    }
	
    if (bOutline){ // draw outline
			//Draw the outline
	        RECT rcOutline;
	        _CopyOffsetRect(&rcOutline, lpRect, 1, 0);
	        //SetTextColor(hDC, pSI->OutlineColor);
			
			bbDrawText(hDC, lpString, &rcOutline, uFormat, pSI->OutlineColor);
			_OffsetRect(&rcOutline,   0,  1);
			bbDrawText(hDC, lpString, &rcOutline, uFormat, pSI->OutlineColor);
			_OffsetRect(&rcOutline,  -1,  0);
			bbDrawText(hDC, lpString, &rcOutline, uFormat, pSI->OutlineColor);
			_OffsetRect(&rcOutline,  -1,  0);
			bbDrawText(hDC, lpString, &rcOutline, uFormat, pSI->OutlineColor);
			_OffsetRect(&rcOutline,   0, -1);
			bbDrawText(hDC, lpString, &rcOutline, uFormat, pSI->OutlineColor);
			_OffsetRect(&rcOutline,   0, -1);
			bbDrawText(hDC, lpString, &rcOutline, uFormat, pSI->OutlineColor);
			_OffsetRect(&rcOutline,   1,  0);
			bbDrawText(hDC, lpString, &rcOutline, uFormat, pSI->OutlineColor);
			_OffsetRect(&rcOutline,   1,  0);
			bbDrawText(hDC, lpString, &rcOutline, uFormat, pSI->OutlineColor);
		//}
    }
    // draw text
    //SetTextColor(hDC, pSI->TextColor);
    bbDrawText(hDC, lpString, lpRect, uFormat, pSI->TextColor);
	return 1;//FIXME: Supposed to be DrawText(); - Should probably not call into bbDrawText to do the dirty work
}
Example #4
0
//===========================================================================
// Function: get_fontheight
//===========================================================================
int get_fontheight(HFONT hFont)
{
	TEXTMETRIC TXM;
	HDC hdc = CreateCompatibleDC(NULL);
	HGDIOBJ other = SelectObject(hdc, hFont);
	GetTextMetrics(hdc, &TXM);
	SelectObject(hdc, other);
	DeleteDC(hdc);
	return TXM.tmHeight;// - TXM.tmInternalLeading - TXM.tmExternalLeading;
//===========================================================================
// Function: BBDrawText
// Purpose: draw text with shadow and/or outline
// In:
// Out:
//===========================================================================
int BBDrawText(HDC hDC, LPCTSTR lpString, int nCount, LPRECT lpRect, UINT uFormat, StyleItem* pSI){
    if (pSI->validated & VALID_SHADOWCOLOR){ // draw shadow
        RECT rcShadow;
        SetTextColor(hDC, pSI->ShadowColor);
        if (pSI->validated & VALID_OUTLINECOLOR){ // draw shadow with outline
            _CopyOffsetRect(&rcShadow, lpRect, 2, 0);
            DrawText(hDC, lpString, nCount, &rcShadow, uFormat); _OffsetRect(&rcShadow,  0, pSI->ShadowY);
            DrawText(hDC, lpString, nCount, &rcShadow, uFormat); _OffsetRect(&rcShadow,  0, pSI->ShadowY);
            DrawText(hDC, lpString, nCount, &rcShadow, uFormat); _OffsetRect(&rcShadow, pSI->ShadowX, 0);
            DrawText(hDC, lpString, nCount, &rcShadow, uFormat); _OffsetRect(&rcShadow, pSI->ShadowX, 0);
            DrawText(hDC, lpString, nCount, &rcShadow, uFormat);
        }
        else{
            _CopyOffsetRect(&rcShadow, lpRect, pSI->ShadowX, pSI->ShadowY);
            DrawText(hDC, lpString, nCount, &rcShadow, uFormat);
        }
    }
    if (pSI->validated & VALID_OUTLINECOLOR){ // draw outline
        RECT rcOutline;
        SetTextColor(hDC, pSI->OutlineColor);
        _CopyOffsetRect(&rcOutline, lpRect, 1, 0);
        DrawText(hDC, lpString, nCount, &rcOutline, uFormat); _OffsetRect(&rcOutline,   0,  1);
        DrawText(hDC, lpString, nCount, &rcOutline, uFormat); _OffsetRect(&rcOutline,  -1,  0);
        DrawText(hDC, lpString, nCount, &rcOutline, uFormat); _OffsetRect(&rcOutline,  -1,  0);
        DrawText(hDC, lpString, nCount, &rcOutline, uFormat); _OffsetRect(&rcOutline,   0, -1);
        DrawText(hDC, lpString, nCount, &rcOutline, uFormat); _OffsetRect(&rcOutline,   0, -1);
        DrawText(hDC, lpString, nCount, &rcOutline, uFormat); _OffsetRect(&rcOutline,   1,  0);
        DrawText(hDC, lpString, nCount, &rcOutline, uFormat); _OffsetRect(&rcOutline,   1,  0);
        DrawText(hDC, lpString, nCount, &rcOutline, uFormat);
    }
    // draw text
    SetTextColor(hDC, pSI->TextColor);
    return DrawText(hDC, lpString, nCount, lpRect, uFormat);
}
}
void bbTooltip::_Show()
{
    RECT parent_rect;
    POINT pos;

    m_bInitial = false;

    GetWindowRect(m_hHost, &parent_rect);

    RECT r = {0, 0, m_pInfo->max_width, _MAX_HEIGHT};
	
	//if (m_pInfo->pStyle->ShadowXY && !m_pInfo->pStyle->parentRelative) {
	if (m_pInfo->pStyle->validated & VALID_SHADOWCOLOR) {
		RECT Rs;
		int i;
		COLORREF cr0;
		i = m_pInfo->pStyle->ShadowY;
		Rs.top = r.top + i;
		Rs.bottom = r.bottom + i;
		i = m_pInfo->pStyle->ShadowX;
		Rs.left = r.left + i;
		Rs.right = r.right + i;
		cr0 = SetTextColor(m_hSecondaryBuf, m_pInfo->pStyle->ShadowColor);
		DrawText(m_hSecondaryBuf, m_Text, -1, &Rs, DT_LEFT|DT_WORDBREAK|DT_CALCRECT|DT_END_ELLIPSIS);
		SetTextColor(m_hSecondaryBuf, cr0);
	}

#define VALID_OUTLINECOLOR  (1<<16) //October 30, 2011
	if (m_pInfo->pStyle->validated & VALID_OUTLINECOLOR) {	
		//COLORREF cr0;
			RECT rcOutline;
			//_CopyRect(&rcOutline, r);
			rcOutline.bottom = r.bottom;
			rcOutline.top = r.top;
			rcOutline.left = r.left+1;
			rcOutline.right = r.right+1;
			//cr0 = SetTextColor(bufDC, StyleItemArray[STYLE_TOOLBARLABEL].OutlineColor);
			SetTextColor(m_hSecondaryBuf, m_pInfo->pStyle->OutlineColor);
			//_CopyOffsetRect(&rcOutline, lpRect, 1, 0);
			DrawText(m_hSecondaryBuf, m_Text, -1, &rcOutline, DT_LEFT|DT_WORDBREAK|DT_CALCRECT|DT_END_ELLIPSIS);
			_OffsetRect(&rcOutline,   0,  1);
			DrawText(m_hSecondaryBuf, m_Text, -1, &rcOutline, DT_LEFT|DT_WORDBREAK|DT_CALCRECT|DT_END_ELLIPSIS);
			_OffsetRect(&rcOutline,  -1,  0);
			DrawText(m_hSecondaryBuf, m_Text, -1, &rcOutline, DT_LEFT|DT_WORDBREAK|DT_CALCRECT|DT_END_ELLIPSIS);
			_OffsetRect(&rcOutline,  -1,  0);
			DrawText(m_hSecondaryBuf, m_Text, -1, &rcOutline, DT_LEFT|DT_WORDBREAK|DT_CALCRECT|DT_END_ELLIPSIS);
			_OffsetRect(&rcOutline,   0, -1);
			DrawText(m_hSecondaryBuf, m_Text, -1, &rcOutline, DT_LEFT|DT_WORDBREAK|DT_CALCRECT|DT_END_ELLIPSIS);
			_OffsetRect(&rcOutline,   0, -1);
			DrawText(m_hSecondaryBuf, m_Text, -1, &rcOutline, DT_LEFT|DT_WORDBREAK|DT_CALCRECT|DT_END_ELLIPSIS);
			_OffsetRect(&rcOutline,   1,  0);
			DrawText(m_hSecondaryBuf, m_Text, -1, &rcOutline, DT_LEFT|DT_WORDBREAK|DT_CALCRECT|DT_END_ELLIPSIS);
			_OffsetRect(&rcOutline,   1,  0);
			DrawText(m_hSecondaryBuf, m_Text, -1, &rcOutline, DT_LEFT|DT_WORDBREAK|DT_CALCRECT|DT_END_ELLIPSIS);
	}
	//bool	shadow_ = m_pInfo->Tooltips_Shadow ? ( shadow_ = true ) : ( shadow_ = false );
	//COLORREF Shadow = CreateShadowColor(m_pInfo->pStyle, m_pInfo->pStyle->Color, m_pInfo->pStyle->ColorTo, m_pInfo->pStyle->TextColor);
	//DrawTextWithShadow( m_hSecondaryBuf, m_Text, r, DT_LEFT|DT_WORDBREAK|DT_CALCRECT|DT_END_ELLIPSIS, m_pInfo->pStyle->TextColor, Shadow, shadow_ );
    DrawText(m_hSecondaryBuf, m_Text, -1, &r, DT_LEFT|DT_WORDBREAK|DT_CALCRECT|DT_END_ELLIPSIS);

    m_Width = r.right - r.left + 2 * m_tipBorder;
    m_Height = r.bottom - r.top + 2 * m_tipBorder;

    pos.x = parent_rect.left + m_ActivationRect.left +
        (m_pInfo->bCenterTip ? ((m_ActivationRect.right - m_ActivationRect.left) / 2 - (m_Width / 2)): 0);

    if (pos.x < 0)
        pos.x = 0;
    else if ((pos.x + m_Width) > m_ScreenWidth)
        pos.x = m_ScreenWidth - m_Width;

    pos.y =
        ((m_pInfo->bAbove && ((m_Height + m_pInfo->distance) < parent_rect.top)) ||
        (!m_pInfo->bAbove && ((m_Height + m_pInfo->distance) > (m_ScreenHeight - parent_rect.bottom)))) ?
        parent_rect.top - m_Height - (m_pInfo->bDocked ? -m_BorderWidth: m_pInfo->distance):
        parent_rect.bottom + (m_pInfo->bDocked ? -m_BorderWidth: m_pInfo->distance);

    SetWindowPos(
        m_TipHwnd,
        HWND_TOPMOST,
        pos.x,
        pos.y,
        m_Width,
        m_Height,
        SWP_SHOWWINDOW|SWP_NOACTIVATE);

    InvalidateRect(m_TipHwnd, NULL, false);
}