コード例 #1
0
ファイル: FrameHolder.cpp プロジェクト: huyiice/ConEmu
void CFrameHolder::CalculateTabPosition(const RECT &rcWindow, const RECT &rcCaption, RECT* rcTabs)
{
	int nBtnWidth = GetSystemMetrics(SM_CXSIZE);

	bool bCaptionHidden = gpSet->isCaptionHidden();

	FrameDrawStyle fdt = gpConEmu->DrawType();

	rcTabs->left = rcCaption.left;
	if (bCaptionHidden || gpSet->isTabsInCaption)
		rcTabs->left += GetSystemMetrics(SM_CXSMICON) + mn_FrameWidth;

	if (gpSet->nTabsLocation == 0)
	{
		// Tabs on Top
		if (gpSet->isTabsInCaption && (fdt >= fdt_Aero))
			rcTabs->bottom = rcCaption.bottom - 2;
		else if (fdt == fdt_Aero)
			rcTabs->bottom = rcCaption.bottom - 7;
		else
			rcTabs->bottom = rcCaption.bottom - 1;
		rcTabs->top = max((rcCaption.bottom - GetTabsHeight()/*nHeightIdeal*/), rcCaption.top);
	}
	else
	{
		// Tabs on Bottom
		rcTabs->top = rcCaption.top;
		rcTabs->bottom = rcCaption.bottom - 1;// min(rcCaption.bottom, (rcCaption.top + GetTabsHeight()));
	}

	if (!bCaptionHidden)
	{
		rcTabs->right = rcCaption.right - 1;
	}
	// TODO: определить ширину кнопок + Shift из настроек юзера
	else if (gpConEmu->DrawType() == fdt_Aero)
	{
		RECT rcButtons = {0};
		HRESULT hr = gpConEmu->DwmGetWindowAttribute(ghWnd, DWMWA_CAPTION_BUTTON_BOUNDS, &rcButtons, sizeof(rcButtons));

		if (SUCCEEDED(hr))
			rcTabs->right = min((rcButtons.left - 4),(rcCaption.right - 3*nBtnWidth)) - 1;
		else
			rcTabs->right = rcCaption.right - 3*nBtnWidth - 1;
	}
	else if (gpConEmu->DrawType() == fdt_Themed)
	{
		// -- Не работает :(
		//HTHEME hTheme = gpConEmu->OpenThemeData(NULL, L"WINDOW");
		//RECT rcBtns, wr; GetWindowRect(ghWnd, &wr); OffsetRect(&wr, -wr.left, -wr.top);
		//HRESULT hr = gpConEmu->GetThemeBackgroundContentRect(hTheme, NULL, 15/*WP_MINBUTTON*/, 1/*MINBS_NORMAL*/, &wr, &rcBtns);
		//gpConEmu->CloseThemeData(hTheme);

		rcTabs->right = rcCaption.right - 3*nBtnWidth - 1;
	}
	else
	{
		rcTabs->right = rcCaption.right - 3*nBtnWidth /*+ 2*/ - 1;
	}
}
コード例 #2
0
ファイル: FrameHolder.cpp プロジェクト: CyberShadow/conemu
void CFrameHolder::CalculateTabPosition(const RECT &rcWindow, const RECT &rcCaption, RECT* rcTabs)
{
	int nBtnWidth = GetSystemMetrics(SM_CXSIZE);

	rcTabs->left = rcCaption.left + GetSystemMetrics(SM_CXSMICON) + 3;
	rcTabs->bottom = rcCaption.bottom - 1;
	rcTabs->top = max((rcCaption.bottom - GetTabsHeight()/*nHeightIdeal*/), rcCaption.top);

	// TODO: определить ширину кнопок + Shift из настроек юзера

	if (gpConEmu->DrawType() == fdt_Aero)
	{
		RECT rcButtons = {0};
		HRESULT hr = gpConEmu->DwmGetWindowAttribute(ghWnd, DWMWA_CAPTION_BUTTON_BOUNDS, &rcButtons, sizeof(rcButtons));

		if (SUCCEEDED(hr))
			rcTabs->right = min((rcButtons.left - 4),(rcCaption.right - 3*nBtnWidth));
		else
			rcTabs->right = rcCaption.right - 3*nBtnWidth;
	}
	else if (gpConEmu->DrawType() == fdt_Themed)
	{
		// -- Не работает :(
		//HTHEME hTheme = gpConEmu->OpenThemeData(NULL, L"WINDOW");
		//RECT rcBtns, wr; GetWindowRect(ghWnd, &wr); OffsetRect(&wr, -wr.left, -wr.top);
		//HRESULT hr = gpConEmu->GetThemeBackgroundContentRect(hTheme, NULL, 15/*WP_MINBUTTON*/, 1/*MINBS_NORMAL*/, &wr, &rcBtns);
		//gpConEmu->CloseThemeData(hTheme);

		rcTabs->right = rcCaption.right - 3*nBtnWidth;
	}
	else
	{
		rcTabs->right = rcCaption.right - 3*nBtnWidth /*+ 2*/;
	}
}
コード例 #3
0
ファイル: FrameHolder.cpp プロジェクト: huyiice/ConEmu
void CFrameHolder::RecalculateFrameSizes()
{
	_ASSERTE(mb_Initialized==TRUE); // CConEmuMain должен позвать из своего конструктора InitFrameHolder()

	//mn_WinCaptionHeight, mn_FrameWidth, mn_FrameHeight, mn_OurCaptionHeight, mn_TabsHeight;
	mn_WinCaptionHeight = GetSystemMetrics(SM_CYCAPTION);
	mn_FrameWidth = GetSystemMetrics(SM_CXFRAME);
	mn_FrameHeight = GetSystemMetrics(SM_CYFRAME);

	//int nHeightIdeal = mn_WinCaptionHeight * 3 / 4;
	//if (nHeightIdeal < 19) nHeightIdeal = 19;
	mn_TabsHeight = GetTabsHeight(); // min(nHeightIdeal,mn_OurCaptionHeight);

	//int nCaptionDragHeight = 10;
	int nCaptionDragHeight = GetSystemMetrics(SM_CYSIZE); // - mn_FrameHeight;
	if (gpConEmu->DrawType() >= fdt_Themed)
	{
	//	//SIZE sz = {}; RECT tmpRc = MakeRect(600,400);
	//	//HANDLE hTheme = gpConEmu->OpenThemeData(NULL, L"WINDOW");
	//	//HRESULT hr = gpConEmu->GetThemePartSize(hTheme, NULL/*dc*/, 18/*WP_CLOSEBUTTON*/, 1/*CBS_NORMAL*/, &tmpRc, 2/*TS_DRAW*/, &sz);
	//	//if (SUCCEEDED(hr))
	//	//	nCaptionDragHeight = max(sz.cy - mn_FrameHeight,10);
	//	//gpConEmu->CloseThemeData(hTheme);
		nCaptionDragHeight -= mn_FrameHeight;
	}
	mn_CaptionDragHeight = max(10,nCaptionDragHeight);

	if (gpSet->isCaptionHidden())
	{
		mn_OurCaptionHeight = 0;
	}
#if defined(CONEMU_TABBAR_EX)
	else if (gpSet->isTabsInCaption && gpConEmu->mp_TabBar && gpConEmu->mp_TabBar->IsTabsActive())
	{
		if ((GetCaptionDragHeight() == 0) && (mn_TabsHeight > mn_WinCaptionHeight))
		{
			// Если дополнительную высоту в заголовке не просили -
			// нужно строго уместиться в стандартную высоту заголовка
			mn_TabsHeight = mn_WinCaptionHeight;
		}
		int nCHeight = mn_TabsHeight + GetCaptionDragHeight();
		mn_OurCaptionHeight = max(mn_WinCaptionHeight,nCHeight);
	}
#endif
	else
	{
		mn_OurCaptionHeight = mn_WinCaptionHeight;
	}


	//if (gpConEmu->DrawType() == fdt_Aero)
	//{
	//	rcCaption->left = 2; //GetSystemMetrics(SM_CXFRAME);
	//	rcCaption->right = (rcWindow.right - rcWindow.left) - GetSystemMetrics(SM_CXFRAME);
	//	rcCaption->top = 6; //GetSystemMetrics(SM_CYFRAME);
	//	rcCaption->bottom = gpConEmu->GetDwmClientRectTopOffset() - 1;
	//}
	//else if (gpConEmu->DrawType() == fdt_Themed)
	//{
	//	rcCaption->left = GetSystemMetrics(SM_CXFRAME);
	//	rcCaption->right = (rcWindow.right - rcWindow.left) - GetSystemMetrics(SM_CXFRAME) - 1;
	//	rcCaption->top = GetSystemMetrics(SM_CYFRAME);
	//	rcCaption->bottom = rcCaption->top + GetSystemMetrics(SM_CYCAPTION) + (gpSet->isTabs ? (GetSystemMetrics(SM_CYCAPTION)/2) : 0);
	//}
	//else
	//{
	//	rcCaption->left = GetSystemMetrics(SM_CXFRAME);
	//	rcCaption->right = (rcWindow.right - rcWindow.left) - GetSystemMetrics(SM_CXFRAME) - 1;
	//	rcCaption->top = GetSystemMetrics(SM_CYFRAME);
	//	rcCaption->bottom = rcCaption->top + GetSystemMetrics(SM_CYCAPTION) - 1 + (gpSet->isTabs ? (GetSystemMetrics(SM_CYCAPTION)/2) : 0);
	//}
}