Exemple #1
0
void CPlayerToolBar::OnInitialUpdate()
{
	if (!::IsWindow(m_volctrl.m_hWnd)) {
		return;
	}

	CRect r, br, vr2;

	GetClientRect(&r);
	br = GetBorders();

	if (AfxGetAppSettings().fDisableXPToolbars) {
		int nBMedian = r.bottom - 3 - 0.5 * m_nButtonHeight;
		vr2.SetRect(r.right + br.right - 60, nBMedian - 14, r.right + br.right + 6, nBMedian + 10);
	} else {
		vr2.SetRect(r.right + br.right - 60, r.bottom - 25, r.right + br.right + 6, r.bottom);
	}

	m_volctrl.MoveWindow(vr2);

	if (iDisableXPToolbars != (__int64)AfxGetAppSettings().fDisableXPToolbars) {
		SwitchTheme();
	}

	SetButtonInfo(7, GetItemID(7), TBBS_SEPARATOR | TBBS_DISABLED, 48);
	CRect r10, r12;
	GetItemRect(10, &r10);
	GetItemRect(12, &r12);
	SetButtonInfo(11, GetItemID(11), TBBS_SEPARATOR | TBBS_DISABLED, vr2.left - r10.right - r12.Width());
}
void CFormatBar::PositionCombos()
{
	CRect rect;
	// make font name box same size as font size box
	// this is necessary since font name box is owner draw
	m_comboFontName.SetItemHeight(-1, m_comboFontSize.GetItemHeight(-1));

	m_comboFontName.GetWindowRect(&rect);
	int nHeight = rect.Height();

	int index = 5;
	m_comboFontName.GetWindowRect(&rect);
	SetButtonInfo(index, IDC_FONTNAME, TBBS_SEPARATOR, rect.Width());
	GetItemRect(index, &rect); // FontName ComboBox
	m_comboFontName.SetWindowPos(NULL, rect.left,
		((rect.Height() - nHeight) / 2) + rect.top, 0, 0,
		SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE);

	index = 7;
	m_comboFontSize.GetWindowRect(&rect);
	SetButtonInfo(index, IDC_FONTSIZE, TBBS_SEPARATOR, rect.Width());
	GetItemRect(index, &rect); // FontSize ComboBox
	m_comboFontSize.SetWindowPos(NULL, rect.left,
		((rect.Height() - nHeight) / 2) + rect.top, 0, 0,
		SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE);
}
Exemple #3
0
void CPWFindToolBar::AddExtraControls()
{
  CRect rect, rt;
  int index;

  GetItemRect(0, &rt);
  const int iBtnHeight = rt.Height();
  const int iHeight = iBtnHeight;

  // Add find search text CEdit control (CEditExtn)
  // Get the index of the placeholder's position in the toolbar
  index = CommandToIndex(ID_TOOLBUTTON_FINDEDITCTRL);
  ASSERT(index != -1);

  // If we have been here before, destroy it first
  if (m_findedit.GetSafeHwnd() != NULL) {
    m_findedit.DestroyWindow();
  }

  // Convert that button to a separator
  SetButtonInfo(index, ID_TOOLBUTTON_FINDEDITCTRL, TBBS_SEPARATOR, EDITCTRL_WIDTH);

  // Note: "ES_WANTRETURN | ES_MULTILINE".  This is to allow the return key to be
  // trapped by PreTranslateMessage and treated as if the Find button had been
  // pressed
  rect = CRect(0, 0, EDITCTRL_WIDTH, iHeight);
  VERIFY(m_findedit.Create(WS_CHILD | WS_VISIBLE |
                           ES_AUTOHSCROLL | ES_LEFT | ES_WANTRETURN | ES_MULTILINE,
                           CRect(rect.left + 2, rect.top, rect.right - 2, rect.bottom),
                           this, ID_TOOLBUTTON_FINDEDITCTRL));

  GetItemRect(index, &rect);
  m_findedit.SetWindowPos(NULL, rect.left + 2, rect.top , 0, 0,
                          SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOCOPYBITS);

  // Add find search results CStatic control
  // Get the index of the placeholder's position in the toolbar
  index = CommandToIndex(ID_TOOLBUTTON_FINDRESULTS);
  ASSERT(index != -1);

  // If we have been here before, destroy it first
  if (m_findresults.GetSafeHwnd() != NULL) {
    m_findresults.DestroyWindow();
  }

  // Convert that button to a separator
  SetButtonInfo(index, ID_TOOLBUTTON_FINDRESULTS, TBBS_SEPARATOR, FINDRESULTS_WIDTH);

  rect = CRect(0, 0, FINDRESULTS_WIDTH, iHeight);
  VERIFY(m_findresults.Create(L"", WS_CHILD | WS_VISIBLE |
                              SS_LEFTNOWORDWRAP | SS_CENTERIMAGE,
                              CRect(rect.left + 2, rect.top, rect.right - 2, rect.bottom),
                              this, ID_TOOLBUTTON_FINDEDITCTRL));

  GetItemRect(index, &rect);
  m_findresults.SetWindowPos(NULL, rect.left + 2, rect.top, 0, 0,
                             SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOCOPYBITS);
}
Exemple #4
0
int CTitleBar::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CToolBar::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// Load Toolbar
	if (!LoadToolBar(IDR_TITLEBAR))
		return -1;

	CClientDC dc(this);

	int nHeight=-((dc.GetDeviceCaps(LOGPIXELSY)*8)/72);

	// Create an 8 point sans serief font for the combo boxes
	m_font.CreateFont(nHeight,0,0,0,FW_NORMAL,0,0,0,DEFAULT_CHARSET,OUT_CHARACTER_PRECIS,
		CLIP_CHARACTER_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH | FF_DONTCARE, _T( "MS Sans Serif" ));

	CFont* pOldFont =dc.SelectObject(&m_font);


	TEXTMETRIC tm;
	dc.GetTextMetrics(&tm);

	int cxChar = tm.tmAveCharWidth;
	int cyChar = tm.tmHeight + tm.tmExternalLeading;

	dc.SelectObject(pOldFont);

	// Add "Artist" field to toolbar
	SetButtonInfo(0,IDC_TBARTIST,TBBS_SEPARATOR,cxChar*16);

	CRect rcClient;

	GetItemRect(0,&rcClient);

	rcClient.bottom=rcClient.top+ (cyChar*16);

	if (!m_Artist.Create( _T( "Artist" ),WS_CHILD|WS_VISIBLE,rcClient,this,IDC_TBARTIST))
		return -1;

	// Add "Artist" field to toolbar
	SetButtonInfo(2,IDC_TBARTISTE,TBBS_SEPARATOR,cxChar*80);

	rcClient;

	GetItemRect(2,&rcClient);

	rcClient.bottom=rcClient.top+ (cyChar*16);

	if (!m_ArtistE.Create(WS_CHILD|WS_VISIBLE,rcClient,this,IDC_TBARTISTE))
		return -1;

	
	return 0;
}
void CMuleToolbarCtrl::SetAllButtonsStrings()
{
	static const int TBStringIDs[] =
	{
		IDS_EM_KADEMLIA, 
		IDS_EM_SERVER,
		IDS_EM_TRANS,
		IDS_EM_SEARCH,
		IDS_EM_FILES,
		IDS_EM_MESSAGES,
#ifdef IRC
		IDS_IRC,
#endif
		IDS_EM_STATISTIC,
		IDS_EM_PREFS,
		IDS_TOOLS,
#ifdef MOD_SUNYAN
		IDS_EM_HELP,
		IDS_DMIBOX
#else
		IDS_EM_HELP
#endif
	};
	TBBUTTONINFO tbi;
	tbi.dwMask = TBIF_TEXT;
	tbi.cbSize = sizeof(TBBUTTONINFO);

	CString buffer;
	if (theApp.serverconnect->IsConnected())
		buffer = GetResString(IDS_MAIN_BTN_DISCONNECT);
	else if (theApp.serverconnect->IsConnecting())
		buffer = GetResString(IDS_MAIN_BTN_CANCEL);
	else
		buffer = GetResString(IDS_MAIN_BTN_CONNECT);

	_sntprintf(TBStrings[0], _countof(TBStrings[0]), _T("%s"), buffer);
	TBStrings[0][_countof(TBStrings[0]) - 1] = _T('\0');
	tbi.pszText = TBStrings[0];
	SetButtonInfo(IDC_TOOLBARBUTTON+0, &tbi);

	for (int i = 1; i < m_buttoncount; i++)
	{
		_sntprintf(TBStrings[i], _countof(TBStrings[0]), _T("%s"), GetResString(TBStringIDs[i-1]));
		TBStrings[i][_countof(TBStrings[0]) - 1] = _T('\0');
		tbi.pszText = TBStrings[i];
		SetButtonInfo(IDC_TOOLBARBUTTON+i, &tbi);
	}
}
void CBrowserToolbarCtrl::Localize()
{
	static const int TBStringIDs[] =
	{
		IDS_BROWSER_BACK, 
		IDS_BROWSER_FORWARD,
		IDS_BROWSER_STOP,
		IDS_BROWSER_REFRESH,
		IDS_BROWSER_VERYCD //Added by GGSoSo for webbrowser
	};
	TBBUTTONINFO tbi;
	tbi.dwMask = TBIF_TEXT;
	tbi.cbSize = sizeof(TBBUTTONINFO);

	for (int i = 0; i < NUM_BROWSER_BUTTON; i++)
	{
		_sntprintf(TBStrings[i], ARRSIZE(TBStrings[0]), _T("%s"), GetResString(TBStringIDs[i]));
		tbi.pszText = TBStrings[i];
		SetButtonInfo(IDC_BROWSERBUTTON+i, &tbi);
	}

	CWnd *pParent = GetParent();
	if (NULL != pParent)
		pParent->SendMessage(WM_SIZE);
}
Exemple #7
0
void CPlayerToolBar::ArrangeControls()
{
    if (!::IsWindow(m_volctrl.m_hWnd)) {
        return;
    }

    CRect r;
    GetClientRect(&r);

    CRect br = GetBorders();

    CRect r10;
    GetItemRect(10, &r10);

    CRect vr;
    m_volctrl.GetClientRect(&vr);
    CRect vr2(r.right + br.right - 60, r.bottom - 25, r.right + br.right + 6, r.bottom);
    m_volctrl.MoveWindow(vr2);

    UINT nID;
    UINT nStyle;
    int iImage;
    GetButtonInfo(12, nID, nStyle, iImage);
    SetButtonInfo(11, GetItemID(11), TBBS_SEPARATOR, vr2.left - iImage - r10.right - (r10.bottom - r10.top) + 11);
}
Exemple #8
0
CWnd* CToolBarEx::InsertControl(CWnd* pCtrl, RECT& rect, UINT nID)
{
	ASSERT_VALID(pCtrl);
	// make sure the id is valid, and set the button style for a seperator.
	int nState, nIndex = CommandToIndex(nID);
	if (nIndex > -1)
	{
		ASSERT(nIndex >= 0);
		SetButtonInfo(nIndex, nID, TBBS_SEPARATOR, rect.right - rect.left);
		// insert the control into the toolbar.
		GetItemRect(nIndex, &rect);				
		pCtrl->SetWindowPos(0, rect.left, rect.top, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOCOPYBITS);
		pCtrl->SetFont(GetFont());

		BOOL bVert = (m_dwStyle & CBRS_ORIENT_VERT) != 0;
		if (bVert)
		{
		   	nState = GetToolBarCtrl().GetState(nIndex);
		   	GetToolBarCtrl().SetState(nID,(nState | TBSTATE_HIDDEN));
			pCtrl->ShowWindow(SW_HIDE);
		}
		else
		{
		   	nState = GetToolBarCtrl().GetState(nIndex);
		   	GetToolBarCtrl().SetState(nIndex,(nState & ~TBSTATE_HIDDEN));
			pCtrl->ShowWindow(SW_SHOW);
		}
	}
	else pCtrl->ShowWindow(SW_HIDE);	
	return pCtrl;	
}
void CPlayerToolBar::ArrangeControls()
{
    if (!::IsWindow(m_volctrl.m_hWnd)) {
        return;
    }

    CRect r;
    GetClientRect(&r);

    CRect br = GetBorders();

    CRect r10;
    GetItemRect(10, &r10);

    CRect vr(r.right + br.right - 60, r.top - 2, r.right + br.right + 6, r.bottom);
    m_volctrl.MoveWindow(vr);

    CRect thumbRect;
    m_volctrl.GetThumbRect(thumbRect);
    m_volctrl.MapWindowPoints(this, thumbRect);
    vr.top += std::max((r.bottom - thumbRect.bottom - 4) / 2, 0l);
    vr.left -= m_volumeMinSizeInc = MulDiv(thumbRect.Height(), 50, 19) - 50;
    m_volctrl.MoveWindow(vr);

    UINT nID;
    UINT nStyle;
    int iImage;
    GetButtonInfo(12, nID, nStyle, iImage);
    SetButtonInfo(11, GetItemID(11), TBBS_SEPARATOR, vr.left - iImage - r10.right - (r10.bottom - r10.top) + 11);
}
void CToolBarCtrlX::SetBtnText(int nID, LPCTSTR pszString)
{
	TBBUTTONINFO tbbi = {0};
	tbbi.cbSize = sizeof tbbi;
	tbbi.dwMask = TBIF_TEXT;
	tbbi.pszText = const_cast<LPTSTR>(pszString);
	SetButtonInfo(nID, &tbbi);
}
void CToolBarCtrlX::SetBtnWidth(int nID, int iWidth)
{
	TBBUTTONINFO tbbi = {0};
	tbbi.cbSize = sizeof tbbi;
	tbbi.dwMask = TBIF_SIZE;
	tbbi.cx = (WORD)iWidth;
	SetButtonInfo(nID, &tbbi);
}
Exemple #12
0
int
MFCQuaTransportBar::OnCreate(LPCREATESTRUCT lpcs) 
{
	TBBUTTONINFO	tbinfo;
	
	tbinfo.cbSize = sizeof(TBBUTTONINFO);
	tbinfo.dwMask = TBIF_SIZE;

	LoadToolBar(IDR_QUAMFCTYPE);
	int gotit = CToolBar::OnCreate(lpcs);

	for (int index=0; index<GetCount(); index++) {
		int	id = GetItemID(index);
		CRect	rect;
		CRect	tr;
		GetItemRect(index, &rect);
		COLORREF	bgc = GetSysColor(COLOR_MENUBAR);
		if (id == ID_TRANSPORT_PLAYTIME) {
		    SetButtonInfo(index, ID_TRANSPORT_PLAYTIME, TBBS_SEPARATOR, TIME_DISPLAY_WIDTH+20);
			rect.top = 1;
			rect.left +=5;
			rect.right = rect.left+TIME_DISPLAY_WIDTH;
			rect.bottom = 22;
			tr = CRect(3, 5, 3+TIME_DISPLAY_WIDTH, 5+TIME_DISPLAY_HEIGHT);
			pleitym.CreateTimeCtrl(rect, this, ID_TRANSPORT_PLAYTIME, &displayFont, &tr, &bgc, &rgb_black, &rgb_red);
			pleitym.SetVCMsgParams(QM_CTL_CHANGED, QCID_TB_TIME, (WPARAM)&pleitym);
		} else if (id == ID_TRANSPORT_TEMPO) {
			rect.top = 1;
		    SetButtonInfo(index, ID_TRANSPORT_TEMPO, TBBS_SEPARATOR, TEMPO_DISPLAY_WIDTH+10);
			rect.right = rect.left+TEMPO_DISPLAY_WIDTH+2;
			rect.bottom = 22;
			tr = CRect(3+26, 5, 3+TEMPO_DISPLAY_WIDTH, 5+TEMPO_DISPLAY_HEIGHT);
			tempeh.CreateFloatCtrl(rect, this, ID_TRANSPORT_PLAYTIME, &displayFont, &tr, &bgc, &rgb_black, &rgb_red);
			tempeh.SetVCMsgParams(QM_CTL_CHANGED, QCID_TB_TEMPO, (WPARAM)&tempeh);
//			tempeh.SetLabel("BPM", &labelFont);
			tempeh.SetRange(1, 120, 2001);
			tempeh.SetSteps(1,0.1f,0.01f);
			tempeh.SetValue(1029.2345f);
		}
 

	}
	return gotit;
}
Exemple #13
0
bool Toolbar::SetButtonText(INT_PTR iCmd, CTSTRING &tsText) {

  TBBUTTONINFO bi = {0};

  bi.cbSize   = sizeof(TBBUTTONINFO);
  bi.dwMask   = TBIF_TEXT;
  bi.pszText  = const_cast<PTSTR>(tsText.c_str());

  return SetButtonInfo(iCmd, &bi);
}
Exemple #14
0
BOOL CLineBar::ShowComboBoxline()
{
	CRect rect;
	SetButtonInfo(0, ID_BL, TBBS_SEPARATOR,150);
	if(m_combox.m_hWnd != NULL)
	{
		m_combox.ShowWindow(SW_SHOW);
	}
		return FALSE;
}
Exemple #15
0
BOOL ULTooToolBar::SetVertical()
{
	m_bVertical = TRUE;

	SetButtonInfo(COMBOBOX_INDEX, ID_EDIT_FIND, TBBS_BUTTON, COMBOBOX_BITMAP);

	if (m_ToolBox.m_hWnd != NULL)
		m_ToolBox.ShowWindow(SW_HIDE);

	return TRUE;
}
DWORD CToolBarCtrlX::RemoveBtnStyle(int id, DWORD dwStyle)
{
	TBBUTTONINFO tbbi = {0};
	tbbi.cbSize = sizeof tbbi;
	tbbi.dwMask = TBIF_STYLE;
	(void)GetButtonInfo(id, &tbbi);
	DWORD dwOldStyle = tbbi.fsStyle;
	tbbi.fsStyle &= ~dwStyle;
	SetButtonInfo(id, &tbbi);
	return dwOldStyle;
}
Exemple #17
0
BOOL CDeviceBar::Create(CWnd *pWnd)
{
    if (!CreateEx(pWnd, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
        | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
        !LoadToolBar(IDR_DEVICEBAR))
    {
        TRACE0("Failed to create toolbar\n");
        return FALSE;      // fail to create
    }

    CRect rect;
    int nIndex;
    nIndex = GetToolBarCtrl().CommandToIndex(ID_DEVICE_TYPE);
    SetButtonInfo(nIndex, ID_DEVICE_TYPE, TBBS_SEPARATOR, 205);
    GetToolBarCtrl().GetItemRect(nIndex, &rect);
    rect.top = 1;
    rect.bottom = rect.top + 250;
    if (!m_DeviceType.Create(CBS_DROPDOWNLIST | WS_VISIBLE |
        WS_TABSTOP | WS_VSCROLL, rect, this, ID_DEVICE_TYPE))
    {
        TRACE("Failed to create combo-box\n");
        return FALSE;
    }
    nIndex = GetToolBarCtrl().CommandToIndex(ID_DEVICE_SUBTYPE);
    SetButtonInfo(nIndex, ID_DEVICE_SUBTYPE, TBBS_SEPARATOR, 205);
    GetToolBarCtrl().GetItemRect(nIndex,&rect);
    rect.top = 1;
    rect.bottom = rect.top + 250;
    if (!m_DeviceSubType.Create(CBS_DROPDOWNLIST | WS_VISIBLE |
        WS_TABSTOP | WS_VSCROLL, rect, this, ID_DEVICE_SUBTYPE))
    {
        TRACE("Failed to create combo-box\n");
        return FALSE;
    }
    ResetDeviceTypes();
    ResetDeviceSubTypes();
    return TRUE;
}
void CDropDownButton::SetWindowText(LPCTSTR pszString)
{
	int cx = 0;
	if (!m_bSingleDropDownBtn)
		cx = GetBtnWidth(GetWindowLong(m_hWnd, GWL_ID));

	TBBUTTONINFO tbbi = {0};
	tbbi.cbSize = sizeof tbbi;
	tbbi.dwMask = TBIF_TEXT;
	tbbi.pszText = const_cast<LPTSTR>(pszString);
	SetButtonInfo(GetWindowLong(m_hWnd, GWL_ID), &tbbi);

	if (cx)
		SetBtnWidth(GetWindowLong(m_hWnd, GWL_ID), cx);
}
void CDropDownButton::ResizeToMaxWidth()
{
	if (!m_bSingleDropDownBtn)
		return;

	CRect rcWnd;
	GetWindowRect(&rcWnd);
	if (rcWnd.Width() > 0)
	{
	    TBBUTTONINFO tbbi = {0};
	    tbbi.cbSize = sizeof tbbi;
	    tbbi.dwMask = TBIF_SIZE;
	    tbbi.cx = (WORD)rcWnd.Width();
	    SetButtonInfo(GetWindowLong(m_hWnd, GWL_ID), &tbbi);
	}
}
Exemple #20
0
BOOL ULTooToolBar::SetHorizontal()
{
	m_bVertical = FALSE;

	SetBarStyle((GetBarStyle() & ~CBRS_ALIGN_ANY) | CBRS_ALIGN_TOP);

	SetButtonInfo(COMBOBOX_INDEX, ID_TOOLCOMBOBOXID, TBBS_SEPARATOR, COMBOBOX_WIDTH);

	if (m_ToolBox.m_hWnd != NULL)
	{
		CRect rect;
		GetItemRect(COMBOBOX_INDEX, rect);

		m_ToolBox.SetWindowPos(NULL, rect.left, rect.top, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOCOPYBITS);
		m_ToolBox.ShowWindow(SW_SHOW);
	}

	return TRUE;
}
void CDropDownButton::SetIcon(LPCTSTR pszResourceID)
{
	if (!m_bSingleDropDownBtn)
		return;

	CImageList iml;
	iml.Create(16, 16, ILC_COLOR32 | ILC_MASK, 1, 1);
	iml.Add(CTempIconLoader(pszResourceID));
	CImageList* pImlOld = SetImageList(&iml);
	iml.Detach();
	if (pImlOld)
		pImlOld->DeleteImageList();

	TBBUTTONINFO tbbi = {0};
	tbbi.cbSize = sizeof tbbi;
	tbbi.dwMask = TBIF_IMAGE;
	tbbi.iImage = 0;
	SetButtonInfo(GetWindowLong(m_hWnd, GWL_ID), &tbbi);
}
BOOL CToolBarWithCombo::CreateComboBox(CComboBox& comboBox, UINT nIndex, UINT nID, 
								int nWidth, int nDropHeight)
{
	// Create the combo box
	SetButtonInfo(nIndex, nID, TBBS_SEPARATOR, nWidth);

	CRect rect;
	GetItemRect(nIndex, &rect);
	rect.top = 1;
	rect.bottom = rect.top + nDropHeight;
	if (!comboBox.Create(
			CBS_DROPDOWN|WS_VISIBLE|WS_TABSTOP|WS_VSCROLL,
			rect, this, nID))
	{
		TRACE("Failed to create combo-box\n");
		return FALSE;
	}

	return TRUE;
}
BOOL CFormatBar::create(CWnd *parent)
{
	if (!CreateEx(parent, TBSTYLE_FLAT,
		WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS | CBRS_SIZE_FIXED) ||
		!LoadBitmap(IDB_FORMATBAR) ||
		!SetButtons(format, sizeof(format)/sizeof(UINT)))
	{
		return FALSE;      // fail to create
	}

	for (int i = 0; i < 3; ++i) {
		UINT id, style;
		int image;
		GetButtonInfo(i, id, style, image);
		SetButtonInfo(i, id, style | TBBS_CHECKBOX, image);
	}

	SetSizes(CSize(23,22), CSize(16,16));
	PositionCombos();

	return TRUE;
}
Exemple #24
0
void CMuleToolbarCtrl::ChangeTextLabelStyle(EToolbarLabelType eLabelType, bool bRefresh, bool bForceUpdateButtons)
{
	if (m_eLabelType != eLabelType || bForceUpdateButtons)
	{
		switch (eLabelType)
		{
			case NoLabels:
				SetStyle(GetStyle() & ~TBSTYLE_LIST);
				SetMaxTextRows(0);
				break;
			case LabelsBelow:
				SetStyle(GetStyle() & ~TBSTYLE_LIST);
				SetMaxTextRows(1);
				break;
			case LabelsRight:
				SetStyle(GetStyle() | TBSTYLE_LIST);
				SetMaxTextRows(1);
				break;
		}

		for (int i = 0; i < m_buttoncount; i++)
		{	
			TBBUTTONINFO tbbi = {0};
			tbbi.cbSize = sizeof(tbbi);
			tbbi.dwMask = TBIF_STYLE;
			GetButtonInfo(IDC_TOOLBARBUTTON + i, &tbbi);
			if (eLabelType == LabelsRight)
				tbbi.fsStyle |= TBSTYLE_AUTOSIZE;
			else
				tbbi.fsStyle &= ~TBSTYLE_AUTOSIZE;
			SetButtonInfo(IDC_TOOLBARBUTTON + i, &tbbi);
		}

		m_eLabelType = eLabelType;
		if (bRefresh)
			Refresh();
	}
}
void CBrowserToolbarCtrl::EnableAllButtons(BOOL bEnable)
{
	int iCount = GetButtonCount();

	int	i;
	TBBUTTONINFO	tbbi;

	ZeroMemory(&tbbi, sizeof(tbbi));
	tbbi.cbSize = sizeof(tbbi);
	tbbi.dwMask = TBIF_BYINDEX | TBIF_STATE;

	for (i = 0; i < iCount; i++)
	{
		GetButtonInfo(i, &tbbi);

		if (bEnable)
			tbbi.fsState |= TBSTATE_ENABLED;
		else
			tbbi.fsState &= ~TBSTATE_ENABLED;

		SetButtonInfo(i, &tbbi);
	}
}
Exemple #26
0
void
CToolWindow::UpdateIcon()
{
	if (!m_Parent) return;
	if (!m_hWnd) return;
	CString bname = _T("XRefresh");
	int count = GetButtonCount();
	for (int i=0; i<count; i++)
	{
		TBBUTTON button;
		ZeroMemory(&button, sizeof(button));
		GetButton(i, &button);

		TBBUTTONINFO info;
		TCHAR buf[1000];
		ZeroMemory(&info, sizeof(info));
		info.cbSize = sizeof(info);
		info.dwMask = TBIF_TEXT|TBIF_IMAGE;
		info.cchText = 999;
		info.pszText = buf;
		GetButtonInfo(button.idCommand, &info);
		if (bname==buf)
		{
			if (m_Parent->IsConnected())
			{
				info.iImage = m_IconBase+0;
			}
			else
			{
				info.iImage = m_IconBase+1;
			}
			SetButtonInfo(button.idCommand, &info);
			break;
		}
	}
}
Exemple #27
0
int CDynToolBar::Create(BOOL ShowTitle, BOOL FloatIt, DWORD dwDockingStyle, DWORD dwBarStyle, BOOL Show, BOOL UseEscape)
  {
  DWORD dwStyle = WS_CHILD|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY;
  if (Show)
    dwStyle |= WS_VISIBLE;
  if (bCanConfigure)
    dwStyle |= CCS_ADJUSTABLE;
  if (!CToolBar::Create(pTBMngr->pMainFrame, dwStyle, iWindowID))
    return -1;
  //if (!SetButtons(pBtnIDs, iLen))
  //  return -2; 

  BITMAP bm;
  bm.bmType = 0;
  bm.bmWidth = pTBMngr->BtnWidth * iBitLen * 8 / pTBMngr->BitsPixel;
  bm.bmHeight = pTBMngr->BtnHeight;
  bm.bmWidthBytes = pTBMngr->BtnWidth * iBitLen;
  bm.bmPlanes = 1;
  bm.bmBitsPixel = pTBMngr->BitsPixel;
  bm.bmBits = (LPVOID)pBits;
  if (!Bitmap.CreateBitmapIndirect(&bm))
    return -3;
  CToolBarCtrl& bc = GetToolBarCtrl();
  if (bc.AddBitmap(iBitLen/*(bButtonsOnce ? iBitLen : iLen)*/, &Bitmap)<0)
    return -4;
  if (!DoCreateButtons())
    return -5;

  if (iTxtLen>0)
    {
    pTxtButtons = new CButton[iTxtLen];
    UINT TxtCnt = 0;
    CRect rect;
    for (UINT i=0; i<iLen; i++)
      if (BtnStyles[i]==ButText)
        {
        SetButtonInfo(i, BtnIDs[i], TBBS_SEPARATOR, (BtnTxts[TxtCnt].GetLength()+3)*6);
        GetItemRect(i, &rect);
        pTxtButtons[TxtCnt].Create((const char*)(BtnTxts[TxtCnt]), WS_VISIBLE|WS_TABSTOP, rect, this, BtnIDs[i]);
        pTxtButtons[TxtCnt].SetFont(&(pTBMngr->Font));
        TxtCnt++;
        }
    }
  
  if (iComboLen>0)
    {
    bComboListChanged = 0;
    const int nDropHeight = 100;
    pComboButtons = new CComboBox[iComboLen];
    UINT ComboCnt = 0;
    CRect rect;
    for (UINT i=0; i<iLen; i++)
      if (BtnStyles[i]==ButCombo)
        {
        SetButtonInfo(i, BtnIDs[i], TBBS_SEPARATOR, 120);
        GetItemRect(i, &rect);
        rect.top = 3;
        rect.bottom = rect.top + nDropHeight;
        pComboButtons[ComboCnt].Create(CBS_DROPDOWN|CBS_AUTOHSCROLL|WS_VISIBLE|WS_TABSTOP, rect, this, ID_TOOLBAR_COMBO_0+ComboCnt);//BtnIDs[i]);
        pComboButtons[ComboCnt].SetFont(&(pTBMngr->Font));
        ComboCnt++;
        }
    }

  if (iEditLen>0)
    {
    pEditButtons = new CEdit[iEditLen];
    UINT EditCnt = 0;
    CRect rect;
    for (UINT i=0; i<iLen; i++)
      if (BtnStyles[i]==ButEdit)
        {
        SetButtonInfo(i, BtnIDs[i], TBBS_SEPARATOR, 120);
        GetItemRect(i, &rect);
        //rect.top = 3;
        //rect.bottom = rect.top + nDropHeight;
        pEditButtons[EditCnt].Create(WS_VISIBLE|WS_TABSTOP, rect, this, BtnIDs[i]);//ID_TOOLBAR_EDIT_0+EditCnt);
        pEditButtons[EditCnt].SetFont(&(pTBMngr->Font));
        EditCnt++;
        }
    }
  
  SetBarStyle(GetBarStyle() | dwBarStyle);
  if (ShowTitle)
    SetWindowText((const char*)sTitle);
  EnableDocking(dwDockingStyle);
  if (FloatIt)
    pTBMngr->pMainFrame->FloatControlBar(this, Location);
  else
    pTBMngr->pMainFrame->DockControlBar(this);
  bUseEscape = UseEscape;
  bWasVisible = Show;
  return 0;
  }
Exemple #28
0
BOOL CRRECToolbar::Create( CWnd* parent, CRect& rc )
/* ============================================================
	Function :		CRRECToolbar::Create
	Description :	Creates the toolbar control
	Access :		Public
					
	Return :		BOOL			-	"TRUE" if success
	Parameters :	CWnd* parent	-	Parent editor
					CRect& rc		-	Rectangle to place 
										toolbar in.

	Usage :			Called from the parent editor

   ============================================================*/
{

	BOOL result = FALSE;

	HINSTANCE hInstance = AfxFindResourceHandle( MAKEINTRESOURCE( TOOLBAR_CONTROL ), RT_TOOLBAR );
	if(!hInstance)
		return FALSE;

	HRSRC hRsrc = ::FindResource( hInstance, MAKEINTRESOURCE( TOOLBAR_CONTROL ), RT_TOOLBAR );
	if( !hRsrc )
		return FALSE;

	HGLOBAL hGlobal = LoadResource( hInstance, hRsrc );
	if (hGlobal == NULL)
		return FALSE;

	CToolBarData* pData = ( CToolBarData* ) LockResource( hGlobal );
	if (pData == NULL)
		return FALSE;

	ASSERT( pData->wVersion == 1 );

	TBBUTTON tb, tbSep;
	memset ( &tb, 0, sizeof( tb ) );
	memset ( &tbSep, 0, sizeof( tbSep ) );

	result = CToolBarCtrl::Create(WS_VISIBLE|WS_CHILD, rc, parent, TOOLBAR_CONTROL);

	if( result )
	{
		SetButtonStructSize( sizeof ( tb ) );

		CSize sz ( pData->wWidth, pData->wHeight );
		SetBitmapSize( sz );
		sz.cx += 4;
		sz.cy += 4;
		SetButtonSize( sz );

		// Loop through adding buttons.
		tb.fsState = TBSTATE_ENABLED;
		tb.fsStyle = TBSTYLE_BUTTON;
		tb.iString = -1;
		tb.iBitmap = 0;

		tbSep.iString = -1;
		tbSep.fsStyle = TBSTYLE_SEP;

		for( WORD w = 0; w < pData->wItemCount; w++ )
		{
			if ( pData->items()[ w ] == 0 )
				AddButtons( 1, &tbSep );
			else
			{
				tb.idCommand = pData->items()[ w ];
				AddButtons( 1, &tb );
				tb.iBitmap++;
			}
		}

		HBITMAP	hBitmap = (HBITMAP) ::LoadImage( hInstance, MAKEINTRESOURCE( TOOLBAR_CONTROL ), IMAGE_BITMAP, 0,0, LR_LOADMAP3DCOLORS );
		if( !hBitmap )
			return FALSE;

		BITMAP bm;
		memset( &bm, 0, sizeof ( bm ) );
		::GetObject( hBitmap, sizeof ( bm ), &bm );
		AddBitmap( bm.bmWidth / pData->wWidth, CBitmap::FromHandle ( hBitmap ) );

		UnlockResource( hGlobal );
		FreeResource( hGlobal );

		/////////////////////////////////////
		// Map in combo boxes
		//

		CRect rect;

		TBBUTTONINFO tbi;
		tbi.cbSize = sizeof( TBBUTTONINFO );
		tbi.cx = FONT_COMBO_WIDTH;
		tbi.dwMask = TBIF_SIZE | 0x80000000;  // By index

		SetButtonInfo( FONT_NAME_POS, &tbi );
		GetItemRect( FONT_NAME_POS, &rect );
		rect.bottom += COMBO_HEIGHT;

		// The font name combo
		if( m_font.Create( WS_CHILD | 
							WS_VSCROLL |
							WS_VISIBLE |
							CBS_AUTOHSCROLL | 
							CBS_DROPDOWN | 
							CBS_SORT | 
							CBS_HASSTRINGS, 
							rect, this, DROPDOWN_FONT ) )
		{

			m_font.SetFont( CFont::FromHandle( ( HFONT ) ::GetStockObject( ANSI_VAR_FONT ) ) );
			m_font.FillCombo();

			tbi.cx = COMBO_WIDTH;
			SetButtonInfo( FONT_SIZE_POS, &tbi );
			GetItemRect( FONT_SIZE_POS, &rect );
			rect.bottom += COMBO_HEIGHT;

			// The font size combo
			if( m_size.Create( WS_CHILD | 
								WS_VISIBLE | 
								CBS_AUTOHSCROLL | 
								CBS_DROPDOWNLIST | 
								CBS_HASSTRINGS, 
								rect, this, DROPDOWN_SIZE ) )
			{

				m_size.SetFont( CFont::FromHandle( ( HFONT ) ::GetStockObject( ANSI_VAR_FONT ) ) );
				m_size.FillCombo();
				CString color;
				CString defaultText;
				CString customText;
				color.LoadString( STRING_COLOR );
				defaultText.LoadString( STRING_DEFAULT );
				customText.LoadString( STRING_CUSTOM );

				tbi.cx = COLOR_WIDTH;
				SetButtonInfo( FONT_COLOR_POS, &tbi );
				GetItemRect( FONT_COLOR_POS, &rect );

				// The color picker
				if( m_color.Create( color,
									WS_VISIBLE|
									WS_CHILD,
									rect, this, BUTTON_COLOR ) )
				{

					m_color.SetDefaultText( defaultText );
					m_color.SetCustomText( customText );
					m_color.SetSelectionMode( CP_MODE_TEXT );
					m_color.SetBkColour( RGB( 255, 255, 255 ) );

					m_color.SetFont( CFont::FromHandle( ( HFONT ) ::GetStockObject( ANSI_VAR_FONT ) ) );
					result = TRUE;

				}

			}

		}

	}

	return result;

}
Exemple #29
0
bool CEditToolBar::Create(CMainFrame* pParent)
{
    ASSERT_VALID(pParent);

    if (!CToolBar::Create(pParent, WS_CHILD | WS_VISIBLE | /*CBRS_SIZE_DYNAMIC |*/ CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY) ||
        !LoadToolBar(IDR_MAINFRAME))
    {
        TRACE0("Failed to create toolbar\n");
        ASSERT(false);
        return false;
    }

    ////////////////////////////////////////////////////////////////////////////////

    // Create an 8-point MS Sans Serif font for the combo boxes
    CClientDC dc(this);
    int FontHeight = -((dc.GetDeviceCaps (LOGPIXELSY) * 8) / 72);
    m_ToolBarFont.CreateFont(FontHeight, 0, 0, 0, FW_NORMAL, 0, 0, 0,
        DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS,
        DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "MS Sans Serif");

    // mearsure font to get size of average character
    CFont* pOldFont = dc.SelectObject(&m_ToolBarFont);
    TEXTMETRIC tm;
    dc.GetTextMetrics(&tm);
    int CharWidth  = tm.tmAveCharWidth;
    int CharHeight = tm.tmHeight + tm.tmExternalLeading;
    dc.SelectObject(pOldFont);


    // create catagory list
    {
        SetButtonInfo(k_CatagoryIndex, ID_CATEGORY, TBBS_SEPARATOR, CharWidth*25);

        CRect rect;
        GetItemRect(k_CatagoryIndex, &rect);
        rect.bottom = rect.top + CharHeight*35;

        if (!m_CategoryList.Create(
            WS_CHILD | WS_VISIBLE | WS_VSCROLL | CBS_DROPDOWNLIST,
            rect, this, ID_CATEGORY))
            return false;

        m_CategoryList.SetFont(&m_ToolBarFont);
        for (int i = 0; i < NUMCATEGORIES; i++)
        {
            m_CategoryList.AddString(g_CategoryNames[i]);
        }
        m_CategoryList.SetCurSel(g_Category);
    }

    // create terrain list
    {
        SetButtonInfo(k_TerrainIndex, ID_TERRAIN, TBBS_SEPARATOR, CharWidth*30);

        CRect rect;
        GetItemRect(k_TerrainIndex, &rect);
        rect.bottom = rect.top + CharHeight*20;

        if (!m_TerrainList.Create(
            WS_CHILD | WS_VISIBLE | WS_VSCROLL | CBS_DROPDOWNLIST,
            rect, this, ID_TERRAIN))
            return false;

        m_TerrainList.SetFont(&m_ToolBarFont);
        for (int i = 0; i < MAXTILES; i++)
            g_TerrainToTile[i] = -1;
        int j=0;
        for (i = 0; i < g_App.m_Elements.GetSize(); i++)
        {
            if (g_App.m_Elements[i].TileType == g_Category)
            {
                g_TerrainToTile[j++] = i;
                m_TerrainList.AddString(g_App.m_Elements[i].Name);

            }
        }
        g_Terrain = 0;
        m_TerrainList.SetCurSel(g_Terrain);
    }

    // create elevation edit
    {
        SetButtonInfo(k_ElevationIndex, ID_ELEVATION, TBBS_SEPARATOR, CharWidth*5);

        CRect rect;
        GetItemRect(k_ElevationIndex, &rect);
        rect.bottom -= 1;
        rect.top += 1;

        if (!m_ElevationEdit.Create(ES_NUMBER | WS_BORDER | WS_CHILD | WS_VISIBLE,
            rect, this, ID_ELEVATION))
            return false;
        m_ElevationEdit.SetFont(&m_ToolBarFont);
        g_Elevation = 20;
        CString str;
        str.Format("%d", g_Elevation);
        m_ElevationEdit.SetWindowText(str);

        SetButtonInfo(k_ElevationSpinnerIndex, ID_ELEVATION_SPINNER, TBBS_SEPARATOR, 20);
        GetItemRect(k_ElevationSpinnerIndex, &rect);
        rect.left += 3;
        rect.right += 3;
        if (!m_ElevationCtrl.Create(UDS_SETBUDDYINT|UDS_ARROWKEYS| WS_CHILD | WS_VISIBLE,
            rect, this, ID_ELEVATION_SPINNER))
            return false;
        m_ElevationCtrl.SetBuddy(&m_ElevationEdit);
        m_ElevationCtrl.SetRange(0,100);

    }

    SetWindowText(_T(""));
    EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
    pParent->DockControlBar(this, AFX_IDW_DOCKBAR_TOP);


    return true;
}
BOOL CPlayerToolBar::Create(CWnd* pParentWnd)
{
    VERIFY(__super::CreateEx(pParentWnd,
                             TBSTYLE_FLAT | TBSTYLE_TRANSPARENT | TBSTYLE_AUTOSIZE | TBSTYLE_CUSTOMERASE,
                             WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | CBRS_TOOLTIPS,
                             CRect(2, 2, 0, 1)));

    VERIFY(LoadToolBar(IDB_PLAYERTOOLBAR));

    // Should never be RTLed
    ModifyStyleEx(WS_EX_LAYOUTRTL, WS_EX_NOINHERITLAYOUT);

    CToolBarCtrl& tb = GetToolBarCtrl();
    tb.DeleteButton(tb.GetButtonCount() - 1);
    tb.DeleteButton(tb.GetButtonCount() - 1);

    SetMute(AfxGetAppSettings().fMute);

    UINT styles[] = {
        TBBS_CHECKGROUP, TBBS_CHECKGROUP, TBBS_CHECKGROUP,
        TBBS_SEPARATOR,
        TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON,
        TBBS_SEPARATOR,
        TBBS_BUTTON,
        TBBS_SEPARATOR,
        TBBS_SEPARATOR,
        TBBS_CHECKBOX,
    };

    for (int i = 0; i < _countof(styles); ++i) {
        // This fixes missing separator in Win 7
        if (styles[i] & TBBS_SEPARATOR) {
            SetButtonInfo(i, GetItemID(i), styles[i], -1);
        } else {
            SetButtonStyle(i, styles[i] | TBBS_DISABLED);
        }
    }

    m_volctrl.Create(this);
    m_volctrl.SetRange(0, 100);

    m_nButtonHeight = 16; // reset m_nButtonHeight
    CImage image;
    if (LoadExternalToolBar(&image)) {
        CBitmap* bmp = CBitmap::FromHandle(image);
        int width = image.GetWidth();
        int height = image.GetHeight();
        int bpp = image.GetBPP();
        if (width == height * 15) {
            // the manual specifies that sizeButton should be sizeImage inflated by (7, 6)
            SetSizes(CSize(height + 7, height + 6), CSize(height, height));

            m_pButtonsImages = DEBUG_NEW CImageList();
            if (bpp == 32) {
                m_pButtonsImages->Create(height, height, ILC_COLOR32 | ILC_MASK, 1, 0);
                m_pButtonsImages->Add(bmp, nullptr); // alpha is the mask
            } else {
                m_pButtonsImages->Create(height, height, ILC_COLOR24 | ILC_MASK, 1, 0);
                m_pButtonsImages->Add(bmp, RGB(255, 0, 255));
            }
            m_nButtonHeight = height;
            GetToolBarCtrl().SetImageList(m_pButtonsImages);
        }
        image.Destroy();
    }

    return TRUE;
}