void AstadeView::contextMenuRequested( QAbstractItemModel* model, const QModelIndex& requestedIndex, const QPoint& pos ) { // Expect that the Astade data model is the current model or the source model (if it is a proxy model) // Try to find it.. AstadeDataModel* astade_model = obtainAstadeModelForModel( model ); QModelIndex requested_source_index = convertProxyModelIndexToAstadeDataModelIndex( model, requestedIndex ); if ( !astade_model ) { qWarning() << "Unable to access Astade data model. It may be hidden behind a proxy model. No context menu access is possible!"; return; } Element* requested_element = astade_model->elementForIndex( requested_source_index ); Q_ASSERT( requested_element ); QList<QAction* > supported_actions = requested_element->supportedActions(); if ( supported_actions.isEmpty() ) return; QMenu context_menu( tr( "Context for Element" ), this ); context_menu.addActions( supported_actions ); context_menu.exec( pos ); // Delete Actions foreach( QAction* action, supported_actions ) { delete action; } }
/* Callback for button press in the directory tree area */ static int dirtree_select_cb( GtkWidget *ctree_w, GdkEventButton *ev_button ) { GNode *dnode; int row; /* If About presentation is up, end it */ about( ABOUT_END ); if (globals.fsv_mode == FSV_SPLASH) return FALSE; gtk_clist_get_selection_info( GTK_CLIST(ctree_w), ev_button->x, ev_button->y, &row, NULL ); if (row < 0) return FALSE; dnode = (GNode *)gtk_clist_get_row_data( GTK_CLIST(ctree_w), row ); if (dnode == NULL) return FALSE; /* A single-click from button 1 highlights the node, shows the * name, and updates the file list if necessary. (and also selects * the row, but GTK+ does that automatically for us) */ if ((ev_button->button == 1) && (ev_button->type == GDK_BUTTON_PRESS)) { geometry_highlight_node( dnode, FALSE ); window_statusbar( SB_RIGHT, node_absname( dnode ) ); if (dnode != dirtree_current_dnode) filelist_populate( dnode ); dirtree_current_dnode = dnode; return FALSE; } /* A double-click from button 1 gets the camera moving */ if ((ev_button->button == 1) && (ev_button->type == GDK_2BUTTON_PRESS)) { camera_look_at( dnode ); /* Preempt the forthcoming tree expand/collapse * (the standard action spawned by a double-click) */ gtk_signal_emit_stop_by_name( GTK_OBJECT(ctree_w), "button_press_event" ); return TRUE; } /* A click from button 3 selects the row, highlights the node, * shows the name, updates the file list if necessary, and brings * up a context-sensitive menu */ if (ev_button->button == 3) { gtk_clist_select_row( GTK_CLIST(ctree_w), row, 0 ); geometry_highlight_node( dnode, FALSE ); window_statusbar( SB_RIGHT, node_absname( dnode ) ); if (dnode != dirtree_current_dnode) filelist_populate( dnode ); dirtree_current_dnode = dnode; context_menu( dnode, ev_button ); return FALSE; } return FALSE; }
void HaiQTextEdit::contextMenuEvent(QContextMenuEvent *event) { //QTextEdit::contextMenuEvent(event); if (textCursor().selectedText().isEmpty()) setTextCursor(cursorForPosition(event->pos())); qApp->processEvents(); emit context_menu(event->globalPos()); }
void TypeUiHtmlTextView::OnCustomContextMenuRequested( const QPoint& point ) { int cursor_position = ui->TextEdit->cursorForPosition( point ).position(); QPoint global_point = ui->TextEdit->viewport()->mapToGlobal( point ); TypeHtmlBlockStream& block_stream = Document().HtmlBuilder().BlockStream(); TypeHtmlBlock* block = block_stream.BlockFromCursorPosition( cursor_position ); long action_flags; if( block == 0 ) { // // There is no selection on html text view: action_flags = Document().Context().Struct().Flags(); TypeUiRecordContextMenu context_menu( Controller(), action_flags, false, global_point, this ); return; } TypeRootStruct& root = Document().Root(); TypeRecord* record = root.FromId( block->RecordId(), true ); SetActiveRecord( record ); ActivateBlock( block ); emit Controller().SetActiveRecord( record ); if( record == 0 ) { // // The selected block doesn't contain any record: action_flags = Document().Context().Struct().Flags();//WHY?-------------- TypeUiRecordContextMenu context_menu( Controller(), action_flags, false, global_point, this ); return; } // // Open a context menu for selected record: action_flags = record->ParentStruct()->Flags(); TypeUiRecordContextMenu context_menu( Controller(), action_flags, true, global_point, this ); }
void LLWidgetReg::initClass(bool register_widgets) { // Only need to register if the Windows linker has optimized away the // references to the object files. if (register_widgets) { LLDefaultChildRegistry::Register<LLButton> button("button"); LLDefaultChildRegistry::Register<LLMenuButton> menu_button("menu_button"); LLDefaultChildRegistry::Register<LLCheckBoxCtrl> check_box("check_box"); LLDefaultChildRegistry::Register<LLComboBox> combo_box("combo_box"); LLDefaultChildRegistry::Register<LLFilterEditor> filter_editor("filter_editor"); LLDefaultChildRegistry::Register<LLFlyoutButton> flyout_button("flyout_button"); LLDefaultChildRegistry::Register<LLContainerView> container_view("container_view"); LLDefaultChildRegistry::Register<LLIconCtrl> icon("icon"); LLDefaultChildRegistry::Register<LLLoadingIndicator> loading_indicator("loading_indicator"); LLDefaultChildRegistry::Register<LLLineEditor> line_editor("line_editor"); LLDefaultChildRegistry::Register<LLMenuItemSeparatorGL> menu_item_separator("menu_item_separator"); LLDefaultChildRegistry::Register<LLMenuItemCallGL> menu_item_call_gl("menu_item_call"); LLDefaultChildRegistry::Register<LLMenuItemCheckGL> menu_item_check_gl("menu_item_check"); LLDefaultChildRegistry::Register<LLMenuGL> menu("menu"); LLDefaultChildRegistry::Register<LLMenuBarGL> menu_bar("menu_bar"); LLDefaultChildRegistry::Register<LLContextMenu> context_menu("context_menu"); LLDefaultChildRegistry::Register<LLMultiSlider> multi_slider_bar("multi_slider_bar"); LLDefaultChildRegistry::Register<LLMultiSliderCtrl> multi_slider("multi_slider"); LLDefaultChildRegistry::Register<LLPanel> panel("panel", &LLPanel::fromXML); LLDefaultChildRegistry::Register<LLLayoutStack> layout_stack("layout_stack"); LLDefaultChildRegistry::Register<LLProgressBar> progress_bar("progress_bar"); LLDefaultChildRegistry::Register<LLRadioGroup> radio_group("radio_group"); LLDefaultChildRegistry::Register<LLSearchEditor> search_editor("search_editor"); LLDefaultChildRegistry::Register<LLScrollContainer> scroll_container("scroll_container"); LLDefaultChildRegistry::Register<LLScrollingPanelList> scrolling_panel_list("scrolling_panel_list"); LLDefaultChildRegistry::Register<LLScrollListCtrl> scroll_list("scroll_list"); LLDefaultChildRegistry::Register<LLSlider> slider_bar("slider_bar"); LLDefaultChildRegistry::Register<LLSliderCtrl> slider("slider"); LLDefaultChildRegistry::Register<LLSpinCtrl> spinner("spinner"); LLDefaultChildRegistry::Register<LLStatBar> stat_bar("stat_bar"); //LLDefaultChildRegistry::Register<LLPlaceHolderPanel> placeholder("placeholder"); LLDefaultChildRegistry::Register<LLTabContainer> tab_container("tab_container"); LLDefaultChildRegistry::Register<LLTextBox> text("text"); LLDefaultChildRegistry::Register<LLTimeCtrl> time("time"); LLDefaultChildRegistry::Register<LLTextEditor> simple_text_editor("simple_text_editor"); LLDefaultChildRegistry::Register<LLUICtrl> ui_ctrl("ui_ctrl"); LLDefaultChildRegistry::Register<LLStatView> stat_view("stat_view"); //LLDefaultChildRegistry::Register<LLUICtrlLocate> locate("locate"); //LLDefaultChildRegistry::Register<LLUICtrlLocate> pad("pad"); LLDefaultChildRegistry::Register<LLViewBorder> view_border("view_border"); } // *HACK: Usually this is registered as a viewer text editor LLDefaultChildRegistry::Register<LLTextEditor> text_editor("text_editor"); }
/* Callback for a click in the file list area */ static int filelist_select_cb( GtkWidget *clist_w, GdkEventButton *ev_button ) { GNode *node; int row; /* If About presentation is up, end it */ about( ABOUT_END ); if (globals.fsv_mode == FSV_SPLASH) return FALSE; gtk_clist_get_selection_info( GTK_CLIST(clist_w), ev_button->x, ev_button->y, &row, NULL ); if (row < 0) return FALSE; node = (GNode *)gtk_clist_get_row_data( GTK_CLIST(clist_w), row ); if (node == NULL) return FALSE; /* A single-click from button 1 highlights the node and shows the * name (and also selects the row, but GTK+ does that for us) */ if ((ev_button->button == 1) && (ev_button->type == GDK_BUTTON_PRESS)) { geometry_highlight_node( node, FALSE ); window_statusbar( SB_RIGHT, node_absname( node ) ); return FALSE; } /* A double-click from button 1 gets the camera moving */ if ((ev_button->button == 1) && (ev_button->type == GDK_2BUTTON_PRESS)) { camera_look_at( node ); return FALSE; } /* A click from button 3 selects the row, highlights the node, * shows the name, and pops up a context-sensitive menu */ if (ev_button->button == 3) { gtk_clist_select_row( GTK_CLIST(clist_w), row, 0 ); geometry_highlight_node( node, FALSE ); window_statusbar( SB_RIGHT, node_absname( node ) ); context_menu( node, ev_button ); return FALSE; } return FALSE; }
/** * Create one of the objects associated with an item in the current folder. * * Currently, only requests for the current objects are displatched to the * subclasses: * - IContextMenu * - IDataObject * - IQueryAssociations * - IExtractIconW/IExtractIconA */ ATL::CComPtr<IUnknown> folder_item_object( HWND hwnd, REFIID riid, UINT cpidl, PCUITEMID_CHILD_ARRAY apidl) { assert(cpidl > 0); ATL::CComPtr<IUnknown> object; if (riid == __uuidof(IContextMenu)) { object = context_menu(hwnd, cpidl, apidl); } else if (riid == __uuidof(IDataObject)) { object = data_object(hwnd, cpidl, apidl); } else if (riid == __uuidof(IQueryAssociations)) { object = query_associations(hwnd, cpidl, apidl); } else if (riid == __uuidof(IExtractIconW)) { assert(cpidl == 1); if (cpidl == 1) object = extract_icon_w(hwnd, apidl[0]); } else if (riid == __uuidof(IExtractIconA)) { assert(cpidl == 1); if (cpidl == 1) object = extract_icon_a(hwnd, apidl[0]); } // QueryInterface could fail at any point above and it *doesn't* throw // an exception. We have to check for NULL once we are sure it can't // fail again: IUnknown returned as IUnknown shouldn't be able to fail. if (!object) BOOST_THROW_EXCEPTION(comet::com_error(E_NOINTERFACE)); return object; }
/* This callback catches all events for the viewport */ int viewport_cb( GtkWidget *gl_area_w, GdkEvent *event ) { GdkEventButton *ev_button; GdkEventMotion *ev_motion; GNode *node; double dx, dy; unsigned int face_id; int x, y; boolean btn1, btn2, btn3; boolean ctrl_key; /* Handle low-level GL area widget events */ switch (event->type) { case GDK_EXPOSE: ogl_refresh( ); return FALSE; case GDK_CONFIGURE: ogl_resize( ); return FALSE; default: /* Event is probably coming from the mouse */ break; } if (event->type == GDK_BUTTON_PRESS) { /* Exit the About presentation if it is up */ if (about( ABOUT_END )) { indicated_node = NULL; return FALSE; } } /* If we're in splash screen mode, proceed no further */ if (globals.fsv_mode == FSV_SPLASH) return FALSE; /* Mouse-related events */ switch (event->type) { case GDK_BUTTON_PRESS: ev_button = (GdkEventButton *)event; btn1 = ev_button->button == 1; btn2 = ev_button->button == 2; btn3 = ev_button->button == 3; ctrl_key = ev_button->state & GDK_CONTROL_MASK; x = (int)ev_button->x; y = (int)ev_button->y; if (camera_moving( )) { /* Yipe! Impatient user */ camera_pan_finish( ); indicated_node = NULL; } else if (!ctrl_key) { if (btn2) indicated_node = NULL; else indicated_node = node_at_location( x, y, &face_id ); if (indicated_node == NULL) { geometry_highlight_node( NULL, FALSE ); window_statusbar( SB_RIGHT, "" ); } else { if (geometry_should_highlight( indicated_node, face_id ) || btn1) geometry_highlight_node( indicated_node, btn1 ); else geometry_highlight_node( NULL, FALSE ); window_statusbar( SB_RIGHT, node_absname( indicated_node ) ); if (btn3) { /* Bring up context-sensitive menu */ context_menu( indicated_node, ev_button ); filelist_show_entry( indicated_node ); } } } prev_x = x; prev_y = y; break; case GDK_2BUTTON_PRESS: /* Ignore second click of a double-click */ break; case GDK_BUTTON_RELEASE: ev_button = (GdkEventButton *)event; btn1 = ev_button->state & GDK_BUTTON1_MASK; ctrl_key = ev_button->state & GDK_CONTROL_MASK; if (btn1 && !ctrl_key && !camera_moving( ) && (indicated_node != NULL)) camera_look_at( indicated_node ); gui_cursor( gl_area_w, -1 ); break; case GDK_MOTION_NOTIFY: ev_motion = (GdkEventMotion *)event; btn1 = ev_motion->state & GDK_BUTTON1_MASK; btn2 = ev_motion->state & GDK_BUTTON2_MASK; btn3 = ev_motion->state & GDK_BUTTON3_MASK; ctrl_key = ev_motion->state & GDK_CONTROL_MASK; x = (int)ev_motion->x; y = (int)ev_motion->y; if (!camera_moving( ) && !gtk_events_pending( )) { if (btn2) { /* Dolly the camera */ gui_cursor( gl_area_w, GDK_DOUBLE_ARROW ); dy = MOUSE_SENSITIVITY * (y - prev_y); camera_dolly( - dy ); indicated_node = NULL; } else if (ctrl_key && btn1) { /* Revolve the camera */ gui_cursor( gl_area_w, GDK_FLEUR ); dx = MOUSE_SENSITIVITY * (x - prev_x); dy = MOUSE_SENSITIVITY * (y - prev_y); camera_revolve( dx, dy ); indicated_node = NULL; } else if (!ctrl_key && (btn1 || btn3)) { /* Pointless dragging */ if (indicated_node != NULL) { node = node_at_location( x, y, &face_id ); if (node != indicated_node) indicated_node = NULL; } } else indicated_node = node_at_location( x, y, &face_id ); /* Update node highlighting */ if (indicated_node == NULL) { geometry_highlight_node( NULL, FALSE ); window_statusbar( SB_RIGHT, "" ); } else { if (geometry_should_highlight( indicated_node, face_id ) || btn1) geometry_highlight_node( indicated_node, btn1 ); else geometry_highlight_node( NULL, FALSE); window_statusbar( SB_RIGHT, node_absname( indicated_node ) ); } prev_x = x; prev_y = y; } break; case GDK_LEAVE_NOTIFY: /* The mouse has left the viewport */ geometry_highlight_node( NULL, FALSE ); window_statusbar( SB_RIGHT, "" ); gui_cursor( gl_area_w, -1 ); indicated_node = NULL; break; default: /* Ignore event */ break; } return FALSE; }