Пример #1
0
HDC
TkWinGetDrawableDC(
    Display *display,
    Drawable d,
    TkWinDCState *state)
{
    HDC dc;
    TkWinDrawable *twdPtr = (TkWinDrawable *)d;
    Colormap cmap;

    if (twdPtr->type == TWD_WINDOW) {
	TkWindow *winPtr = twdPtr->window.winPtr;

 	dc = GetDC(twdPtr->window.handle);
	if (winPtr == NULL) {
	    cmap = DefaultColormap(display, DefaultScreen(display));
	} else {
	    cmap = winPtr->atts.colormap;
	}
    } else if (twdPtr->type == TWD_WINDC) {
	dc = twdPtr->winDC.hdc;
	cmap = DefaultColormap(display, DefaultScreen(display));
    } else {
	dc = CreateCompatibleDC(NULL);
	SelectObject(dc, twdPtr->bitmap.handle);
	cmap = twdPtr->bitmap.colormap;
    }
    state->palette = TkWinSelectPalette(dc, cmap);
    state->bkmode  = GetBkMode(dc);
    return dc;
}
Пример #2
0
static void update_masks( dibdrv_physdev *pdev, INT rop )
{
    calc_and_xor_masks( rop, pdev->pen_color, &pdev->pen_and, &pdev->pen_xor );
    update_brush_rop( pdev, rop );
    if( GetBkMode( pdev->dev.hdc ) == OPAQUE )
        calc_and_xor_masks( rop, pdev->bkgnd_color, &pdev->bkgnd_and, &pdev->bkgnd_xor );
}
Пример #3
0
// If the background is a bitmap, and a tree is expanded/collapsed we
// need to redraw the entire background because windows moves the bitmap
// up (on collapse) destroying the position of the background.
void VividTree::OnTvnItemexpanding(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
	if ( GetBkMode() == VividTree::BK_MODE_BMP && ItemIsVisible( pNMTreeView->itemNew.hItem ) )
		Invalidate();  // redraw everything
	*pResult = 0;
}
Пример #4
0
void KTraceEMF::CompareDC(HDC hDC)
{
	Compare(m_value[0],  GetMapMode(hDC),						"MapMode      : %d\r\n");
	Compare(m_value[1],  GetGraphicsMode(hDC),					"GraphicsMode : %d\r\n");
	
	XFORM xm;
	GetWorldTransform(hDC, & xm);
	Compare(m_float[0],  xm.eM11,								"WT.eM11      : %8.5f\r\n");
	Compare(m_float[1],  xm.eM12,								"WT.eM12      : %8.5f\r\n");
	Compare(m_float[2],  xm.eM21,								"WT.eM21      : %8.5f\r\n");
	Compare(m_float[3],  xm.eM22,								"WT.eM22      : %8.5f\r\n");
	Compare(m_float[4],  xm.eDx,								"WT.eDx       : %8.5f\r\n");
	Compare(m_float[5],  xm.eDy,								"WT.eDy       : %8.5f\r\n");

	Compare(m_value[2],  GetBkMode(hDC),						"BkMode       : %d\r\n");
	Compare(m_value[3],  GetROP2(hDC),							"ROP2         : %d\r\n");
	Compare(m_value[4],  ((int)GetTextAlign(hDC)),				"TextAlign    : 0x%x\r\n");

	Compare(m_object[0], GetCurrentObject(hDC, OBJ_PEN),		"Pen          : 0x%08x\r\n");
	Compare(m_object[1], GetCurrentObject(hDC, OBJ_BRUSH),		"Brush        : 0x%08x\r\n");
	Compare(m_object[2], GetCurrentObject(hDC, OBJ_FONT),		"Font         : 0x%08x\r\n");
	Compare(m_object[3], GetCurrentObject(hDC, OBJ_PAL),		"Palette      : 0x%08x\r\n");
	Compare(m_object[4], GetCurrentObject(hDC, OBJ_COLORSPACE),	"ColorSpace   : 0x%08x\r\n");
	Compare(m_object[5], GetCurrentObject(hDC, OBJ_BITMAP),		"Bitmap       : 0x%08x\r\n");
}
Пример #5
0
// --------------------------------------------------------------
VGColor
GDeviceWin32::GetFontBackgroundColor() const
{
	int mode = GetBkMode(mHDC);
//	COLORREF c = GetBkColor(mHDC);
	unsigned char c = (unsigned char)GetTextColor( mHDC ); // COLORREF mask is 0x00bbggrr
	return VGColor ( c & 0xff, c & 0xff00, c & 0xff0000, mode == TRANSPARENT ? ALPHA_TRANSPARENT : ALPHA_OPAQUE);
}
Пример #6
0
void WinUndrawChar (int x, int y, char c, OSPictContext context)
{
	int oldmode;

	StartUndrawing(context);

	oldmode = GetBkMode (context->hDC);
	SetBkMode (context->hDC, TRANSPARENT);
	TextOut (context->hDC, x, y, &c, 1);
	SetBkMode (context->hDC, oldmode);
}	/* WinEraseChar */
Пример #7
0
/***************************************************************************
 *                get_pen_bkgnd_masks
 *
 * Returns the pre-calculated bkgnd color masks unless the dib is 1 bpp.
 * In this case since there are several fg sources (pen, brush, text)
 * this makes pdev->bkgnd_color unusable.  So here we take the inverse
 * of the relevant fg color (which is always set up correctly).
 */
static inline void get_pen_bkgnd_masks(const dibdrv_physdev *pdev, DWORD *and, DWORD *xor)
{
    if(pdev->dib.bit_count != 1 || GetBkMode(pdev->dev.hdc) == TRANSPARENT)
    {
        *and = pdev->bkgnd_and;
        *xor = pdev->bkgnd_xor;
    }
    else
    {
        DWORD color = ~pdev->pen_color;
        if(pdev->pen_colorref == GetBkColor(pdev->dev.hdc)) color = pdev->pen_color;
        calc_and_xor_masks( GetROP2(pdev->dev.hdc), color, and, xor );
    }
}
Пример #8
0
CPaintHelper::CPaintHelper(CUIGlobals &uig, HDC hDC) :
	m_uig(uig), m_priv_hDC(hDC), m_hDC(m_priv_hDC),
	m_eFont(UIF_VOID),
	m_eBrush(UIB_VOID),
	m_ePen(UIP_VOID),
	m_eText(UIC_VOID),
	m_eBk(UIC_VOID),
	m_hOldFont(NULL), m_hOldBrush(NULL), m_hOldPen(NULL),
	m_bOldFont(FALSE), m_bOldBrush(FALSE), m_bOldPen(FALSE)
{
	if (m_hDC != NULL)
	{
		m_oldtextcolor = GetTextColor(m_hDC);
		m_oldbkcolor = GetBkColor(m_hDC);
		m_oldbkmode = GetBkMode(m_hDC);
	}
}
Пример #9
0
void CentreText(HDC dc,int x,int y,char *font,int size,char *string,COLORREF Col)
{
	HFONT Font=CreateFont(size,0,0,0,FW_NORMAL,0,0,0,
		ANSI_CHARSET,OUT_TT_PRECIS,CLIP_TT_ALWAYS,PROOF_QUALITY,
		VARIABLE_PITCH | 4 | FF_DONTCARE,font);
	HFONT OldFont=(HFONT) SelectObject(dc,Font);
	SIZE sz;
	GetTextExtentPoint(dc, string,strlen(string), &sz);
	int BkMode=GetBkMode(dc);
	SetBkMode(dc,TRANSPARENT);
	COLORREF OldCol=SetTextColor(dc,Col);
	TextOut(dc,x-sz.cx/2,y-sz.cy/2,string,strlen(string));
	SetTextColor(dc,OldCol);
	SetBkMode(dc,BkMode);
	SelectObject(dc,OldFont);
	DeleteObject(Font);
}
Пример #10
0
/***********************************************************************
 *           dibdrv_SetBkColor
 */
