コード例 #1
0
//===========================================================================
void DrawActiveWindow(HDC buf, RECT r)
{
	COLORREF bColor;
	Settings const & s = getSettings();

	// Checks for windows just showing on the edges of the screen
	if (r.bottom - r.top < 2)
	{
		if (!_stricmp(s.m_focusedWindow.styleType, "border"))
			bColor = s.m_focusedWindow.borderColor;
		else
			bColor = s.m_window.borderColor;

		HPEN borderPen = CreatePen(PS_SOLID, 1, bColor);
		HPEN oldPen = (HPEN) SelectObject(buf, borderPen);

		MoveToEx(buf, r.left, r.top, NULL);
		LineTo(buf, r.right, r.top);

		SelectObject(buf,oldPen);
		DeleteObject(borderPen);

		//MessageBox(0, "Warning sir!\n\nCan't draw this window as a RECT dude!", "DrawActiveWindow", MB_OK | MB_TOPMOST | MB_SETFOREGROUND);

		return;
	}

	if (r.right - r.left < 2)
	{
		if (!_stricmp(s.m_focusedWindow.styleType, "border"))
			bColor = s.m_focusedWindow.borderColor;
		else
			bColor = s.m_window.borderColor;

		HPEN borderPen = CreatePen(PS_SOLID, 1, bColor);
		HPEN oldPen = (HPEN) SelectObject(buf, borderPen);

		MoveToEx(buf, r.left, r.top, NULL);
		LineTo(buf, r.left, r.bottom);

		SelectObject(buf,oldPen);
		DeleteObject(borderPen);

		return;
	}

	if (!_stricmp(s.m_focusedWindow.styleType, "texture"))
	{
		MakeStyleGradient(buf, &r, s.m_focusedWindow.ownStyle ? s.m_focusedWindow.style : &s.m_focusedWindow.Style, false);
		CreateBorder(buf, &r, s.m_focusedWindow.borderColor, 1);
	}
	else if (!_stricmp(s.m_focusedWindow.styleType, "border"))
	{
		MakeStyleGradient(buf, &r, s.m_window.ownStyle ? s.m_window.style : &s.m_window.Style, false);
		CreateBorder(buf, &r, s.m_focusedWindow.borderColor, 1);
	}
	else
		MakeStyleGradient(buf, &r, s.m_window.style, true);
}
コード例 #2
0
//===========================================================================
void DrawActiveDesktop(HDC buf, RECT r, int i)
{
	Settings const & s = getSettings();
	if (!_stricmp(s.m_activeDesktop.styleType, "border3")) 
	{
		r.right = r.right + 2;
		r.bottom = r.bottom + 2;

		if (s.m_activeDesktop.Style.parentRelative)
			CreateBorder(buf, &r, s.m_activeDesktop.borderColor, 1);
		else
		{
			MakeStyleGradient(buf, &r, s.m_activeDesktop.ownStyle ? s.m_activeDesktop.style : &s.m_activeDesktop.Style, false);
			CreateBorder(buf, &r, s.m_activeDesktop.borderColor, 1);
		}
	}
	else if (!_stricmp(s.m_activeDesktop.styleType, "border2")) 
	{
		r.left = r.left - 1;
		r.top = r.top - 1;
		r.right = r.right + 1;
		r.bottom = r.bottom + 1;

		if (!s.m_activeDesktop.ownStyle && s.m_activeDesktop.Style.parentRelative)
			CreateBorder(buf, &r, s.m_activeDesktop.borderColor, 1);
		else
		{
			MakeStyleGradient(buf, &r, s.m_activeDesktop.ownStyle ? s.m_activeDesktop.style : &s.m_activeDesktop.Style, false);
			CreateBorder(buf, &r, s.m_desktop.Style.borderColor, 1);
		}
	}
	else if (!_stricmp(s.m_activeDesktop.styleType, "border")) 
	{
		if (!s.m_activeDesktop.ownStyle && s.m_activeDesktop.Style.parentRelative)
			CreateBorder(buf, &r, s.m_activeDesktop.borderColor, 1);
		else
		{
			MakeStyleGradient(buf, &r, s.m_activeDesktop.ownStyle ? s.m_activeDesktop.style : &s.m_activeDesktop.Style, false);
			CreateBorder(buf, &r, s.m_desktop.Style.borderColor, 1);
		}
	}
	else if (!_stricmp(s.m_activeDesktop.styleType, "texture")) 
	{
		if (!s.m_activeDesktop.ownStyle && !s.m_activeDesktop.Style.parentRelative)
			MakeStyleGradient(buf, &r, s.m_activeDesktop.ownStyle ? s.m_activeDesktop.style : &s.m_activeDesktop.Style, false);
		CreateBorder(buf, &r, s.m_activeDesktop.borderColor, 1);
	}
	else if (!s.m_desktop.Style.parentRelative) // "none"
		MakeStyleGradient(buf, &r, s.m_desktop.ownStyle ? s.m_desktop.style : &s.m_desktop.Style, false);	

	//desktopRect[i] = r;
	desktopRect.insert(desktopRect.begin() + i, r);
}
コード例 #3
0
ファイル: bbSDK.cpp プロジェクト: Jmos/bbclean-xzero450
void paint_window(HDC hdc_buffer, RECT *p_rect)
{
    /* and draw the frame */
    MakeStyleGradient(hdc_buffer, p_rect, &my.Frame, my.drawBorder);

    if (my.windowText[0])
    {
        HGDIOBJ otherfont;
        int margin;
        RECT text_rect;

        /* Set the font, storing the default.. */
        otherfont = SelectObject(hdc_buffer, my.hFont);

        /* adjust the rectangle */
        margin = my.Frame.marginWidth + my.Frame.bevelposition;
        if (my.drawBorder)
            margin += my.Frame.borderWidth;

        text_rect.left  = p_rect->left + margin;
        text_rect.top   = p_rect->top + margin;
        text_rect.right = p_rect->right - margin;
        text_rect.bottom = p_rect->bottom - margin;

        /* draw the text */
        SetTextColor(hdc_buffer, my.Frame.TextColor);
        SetBkMode(hdc_buffer, TRANSPARENT);
        DrawText(hdc_buffer, my.windowText, -1, &text_rect,
            my.Frame.Justify|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS);

        /* Put back the previous default font. */
        SelectObject(hdc_buffer, otherfont);
    }
}
コード例 #4
0
void FoompButton::draw (HDC buf)
{
	//Create drawing tools
	HPEN hDefPen = CreatePen(PS_SOLID, 1, getStyles().OuterStyle.TextColor);
	HPEN hPressedPen = CreatePen(PS_SOLID, 1, getStyles().ButtonStyle.TextColor);
	HPEN hShadowPen = CreatePen(PS_SOLID, 1, GetShadowColor(getStyles().OuterStyle));
	HPEN hPressedShadowPen = CreatePen(PS_SOLID, 1, GetShadowColor(getStyles().ButtonStyle));
	//Save current object
	HGDIOBJ prev = SelectObject(buf,hDefPen);

	if (pressed)
		MakeStyleGradient(buf, &hitrect, &getStyles().ButtonStyle, false);

	if (getSettings().FooShadowsEnabled)
	{
		SelectObject(buf,pressed ? hPressedShadowPen : hShadowPen);
		drawShape(buf,x+1,y+1);
	}
	SelectObject(buf,pressed ? hPressedPen : hDefPen);
	drawShape(buf,x,y);


	//Revert old object
	SelectObject(buf, prev);
	//Destroy drawing tools
	DeleteObject(hDefPen);
	DeleteObject(hPressedPen);
	DeleteObject(hShadowPen);
	DeleteObject(hPressedShadowPen);
}
コード例 #5
0
ファイル: TitleItem.cpp プロジェクト: Jmos/bbclean-xzero450
void TitleItem::Paint(HDC hDC)
{
    StyleItem *pSI = &mStyle.MenuTitle;
    RECT rect; GetItemRect(&rect);
    int spacing = MenuInfo.nTitleIndent;
    int just = pSI->Justify | DT_MENU_STANDARD;
    int bw = pSI->borderWidth;
    COLORREF bc = pSI->borderColor;

    rect.bottom -= bw;
    if (false == pSI->parentRelative)
    {
        MakeStyleGradient(hDC, &rect, pSI, false);
        if (bw) draw_line_h(hDC, rect.left, rect.right, rect.bottom, bw, bc);
    }

    _InflateRect(&rect, -spacing, 0);

    if (pSI->parentRelative)
    {
        if (bw) draw_line_h(hDC, rect.left, rect.right, rect.bottom, bw, bc);
        rect.bottom -= MenuInfo.nTitlePrAdjust;
        just = just & ~DT_VCENTER | DT_BOTTOM;
    }

    if (pSI->FontHeight)
        BBDrawText(hDC, GetDisplayString(), -1, &rect, just, pSI);
}
コード例 #6
0
void DrawInactiveWindow(HDC buf, RECT r)
{
	Settings const & s = getSettings();
	if (r.bottom - r.top < 2)
	{
		HPEN borderPen = CreatePen(PS_SOLID, 1, getSettings().m_window.borderColor);
		HPEN oldPen = (HPEN) SelectObject(buf, borderPen);

		MoveToEx(buf, r.left, r.top, NULL);
		LineTo(buf, r.right, r.top);

		SelectObject(buf,oldPen);
		DeleteObject(borderPen);

		return;
	}

	if (r.right - r.left < 2)
	{
		HPEN borderPen = CreatePen(PS_SOLID, 1, getSettings().m_window.borderColor);
		HPEN oldPen = (HPEN) SelectObject(buf, borderPen);

		MoveToEx(buf, r.left, r.top, NULL);
		LineTo(buf, r.left, r.bottom);

		SelectObject(buf,oldPen);
		DeleteObject(borderPen);

		return;
	}

	MakeStyleGradient(buf, &r, s.m_window.ownStyle ? s.m_window.style : &s.m_window.Style, false);
		CreateBorder(buf, &r, s.m_window.borderColor, 1);
}
コード例 #7
0
ファイル: StyleMaster.cpp プロジェクト: Jmos/bbclean-xzero450
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//style_draw_box
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void style_draw_box(RECT &rect, HDC &buffer, StyleItem* styleptr, bool is_bordered)
{
	if (!styleptr) return;

	if (rect.right - rect.left < 2) return;
	if (rect.bottom - rect.top < 2) return;

	//Draw the box appropriately
	MakeStyleGradient(buffer, &rect, styleptr, is_bordered);
}
コード例 #8
0
void OnPaint(HWND hwnd)
{
	// Create buffer hdc's, bitmaps etc.
	PAINTSTRUCT ps;  RECT r;

	//get screen buffer
	HDC hdc_scrn = BeginPaint(hwnd, &ps);

	//get window rectangle.
	GetClientRect(hwnd, &r);

	//first get a new 'device context'
	HDC hdc = CreateCompatibleDC(NULL);

	//then create a buffer in memory with the window size
	HBITMAP bufbmp = CreateCompatibleBitmap(hdc_scrn, r.right, r.bottom);

	//select the bitmap into the DC
	HGDIOBJ otherbmp = SelectObject(hdc, bufbmp);


	MakeStyleGradient(hdc, &r, &myStyleItem, showBorder);

	SetToolTip(&r, tipString);

	if (track_needsupdate) SliderUpdateTrack(r);
	if (knob_needsupdate) SliderUpdateKnob(r);

	MakeStyleGradient(hdc, &track, &trackStyleItem, false);
 
	if (knob.right - knob.left > 2 && knob.bottom - knob.top > 2)
		MakeStyleGradient(hdc, &knob, &knobStyleItem, showBorder);

	// Finally, copy from the paint buffer to the window...
	BitBlt(hdc_scrn, 0, 0, width, height, hdc, 0, 0, SRCCOPY);

	// Remember to delete all objects!
	DeleteObject(SelectObject(hdc, otherbmp));
	DeleteDC(hdc);

	EndPaint(hwnd, &ps);
}
コード例 #9
0
void PutGradient (WinInfo * WI, HDC hdc, RECT * rc, StyleItem * pG)
{
    if (pG->parentRelative) {
        if (pG->borderWidth)
            CreateBorder(hdc, rc, pG->borderColor, pG->borderWidth);
        return;
    }

    int width = rc->right - rc->left;
    int height = rc->bottom - rc->top;
    int i = pG >= &mSkin.F.Title
        ? pG - &mSkin.F.Title + 6
        : pG - &mSkin.U.Title;

    GdiInfo *pGdi = WI->gdiobjs + i;
    HBITMAP bmp = (HBITMAP)pGdi->hObj;
    HGDIOBJ other;

    if (bmp && width == pGdi->cx && height == pGdi->cy) {
        other = SelectObject(WI->buf, bmp);

    } else {
        RECT r;

        r.left = r.top = 0;
        r.right = width, r.bottom = height;

        if (bmp)
            DeleteObject(bmp);

        pGdi->cx = width;
        pGdi->cx = height;
        pGdi->hObj = bmp = CreateCompatibleBitmap(hdc, width, height);

        if (NULL == bmp)
            return;

        other = SelectObject(WI->buf, bmp);

        StyleItem si;
        si = *pG; // makes a copy of StyleItem into si
        MakeStyleGradient(WI->buf, &r, &si, true);
    }

    BitBlt(hdc, rc->left, rc->top, width, height, WI->buf, 0, 0, SRCCOPY);
    SelectObject(WI->buf, other);
}
コード例 #10
0
ファイル: StyleMaster.cpp プロジェクト: Jmos/bbclean-xzero450
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//style_draw_box
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void style_draw_box(RECT &rect, HDC &buffer, int style, bool is_bordered)
{
	if (style == STYLETYPE_NONE)
	{
		HBRUSH hbbrush = CreateSolidBrush(TRANSCOLOUR);
		FillRect(buffer, &rect, hbbrush);
		DeleteObject(hbbrush);
		return;
	}

	if (style >= STYLE_COUNT) return;
	if (rect.right - rect.left < 2) return;
	if (rect.bottom - rect.top < 2) return;

	//Draw the box appropriately
	MakeStyleGradient(buffer, &rect, &style_fill[style], is_bordered);
}
コード例 #11
0
inline void bbTooltip::_Paint()
{
    m_hPrimaryBuf = BeginPaint(m_TipHwnd, &m_PaintStruct);

    m_rect.left = m_rect.top = 0;
	m_rect.right = m_Width;
    m_rect.bottom = m_Height;

    MakeStyleGradient(m_hSecondaryBuf, &m_rect, m_pInfo->pStyle, m_pInfo->pStyle->bordered);

    m_rect.left =
        m_rect.top = 0;
    m_rect.right = m_Width;
    m_rect.bottom = m_Height;

   // CreateBorder(m_hSecondaryBuf, &m_rect, m_BorderColor, m_BorderWidth);

    m_rect.left = m_rect.top = m_tipBorder;

	//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, m_rect, DT_LEFT|DT_WORDBREAK|DT_END_ELLIPSIS, m_pInfo->pStyle->TextColor, Shadow, shadow_ );
    
	DrawText(
        m_hSecondaryBuf,
        m_Text,
        -1,
        &m_rect,
        DT_LEFT|DT_WORDBREAK|DT_END_ELLIPSIS);

    m_pPaintRect = &m_PaintStruct.rcPaint;

    BitBlt(
        m_hPrimaryBuf,
        m_pPaintRect->left,
        m_pPaintRect->top,
        (m_pPaintRect->right - m_pPaintRect->left),
        (m_pPaintRect->bottom - m_pPaintRect->top),
        m_hSecondaryBuf,
        m_pPaintRect->left,
        m_pPaintRect->top,
        SRCCOPY);

    EndPaint(m_TipHwnd, &m_PaintStruct);
}
コード例 #12
0
ファイル: Toolbar.cpp プロジェクト: fin-alice/bb4nt
//===========================================================================
void PaintToolbar(HDC hdc, RECT *rcPaint)
{
	RECT r; int i; const TCHAR *label = Toolbar_CurrentWindow; StyleItem *pSI;

#ifdef BBOPT_MEMCHECK
	// Display some statistics.
#pragma message("\n"__FILE__ "(397) : warning 0: MEMCHECK enabled.\n")
	/*
    if (NULL==Toolbar_hFont)
    {
        LOGFONT logFont;
        SystemParametersInfo(SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
        Toolbar_hFont = CreateFontIndirect(&logFont);
    }
	 */
	extern int g_menu_count;
	extern int g_menu_item_count;
	TCHAR temp[256];
	if (alloc_size && false == Toolbar_ShowingExternalLabel)
	{
		_stprintf(temp,_T("Menus %d  MenuItems %d  Memory %d"), g_menu_count, g_menu_item_count, alloc_size);
		label = temp;

	}
#endif

	int tbW = TBInfo.width;
	int tbH = TBInfo.height;
	HDC buf = CreateCompatibleDC(NULL);
	HGDIOBJ bufother = SelectObject(buf, CreateCompatibleBitmap(hdc, tbW, tbH));

	if (NULL==Toolbar_hFont) Toolbar_hFont = CreateStyleFont(&mStyle.Toolbar);
	HGDIOBJ other_font = SelectObject(buf, Toolbar_hFont);

	// Get width of clock...
	SIZE size;

	GetTextExtentPoint32(buf, Toolbar_CurrentTime, (int)_tcsnlen(Toolbar_CurrentTime,0x7FFFFFFFUL), &size);
	size.cx += 6;
	if (tbClockW < size.cx) tbClockW = size.cx + 6;

	GetTextExtentPoint32(buf, Toolbar_WorkspaceName, (int)_tcsnlen(Toolbar_WorkspaceName,0x7FFFFFFFUL), &size);
	int tbLabelW = size.cx + 6;

	// The widest sets the width!
	tbLabelW = tbClockW = (int)imax(tbH * 2, imax(tbLabelW, tbClockW));

	int margin = tbMargin;
	int border = mStyle.Toolbar.borderWidth;
	int border_margin = margin + border;
	int button_padding = (tbH - tbButtonWH) / 2 - border;

	int tbLabelX = border_margin;
	int tbClockX = tbW - tbClockW - border_margin;
	int two_buttons = 2*tbButtonWH + 3*button_padding;
	int tbWinLabelX = tbLabelX + tbLabelW + two_buttons;
	int tbWinLabelW = tbClockX - tbWinLabelX - two_buttons;
	if (tbWinLabelW < 0) tbWinLabelW = 0;

	Toolbar_Button[0].r.left = tbLabelX + tbLabelW + button_padding;
	Toolbar_Button[1].r.left = Toolbar_Button[0].r.left + tbButtonWH + button_padding;
	Toolbar_Button[2].r.left = tbClockX - 2*tbButtonWH - 2*button_padding;
	Toolbar_Button[3].r.left = Toolbar_Button[2].r.left + tbButtonWH + button_padding;

	Toolbar_Button[4].r.left = tbClockX;
	for (i = 0; i<5; i++)
	{
		Toolbar_Button[i].r.top    = (tbH - tbButtonWH) / 2;
		Toolbar_Button[i].r.bottom = Toolbar_Button[i].r.top + tbButtonWH;
		Toolbar_Button[i].r.right  = Toolbar_Button[i].r.left + tbButtonWH;
	}
	Toolbar_Button[4].r.right = tbClockX + tbClockW;

	//====================

	// Paint toolbar Style
	_SetRect(&r, 0, 0, tbW, tbH); pSI = &mStyle.Toolbar;
	MakeStyleGradient(buf, &r, pSI, true);

	//====================
	// Paint unpressed workspace/task buttons...

	r.left = r.top = 0; r.right = r.bottom = tbButtonWH;
	{
		HPEN activePen   = CreatePen(PS_SOLID, 1, mStyle.ToolbarButtonPressed.picColor);
		HPEN inactivePen = CreatePen(PS_SOLID, 1, mStyle.ToolbarButton.picColor);
		HDC src = CreateCompatibleDC(NULL);
		HGDIOBJ srcother = SelectObject(src, CreateCompatibleBitmap(hdc, tbButtonWH, tbButtonWH));
		int yOffset = tbH / 2; int xOffset; int f1 = -1;
		for (i=0; i<4; i++)
		{
			int f2 = Toolbar_Button[i].pressed || (Toolbar_force_button_pressed && i&1);
			pSI = f2 ? &mStyle.ToolbarButtonPressed : &mStyle.ToolbarButton;

			if (pSI->parentRelative)
			{
				CreateBorder(buf, &r, pSI->borderColor, pSI->borderWidth);
			}
			else
			{
				if (f1 != f2)
					MakeStyleGradient(src, &r, pSI, pSI->bordered), f1 = f2;

				BitBlt(buf,
					   Toolbar_Button[i].r.left,
					   Toolbar_Button[i].r.top,
					   tbButtonWH, tbButtonWH, src, 0, 0, SRCCOPY
					   );
			}

			xOffset = Toolbar_Button[i].r.left + (tbButtonWH / 2);
			HGDIOBJ penother = SelectObject(buf, f2 ? activePen : inactivePen);
			arrow_bullet(buf, xOffset, yOffset, (i&1)*2-1);
			SelectObject(buf, penother);
		}

		DeleteObject(SelectObject(src, srcother));
		DeleteDC(src);
		DeleteObject(inactivePen);
		DeleteObject(activePen);
	}

	//====================

	r.top = (tbH - tbLabelH)/2;
	r.bottom = r.top + tbLabelH;
	SetBkMode(buf, TRANSPARENT);
	int justify = mStyle.Toolbar.Justify | (DT_VCENTER|DT_SINGLELINE|DT_WORD_ELLIPSIS|DT_NOPREFIX);

	// Paint workspaces background...
	r.right = (r.left = tbLabelX) + tbLabelW; pSI = &mStyle.ToolbarLabel;
	MakeStyleGradient(buf, &r, pSI, pSI->bordered);
	_InflateRect(&r, -3, 0);
	BBDrawText(buf, Toolbar_WorkspaceName, -1, &r, justify, pSI);

	// Paint window label background...
	r.right = (r.left = tbWinLabelX) + tbWinLabelW; pSI = &mStyle.ToolbarWindowLabel;
	MakeStyleGradient(buf, &r, pSI, pSI->bordered);
	_InflateRect(&r, -3, 0);
	BBDrawText(buf, label, -1, &r, justify, pSI);

	// Paint clock background...
	r.right = (r.left = tbClockX) + tbClockW; pSI = &mStyle.ToolbarClock;
	MakeStyleGradient(buf, &r, pSI, pSI->bordered);
	_InflateRect(&r, -3, 0);
	BBDrawText(buf, Toolbar_CurrentTime, -1, &r, justify, pSI);

	//====================

	BitBltRect(hdc, buf, rcPaint);

	SelectObject(buf, other_font);
	DeleteObject(SelectObject(buf, bufother));
	DeleteDC(buf);
}
コード例 #13
0
//===========================================================================
void DrawBBPager(HWND hwnd)
{
	Settings const & s = getSettings();
	// Create buffer hdc's, bitmaps etc.
	PAINTSTRUCT ps;
	HDC hdc = BeginPaint(hwnd, &ps);
	HDC buf = CreateCompatibleDC(NULL);
	HBITMAP bufbmp = CreateCompatibleBitmap(hdc, s.m_frame.width, s.m_frame.height);
	HGDIOBJ oldbmp = SelectObject(buf, bufbmp);
	RECT r;
	char toolText[256];

	GetClientRect(hwnd, &r);

	// Paint background and border according to the current style...
	MakeStyleGradient(buf, &r, s.m_frame.ownStyle ? s.m_frame.style : &s.m_frame.Style, true);

	HFONT font = CreateStyleFont((StyleItem *)GetSettingPtr(SN_TOOLBARLABEL));
	HGDIOBJ oldfont = SelectObject(buf, font);
	SetBkMode(buf, TRANSPARENT);
	SetTextColor(buf, s.m_desktop.fontColor);
	UINT flags = DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_WORD_ELLIPSIS|DT_NOPREFIX;

	desktopRect.clear();

	// Paint desktops :D
	if (s.m_position.horizontal) 
	{
		// Do loop to draw desktops other than current selected desktop
		int i = 0;

		do 
		{
			col = i / s.m_frame.rows;
			row = i % s.m_frame.rows + 1;

			if (getRuntimeState().m_currentDesktop == i) 
			{
				currentCol = col;
				currentRow = row;
			}
			else 
			{
				r.left = s.m_frame.borderWidth + s.m_frame.bevelWidth + ((col) * (s.m_desktop.width + s.m_frame.bevelWidth));
				r.right = r.left + s.m_desktop.width;
				r.top = s.m_frame.borderWidth + s.m_frame.bevelWidth + ((row - 1) * (s.m_desktop.height + s.m_frame.bevelWidth));
				r.bottom = r.top + s.m_desktop.height;

				//desktopRect[i] = r; // set RECT item for this desktop
				//desktopRect.insert(desktopRect.begin() + i - 1, r);
				desktopRect.push_back(r);

				if (s.m_desktop.ownStyle)
					CreateBorder(buf, &r, s.m_activeDesktop.borderColor, 1);
				else
				{
					r.left  += 1;
					r.top   += 1;
					r.right   -= 1;
					r.bottom  -= 1;
					MakeStyleGradient(buf, &r, &s.m_activeDesktop.Style, false);
				}
				if (s.m_desktop.numbers) 
				{
					char desktopNumber[4];
					sprintf(desktopNumber, "%d", (i + 1));
					DrawText(buf, desktopNumber, -1, &r, flags);
				}
			}
			i++;
		}
		while (i < getRuntimeState().m_desktops);

		// Do this now so bordered desktop is drawn last
		i = getRuntimeState().m_currentDesktop;

		r.left = s.m_frame.borderWidth + s.m_frame.bevelWidth + ((currentCol) * (s.m_desktop.width + s.m_frame.bevelWidth));
		r.right = r.left + s.m_desktop.width;
		r.top = s.m_frame.borderWidth + s.m_frame.bevelWidth + ((currentRow - 1) * (s.m_desktop.height + s.m_frame.bevelWidth));
		r.bottom = r.top + s.m_desktop.height;

		//desktopRect[i] = r; // set RECT item for this desktop

		DrawActiveDesktop(buf, r, i);

		if (s.m_desktop.numbers) 
		{
			char desktopNumber[4];
			sprintf(desktopNumber, "%d", (i + 1));
			DrawText(buf, desktopNumber, -1, &r, flags);
		}
	}
	else if (s.m_position.vertical) 
	{
		// Do loop to draw desktops other than current selected desktop
		int i = 0;

		do 
		{					
			row = i / s.m_frame.columns;
			col = i % s.m_frame.columns + 1;

			if (getRuntimeState().m_currentDesktop == i)
			{
				currentCol = col;
				currentRow = row;
			}
			else 
			{
				r.left = s.m_frame.borderWidth + s.m_frame.bevelWidth + ((col - 1) * (s.m_desktop.width + s.m_frame.bevelWidth));
				r.right = r.left + s.m_desktop.width;
				r.top = s.m_frame.borderWidth + s.m_frame.bevelWidth + ((row) * (s.m_desktop.height + s.m_frame.bevelWidth));
				r.bottom = r.top + s.m_desktop.height;

				//desktopRect[i] = r; // set RECT item for this desktop
				//desktopRect.insert(desktopRect.begin() + i - 1, r);
				desktopRect.push_back(r);

				MakeStyleGradient(buf, &r, s.m_desktop.ownStyle ? s.m_desktop.style : &s.m_desktop.Style, false);
				if (s.m_desktop.ownStyle)
					CreateBorder(buf, &r, s.m_activeDesktop.borderColor, 1);
				else
				{
					r.left  += 1;
					r.top   += 1;
					r.right   -= 1;
					r.bottom  -= 1;
					MakeStyleGradient(buf, &r, &s.m_activeDesktop.Style, false);
				}
				if (s.m_desktop.numbers) 
				{
					char desktopNumber[4];
					sprintf(desktopNumber, "%d", (i + 1));
					DrawText(buf, desktopNumber, -1, &r, flags);
				}
			}
			i++;
		}
		while (i < getRuntimeState().m_desktops);

		// Do this now so bordered desktop is drawn last
		i = getRuntimeState().m_currentDesktop;

		r.left = s.m_frame.borderWidth + s.m_frame.bevelWidth + ((currentCol - 1) * (s.m_desktop.width + s.m_frame.bevelWidth));
		r.right = r.left + s.m_desktop.width;
		r.top = s.m_frame.borderWidth + s.m_frame.bevelWidth + ((currentRow) * (s.m_desktop.height + s.m_frame.bevelWidth));
		r.bottom = r.top + s.m_desktop.height;

		//desktopRect[i] = r; // set RECT item for this desktop

		DrawActiveDesktop(buf, r, i);

		if (s.m_desktop.numbers) 
		{
			char desktopNumber[4];
			sprintf(desktopNumber, "%d", (i + 1));
			SetTextColor(buf, s.m_activeDesktop.borderColor);
			DrawText(buf, desktopNumber, -1, &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS | DT_NOPREFIX);
			//DrawText(buf, desktopNumber, strlen(desktopNumber), &r, DT_CALCRECT|DT_NOPREFIX);
			//SetTextColor(buf, s.m_desktop.fontColor);
		}
	}

	//DeleteObject(font);
	DeleteObject(SelectObject(buf, oldfont));

	// Draw windows on workspaces if wanted
	if (s.m_desktop.windows)
	{
		getRuntimeState().m_winCount = 0; // Reset number of windows to 0 on each paint to be counted by...
		getRuntimeState().m_winList.clear();

		// ... this function which passes HWNDs to CheckTaskEnumProc callback procedure
		if (!getRuntimeState().m_is_xoblite && getRuntimeState().m_usingAltMethod)
			EnumWindows(CheckTaskEnumProc_AltMethod, 0);
		else
			EnumWindows(CheckTaskEnumProc, 0); 

		//struct tasklist *tlist;
		/*tl = GetTaskListPtr();
		while (tl)
		{
			AddBBWindow(tl);
			tl = tl->next;
		}*/

		// Only paint windows if there are any!
		if (getRuntimeState().m_winCount > 0)
		{
			// Start at end of list (bottom of zorder)
			for (int i = (getRuntimeState().m_winCount - 1); i > -1; i--)
			{
				RECT win = getRuntimeState().m_winList[i].r;
				RECT desk = desktopRect[getRuntimeState().m_winList[i].desk];

				if (win.right - win.left <= 1 && win.bottom - win.top <= 1)
					continue;
				
				// This is done so that windows only show within the applicable desktop RECT
				if (win.top < desk.top) 
					win.top = desk.top; // + 1;

				if (win.right > desk.right) 
					win.right = desk.right; // - 1;

				if (win.bottom > desk.bottom) 
					win.bottom = desk.bottom; // - 1;

				if (win.left < desk.left) 
					win.left = desk.left; // + 1;

				if (getRuntimeState().m_winList[i].sticky)
				{
					RECT sWin;
					RECT sDesk;
					win.bottom = win.bottom - desk.top;
					win.top = win.top - desk.top;
					win.left = win.left - desk.left;
					win.right = win.right - desk.left;

					for (int j = 0; j < getRuntimeState().m_desktops; j++)
					{
						sDesk = desktopRect[j];
						sWin.bottom = sDesk.top + win.bottom;
						sWin.top = sDesk.top + win.top;
						sWin.left = sDesk.left + win.left;
						sWin.right = sDesk.left + win.right;

						if (getRuntimeState().m_winList[i].active) // draw active window style
						{
							DrawActiveWindow(buf, sWin);
							RemoveFlash(getRuntimeState().m_winList[i].window, true);
						}
						else if (IsFlashOn(getRuntimeState().m_winList[i].window))
						{
							DrawActiveWindow(buf, sWin);
						}
						else // draw inactive window style
						{
							DrawInactiveWindow(buf, sWin);
							RemoveFlash(getRuntimeState().m_winList[i].window, true);
						}

						// Create a tooltip...
						if (s.m_desktop.tooltips)
						{
							GetWindowText(getRuntimeState().m_winList[i].window, toolText, 255);
							SetToolTip(&sWin, toolText);
						}
					}
				}
				else
				{
					if (getRuntimeState().m_winList[i].active) // draw active window style
					{
						DrawActiveWindow(buf, win);
						RemoveFlash(getRuntimeState().m_winList[i].window, true);
					}
					else if (IsFlashOn(getRuntimeState().m_winList[i].window))
					{
						DrawActiveWindow(buf, win);
					}
					else // draw inactive window style
					{
						DrawInactiveWindow(buf, win);
						RemoveFlash(getRuntimeState().m_winList[i].window, true);
					}

					// Create a tooltip...
					if (s.m_desktop.tooltips)
					{
						GetWindowText(getRuntimeState().m_winList[i].window, toolText, 255);
						SetToolTip(&win, toolText);
					}
				}
			}
		}

		if (getRuntimeState().m_winMoving)
		{
			RECT win = getRuntimeState().m_moveWin.r;
			RECT client;

			GetClientRect(getRuntimeState().m_hwndBBPager, &client);
		
			// This is done so that the window only shows within the pager
			if (win.top < client.top) 
				win.top = client.top; // + 1;

			if (win.right > client.right) 
				win.right = client.right; // - 1;

			if (win.bottom > client.bottom) 
				win.bottom = client.bottom; // - 1;

			if (win.left < client.left) 
				win.left = client.left; // + 1;

			if (getRuntimeState().m_moveWin.active) // draw active window style
				DrawActiveWindow(buf, win);
			else // draw inactive window style
				DrawInactiveWindow(buf, win);
		}

	}

	ClearToolTips();

	// Finally, copy from the paint buffer to the window...
	BitBlt(hdc, 0, 0, s.m_frame.width, s.m_frame.height, buf, 0, 0, SRCCOPY);

    //restore the first previous whatever to the dc,
    //get in exchange back our bitmap, and delete it.
    DeleteObject(SelectObject(buf, oldbmp));

    //delete the memory - 'device context'
    DeleteDC(buf);

    //done
    EndPaint(hwnd, &ps);
}
コード例 #14
0
ファイル: MenuItem.cpp プロジェクト: BackupTheBerlios/boxcore
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);
	}
}
コード例 #15
0
ファイル: MenuItem.cpp プロジェクト: Jmos/bbclean-xzero450
void MenuItem::Paint(HDC hDC)
{
    RECT rc, rhi;
    StyleItem *pSI;
    COLORREF TC, BC;
    int j;

    GetTextRect(&rc);
    pSI = &mStyle.MenuFrame;

    if (m_bActive && false == m_bNOP) {
        // draw hilite bar
        GetItemRect(&rhi);
        pSI = &mStyle.MenuHilite;
        MakeStyleGradient(hDC, &rhi, pSI, pSI->bordered);
        TC = pSI->TextColor;
        BC = pSI->foregroundColor;
    } else if (m_bDisabled) {
        BC = TC = pSI->disabledColor;
    } else {
        TC = pSI->TextColor;
        BC = pSI->foregroundColor;
    }

    j = m_Justify;
    if (MENUITEM_CUSTOMTEXT != j) {
        if (MENUITEM_STANDARD_JUSTIFY == j)
            j = mStyle.MenuFrame.Justify;
        // draw menu item text
        //bbDrawText(hDC, GetDisplayString(), &rc, j | DT_MENU_STANDARD, TC);
		/* BlackboxZero 1.5.2012 */
		BBDrawText(hDC, GetDisplayString(), -1, &rc, j | DT_MENU_STANDARD, pSI);
    }

//#ifdef BBOPT_MENUICONS
	if ( Settings_menu.iconSize ) /* BlackboxZero 1.3.2012 */
		this->DrawIcon(hDC);
//#endif

    if (m_bChecked) // draw check-mark
    {
        int d, atright;

//#ifdef BBOPT_MENUICONS
		if ( Settings_menu.iconSize ) { /* BlackboxZero 1.3.2012 */
			if (m_ItemID & MENUITEM_ID_FOLDER)
				atright = MenuInfo.nBulletPosition == FOLDER_LEFT;
			else
				atright = true;
		} else {
//#else
			if (MenuInfo.nItemLeftIndent != MenuInfo.nItemRightIndent)
				atright = MenuInfo.nBulletPosition != FOLDER_LEFT;
			else
			if (m_ItemID & MENUITEM_ID_FOLDER)
				atright = MenuInfo.nBulletPosition == FOLDER_LEFT;
			else
				atright = j != DT_LEFT;
		}
//#endif
        rc.bottom = (rc.top = m_nTop) + m_nHeight + 1;
        if (atright) {
            d = MenuInfo.nItemRightIndent + mStyle.MenuHilite.borderWidth;
            rc.left = (rc.right = m_nLeft + m_nWidth) - d + 1;
        } else {
            d = MenuInfo.nItemLeftIndent + mStyle.MenuHilite.borderWidth;
            rc.right = (rc.left = m_nLeft) + d;
        }

#if 1
        bbDrawPix(hDC, &rc, BC, BS_CHECK);
#else
        {
            bool pr, lit;
            const int w = 6;
            pSI = &mStyle.MenuHilite;
            pr = pSI->parentRelative;
            lit = m_bActive && false == m_bNOP;
            if (lit != pr)
                pSI = &mStyle.MenuFrame;
            rc.left   = (rc.left + rc.right - w)/2;
            rc.right  = rc.left + w;
            rc.top    = (rc.top + rc.bottom - w)/2;
            rc.bottom = rc.top + w;
            if (pr)
                MakeGradient(hDC, rc, B_SOLID, pSI->TextColor, 0, false, BEVEL_FLAT, 0, 0, 0, 0);
            else
                MakeStyleGradient(hDC, &rc, pSI, false);
        }
#endif
    }
}
コード例 #16
0
ファイル: bbSlit.cpp プロジェクト: BackupTheBerlios/bblean
LRESULT slit_info::wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *ret)
{
    static unsigned int msgs[] = { BB_REDRAWGUI, 0 };
    PluginInfo *p, **pp;

    if (ret)
        return *ret;

    switch(message)
    {
        //=============================================

        case WM_CREATE:
            SendMessage(GetBBWnd(), BB_REGISTERMESSAGE, (WPARAM)hwnd, (LPARAM)msgs);
            break;

        case WM_DESTROY:
            SendMessage(GetBBWnd(), BB_UNREGISTERMESSAGE, (WPARAM)hwnd, (LPARAM)msgs);
            if (this->bufbmp)
                DeleteObject(this->bufbmp), this->bufbmp = NULL;
            SetDesktopMargin(hwnd, 0, 0);
            for (pp = &this->m_pInfo; NULL != (p = *pp); *pp = p->next, m_free(p));
            break;

        //=============================================

        case SLIT_ADD:
            //pdbg ((HWND) lParam, "add");
            for (pp = &this->m_pInfo; NULL != (p = *pp); pp = &p->next);
            *pp = p = (PluginInfo*)m_alloc(sizeof(struct PluginInfo));
            memset(p, 0, sizeof *p);
            /* if (!IsBadStringPtr((const char*)wParam, 80))
                ... */
            p->hwnd = (HWND)lParam;
            SetWindowLong(p->hwnd, GWL_STYLE,
                (GetWindowLong(p->hwnd, GWL_STYLE) & ~WS_POPUP) | WS_CHILD);
            SetParent(p->hwnd, hwnd);
            SetTimer(hwnd, 2, 20, NULL);
            break;

        case SLIT_REMOVE:
            //pdbg ((HWND) lParam, "remove");
            for (pp = &this->m_pInfo; NULL != (p = *pp) && p->hwnd != (HWND)lParam; pp = &p->next);
            if (p) {
                if (IsWindow(p->hwnd)) {
                    SetParent(p->hwnd, NULL);
                    SetWindowLong(p->hwnd, GWL_STYLE,
                        (GetWindowLong(p->hwnd, GWL_STYLE) & ~WS_CHILD) | WS_POPUP);
                }
                *pp = p->next;
                m_free(p);
            }
            SetTimer(hwnd, 2, 20, NULL);
            this->suspend_autohide = 0;
            break;

        case SLIT_UPDATE:
            //pdbg ((HWND) lParam, "update");
            SetTimer(hwnd, 2, 20, NULL);
            break;

        case WM_TIMER:
            if (2 == wParam) {
                KillTimer(hwnd, wParam);
                this->calculate_frame();
            }
            break;

        //=============================================
        // support bbStyleMaker under bbLean 1.16
        case WM_COPYDATA:
            return BBReceiveData(hwnd, lParam, NULL);

        case BB_SETSTYLESTRUCT:
            if (SN_SLIT == wParam)
                memcpy(&m_style, (void*)lParam, sizeof m_style);
            break;

        case BB_REDRAWGUI:
            if (wParam & BBRG_SLIT)
            {
                int m = margin;
                int p = padding;
                if (this->bufbmp)
                    DeleteObject(this->bufbmp), this->bufbmp = NULL;

                if (bblean_version >= 1170) {
                    getStyleSettings();
                } else {
                    // Workaround under bbLean 1.16
                    padding = m_style.marginWidth;
                    margin = m_style.marginWidth + m_style.borderWidth;
                }

                if (m != margin || p != padding)
                    this->calculate_frame();
                else
                    InvalidateRect(hwnd, NULL, FALSE);
            }
            break;

        case BB_RECONFIGURE:
            if (this->bufbmp)
                DeleteObject(this->bufbmp), this->bufbmp = NULL;
            getStyleSettings();
            this->getRCSettings();
            SetTimer(hwnd, 2, 20, NULL);
            break;

        //=============================================

        case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc = BeginPaint(hwnd, &ps);
            HDC buf = CreateCompatibleDC(NULL);
            HGDIOBJ otherbmp;

            if (this->bufbmp
             && (this->bmp_width != this->width || this->bmp_height != this->height))
                DeleteObject(this->bufbmp), this->bufbmp = NULL;

            if (NULL == this->bufbmp) {
                this->bufbmp = CreateCompatibleBitmap(hdc,
                    this->bmp_width = this->width,
                    this->bmp_height = this->height
                    );
                otherbmp = SelectObject(buf, this->bufbmp);
                RECT r = { 0, 0, this->bmp_width, this->bmp_height };
                MakeStyleGradient(buf, &r, &m_style, m_style.bordered);
            } else {
                otherbmp = SelectObject(buf, this->bufbmp);
            }

            BitBltRect(hdc, buf, &ps.rcPaint);
            SelectObject(buf, otherbmp);
            DeleteDC(buf);
            EndPaint(hwnd, &ps);
            break;
        }

        //=============================================

        // Right mouse button clicked?
        case WM_RBUTTONUP:
            this->show_menu (true);
            break;

        case WM_LBUTTONDBLCLK:
            BBP_set_autoHide(this, false == this->autoHide);
            this->show_menu (false);
            break;
    
        //=============================================
        default:
            return DefWindowProc(hwnd, message, wParam, lParam);
    }

    return 0;
}
コード例 #17
0
ファイル: Toolbar.cpp プロジェクト: diab0l/bbMean
//===========================================================================
static void PaintToolbar(HDC hdc, RECT *rcPaint)
{
    RECT r;
    StyleItem *pSI;
    struct button *btn;

    HDC buf;
    HGDIOBJ bufother, other_font;
    int size;

    int margin, border, border_margin, button_padding, middle_padding, two_buttons;
    int tbW, tbH, tbLabelW, tbLabelX, tbClockX, tbWinLabelX, tbWinLabelW;
    int i, justify;

    tbW = TBInfo.width;
    tbH = TBInfo.height;
    buf = CreateCompatibleDC(NULL);
    bufother = SelectObject(buf, CreateCompatibleBitmap(hdc, tbW, tbH));

    if (NULL==Toolbar_hFont)
        Toolbar_hFont = CreateStyleFont(&mStyle.Toolbar);
    other_font = SelectObject(buf, Toolbar_hFont);

    size = 6 + get_text_extend(buf, Toolbar_CurrentTime);
    if (tbClockW < size)
        tbClockW = size + 2*tbLabelIndent;

    size = get_text_extend(buf, Toolbar_WorkspaceName);
    tbLabelW = size + 2*tbLabelIndent;

    // The widest sets the width!
    tbLabelW = tbClockW = imax(tbH * 2, imax(tbLabelW, tbClockW));

    margin = tbMargin;
    border = mStyle.Toolbar.borderWidth;
    border_margin = margin + border;
    button_padding = (tbH - tbButtonWH) / 2 - border;
    middle_padding = button_padding;
    if (0 == button_padding)
        middle_padding -= mStyle.ToolbarButton.borderWidth;

    tbLabelX = border_margin;
    tbClockX = tbW - tbClockW - border_margin;
    two_buttons = 2*tbButtonWH + 2*button_padding + middle_padding;
    tbWinLabelX = tbLabelX + tbLabelW + two_buttons;
    tbWinLabelW = tbClockX - tbWinLabelX - two_buttons;
    if (tbWinLabelW < 0) tbWinLabelW = 0;

    btn = Toolbar_Button;
    btn[0].r.left = tbLabelX + tbLabelW + button_padding;
    btn[1].r.left = btn[0].r.left + tbButtonWH + middle_padding;
    btn[2].r.left = tbClockX - 2*tbButtonWH - button_padding - middle_padding;
    btn[3].r.left = btn[2].r.left + tbButtonWH + middle_padding;
    btn[4].r.left = tbClockX;
    for (i = 0; i<5; i++) {
        btn[i].r.top    = (tbH - tbButtonWH) / 2;
        btn[i].r.bottom = btn[i].r.top + tbButtonWH;
        btn[i].r.right  = btn[i].r.left + tbButtonWH;
    }
    btn[4].r.right = tbClockX + tbClockW;

    //====================

    // Paint toolbar Style
    r.left = r.top = 0;
    r.right = tbW;
    r.bottom = tbH;
    pSI = &mStyle.Toolbar;
    MakeStyleGradient(buf, &r, pSI, pSI->bordered);

    //====================
    // Paint unpressed workspace/task buttons...

    r.left = r.top = 0;
    r.right = r.bottom = tbButtonWH;
    {
        HDC src;
        HGDIOBJ srcother;
        int x, y, f2, f1 = -1;
        src = CreateCompatibleDC(NULL);
        srcother = SelectObject(src, CreateCompatibleBitmap(hdc, tbButtonWH, tbButtonWH));
        for (i = 0; i < 4; i++)
        {
            btn = Toolbar_Button + i;
            f2 = btn->pressed || (Toolbar_force_button_pressed && (i&1));
            x = btn->r.left, y = btn->r.top;
            pSI = f2 ? &mStyle.ToolbarButtonPressed : &mStyle.ToolbarButton;
            if (pSI->parentRelative) {
                RECT b;
                b.left = x, b.top = y, b.right = x+r.right, b.bottom = y+r.bottom;
                CreateBorder(buf, &b, pSI->borderColor, pSI->borderWidth);
            } else {
                if (f1 != f2) {
                    MakeStyleGradient(src, &r, pSI, pSI->bordered);
                    f1 = f2;
                }
                BitBlt(buf, x, y, tbButtonWH, tbButtonWH, src, 0, 0, SRCCOPY);
            }
            bbDrawPix(buf, &btn->r, pSI->picColor, (i&1) ? BS_TRIANGLE : -BS_TRIANGLE);
        }

        DeleteObject(SelectObject(src, srcother));
        DeleteDC(src);
    }

    //====================

    r.top = (tbH - tbLabelH)/2;
    r.bottom = r.top + tbLabelH;
    SetBkMode(buf, TRANSPARENT);
    justify = mStyle.Toolbar.Justify | (DT_VCENTER|DT_SINGLELINE|DT_WORD_ELLIPSIS|DT_NOPREFIX);

    // Paint workspaces background...
    r.right = (r.left = tbLabelX) + tbLabelW;
    pSI = &mStyle.ToolbarLabel;
    MakeStyleGradient(buf, &r, pSI, pSI->bordered);
    r.left  += tbLabelIndent;
    r.right -= tbLabelIndent;
    bbDrawText(buf, Toolbar_WorkspaceName, &r, justify, pSI->TextColor);

    // Paint window label background...
    r.right = (r.left = tbWinLabelX) + tbWinLabelW;
    pSI = &mStyle.ToolbarWindowLabel;
    MakeStyleGradient(buf, &r, pSI, pSI->bordered);
    r.left  += tbLabelIndent;
    r.right -= tbLabelIndent;
    bbDrawText(buf, Toolbar_CurrentWindow, &r, justify, pSI->TextColor);

    // Paint clock background...
    r.right = (r.left = tbClockX) + tbClockW;
    pSI = &mStyle.ToolbarClock;
    MakeStyleGradient(buf, &r, pSI, pSI->bordered);
    r.left  += tbLabelIndent;
    r.right -= tbLabelIndent;
    bbDrawText(buf, Toolbar_CurrentTime, &r, justify, pSI->TextColor);

    //====================

    BitBltRect(hdc, buf, rcPaint);

    SelectObject(buf, other_font);
    DeleteObject(SelectObject(buf, bufother));
    DeleteDC(buf);
}