Ejemplo n.º 1
0
COLORREF get_mixed_color(StyleItem *pSI)
{
    COLORREF b = get_bg_color(pSI);
    COLORREF t = pSI->TextColor;
    if (greyvalue(b) > greyvalue(t))
        return mixcolors(t, b, 96);
    else
        return mixcolors(t, b, 144);
}
Ejemplo n.º 2
0
void setTTC(int f)
{
	const int NCOLORS = 2;
	static int C_ID[NCOLORS] =
	{
		// tooltips bk + txt
		COLOR_INFOBK,
		COLOR_INFOTEXT
	};
	static COLORREF C_SAVE[NCOLORS];
	static bool changed;

	if (SAVE_3DC == f)
	{
		int n = 0;
		do C_SAVE[n] = GetSysColor(C_ID[n]);
		while (++n<NCOLORS);
		changed = false;
		return;
	}

	if (RESTORE_3DC == f || false == setTTColor)
	{
		if (changed)
		{
			SetSysColors(NCOLORS, C_ID, C_SAVE);
			changed = false;
		}
		return;
	}

	if (APPLY_3DC == f)
	{
		COLORREF C_CR[NCOLORS];
		GradientItem *S1, *S2;
		S1 = S2 = &mSkin.windowLabelFocus;

		if (S1->parentRelative)
			S1 = &mSkin.windowTitleFocus;

		if (B_SOLID == S1->type)
			C_CR[0] = S1->Color;
		else
			C_CR[0] = mixcolors(S1->Color, S1->ColorTo);

		C_CR[1] = S2->TextColor;

		SetSysColors(NCOLORS, C_ID, C_CR);
		changed = true;
	}
}
Ejemplo n.º 3
0
void paint_back (HDC hdc_scrn, RECT* m_rect, RECT *ptext)
{
    HDC hdc = NULL;
    if (NULL == hdc_back)
    {
        unsigned grey_b = grey_value (mixcolors(&mStyle.MenuFrame));
        unsigned grey_t = grey_value (mStyle.MenuFrame.TextColor);
        //dbg_printf("%d %d - #%06x #%06x", grey_b, grey_t, c1, c3);
        darkcolors = grey_b < grey_t;

        hdc = hdc_back  = CreateCompatibleDC(hdc_scrn);
        m_hBitMap = CreateCompatibleBitmap(hdc_scrn, m_rect->right, m_rect->bottom);
        SelectObject(hdc_back, m_hBitMap);
    }

    draw_frame(hdc, m_rect, title_h, ptext);
}
Ejemplo n.º 4
0
/*----------------------------------------------------------------------------*/
void paint_window(HWND hwnd) {

    PAINTSTRUCT ps ;
    HFONT       hfnt0;
    HDC         hdc;
    int i,k,n,y,x;
    //int mm,yy;
    char bstr[256];

    RECT rw, r; SIZE sz;

#define MEMDC

#ifdef MEMDC
    HBITMAP     bm0,bm;
    HDC         fhdc ;
#endif

#ifdef MEMDC
    fhdc = BeginPaint (hwnd, &ps);

    hdc  = CreateCompatibleDC(fhdc);
    bm   = CreateCompatibleBitmap(fhdc,cwx+FRM,cwy+FRM);
    bm0  = (HBITMAP)SelectObject(hdc,bm);
#else
    hdc  = BeginPaint(hwnd,&ps);
#endif

    //goto pe;

    //fillpaint(&ps.rcPaint, Cbgd, hdc);

    GetClientRect(hwnd, &rw);

    paint_back(hdc, &rw, &r);
    BitBltRect(hdc, hdc_back, &ps.rcPaint);

    hfnt0 = (HFONT)SelectObject(hdc,hfnt_n);

    if (0!=synhilite)
    {
        memmove (My_Colors, darkcolors ? My_Colors_d : My_Colors_l, sizeof(My_Colors));
    }

    My_Colors[0] = (COLORREF)-1;
    My_Colors[1] = mStyle.MenuFrame.TextColor;
    My_Colors[3] = mStyle.MenuHilite.TextColor;
    if (mStyle.MenuHilite.parentRelative)
        My_Colors[2] = grey_value (My_Colors[3]) > 128 ? 0x333333 : 0xeeeeee;
    else
        My_Colors[2] = mixcolors(&mStyle.MenuHilite);

    if (edp) {
        i=ps.rcPaint.top;
        k=ps.rcPaint.bottom;
        n=ps.rcPaint.right;

        i=(i-zy0)/zy;
        k=(k-zy0+zy-1)/zy;
        n=(n-zx0+zx-1)/zx;

        if (i<0) i=0;
        if (k<0) k=0;
        if (k>i && n>0) printpage(hdc,n,i,k);

        BitBlt(hdc, 0, rw.bottom-FRM,  rw.right,  FRM, hdc_back, 0, rw.bottom-FRM, SRCCOPY);
        BitBlt(hdc, rw.right-FRM,  0,  FRM, rw.bottom, hdc_back, rw.right-FRM,  0, SRCCOPY);
    }

    SetTextColor (hdc, mStyle.MenuTitle.TextColor );
    SetBkMode    (hdc, TRANSPARENT);
    //SelectObject (hdc, hfnt_sb);
    SelectObject (hdc, fnt2);
    format_status(bstr,1);
    DrawText(hdc, bstr, strlen(bstr), &r,
        //mStyle.MenuTitle.justify|DT_VCENTER|DT_SINGLELINE
        DT_LEFT|DT_VCENTER|DT_SINGLELINE
        );

    if (edp==NULL) goto paint_end;

    if (infomsg[0]) {

        SetBkColor   (hdc, My_Colors[2]);
        SetTextColor (hdc, My_Colors[3]);
        SetBkMode    (hdc,OPAQUE);

        SelectObject (hdc, fnt1);

        sprintf(bstr," %s ",infomsg);
        n=strlen(bstr);

        GetTextExtentPoint32 (hdc, bstr, n, &sz);
        y=cwy-sz.cy;
        x=cwx-sz.cx;
        if (x<0) x = 0;
        TextOut(hdc, x, y, bstr, n);
    }

    {
        StyleItem *pSI = &MenuInfo.Scroller;
        get_vscr_rect(&rw);
        MakeGradient_s(hdc, rw, pSI, pSI->bordered ?  pSI->borderWidth : 0);
    }

#if 0
    if (lmax==0
       && yy>=imin(tlin-plin,pgy)
       && mm>(pgx<50?pgx:pgx*6/5)
        ) lmax=mm;
#endif


paint_end:
    SelectObject (hdc, hfnt0);

#ifdef MEMDC
    BitBltRect(fhdc, hdc, &ps.rcPaint);
    //BitBlt(fhdc,0,0,cwx+FRM,cwy+FRM,hdc,0,0,SRCCOPY);
    SelectObject (hdc, bm0);
    DeleteDC(hdc);
    DeleteObject (bm);
#endif
    EndPaint (hwnd, &ps) ;

    if (edp && 0==scroll_lock && caret==1)
        ShowCaret(hwnd), caret=3;
}
Ejemplo n.º 5
0
COLORREF get_bg_color(StyleItem *pSI)
{
    if (B_SOLID == pSI->type) // && false == pSI->interlaced)
        return pSI->Color;
    return mixcolors(pSI->Color, pSI->ColorTo, 128);
}
Ejemplo n.º 6
0
void MenuItem::Paint(HDC hDC)
{
	RECT rect;

	COLORREF cr0 = (COLORREF)-1;
	bool lit = false;
	StyleItem *pSI = &mStyle.MenuFrame;

	if (m_bActive && 0 == (m_isNOP & (MI_NOP_TEXT | MI_NOP_SEP)) && (0 == (m_isNOP & MI_NOP_DISABLED) || m_pSubMenu))
	{
		// draw hilite bar
		GetItemRect(&rect);
		pSI = &mStyle.MenuHilite;
		MakeStyleGradient(hDC, &rect, pSI, pSI->bordered);
		cr0 = SetTextColor(hDC, pSI->TextColor);
		lit = true;
	}
	else
		if (m_isNOP & MI_NOP_DISABLED)
		{
			cr0 = SetTextColor(hDC, mStyle.MenuFrame.disabledColor);
		}

	//dbg_printf("Menu separator style is: %s",Settings_menuSeparatorStyle);

	// draw separator
	if (m_isNOP & MI_NOP_LINE)
	{
		int x, y = m_nTop + m_nHeight / 2;
		// Noccy: Looks like we have to remove some pixels here to prevent it from overwriting the right border.
		int left  = m_nLeft + ((Settings_menuFullSeparatorWidth)?1:mStyle.MenuSepMargin) - 1;
		int right = m_nLeft + m_nWidth - ((Settings_menuFullSeparatorWidth)?1:mStyle.MenuSepMargin);
		// int dist = (m_nWidth + 1) / 2 - ((Settings_menuFullSeparatorWidth==true)?mStyle.MenuFrame.borderWidth:mStyle.MenuSepMargin);
		int dist = (m_nWidth+1) / 2 - ((Settings_menuFullSeparatorWidth)?1:mStyle.MenuSepMargin);
		COLORREF c = mStyle.MenuSepColor;
		COLORREF cs = pSI->ShadowColor;

		if (pSI->ShadowXY)
		{
			int yS = y + pSI->ShadowY;
			int leftS  = left + pSI->ShadowX;
			int rightS = right + pSI->ShadowX;
			if (0 == stricmp(Settings_menuSeparatorStyle,"gradient"))
			{
				// Gradient shadow
				for (x = 0; x <= dist; ++x)
				{
					int pos, hue = x * 255 / dist;
					pos = leftS + x;
					SetPixel(hDC, pos, yS, mixcolors(cs, GetPixel(hDC, pos, y), hue));
					pos = rightS - x;
					SetPixel(hDC, pos, yS, mixcolors(cs, GetPixel(hDC, pos, y), hue));
				}
			}
			else
				if (0 == stricmp(Settings_menuSeparatorStyle,"flat"))
				{
					// Flat shadow
					for (x = 0; x <= dist; ++x)
					{
						int pos;
						pos = leftS + x;
						SetPixel(hDC, pos, yS, cs);
						pos = rightS - x;
						SetPixel(hDC, pos, yS, cs);
					}
				}
				else
					if (0 == stricmp(Settings_menuSeparatorStyle,"bevel"))
					{
						// Bevel shadow is simply none...
					}
		}
		if (0 == stricmp(Settings_menuSeparatorStyle,"gradient"))
		{
			for (x = 0; x <= dist; ++x)
			{
				int pos, hue = x * 255 / dist;
				pos = left + x;
				SetPixel(hDC, pos, y, mixcolors(c, GetPixel(hDC, pos, y), hue));
				pos = right - x;
				SetPixel(hDC, pos, y, mixcolors(c, GetPixel(hDC, pos, y), hue));
			}
		}
		else
			if (0 == stricmp(Settings_menuSeparatorStyle,"flat"))
			{
				for (x = 0; x <= dist; ++x)
				{
					int pos; //, hue = x * 255 / dist;
					pos = left + x;
					SetPixel(hDC, pos, y, c);
					pos = right - x;
					SetPixel(hDC, pos, y, c);
				}
			}
			else
				if (0 == stricmp(Settings_menuSeparatorStyle,"bevel"))
				{
					for (x = 0; x <= dist; ++x)
					{
						int pos;
						pos = left + x;
						SetPixel(hDC, pos, y, mixcolors(0x00000000, GetPixel(hDC, pos, y), 160));
						pos = right - x;
						SetPixel(hDC, pos, y, mixcolors(0x00000000, GetPixel(hDC, pos, y), 160));
						pos = left + x;
						SetPixel(hDC, pos, y+1, mixcolors(0x00FFFFFF, GetPixel(hDC, pos, y+1), 160));
						pos = right - x;
						SetPixel(hDC, pos, y+1, mixcolors(0x00FFFFFF, GetPixel(hDC, pos, y+1), 160));
					}
				}
	}

	int iconSize = m_pMenu->m_iconSize;
	if (-2 == iconSize) iconSize = MenuInfo.nIconSize;
	GetTextRect(&rect, iconSize);

	// [load and ]draw menu item icon
	if (iconSize)
	{
		bool bSmallIcon = (16 >= iconSize);
		// load menu item icon
		if (NULL == m_hIcon || bSmallIcon != m_bSmallIcon)
		{
			DestroyIcon(m_hIcon), m_hIcon = NULL;
			m_bSmallIcon = bSmallIcon;
			switch (m_iconMode)
			{
			case IM_PIDL:
			{
				const _ITEMIDLIST *pidl = (MENUITEM_ID_SF == m_ItemID) ?
										  ((SpecialFolderItem*)this)->check_pidl() : m_pidl;

				if (pidl)
				{
					SHFILEINFO sfi;
					HIMAGELIST sysimgl = (HIMAGELIST)SHGetFileInfo((LPCSTR)pidl, 0, &sfi, sizeof(SHFILEINFO), SHGFI_PIDL | SHGFI_SYSICONINDEX | (bSmallIcon ? SHGFI_SMALLICON : SHGFI_LARGEICON));
					if (sysimgl) m_hIcon = ImageList_GetIcon(sysimgl, sfi.iIcon, ILD_NORMAL);
				}
			}
			break;

			case IM_TASK:
			{
				const struct tasklist *tl = (struct tasklist *)m_im_stuff;
				m_hIcon = CopyIcon(bSmallIcon ? tl->icon : tl->icon_big);
			}
			break;

			case IM_PATH:
				char *icon = (char *)m_im_stuff;
				char *path = strrchr(icon, ',');
				int idx;
				if (path)
					idx = atoi(path + 1), *path = 0;
				else
					idx = 0;
				if (bSmallIcon)
					ExtractIconEx(icon, idx, NULL, &m_hIcon, 1);
				else
					ExtractIconEx(icon, idx, &m_hIcon, NULL, 1);
				if (path) *path = ',';
				break;
			}
		}

		// draw menu item icon
		if (m_hIcon)
		{
			int top = rect.top + (m_nHeight - iconSize) / 2;
			int adjust = (MenuInfo.nItemIndent[iconSize] - iconSize) / 2;
			int left = ((DT_LEFT == FolderItem::m_nBulletPosition) ? rect.right : m_nLeft) + adjust;
			drawIco(left, top, iconSize, m_hIcon, hDC, !m_bActive, Settings_menuIconSaturation, Settings_menuIconHue);
		}
	}


	/*
		Noccy: Added DT_NOPREFIX to BBDrawText to prevent ampersand (&) to be interpreted as
		a hotkey.
		Note: Reverted.
	*/

	// draw menu item text
	const char *title = GetDisplayString();

	if (0 == (m_ItemID & (~MENUITEM_ID_CI & (MENUITEM_ID_CIInt|MENUITEM_ID_CIStr))) || Settings_menusBroamMode)
		BBDrawText(hDC, title, -1, &rect, mStyle.MenuFrame.Justify | DT_MENU_STANDARD, pSI);
	else
		if (m_ItemID != MENUITEM_ID_CIStr)
			BBDrawText(hDC, title, -1, &rect, DT_CENTER | DT_MENU_STANDARD, pSI);

	// set back previous textColor
	if ((COLORREF)-1 != cr0) SetTextColor(hDC, cr0);

	if (m_isChecked) // draw check-mark
	{
		pSI = &mStyle.MenuHilite;
		bool pr = pSI->parentRelative;
		if (lit != pr) pSI = &mStyle.MenuFrame;

		int x, y = m_nTop + m_nHeight / 2;
		if ((FolderItem::m_nBulletPosition == DT_RIGHT) == (0 == (MENUITEM_ID_FOLDER & m_ItemID)))
			x = m_nLeft + m_nWidth - MenuInfo.nItemIndent[iconSize] / 2 - 1;
		else
			x = m_nLeft + MenuInfo.nItemIndent[iconSize] / 2;

		const int r = 3;
		rect.left   = x - r;
		rect.right  = x + r;
		rect.top    = y - r;
		rect.bottom = y + r;

		if (pr) MakeGradient(hDC, rect, B_SOLID, pSI->TextColor, 0, false, BEVEL_FLAT, 0, 0, 0, 0);
		else MakeStyleGradient(hDC, &rect, pSI, false);
	}
}
Ejemplo n.º 7
0
void SeparatorItem::Paint(HDC hDC)
{
	/* BlackboxZero 1.8.2012
	** Dont' use original..
    RECT rect; int y, d;
    if (false == Settings_menu.drawSeparators)
        return;
    GetTextRect(&rect);
    d = MenuInfo.separatorWidth;
    y = (rect.top + rect.bottom - d) / 2;
    draw_line_h(hDC, rect.left, rect.right, y, d, MenuInfo.separatorColor);
	** */

	StyleItem *pSI = &mStyle.MenuFrame;
	int x, y = m_nTop + m_nHeight / 2;
	// Noccy: Looks like we have to remove some pixels here to prevent it from overwriting the right border.
	int left  = m_nLeft + ((Settings_menu.separatorFullWidth)?1:mStyle.MenuSepMargin) - 1;
	int right = m_nLeft + m_nWidth - ((Settings_menu.separatorFullWidth)?1:mStyle.MenuSepMargin);
	// int dist = (m_nWidth + 1) / 2 - ((Settings_menuFullSeparatorWidth==true)?mStyle.MenuFrame.borderWidth:mStyle.MenuSepMargin);
	int dist = (m_nWidth+1) / 2 - ((Settings_menu.separatorFullWidth)?1:mStyle.MenuSepMargin);
	COLORREF c = mStyle.MenuSepColor;
	COLORREF cs = mStyle.MenuSepShadowColor;//pSI->ShadowColor; /*12.08.2011*/

	if (pSI->ShadowXY) {
		int yS = y + pSI->ShadowY;
		int leftS  = left + pSI->ShadowX;
		int rightS = right + pSI->ShadowX;
		if (0 == stricmp(Settings_menu.separatorStyle,"gradient")) {
			// Gradient shadow
			for (x = 0; x <= dist; ++x) {
				int pos, hue = x * 255 / dist;
				pos = leftS + x;
				SetPixel(hDC, pos, yS, mixcolors(cs, GetPixel(hDC, pos, y), hue));
				pos = rightS - x;
				SetPixel(hDC, pos, yS, mixcolors(cs, GetPixel(hDC, pos, y), hue));
			}
		} else if (0 == stricmp(Settings_menu.separatorStyle,"flat")) {
			// Flat shadow
			for (x = 0; x <= dist; ++x) {
				int pos;
				pos = leftS + x;
				SetPixel(hDC, pos, yS, cs);
				pos = rightS - x;
				SetPixel(hDC, pos, yS, cs);
			}
		} /*else if (0 == stricmp(Settings_menu.separatorStyle,"bevel")) {
				// Bevel shadow is simply none...
		}*/
	}

	//Draw Separator
	if (0 == stricmp(Settings_menu.separatorStyle,"gradient")) {
		for (x = 0; x <= dist; ++x) {
			int pos, hue = x * 255 / dist;
			pos = left + x;
			SetPixel(hDC, pos, y, mixcolors(c, GetPixel(hDC, pos, y), hue));
			pos = right - x;
			SetPixel(hDC, pos, y, mixcolors(c, GetPixel(hDC, pos, y), hue));
		}
	} else if (0 == stricmp(Settings_menu.separatorStyle,"flat")) {
		for (x = 0; x <= dist; ++x) {
			int pos; //, hue = x * 255 / dist;
			pos = left + x; SetPixel(hDC, pos, y, c);
			pos = right - x; SetPixel(hDC, pos, y, c);
		}
	} else if (0 == stricmp(Settings_menu.separatorStyle,"bevel")) {
		for (x = 0; x <= dist; ++x) {
			int pos;
			pos = left + x; SetPixel(hDC, pos, y, mixcolors(0x00000000, GetPixel(hDC, pos, y), 160));
			pos = right - x; SetPixel(hDC, pos, y, mixcolors(0x00000000, GetPixel(hDC, pos, y), 160));
			pos = left + x; SetPixel(hDC, pos, y+1, mixcolors(0x00FFFFFF, GetPixel(hDC, pos, y+1), 160));
			pos = right - x; SetPixel(hDC, pos, y+1, mixcolors(0x00FFFFFF, GetPixel(hDC, pos, y+1), 160));
		}
	}
}
Ejemplo n.º 8
0
void FolderItem::Paint(HDC hDC)
{
	MenuItem::Paint(hDC);

	COLORREF C =
		m_bActive
		? mStyle.MenuHilite.foregroundColor
		: (MI_NOP_DISABLED & m_isNOP)
		? mStyle.MenuFrame.disabledColor
		: mStyle.MenuFrame.foregroundColor
		;

	int r = mStyle.bulletUnix ? 2 : 3;

	int yOffset = m_nTop + m_nHeight / 2;
	int xOffset;
	if (FolderItem::m_nBulletPosition == DT_RIGHT)
		xOffset = m_nLeft + m_nWidth - MenuInfo.nItemIndent / 2 - 1;
	else
		xOffset = m_nLeft + MenuInfo.nItemIndent / 2;

	int xLeft   = xOffset - r;
	int xRight  = xOffset + r;
	int yTop    = yOffset - r;
	int yBottom = yOffset + r;

	HGDIOBJ oldPen = SelectObject(hDC, CreatePen(PS_SOLID, 1, C));
	switch (m_nBulletStyle)
	{
		case BS_TRIANGLE:
			arrow_bullet (hDC, xOffset, yOffset, m_nBulletPosition == DT_LEFT ? -1 : 1);
			break;

		case BS_SQUARE:
			MoveToEx(hDC, xRight, yBottom, NULL);
			LineTo  (hDC, xRight, yTop);
			LineTo  (hDC, xLeft,  yTop);
			LineTo  (hDC, xLeft,  yBottom);
			LineTo  (hDC, xRight, yBottom);
			break;

		case BS_DIAMOND:
			int  x1, x2, y;
			for (x2=1+(x1=xOffset), y = yTop; y <= yBottom; y++)
			{
				MoveToEx(hDC, x1, y, NULL);
				LineTo  (hDC, x2, y);
				if (y<yOffset) x1--, x2++;
				else     x1++, x2--;
			}
			break;

		case BS_CIRCLE:
			Arc(hDC, xLeft, yTop, xRight+1, yBottom+1, xOffset, 0, xOffset, 0);
			break;

		case BS_BMP:
			if (m_byBulletBmp == NULL) break;
			// if active, draw lower of Bitmap
			int nBmpPosY = m_bActive ? m_nBulletBmpSize : 0;
			// triming draw area
			int nBulletSize = (int)imin(m_nBulletBmpSize, (int)imin(m_nHeight, m_nWidth));
			// start/end pos
			int xs = xOffset - nBulletSize/2, xe = xs + nBulletSize;
			int ys = yOffset - nBulletSize/2, ye = ys + nBulletSize;
			for(int i = xs, m = 0; i < xe; i++, m++){
				for(int j = ys, n = nBmpPosY; j < ye; j++, n++){
					SetPixel(hDC, i, j, mixcolors(C, GetPixel(hDC, i, j), m_byBulletBmp[m][n]));
				}
			}
			break;

//		default:
//			break;
	}

	DeleteObject(SelectObject(hDC, oldPen));
}