void DrawHighlightedButton(buttonT & button) {
    SetPenColor("ACTIVATED_BACKGROUND");
    DrawBackground(button);
    SetPenColor("ACTIVATED_INNERSHADE");
    DrawInnerShade(button);
    SetPenColor("ACTIVATED_BORDER");
    DrawOutline(button);
    SetPenColor("ACTIVATED_TEXT");
    DrawButtonText(button);
}
void DrawNormalButton(buttonT & button) {
    SetPenColor("STANDARD_BACKGROUND");
    DrawBackground(button);
    SetPenColor("STANDARD_OUTERSHADE");
    DrawOuterShade(button);
    SetPenColor("STANDARD_INNERSHADE");
    DrawInnerShade(button);
    SetPenColor("STANDARD_HIGHLIGHT");
    DrawHighlight(button);
    SetPenColor("Black");
    DrawOutline(button);
    DrawButtonText(button);
}
Exemple #3
0
void CColorButton::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
    CDC* pDC = CDC::FromHandle(lpDIS->hDC);

    UINT state = lpDIS->itemState;
    CRect focusRect, btnRect;
    focusRect.CopyRect(&lpDIS->rcItem);
    btnRect.CopyRect(&lpDIS->rcItem);

    //
    // Set the focus rectangle to just past the border decoration
    //
    focusRect.left += 4;
    focusRect.right -= 4;
    focusRect.top += 4;
    focusRect.bottom -= 4;

    //
    // Retrieve the button's caption
    //
    const int bufSize = 512;
    TCHAR buffer[bufSize];
    GetWindowText(buffer, bufSize);


    //
    // Draw and label the button using draw methods
    //
    DrawFilledRect(pDC, btnRect, GetBGColor());
    DrawFrame(pDC, btnRect, GetBevel());
    DrawButtonText(pDC, btnRect, buffer, GetFGColor());


    //
    // Now, depending upon the state, redraw the button (down image) if it is selected,
    // place a focus rectangle on it, or redisplay the caption if it is disabled
    //
    if (state & ODS_FOCUS) {
        DrawFocusRect(lpDIS->hDC, (LPRECT)&focusRect);
        if (state & ODS_SELECTED) {
            DrawFilledRect(pDC, btnRect, GetBGColor());
            DrawFrame(pDC, btnRect, -1);


// ----> Changes!	// changes by RW:

            // move the button text if it is pressed...
            CRect rectPressedBtnText = btnRect;

            // to the right and bottom...
            rectPressedBtnText.OffsetRect( 1, 1 );

            // ... and now paint it!
            DrawButtonText(pDC, rectPressedBtnText, buffer, GetFGColor());

            // DrawButtonText(pDC, btnRect, buffer, GetFGColor());
            DrawFocusRect(lpDIS->hDC, (LPRECT)&focusRect);
        }
    }
    else if (state & ODS_DISABLED) {
        //COLORREF disabledColor = bg ^ 0xFFFFFF; // contrasting color
        DrawButtonText(pDC, btnRect, buffer, GetDisabledColor());
    }
}
void CClrButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	CDC		*dc;
	CRect	focus_rect, button_rect, text_rect, offset_text_rect;
	UINT	state;
	
	dc    = CDC::FromHandle(lpDrawItemStruct->hDC);
	state = lpDrawItemStruct->itemState;

	focus_rect.CopyRect(&lpDrawItemStruct->rcItem); 
	button_rect.CopyRect(&lpDrawItemStruct->rcItem); 

	text_rect = button_rect;
	text_rect.OffsetRect(-1, -1); 
	offset_text_rect = text_rect;
	offset_text_rect.OffsetRect(1, 1);

	// Set the focus rectangle to just past the border decoration
	focus_rect.left   += 4;
    focus_rect.right  -= 4;
    focus_rect.top    += 4;
    focus_rect.bottom -= 4;
      
	// Retrieve the button's caption
    const int bufSize = 512;
    TCHAR buffer[bufSize];
    GetWindowText(buffer, bufSize);

	if (state & ODS_DISABLED)
    {
		DrawFilledRect(dc, button_rect, disabled_background_colour);
	}
	else
	{
		DrawFilledRect(dc, button_rect, background_colour);
	}
		
	if (state & ODS_SELECTED)
	{ 
    	DrawFrame(dc, button_rect, BUTTON_IN);
	}
	else
	{
		if ((state & ODS_DEFAULT) || (state & ODS_FOCUS))
		{
			DrawFrame(dc, button_rect, BUTTON_OUT | BUTTON_BLACK_BORDER);			
		}
		else
		{
			DrawFrame(dc, button_rect, BUTTON_OUT);
		}
	}

	if (state & ODS_DISABLED)
	{
		DrawButtonText(dc, offset_text_rect, buffer, CLR_BTN_WHITE);
		DrawButtonText(dc, text_rect,		 buffer, CLR_BTN_DGREY);
    }
	else
	{
		if (state & ODS_SELECTED)
		{
			DrawButtonText(dc, offset_text_rect, buffer, text_colour);
		}
		else
		{
  			DrawButtonText(dc, text_rect, buffer, text_colour);
		}
	}

	if (state & ODS_FOCUS)
	{
		DrawFocusRect(lpDrawItemStruct->hDC, (LPRECT)&focus_rect);
	}
}