本文整理汇总了C++中zltoolbar::ItemPtr::type方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemPtr::type方法的具体用法?C++ ItemPtr::type怎么用?C++ ItemPtr::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zltoolbar::ItemPtr
的用法示例。
在下文中一共展示了ItemPtr::type方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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()
);
}
}
示例2: 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));
}
}
示例3: 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;
}
}
示例4: 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;
//}
}
示例5: 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;
}
}
示例6: 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;
}
}
示例7: 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;
}
}
}
示例8: toolbar
void ZLWin32ApplicationWindow::setToolbarItemState(ZLToolbar::ItemPtr item, bool visible, bool enabled) {
Toolbar &tb = toolbar(type(*item));
if (tb.hwnd == 0) {
return;
}
const ZLToolbar::Item::Type type = item->type();
switch (type) {
case ZLToolbar::Item::TEXT_FIELD:
case ZLToolbar::Item::COMBO_BOX:
{
const ZLToolbar::ParameterItem &textFieldItem = (const ZLToolbar::ParameterItem&)*item;
HWND handle = myParameters[tb.ParameterCodeById[textFieldItem.actionId()]];
if (handle != 0) {
const int idCommand = tb.ParameterCodeById[textFieldItem.actionId()];
PostMessage(tb.hwnd, TB_SETSTATE, idCommand, visible ? 0 : TBSTATE_HIDDEN);
ShowWindow(handle, visible ? SW_SHOW : SW_HIDE);
PostMessage(handle, EM_SETREADONLY, !enabled, 0);
}
break;
}
case ZLToolbar::Item::PLAIN_BUTTON:
case ZLToolbar::Item::MENU_BUTTON:
case ZLToolbar::Item::TOGGLE_BUTTON:
{
ZLToolbar::AbstractButtonItem &buttonItem = (ZLToolbar::AbstractButtonItem&)*item;
LPARAM state = (visible ? 0 : TBSTATE_HIDDEN) | (enabled ? TBSTATE_ENABLED : 0);
const int idCommand = tb.ActionCodeById[buttonItem.actionId()];
PostMessage(tb.hwnd, TB_SETSTATE, (WPARAM)idCommand, state);
break;
}
case ZLToolbar::Item::SEPARATOR:
PostMessage(tb.hwnd, TB_SETSTATE, tb.SeparatorNumbers[item], visible ? 0 : TBSTATE_HIDDEN);
break;
}
}
示例9: 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;
}
}
}