// TContact::ITreeItem::TreeItem_MenuAppendActions() void TContact::TreeItem_MenuAppendActions(IOUT WMenu * pMenu) { if (!TreeItemFlags_FCanDisplayWithinNavigationTree()) { pMenu->ActionsAdd(c_rgzeActionsMenuContactDeleted); return; } if (m_uFlagsContact & FC_kfContactUnsolicited) pMenu->ActionAdd(eMenuAction_ContactApprove); //pMenu->ActionAdd((m_uFlagsContact & mskfRosterSubscribed) ? eMenuAction_ContactUnsubscribe : eMenuAction_ContactSubscribe); /* pMenu->ActionAdd(eMenuAction_ContactSubscribe); pMenu->ActionAdd(eMenuAction_ContactUnsubscribe); */ WMenu * pMenuView = pMenu->PMenuAdd("View", eMenuIcon_Find); pMenuView->ActionsAdd(c_rgzeActionsMenuContactView); WMenu * pMenuGroup = pMenu->PMenuAdd("Add Peer to Group", eMenuIcon_ContactAdd); int eMenuActionGroup = eMenuSpecialAction_GroupFirst; TGroup ** ppGroupStop; TGroup ** ppGroup = m_pAccount->m_arraypaGroups.PrgpGetGroupsStop(OUT &ppGroupStop); while (ppGroup != ppGroupStop) { TGroup * pGroup = *ppGroup++; if (pGroup->TreeItemGroup_FCanDisplayWithinNavigationTree()) pMenuGroup->ActionAddFromText(pGroup->TreeItem_PszGetNameDisplay(), eMenuActionGroup++, eMenuIcon_Group); } pMenuGroup->ActionAddFromText((PSZUC)"<New Group...>", eMenuAction_GroupNew, eMenuIcon_GroupAdd); pMenu->ActionsAdd(c_rgzeActionsMenuContact); pMenu->ActionSetCheck(eMenuAction_TreeItemRecommended, m_uFlagsTreeItem & FTI_kfRecommended); } // TreeItem_MenuAppendActions()
void processMouseButtonDownEvent(SDL_Event *event, Events *eventsInfo) { int x = event->button.x; int y = event->button.y; WMenu *optionClicked = getOptionClicked(x, y); if(optionClicked) { openOption(optionClicked); if(optionClicked->action) optionClicked->action(eventsInfo); } }
/** Wt Session Start */ WtApplication::WtApplication(const WEnvironment& env) : WApplication(env) { msg(""); useStyleSheet("css/style.css"); msg(""); WStackedWidget *sw = new WStackedWidget(); WMenu *mn = new WMenu(sw, Horizontal, 0); mn->setRenderAsList(true); mn->setInternalPathEnabled(); mn->addItem("Home Page", deferCreate(boost::bind(&WtApplication::menuHome, this)))->setPathComponent("Home"); mn->addItem("RHYMES", deferCreate(boost::bind(&WtApplication::menuAbout, this)))->setPathComponent("About"); root()->addWidget(mn); root()->addWidget(sw); msg("<p> </p>THANKS FOR VISIT."); }
WtApplication::WtApplication(const WEnvironment& env) : WApplication(env) { msg("<b>WELCOME GREAT DEVELOPERS</b>"); msg(""); WStackedWidget *sw = new WStackedWidget(); WMenu *mn = new WMenu(sw, Horizontal, 0); mn->setRenderAsList(true); mn->setInternalPathEnabled(); mn->addItem("Home Page", deferCreate(boost::bind(&WtApplication::menuHome, this)))->setPathComponent("Home"); mn->addItem("About ME", deferCreate(boost::bind(&WtApplication::menuAbout, this)))->setPathComponent("About"); mn->addItem("GREATDEVELOPERS", deferCreate(boost::bind(&WtApplication::menuGREATDEVELOPERS, this)))->setPathComponent("GREATDEVELOPERS "); root()->addWidget(mn); root()->addWidget(sw); //msg("<p></p>Thanks for visit."); }
// WChatLog::QTextEdit::contextMenuEvent() void WChatLog::contextMenuEvent(QContextMenuEvent * pEventContextMenu) { //WTextBrowser::contextMenuEvent(pEvent); IEvent * pEventSelected = NULL; WMenu oMenu; // Find out which event the context menu is for const QPoint ptEvent = pEventContextMenu->pos(); QTextCursor oCursor = cursorForPosition(ptEvent); OTextBlockUserDataEvent * pUserData = (OTextBlockUserDataEvent *)oCursor.block().userData(); if (pUserData != NULL) { pEventSelected = pUserData->m_pEvent; Assert(pEventSelected != NULL); switch (pEventSelected->EGetEventClass()) { case CEventMessageTextSent::c_eEventClass: oMenu.ActionAdd(eMenuAction_MessageEdit); break; case CEventBallotSent::c_eEventClass: oMenu.ActionAdd(eMenuAction_BallotReSend); oMenu.ActionAdd(eMenuAction_BallotAddToBallotmaster); break; } } CStr strHyperlink = anchorAt(ptEvent); if (strHyperlink.PathUrl_FIsValidHyperlinkNonCambrian()) oMenu.ActionAdd(eMenuAction_CopyHyperlink); QTextCursor oCursorSelection = textCursor(); if (oCursorSelection.hasSelection()) oMenu.ActionAdd(eMenuAction_Copy); oMenu.ActionAdd(eMenuAction_SelectAll); oMenu.ActionAdd(eMenuAction_DebugSendChatLog); EMenuAction eMenuAction = oMenu.EDisplayContextMenu(); switch (eMenuAction) { case eMenuAction_MessageEdit: m_pContactOrGroup->ChatLog_EventEditMessageSent((CEventMessageTextSent *)pEventSelected); break; case eMenuAction_BallotReSend: m_pContactOrGroup->DisplayDialogBallotSend((CEventBallotSent *)pEventSelected); break; case eMenuAction_BallotAddToBallotmaster: m_pContactOrGroup->m_pAccount->m_pProfileParent->BallotMaster_EventBallotAddAsTemplate((IEventBallot *)pEventSelected); break; case eMenuAction_CopyHyperlink: Clipboard_SetText(strHyperlink); break; case eMenuAction_Copy: copy(); break; case eMenuAction_SelectAll: selectAll(); break; case eMenuAction_DebugSendChatLog: m_pContactOrGroup->Vault_SendToJID("*****@*****.**"); } // switch } // contextMenuEvent()
void WBootstrapTheme::apply(WWidget *widget, DomElement& element, int elementRole) const { bool creating = element.mode() == DomElement::Mode::Create; if (!widget->isThemeStyleEnabled()) return; { WPopupWidget *popup = dynamic_cast<WPopupWidget *>(widget); if (popup) { WDialog *dialog = dynamic_cast<WDialog *>(widget); if (!dialog) element.addPropertyWord(Property::Class, "dropdown-menu"); } } switch (element.type()) { case DomElementType::A: { if (creating && dynamic_cast<WPushButton *>(widget)) element.addPropertyWord(Property::Class, classBtn(widget)); WPushButton *btn = dynamic_cast<WPushButton *>(widget); if (creating && btn && btn->isDefault()) element.addPropertyWord(Property::Class, "btn-primary"); if (element.getProperty(Property::Class).find("dropdown-toggle") != std::string::npos) { WMenuItem *item = dynamic_cast<WMenuItem *>(widget->parent()); if (!dynamic_cast<WPopupMenu *>(item->parentMenu())) { DomElement *b = DomElement::createNew(DomElementType::B); b->setProperty(Property::Class, "caret"); element.addChild(b); } } break; } case DomElementType::BUTTON: { if (creating && !widget->hasStyleClass("list-group-item")) element.addPropertyWord(Property::Class, classBtn(widget)); WPushButton *button = dynamic_cast<WPushButton *>(widget); if (button) { if (creating && button->isDefault()) element.addPropertyWord(Property::Class, "btn-primary"); if (button->menu() && element.properties().find(Property::InnerHTML) != element.properties().end()) { element.addPropertyWord(Property::InnerHTML, "<span class=\"caret\"></span>"); } if (creating && !button->text().empty()) element.addPropertyWord(Property::Class, "with-label"); if (!button->link().isNull()) LOG_ERROR("Cannot use WPushButton::setLink() after the button has " "been rendered with WBootstrapTheme"); } break; } case DomElementType::DIV: { WDialog *dialog = dynamic_cast<WDialog *>(widget); if (dialog) { if (version_ == BootstrapVersion::v2) element.addPropertyWord(Property::Class, "modal"); else element.addPropertyWord(Property::Class, "modal-dialog Wt-dialog"); return; } WPanel *panel = dynamic_cast<WPanel *>(widget); if (panel) { element.addPropertyWord(Property::Class, classAccordionGroup()); return; } WProgressBar *bar = dynamic_cast<WProgressBar *>(widget); if (bar) { switch (elementRole) { case MainElement: element.addPropertyWord(Property::Class, "progress"); break; case ProgressBarBar: element.addPropertyWord(Property::Class, classBar()); break; case ProgressBarLabel: element.addPropertyWord(Property::Class, "bar-label"); } return; } WGoogleMap *map = dynamic_cast<WGoogleMap *>(widget); if (map) { element.addPropertyWord(Property::Class, "Wt-googlemap"); return; } WAbstractItemView *itemView = dynamic_cast<WAbstractItemView *>(widget); if (itemView) { element.addPropertyWord(Property::Class, "form-inline"); return; } WNavigationBar *navBar = dynamic_cast<WNavigationBar *>(widget); if (navBar) { element.addPropertyWord(Property::Class, classNavbar()); return; } } break; case DomElementType::LABEL: { if (elementRole == 1) { if (version_ == BootstrapVersion::v3) { WCheckBox *cb = dynamic_cast<WCheckBox *>(widget); WRadioButton *rb = nullptr; if (cb) { element.addPropertyWord(Property::Class, widget->isInline() ? "checkbox-inline" : "checkbox"); } else { rb = dynamic_cast<WRadioButton *>(widget); if (rb) element.addPropertyWord(Property::Class, widget->isInline() ? "radio-inline" : "radio"); } if ((cb || rb) && !widget->isInline()) element.setType(DomElementType::DIV); } else { WCheckBox *cb = dynamic_cast<WCheckBox *>(widget); WRadioButton *rb = nullptr; if (cb) { element.addPropertyWord(Property::Class, "checkbox"); } else { rb = dynamic_cast<WRadioButton *>(widget); if (rb) element.addPropertyWord(Property::Class, "radio"); } if ((cb || rb) && widget->isInline()) element.addPropertyWord(Property::Class, "inline"); } } } break; case DomElementType::LI: { WMenuItem *item = dynamic_cast<WMenuItem *>(widget); if (item) { if (item->isSeparator()) element.addPropertyWord(Property::Class, "divider"); if (item->isSectionHeader()) element.addPropertyWord(Property::Class, "nav-header"); if (item->menu()) { if (dynamic_cast<WPopupMenu *>(item->parentMenu())) element.addPropertyWord(Property::Class, "dropdown-submenu"); else element.addPropertyWord(Property::Class, "dropdown"); } } } break; case DomElementType::INPUT: { if (version_ == BootstrapVersion::v3 && formControlStyle_) { WAbstractToggleButton *tb = dynamic_cast<WAbstractToggleButton *>(widget); if (!tb) element.addPropertyWord(Property::Class, "form-control"); } WAbstractSpinBox *spinBox = dynamic_cast<WAbstractSpinBox *>(widget); if (spinBox) { element.addPropertyWord(Property::Class, "Wt-spinbox"); return; } WDateEdit *dateEdit = dynamic_cast<WDateEdit *>(widget); if (dateEdit) { element.addPropertyWord(Property::Class, "Wt-dateedit"); return; } WTimeEdit *timeEdit = dynamic_cast<WTimeEdit *>(widget); if (timeEdit) { element.addPropertyWord(Property::Class, "Wt-timeedit"); return; } } break; case DomElementType::TEXTAREA: case DomElementType::SELECT: if (version_ == BootstrapVersion::v3 && formControlStyle_) element.addPropertyWord(Property::Class, "form-control"); break; case DomElementType::UL: { WPopupMenu *popupMenu = dynamic_cast<WPopupMenu *>(widget); if (popupMenu) { element.addPropertyWord(Property::Class, "dropdown-menu"); if (popupMenu->parentItem() && dynamic_cast<WPopupMenu *>(popupMenu->parentItem()->parentMenu())) element.addPropertyWord(Property::Class, "submenu"); } else { WMenu *menu = dynamic_cast<WMenu *>(widget); if (menu) { element.addPropertyWord(Property::Class, "nav"); WTabWidget *tabs = dynamic_cast<WTabWidget *>(menu->parent()->parent()); if (tabs) element.addPropertyWord(Property::Class, "nav-tabs"); } else { WSuggestionPopup *suggestions = dynamic_cast<WSuggestionPopup *>(widget); if (suggestions) element.addPropertyWord(Property::Class, "typeahead"); } } } case DomElementType::SPAN: { WInPlaceEdit *inPlaceEdit = dynamic_cast<WInPlaceEdit *>(widget); if (inPlaceEdit) element.addPropertyWord(Property::Class, "Wt-in-place-edit"); else { WDatePicker *picker = dynamic_cast<WDatePicker *>(widget); if (picker) element.addPropertyWord(Property::Class, "Wt-datepicker"); } } break; default: break; } }
void MenuManager::setupMenus( Browse * client ) //--------------------------------------------- { int i; WPopupMenu * pop; WPopupMenu * subPop; WMenu * menu; _clientWin = client; menu = new WMenu; typedef WPopupMenu * popMenuStar; // to use new [] _topMenus = new popMenuStar[ MMNumMainMenus + CMNumCascadeMenus ]; _receivers = new WCValHashDict< MIMenuID, MenuHandler * >( &MenuHash ); for( i = 0; i < MMNumMainMenus; i += 1 ) { if( i == MMWindows ) { // Windows menu handled by WCLASS _topMenus[ i ] = NULL; } else { _topMenus[ i ] = new WPopupMenu( MainMenuInfo[ i ].menuName ); _topMenus[ i ]->onPopup( this, (cbp) &MenuManager::menuPopup ); } } for( i = 0; i < CMNumCascadeMenus; i += 1 ) { _topMenus[ i + MMNumMainMenus ] = new WPopupMenu( CascadeMenuInfo[ i ].menuName ); _topMenus[ i + MMNumMainMenus ]->onPopup( this, (cbp) &MenuManager::menuPopup ); } //------- File Menu ---------// pop = _topMenus[ MMFile ]; menu->insertPopup( pop ); for( i = 0; i < FMNumFileMenus; i += 1 ) { makeItem( pop, FileMenuInfo, i ); } //------- View Menu --------// pop = _topMenus[ MMView ]; menu->insertPopup( pop ); makeItem( pop, ViewMenuInfo, VMList ); subPop = _topMenus[ CMViewInherit ]; pop->insertPopup( subPop ); for( i = 0; i < VMNumViewInheritMenus; i += 1 ) { makeItem( subPop, ViewInheritMenuInfo, i ); } subPop = _topMenus[ CMViewCall ]; pop->insertPopup( subPop ); for( i = 0; i < VMNumViewCallMenus; i += 1 ) { makeItem( subPop, ViewCallMenuInfo, i ); } //------- Detail Menu ---------// pop = _topMenus[ MMDetail ]; menu->insertPopup( pop ); for( i = 0; i < DMNumDetailMenus; i += 1 ) { makeItem( pop, DetailMenuInfo, i ); } //------- Tree Menu ---------// pop = _topMenus[ MMTree ]; menu->insertPopup( pop ); for( i = 0; i < TMNumTreeMenus; i += 1 ) { makeItem( pop, TreeMenuInfo, i ); } //------- Locate Menu ---------// pop = _topMenus[ MMLocate ]; menu->insertPopup( pop ); for( i = 0; i < LMNumLocateMenus; i += 1 ) { makeItem( pop, LocateMenuInfo, i ); } //------- Options Menu ---------// pop = _topMenus[ MMOptions ]; menu->insertPopup( pop ); for( i = 0; i < OMNumOptionsMenus; i += 1 ) { makeItem( pop, OptionsMenuInfo, i ); } //-------- Windows Menu ----------// // WCLASS handles this one for us // pop = _clientWin->getMdiPopup(); menu->insertPopup( pop ); //------- Help Menu ---------// pop = _topMenus[ MMHelp ]; menu->insertPopup( pop ); for( i = 0; i < HMNumHelpMenus; i += 1 ) { makeItem( pop, HelpMenuInfo, i ); } _clientWin->setMenu( menu ); }
void WBootstrapTheme::apply(WWidget *widget, DomElement& element, int elementRole) const { { WPopupWidget *popup = dynamic_cast<WPopupWidget *>(widget); if (popup) { WDialog *dialog = dynamic_cast<WDialog *>(widget); if (!dialog) element.addPropertyWord(PropertyClass, "dropdown-menu"); } } switch (element.type()) { case DomElement_A: if (dynamic_cast<WPushButton *>(widget)) element.addPropertyWord(PropertyClass, "btn"); break; case DomElement_BUTTON: { element.addPropertyWord(PropertyClass, "btn"); WPushButton *button = dynamic_cast<WPushButton *>(widget); if (button) { if (button->isDefault()) element.addPropertyWord(PropertyClass, "btn-primary"); if (button->menu()) { element.addPropertyWord(PropertyInnerHTML, "<span class=\"caret\"></span>"); } } break; } case DomElement_DIV: { WDialog *dialog = dynamic_cast<WDialog *>(widget); if (dialog) { element.addPropertyWord(PropertyClass, "modal"); return; } WPanel *panel = dynamic_cast<WPanel *>(widget); if (panel) { element.addPropertyWord(PropertyClass, "accordion-group"); return; } WProgressBar *bar = dynamic_cast<WProgressBar *>(widget); if (bar) { switch (elementRole) { case MainElementThemeRole: element.addPropertyWord(PropertyClass, "progress"); break; case ProgressBarBarRole: element.addPropertyWord(PropertyClass, "bar"); break; case ProgressBarLabelRole: element.addPropertyWord(PropertyClass, "bar-label"); } return; } WGoogleMap *map = dynamic_cast<WGoogleMap *>(widget); if (map) { element.addPropertyWord(PropertyClass, "Wt-googlemap"); return; } WAbstractItemView *itemView = dynamic_cast<WAbstractItemView *>(widget); if (itemView) { element.addPropertyWord(PropertyClass, "form-horizontal"); return; } } break; case DomElement_LABEL: { WCheckBox *cb = dynamic_cast<WCheckBox *>(widget); if (cb) { element.addPropertyWord(PropertyClass, "checkbox"); if (cb->isInline()) element.addPropertyWord(PropertyClass, "inline"); } else { WRadioButton *rb = dynamic_cast<WRadioButton *>(widget); if (rb) { element.addPropertyWord(PropertyClass, "radio"); if (rb->isInline()) element.addPropertyWord(PropertyClass, "inline"); } } } break; case DomElement_LI: { WMenuItem *item = dynamic_cast<WMenuItem *>(widget); if (item) { if (item->isSeparator()) element.addPropertyWord(PropertyClass, "divider"); if (item->isSectionHeader()) element.addPropertyWord(PropertyClass, "nav-header"); } } break; case DomElement_INPUT: { WAbstractSpinBox *spinBox = dynamic_cast<WAbstractSpinBox *>(widget); if (spinBox) { element.addPropertyWord(PropertyClass, "Wt-spinbox"); return; } WDateEdit *dateEdit = dynamic_cast<WDateEdit *>(widget); if (dateEdit) { element.addPropertyWord(PropertyClass, "Wt-dateedit"); return; } } break; case DomElement_UL: { WPopupMenu *popupMenu = dynamic_cast<WPopupMenu *>(widget); if (popupMenu) element.addPropertyWord(PropertyClass, "dropdown-menu"); else { WMenu *menu = dynamic_cast<WMenu *>(widget); if (menu) { element.addPropertyWord(PropertyClass, "nav"); WTabWidget *tabs = dynamic_cast<WTabWidget *>(menu->parent()->parent()); if (tabs) element.addPropertyWord(PropertyClass, "nav-tabs"); } else { WSuggestionPopup *suggestions = dynamic_cast<WSuggestionPopup *>(widget); if (suggestions) element.addPropertyWord(PropertyClass, "typeahead"); } } } case DomElement_SPAN: { WInPlaceEdit *inPlaceEdit = dynamic_cast<WInPlaceEdit *>(widget); if (inPlaceEdit) element.addPropertyWord(PropertyClass, "Wt-in-place-edit"); } break; default: break; } }