// // WM_LBUTTONDOWN // // Set the item position from the specified client coordinates // LRESULT GridView::OnLButtonDown(int x, int y) { ULONG lineNo, colIdx, portion; GVRow *rowptr; RECT rect; // RelayEvent(m_hWndTooltip, WM_LBUTTONDOWN, x, y); if((rowptr = MouseToItem(x, y, &lineNo, &colIdx, &portion, &rect)) == 0) return 0; if(m_hwndEdit) ExitEditMode(FALSE); if((portion & GHT_TREEBUTTON) && rowptr) { ToggleRow(rowptr, lineNo); NotifyParent(GVN_ITEMEXPANDED, rowptr); } else { // have we clicked again in the already selected item? if(m_nCurrentColumn == colIdx && m_nCurrentLine == lineNo) { if(portion & GHT_TEXT) { EnterEditMode(); return 0; } } else { if(m_nCurrentColumn != colIdx) { RefreshWindow(); m_nCurrentColumn = colIdx; } if(m_nCurrentLine != lineNo) { RedrawLine(m_nCurrentLine); RedrawLine(lineNo); m_nCurrentLine = lineNo; } NotifyParent(GVN_SELCHANGED, rowptr); // make an exception - always edit if the combo is clicked on! if(portion & GHT_COMBO) EnterEditMode(); } m_fMouseDown = TRUE; SetCapture(m_hWnd); } return 0; }
// // WM_LBUTTONDBLCLK // // Double-click handler - expand tree nodes // LRESULT GridView::OnLButtonDblClick(int x, int y) { ULONG lineNo, colIdx, portion; GVRow *rowptr; GVITEM *gvitem; GVCOLUMN *gvcol; // make sure we clicked a valid row/item if((rowptr = MouseToItem(x, y, &lineNo, &colIdx, &portion, 0, &gvitem)) == 0 || gvitem == 0) return 0; if((gvcol = GetColumn(colIdx, 0)) == 0) return 0; // only collapse/expand on double-clicks if the grid is readonly if((portion & (GHT_TREE|GHT_ICON)) || (gvitem->state & GVIS_READONLY) || (gvcol->uState & GVCS_READONLY) || (m_uState & GVS_READONLY)) { ToggleRow(rowptr, lineNo); if(!(portion & (GHT_TREE|GHT_ICON))) NotifyParent(GVN_DBLCLK, rowptr); } // otherwise a double-click should edit the cell else { EnterEditMode(); } return 0; }
//----------------------------------------------------------------------------- //! Enters edit mode, and transfers focus to the tInfoPageWidget. //----------------------------------------------------------------------------- void tSuzukiRepowerEnginePanel::mouseDoubleClickEvent( QMouseEvent* pEvent ) { if( pEvent->button() == Qt::LeftButton && m_pPageWidget ) { EnterEditMode(); m_pPageWidget->SelectGauge( m_pPageWidget->GaugeClosestToMousePoint( pEvent->pos() ) ); UpdateActions(); } else { tPanel::mouseDoubleClickEvent( pEvent ); } }
//----------------------------------------------------------------------------- //! //----------------------------------------------------------------------------- void tSuzukiRepowerEnginePanel::keyPressEvent( QKeyEvent* pEvent ) { bool editMode = m_pPageWidget->InEditMode(); pEvent->ignore(); switch( pEvent->key() ) { case Key::Enter: case Key::Rotary: if( pEvent->isAutoRepeat() ) break; if( editMode ) { SelectInfo(); } else { EnterEditMode(); } pEvent->accept(); break; case Key::Exit: if( pEvent->isAutoRepeat() ) break; if( editMode ) { EditCancel(); pEvent->accept(); } break; default: if( pEvent->isAutoRepeat() ) break; if( editMode ) { EditSave(); } tPanel::keyPressEvent( pEvent ); break; } }
//----------------------------------------------------------------------------- //! //----------------------------------------------------------------------------- void tSuzukiRepowerEnginePanel::CreateActions() { m_pSpacerAct = new tAction( this ); m_pEditAct = new tAction( tr( "Edit" ) + "...", this ); m_pEditAct->SetAbbreviation( tr( "Edit", "[abbrev] for Edit" ) ); Connect( m_pEditAct, SIGNAL( triggered() ), this, SLOT( EnterEditMode() ) ); m_pSaveAct = new tAction( tr( "Save", "[button]" ), this ); m_pSaveAct->SetAbbreviation( tr( "Save", "[abbrev] for Save" ) ); Connect( m_pSaveAct, SIGNAL( triggered() ), this, SLOT( EditSave() ) ); m_pCancelAct = new tAction( tr( "Cancel", "[button]" ), this ); m_pCancelAct->SetAbbreviation( tr( "Cancel", "[abbrev] for Cancel" ) ); m_pCancelAct->SetAppearance( Action::DestructiveAppearance ); Connect( m_pCancelAct, SIGNAL( triggered() ), this, SLOT( EditCancel() ), Qt::QueuedConnection ); m_pChangeGaugeRangeAct = new tAction( tr( "Configure limits", "[button]" ) + "..." ); m_pChangeGaugeRangeAct->SetAbbreviation( tr( "Config. limits", "[abbrev] for Configure limits" ) ); Connect( m_pChangeGaugeRangeAct, SIGNAL( triggered() ), this, SLOT( ConfigureGaugeLimits() ) ); m_pSelectDataAct = new tAction( tr( "Select info" ) + "..." ); m_pSelectDataAct->SetAbbreviation( tr( "Select info", "[abbrev] for Select information" ) ); Connect( m_pSelectDataAct, SIGNAL( triggered() ), this, SLOT( SelectInfo() ) ); m_pAddSourceAct = new tAction( tr( "Add" ) ); m_pAddSourceAct->SetAbbreviation( tr( "Add", "[abbrev] for Add" ) ); m_pRemoveSourceAct = new tAction( tr( "Remove" ) ); m_pRemoveSourceAct->SetAbbreviation( tr( "Remove", "[abbrev] for Remove" ) ); m_pAutoAct = new tAction( tr( "Auto" ), this ); m_pAutoAct->SetAbbreviation( tr( "Auto", "[abbrev] for Auto" ) ); m_pAutoAct->setCheckable( true ); m_pSourceMenuAct = new tAction( tr("Sources"), tr( "Sources", "[abbrev] for Sources" ), this ); m_pSourceMenuAct->AppendSubAction( m_pAddSourceAct ); m_pSourceMenuAct->AppendSubAction( m_pRemoveSourceAct ); m_pSourceMenuAct->AppendSubAction( m_pAutoAct ); Connect( m_pAddSourceAct, SIGNAL( triggered() ), m_pPageWidget, SLOT( AddSource() ) ); Connect( m_pRemoveSourceAct, SIGNAL( triggered() ), m_pPageWidget, SLOT( RemoveSource() ), Qt::QueuedConnection ); Connect( m_pAutoAct, SIGNAL( toggled( bool ) ), m_pPageWidget, SLOT( SetAutoConfigureSources( bool ) ) ); }