本文整理汇总了C++中zltoolbar::ItemPtr类的典型用法代码示例。如果您正苦于以下问题:C++ ItemPtr类的具体用法?C++ ItemPtr怎么用?C++ ItemPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ItemPtr类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: refreshToolbar
void ZLApplicationWindow::refreshToolbar() {
const ZLToolbar::ItemVector &items = application().toolbar().items();
bool canAddSeparator = false;
ZLToolbar::ItemPtr lastSeparator = 0;
for (ZLToolbar::ItemVector::const_iterator it = items.begin(); it != items.end(); ++it) {
if ((*it)->isSeparator()) {
if (canAddSeparator) {
lastSeparator = *it;
canAddSeparator = false;
} else {
setToolbarItemState(*it, false, true);
}
} else {
ZLToolbar::ButtonItem &button = (ZLToolbar::ButtonItem&)**it;
const std::string &id = button.actionId();
const bool visible = application().isActionVisible(id);
const bool enabled = application().isActionEnabled(id);
if (visible) {
if (!lastSeparator.isNull()) {
setToolbarItemState(lastSeparator, true, true);
lastSeparator = 0;
}
canAddSeparator = true;
}
setToolbarItemState(*it, visible, enabled);
}
}
if (!lastSeparator.isNull()) {
setToolbarItemState(lastSeparator, false, true);
}
}
开发者ID:euroelessar,项目名称:FBReader,代码行数:33,代码来源:ZLApplicationWindow.cpp
示例2: toolbar
void ZLWin32ApplicationWindow::runPopup(const NMTOOLBAR &nmToolbar) {
Toolbar &tb = toolbar(isFullscreen() ? FULLSCREEN_TOOLBAR : WINDOW_TOOLBAR);
if (tb.hwnd == 0) {
return;
}
ZLToolbar::ItemPtr item = tb.TBItemByActionCode[nmToolbar.iItem];
if (!item.isNull()) {
const ZLToolbar::MenuButtonItem &button =
(const ZLToolbar::MenuButtonItem&)*item;
shared_ptr<ZLPopupData> popupData = button.popupData();
if (!popupData.isNull()) {
const int count = popupData->count();
if (count != 0) {
myPopupMenu = new ZLWin32PopupMenu(myMainWindow);
for (int i = 0; i < count; ++i) {
myPopupMenu->addItem(popupData->text(i), 0, true);
}
POINT p;
p.x = nmToolbar.rcButton.left;
p.y = nmToolbar.rcButton.bottom + 6;
ClientToScreen(myMainWindow, &p);
int code = myPopupMenu->run(p);
if (code > 0) {
popupData->run(code - 1);
}
myPopupMenu.reset();
}
}
}
}
开发者ID:justsoso8,项目名称:fbreader,代码行数:30,代码来源:ZLWin32ApplicationWindow.cpp
示例3: SendMessage
void ZLWin32ApplicationWindow::processChevron(const NMREBARCHEVRON &chevron) {
RECT toolbarRect;
GetClientRect(myWindowToolbar.hwnd, &toolbarRect);
HIMAGELIST imageList = (HIMAGELIST)SendMessage(myWindowToolbar.hwnd, TB_GETIMAGELIST, 0, 0);
int imageIndex = 0;
const int len = SendMessage(myWindowToolbar.hwnd, TB_BUTTONCOUNT, 0, 0);
int index = 0;
for (; index < len; ++index) {
TBBUTTON info;
SendMessage(myWindowToolbar.hwnd, TB_GETBUTTON, index, (LPARAM)&info);
if ((info.fsState & TBSTATE_HIDDEN) == 0) {
RECT rect;
SendMessage(myWindowToolbar.hwnd, TB_GETITEMRECT, index, (LPARAM)&rect);
if (rect.right > toolbarRect.right) {
break;
}
}
if (info.idCommand > -100) {
++imageIndex;
}
}
myPopupMenu = new ZLWin32PopupMenu(myMainWindow);
for (; index < len; ++index) {
TBBUTTON info;
SendMessage(myWindowToolbar.hwnd, TB_GETBUTTON, index, (LPARAM)&info);
if ((info.fsState & TBSTATE_HIDDEN) == 0) {
ZLToolbar::ItemPtr item = myWindowToolbar.TBItemByActionCode[info.idCommand];
if (!item.isNull()) {
const ZLToolbar::AbstractButtonItem &button =
(const ZLToolbar::AbstractButtonItem&)*item;
myPopupMenu->addItem(
" " + button.tooltip(),
ImageList_GetIcon(imageList, imageIndex, ILD_NORMAL),
info.fsState & TBSTATE_ENABLED,
info.idCommand
);
} else if (info.idCommand >= -200) /* is a separator */ {
myPopupMenu->addSeparator();
}
}
if (info.idCommand > -100) {
++imageIndex;
}
}
POINT p;
p.x = chevron.rc.right - 2;
p.y = chevron.rc.bottom;
ClientToScreen(myMainWindow, &p);
onToolbarButtonRelease(myPopupMenu->run(p, true));
myPopupMenu.reset();
}
开发者ID:OpenInkpot-archive,项目名称:fbreader,代码行数:54,代码来源:Toolbar.cpp
示例4: setToolbarItemState
void ZLGtkApplicationWindow::setToolbarItemState(ZLToolbar::ItemPtr item, bool visible, bool enabled) {
std::map<const ZLToolbar::Item*,GtkToolItem*>::const_iterator it = myAbstractToGtk.find(&*item);
if (it == myAbstractToGtk.end()) {
return;
}
GtkToolItem *toolItem = it->second;
gtk_tool_item_set_visible_horizontal(toolItem, visible);
/*
* Not sure, but looks like gtk_widget_set_sensitive(WIDGET, false)
* does something strange if WIDGET is already insensitive.
*/
bool alreadyEnabled =
(GTK_WIDGET_STATE(toolItem) & GTK_STATE_INSENSITIVE) == 0;
if (enabled != alreadyEnabled) {
gtk_widget_set_sensitive(GTK_WIDGET(toolItem), enabled);
}
if (item->type() == ZLToolbar::Item::MENU_BUTTON) {
updatePopupData(
GTK_MENU_TOOL_BUTTON(toolItem),
((ZLToolbar::MenuButtonItem&)*item).popupData()
);
}
}
开发者ID:euroelessar,项目名称:FBReader,代码行数:25,代码来源:ZLGtkApplicationWindow.cpp
示例5: addToolbarItem
void ZLGtkApplicationWindow::addToolbarItem(ZLToolbar::ItemPtr item) {
GtkToolItem *gtkItem = 0;
switch (item->type()) {
case ZLToolbar::Item::TEXT_FIELD:
case ZLToolbar::Item::COMBO_BOX:
{
const ZLToolbar::ParameterItem ¶meterItem = (const ZLToolbar::ParameterItem&)*item;
GtkEntryParameter *parameter =
new GtkEntryParameter(*this, parameterItem);
addVisualParameter(parameterItem.parameterId(), parameter);
gtkItem = parameter->createToolItem();
gtk_tool_item_set_tooltip(gtkItem, myToolbar->tooltips, parameterItem.tooltip().c_str(), 0);
}
break;
case ZLToolbar::Item::PLAIN_BUTTON:
case ZLToolbar::Item::TOGGLE_BUTTON:
case ZLToolbar::Item::MENU_BUTTON:
gtkItem = createGtkToolButton((ZLToolbar::AbstractButtonItem&)*item);
break;
case ZLToolbar::Item::SEPARATOR:
gtkItem = gtk_separator_tool_item_new();
gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(gtkItem), false);
break;
}
if (gtkItem != 0) {
gtk_toolbar_insert(myToolbar, gtkItem, -1);
myAbstractToGtk[&*item] = gtkItem;
myGtkToAbstract[gtkItem] = item;
gtk_widget_show_all(GTK_WIDGET(gtkItem));
}
}
开发者ID:euroelessar,项目名称:FBReader,代码行数:31,代码来源:ZLGtkApplicationWindow.cpp
示例6: setToolbarItemState
void ZLbadaApplicationWindow::setToolbarItemState(ZLToolbar::ItemPtr item, bool visible, bool enabled) {
// AppLog("setToolbarItemState ");
/* QAction *action = myActions[&*item];
if (action != 0) {
action->setEnabled(enabled);
action->setVisible(visible);
}*/
switch (item->type()) {
default:
break;
case ZLToolbar::Item::MENU_BUTTON:
//AppLog("MENU_BUTTON ");
/*{
ZLToolbar::MenuButtonItem &buttonItem = (ZLToolbar::MenuButtonItem&)*item;
shared_ptr<ZLPopupData> data = buttonItem.popupData();
if (!data.isNull() && (data->id() != myPopupIdMap[&buttonItem])) {
myPopupIdMap[&buttonItem] = data->id();
QToolButton *button = myMenuButtons[&buttonItem];
QMenu *menu = button->menu();
menu->clear();
const size_t count = data->count();
for (size_t i = 0; i < count; ++i) {
menu->addAction(new ZLQtRunPopupAction(menu, data, i));
}
}*/
break;
}
}
开发者ID:temper8,项目名称:FBReader-Tizen,代码行数:31,代码来源:ZLbadaApplicationWindow.cpp
示例7: addToolbarItem
void ZLQtApplicationWindow::addToolbarItem(ZLToolbar::ItemPtr item) {
if (item->isSeparator()) {
myToolbarActions[item] = myToolbar->addSeparator();
} else {
ZLToolbar::ButtonItem& buttonItem = (ZLToolbar::ButtonItem&)*item;
QAction *action = getAction(buttonItem.actionId());
ZLQtToolbarButton *button = new ZLQtToolbarButton(buttonItem.iconName(), myToolbar);
button->setToolTip(::qtString(buttonItem.tooltip()));
connect(button, SIGNAL(clicked()), action, SLOT(onActivated()));
myToolbarActions[item] = myToolbar->addWidget(button);
}
}
开发者ID:euroelessar,项目名称:FBReader,代码行数:12,代码来源:ZLQtApplicationWindow.cpp
示例8: addToolbarItem
void ZLbadaApplicationWindow::addToolbarItem(ZLToolbar::ItemPtr item) {
//QToolBar *tb = toolbar(type(*item));
//QAction *action = 0;
AppLog("addToolbarItem ");
switch (item->type()) {
case ZLToolbar::Item::PLAIN_BUTTON:
case ZLToolbar::Item::TOGGLE_BUTTON:
// AppLog("TOGGLE_BUTTON ");//,(ZLToolbar::AbstractButtonItem&)*item.tooltip().c_str());
//action = new ZLQtToolBarAction(this, (ZLToolbar::AbstractButtonItem&)*item);
//tb->addAction(action);
break;
case ZLToolbar::Item::MENU_BUTTON:
{
// AppLog("MENU_BUTTON ");
/*ZLToolbar::MenuButtonItem &buttonItem = (ZLToolbar::MenuButtonItem&)*item;
QToolButton *button = new QToolButton(tb);
button->setFocusPolicy(Qt::NoFocus);
button->setDefaultAction(new ZLQtToolBarAction(this, buttonItem));
button->setMenu(new QMenu(button));
button->setPopupMode(QToolButton::MenuButtonPopup);
action = tb->addWidget(button);
myMenuButtons[&buttonItem] = button;
shared_ptr<ZLPopupData> popupData = buttonItem.popupData();
myPopupIdMap[&buttonItem] =
popupData.isNull() ? (size_t)-1 : (popupData->id() - 1);*/
break;
}
case ZLToolbar::Item::TEXT_FIELD:
case ZLToolbar::Item::SEARCH_FIELD:
{
// AppLog("SEARCH_FIELD ");
/* ZLToolbar::ParameterItem &textFieldItem =
(ZLToolbar::ParameterItem&)*item;
LineEditParameter *para = new LineEditParameter(tb, *this, textFieldItem);
addVisualParameter(textFieldItem.parameterId(), para);
action = para->action();*/
break;
}
case ZLToolbar::Item::SEPARATOR:
// AppLog("SEPARATOR ");
//action = tb->addSeparator();
break;
}
//if (action != 0) {
// myActions[&*item] = action;
//}
}
开发者ID:temper8,项目名称:FBReader-Tizen,代码行数:50,代码来源:ZLbadaApplicationWindow.cpp
示例9: setItemState
void MyMenuBar::setItemState(ZLToolbar::ItemPtr item, bool visible, bool enabled) {
switch (item->type()) {
case ZLToolbar::Item::PLAIN_BUTTON:
case ZLToolbar::Item::TOGGLE_BUTTON:
case ZLToolbar::Item::MENU_BUTTON:
{
ZLToolbar::AbstractButtonItem &button =
(ZLToolbar::AbstractButtonItem&)*item;
const std::string &id = button.actionId();
std::map<std::string,int> ::const_iterator iter = myActionIndices.find(id);
int actionIndex = (iter != myActionIndices.end()) ? iter->second : 0;
if (visible) {
if ((actionIndex == 0) || (idAt(myIndex) != actionIndex)) {
ToolBarButton *tbButton = myButtons[id];
if (actionIndex == 0) {
tbButton = new ToolBarButton(myWindow, button);
myButtons[id] = tbButton;
actionIndex = myActionIndices.size() + 1;
myActionIndices[id] = actionIndex;
}
insertItem(tbButton->pixmap(), tbButton, SLOT(doActionSlot()), 0, actionIndex, myIndex);
}
setItemEnabled(actionIndex, enabled);
++myIndex;
} else {
if ((actionIndex != 0) && (idAt(myIndex) == actionIndex)) {
removeItem(actionIndex);
}
}
break;
}
/*
case ZLToolbar::Item::OPTION_ENTRY:
if (idAt(myIndex) < 10001) {
shared_ptr<ZLOptionEntry> entry = ((ZLToolbar::OptionEntryItem&)*item).entry();
if (entry->isVisible()) {
ZLOptionView *view = createViewByEntry("", "", entry);
view->setVisible(true);
}
} else {
++myIndex;
}
break;
*/
case ZLToolbar::Item::SEPARATOR:
break;
}
}
开发者ID:TodorGrin,项目名称:boox-opensource,代码行数:48,代码来源:ZLQtApplicationWindow.cpp
示例10: addToolbarItem
void ZLQtApplicationWindow::addToolbarItem(ZLToolbar::ItemPtr item) {
switch (item->type()) {
case ZLToolbar::Item::TEXT_FIELD:
myItemToWidgetMap[&*item] = new LineEditParameter(myToolBar, *this, (ZLToolbar::TextFieldItem&)*item);
break;
case ZLToolbar::Item::PLAIN_BUTTON:
case ZLToolbar::Item::MENU_BUTTON:
case ZLToolbar::Item::TOGGLE_BUTTON:
myItemToWidgetMap[&*item] = new ZLQtToolButton(*this, (ZLToolbar::AbstractButtonItem&)*item);
break;
case ZLToolbar::Item::SEPARATOR:
myToolBar->addSeparator();
myItemToWidgetMap[&*item] = (QWidget*)myToolBar->children()->getLast();
break;
}
}
开发者ID:TodorGrin,项目名称:boox-opensource,代码行数:16,代码来源:ZLQtApplicationWindow.cpp
示例11: setToolbarItemState
void ZLQtApplicationWindow::setToolbarItemState(ZLToolbar::ItemPtr item, bool visible, bool enabled) {
QWidget *widget = myItemToWidgetMap[&*item];
if (widget == 0) {
return;
}
widget->setEnabled(enabled);
widget->setShown(visible);
switch (item->type()) {
default:
break;
case ZLToolbar::Item::MENU_BUTTON:
{
ZLToolbar::MenuButtonItem &menuButtonItem = (ZLToolbar::MenuButtonItem&)*item;
shared_ptr<ZLPopupData> data = menuButtonItem.popupData();
if (data && (data->id() != myPopupIdMap[&menuButtonItem])) {
myPopupIdMap[&menuButtonItem] = data->id();
((ZLQtPopupMenu*)((QToolButton*)widget)->popup())->reset(data);
}
break;
}
}
}
开发者ID:TodorGrin,项目名称:boox-opensource,代码行数:23,代码来源:ZLQtApplicationWindow.cpp
示例12: file
void ZLWin32ApplicationWindow::addToolbarItem(ZLToolbar::ItemPtr item) {
if (myRebar == 0) {
createWindowToolbar();
}
Toolbar &tb = toolbar(type(*item));
if (tb.hwnd == 0) {
myFloatingToolbarItems.push_back(item);
return;
}
TBBUTTON button;
button.fsState = TBSTATE_ENABLED;
const ZLToolbar::Item::Type type = item->type();
switch (type) {
case ZLToolbar::Item::TEXT_FIELD:
case ZLToolbar::Item::COMBO_BOX:
{
const ZLToolbar::ParameterItem &textFieldItem = (ZLToolbar::ParameterItem&)*item;
button.idCommand = -200 + tb.ParameterCodeById.size();
tb.ParameterCodeById[textFieldItem.actionId()] = button.idCommand;
button.iBitmap = I_IMAGENONE;
button.fsStyle = TBSTYLE_BUTTON | BTNS_AUTOSIZE | BTNS_SHOWTEXT;
button.fsState = 0;
tb.TBItemByActionCode[button.idCommand] = item;
break;
}
case ZLToolbar::Item::PLAIN_BUTTON:
case ZLToolbar::Item::MENU_BUTTON:
case ZLToolbar::Item::TOGGLE_BUTTON:
{
const ZLToolbar::AbstractButtonItem &buttonItem = (const ZLToolbar::AbstractButtonItem&)*item;
std::string imageFileName = ZLibrary::ApplicationImageDirectory() + ZLibrary::FileNameDelimiter + buttonItem.iconName() + ".ico";
ZLFile file(imageFileName);
ZLUnicodeUtil::Ucs2String wPath;
HICON bitmap = (HICON)LoadImageW(0, ::wchar(::createNTWCHARString(wPath, file.path())), IMAGE_ICON, IconSize, IconSize, LR_LOADFROMFILE);
ImageList_AddIcon((HIMAGELIST)SendMessage(tb.hwnd, TB_GETIMAGELIST, 0, 0), bitmap);
button.iBitmap = tb.ActionCodeById.size();
button.fsStyle = TBSTYLE_BUTTON;
if (type == ZLToolbar::Item::MENU_BUTTON) {
button.fsStyle |= TBSTYLE_DROPDOWN;
} else if (type == ZLToolbar::Item::TOGGLE_BUTTON) {
button.fsStyle |= TBSTYLE_CHECK;
}
const int actionCode = tb.ActionCodeById.size() + 1;
tb.ActionCodeById[buttonItem.actionId()] = actionCode;
button.idCommand = actionCode;
tb.TBItemByActionCode[button.idCommand] = item;
button.dwData = 0;
button.iString = 0;
break;
}
case ZLToolbar::Item::SEPARATOR:
{
button.idCommand = -100 - tb.SeparatorNumbers.size();
tb.SeparatorNumbers[item] = button.idCommand;
button.iBitmap = 6;
button.fsStyle = TBSTYLE_SEP;
break;
}
}
SendMessage(tb.hwnd, TB_ADDBUTTONS, 1, (LPARAM)&button);
switch (type) {
default:
break;
case ZLToolbar::Item::TEXT_FIELD:
case ZLToolbar::Item::COMBO_BOX:
{
const ZLToolbar::ParameterItem &textFieldItem = (ZLToolbar::ParameterItem&)*item;
TBBUTTONINFO buttonInfo;
buttonInfo.cbSize = sizeof(TBBUTTONINFO);
buttonInfo.dwMask = TBIF_SIZE;
buttonInfo.cx = 10 + 8 * textFieldItem.maxWidth();
if (type == ZLToolbar::Item::COMBO_BOX) {
buttonInfo.cx += 15;
}
SendMessage(tb.hwnd, TB_SETBUTTONINFO, button.idCommand, (LPARAM)&buttonInfo);
TextEditParameter *parameter = new TextEditParameter(application(), myMainWindow, tb.hwnd, button.idCommand, textFieldItem);
addVisualParameter(textFieldItem.parameterId(), parameter);
myParameters[button.idCommand] = parameter->handle();
break;
}
}
}
开发者ID:justsoso8,项目名称:fbreader,代码行数:88,代码来源:ZLWin32ApplicationWindow.cpp
示例13: refreshToolbar
void ZLApplicationWindow::refreshToolbar(ToolbarType type) {
const ZLToolbar::ItemVector &items = application().toolbar(type).items();
bool canAddSeparator = false;
ZLToolbar::ItemPtr lastSeparator = 0;
for (ZLToolbar::ItemVector::const_iterator it = items.begin(); it != items.end(); ++it) {
switch ((*it)->type()) {
case ZLToolbar::Item::TEXT_FIELD:
case ZLToolbar::Item::COMBO_BOX:
case ZLToolbar::Item::SEARCH_FIELD:
case ZLToolbar::Item::PLAIN_BUTTON:
case ZLToolbar::Item::MENU_BUTTON:
{
ZLToolbar::ActionItem &button = (ZLToolbar::ActionItem&)**it;
const std::string &id = button.actionId();
const bool visible = application().isActionVisible(id);
const bool enabled = application().isActionEnabled(id);
if (visible) {
if (!lastSeparator.isNull()) {
setToolbarItemState(lastSeparator, true, true);
lastSeparator = 0;
}
canAddSeparator = true;
}
setToolbarItemState(*it, visible, enabled);
}
break;
case ZLToolbar::Item::TOGGLE_BUTTON:
{
ZLToolbar::ToggleButtonItem &button = (ZLToolbar::ToggleButtonItem&)**it;
const std::string &id = button.actionId();
const bool visible = application().isActionVisible(id);
const bool enabled = application().isActionEnabled(id);
if (visible) {
if (!lastSeparator.isNull()) {
setToolbarItemState(lastSeparator, true, true);
lastSeparator = 0;
}
canAddSeparator = true;
}
/*
if (!enabled && button.isPressed()) {
button.buttonGroup().press(0);
//application().doAction(group->UnselectAllButtonsActionId);
myToggleButtonLock = true;
setToggleButtonState(button);
myToggleButtonLock = false;
}
*/
setToolbarItemState(*it, visible, enabled);
setToggleButtonState(button);
}
break;
case ZLToolbar::Item::SEPARATOR:
if (canAddSeparator) {
lastSeparator = *it;
canAddSeparator = false;
} else {
setToolbarItemState(*it, false, true);
}
break;
case ZLToolbar::Item::FILL_SEPARATOR:
if (canAddSeparator) {
lastSeparator = *it;
canAddSeparator = false;
} else if (lastSeparator != 0) {
setToolbarItemState(lastSeparator, false, true);
lastSeparator = *it;
} else {
setToolbarItemState(*it, false, true);
}
break;
}
}
if (!lastSeparator.isNull()) {
setToolbarItemState(lastSeparator, false, true);
}
}
开发者ID:ALEXGUOQ,项目名称:FBReader,代码行数:81,代码来源:ZLApplicationWindow.cpp
注:本文中的zltoolbar::ItemPtr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论