Exemple #1
0
void DataGrid::onKeyDown(wxKeyEvent &event)
{
	bool modified = false;
	if (event.GetKeyCode() == WXK_RETURN || event.GetKeyCode() == WXK_NUMPAD_ENTER) {
		if (event.ControlDown()) {
			if (!IsCellEditControlEnabled()) {
				insertRowToDataUp(GetGridCursorRow());
				modified = true;
			}
		} else {
			insertRowToData(GetGridCursorRow());
			modified = true;
		}
	} else if (event.GetKeyCode() == WXK_DELETE) {
		if (IsSelection()) {
			wxArrayInt rows = GetSelectedRows();
			if (rows.Count() > 0) {
				modified = deleteRowsFromData(rows);
			} else {
				unsigned int i;
				int row, col;
				wxGridCellCoordsArray cells = GetSelectedCells();
				for (i = 0; i < cells.Count(); i++) {
					clearCellData(cells[i].GetRow(), cells[i].GetCol());
				}
				wxGridCellCoordsArray topLeft = GetSelectionBlockTopLeft();
				wxGridCellCoordsArray bottomRight = GetSelectionBlockBottomRight();
				for (i = 0; i < topLeft.Count(); i++) {
					for (row = topLeft[i].GetRow(); row <= bottomRight[i].GetRow(); row++) {
						for (col = topLeft[i].GetCol(); col <= bottomRight[i].GetCol(); col++) {
							clearCellData(row, col);
						}
					}
				}
				wxArrayInt cols = GetSelectedCols();
				for (i = 0; i < cols.Count(); i++) {
					for (row = 1; row < GetNumberRows(); row++) {
						clearCellData(row, cols[i]);
					}
				}
			}
			ClearSelection();
		} else {
			clearCellData(GetGridCursorRow(), GetGridCursorCol());
		}
	}
	wxGrid::OnKeyDown(event);
	if (modified) updateData(true);
}
bool GLIDebugVariableGrid::OnDnDText(const wxString &newWatchName)
{
  //If currently editing, return now
  if(IsCellEditControlEnabled())
  {
    return false;
  }

  //If showing watch values or there is already too many watch variables
  if(!(gridFlags & DF_ShowWatchValues) || 
     watchValuesArray.size() >= MAX_NUM_WATCH_VALUES)
  {
    return false;
  }

  //Add the value
  UniformData newWatchData;
  newWatchData.name = newWatchName;
  newWatchData.type = GL_FLOAT;
  newWatchData.isFloatType = true;

  watchValuesArray.push_back(newWatchData);

  //Refresh the display
  int currRow    = GetGridCursorRow();
  int currColumn = GetGridCursorCol();

  //Update the grid
  RefreshGrid();
  
  //Reset the selected cell
  SetCurrentCell(currRow, currColumn);

  return true;
}
Exemple #3
0
void wxGridCtrl::DrawRowLabel(wxDC& dc, int row)
{
    if (GetRowHeight(row) <= 0 || m_rowLabelWidth <= 0)
        return;
    wxRect rect;
#ifdef __WXGTK20__
    rect.SetX(1);
    rect.SetY(GetRowTop(row) + 1);
    rect.SetWidth(m_rowLabelWidth - 2);
    rect.SetHeight(GetRowHeight(row) - 2);
    CalcScrolledPosition(0, rect.y, NULL, &rect.y);
    wxWindowDC *win_dc = (wxWindowDC*)&dc;
    wxRendererNative::Get().DrawHeaderButton(win_dc->m_owner, dc, rect, 0);
#else
    int rowTop = GetRowTop(row), rowBottom = GetRowBottom(row) - 1;
    dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW), 1, wxSOLID));
    dc.DrawLine(m_rowLabelWidth - 1, rowTop, m_rowLabelWidth - 1, rowBottom);
    dc.DrawLine(0, rowTop, 0, rowBottom);
    dc.DrawLine(0, rowBottom, m_rowLabelWidth, rowBottom);
    dc.SetPen(*wxWHITE_PEN);
    dc.DrawLine(1, rowTop, 1, rowBottom);
    dc.DrawLine(1, rowTop, m_rowLabelWidth - 1, rowTop);
