//------------------------------------------------------------------------------ // void OnCellClick(wxGridEvent& event) //------------------------------------------------------------------------------ void InteractiveMatlabDialog::OnCellClick(wxGridEvent& event) { unsigned int row = event.GetRow(); unsigned int col = event.GetCol(); if (event.GetEventObject() == inputGrid) { ParameterSelectDialog paramDlg(this, mObjectTypeList, GuiItemManager::SHOW_PLOTTABLE, true, false, true); paramDlg.SetParamNameArray(inputStrings); paramDlg.ShowModal(); inputStrings = paramDlg.GetParamNameArray(); wxString cellValue = wxT(""); if (inputStrings.Count() > 0) { cellValue = cellValue + inputStrings[0]; for (unsigned int i=1; i<inputStrings.Count(); i++) { cellValue = cellValue + wxT(", ") + inputStrings[i]; } inputGrid->SetCellValue(row, col, cellValue); } else // no selections inputGrid->SetCellValue(row, col, wxT("")); } else if (event.GetEventObject() == outputGrid) { ParameterSelectDialog paramDlg(this, mObjectTypeList, GuiItemManager::SHOW_PLOTTABLE, true, false, true); paramDlg.SetParamNameArray(outputStrings); paramDlg.ShowModal(); outputStrings = paramDlg.GetParamNameArray(); wxString cellValue = wxT(""); if (outputStrings.Count() > 0) { cellValue = cellValue + outputStrings[0]; for (unsigned int i=1; i<outputStrings.Count(); i++) { cellValue = cellValue + wxT(", ") + outputStrings[i]; } outputGrid->SetCellValue(row, col, cellValue); } else // no selections outputGrid->SetCellValue(row, col, wxT("")); } }
void CManagePasswordPolicies::OnSelectCell( wxGridEvent& evt ) { if (evt.GetEventObject() == m_PolicyNames) { m_curPolRow = evt.GetRow(); UpdateDetails(); } }
//------------------------------------------------------------------------------ // void OnCellLeftClick(wxGridEvent& event) //------------------------------------------------------------------------------ void DoWhilePanel::OnCellLeftClick(wxGridEvent& event) { int row = event.GetRow(); if (event.GetEventObject() == conditionGrid) { conditionGrid->SelectRow(row); } }
void TrackPickerDlg::onTrackCellLeftClick( wxGridEvent& event ) { wxString str = ((wxGrid*)event.GetEventObject())->GetCellValue( event.GetRow(), 0 ); ((wxGrid*)event.GetEventObject())->SetGridCursor(event.GetRow(), 0); CellRenderer* renderer = (CellRenderer*)((wxGrid*)event.GetEventObject())->GetCellRenderer(event.GetRow(),0); if( renderer->GetTip() != NULL) { TraceOp.trc( "trackpicker", TRCLEVEL_DEBUG, __LINE__, 9999, "cell tip is [%s] at row %d", renderer->GetTip(), event.GetRow()); m_Tip->SetValue(wxGetApp().getMsg( renderer->GetTip() )); } else m_Tip->SetValue(str); wxString my_text = wxT("addsymbol:") + str; TraceOp.trc( "trackpicker", TRCLEVEL_DEBUG, __LINE__, 9999, "drag [%s]", (const char*)my_text.mb_str(wxConvUTF8) ); wxTextDataObject my_data(my_text); wxDropSource dragSource( this ); dragSource.SetData( my_data ); wxDragResult result = dragSource.DoDragDrop(wxDrag_CopyOnly); Raise(); event.Skip(); }
void CDialogVolumes::OnGridEditStart(wxGridEvent &e) { m_bGridEditorShown = true; wxObject *pObj = e.GetEventObject(); m_pGridObject = wxDynamicCast(pObj,wxGrid); #ifdef __WXDEBUG__ if(m_pGridObject != NULL) { nwxGrid::ComputeSize(m_pGridObject); } #endif e.Skip(); }
void GridFrame::OnSelectCell( wxGridEvent& ev ) { wxString logBuf; if ( ev.Selecting() ) logBuf << _T("Selected "); else logBuf << _T("Deselected "); logBuf << _T("cell at row ") << ev.GetRow() << _T(" col ") << ev.GetCol() << _T(" ( ControlDown: ")<< (ev.ControlDown() ? 'T':'F') << _T(", ShiftDown: ")<< (ev.ShiftDown() ? 'T':'F') << _T(", AltDown: ")<< (ev.AltDown() ? 'T':'F') << _T(", MetaDown: ")<< (ev.MetaDown() ? 'T':'F') << _T(" )"); //Indicate whether this column was moved if ( ((wxGrid *)ev.GetEventObject())->GetColPos( ev.GetCol() ) != ev.GetCol() ) logBuf << _T(" *** Column moved, current position: ") << ((wxGrid *)ev.GetEventObject())->GetColPos( ev.GetCol() ); wxLogMessage( wxT("%s"), logBuf.c_str() ); // you must call Skip() if you want the default processing // to occur in wxGrid ev.Skip(); }
void CDialogEditGridColours::OnGrid(wxGridEvent &e) { int nRowColor = m_nRowColor; int nRowAttr = m_nRowAttr; int nRow = e.GetRow(); wxGrid *pGrid = (wxGrid *)e.GetEventObject(); if(pGrid == m_pGridAttr) { nRowAttr = nRow; } else if(pGrid == m_pGridColor) { nRowColor = nRow; } else { nRowColor = -1; nRowAttr = -1; wxASSERT_MSG(0,_T("CDialogEditGridColours::OnGrid() unknown grid")); } _UpdateButtons(nRowColor,nRowAttr); e.Skip(true); }
void CompareDlg::OnGridCellRightClick(wxGridEvent& evt) { wxGrid* grid = wxDynamicCast(evt.GetEventObject(), wxGrid); if (!grid) { evt.Skip(); return; } ComparisonData* cd = reinterpret_cast<ComparisonData*>(grid->GetClientData()); wxCHECK_RET(cd, wxT("ClientData object not found in grid")); ContextMenuData menuContext; menuContext.cdata = cd; if (!menuContext.cdata->grid->IsInSelection(evt.GetRow(), evt.GetCol())) { menuContext.cdata->grid->SelectRow(evt.GetRow(), false); } if (menuContext.cdata == m_conflicts) { menuContext.cdata->grid->SelectRow(evt.GetRow()%2 == 0? evt.GetRow()+1: evt.GetRow()-1, true); } menuContext.cdata->grid->SetGridCursor(evt.GetRow(), evt.GetCol()); menuContext.selectedRows = menuContext.cdata->grid->GetSelectedRows(); menuContext.selectedItems = menuContext.selectedRows; size_t selectionCount = menuContext.selectedRows.GetCount(); if (menuContext.cdata == m_conflicts) { selectionCount /= 2; wxCHECK_RET(menuContext.selectedItems.GetCount()%2 ==0, wxT("Conflicts grid should always select an even numer of items")); //Our alogo requires the indexes to be in order, and sometimes these are actually unsorted menuContext.selectedItems.Sort(pless); for( size_t idx = 1; idx <= selectionCount; ++idx) { wxCHECK_RET(menuContext.selectedItems[idx]%2 != 0, wxT("Selection indexes not in expected order")); wxLogDebug( wxString() << wxT("Removing index ") << menuContext.selectedItems.Item(idx) << wxT(" from selection at index ") << idx << wxT('\n')); menuContext.selectedItems.RemoveAt(idx, 1); } for( size_t idx = 0; idx < selectionCount; ++idx) { wxLogDebug(wxString() << wxT("Found index ") << menuContext.selectedItems.Item(idx) << wxT(" from selection at ") << idx << wxT('\n')); wxCHECK_RET(menuContext.selectedItems[idx]%2 == 0, wxT("Conflicts grid selection should only have even indexes after normalization")); menuContext.selectedItems[idx] /= 2; } } stringT itemStr; LoadAString(itemStr, selectionCount > 1? IDSC_ENTRIES: IDSC_ENTRY); wxString selCountStr(wxT(" ")); if (selectionCount > 1) selCountStr << selectionCount << wxT(" "); wxMenu itemEditMenu; wxString strSyncSelectedItemsMenu; if (selectionCount == 1) strSyncSelectedItemsMenu << _("Synchronize this item..."); else strSyncSelectedItemsMenu << _("Synchronize") << selCountStr << _("selected ") << towxstring(itemStr) << _("..."); itemEditMenu.Append(ID_SYNC_SELECTED_ITEMS_WITH_CURRENT_DB, strSyncSelectedItemsMenu); itemEditMenu.Append(ID_SYNC_ALL_ITEMS_WITH_CURRENT_DB, _("Synchronize all items...")); wxString strCopyItemsMenu; strCopyItemsMenu << _("Copy") << selCountStr << _("selected ") << towxstring(itemStr) << _(" to current db"); itemEditMenu.Append(ID_COPY_ITEMS_TO_CURRENT_DB, strCopyItemsMenu); wxString strDeleteItemsMenu; strDeleteItemsMenu << _("Delete") << selCountStr << _("selected ") << towxstring(itemStr) << _(" from current db"); itemEditMenu.Append(ID_DELETE_ITEMS_FROM_CURRENT_DB, strDeleteItemsMenu); if (selectionCount == 1) { itemEditMenu.AppendSeparator(); itemEditMenu.Append(ID_EDIT_IN_CURRENT_DB, _("&Edit entry in current db")); itemEditMenu.Append(ID_VIEW_IN_COMPARISON_DB, _("&View entry in comparison db")); } if (menuContext.cdata == m_conflicts) { wxString strCopyFieldMenu; ComparisonGridTable* table = wxDynamicCast(menuContext.cdata->grid->GetTable(), ComparisonGridTable); menuContext.field = table->ColumnToField(evt.GetCol()); if (selectionCount > 1) strCopyFieldMenu << _("&Copy ") << selectionCount << _(" selected ") << towxstring(CItemData::FieldName(menuContext.field)) << _(" fields to current db"); else strCopyFieldMenu << _("&Copy this ") << towxstring(CItemData::FieldName(menuContext.field)) << _(" to current db"); itemEditMenu.Insert(0, ID_COPY_FIELD_TO_CURRENT_DB, strCopyFieldMenu); itemEditMenu.InsertSeparator(1); itemEditMenu.Delete(ID_COPY_ITEMS_TO_CURRENT_DB); } else if (menuContext.cdata == m_current) { itemEditMenu.Delete(ID_SYNC_SELECTED_ITEMS_WITH_CURRENT_DB); itemEditMenu.Delete(ID_SYNC_ALL_ITEMS_WITH_CURRENT_DB); itemEditMenu.Delete(ID_COPY_ITEMS_TO_CURRENT_DB); if (selectionCount == 1) itemEditMenu.Delete(ID_VIEW_IN_COMPARISON_DB); } else if (menuContext.cdata == m_comparison) { itemEditMenu.Delete(ID_SYNC_SELECTED_ITEMS_WITH_CURRENT_DB); itemEditMenu.Delete(ID_SYNC_ALL_ITEMS_WITH_CURRENT_DB); itemEditMenu.Delete(ID_DELETE_ITEMS_FROM_CURRENT_DB); if (selectionCount == 1) itemEditMenu.Delete(ID_EDIT_IN_CURRENT_DB); } else if (menuContext.cdata == m_identical) { itemEditMenu.Delete(ID_SYNC_SELECTED_ITEMS_WITH_CURRENT_DB); itemEditMenu.Delete(ID_SYNC_ALL_ITEMS_WITH_CURRENT_DB); itemEditMenu.Delete(ID_COPY_ITEMS_TO_CURRENT_DB); } // Make the menuContext object available to the handlers EventDataInjector<wxCommandEvent> inject(&itemEditMenu, &menuContext, wxEVT_COMMAND_MENU_SELECTED); menuContext.cdata->grid->PopupMenu(&itemEditMenu); }
//------------------------------------------------------------------------------ // void OnCellDoubleLeftClick(wxGridEvent& event) //------------------------------------------------------------------------------ void DoWhilePanel::OnCellDoubleLeftClick(wxGridEvent& event) { if (event.GetEventObject() == conditionGrid) { int row = event.GetRow(); int col = event.GetCol(); if ( col == 0 ) { wxString strArray[] = { wxT("While") }; wxSingleChoiceDialog dialog(this, wxT("Condition: \n"), wxT("DoWhileConditionDialog"), 1, strArray); dialog.SetSelection(0); if (dialog.ShowModal() == wxID_OK) { if (dialog.GetStringSelection() != conditionGrid->GetCellValue(row, col)) { conditionGrid->SetCellValue(1, 0, dialog.GetStringSelection()); EnableUpdate(true); } } } else if ( (col == 1) || (col == 3)) { // show dialog to select parameter ParameterSelectDialog paramDlg(this); paramDlg.ShowModal(); if (paramDlg.IsParamSelected()) { wxString newParamName = paramDlg.GetParamName(); conditionGrid->SetCellValue(row, col, newParamName); EnableUpdate(true); } } else if (col == 2) { wxString strArray[] = { wxT("="), wxT(">"), wxT("<"), wxT(">="), wxT("<="), wxT("!=") }; wxSingleChoiceDialog dialog(this, wxT("Condition: \n"), wxT("DoWhileConditionDialog"), 6, strArray); dialog.SetSelection(0); if (dialog.ShowModal() == wxID_OK) { if (dialog.GetStringSelection() != conditionGrid->GetCellValue(row, col)) { conditionGrid->SetCellValue(row, col, dialog.GetStringSelection()); EnableUpdate(true); } } } } }
//------------------------------------------------------------------------------ // void OnCellRightClick(wxGridEvent& event) //------------------------------------------------------------------------------ void CallFunctionPanel::OnCellRightClick(wxGridEvent& event) { #ifdef DEBUG_CALLFUNCTION_PANEL MessageInterface::ShowMessage (wxT("CallFunctionPanel::OnCellRightClick() entered\n")); #endif unsigned int row = event.GetRow(); unsigned int col = event.GetCol(); #ifdef DEBUG_CALLFUNCTION_PANEL MessageInterface::ShowMessage(wxT(" row = %d, col = %d\n"), row, col); #endif if (event.GetEventObject() == theInputGrid) { ParameterSelectDialog paramDlg(this, mObjectTypeList, GuiItemManager::SHOW_REPORTABLE, true, true, true); theOutputGrid->DeselectRow(0); paramDlg.SetParamNameArray(mInputWxStrings); paramDlg.ShowModal(); #ifdef DEBUG_CALLFUNCTION_PANEL MessageInterface::ShowMessage (wxT(" Has new input selection made? %d\n"), paramDlg.HasSelectionChanged()); #endif if (paramDlg.HasSelectionChanged()) { EnableUpdate(true); mInputWxStrings = paramDlg.GetParamNameArray(); wxString cellValue = wxT(""); wxString delimiter = wxT(", "); if (mInputWxStrings.Count() > 0) { cellValue = cellValue + mInputWxStrings[0]; for (unsigned int i=1; i<mInputWxStrings.Count(); i++) cellValue = cellValue + delimiter + mInputWxStrings[i]; theInputGrid->SetCellValue(row, col, cellValue); } else // no selections { theInputGrid->SetCellValue(row, col, wxT("")); } } } else if (event.GetEventObject() == theOutputGrid) { ParameterSelectDialog paramDlg(this, mObjectTypeList, GuiItemManager::SHOW_REPORTABLE, true, true, true); theInputGrid->DeselectRow(0); paramDlg.SetParamNameArray(mOutputWxStrings); paramDlg.ShowModal(); #ifdef DEBUG_CALLFUNCTION_PANEL MessageInterface::ShowMessage (wxT(" Has new output selection made? %d\n"), paramDlg.HasSelectionChanged()); #endif if (paramDlg.HasSelectionChanged()) { EnableUpdate(true); mOutputWxStrings = paramDlg.GetParamNameArray(); wxString cellValue = wxT(""); wxString delimiter = wxT(", "); if (mOutputWxStrings.Count() > 0) { cellValue = cellValue + mOutputWxStrings[0]; for (unsigned int i=1; i<mOutputWxStrings.Count(); i++) cellValue = cellValue + delimiter + mOutputWxStrings[i]; theOutputGrid->SetCellValue(row, col, cellValue); } else // no selections { theOutputGrid->SetCellValue(row, col, wxT("")); } } } }