static COLORREF dibdrv_SetBkColor( PHYSDEV dev, COLORREF color )
{
    PHYSDEV next = GET_NEXT_PHYSDEV( dev, pSetBkColor );
    dibdrv_physdev *pdev = get_dibdrv_pdev(dev);

    pdev->bkgnd_color = get_pixel_color( pdev, color, FALSE );

    if( GetBkMode(dev->hdc) == OPAQUE )
        calc_and_xor_masks( GetROP2(dev->hdc), pdev->bkgnd_color, &pdev->bkgnd_and, &pdev->bkgnd_xor );
    else
    {
        pdev->bkgnd_and = ~0u;
        pdev->bkgnd_xor = 0;
    }

    update_fg_colors( pdev ); /* Only needed in the 1 bpp case */

    return next->funcs->pSetBkColor( next, color );
}
Пример #11
0
void WinUndrawString (int x, int y, char *string, OSPictContext context)
{
	int oldmode;

	StartUndrawing(context);

	oldmode = GetBkMode (context->hDC);
	if (context->penMode==iModeXor)					/* Check if currently in XOR mode */
	{
		SetBkMode (context->hDC, OPAQUE);			/* in that case background should be OPAQUE. */
	}
	else
	{
		SetBkMode (context->hDC, TRANSPARENT);		/* otherwise it should be TRANSPARENT. */
	}
	if (!TextOut (context->hDC, x, y, string, strlen(string)))
		rMessageBox (NULL,MB_APPLMODAL,"WinDrawString","TextOut failed.");
	SetBkMode (context->hDC, oldmode);
}	/* WinEraseString */
Пример #12
0
static inline void get_brush_bkgnd_masks(const dibdrv_physdev *pdev, DWORD *and, DWORD *xor)
{
    if(GetBkMode(pdev->dev.hdc) == TRANSPARENT)
    {
        *and = pdev->bkgnd_and;
        *xor = pdev->bkgnd_xor;
    }
    else
    {
        DWORD color = pdev->bkgnd_color;

        if(pdev->dib.bit_count == 1)
        {
            if(pdev->brush_colorref == GetBkColor(pdev->dev.hdc))
                color = pdev->brush_color;
            else
                color = ~pdev->brush_color;
        }
        calc_and_xor_masks( pdev->brush_rop, color, and, xor );
    }
}
Пример #13
0
//---------------------------------------------------------------------------
void TColCombo::DrawItem(DRAWITEMSTRUCT *di)
{
	if (VHandle==NULL)return;

  HANDLE br;
  int oldtextcol=GetTextColor(di->hDC),oldmode=GetBkMode(di->hDC);

  if (di->itemState & ODS_SELECTED){
    br=CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT));
    SetTextColor(di->hDC,GetSysColor(COLOR_HIGHLIGHTTEXT));
  }else{
    br=CreateSolidBrush(GetSysColor(COLOR_WINDOW));
    SetTextColor(di->hDC,GetSysColor(COLOR_WINDOWTEXT));
  }

  SetBkMode(di->hDC,TRANSPARENT);
  FillRect(di->hDC,&(di->rcItem),br);
  DeleteObject(br);
  if ((di->itemID)<(UINT)NumItems){
    br=CreateSolidBrush(VItem[di->itemID]->Col);
    HANDLE pen=CreatePen(PS_SOLID,1,0);
    HANDLE oldpen=SelectObject(di->hDC,pen),oldbr=SelectObject(di->hDC,br);

    Rectangle(di->hDC,
              di->rcItem.left+BoxSurround,di->rcItem.top+BoxSurround,
              di->rcItem.left+(BoxWidth-BoxSurround),di->rcItem.bottom-BoxSurround);

    SelectObject(di->hDC,oldpen);SelectObject(di->hDC,oldbr);
    DeleteObject(pen);DeleteObject(br);

    RECT shiftrect=di->rcItem;shiftrect.left+=BoxWidth+BoxGap;
    DrawText(di->hDC,VItem[di->itemID]->Text,strlen(VItem[di->itemID]->Text),
              &shiftrect,DT_LEFT | DT_SINGLELINE | DT_VCENTER);
  }
  SetTextColor(di->hDC,oldtextcol);
  SetBkMode(di->hDC,oldmode);
  if (di->itemState & ODS_FOCUS)
    DrawFocusRect(di->hDC,&(di->rcItem));
}
Пример #14
0
void CPreviewDC::MirrorAttributes()
{
	ASSERT(m_hAttribDC != NULL);

	if (m_hDC != NULL)
	{
		// extract and re-set Pen and Brush
		HGDIOBJ hTemp = ::SelectObject(m_hAttribDC, ::GetStockObject(BLACK_PEN));
		::SelectObject(m_hAttribDC, hTemp);
		::SelectObject(m_hDC, hTemp);
		hTemp = ::SelectObject(m_hAttribDC, ::GetStockObject(BLACK_BRUSH));
		::SelectObject(m_hAttribDC, hTemp);
		::SelectObject(m_hDC, hTemp);

		SetROP2(GetROP2());
		SetBkMode(GetBkMode());
		SetTextAlign(GetTextAlign());
		SetPolyFillMode(GetPolyFillMode());
		SetStretchBltMode(GetStretchBltMode());
		SetTextColor(GetNearestColor(GetTextColor()));
		SetBkColor(GetNearestColor(GetBkColor()));
	}
}
Пример #15
0
void hdc_with_font::draw_text(const wstring& str, CRect& rect, colorref bg_color, bkmode bkm, colorref fg_color)
{
	use_this_font();
	
	if (bg_color.m_init) {
		COLORREF save = GetBkColor(m_dc);
		SetBkColor(m_dc, bg_color);
		bg_color = save;
	}

	if (fg_color.m_init) {
		COLORREF save = GetTextColor(m_dc);
		SetTextColor(m_dc, fg_color);
		fg_color = save;
	}

	if (bkm.m_init) {
		int save = GetBkMode(m_dc);
		SetBkMode(m_dc, bkm);
		bkm = save;
	}

	DrawText(m_dc, str.c_str(), str.size(), &rect, DT_VCENTER|DT_SINGLELINE);

	if (bg_color.m_init) {
		SetBkColor(m_dc, bg_color);
	}

	if (fg_color.m_init) {
		SetTextColor(m_dc, fg_color);
	}

	if (bkm.m_init) {
		SetBkMode(m_dc, bkm);
	}
}
Пример #16
0
void debugview_info::draw_contents(HDC windc)
{
	debug_view_char const *viewdata = m_view->viewdata();
	debug_view_xy const visarea = m_view->visible_size();

	// get the client rect
	RECT client;
	GetClientRect(m_wnd, &client);

	// create a compatible DC and an offscreen bitmap
	HDC const dc = CreateCompatibleDC(windc);
	if (dc == nullptr)
		return;
	HBITMAP const bitmap = CreateCompatibleBitmap(windc, client.right, client.bottom);
	if (bitmap == nullptr)
	{
		DeleteDC(dc);
		return;
	}
	HGDIOBJ const oldbitmap = SelectObject(dc, bitmap);

	// set the font
	HGDIOBJ const oldfont = SelectObject(dc, metrics().debug_font());
	COLORREF const oldfgcolor = GetTextColor(dc);
	int const oldbkmode = GetBkMode(dc);
	SetBkMode(dc, TRANSPARENT);

	// iterate over rows and columns
	for (UINT32 row = 0; row < visarea.y; row++)
	{
		// loop twice; once to fill the background and once to draw the text
		for (int iter = 0; iter < 2; iter++)
		{
			COLORREF fgcolor;
			COLORREF bgcolor = RGB(0xff,0xff,0xff);
			HBRUSH bgbrush = nullptr;
			int last_attrib = -1;
			TCHAR buffer[256];
			int count = 0;
			RECT bounds;

			// initialize the text bounds
			bounds.left = bounds.right = 0;
			bounds.top = row * metrics().debug_font_height();
			bounds.bottom = bounds.top + metrics().debug_font_height();

			// start with a brush on iteration #0
			if (iter == 0)
				bgbrush = CreateSolidBrush(bgcolor);

			// iterate over columns
			for (UINT32 col = 0; col < visarea.x; col++)
			{
				// if the attribute changed, adjust the colors
				if (viewdata[col].attrib != last_attrib)
				{
					COLORREF oldbg = bgcolor;

					// reset to standard colors
					fgcolor = RGB(0x00,0x00,0x00);
					bgcolor = RGB(0xff,0xff,0xff);

					// pick new fg/bg colors
					if (viewdata[col].attrib & DCA_VISITED) bgcolor = RGB(0xc6, 0xe2, 0xff);
					if (viewdata[col].attrib & DCA_ANCILLARY) bgcolor = RGB(0xe0,0xe0,0xe0);
					if (viewdata[col].attrib & DCA_SELECTED) bgcolor = RGB(0xff,0x80,0x80);
					if (viewdata[col].attrib & DCA_CURRENT) bgcolor = RGB(0xff,0xff,0x00);
					if ((viewdata[col].attrib & DCA_SELECTED) && (viewdata[col].attrib & DCA_CURRENT)) bgcolor = RGB(0xff,0xc0,0x80);
					if (viewdata[col].attrib & DCA_CHANGED) fgcolor = RGB(0xff,0x00,0x00);
					if (viewdata[col].attrib & DCA_INVALID) fgcolor = RGB(0x00,0x00,0xff);
					if (viewdata[col].attrib & DCA_DISABLED) fgcolor = RGB((GetRValue(fgcolor) + GetRValue(bgcolor)) / 2, (GetGValue(fgcolor) + GetGValue(bgcolor)) / 2, (GetBValue(fgcolor) + GetBValue(bgcolor)) / 2);
					if (viewdata[col].attrib & DCA_COMMENT) fgcolor = RGB(0x00,0x80,0x00);

					// flush any pending drawing
					if (count > 0)
					{
						bounds.right = bounds.left + (count * metrics().debug_font_width());
						if (iter == 0)
							FillRect(dc, &bounds, bgbrush);
						else
							ExtTextOut(dc, bounds.left, bounds.top, 0, nullptr, buffer, count, nullptr);
						bounds.left = bounds.right;
						count = 0;
					}

					// set the new colors
					if (iter == 0 && oldbg != bgcolor)
					{
						DeleteObject(bgbrush);
						bgbrush = CreateSolidBrush(bgcolor);
					}
					else if (iter == 1)
						SetTextColor(dc, fgcolor);
					last_attrib = viewdata[col].attrib;
				}

				// add this character to the buffer
				buffer[count++] = viewdata[col].byte;
			}

			// flush any remaining stuff
			if (count > 0)
			{
				bounds.right = bounds.left + (count * metrics().debug_font_width());
				if (iter == 0)
					FillRect(dc, &bounds, bgbrush);
				else
					ExtTextOut(dc, bounds.left, bounds.top, 0, nullptr, buffer, count, nullptr);
			}

			// erase to the end of the line
			if (iter == 0)
			{
				bounds.left = bounds.right;
				bounds.right = client.right;
				FillRect(dc, &bounds, bgbrush);
				DeleteObject(bgbrush);
			}
		}

		// advance viewdata
		viewdata += visarea.x;
	}

	// erase anything beyond the bottom with white
	GetClientRect(m_wnd, &client);
	client.top = visarea.y * metrics().debug_font_height();
	FillRect(dc, &client, (HBRUSH)GetStockObject(WHITE_BRUSH));

	// reset the font
	SetBkMode(dc, oldbkmode);
	SetTextColor(dc, oldfgcolor);
	SelectObject(dc, oldfont);

	// blit the final results
	BitBlt(windc, 0, 0, client.right, client.bottom, dc, 0, 0, SRCCOPY);

	// undo the offscreen stuff
	SelectObject(dc, oldbitmap);
	DeleteObject(bitmap);
	DeleteDC(dc);
}
Пример #17
0
static BOOL UITOOLS95_DrawFrameScroll(HDC dc, LPRECT r, UINT uFlags)
{
    LOGFONTW lf;
    HFONT hFont, hOldFont;
    COLORREF clrsave;
    RECT myr;
    INT bkmode;
    TCHAR Symbol;
    switch(uFlags & 0xff)
    {
        case DFCS_SCROLLCOMBOBOX:
        case DFCS_SCROLLDOWN:
		Symbol = '6';
		break;

	case DFCS_SCROLLUP:
		Symbol = '5';
		break;

	case DFCS_SCROLLLEFT:
		Symbol = '3';
		break;

	case DFCS_SCROLLRIGHT:
		Symbol = '4';
		break;

	case DFCS_SCROLLSIZEGRIP:
	case DFCS_SCROLLSIZEGRIPRIGHT:
		ZeroMemory(&lf, sizeof(LOGFONTW));
		UITOOLS_MakeSquareRect(r, &myr);
		lf.lfHeight = myr.bottom - myr.top;
		lf.lfWidth = 0;
		lf.lfWeight = FW_NORMAL;
		lf.lfCharSet = DEFAULT_CHARSET;
		lstrcpy(lf.lfFaceName, TEXT("Marlett"));
		hFont = CreateFontIndirect(&lf);
		/* save font and text color */
		hOldFont = SelectObject(dc, hFont);
		clrsave = GetTextColor(dc);
		bkmode = GetBkMode(dc);
		/* set color and drawing mode */
		SetBkMode(dc, TRANSPARENT);
		if (!(uFlags & (DFCS_MONO | DFCS_FLAT)))
		{
			SetTextColor(dc, GetSysColor(COLOR_BTNHIGHLIGHT));
			/* draw selected symbol */
			Symbol = ((uFlags & 0xff) == DFCS_SCROLLSIZEGRIP) ? 'o' : 'x';
			TextOut(dc, myr.left, myr.top, &Symbol, 1);
			SetTextColor(dc, GetSysColor(COLOR_BTNSHADOW));
		} else
			SetTextColor(dc, GetSysColor(COLOR_WINDOWFRAME));
		/* draw selected symbol */
		Symbol = ((uFlags & 0xff) == DFCS_SCROLLSIZEGRIP) ? 'p' : 'y';
		TextOut(dc, myr.left, myr.top, &Symbol, 1);
		/* restore previous settings */
		SetTextColor(dc, clrsave);
		SelectObject(dc, hOldFont);
		SetBkMode(dc, bkmode);
		DeleteObject(hFont);
            return TRUE;
	default:
            return FALSE;
    }
    IntDrawRectEdge(dc, r, (uFlags & DFCS_PUSHED) ? EDGE_SUNKEN : EDGE_RAISED, (uFlags&DFCS_FLAT) | BF_MIDDLE | BF_RECT);
    ZeroMemory(&lf, sizeof(LOGFONTW));
    UITOOLS_MakeSquareRect(r, &myr);
    myr.left += 1;
    myr.top += 1;
    myr.right -= 1;
    myr.bottom -= 1;
    if(uFlags & DFCS_PUSHED)
       OffsetRect(&myr,1,1);
    lf.lfHeight = myr.bottom - myr.top;
    lf.lfWidth = 0;
    lf.lfWeight = FW_NORMAL;
    lf.lfCharSet = DEFAULT_CHARSET;
    lstrcpy(lf.lfFaceName, TEXT("Marlett"));
    hFont = CreateFontIndirect(&lf);
    /* save font and text color */
    hOldFont = SelectObject(dc, hFont);
    clrsave = GetTextColor(dc);
    bkmode = GetBkMode(dc);
    /* set color and drawing mode */
    SetBkMode(dc, TRANSPARENT);
    if(uFlags & DFCS_INACTIVE)
    {
        /* draw shadow */
        SetTextColor(dc, GetSysColor(COLOR_BTNHIGHLIGHT));
        TextOut(dc, myr.left + 1, myr.top + 1, &Symbol, 1);
    }
    SetTextColor(dc, GetSysColor((uFlags & DFCS_INACTIVE) ? COLOR_BTNSHADOW : COLOR_BTNTEXT));
    /* draw selected symbol */
    TextOut(dc, myr.left, myr.top, &Symbol, 1);
    /* restore previous settings */
    SetTextColor(dc, clrsave);
    SelectObject(dc, hOldFont);
    SetBkMode(dc, bkmode);
    DeleteObject(hFont);
    return TRUE;
}
Пример #18
0
static BOOL UITOOLS95_DrawFrameCaption(HDC dc, LPRECT r, UINT uFlags)
{
    LOGFONTW lf;
    HFONT hFont, hOldFont;
    COLORREF clrsave;
    RECT myr;
    INT bkmode;
    TCHAR Symbol;
    switch(uFlags & 0xff)
    {
        case DFCS_CAPTIONCLOSE:
		Symbol = 'r';
		break;
        case DFCS_CAPTIONHELP:
		Symbol = 's';
		break;
        case DFCS_CAPTIONMIN:
		Symbol = '0';
		break;
        case DFCS_CAPTIONMAX:
		Symbol = '1';
		break;
        case DFCS_CAPTIONRESTORE:
		Symbol = '2';
		break;
        default:
             return FALSE;
    }
    IntDrawRectEdge(dc,r,(uFlags&DFCS_PUSHED) ? EDGE_SUNKEN : EDGE_RAISED, BF_RECT | BF_MIDDLE | BF_SOFT);
    ZeroMemory(&lf, sizeof(LOGFONTW));
    UITOOLS_MakeSquareRect(r, &myr);
    myr.left += 1;
    myr.top += 1;
    myr.right -= 1;
    myr.bottom -= 1;
    if(uFlags & DFCS_PUSHED)
       OffsetRect(&myr,1,1);
    lf.lfHeight = myr.bottom - myr.top;
    lf.lfWidth = 0;
    lf.lfWeight = FW_NORMAL;
    lf.lfCharSet = DEFAULT_CHARSET;
    lstrcpy(lf.lfFaceName, TEXT("Marlett"));
    hFont = CreateFontIndirect(&lf);
    /* save font and text color */
    hOldFont = SelectObject(dc, hFont);
    clrsave = GetTextColor(dc);
    bkmode = GetBkMode(dc);
    /* set color and drawing mode */
    SetBkMode(dc, TRANSPARENT);
    if(uFlags & DFCS_INACTIVE)
    {
        /* draw shadow */
        SetTextColor(dc, GetSysColor(COLOR_BTNHIGHLIGHT));
        TextOut(dc, myr.left + 1, myr.top + 1, &Symbol, 1);
    }
    SetTextColor(dc, GetSysColor((uFlags & DFCS_INACTIVE) ? COLOR_BTNSHADOW : COLOR_BTNTEXT));
    /* draw selected symbol */
    TextOut(dc, myr.left, myr.top, &Symbol, 1);
    /* restore previous settings */
    SetTextColor(dc, clrsave);
    SelectObject(dc, hOldFont);
    SetBkMode(dc, bkmode);
    DeleteObject(hFont);
    return TRUE;
}
Пример #19
0
static void
button_paint_icon(HWND win, button_t* button, HDC dc)
{
    HICON icon;
    RECT rect;
    RECT content;
    int state;
    SIZE size;
    UINT flags;
    HFONT font, old_font;
    int old_bk_mode;
    COLORREF old_text_color;
    HRGN old_clip;

    /* When theming is not used, we keep all the work on COMCTL32 button
     * implementation. */
    MC_ASSERT(button->theme != NULL);

    GetClientRect(win, &rect);

    icon = (HICON) MC_SEND(win, BM_GETIMAGE, IMAGE_ICON, 0);
    font = (HFONT) MC_SEND(win, WM_GETFONT, 0, 0);
    if(font == NULL)
        font = GetStockObject(SYSTEM_FONT);

    old_font = SelectObject(dc, font);
    old_bk_mode = GetBkMode(dc);
    old_text_color = GetTextColor(dc);
    old_clip = get_clip(dc);

    /* Draw background */
    if(button->style & WS_DISABLED) {
        state = PBS_DISABLED;
    } else {
        LRESULT s = MC_SEND(win, BM_GETSTATE, 0, 0);
        if(s & BST_PUSHED)
            state = PBS_PRESSED;
        else if(s & BST_HOT)
            state = PBS_HOT;
        else if(button->style & BS_DEFPUSHBUTTON)
            state = PBS_DEFAULTED;
        else
            state = PBS_NORMAL;
    }
    if(mcIsThemeBackgroundPartiallyTransparent(button->theme, BP_PUSHBUTTON, state))
        mcDrawThemeParentBackground(win, dc, &rect);
    mcDrawThemeBackground(button->theme, dc, BP_PUSHBUTTON, state, &rect, &rect);

    /* Get content rectangle of the button and clip DC to it */
    mcGetThemeBackgroundContentRect(button->theme, dc, BP_PUSHBUTTON, state, &rect, &content);
    IntersectClipRect(dc, content.left, content.top, content.right, content.bottom);

    /* Draw focus rectangle */
    if(MC_SEND(win, BM_GETSTATE, 0, 0) & BST_FOCUS) {
        if(!button->hide_focus)
            DrawFocusRect(dc, &content);
    }

    /* Draw the contents (i.e. the icon) */
    if(icon != NULL) {
        mc_icon_size(icon, &size);
        flags = DST_ICON;
        if(button->style & WS_DISABLED)
            flags |= DSS_DISABLED;
        DrawState(dc, NULL, NULL, (LPARAM) icon, 0, (rect.right + rect.left - size.cx) / 2,
                  (rect.bottom + rect.top - size.cy) / 2, size.cx, size.cy, flags);
    }

    /* Revert DC into original state */
    SelectObject(dc, old_font);
    SetBkMode(dc, old_bk_mode);
    SetTextColor(dc, old_text_color);
    SelectObject(dc, old_clip);
}
Пример #20
0
static void
button_paint_split(HWND win, button_t* button, HDC dc)
{
    RECT rect;
    RECT rect_left, rect_right;
    int state_left, state_right;
    int text_offset = 0;
    HFONT font, old_font;
    int old_bk_mode;
    COLORREF old_text_color;
    HRGN old_clip;
    HICON glyph;
    int width_right = DROPDOWN_W;

    glyph = ImageList_GetIcon(mc_bmp_glyphs, MC_BMP_GLYPH_MORE_OPTIONS, ILD_TRANSPARENT);
    GetClientRect(win, &rect);

    font = (HFONT) MC_SEND(win, WM_GETFONT, 0, 0);
    if(font == NULL)
        font = GetStockObject(SYSTEM_FONT);

    old_font = SelectObject(dc, font);
    old_bk_mode = GetBkMode(dc);
    old_text_color = GetTextColor(dc);
    old_clip = get_clip(dc);

    /* Draw what's common for left and right parts background. */
    if(!button->theme  &&  (button->style & BS_DEFPUSHBUTTON)) {
        SelectObject(dc, GetSysColorBrush(COLOR_WINDOWFRAME));
        Rectangle(dc, rect.left, rect.top, rect.right, rect.bottom);
        mc_rect_inflate(&rect, -1, -1);
        width_right--;
    }

    /* Setup subrectangles (mainpart 1 and push-down part 2) */
    mc_rect_copy(&rect_left, &rect);
    rect_left.right -= width_right;
    mc_rect_copy(&rect_right, &rect);
    rect_right.left = rect_left.right;

    /* Draw background. */
    if(button->theme) {
        UINT transparent;
        RECT tmp;

        /* Determine styles for left and right parts */
        if(button->style & WS_DISABLED) {
            state_left = state_right = PBS_DISABLED;
        } else {
            LRESULT state;

            state = MC_SEND(win, BM_GETSTATE, 0, 0);
            if(state & MC_BST_DROPDOWNPUSHED) {
                state_left = PBS_NORMAL;
                state_right = PBS_PRESSED;
            } else {
                if(state & BST_PUSHED)
                    state_left = state_right = PBS_PRESSED;
                else if(state & BST_HOT)
                    state_left = state_right = PBS_HOT;
                else if(button->style & BS_DEFPUSHBUTTON)
                    state_left = state_right = PBS_DEFAULTED;
                else
                    state_left = state_right = PBS_NORMAL;
            }
        }

        /* Handle (semi-)transparent themes. */
        transparent = 0;
        if(mcIsThemeBackgroundPartiallyTransparent(button->theme,
                    BP_PUSHBUTTON, state_left))
            transparent |= 0x1;
        if(mcIsThemeBackgroundPartiallyTransparent(button->theme,
                    BP_PUSHBUTTON, state_right))
            transparent |= 0x2;
        switch(transparent) {
            case 0x1:
                mcDrawThemeParentBackground(win, dc, &rect_left);
                break;
            case 0x2:
                mcDrawThemeParentBackground(win, dc, &rect_right);
                break;
            case 0x3:
                mcDrawThemeParentBackground(win, dc, &rect);
                break;
        }

        /* Draw backgrond. */
        mcDrawThemeBackground(button->theme, dc, BP_PUSHBUTTON, state_left, &rect, &rect_left);
        mcDrawThemeBackground(button->theme, dc, BP_PUSHBUTTON, state_right, &rect, &rect_right);

        /* Deflate both rects to content rects only */
        mcGetThemeBackgroundContentRect(button->theme, dc, BP_PUSHBUTTON, state_left, &rect_left, &tmp);
        rect_left.left = tmp.left;
        rect_left.top = tmp.top;
        rect_left.bottom = tmp.bottom;
        mcGetThemeBackgroundContentRect(button->theme, dc, BP_PUSHBUTTON, state_right, &rect_right, &tmp);
        rect_right.top = tmp.top;
        rect_right.right = tmp.right;
        rect_right.bottom = tmp.bottom;

        /* Draw delimiter of left and right parts. */
        rect_right.top += 1;
        rect_right.bottom -= 1;
        mcDrawThemeEdge(button->theme, dc, BP_PUSHBUTTON, state_right, &rect_right, BDR_SUNKEN, BF_LEFT, NULL);
        rect_right.left = tmp.left;
    } else {
        /* Determine styles for left and right parts */
        if(button->style & WS_DISABLED) {
            state_left = state_right = DFCS_INACTIVE;
        } else {
            LRESULT s = MC_SEND(win, BM_GETSTATE, 0, 0);
            if(s & MC_BST_DROPDOWNPUSHED) {
                state_left = 0;
                state_right = DFCS_PUSHED;
            } else {
                if(s & BST_PUSHED) {
                    state_left = state_right = DFCS_PUSHED;
                } else {
                    state_left = state_right = 0;
                }
            }
        }

        button_send_ctlcolorbtn(win, dc);

        /* Draw control edges */
        IntersectClipRect(dc, rect_left.left, rect_left.top, rect_left.right, rect_left.bottom);
        DrawFrameControl(dc, &rect, DFC_BUTTON, DFCS_BUTTONPUSH | state_left);
        SelectClipRgn(dc, NULL);
        IntersectClipRect(dc, rect_right.left, rect_right.top, rect_right.right, rect_right.bottom);
        DrawFrameControl(dc, &rect, DFC_BUTTON, DFCS_BUTTONPUSH | state_right);

        /* Parts which are pushed, should have the contents moved a bit */
        if(state_left == DFCS_PUSHED)
            mc_rect_offset(&rect_left, 1, 1);
        if(state_right == DFCS_PUSHED)
            mc_rect_offset(&rect_right, 1, 1);

        /* Draw delimiter */
        if(state_left == state_right) {
            DrawEdge(dc, &rect_right, BDR_SUNKENOUTER | BDR_RAISEDINNER, BF_LEFT | BF_SOFT);
        } else {
            rect_right.left--;
            DrawEdge(dc, &rect_right, BDR_SUNKENOUTER, BF_LEFT | BF_SOFT);
            rect_right.left++;
        }

        /* Adjust for the outer control edges */
        mc_rect_inflate(&rect_left, 0, -2);
        rect_left.left += 2;
        mc_rect_inflate(&rect_right, -2, -2);
    }

    /* Draw focus rectangle. */
    if((MC_SEND(win, BM_GETSTATE, 0, 0) & BST_FOCUS) && !button->hide_focus) {
        SelectClipRgn(dc, NULL);
        if(button->theme) {
            mc_rect_set(&rect, rect_left.left, rect_left.top,
                        rect_right.right - DROPDOWN_W, rect_right.bottom);
            DrawFocusRect(dc, &rect);
        } else {
            mc_rect_inflate(&rect_left, -1, -2);
            DrawFocusRect(dc, &rect_left);
            mc_rect_inflate(&rect_left, -1, -1);
        }
    }

    /* Draw glyph into the right part */
    SelectClipRgn(dc, NULL);
    IntersectClipRect(dc, rect_right.left, rect_right.top,
                          rect_right.right, rect_right.bottom);
    DrawIconEx(dc, (rect_right.right + rect_right.left - MC_BMP_GLYPH_W) / 2,
                   (rect_right.bottom + rect_right.top - MC_BMP_GLYPH_H) / 2,
                   glyph, MC_BMP_GLYPH_W, MC_BMP_GLYPH_H, 0, NULL, DI_NORMAL);

    /* Draw left part contents */
    SelectClipRgn(dc, NULL);
    IntersectClipRect(dc, rect_left.left, rect_left.top,
                          rect_left.right, rect_left.bottom);
    if(button->style & BS_ICON) {
        /* Paint (BS_SPLITBUTTON | BS_ICON). Note that this is used even on
         * Vista, as according to some my testing this style combination
         * is not supported there... */
        HICON icon;

        icon = (HICON) MC_SEND(win, BM_GETIMAGE, (WPARAM) IMAGE_ICON, (LPARAM) 0);
        if(icon != NULL) {
            SIZE size;
            UINT flags;

            mc_icon_size(icon, &size);

            flags = DST_ICON;
            if(button->style & WS_DISABLED)
                flags |= DSS_DISABLED;

            DrawState(dc, NULL, NULL, (LPARAM) icon, 0,
                      (rect_left.right + rect_left.left - size.cx) / 2,
                      (rect_left.bottom + rect_left.top - size.cy) / 2,
                      size.cx, size.cy, flags);
        }
    } else {
        /* Paint text label */
        TCHAR buffer[256];
        int n;
        UINT flags = 0;

        /* Setup flags for TextOut/mcDrawThemeText */
        switch(button->style & (BS_LEFT | BS_CENTER | BS_RIGHT)) {
            case BS_LEFT:
                flags |= DT_LEFT;
                break;
            case BS_RIGHT:
                flags |= DT_RIGHT;
                break;
            default:
                if(GetWindowLong(win, GWL_EXSTYLE) & WS_EX_RIGHT)
                    flags |= DT_RIGHT;
                else
                    flags |= DT_CENTER;
                break;
        }
        switch(button->style & (BS_TOP | BS_VCENTER | BS_BOTTOM)) {
            case BS_TOP:
                flags |= DT_TOP;
                break;
            case BS_BOTTOM:
                flags |= DT_BOTTOM;
                break;
            default:
                flags |= DT_VCENTER;
                break;
        }
        if(button->style & BS_MULTILINE)
            flags |= DT_WORDBREAK;
        else
            flags |= DT_SINGLELINE;

        if(button->hide_accel)
            flags |= DT_HIDEPREFIX;

        n = MC_SEND(win, WM_GETTEXT, MC_ARRAY_SIZE(buffer), buffer);

        if(button->theme) {
            mcDrawThemeText(button->theme, dc, BP_PUSHBUTTON,
                        state_left, buffer, n, flags, 0, &rect_left);
        } else {
            SetBkMode(dc, TRANSPARENT);
            SetTextColor(dc, GetSysColor(COLOR_BTNTEXT));
            mc_rect_offset(&rect_left, text_offset, text_offset);
            DrawText(dc, buffer, n, &rect_left, flags);
        }
    }

    SelectObject(dc, old_font);
    SetBkMode(dc, old_bk_mode);
    SetTextColor(dc, old_text_color);
    SelectObject(dc, old_clip);
}
Пример #21
0
/* WINE synced 22-May-2006 */
static LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCWSTR lpstr,
                                INT count, INT cTabStops, const INT *lpTabPos, INT nTabOrg,
                                BOOL fDisplayText )
{
    INT defWidth;
    SIZE extent;
    int i, j;
    int start = x;

    if (!lpTabPos)
        cTabStops=0;

    if (cTabStops == 1)
    {
        defWidth = *lpTabPos;
        cTabStops = 0;
    }
    else
    {
        TEXTMETRICA tm;
        GetTextMetricsA( hdc, &tm );
        defWidth = 8 * tm.tmAveCharWidth;
    }

    while (count > 0)
    {
        RECT r;
        INT x0;
        x0 = x;
        r.left = x0;
        /* chop the string into substrings of 0 or more <tabs>
         * possibly followed by 1 or more normal characters */
        for (i = 0; i < count; i++)
            if (lpstr[i] != '\t') break;
        for (j = i; j < count; j++)
            if (lpstr[j] == '\t') break;
        /* get the extent of the normal character part */
        GetTextExtentPointW( hdc, lpstr + i, j - i , &extent );
        /* and if there is a <tab>, calculate its position */
        if( i) {
            /* get x coordinate for the drawing of this string */
            for (; cTabStops > i; lpTabPos++, cTabStops--)
            {
                if( nTabOrg + abs( *lpTabPos) > x) {
                    if( lpTabPos[ i - 1] >= 0) {
                        /* a left aligned tab */
                        x = nTabOrg + lpTabPos[ i-1] + extent.cx;
                        break;
                    }
                    else
                    {
                        /* if tab pos is negative then text is right-aligned
                         * to tab stop meaning that the string extends to the
                         * left, so we must subtract the width of the string */
                        if (nTabOrg - lpTabPos[ i - 1] - extent.cx > x)
                        {
                            x = nTabOrg - lpTabPos[ i - 1];
                            x0 = x - extent.cx;
                            break;
                        }
                    }
                }
            }
            /* if we have run out of tab stops and we have a valid default tab
             * stop width then round x up to that width */
            if ((cTabStops <= i) && (defWidth > 0)) {
                x0 = nTabOrg + ((x - nTabOrg) / defWidth + i) * defWidth;
                x = x0 + extent.cx;
            } else if ((cTabStops <= i) && (defWidth < 0)) {
                x = nTabOrg + ((x - nTabOrg + extent.cx) / -defWidth + i)
                    * -defWidth;
                x0 = x - extent.cx;
            }
        } else
            x += extent.cx;

        if (fDisplayText)
        {
            r.top    = y;
            r.right  = x;
            r.bottom = y + extent.cy;
            ExtTextOutW( hdc, x0, y, GetBkMode(hdc) == OPAQUE ? ETO_OPAQUE : 0,
                         &r, lpstr + i, j - i, NULL );
        }
        count -= j;
        lpstr += j;
    }
    return MAKELONG(x - start, extent.cy);
}
Пример #22
0
TANY PEXPORT KpiUpdateRectLight(OBJECTID idSelf, LPSTR ap)
{
    WORD wType = OBJECT_TYPE(idSelf);
    ATOMID idWidget = KppGetItemName(wType, idSelf);
    ATOMID idValue = va_far_arg(ap, ATOMID);
    short sXL, sHeight = 0;
    WORD wMaxWidth, wTextHeight, wRectWidth, wTitleHgt;
    ATOMID idOwner, idOwnerSlot, idItem, idDesc;
    LISTID idPossValues;
    WORD wNumPossValues;
    HBRUSH hRedBrush, hWhiteBrush, hOldBrush;
    RECT rect;
    HFONT hOldFont;
    short sBkMode;
    DWORD dwTextColor;
    HDC hDC;
    HWND hWnd;
    TANY res;
    
    res.type = T_CBOOL;
    res.data.cbool = FALSE;
    
    KppGetAtomInt(Kpp_Get_SlotValue(wType, idSelf, lpSNs->idWinIdSN),
		  (int *) &hWnd);
    if (!hWnd)
        return res;
    
    hDC = GetDC(hWnd);
    if (!hDC)
        return res;
    
    idOwner = Kpp_Get_SlotValue(wType, idSelf, lpSNs->idOwnerSN);
    idOwnerSlot = Kpp_Get_SlotValue(wType, idSelf, lpSNs->idOwnerSlotSN);
    idDesc = Kpp_Get_SlotValue(wType, idSelf, lpSNs->idTitleSN);
    if (!idOwner || !idOwnerSlot || !idDesc)
    {
        ReleaseDC(hWnd, hDC);
        return res;
    }

    if (idOwner == lpIDs->idNull || idOwnerSlot == lpIDs->idNull)
    {
        idPossValues = Kpp_Get_SlotListValue(wType, idSelf,
                                             lpSNs->idPossValuesSN);
        if (!idPossValues)
        {
            ReleaseDC(hWnd, hDC);
            return res;
        }
    }
    else
    {
        /* Get the current values from owner */
        if (!idValue || idValue == lpIDs->idNull)
            idValue = KppGetSlotValue(idOwner, idOwnerSlot);

		idPossValues =  KppGetOption(idOwner, idOwnerSlot, OPT_PV);
		if (!idPossValues || idPossValues == lpIDs->idNull)
            idPossValues = Kpp_Get_SlotListValue(wType, idSelf,
                                                 lpSNs->idPossValuesSN);

        if (!idValue)
        {
            ReleaseDC(hWnd, hDC);
            return res;
        }
    }

    /* Determine the maximum width of a string in possible values */
    wNumPossValues = KppListLen(idPossValues);
    if (!wNumPossValues)
    {
        ReleaseDC(hWnd, hDC);
        return res;
    }

    /* Determine scaling parameters */
    hOldFont = KpsSetWidgetFont(idWidget, hDC, FALSE, 1.0);
    wMaxWidth = DetRStringWidths(hDC, idPossValues, idDesc,
                                 &wRectWidth, &wTextHeight);

    SetupRLightMapping(hWnd, hDC, wMaxWidth, wTextHeight, wNumPossValues);

    sXL = (short) ((double) wRectWidth / 2.0);

    if (idDesc != lpIDs->idNull)
    {
        SelectObject(hDC, hOldFont);
        hOldFont = KpsSetWidgetFont(idWidget, hDC, TRUE, 1.0);
        KppGetAtomName(idDesc, (LPSTR) pBuffer, 50);
        wTitleHgt = HIWORD(GetTextExtent(hDC, (LPSTR) pBuffer,
                                         strlen(pBuffer)));
        sHeight = HALF_VERT_PAD + wTitleHgt;
        if (hOldFont)
            SelectObject(hDC, hOldFont);
    }

    hOldFont = KpsSetWidgetFont(idWidget, hDC, FALSE, 1.0);
    sHeight += (VERT_PAD + HALF_VERT_PAD);

    sBkMode = GetBkMode(hDC);
    hRedBrush = CreateSolidBrush(RGB(255, 0, 0));
    hWhiteBrush = KpsSetWidgetText2Color(idWidget, hDC, (HBRUSH) NULL);
    dwTextColor = GetTextColor(hDC);
    hOldBrush = SelectObject(hDC, hWhiteBrush);

    if (idPossValues && idPossValues != lpIDs->idNull)
    {
        LIST_LOOP loop;
        
        kpc_init_loop(idPossValues, &loop);
        while (idItem = KppNextListElement(&loop)) {
            WORD wLen = KppGetAtomName(idItem, pBuffer, 32);
            
            sHeight += (VERT_PAD + wTextHeight);
            SelectObject(hDC, hWhiteBrush);
            ECHO_ROUNDRECT(hDC, sXL, sHeight, wTextHeight);

            if (idValue == idItem)
            {
                SelectObject(hDC, hRedBrush);
                SetTextColor(hDC, RGB(255, 255, 255));
            }
            else
            {
                SelectObject(hDC, hWhiteBrush);
                SetTextColor(hDC, dwTextColor);
            }

            DRAW_ROUNDRECT(hDC, sXL, sHeight, wTextHeight);
            FILLRECT(rect, -sXL, sHeight, sXL, sHeight - wTextHeight);

            SetBkMode(hDC, TRANSPARENT);
            DrawText(hDC, pBuffer, wLen, &rect, DT_CENTER);
            SetBkMode(hDC, OPAQUE);
            sHeight += VERT_PAD;
        }
    }

    Kpp_Set_SlotValue(wType, idSelf, lpSNs->idValueSN, idValue, EXPATOM);

    SetBkMode(hDC, sBkMode);
    SelectObject(hDC, hOldFont);
    SelectObject(hDC, hOldBrush);
    DeleteObject(hRedBrush);
    SetTextColor(hDC, BLACK);
    ReleaseDC(hWnd, hDC);

    res.data.cbool = TRUE;
    return res;
}
Пример #23
0
TANY PEXPORT KpiDrawRectLight(OBJECTID idSelf, LPSTR ap)
{
    WORD wType = OBJECT_TYPE(idSelf);
    ATOMID idWidget = va_far_arg(ap, ATOMID);
    short sXL, sHeight = 0;
    char *Context = "Context";
    ATOMID idOwner =
        Kpp_Get_SlotValue(wType, idSelf, lpSNs->idOwnerSN);
    ATOMID idOwnerSlot =
        Kpp_Get_SlotValue(wType, idSelf, lpSNs->idOwnerSlotSN);
    WORD wMaxWidth, wTextHeight, wTitleHgt;
    BOOL bOwnerValues = FALSE;
    short sBkMode;
    HDC hDC;
    HWND hWnd;
    ATOMID idDesc, idValue = NULLID, idItem;
    LISTID idPossValues;
    WORD wNumPossValues, wRectWidth;
    RECT rect;
    HBRUSH hRedBrush, hWhiteBrush, hOldBrush;
    HFONT hOldFont;
    DWORD dwTextColor;
    TANY res;
    
    res.type = T_CBOOL;
    res.data.cbool = FALSE;
    
    KppGetAtomInt(Kpp_Get_SlotValue(wType, idSelf, lpSNs->idWinIdSN),
		  (int *) &hWnd);
    if (!hWnd)
        return res;

    hDC = GetProp(hWnd, Context);
    if (!hDC)
        hDC = GetDC(hWnd);

    if (idOwner != lpIDs->idNull && idOwnerSlot != lpIDs->idNull)
    {
        idValue = KppGetSlotValue(idOwner, idOwnerSlot);
        idPossValues = KppGetOption(idOwner, idOwnerSlot, OPT_PV);
        wNumPossValues = KppListLen(idPossValues);

        if (wNumPossValues > 0)
            bOwnerValues = TRUE;
    }

    if (!bOwnerValues)
    {
        idPossValues = Kpp_Get_SlotListValue(wType, idSelf,
                                             lpSNs->idPossValuesSN);
        wNumPossValues = KppListLen(idPossValues);
    }

    if (!idValue || idValue == lpIDs->idNull)
        idValue = Kpp_Get_SlotValue(wType, idSelf, lpSNs->idValueSN);

    if (wNumPossValues <= 0)
    {
        if (!GetProp(hWnd, Context))
            ReleaseDC(hWnd, hDC);
        return res;
    }

    idDesc = Kpp_Get_SlotValue(wType, idSelf, lpSNs->idTitleSN);
    SetTextColor(hDC, BLACK);

    hOldFont = KpsSetWidgetFont(idWidget, hDC, FALSE, 1.0);
    wMaxWidth = DetRStringWidths(hDC, idPossValues, idDesc, 
                                 &wRectWidth, &wTextHeight);

    SetupRLightMapping(hWnd, hDC, wMaxWidth, wTextHeight, wNumPossValues);

    sXL = (short) ((double) wMaxWidth / 2.0);

    if (hOldFont)
        SelectObject(hDC, hOldFont);

    if (idDesc != lpIDs->idNull)
    {
        WORD wLen = KppGetAtomName(idDesc, pBuffer, 50);
        HBRUSH hBrBack = KpsSetWidgetTextColor(idWidget, hDC, NULL);
        DWORD dwExtent;
        
        hOldFont = KpsSetWidgetFont(idWidget, hDC, TRUE, 1.0);
        SetBkMode(hDC, TRANSPARENT);

        dwExtent = GetTextExtent(hDC, pBuffer, wLen);
        wMaxWidth = LOWORD(dwExtent);
        wTitleHgt = HIWORD(dwExtent);
        sXL = (short) ((double) wMaxWidth / 2.0);
        sHeight = HALF_VERT_PAD + wTitleHgt;
        FILLRECT(rect, -sXL, sHeight, sXL, sHeight - wTitleHgt);
        DrawText(hDC, pBuffer, wLen, &rect, DT_CENTER);

        if (hOldFont)
        {
            SelectObject(hDC, hOldFont);
            hOldFont = NULL;
        }
        DeleteObject(hBrBack);
        SetTextColor(hDC, BLACK);
    }

    hOldFont = KpsSetWidgetFont(idWidget, hDC, FALSE, 1.0);

    sXL = (short) ((double) wRectWidth / 2.0);
    sHeight += (VERT_PAD + HALF_VERT_PAD);

    /* Prepare fonts && brushes */
    sBkMode = GetBkMode(hDC);
    hRedBrush = CreateSolidBrush(RGB(255, 0, 0));

    hWhiteBrush = KpsSetWidgetText2Color(idWidget, hDC, NULL);
    dwTextColor = GetTextColor(hDC);

    hOldBrush = SelectObject(hDC, hWhiteBrush);

    /* Begin looping && draw possible values */
    if (idPossValues && idPossValues != lpIDs->idNull)
    {
        LIST_LOOP loop;
        
        kpc_init_loop(idPossValues, &loop);
        while (idItem = KppNextListElement(&loop)) {
            WORD wLen = KppGetAtomName(idItem, pBuffer, 32);

            sHeight += (VERT_PAD + wTextHeight);

            SelectObject(hDC, hWhiteBrush);
            ECHO_ROUNDRECT(hDC, sXL, sHeight, wTextHeight);

            if (idValue == idItem)
            {
                SelectObject(hDC, hRedBrush);
                SetTextColor(hDC, RGB(255, 255, 255));
            }
            else
            {
                SelectObject(hDC, hWhiteBrush);
                SetTextColor(hDC, dwTextColor);
            }
            DRAW_ROUNDRECT(hDC, sXL, sHeight, wTextHeight);

            FILLRECT(rect, -sXL, sHeight, sXL, sHeight - wTextHeight);

            SetBkMode(hDC, TRANSPARENT);
            DrawText(hDC, pBuffer, wLen, &rect, DT_CENTER);
            SetBkMode(hDC, OPAQUE);
            sHeight += VERT_PAD;
        }
    }

    Kpp_Set_SlotValue(wType, idSelf, lpSNs->idValueSN, idValue, EXPATOM);

    /* Restore the fonts && brushes */
    SetBkMode(hDC, sBkMode);
    SelectObject(hDC, hOldFont);
    SelectObject(hDC, hOldBrush);
    DeleteObject(hRedBrush);
    SetTextColor(hDC, dwTextColor);

    if (!GetProp(hWnd, Context))
        ReleaseDC(hWnd, hDC);
    
    res.data.cbool = TRUE;
    return res;
}
Пример #24
0
void vis_lyrics_draw(HDC dc)
{
	vis_lyrics_timercall();

	if(vis_lyric_current_text_len && vis_lyric_current_action == 1)
	{
		int      bkmod;
		COLORREF col;
		RECT     rct;
		WINDOWPLACEMENT  wp;
		HFONT    oldfont;

		GetWindowPlacement(window_vis, &wp);

		GetClientRect(window_vis, &rct);

		bkmod = GetBkMode(dc);
		col = GetTextColor(dc);

		SetBkMode(dc, TRANSPARENT);


		if(wp.showCmd != SW_MAXIMIZE)
		{
			rct.top     = rct.bottom - 13 -  (vis_lyrics_font_size + 10) ;
			rct.bottom  -= 13;
			rct.left    =  20;
			rct.right   -= 28;
		}else{
			rct.top     = rct.bottom -  (vis_lyrics_font_size + 10) ;
		}

		//SetTextColor(dc, 0x0);
		//oldfont = (HFONT)SelectObject(dc, vis_lyric_font_b);
		//DrawText(dc, vis_lyric_current_text, vis_lyric_current_text_len, &rct, DT_CENTER | DT_END_ELLIPSIS | DT_VCENTER | DT_SINGLELINE);
		//SelectObject(dc, oldfont);

		rct.left    += 1;
		rct.right   += 1;

		SetTextColor(dc, 0xffffff);
		oldfont = (HFONT)SelectObject(dc, vis_lyric_font);
		DrawText(dc, vis_lyric_current_text, vis_lyric_current_text_len, &rct, DT_CENTER | DT_END_ELLIPSIS | DT_VCENTER | DT_SINGLELINE);
		SelectObject(dc, oldfont);



		SetBkMode(dc, bkmod);
		SetTextColor(dc, col);

		//vis_lyric_current_laction = vis_lyric_current_action;
		//vis_lyric_current_action = 0;
	}

	if(vis_lyric_current_action == 2)
	{
		RECT     rct;
		WINDOWPLACEMENT  wp;

		GetWindowPlacement(window_vis, &wp);


		GetClientRect(window_vis, &rct);

		if(wp.showCmd != SW_MAXIMIZE)
		{
			BitBlt(dc, 10, rct.bottom - 13 - 20, rct.right - (10 + 12), 20, 0, 0, 0, BLACKNESS);
		}else{
			BitBlt(dc, 0, rct.bottom - 20, rct.right, 20, 0, 0, 0, BLACKNESS);
		}

		vis_lyric_current_laction = vis_lyric_current_action;
		vis_lyric_current_action = 0;
	}
}
Пример #25
0
void KDCAttributes::DumpDC(HDC hDC)
{
	POINT pnt;
	SIZE  size;

	m_List.DeleteAll();

	Add(_T("Technology"),  _T("%d"), GetDeviceCaps(hDC, TECHNOLOGY));
	Add(_T("width"),	   _T("%d"), GetDeviceCaps(hDC, HORZRES));
	Add(_T("height"),	   _T("%d"), GetDeviceCaps(hDC, VERTRES));

	GetDCOrgEx(hDC, & pnt); 
	Add(_T("DC Origin"), _T("{ %d, %d }"), pnt.x, pnt.y);

	TCHAR szTitle[MAX_PATH];

	szTitle[0] = 0;

	GetWindowText(WindowFromDC(hDC), szTitle, MAX_PATH);
	Add(_T("Window"),    _T("0x%X \"%s\""), WindowFromDC(hDC), szTitle);

	Add(_T("Bitmap"),        _T("0x%X"), GetCurrentObject(hDC, OBJ_BITMAP));

	Add(_T("Graphics Mode"), _T("%d"), GetGraphicsMode(hDC));
	Add(_T("Mapping Mode"),  _T("%d"), GetMapMode(hDC));

	GetViewportExtEx(hDC, & size);
	Add(_T("Viewport Extent"), _T("{ %d, %d }"), size.cx, size.cy);
	
	GetViewportOrgEx(hDC, & pnt);
	Add(_T("Viewport Origin"), _T("{ %d, %d }"), pnt.x, pnt.y);

	GetWindowExtEx(hDC, & size);
	Add(_T("Window Extent"), _T("{ %d, %d }"), size.cx, size.cy);
	
	GetWindowOrgEx(hDC, & pnt);
	Add(_T("Window Origin"), _T("{ %d, %d }"), pnt.x, pnt.y);

	XFORM xform;
	GetWorldTransform(hDC, & xform);

	Add(_T("World transformation"), _T("{ %f, %f, %f, %f, %f, %f }"),
		xform.eM11, xform.eM12, xform.eM21, xform.eM22, xform.eDx, xform.eDy);

	// transformation

	Add(_T("Background Color"), _T("0x%X"), GetBkColor(hDC));
	Add(_T("Text Color"),       _T("0x%X"), GetTextColor(hDC));
	Add(_T("Palette"),          _T("0x%X"), GetCurrentObject(hDC, OBJ_PAL));

	{
		COLORADJUSTMENT ca;
		GetColorAdjustment(hDC, & ca);
	
		Add(_T("Color Adjustment"), _T("{ %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d }"), 
			ca.caSize, ca.caFlags, ca.caIlluminantIndex,
			ca.caRedGamma, ca.caGreenGamma, ca.caBlueGamma, 
			ca.caReferenceBlack, ca.caReferenceWhite,
			ca.caContrast, ca.caBrightness, ca.caColorfulness, ca.caRedGreenTint);
	}

	Add(_T("Color Space"), _T("0x%X"), GetColorSpace(hDC));
	Add(_T("ICM Mode"),    _T("%d"),   SetICMMode(hDC, ICM_QUERY));

	{
		TCHAR szProfile[MAX_PATH];
		DWORD dwSize = MAX_PATH;

		szProfile[0] = 0;
		GetICMProfile(hDC, & dwSize, szProfile);

		Add(_T("ICM Profile"), _T("%s"), szProfile);
	}

	GetCurrentPositionEx(hDC, & pnt);
	Add(_T("Current Position"), _T("{ %d, %d }"), pnt.x, pnt.y);

	Add(_T("ROP2"),				_T("%d"),	GetROP2(hDC));
	Add(_T("Background Mode"),	_T("%d"),	GetBkMode(hDC));
	Add(_T("Logical Pen"),		_T("0x%X"), GetCurrentObject(hDC, OBJ_PEN));
	Add(_T("DC Pen Color"),     _T("0x%X"), GetDCPenColor(hDC));
	Add(_T("Arc Direction"),	_T("%d"),	GetArcDirection(hDC));

	FLOAT miter;
	GetMiterLimit(hDC, & miter);

	Add(_T("Miter Limit"),		_T("%f"),	miter);
	
	Add(_T("Logical Brush"),    _T("0x%X"), GetCurrentObject(hDC, OBJ_BRUSH));
	Add(_T("DC Brush Color"),   _T("0x%X"), GetDCBrushColor(hDC));

	GetBrushOrgEx(hDC, & pnt);
	Add(_T("Brush Origin"),     _T("{ %d, %d }"), pnt.x, pnt.y);

	Add(_T("Polygon Filling Mode"),   _T("%d"), GetPolyFillMode(hDC));
	Add(_T("Bitmap Stretching Mode"), _T("%d"), GetStretchBltMode(hDC));
	Add(_T("Logical Font"),			  _T("0x%X"), GetCurrentObject(hDC, OBJ_FONT));
	Add(_T("Inter-character spacing"), _T("%d"), GetTextCharacterExtra(hDC));

	DWORD flag = SetMapperFlags(hDC, 0);
	SetMapperFlags(hDC, flag);

	Add(_T("Font Mapper Flags"),       _T("0x%X"), flag);

	Add(_T("Text Alignment"),		   _T("0x%X"), GetTextAlign(hDC));

	Add(_T("Text Justification"),      _T("write only"), 0);

	Add(_T("Layout"),                  _T("%d"), GetLayout(hDC));

	Add(_T("Path"),					   _T("%d bytes"), GetPath(hDC, NULL, NULL, 0));

	RECT rect;

	int typ = GetClipBox(hDC, & rect);

	HRGN hRgn = CreateRectRgn(0, 0, 1, 1);
	
	GetClipRgn(hDC, hRgn);

	Add(_T("Clipping"),				   _T("type %d clip box { %d, %d, %d, %d } size %d bytes"), 
		typ, rect.left, rect.top, rect.right, rect.bottom,
		GetRegionData(hRgn, 0, NULL)
		);
	
	GetMetaRgn(hDC, hRgn);

	GetRgnBox(hRgn, & rect);
	Add(_T("Meta Region"), _T("size %d bytes, rgn box { %d, %d, %d, %d }"), 
		GetRegionData(hRgn, 0, NULL), rect.left, rect.top, rect.right, rect.bottom);

	for (int i=1; i<=5; i++)
	{
		int rslt = GetRandomRgn(hDC, hRgn, i);

		if ( rslt==1 )
		{
			GetRgnBox(hRgn, & rect);
			Add(_T("Random Region"), _T("size %d bytes, rgn box { %d, %d, %d, %d }"), 
			GetRegionData(hRgn, 0, NULL), rect.left, rect.top, rect.right, rect.bottom);
		}
		else if ( rslt==0 )
			Add(_T("Random Region"), _T("NULL"), 0);
		else
			Add(_T("Random Region"), _T("FAIL"), 0);
	}
	DeleteObject(hRgn);

	GetBoundsRect(hDC, & rect, 0);

	Add(_T("Bounds Rectangle"),		_T("{ %d, %d, %d, %d }"), 
		rect.left, rect.top, rect.right, rect.bottom);
}