本文整理汇总了C++中CToolBar类的典型用法代码示例。如果您正苦于以下问题:C++ CToolBar类的具体用法?C++ CToolBar怎么用?C++ CToolBar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CToolBar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
LRESULT CMainFrame::OnReset(LPNMTOOLBAR pNMTB)
// Called when the user presses the Reset button on teh ToolBar customize dialog.
// Here we restore the Toolbar to the settings saved in OnBeginAdjust.
{
CToolBar* pToolBar = static_cast<CToolBar*>(FromHandle(pNMTB->hdr.hwndFrom));
assert (dynamic_cast<CToolBar*> (pToolBar));
// Remove all current buttons
int nCount = pToolBar->GetButtonCount();
for (int i = nCount - 1; i >= 0; i--)
{
pToolBar->DeleteButton(i);
}
// Restore buttons from info stored in m_vTBBReset
int nResetCount = m_vTBBReset.size();
for (int j = 0; j < nResetCount; j++)
{
TBBUTTON tbb = m_vTBBReset[j];
pToolBar->InsertButton(j, &tbb);
}
RecalcLayout();
return TRUE;
}
示例2: ShowButton
void CMainFrame::ShowButton(CToolBar& ToolBar, int CmdID, bool Enable)
{
TBBUTTONINFO tbi;
tbi.cbSize = sizeof(tbi);
tbi.dwMask = TBIF_STATE;
ToolBar.SendMessage(TB_GETBUTTONINFO, CmdID, (LPARAM)&tbi); // get button state
BYTE PrevState = tbi.fsState;
if (Enable) // if showing button
tbi.fsState &= ~TBSTATE_HIDDEN; // unhide it
else
tbi.fsState |= TBSTATE_HIDDEN; // hide it
if (tbi.fsState != PrevState) // if button state changed
ToolBar.SendMessage(TB_SETBUTTONINFO, CmdID, (LPARAM)&tbi); // set button state
}
示例3: AppendToolsToToolbar
void CToolsHelper::AppendToolsToToolbar(const CUserToolArray& aTools, CToolBar& toolbar, UINT nCmdAfter)
{
// remove tools first
RemoveToolsFromToolbar(toolbar, nCmdAfter);
// then re-add
if (aTools.GetSize())
{
// figure out if we want the large or small images
CSize sizeBtn(toolbar.GetToolBarCtrl().GetButtonSize());
sizeBtn -= CSize(7, 7); // btn borders from BarTool.cpp
CSysImageList sil((sizeBtn.cx > 16));
VERIFY(sil.Initialize());
// start adding after the pref button
int nStartPos = toolbar.CommandToIndex(nCmdAfter) + 1;
int nAdded = 0;
for (int nTool = 0; nTool < aTools.GetSize(); nTool++)
{
const USERTOOL& tool = aTools[nTool];
HICON hIcon = GetToolIcon(sil, tool);
if (hIcon)
{
CImageList* pIL = toolbar.GetToolBarCtrl().GetImageList();
int nImage = pIL->Add(hIcon);
TBBUTTON tbb = { nImage, nTool + m_nStartID, 0, TBSTYLE_BUTTON, 0, 0, (UINT)-1 };
if (toolbar.GetToolBarCtrl().InsertButton(nStartPos + nAdded, &tbb))
nAdded++;
else // remove image
pIL->Remove(nImage);
// cleanup
::DestroyIcon(hIcon);
}
}
// add a separator if any buttons added
if (nAdded)
{
TBBUTTON tbb = { -1, 0, 0, TBSTYLE_SEP, 0, 0, (UINT)-1 };
toolbar.GetToolBarCtrl().InsertButton(nStartPos, &tbb);
}
}
}
示例4: AppendExtensionsToToolbar
void CUIExtensionUIHelper::AppendExtensionsToToolbar(CToolBar& toolbar, UINT nCmdAfter)
{
// remove tools first
RemoveExtensionsFromToolbar(toolbar, nCmdAfter);
// then re-add
int nNumExt = m_mgrUIExt.GetNumUIExtensions();
if (nNumExt)
{
// start adding after the pref button
int nStartPos = toolbar.CommandToIndex(nCmdAfter) + 1;
int nAdded = 0;
for (int nExt = 0; nExt < m_mgrUIExt.GetNumUIExtensions(); nExt++)
{
HICON hIcon = m_mgrUIExt.GetUIExtensionIcon(nExt);
if (hIcon)
{
CImageList* pIL = toolbar.GetToolBarCtrl().GetImageList();
int nImage = pIL->Add(hIcon);
TBBUTTON tbb = { nImage, nExt + m_nStartID, 0, TBSTYLE_BUTTON, 0, 0, (UINT)-1 };
if (toolbar.GetToolBarCtrl().InsertButton(nStartPos + nAdded, &tbb))
{
nAdded++;
}
else // remove image
{
pIL->Remove(nImage);
}
// Note: we do not delete the extensions icon
}
}
// add a separator if any buttons added
if (nAdded)
{
TBBUTTON tbb = { -1, 0, 0, TBSTYLE_SEP, 0, 0, (UINT)-1 };
toolbar.GetToolBarCtrl().InsertButton(nStartPos, &tbb);
}
}
}
示例5: ToolbarMenu
void CMainFrame::ToolbarMenu (CToolBar& wndToolbar, UINT nID) {
int i, n, count;
CMenu menu;
CBitmap *bmp;
CRect rect1, rect2;
menu.CreatePopupMenu ();
count = theSettings.GetSetting (nID, CSettings::sqCount);
for (i = 0; i < count; ++i) {
menu.AppendMenu (MF_STRING, n = theSettings.GetSetting (nID, CSettings::sqMenuID, true, (UINT)i), theSettings.GetSetting (nID, CSettings::sqName, (UINT)i));
bmp = theApp.LoadBitmap (theSettings.GetSetting (nID, CSettings::sqBmpID, true, (UINT)i));
menu.SetMenuItemBitmaps (n, MF_BYCOMMAND, bmp, bmp);
}
menu.CheckMenuRadioItem (0, count, theSettings.GetSetting (nID, CSettings::sqCurrent), MF_BYPOSITION);
wndToolbar.GetWindowRect (&rect1);
wndToolbar.GetToolBarCtrl ().GetRect (nID, &rect2);
menu.TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON, rect1.left + rect2.left, rect1.top + rect2.bottom, this);
}
示例6: LoadToolBar
BOOL CCoolBarCtrl::LoadToolBar(UINT nIDToolBar)
{
CToolBar pToolBar;
if ( ! pToolBar.Create( this ) || ! pToolBar.LoadToolBar( nIDToolBar ) ) return FALSE;
for ( int i = 0 ; i < pToolBar.GetCount(); i++ )
{
UINT nID, nStyle;
int nImage;
pToolBar.GetButtonInfo( i, nID, nStyle, nImage );
Add( nID );
}
return TRUE;
}
示例7: RemoveExtensionsFromToolbar
void CUIExtensionUIHelper::RemoveExtensionsFromToolbar(CToolBar& toolbar, UINT nCmdAfter)
{
int nRemoved = 0;
TBBUTTON tbb;
CImageList* pIL = toolbar.GetToolBarCtrl().GetImageList();
for (UINT nExtID = m_nStartID; nExtID <= m_nStartID + m_nSize; nExtID++)
{
int nBtn = toolbar.CommandToIndex(nExtID);
if (nBtn != -1)
{
VERIFY(toolbar.GetToolBarCtrl().GetButton(nBtn, &tbb));
if (toolbar.GetToolBarCtrl().DeleteButton(nBtn))
{
// delete the image too
pIL->Remove(tbb.iBitmap);
nRemoved++;
}
}
}
// remove separator
if (nRemoved)
{
int nSep = toolbar.CommandToIndex(nCmdAfter) + 1;
toolbar.GetToolBarCtrl().DeleteButton(nSep);
}
}
示例8: rc
bool CMainFrame::CreateToolbars()
{
DWORD style = WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC;
CRect rc(0, 0, 0, 0);
for (int iBar = 0; iBar < TOOLBARS; iBar++) {
const BAR_INFO& info = m_ToolbarInfo[iBar];
CToolBar *pBar = STATIC_DOWNCAST(CToolBar, GetBarAtOffset(info.Offset));
if (!pBar->CreateEx(this, TBSTYLE_FLAT, style, rc, info.BarID))
return(FALSE);
if (!pBar->LoadToolBar(info.BarResID))
return(FALSE);
pBar->SetWindowText(LDS(info.CaptionID));
pBar->EnableDocking(CBRS_ALIGN_ANY);
if (info.LeftOf) {
CControlBar *LeftOf = GetBarAtOffset(info.LeftOf);
CWinAppEx::DockControlBarLeftOf(this, pBar, LeftOf);
} else
DockControlBar(pBar);
}
return(TRUE);
}
示例9: CreateFileBar
bool CPromFrame::CreateFileBar(CToolBar& tb, UINT resourceID, const char *title)
{
if (!tb.Create(this) || !tb.LoadToolBar(resourceID)) {
TRACE0("Failed to create toolbar\n");
return false; // fail to create
}
tb.SetBarStyle(tb.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
if (title) {
tb.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
ShowControlBar(&tb,FALSE,FALSE);
DockControlBar(&tb);
tb.SetWindowText(title);
}
return true;
}
示例10: GetToolBar
void CMainFrame::AddCombo()
{
// We'll be placing the ComboBoxEx control over the 'File Save' toolbar button
int nComboWidth = 120;
CToolBar* pTB = GetToolBar();
if (pTB->CommandToIndex(IDM_FILE_SAVE) < 0) return;
pTB->SetButtonStyle(IDM_FILE_SAVE, TBSTYLE_SEP); // Convert the button to a separator
pTB->SetButtonWidth(IDM_FILE_SAVE, nComboWidth);
// Determine the size and position of the ComboBox
int nIndex = pTB->CommandToIndex(IDM_FILE_SAVE);
CRect rc = pTB->GetItemRect(nIndex);
// Create and position the ComboboxEx window
m_ComboBoxEx.Create(pTB);
m_ComboBoxEx.SetWindowPos(NULL, rc, SWP_NOACTIVATE);
// Set ComboBox Height
m_ComboBoxEx.SendMessage(CB_SETITEMHEIGHT, (WPARAM)-1, (LPARAM)rc.Height()-6);
m_ComboBoxEx.AddItems();
RecalcLayout();
}
示例11: switch
/**
* Handles the Notify Messages
*/
LRESULT CWindow::handleNotifyMessages(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
UINT code = ((LPNMHDR) lparam)->code;
switch(code)
{
case TCN_SELCHANGE:
{
HWND hwndFrom = ((LPNMHDR)lparam)->hwndFrom;
CTabControl* tabCtrl = getControlForHandle<CTabControl>(hwndFrom);
if(tabCtrl)
{
return tabCtrl->selChanged();
}
break;
}
case TCN_SELCHANGING:
{
HWND hwndFrom = ((LPNMHDR)lparam)->hwndFrom;
CTabControl* tabCtrl = getControlForHandle<CTabControl>(hwndFrom);
if(tabCtrl)
{
return tabCtrl->selChanging();
}
break;
}
case TVN_ENDLABELEDIT:
{
HWND hwndFrom = ((LPNMHDR)lparam)->hwndFrom;
CTreeControl* tree = getControlForHandle<CTreeControl>(hwndFrom);
if(tree)
{
return tree->endLabelEdit((LPNMTREEVIEW)lparam);
}
break;
}
case TVN_BEGINLABELEDIT:
{
HWND hwndFrom = ((LPNMHDR)lparam)->hwndFrom;
CTreeControl* tree = getControlForHandle<CTreeControl>(hwndFrom);
if(tree)
{
return tree->startLabelEdit((LPNMTREEVIEW)lparam);
}
break;
}
case TTN_GETDISPINFO:
{
LPTOOLTIPTEXT lpttt;
lpttt = (LPTOOLTIPTEXT) lparam;
HWND hwndFrom = lpttt->hdr.hwndFrom; // the tooltips handle
HWND ttparent = GetParent(hwndFrom); // the "main" window
CWindow* ctrl = getControlForHandle<CWindow>(ttparent);
CToolBar* tb = ctrl->getToolbar();
if(tb)
{
int idButton = lpttt->hdr.idFrom;
lpttt->lpszText = (LPWSTR)tb->getTooltip(idButton);
lpttt->uFlags |= TTF_DI_SETITEM;
return 0;
}
}
}
return NOT_HANDLED_MESSAGE;
}
示例12: wxDynamicCast
CToolBar* CToolBar::Load(CMainFrame* pMainFrame)
{
{
wxString str = COptions::Get()->GetOption(OPTION_THEME_ICONSIZE);
wxSize iconSize = CThemeProvider::GetIconSize(str);
wxToolBarXmlHandlerEx::SetIconSize(iconSize);
}
CToolBar* toolbar = wxDynamicCast(wxXmlResource::Get()->LoadToolBar(pMainFrame, _T("ID_TOOLBAR")), CToolBar);
if (!toolbar)
return 0;
toolbar->m_pMainFrame = pMainFrame;
CContextManager::Get()->RegisterHandler(toolbar, STATECHANGE_REMOTE_IDLE, true, true);
CContextManager::Get()->RegisterHandler(toolbar, STATECHANGE_SERVER, true, true);
CContextManager::Get()->RegisterHandler(toolbar, STATECHANGE_SYNC_BROWSE, true, true);
CContextManager::Get()->RegisterHandler(toolbar, STATECHANGE_COMPARISON, true, true);
CContextManager::Get()->RegisterHandler(toolbar, STATECHANGE_APPLYFILTER, true, false);
CContextManager::Get()->RegisterHandler(toolbar, STATECHANGE_QUEUEPROCESSING, false, false);
CContextManager::Get()->RegisterHandler(toolbar, STATECHANGE_CHANGEDCONTEXT, false, false);
toolbar->RegisterOption(OPTION_SHOW_MESSAGELOG);
toolbar->RegisterOption(OPTION_SHOW_QUEUE);
toolbar->RegisterOption(OPTION_SHOW_TREE_LOCAL);
toolbar->RegisterOption(OPTION_SHOW_TREE_REMOTE);
toolbar->RegisterOption(OPTION_MESSAGELOG_POSITION);
#ifdef __WXMSW__
int majorVersion, minorVersion;
wxGetOsVersion(& majorVersion, & minorVersion);
if (majorVersion < 6)
toolbar->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
#endif
toolbar->ToggleTool(XRCID("ID_TOOLBAR_FILTER"), CFilterManager::HasActiveFilters());
toolbar->ToggleTool(XRCID("ID_TOOLBAR_LOGVIEW"), COptions::Get()->GetOptionVal(OPTION_SHOW_MESSAGELOG) != 0);
toolbar->ToggleTool(XRCID("ID_TOOLBAR_QUEUEVIEW"), COptions::Get()->GetOptionVal(OPTION_SHOW_QUEUE) != 0);
toolbar->ToggleTool(XRCID("ID_TOOLBAR_LOCALTREEVIEW"), COptions::Get()->GetOptionVal(OPTION_SHOW_TREE_LOCAL) != 0);
toolbar->ToggleTool(XRCID("ID_TOOLBAR_REMOTETREEVIEW"), COptions::Get()->GetOptionVal(OPTION_SHOW_TREE_REMOTE) != 0);
if (COptions::Get()->GetOptionVal(OPTION_MESSAGELOG_POSITION) == 2)
toolbar->HideTool(XRCID("ID_TOOLBAR_LOGVIEW"));
#ifdef __WXMAC__
// Hide then re-show fixes some odd sizing
toolbar->Hide();
if (COptions::Get()->GetOptionVal(OPTION_TOOLBAR_HIDDEN) == 0)
toolbar->Show();
#endif
return toolbar;
}
示例13: TB_toggle
void CPromFrame::TB_toggle(CToolBar& whichbar)
{
bool displayed=!(whichbar.GetStyle()&WS_VISIBLE);
ShowControlBar(&whichbar,displayed,FALSE);
}
示例14: wxSize
CToolBar* CToolBar::Load(CMainFrame* pMainFrame)
{
wxSize iconSize = CThemeProvider::GetIconSize(iconSizeSmall, true);
#ifdef __WXMAC__
// OS X only knows two hardcoded toolbar sizes.
if (iconSize.x >= 32) {
iconSize = wxSize(32, 32);
}
else {
iconSize = wxSize(24, 24);
}
#endif
CToolBar* toolbar = new CToolBar();
toolbar->m_pMainFrame = pMainFrame;
int style = wxTB_FLAT | wxTB_HORIZONTAL | wxTB_NODIVIDER;
#ifdef __WXMSW__
style |= wxTB_NOICONS;
#endif
if (!toolbar->Create(pMainFrame, XRCID("ID_TOOLBAR"), wxDefaultPosition, wxDefaultSize, style)) {
delete toolbar;
return 0;
}
toolbar->SetToolBitmapSize(iconSize);
toolbar->MakeTools();
CContextManager::Get()->RegisterHandler(toolbar, STATECHANGE_REMOTE_IDLE, true);
CContextManager::Get()->RegisterHandler(toolbar, STATECHANGE_SERVER, true);
CContextManager::Get()->RegisterHandler(toolbar, STATECHANGE_SYNC_BROWSE, true);
CContextManager::Get()->RegisterHandler(toolbar, STATECHANGE_COMPARISON, true);
CContextManager::Get()->RegisterHandler(toolbar, STATECHANGE_APPLYFILTER, true);
CContextManager::Get()->RegisterHandler(toolbar, STATECHANGE_QUEUEPROCESSING, false);
CContextManager::Get()->RegisterHandler(toolbar, STATECHANGE_CHANGEDCONTEXT, false);
toolbar->RegisterOption(OPTION_SHOW_MESSAGELOG);
toolbar->RegisterOption(OPTION_SHOW_QUEUE);
toolbar->RegisterOption(OPTION_SHOW_TREE_LOCAL);
toolbar->RegisterOption(OPTION_SHOW_TREE_REMOTE);
toolbar->RegisterOption(OPTION_MESSAGELOG_POSITION);
toolbar->ToggleTool(XRCID("ID_TOOLBAR_FILTER"), CFilterManager::HasActiveFilters());
toolbar->ToggleTool(XRCID("ID_TOOLBAR_LOGVIEW"), COptions::Get()->GetOptionVal(OPTION_SHOW_MESSAGELOG) != 0);
toolbar->ToggleTool(XRCID("ID_TOOLBAR_QUEUEVIEW"), COptions::Get()->GetOptionVal(OPTION_SHOW_QUEUE) != 0);
toolbar->ToggleTool(XRCID("ID_TOOLBAR_LOCALTREEVIEW"), COptions::Get()->GetOptionVal(OPTION_SHOW_TREE_LOCAL) != 0);
toolbar->ToggleTool(XRCID("ID_TOOLBAR_REMOTETREEVIEW"), COptions::Get()->GetOptionVal(OPTION_SHOW_TREE_REMOTE) != 0);
pMainFrame->SetToolBar(toolbar);
toolbar->Realize();
if (COptions::Get()->GetOptionVal(OPTION_MESSAGELOG_POSITION) == 2) {
toolbar->HideTool(XRCID("ID_TOOLBAR_LOGVIEW"));
}
return toolbar;
}
示例15: BPopUpMenu
void
CAssemblyWindow::AddToolBar()
{
BMessage *message;
// make the pop up menu for 'Select' tool
BPopUpMenu *selectMenu = new BPopUpMenu("", false, false);
selectMenu->SetFont(be_plain_font);
message = new BMessage(SELECT_MODE_CHANGED);
message->AddInt32("mev:mode", CEventEditor::RECTANGLE_SELECTION);
selectMenu->AddItem(new CIconMenuItem("Rectangle", message,
ResourceUtils::LoadImage("ArrowTool")));
message = new BMessage(*message);
message->ReplaceInt32("mev:mode", CEventEditor::LASSO_SELECTION);
selectMenu->AddItem(new CIconMenuItem("Lasso", message,
ResourceUtils::LoadImage("LassoTool")));
selectMenu->SetTargetForItems(this);
// make the pop up menu for 'Create' tool
BPopUpMenu *createMenu = new BPopUpMenu("", false, false);
createMenu->SetFont(be_plain_font);
message = new BMessage(NEW_EVENT_TYPE_CHANGED);
message->AddInt32("type", EvtType_Count);
createMenu->AddItem(new CIconMenuItem("Default", message,
ResourceUtils::LoadImage("PencilTool")));
createMenu->AddSeparatorItem();
message = new BMessage(*message);
message->ReplaceInt32("type", EvtType_Tempo);
createMenu->AddItem(new CIconMenuItem("Tempo", message,
ResourceUtils::LoadImage("MetroTool")));
message = new BMessage(*message);
message->ReplaceInt32("type", EvtType_TimeSig);
createMenu->AddItem(new CIconMenuItem("Time Signature", message,
ResourceUtils::LoadImage("TimeSigTool")));
message = new BMessage(*message);
message->ReplaceInt32("type", EvtType_Repeat);
createMenu->AddItem(new CIconMenuItem("Repeat", message,
ResourceUtils::LoadImage("RepeatTool")));
message = new BMessage(*message);
message->ReplaceInt32("type", EvtType_End);
createMenu->AddItem(new CIconMenuItem("Part End", message,
ResourceUtils::LoadImage("EndTool")));
createMenu->SetTargetForItems(this);
BRect rect(Bounds());
if (KeyMenuBar())
rect.top = KeyMenuBar()->Frame().bottom + 1.0;
rect.right += 1.0;
// add the tool bar
CToolBar *toolBar = new CToolBar(rect, "General");
CTool *tool;
toolBar->AddTool(tool = new CBitmapTool("Snap To Grid",
ResourceUtils::LoadImage("GridTool"),
new BMessage(CEventEditor::TOOL_GRID)));
tool->SetValue(B_CONTROL_ON);
toolBar->AddSeparator();
toolBar->AddTool(tool = new CMenuTool("Select",
ResourceUtils::LoadImage("ArrowTool"),
selectMenu,
new BMessage(CEventEditor::TOOL_SELECT)));
tool->SetValue(B_CONTROL_ON);
toolBar->AddTool(new CMenuTool("Create", ResourceUtils::LoadImage("PencilTool"),
createMenu, new BMessage(CEventEditor::TOOL_CREATE)));
toolBar->AddTool(tool = new CBitmapTool("Eraser",
ResourceUtils::LoadImage("EraserTool"),
new BMessage(CEventEditor::TOOL_ERASE)));
toolBar->MakeRadioGroup("Select", "Eraser", true);
SetToolBar(toolBar);
}