Ejemplo n.º 1
0
//Checks the toolbar position and eventually enables magnetization
void WindowMagnetizer::CheckToolbarPos(LPRECT tbRect)
{
	if(!IsInitialized() || !enabled)
		return;
	magnState=getNewMagnState(tbRect);
	UpdateToolbarPos(tbRect);
}
Ejemplo n.º 2
0
// nConNumber - 0-based
void CTabPanelWin::OnConsoleActivatedInt(int nConNumber)
{
	if (!mh_Toolbar)
		return;

	TBBUTTONINFO tbi = {sizeof(TBBUTTONINFO), TBIF_IMAGE};
	SendMessage(mh_Toolbar, TB_GETBUTTONINFO, TID_ACTIVE_NUMBER, (LPARAM)&tbi);

	if (tbi.iImage != nConNumber)
	{
		bool bNeedShow = false, bWasHidden = false;

		if ((nConNumber >= BID_FIST_CON) && (nConNumber <= BID_LAST_CON))
		{
			bNeedShow = (tbi.iImage == BID_DUMMYBTN_IDX);
			tbi.iImage = nConNumber;
		}
		else
		{
			if (tbi.iImage != BID_DUMMYBTN_IDX)
			{
				SendMessage(mh_Toolbar, TB_HIDEBUTTON, TID_ACTIVE_NUMBER, TRUE);
				bWasHidden = true;
			}
			tbi.iImage = BID_DUMMYBTN_IDX;
		}

		//if (!bRedraw)
		//{
		//	bRedraw = true;
		//	SendMessage(mh_Toolbar, WM_SETREDRAW, FALSE, 0);
		//}

		SendMessage(mh_Toolbar, TB_SETBUTTONINFO, TID_ACTIVE_NUMBER, (LPARAM)&tbi);

		if (bNeedShow)
		{
			SendMessage(mh_Toolbar, TB_HIDEBUTTON, TID_ACTIVE_NUMBER, FALSE);
		}

		if (bNeedShow || bWasHidden)
		{
			SendMessage(mh_Toolbar, TB_AUTOSIZE, 0, 0);
			UpdateToolbarPos();
		}
	}

	//UpdateToolConsoles(true);
	////nConNumber = gpConEmu->ActiveConNum()+1; -- сюда пришел уже правильный номер!
	//if (nConNumber>=1 && nConNumber<=MAX_CONSOLE_COUNT)
	//{
	//	SendMessage(mh_Toolbar, TB_CHECKBUTTON, nConNumber, 1);
	//}
	//else
	//{
	//	for (int i = 1; i <= MAX_CONSOLE_COUNT; i++)
	//		SendMessage(mh_Toolbar, TB_CHECKBUTTON, i, 0);
	//}
}
Ejemplo n.º 3
0
// nConNumber - 0-based
void CTabPanelWin::OnConsoleActivatedInt(int nConNumber)
{
	if (!mh_Toolbar)
		return;

	TBBUTTONINFO tbi = {sizeof(TBBUTTONINFO), TBIF_IMAGE};
	SendMessage(mh_Toolbar, TB_GETBUTTONINFO, TID_ACTIVE_NUMBER, (LPARAM)&tbi);

	if (tbi.iImage != nConNumber)
	{
		bool bNeedShow = false, bWasHidden = false;

		if ((nConNumber >= BID_FIST_CON) && (nConNumber <= BID_LAST_CON))
		{
			bNeedShow = (tbi.iImage == BID_DUMMYBTN_IDX);
			tbi.iImage = nConNumber;
		}
		else
		{
			if (tbi.iImage != BID_DUMMYBTN_IDX)
			{
				SendMessage(mh_Toolbar, TB_HIDEBUTTON, TID_ACTIVE_NUMBER, TRUE);
				bWasHidden = true;
			}
			tbi.iImage = BID_DUMMYBTN_IDX;
		}

		SendMessage(mh_Toolbar, TB_SETBUTTONINFO, TID_ACTIVE_NUMBER, (LPARAM)&tbi);

		if (bNeedShow)
		{
			SendMessage(mh_Toolbar, TB_HIDEBUTTON, TID_ACTIVE_NUMBER, FALSE);
		}

		if (bNeedShow || bWasHidden)
		{
			SendMessage(mh_Toolbar, TB_AUTOSIZE, 0, 0);
			UpdateToolbarPos();
		}
	}
}
Ejemplo n.º 4
0
void CTabPanelWin::RepositionInt()
{
	RECT client, self;
	client = gpConEmu->GetGuiClientRect();
	GetWindowRect(mh_Tabbar, &self);

	if (mh_Rebar)
	{
		// Rebar location (top/bottom)
		if (gpSet->nTabsLocation == 1)
		{
			int nStatusHeight = gpSet->isStatusBarShow ? gpSet->StatusBarHeight() : 0;
			MoveWindow(mh_Rebar, 0, client.bottom-nStatusHeight-mn_TabHeight, client.right, mn_TabHeight, 1);
		}
		else
		{
			MoveWindow(mh_Rebar, 0, 0, client.right, mn_TabHeight, 1);
		}

		// Visible panes
		bool bRebarChanged = false;
		int iAllWidth = 0;
		// Desired panes position
		struct {
			ReBarIndex iPaneID;
			HWND hChild;
			int iPaneMinWidth;
			bool bNeedShow;
		} Panes[3] = {
			{rbi_TabBar}, {rbi_FindBar}, {rbi_ToolBar}
		};

		// Default (minimal) widths
		for (size_t i = 0; i < countof(Panes); i++)
		{
			switch (Panes[i].iPaneID)
			{
			case rbi_TabBar:
				Panes[i].hChild = mh_Tabbar;
				Panes[i].iPaneMinWidth = max(150,mn_TabHeight*5);
				break;
			case rbi_FindBar:
				if (mp_Find && ((Panes[i].hChild = mp_Find->GetHWND()) != NULL))
				{
					if (gpSet->isMultiShowSearch)
						Panes[i].iPaneMinWidth = mp_Find->GetMinWidth();
				}
				break;
			case rbi_ToolBar:
				if ((Panes[i].hChild = mh_Toolbar) != NULL)
				{
					SIZE sz = {0,0};
					SendMessage(mh_Toolbar, TB_GETMAXSIZE, 0, (LPARAM)&sz);
					sz.cx += (gpSet->isHideCaptionAlways() ? gpSet->nToolbarAddSpace : 0);
					if (gpSet->isMultiShowButtons)
						Panes[i].iPaneMinWidth = sz.cx;
				}
				break;
			}
			iAllWidth += Panes[i].iPaneMinWidth;
		}

		// Check what panes are fit
		if (iAllWidth > client.right)
		{
			// Firstly we hide find-pane
			if (Panes[1].iPaneMinWidth > 0)
			{
				iAllWidth -= Panes[1].iPaneMinWidth;
				Panes[1].iPaneMinWidth = 0;
			}
			// If that is not enough - hide toolbar
			if (iAllWidth > client.right)
			{
				Panes[2].iPaneMinWidth = 0;
			}
		}

		// Run through and hide don't fit panes
		for (size_t i = 1; i < countof(Panes); i++)
		{
			if (!Panes[i].hChild)
				continue;

			INT_PTR nPaneIndex = SendMessage(mh_Rebar, RB_IDTOINDEX, Panes[i].iPaneID, 0);
			if (nPaneIndex < 0)
				continue;

			if (IsWindowVisible(Panes[i].hChild))
			{
				if (Panes[i].iPaneMinWidth == 0)
				{
					SendMessage(mh_Rebar, RB_SHOWBAND, nPaneIndex, 0);
					bRebarChanged = true;
				}
			}
			else if (Panes[i].iPaneMinWidth > 0)
			{
				Panes[i].bNeedShow = true;
			}
		}

		// Fix probably tangled order
		INT_PTR iAfter = 0;
		for (size_t i = 0; i < countof(Panes); i++)
		{
			if (Panes[i].iPaneMinWidth <= 0)
				continue;
			INT_PTR nIndex = SendMessage(mh_Rebar, RB_IDTOINDEX, Panes[i].iPaneID, 0);
			if (nIndex < 0)
				continue;
			if (nIndex > iAfter)
			{
				SendMessage(mh_Rebar, RB_MOVEBAND, nIndex, iAfter);
				bRebarChanged = true;
			}
			iAfter++;
		}

		// Show panes was hidden
		for (size_t i = 0; i < countof(Panes); i++)
		{
			if (!Panes[i].bNeedShow)
				continue;
			INT_PTR nIndex = SendMessage(mh_Rebar, RB_IDTOINDEX, Panes[i].iPaneID, 0);
			SendMessage(mh_Rebar, RB_SHOWBAND, nIndex, TRUE);
			bRebarChanged = true;
		}

		// If the toolbar is visible, and rebar was changed...
		if (bRebarChanged && (Panes[2].iPaneMinWidth > 0))
		{
			UpdateToolbarPos();
		}
	}
	else
	{
		_ASSERTE((mh_Rebar!=NULL) && "ReBar was not created!");
	}
}
Ejemplo n.º 5
0
void CTabPanelWin::RepositionInt()
{
	RECT client, self;
	client = gpConEmu->GetGuiClientRect();
	GetWindowRect(mh_Tabbar, &self);

	if (mh_Rebar)
	{
		SIZE sz = {0,0};
		int nBarIndex = -1;
		BOOL lbNeedShow = FALSE, lbWideEnough = FALSE;

		if (mh_Toolbar)
		{
			nBarIndex = SendMessage(mh_Rebar, RB_IDTOINDEX, 2, 0);

			if (gpSet->isMultiShowButtons)
			{
				SendMessage(mh_Toolbar, TB_GETMAXSIZE, 0, (LPARAM)&sz);
				sz.cx += (gpSet->isHideCaptionAlways() ? gpSet->nToolbarAddSpace : 0);
				lbWideEnough = (sz.cx + 150) <= client.right;

				if (!lbWideEnough)
				{
					if (IsWindowVisible(mh_Toolbar))
						SendMessage(mh_Rebar, RB_SHOWBAND, nBarIndex, 0);
				}
				else
				{
					if (!IsWindowVisible(mh_Toolbar))
						lbNeedShow = TRUE;
				}
			}
			else
			{
				SendMessage(mh_Rebar, RB_SHOWBAND, nBarIndex, 0);
			}
		}

		if (gpSet->nTabsLocation == 1)
		{
			int nStatusHeight = gpSet->isStatusBarShow ? gpSet->StatusBarHeight() : 0;
			MoveWindow(mh_Rebar, 0, client.bottom-nStatusHeight-mn_TabHeight, client.right, mn_TabHeight, 1);
		}
		else
		{
			MoveWindow(mh_Rebar, 0, 0, client.right, mn_TabHeight, 1);
		}

		// Не будем пока трогать. Некрасиво табы рисуются. Нужно на OwnerDraw переходить.
		#if 0
		DWORD nCurStyle = GetWindowLong(mh_Tabbar, GWL_STYLE);
		DWORD nNeedStyle = (gpSet->nTabsLocation == 1) ? (nCurStyle | TCS_BOTTOM) : (nCurStyle & ~TCS_BOTTOM);
		if (nNeedStyle != nCurStyle)
		{
			SetWindowLong(mh_Tabbar, GWL_STYLE, nNeedStyle);

			//_ASSERTE(!gpSet->isTabFrame);
			if (gpSet->nTabsLocation == 1)
			{
				RECT rcTab = client;
				GetWindowRect(mh_Tabbar, &rcTab);
				SetWindowPos(mh_Tabbar, NULL, 0, client.bottom - (rcTab.bottom-rcTab.top), 0,0, SWP_NOSIZE);
			}
			else
			{
				SetWindowPos(mh_Tabbar, NULL, 0,0, 0,0, SWP_NOSIZE);
			}
		}
		#endif

		//if (gpSet->nTabsLocation == 1)
		//	m_Margins = MakeRect(0,0,0,mn_TabHeight);
		//else
		//	m_Margins = MakeRect(0,mn_TabHeight,0,0);
		//gpSet->UpdateMargins(m_Margins);


		if (lbWideEnough && nBarIndex != 1)
		{
			SendMessage(mh_Rebar, RB_MOVEBAND, nBarIndex, 1);
			nBarIndex = SendMessage(mh_Rebar, RB_IDTOINDEX, 2, 0);
			_ASSERTE(nBarIndex == 1);
		}

		if (lbNeedShow)
		{
			SendMessage(mh_Rebar, RB_SHOWBAND, nBarIndex, 1);
		}
	}
	//else if (gpSet->isTabFrame)
	//{
	//	MoveWindow(mh_Tabbar, 0, 0, client.right, client.bottom, 1);
	//}
	else
	{
		MoveWindow(mh_Tabbar, 0, 0, client.right, mn_TabHeight, 1);
	}

	UpdateToolbarPos();
}