Ejemplo n.º 1
0
void GetStyleSettings(void)
{
    my.Frame = *(StyleItem *)GetSettingPtr(SN_TOOLBAR);
    if (my.hFont)
        DeleteObject(my.hFont);
    my.hFont = CreateStyleFont(&my.Frame);
}
Ejemplo n.º 2
0
void Styles::GetStyleSettings()
{
	int const style_assoc[] =
	{ 
		SN_TOOLBARLABEL,
		SN_TOOLBARWINDOWLABEL,
		SN_TOOLBARCLOCK,
		SN_TOOLBAR,
		SN_TOOLBARBUTTON,
		SN_TOOLBARBUTTONP
	};

	StyleItem const * os = (StyleItem *)GetSettingPtr(style_assoc[getSettings().OuterStyleIndex-1]);
	StyleItem const * is = (StyleItem *)GetSettingPtr(style_assoc[getSettings().InnerStyleIndex-1]);
	StyleItem const * toolbar = (StyleItem *)GetSettingPtr(SN_TOOLBAR);
	StyleItem const * toolbarButtonPressed = (StyleItem *)GetSettingPtr(SN_TOOLBARBUTTONP);

	OuterStyle = os->parentRelative ? *toolbar : *os;
	InnerStyle = is->parentRelative ? *toolbar : *is;
	ButtonStyle = *toolbarButtonPressed;

//	SIZE size;
	HDC fonthdc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
	HFONT font = CreateStyleFont(toolbar);
	HGDIOBJ oldfont = SelectObject(fonthdc, font);
//	GetTextExtentPoint32(fonthdc, foobarWnd, 32, &size);
	getSettings().width = getSettings().FooWidth;
	DeleteObject(SelectObject(fonthdc, oldfont));
	DeleteDC(fonthdc);
}
Ejemplo n.º 3
0
void bbTooltip::Start(HINSTANCE h_host_instance, HWND h_host, bbTooltipInfo *p_info)
{
    WNDCLASS wc;
    m_bInitial = true;
    m_WindowName = "_bbTooltip";
    m_hCore = GetBBWnd();

    ZeroMemory((void*)&m_TipList, sizeof(m_TipList));

    m_hostInstance = h_host_instance;
    m_hHost = h_host;
    m_pInfo = p_info;

    ZeroMemory(&wc,sizeof(wc));
    wc.lpfnWndProc = _WndProc;
    wc.hInstance = m_hostInstance;
    wc.lpszClassName = m_WindowName;
    //wc.style = CS_SAVEBITS;
    RegisterClass(&wc);

    m_TipHwnd = CreateWindowEx(
        WS_EX_TOOLWINDOW,
        m_WindowName,
        NULL,
        WS_POPUP,
        0,
        0,
        0,
        0,
        NULL,
        NULL,
        m_hostInstance,
        NULL);

    SetWindowLongPtr(m_TipHwnd, GWLP_USERDATA, (LONG_PTR)this);

    m_hSecondaryBuf = CreateCompatibleDC(NULL);
    m_hBitmapNull = (HBITMAP)SelectObject(m_hSecondaryBuf, CreateCompatibleBitmap(m_hSecondaryBuf, 2, 2));
    m_hFontNull = (HFONT)SelectObject(m_hSecondaryBuf, CreateStyleFont(m_pInfo->pStyle));
    SetBkMode(m_hSecondaryBuf, TRANSPARENT);

    ZeroMemory(&m_bmpInfo, sizeof(m_bmpInfo));
    m_bmpInfo.biSize = sizeof(m_bmpInfo);
    m_bmpInfo.biPlanes = 1;
    m_bmpInfo.biCompression = BI_RGB;
    m_bmpInfo.biWidth = _MAX_WIDTH;
    m_bmpInfo.biHeight = _MAX_HEIGHT;

    UpdateSettings();
}
Ejemplo n.º 4
0
void bbTooltip::UpdateSettings()
{
    m_ScreenWidth = GetSystemMetrics(SM_CXSCREEN);
    m_ScreenHeight = GetSystemMetrics(SM_CYSCREEN);

    m_BorderColor = *(COLORREF*)GetSettingPtr(SN_BORDERCOLOR);
    m_BorderWidth = *(int*)GetSettingPtr(SN_BORDERWIDTH);

    m_tipBorder = m_BorderWidth + ((m_pInfo->pStyle->bevelstyle == BEVEL_SUNKEN) ? 3: 2);

    DeleteObject((HFONT)SelectObject(m_hSecondaryBuf, CreateStyleFont(m_pInfo->pStyleFont)));
    SetTextColor(m_hSecondaryBuf, m_pInfo->pStyle->TextColor);

    if (m_pInfo->max_width > _MAX_WIDTH)
        m_pInfo->max_width = _MAX_WIDTH;

    HDC hdc = GetDC(NULL);
    m_bmpInfo.biBitCount = GetDeviceCaps(hdc, BITSPIXEL);
    ReleaseDC(NULL, hdc);
    DeleteObject((HBITMAP)SelectObject(m_hSecondaryBuf, CreateDIBSection(
        NULL, (BITMAPINFO*)&m_bmpInfo, DIB_RGB_COLORS, NULL, NULL, 0)));
}
Ejemplo n.º 5
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//style_init
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int style_startup()
{
	// --------------------
	StyleItem * T = (StyleItem *)GetSettingPtr(SN_TOOLBAR);
	StyleItem * W = (StyleItem *)GetSettingPtr(SN_TOOLBARWINDOWLABEL);
	StyleItem * L = (StyleItem *)GetSettingPtr(SN_TOOLBARLABEL);
	StyleItem * C = (StyleItem *)GetSettingPtr(SN_TOOLBARCLOCK);
	StyleItem * B = (StyleItem *)GetSettingPtr(SN_TOOLBARBUTTON);
	StyleItem * X;

	if (T->validated & VALID_TEXTCOLOR) X = T;
	else
	if (W->parentRelative)  X = W;
	else
	if (L->parentRelative)  X = L;
	else
	if (C->parentRelative)  X = C;
	else
	if (B->parentRelative)  X = B;
	else                    X = L;

	COLORREF Color_N = X->TextColor;

	if (false == W->parentRelative) X = W;
	else
	if (false == L->parentRelative) X = L;
	else
	if (false == C->parentRelative) X = C;
	else
	if (false == B->parentRelative) X = B;
	else                            X = T;

	StyleItem * A = X;

	if (X == T) X = W;

	COLORREF Color_A = X->TextColor;

	style_fill[STYLETYPE_TOOLBAR] = *T;
	style_fill[STYLETYPE_TOOLBAR].TextColor = Color_N;
	style_fill[STYLETYPE_INSET] = *A;
	style_fill[STYLETYPE_INSET].TextColor = Color_A;

	style_fill[STYLETYPE_FLAT] = style_fill[STYLETYPE_TOOLBAR];
	style_fill[STYLETYPE_FLAT].ColorTo = style_fill[STYLETYPE_TOOLBAR].Color;
	style_fill[STYLETYPE_SUNKEN] = style_fill[STYLETYPE_INSET];
	style_fill[STYLETYPE_SUNKEN].ColorTo = style_fill[STYLETYPE_INSET].Color;

	style_fill[STYLETYPE_NONE].TextColor = Color_N;


	style_font = CreateStyleFont(T);

	*(FARPROC*)&pSetLayeredWindowAttributes
		= GetProcAddress(GetModuleHandle((LPCWSTR)"USER32"), "SetLayeredWindowAttributes");

	// --------------------

	style_bevel_width   = *(int*)GetSettingPtr(SN_BEVELWIDTH);
	style_border_width  = *(int*)GetSettingPtr(SN_BORDERWIDTH);
	style_color_border  = *(COLORREF*)GetSettingPtr(SN_BORDERCOLOR);

	style_font_height   = get_font_height(style_font);

	//No errors
	return 0;
}
Ejemplo n.º 6
0
void Toolbar_UpdatePosition()
{
	Settings_toolbarAlpha = Settings_toolbarAlphaEnabled ? Settings_toolbarAlphaValue : 255;

	// Another Toolbar has set the info:
	if (NULL == Toolbar_hwnd && TBInfo.hwnd) return;

	intptr_t place = get_string_index(Settings_toolbarPlacement, placement_strings);
	if (-1 == place) place = PLACEMENT_BOTTOM_CENTER;

	// --- toolbar metrics ----------------------

	int labelH, buttonH;

	if (Settings_newMetrics || (mStyle.ToolbarLabel.validated & VALID_MARGIN))
	{
		HFONT hf = CreateStyleFont(&mStyle.Toolbar);
		int lfh = get_fontheight(hf);
		DeleteObject(hf);

		if (mStyle.ToolbarLabel.validated & VALID_MARGIN)
			labelH = lfh + 2 * mStyle.ToolbarLabel.marginWidth;
		else
			labelH = (int)imax(10, lfh) + 2*2;
	}
	else
	{
		labelH = (int)imax(8, mStyle.Toolbar.FontHeight) + 2;
	}

	labelH |= 1;

	if (mStyle.ToolbarButton.validated & VALID_MARGIN)
	{
		buttonH = 9 + 2 * mStyle.ToolbarButton.marginWidth;
	}
	else
	{
		buttonH = labelH - 2;
	}

	tbMargin    = mStyle.Toolbar.marginWidth;
	tbButtonWH  = buttonH;
	tbLabelH    = labelH;

	int tbheight = (int)imax(labelH, buttonH) +
		2 * (mStyle.Toolbar.borderWidth + mStyle.Toolbar.marginWidth);

	int tbwidth = (int)imax (300, ScreenWidth * Settings_toolbarWidthPercent / 100);

	// ------------------------------------------
	//int ScreenWidth = GetSystemMetrics(SM_CXSCREEN);
	//int ScreenHeight = GetSystemMetrics(SM_CYSCREEN);

	TBInfo.placement        = (int)place;
	TBInfo.widthPercent     = Settings_toolbarWidthPercent;
	TBInfo.height           = tbheight;
	TBInfo.width            = tbwidth;
	TBInfo.ypos             = (place<3) ? 0 : ScreenHeight - TBInfo.height;
	TBInfo.xpos             = (place%3) * (ScreenWidth - TBInfo.width) / 2;

	TBInfo.onTop            = Settings_toolbarOnTop;
	TBInfo.autoHide         = Settings_toolbarAutoHide;
	TBInfo.pluginToggle     = Settings_toolbarPluginToggle;
	TBInfo.autohidden       = TBInfo.autoHide;
	TBInfo.alphaValue       = Settings_toolbarAlphaValue;
	TBInfo.transparency     = Settings_toolbarAlphaEnabled;
	TBInfo.disabled         = false == Settings_toolbarEnabled;
	TBInfo.hidden           = false == Settings_toolbarEnabled;

	if (Toolbar_hwnd)
	{
		int d = TBInfo.height - 1;
		Toolbar_HideY = TBInfo.ypos + (place < 3 ? -d : d);

		SetDesktopMargin(
			Toolbar_hwnd,
			place < 3 ? BB_DM_TOP : BB_DM_BOTTOM,
			TBInfo.autoHide || Toolbar_hidden ? 0 : TBInfo.height + (TBInfo.onTop ? 0 : 4)
			);

		tbClockW = 0;
		Toolbar_setlabel();
		Toolbar_setclock();
		if (Toolbar_hFont) DeleteObject(Toolbar_hFont), Toolbar_hFont = NULL;
		Toolbar_set_pos();
	}
}
Ejemplo n.º 7
0
//===========================================================================
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);
}
Ejemplo n.º 8
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);
}
Ejemplo n.º 9
0
void Toolbar_UpdatePosition(void)
{
    int ScreenWidth;
    int ScreenHeight;
    int labelH, buttonH, tbheight, tbwidth, labelBorder;
    int place, fontH;
    HFONT hf;

    struct toolbar_setting *tbs = &Settings_toolbar;

    // Another Toolbar has set the info:
    if (NULL == Toolbar_hwnd && TBInfo.hwnd)
        return;

    ScreenWidth = GetSystemMetrics(SM_CXSCREEN);
    ScreenHeight = GetSystemMetrics(SM_CYSCREEN);

    place = get_string_index(tbs->placement, placement_strings);
    if (-1 == place)
        place = PLACEMENT_BOTTOM_CENTER;

    // --- toolbar metrics ----------------------

    hf = CreateStyleFont(&mStyle.Toolbar);
    fontH = get_fontheight(hf);
    DeleteObject(hf);

    // xxx old behaviour xxx
    if (false == mStyle.is_070
        && 0 == (mStyle.ToolbarLabel.validated & V_MAR))
        fontH = mStyle.Toolbar.FontHeight-2;
    //xxxxxxxxxxxxxxxxxxxxxx

    labelBorder = imax(mStyle.ToolbarLabel.borderWidth,
            imax(mStyle.ToolbarWindowLabel.borderWidth,
                mStyle.ToolbarClock.borderWidth));

    labelH = (fontH|1) + 2*(mStyle.ToolbarLabel.marginWidth/*+labelBorder*/);
    buttonH = labelH + 2*(mStyle.ToolbarButton.marginWidth-mStyle.ToolbarLabel.marginWidth);
    tbMargin    = mStyle.Toolbar.marginWidth;
    tbButtonWH  = buttonH;
    tbLabelH    = labelH;
    tbLabelIndent = imax(2+labelBorder, (labelH-fontH)/2);

    tbheight    = imax(labelH, buttonH) +
        2*(mStyle.Toolbar.borderWidth + mStyle.Toolbar.marginWidth);
    tbwidth     = imax (300, ScreenWidth * tbs->widthPercent / 100);

    // ------------------------------------------

    TBInfo.placement        = place;
    TBInfo.widthPercent     = tbs->widthPercent;
    TBInfo.height           = tbheight;
    TBInfo.width            = tbwidth;
    TBInfo.ypos             = (place<3) ? 0 : ScreenHeight - TBInfo.height;
    TBInfo.xpos             = (place%3) * (ScreenWidth - TBInfo.width) / 2;

    TBInfo.onTop            = tbs->onTop;
    TBInfo.autoHide         = tbs->autoHide;
    TBInfo.pluginToggle     = tbs->pluginToggle;
    TBInfo.autohidden       = TBInfo.autoHide;
    TBInfo.alphaValue       = (BYTE)tbs->alphaValue;
    TBInfo.transparency     = tbs->alphaEnabled;
    TBInfo.disabled         = false == tbs->enabled;
    TBInfo.hidden           = false == tbs->enabled;

    if (Toolbar_hwnd)
    {
        int d = TBInfo.height - 1;
        Toolbar_HideY = TBInfo.ypos + (place < 3 ? -d : d);

        SetDesktopMargin(
            Toolbar_hwnd,
            place < 3 ? BB_DM_TOP : BB_DM_BOTTOM,
            TBInfo.autoHide || Toolbar_hidden ? 0 : TBInfo.height);

        tbClockW = 0;
        Toolbar_setlabel();
        Toolbar_setclock();
        if (Toolbar_hFont) DeleteObject(Toolbar_hFont), Toolbar_hFont = NULL;
        Toolbar_set_pos();
    }
}
Ejemplo n.º 10
0
//===========================================================================
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);
}