#endif
    if (row == GetGridCursorRow())
    {
        dc.DrawBitmap(m_pImageList->GetBitmap(4), 0, GetRowTop(row), true);
    }
}
//---------------------------------------------------------
bool CVIEW_Table_Control::Ins_Record(void)
{
	if( !FIXED_ROWS && m_pTable->Get_ObjectType() == DATAOBJECT_TYPE_Table )
	{
		int		iRecord	= GetGridCursorRow();

		if( iRecord >= 0 && iRecord < GetNumberRows() )
		{
			InsertRows(iRecord);

			m_pRecords	= (CSG_Table_Record **)SG_Realloc(m_pRecords, GetNumberRows() * sizeof(CSG_Table_Record *));

			for(int i=GetNumberRows()-1; i>iRecord; i--)
			{
				m_pRecords[i]	= m_pRecords[i - 1];
			}

			_Set_Record(iRecord, m_pTable->Ins_Record(iRecord));

			return( true );
		}
	}

	return( false );
}
Exemple #5
0
void DataGrid::updateData(bool setModified)
{
	if (setModified) m_data->setModified();
	showMainData();
	updateBalanceAndTotal();
	SetGridCursor(GetGridCursorRow(), OutlayIndex);
}
Exemple #6
0
const std::string wex::grid::get_find_string() const
{
  if (IsSelection())
  {
    // This does not work (if single cell selected, array count is 0!
    // const wxGridCellCoordsArray cells(GetSelectedCells());
    tokenizer tkz(get_selected_cells_value(), "\n");

    // Only if we have one cell, so one EOL.
    if (tkz.count_tokens() == 1)
    {
      find_replace_data::get()->set_find_string(tkz.get_next_token());
    }
  }
  else
  {
    // Just take current cell value, if not empty.
    const auto row = GetGridCursorRow();
    const auto col = GetGridCursorCol();
    const std::string val = GetCellValue(row, col);

    if (!val.empty())
    {
      find_replace_data::get()->set_find_string(val);
    }
  }
    
  return find_replace_data::get()->get_find_string();
}
//---------------------------------------------------------
void CActive_Attributes_Control::On_Field_Open(wxCommandEvent &event)
{
	int	iField	= m_Field_Offset + GetGridCursorCol();
	int	iRecord	=                  GetGridCursorRow();

	if( iField >= 0 && iField<m_pTable->Get_Field_Count() && iRecord >= 0 && iRecord < m_pTable->Get_Count() )
	{
		CSG_Table_Record	*pRecord	= m_pTable->Get_Record(iRecord);

		if( event.GetId() == ID_CMD_TABLE_FIELD_OPEN_APP )
		{
			Open_Application(pRecord->asString(iField));
		}

		if( event.GetId() == ID_CMD_TABLE_FIELD_OPEN_DATA )
		{
			wxString	Value	= pRecord->asString(iField);

			if( _Get_DataSource(Value) )
			{
				g_pData->Open   (Value);
			}
		}
	}
}
Exemple #8
0
void Grid::OnSetFocus(wxFocusEvent &event)
{
    event.Skip();

#if wxUSE_ACCESSIBILITY
    mAx->SetCurrentCell(GetGridCursorRow(), GetGridCursorCol());
#endif
}
Exemple #9
0
void wex::grid::paste_cells_from_clipboard()
{
  set_cells_value(
    wxGridCellCoords(
      GetGridCursorRow(), 
      GetGridCursorCol()), 
    clipboard_get());
}
//---------------------------------------------------------
void CVIEW_Table_Control::On_LClick(wxGridEvent &event)
{
	int					iField		= m_Field_Offset + event.GetCol();
	CSG_Table_Record	*pRecord	= m_pRecords[event.GetRow()];

	//-----------------------------------------------------
	if( event.AltDown() )
	{
		if( m_pTable->Get_Field_Type(iField) == SG_DATATYPE_String )
		{
			if( event.ControlDown() )
			{
				g_pData->Open   (pRecord->asString(iField));
			}
			else
			{
				Open_Application(pRecord->asString(iField));
			}
		}
	}

	//-----------------------------------------------------
	else if( event.ControlDown() )
	{
		m_pTable->Select(pRecord, true);

		Update_Selection();
	}

	else if( event.ShiftDown() )
	{
		SelectBlock(event.GetRow(), 0, GetGridCursorRow(), GetNumberCols(), false);
	}

	else
	{
		SelectRow(event.GetRow(), false);

		if( pRecord && iField >= m_Field_Offset && iField < m_pTable->Get_Field_Count() && m_pTable->Get_Field_Type(iField) == SG_DATATYPE_Color )
		{
			long	lValue;

			if( DLG_Color(lValue = pRecord->asInt(iField)) )
			{
				pRecord->Set_Value(iField, lValue);

				SetCellBackgroundColour(event.GetRow(), event.GetCol(), Get_Color_asWX(pRecord->asInt(iField)));

				ForceRefresh();
			}
		}
	}

	//-----------------------------------------------------
	SetGridCursor(event.GetRow(), event.GetCol());
}
void CBOINCGridCtrl::SaveGridCursorPosition() {
	m_cursorcol = GetGridCursorCol();
	m_cursorrow = GetGridCursorRow();	
	if(m_cursorrow>=0 && m_cursorcol >=0) {
		m_szCursorKey1 = GetCellValue(m_cursorrow,m_pkColumnIndex1);
                if (m_pkColumnIndex2 >= 0) {
                    m_szCursorKey2 = GetCellValue(m_cursorrow,m_pkColumnIndex2);
                }
	}
}
//---------------------------------------------------------
void CActive_Attributes_Control::On_LClick_Label(wxGridEvent &event)
{
	if( event.GetCol() >= 0 )
	{
		SetGridCursor(GetGridCursorRow(), event.GetCol());
	}
	else if( event.GetRow() >= 0 )
	{
		SetGridCursor(event.GetRow(), GetGridCursorCol());
	}
}
//---------------------------------------------------------
void CVIEW_Table_Control::On_LClick_Label(wxGridEvent &event)
{
	if( event.GetCol() >= 0 )
	{
		SetGridCursor	(GetGridCursorRow(), event.GetCol());
	}
	else if( event.GetRow() >= 0 )
	{
		SetGridCursor	(event.GetRow(), GetGridCursorCol());
	}
	else
	{
	//	SelectAll();
	}
}
Exemple #14
0
void wxGridCtrl::DrawRowLabel(wxDC& dc, int row)
{
    if (GetRowHeight(row) <= 0 || m_rowLabelWidth <= 0)
        return;
    wxRect rect;
    int rowTop = GetRowTop(row), rowBottom = GetRowBottom(row) - 1;
    dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW), 1, wxSOLID));
    dc.DrawLine(m_rowLabelWidth - 1, rowTop, m_rowLabelWidth - 1, rowBottom);
    dc.DrawLine(0, rowTop, 0, rowBottom);
    dc.DrawLine(0, rowBottom, m_rowLabelWidth, rowBottom);
    dc.SetPen(*wxWHITE_PEN);
    dc.DrawLine(1, rowTop, 1, rowBottom);
    dc.DrawLine(1, rowTop, m_rowLabelWidth - 1, rowTop);
    if (row == GetGridCursorRow())
	{
		dc.DrawBitmap(wxBitmap(small_arrow_xpm), 0, GetRowTop(row), true);
    }
}
//---------------------------------------------------------
void CVIEW_Table_Control::On_Field_Open(wxCommandEvent &event)
{
	int	iField	= m_Field_Offset + GetGridCursorCol();
	int	iRecord	=                  GetGridCursorRow();

	if( iField >= 0 && iField<m_pTable->Get_Field_Count() && iRecord >= 0 && iRecord < m_pTable->Get_Count() )
	{
		CSG_Table_Record	*pRecord	= m_pRecords[iRecord];

		if( event.GetId() == ID_CMD_TABLE_FIELD_OPEN_APP )
		{
			Open_Application(pRecord->asString(iField));
		}

		if( event.GetId() == ID_CMD_TABLE_FIELD_OPEN_DATA )
		{
			g_pData->Open   (pRecord->asString(iField));
		}
	}
}
Exemple #16
0
int ctlSQLGrid::Copy()
{
	wxString str;
	int copied = 0;
	size_t i;



	if (GetSelectedRows().GetCount())
	{
		AppendColumnHeader(str, 0, (GetNumberCols() - 1));

		wxArrayInt rows = GetSelectedRows();

		for (i = 0 ; i < rows.GetCount() ; i++)
		{
			str.Append(GetExportLine(rows.Item(i)));

			if (rows.GetCount() > 1)
				str.Append(END_OF_LINE);
		}

		copied = rows.GetCount();
	}
	else if (GetSelectedCols().GetCount())
	{
		wxArrayInt cols = GetSelectedCols();
		size_t numRows = GetNumberRows();

		AppendColumnHeader(str, cols);

		for (i = 0 ; i < numRows ; i++)
		{
			str.Append(GetExportLine(i, cols));

			if (numRows > 1)
				str.Append(END_OF_LINE);
		}

		copied = numRows;
	}
	else if (GetSelectionBlockTopLeft().GetCount() > 0 &&
	         GetSelectionBlockBottomRight().GetCount() > 0)
	{
		unsigned int x1, x2, y1, y2;

		x1 = GetSelectionBlockTopLeft()[0].GetCol();
		x2 = GetSelectionBlockBottomRight()[0].GetCol();
		y1 = GetSelectionBlockTopLeft()[0].GetRow();
		y2 = GetSelectionBlockBottomRight()[0].GetRow();

		AppendColumnHeader(str, x1, x2);

		for (i = y1; i <= y2; i++)
		{
			str.Append(GetExportLine(i, x1, x2));

			if (y2 > y1)
				str.Append(END_OF_LINE);
		}

		copied = y2 - y1 + 1;
	}
	else
	{
		int row, col;

		row = GetGridCursorRow();
		col = GetGridCursorCol();

		AppendColumnHeader(str, col, col);

		str.Append(GetExportLine(row, col, col));
		copied = 1;
	}

	if (copied && wxTheClipboard->Open())
	{
		wxTheClipboard->SetData(new wxTextDataObject(str));
		wxTheClipboard->Close();
	}
	else
	{
		copied = 0;
	}

	return copied;
}
Exemple #17
0
void Grid::OnKeyDown(wxKeyEvent &event)
{
    switch (event.GetKeyCode())
    {
    case WXK_LEFT:
    case WXK_RIGHT:
    {
        int rows = GetNumberRows();
        int cols = GetNumberCols();
        int crow = GetGridCursorRow();
        int ccol = GetGridCursorCol();

        if (event.GetKeyCode() == WXK_LEFT) {
            if (crow == 0 && ccol == 0) {
                // do nothing
            }
            else if (ccol == 0) {
                SetGridCursor(crow - 1, cols - 1);
            }
            else {
                SetGridCursor(crow, ccol - 1);
            }
        }
        else {
            if (crow == rows - 1 && ccol == cols - 1) {
                // do nothing
            }
            else if (ccol == cols - 1) {
                SetGridCursor(crow + 1, 0);
            }
            else {
                SetGridCursor(crow, ccol + 1);
            }
        }

#if wxUSE_ACCESSIBILITY
        // Make sure the NEW cell is made available to the screen reader
        mAx->SetCurrentCell(GetGridCursorRow(), GetGridCursorCol());
#endif
    }
    break;

    case WXK_TAB:
    {
        int rows = GetNumberRows();
        int cols = GetNumberCols();
        int crow = GetGridCursorRow();
        int ccol = GetGridCursorCol();

        if (event.ControlDown()) {
            int flags = wxNavigationKeyEvent::FromTab |
                        ( event.ShiftDown() ?
                          wxNavigationKeyEvent::IsBackward :
                          wxNavigationKeyEvent::IsForward );
            Navigate(flags);
            return;
        }
        else if (event.ShiftDown()) {
            if (crow == 0 && ccol == 0) {
                Navigate(wxNavigationKeyEvent::FromTab | wxNavigationKeyEvent::IsBackward);
                return;
            }
            else if (ccol == 0) {
                SetGridCursor(crow - 1, cols - 1);
            }
            else {
                SetGridCursor(crow, ccol - 1);
            }
        }
        else {
            if (crow == rows - 1 && ccol == cols - 1) {
                Navigate(wxNavigationKeyEvent::FromTab | wxNavigationKeyEvent::IsForward);
                return;
            }
            else if (ccol == cols - 1) {
                SetGridCursor(crow + 1, 0);
            }
            else {
                SetGridCursor(crow, ccol + 1);
            }
        }
        MakeCellVisible(GetGridCursorRow(), GetGridCursorCol());

#if wxUSE_ACCESSIBILITY
        // Make sure the NEW cell is made available to the screen reader
        mAx->SetCurrentCell(GetGridCursorRow(), GetGridCursorCol());
#endif
    }
    break;

    case WXK_RETURN:
    case WXK_NUMPAD_ENTER:
    {
        if (!IsCellEditControlShown()) {
            wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
            wxWindow *def = tlw->GetDefaultItem();
            if (def && def->IsEnabled()) {
                wxCommandEvent cevent(wxEVT_COMMAND_BUTTON_CLICKED,
                                      def->GetId());
                GetParent()->GetEventHandler()->ProcessEvent(cevent);
            }
        }
        else {
            wxGrid::OnKeyDown(event);

            // This looks strange, but what it does is selects the cell when
            // enter is pressed after editing.  Without it, Jaws and Window-Eyes
            // do not speak the NEW cell contents (the one below the edited one).
            SetGridCursor(GetGridCursorRow(), GetGridCursorCol());
        }
        break;
    }

    default:
        wxGrid::OnKeyDown(event);
        break;
    }
}
void GLIDebugVariableGrid::OnKeyDown(wxKeyEvent &keyEvent)
{
  //If in edit mode, allow all keys through
  if(IsCellEditControlEnabled())
  {
    keyEvent.Skip();
    return;
  }

  //Don't allow the enter key to switch between rows
  if(keyEvent.m_keyCode == WXK_RETURN)
  {
    //Toggle the expandable rows if necessary
    if(ToggleRowExpansion(GetGridCursorRow()))
    {
      return;
    }

    //If the cell is able to be edited, start editing
    if(!IsCurrentCellReadOnly())
    {
      EnableCellEditControl();
    }

    return;
  }

  //Delete watch values on the delete key
  if(keyEvent.m_keyCode == WXK_DELETE)
  {
    int currRow    = GetGridCursorRow();
    int currColumn = GetGridCursorCol();

    //Check that the current row is in range
    if(currRow >= 0 && currRow < rowTypeDataArray.size() &&
       rowTypeDataArray[currRow].type == RT_WatchValue)
    {
      //Can only delete old stored watch values, not in progress editing ones
      uint watchIndex = rowTypeDataArray[currRow].indexValue;
      if(watchIndex < watchValuesArray.size())
      {
        //Delete the watch value from the array
        watchValuesArray.erase(watchValuesArray.begin() + watchIndex);

        //Refresh the grid
        RefreshGrid();

        //Reset the selected cell
        SetCurrentCell(currRow, currColumn);
        return;
      }
    }
  }

  //Handle Ctrl-C to copy the contents of a cell to the clipboard
  if(keyEvent.m_keyCode == 'C' && keyEvent.m_controlDown)
  {
    if (wxTheClipboard->Open())
    {
      //Add the data this is in the current cell
      wxTheClipboard->SetData( new wxTextDataObject(GetCellValue(GetGridCursorRow(), GetGridCursorCol())) );
      wxTheClipboard->Close();
    }
  }

  //Process all other keys
  keyEvent.Skip();
}
Exemple #19
0
bool wex::grid::find_next(const std::string& text, bool forward)
{
  if (text.empty())
  {
    return false;
  }

  static bool recursive = false;
  static int start_row;
  static int end_row;
  static int init_row;
  static int start_col;
  static int end_col;

  wxString text_use = text;

  if (!find_replace_data::get()->match_case())
  {
    text_use.MakeUpper();
  }

  wxGridCellCoords grid_cursor(GetGridCursorRow(), GetGridCursorCol());

  if (forward)
  {
    init_row = 0;

    if (recursive)
    {
      start_row = init_row;
      start_col = 0;
    }
    else
    {
      start_row = grid_cursor.GetRow() + 1;
      start_col = grid_cursor.GetCol();
    }

    end_row = GetNumberRows();
    end_col = GetNumberCols();
  }
  else
  {
    init_row = GetNumberRows() - 1;

    if (recursive)
    {
      start_row = init_row;
      start_col = GetNumberCols() - 1;
    }
    else
    {
      start_row = grid_cursor.GetRow() - 1;
      start_col = grid_cursor.GetCol();
    }

    end_row = -1;
    end_col = -1;
  }
  
  if (start_col == -1)
  {
    start_col = 0;
  }

  if (start_row == -1)
  {
    start_row = 0;
  }
  
  wxGridCellCoords match;

  for (int j = start_col; j != end_col && !match; (forward ? j++: j--))
  {
    for (int i = (j == start_col ? start_row: init_row);
         i != end_row && !match;
         (forward ? i++: i--))
    {
      wxString text = GetCellValue(i, j);

      if (!find_replace_data::get()->match_case())
      {
        text.MakeUpper();
      }

      if (find_replace_data::get()->match_word())
      {
        if (text == text_use)
        {
          match = wxGridCellCoords(i, j);
        }
      }
      else
      {
        if (text.Contains(text_use))
        {
          match = wxGridCellCoords(i, j);
        }
      }
    }
  }

  if (!match)
  {
    bool result = false;
    
    frame::statustext(
      get_find_result(text, forward, recursive), std::string());
    
    if (!recursive)
    {
      recursive = true;
      result = find_next(text, forward);
      recursive = false;
    }
    
    return result;
  }
  else
  {
    recursive = false;
    SetGridCursor(match.GetRow(), match.GetCol());
    MakeCellVisible(match); // though docs say this isn't necessary, it is
    return true;
  }
}