示例#1
0
void SubModelsDialog::OnNodesGridLabelLeftClick(wxGridEvent& event)
{
    SelectRow(event.GetRow());
    if (event.GetRow() != -1) {
        NodesGrid->GoToCell(event.GetRow(), 0);
    }
}
//---------------------------------------------------------
bool CVIEW_Table_Control::_Set_Record(int iRecord, CSG_Table_Record *pRecord)
{
	m_pRecords[iRecord]	= pRecord;

	if( m_Field_Offset )
	{
		SetRowLabelValue(iRecord, pRecord->asString(0));
	}

	for(int iCol=0, iField=m_Field_Offset; iField<m_pTable->Get_Field_Count(); iCol++, iField++)
	{
		switch( m_pTable->Get_Field_Type(iField) )
		{
		default:
			SetCellValue(iRecord, iCol, pRecord->is_NoData(iField) ? SG_T("") : pRecord->asString(iField));
			break;

		case SG_DATATYPE_Color:
			SetCellBackgroundColour(iRecord, iCol, Get_Color_asWX(pRecord->asInt(iField)));
			break;
		}
	}

	if( pRecord->is_Selected() )
	{
		SelectRow(iRecord, true);
	}

	return( true );
}
//---------------------------------------------------------
bool CActive_Attributes_Control::_Set_Record(int iRecord)
{
	CSG_Table_Record *pRecord	= m_pTable->Get_Record(iRecord);

	if( m_Field_Offset )	// feature attributes
	{
		SetRowLabelValue(iRecord, pRecord->asString(0));
	}
	else					// grid cell values
	{
		SetRowLabelValue(iRecord, wxString::Format("%d", 1 + iRecord));
	}

	for(int iCol=0, iField=m_Field_Offset; iField<m_pTable->Get_Field_Count(); iCol++, iField++)
	{
		switch( m_pTable->Get_Field_Type(iField) )
		{
		default:
			SetCellValue(iRecord, iCol, pRecord->is_NoData(iField) ? SG_T("") : pRecord->asString(iField));
			break;

		case SG_DATATYPE_Color:
			SetCellBackgroundColour(iRecord, iCol, Get_Color_asWX(pRecord->asInt(iField)));
			break;
		}
	}

	if( pRecord->is_Selected() )
	{
		SelectRow(iRecord, true);
	}

	return( true );
}
示例#4
0
void SubModelsDialog::OnNodesGridCellChange(wxGridEvent& event)
{
    int r = event.GetRow();
    SubModelInfo &sm = GetSubModelInfo(NameChoice->GetStringSelection());
    sm.strands[r] = NodesGrid->GetCellValue(r, 0);
    SelectRow(r);
}
/////////////////////////
// Selects visible lines
void BaseGrid::SelectVisible() {
	int rows = GetRows();
	bool selectedOne = false;
	for (int i=0;i<rows;i++) {
		if (IsDisplayed(GetDialogue(i))) {
			if (!selectedOne) {
				SelectRow(i,false);
				MakeCellVisible(i,0);
				selectedOne = true;
			}
			else {
				SelectRow(i,true);
			}
		}
	}
}
示例#6
0
void wxPropertyList::OnCellPopup( wxGridEvent& event )
{
    wxPoint pt;
    int row = event.GetRow();
    
    //pt = ::wxGetMousePosition();
    //ScreenToClient(pt);

    //row = YToRow(pt.y);
    if(row != wxNOT_FOUND)
    {
        wxPropertyItem *pItem = GetPropertyItemFromRow(row);
    
        if(pItem)
        {
            // select the row first if already in selection, don't
            // this will clear the previous selection
            if(!IsInSelection(row, 0))
                SelectRow(row);

            // show popup menu
            wxMenu *menu = AppResources::CreatePopupMenu();
            
            // enable when it is browsable, and selected one only
            wxMenuItem *item = menu->FindItem(ID_CACHE_BROWSE);
            if(item)
                item->Enable(IsSelectedItemBrowsable());
            
            PopupMenu(menu);

            delete menu;
        }
    }
}
void GLIDebugVariableGrid::OnCellSelect(wxGridEvent &gridEvent)
{
  //Select the row when a cell has been selected
  SelectRow(gridEvent.GetRow());

  //Allow other processing
  gridEvent.Skip();
}
//---------------------------------------------------------
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());
}
示例#9
0
/** SelectLocation
  *
  * Shows a location on the grid
  */
void MemoryGrid::SelectLocation(unsigned short location)
{
    last_address = location;
    // Handles close to edge!
    int n_location = (location + 8 + 1) > 0xFFFF ? location : location + 8 + 1;
    SelectRow(location);
    SetGridCursor(location, 0);
    MakeCellVisible((location < 16) ? location : n_location, 0);
    Refresh();
}
/* select all rows, that were formerly selected
   this raises selection events without user interaction */
void CBOINCGridCtrl::RestoreSelection() {
    BeginBatch();       // To prevent flicker
	ClearSelection();
	for(unsigned int i=0;i < m_arrSelectedKeys1.size();i++) {
		int index = GetTable()->FindRowIndexByColValue(
                    m_pkColumnIndex1,m_arrSelectedKeys1[i],m_pkColumnIndex2,m_arrSelectedKeys2[i]
                );
		if(index >=0) {
			SelectRow(index,true);
		}
	}
    EndBatch();
}
示例#11
0
void SubModelsDialog::Select(const wxString &name) {
    if (name == "") {
        NameChoice->Disable();
        DeleteButton->Disable();
        NodesGrid->Disable();
        LayoutCheckbox->Disable();
        AddRowButton->Disable();
        DeleteRowButton->Disable();
        subBufferPanel->Disable();
        TypeNotebook->Disable();
        return;
    }
    NameChoice->Enable();
    DeleteButton->Enable();
    NodesGrid->Enable();
    LayoutCheckbox->Enable();
    AddRowButton->Enable();

    subBufferPanel->Enable();
    TypeNotebook->Enable();

    SubModelInfo &sm = GetSubModelInfo(name);
    DeleteRowButton->Enable(sm.strands.size() > 1);

    NameChoice->SetStringSelection(name);

    if (sm.isRanges) {
        TypeNotebook->SetSelection(0);
        LayoutCheckbox->SetValue(sm.vertical);
        NodesGrid->BeginBatch();
        if (NodesGrid->GetNumberRows() > 0) {
            NodesGrid->DeleteRows(0, NodesGrid->GetNumberRows());
        }
        for (int x = 0; x < sm.strands.size(); x++) {
            NodesGrid->AppendRows(1);
            NodesGrid->SetRowLabelValue(x, wxString::Format("Line %d", (x + 1)));
            NodesGrid->SetCellValue(x, 0, sm.strands[x]);
        }
        NodesGrid->EndBatch();
        NodesGrid->GoToCell(0, 0);
        SelectRow(0);
    } else {
        TypeNotebook->SetSelection(1);
        subBufferPanel->SetValue(sm.subBuffer.ToStdString());
        DisplayRange(sm.subBuffer);
    }
}
示例#12
0
//-----------------------------------------------------------------
//!	\brief	control left button double click message
//-----------------------------------------------------------------
void NPropertiesCtrl::OnLButtonDblClk(NPoint point)
{
	//Row selection
	int nidx = GetRowUnderPoint(point);
	SelectRow(nidx);

	//Row Click
	ClickRow(nidx, point);

	//Start Edit Cell
	/*if (!m_bEditingRow && m_dwCurSelRow!=-1)
	{
		//Edit Cell
		StartRowEditing(m_dwCurSelRow);
	}*/

}
示例#13
0
//-----------------------------------------------------------------
//!	\brief	control Left button down message
//-----------------------------------------------------------------
void NPropertiesCtrl::OnLButtonDown(NPoint point)
{
	SetFocus();

	//TRACE("OnLButtonDown\n");
	udword idx = GetRowUnderPoint(point);

	//Row selection and AddValue
	if (idx!=-1 && !m_bAddValue)
	{
		//Row expand (if group only)
		if (!ExpandRow(idx))
		{
			SelectRow(idx);
			ClickRow(idx, point);

			bool bAnimButton = IsAnimButtonUnderPoint(point);

			//Value sliding
			/*if (m_dwCurSelRow!=-1 && !bAnimButton)
			{
				SetCapture();

				GetGUISubSystem()->GetCursorPos(m_ptCursor);
				m_ptStartMouse = point;
				m_bAddValue = true;
				TRACE("Start Sliding...\n");
			}*/

			if (bAnimButton)
			{
				AddRemoveAnimControlToRow(m_dwCurSelRow);
			}

		}


	}

	//Refresh
	Update();


}
示例#14
0
void BaseGrid::OnSubtitlesOpen() {
	BeginBatch();
	ClearMaps();
	UpdateMaps();

	if (GetRows()) {
		int row = context->ass->GetScriptInfoAsInt("Active Line");
		if (row < 0 || row >= GetRows())
			row = 0;

		SetActiveLine(GetDialogue(row));
		SelectRow(row);
	}

	ScrollTo(context->ass->GetScriptInfoAsInt("Scroll Position"));

	EndBatch();
	SetColumnWidths();
}
示例#15
0
bool nuiMatrixView::Selected(uint col, uint row)
{
  if (mColumnHeader & mRowHeader & !col & !row)
  {
    if (mCanSelectAll)
      return SelectAll();
    else return true;
  }
    
  if (mColumnHeader && !row)
    return SelectColumn(col);
    
  if (mRowHeader & !col)
    return SelectRow(row);
    
  if (IsSelected(col, row))
    return SelectCell(col, row, false);
    
  return SelectCell(col, row, true);
}
示例#16
0
void ctlSQLGrid::OnLabelClick(wxGridEvent &event)
{
	int row = event.GetRow();
	int col = event.GetCol();

	// add support for (de)selecting multiple rows and cols with Control pressed
	if ( row >= 0 && (event.ControlDown() || event.CmdDown()) )
	{
		if (GetSelectedRows().Index(row) == wxNOT_FOUND)
			SelectRow(row, true);
		else
			DeselectRow(row);
	}
	else if ( col >= 0 && (event.ControlDown() || event.CmdDown()) )
	{
		if (GetSelectedCols().Index(col) == wxNOT_FOUND)
			SelectCol(col, true);
		else
			DeselectCol(col);
	}
	else
		event.Skip();
}
//---------------------------------------------------------
bool CVIEW_Table_Control::Update_Selection(void)
{
	if( GetBatchCount() == 0 )
	{
		BeginBatch();

		if( m_pTable->Get_Selection_Count() >= m_pTable->Get_Count() )
		{
			SelectAll();
		}
		else
		{
			ClearSelection();

			if( m_pTable->Get_Selection_Count() > 0 )
			{
				#pragma omp parallel for
				for(int iRecord=0; iRecord<GetNumberRows(); iRecord++)
				{
					if( m_pRecords[iRecord]->is_Selected() )
					{
						SelectRow(iRecord, true);
					}
				}
			}
		}

		EndBatch();

		_Update_Views();

		return( true );
	}

	return( false );
}
示例#18
0
void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
	int h = GetClientSize().GetHeight();
	bool shift = event.ShiftDown();
	bool alt = event.AltDown();
	bool ctrl = event.CmdDown();

	// Row that mouse is over
	bool click = event.LeftDown();
	bool dclick = event.LeftDClick();
	int row = event.GetY() / lineHeight + yPos - 1;
	if (holding && !click) {
		row = mid(0,row,GetRows()-1);
	}
	AssDialogue *dlg = GetDialogue(row);
	if (!dlg) row = 0;

	if (event.ButtonDown() && OPT_GET("Subtitle/Grid/Focus Allow")->GetBool())
		SetFocus();

	if (holding) {
		if (!event.LeftIsDown()) {
			if (dlg)
				MakeCellVisible(row, 0, false);
			holding = false;
			ReleaseMouse();
		}
		else {
			// Only scroll if the mouse has moved to a different row to avoid
			// scrolling on sloppy clicks
			if (row != extendRow) {
				if (row <= yPos)
					ScrollTo(yPos - 3);
				// When dragging down we give a 3 row margin to make it easier
				// to see what's going on, but we don't want to scroll down if
				// the user clicks on the bottom row and drags up
				else if (row > yPos + h / lineHeight - (row > extendRow ? 3 : 1))
					ScrollTo(yPos + 3);
			}
		}
	}
	else if (click && dlg) {
		holding = true;
		CaptureMouse();
	}

	if ((click || holding || dclick) && dlg) {
		int old_extend = extendRow;

		// SetActiveLine will scroll the grid if the row is only half-visible,
		// but we don't want to scroll until the mouse moves or the button is
		// released, to avoid selecting multiple lines on a click
		int old_y_pos = yPos;
		SetActiveLine(dlg);
		ScrollTo(old_y_pos);

		// Toggle selected
		if (click && ctrl && !shift && !alt) {
			bool isSel = !!selection.count(dlg);
			if (isSel && selection.size() == 1) return;
			SelectRow(row, true, !isSel);
			return;
		}

		// Normal click
		if ((click || dclick) && !shift && !ctrl && !alt) {
			if (dclick) {
				context->audioBox->ScrollToActiveLine();
				context->videoController->JumpToTime(dlg->Start);
			}
			SelectRow(row, false);
			return;
		}

		// Change active line only
		if (click && !shift && !ctrl && alt)
			return;

		// Block select
		if ((click && shift && !alt) || holding) {
			extendRow = old_extend;
			int i1 = row;
			int i2 = extendRow;

			if (i1 > i2)
				std::swap(i1, i2);

			// Toggle each
			Selection newsel;
			if (ctrl) newsel = selection;
			for (int i = i1; i <= i2; i++) {
				newsel.insert(GetDialogue(i));
			}
			SetSelectedSet(newsel);
			return;
		}

		return;
	}

	// Mouse wheel
	if (event.GetWheelRotation() != 0) {
		if (ForwardMouseWheelEvent(this, event)) {
			int step = shift ? h / lineHeight - 2 : 3;
			ScrollTo(yPos - step * event.GetWheelRotation() / event.GetWheelDelta());
		}
		return;
	}

	event.Skip();
}
示例#19
0
////////////////
// Mouse events
void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
	// Window size
	int w,h;
	GetClientSize(&w,&h);

	// Modifiers
	bool shift = event.m_shiftDown;
	bool alt = event.m_altDown;
	bool ctrl = event.m_controlDown;

	// Row that mouse is over
	bool click = event.ButtonDown(wxMOUSE_BTN_LEFT);
	bool dclick = event.LeftDClick();
	int row = event.GetY()/lineHeight + yPos - 1;
	if (holding && !click) {
		row = MID(0,row,GetRows()-1);
	}
	bool validRow = row >= 0 && row < GetRows();
	if (!validRow) row = -1;

	// Get focus
	if (event.ButtonDown()) {
		if (Options.AsBool(_T("Grid Allow Focus"))) {
			SetFocus();
		}
	}

	// Click type
	if (click && !holding && validRow) {
		holding = true;
		CaptureMouse();
	}
	if (!event.ButtonIsDown(wxMOUSE_BTN_LEFT) && holding) {
		holding = false;
		ReleaseMouse();
	}

	// Scroll to keep visible
	if (holding) {
		// Find direction
		int minVis = yPos+1;
		int maxVis = yPos+h/lineHeight-3;
		int delta = 0;
		if (row < minVis) delta = -1;
		if (row > maxVis) delta = +1;

		// Scroll
		ScrollTo(yPos+delta*3);
	}

	// Click
	if ((click || holding || dclick) && validRow) {
		// Disable extending
		extendRow = -1;

		// Toggle selected
		if (click && ctrl && !shift && !alt) {
			SelectRow(row,true,!IsInSelection(row,0));
			parentFrame->UpdateToolbar();
			return;
		}

		// Normal click
		if ((click || dclick) && !shift && !ctrl && !alt) {
			if (editBox->linen != row) editBox->SetToLine(row);
			if (dclick) video->JumpToFrame(VFR_Output.GetFrameAtTime(GetDialogue(row)->Start.GetMS(),true));
			SelectRow(row,false);
			parentFrame->UpdateToolbar();
			lastRow = row;
			return;
		}

		// Keep selection
		if (click && !shift && !ctrl && alt) {
			editBox->SetToLine(row);
			return;
		}

		// Block select
		if ((click && shift && !ctrl && !alt) || (holding && !ctrl && !alt && !shift)) {
			if (lastRow != -1) {
				// Set boundaries
				int i1 = row;
				int i2 = lastRow;
				if (i1 > i2) {
					int aux = i1;
					i1 = i2;
					i2 = aux;
				}

				// Toggle each
				bool notFirst = false;
				for (int i=i1;i<=i2;i++) {
					SelectRow(i,notFirst,true);
					notFirst = true;
				}
				parentFrame->UpdateToolbar();
			}
			return;
		}

		return;
	}

	// Popup
	if (event.ButtonDown(wxMOUSE_BTN_RIGHT)) {
		OnPopupMenu();
	}

	// Mouse wheel
	if (event.GetWheelRotation() != 0) {
		int step = 3 * event.GetWheelRotation() / event.GetWheelDelta();
		ScrollTo(yPos - step);
		return;
	}

	event.Skip();
}
示例#20
0
// Change the selection mode
void wxGridSelection::SetSelectionMode( wxGrid::wxGridSelectionModes selmode )
{
    // if selection mode is unchanged return immediately
    if (selmode == m_selectionMode)
        return;

    if ( m_selectionMode != wxGrid::wxGridSelectCells )
    {
        // if changing form row to column selection
        // or vice versa, clear the selection.
        if ( selmode != wxGrid::wxGridSelectCells )
            ClearSelection();

        m_selectionMode = selmode;
    }
    else
    {
        // if changing from cell selection to something else,
        // promote selected cells/blocks to whole rows/columns.
        size_t n;
        while ( ( n = m_cellSelection.GetCount() ) > 0 )
        {
            n--;
            wxGridCellCoords& coords = m_cellSelection[n];
            int row = coords.GetRow();
            int col = coords.GetCol();
            m_cellSelection.RemoveAt(n);
            if (selmode == wxGrid::wxGridSelectRows)
                SelectRow( row );
            else // selmode == wxGridSelectColumns)
                SelectCol( col );
        }

        // Note that m_blockSelectionTopLeft's size may be changing!
        for (n = 0; n < m_blockSelectionTopLeft.GetCount(); n++)
        {
            wxGridCellCoords& coords = m_blockSelectionTopLeft[n];
            int topRow = coords.GetRow();
            int leftCol = coords.GetCol();
            coords = m_blockSelectionBottomRight[n];
            int bottomRow = coords.GetRow();
            int rightCol = coords.GetCol();

            if (selmode == wxGrid::wxGridSelectRows)
            {
                if (leftCol != 0 || rightCol != m_grid->GetNumberCols() - 1 )
                {
                    m_blockSelectionTopLeft.RemoveAt(n);
                    m_blockSelectionBottomRight.RemoveAt(n);
                    SelectBlockNoEvent( topRow, 0,
                                 bottomRow, m_grid->GetNumberCols() - 1);
                }
            }
            else // selmode == wxGridSelectColumns)
            {
                if (topRow != 0 || bottomRow != m_grid->GetNumberRows() - 1 )
                {
                    m_blockSelectionTopLeft.RemoveAt(n);
                    m_blockSelectionBottomRight.RemoveAt(n);
                    SelectBlockNoEvent(0, leftCol,
                                 m_grid->GetNumberRows() - 1, rightCol);
                }
            }
        }

        m_selectionMode = selmode;
    }
}
示例#21
0
/////////////
// Key press
void BaseGrid::OnKeyPress(wxKeyEvent &event) {
	// Get size
	int w,h;
	GetClientSize(&w,&h);

	// Get scan code
	int key = event.KeyCode();
	bool ctrl = event.m_controlDown;
	bool alt = event.m_altDown;
	bool shift = event.m_shiftDown;

	// Left/right, forward to seek bar if video is loaded
	if (key == WXK_LEFT || key == WXK_RIGHT) {
		if (video->loaded) {
			video->ControlSlider->SetFocus();
			video->ControlSlider->AddPendingEvent(event);
			return;
		}
		event.Skip();
		return;
	}

	// Select all
	if (key == 'A' && ctrl && !alt && !shift) {
		int rows = GetRows();
		for (int i=0;i<rows;i++) SelectRow(i,true);
	}

	// Up/down
	int dir = 0;
	int step = 1;
	if (key == WXK_UP) dir = -1;
	if (key == WXK_DOWN) dir = 1;
	if (key == WXK_PRIOR) {
		dir = -1;
		step = h/lineHeight - 2;
	}
	if (key == WXK_NEXT) {
		dir = 1;
		step = h/lineHeight - 2;
	}
	if (key == WXK_HOME) {
		dir = -1;
		step = GetRows();
	}
	if (key == WXK_END) {
		dir = 1;
		step = GetRows();
	}

	// Moving
	if (dir) {
		// Move selection
		if (!ctrl && !shift && !alt) {
			// Move to extent first
			int curLine = editBox->linen;
			if (extendRow != -1) {
				curLine = extendRow;
				extendRow = -1;
			}

			int next = MID(0,curLine+dir*step,GetRows()-1);
			editBox->SetToLine(next);
			SelectRow(next);
			MakeCellVisible(next,0,false);
			return;
		}

		// Move active only
		if (alt && !shift && !ctrl) {
			extendRow = -1;
			int next = MID(0,editBox->linen+dir*step,GetRows()-1);
			editBox->SetToLine(next);
			Refresh(false);
			MakeCellVisible(next,0,false);
			return;
		}

		// Shift-selection
		if (shift && !ctrl && !alt) {
			// Find end
			if (extendRow == -1) extendRow = editBox->linen;
			extendRow = MID(0,extendRow+dir*step,GetRows()-1);

			// Set range
			int i1 = editBox->linen;
			int i2 = extendRow;
			if (i2 < i1) {
				int aux = i1;
				i1 = i2;
				i2 = aux;
			}

			// Select range
			ClearSelection();
			for (int i=i1;i<=i2;i++) {
				SelectRow(i,true);
			}

			MakeCellVisible(extendRow,0,false);
			return;
		}
	}

	// Other events, send to audio display
	if (video->audio->loaded) {
		video->audio->AddPendingEvent(event);
	}
	else event.Skip();
}
示例#22
0
void SubModelsDialog::OnNodesGridCellSelect(wxGridEvent& event)
{
    SelectRow(event.GetRow());
}
示例#23
0
void CCellView::MouseDown(BPoint where)
{
	StPenState save(this);
	
	try
	{
		bool optional = IsOptionalClick(Window()->CurrentMessage());
		
		if (!IsFocus() && !fEntering)
			MakeFocus();

		ResetOffset(-1);
	
		BRect myRect, bounds(Bounds());
		cell myCell = cell(fFrozen.h ? 1 : fPosition.h, fFrozen.v ? 1 : fPosition.v);

		if (fFirstGraphic)
		{
			if (fFirstGraphic->HandleMouseDown(where))
				return;
			else if (fFirstGraphic->HasFocus())
				fFirstGraphic->MakeFocus(false);
		}
	
		if (fCellBounds.Contains(where))
		{
			if ((PointIsInSelection(where) &&
				!fEntering) &&
				(optional ||
				WaitMouseMoved(where, false)))
			{
				StartDrag(where, optional);
			}
			else if (optional)
				GridMenu(where);
			else
				SelectCell(where);
		}
		
		if (!fShowBorders)
			return;
		
		myRect = bounds;
		myRect.top = fBorderHeight;
		myRect.left = 0.0;
		myRect.right = fBorderWidth;
	
		if (myRect.Contains(where))
		{
			if (optional)
				BorderMenu(where);
			else
			{
				do
				{
					myCell.v++;
					GetCellRect(myCell, myRect);
				}
				while (myRect.top + 2.0 <= where.y);
		
				if (where.y >= myRect.top - 2.0 && where.y <= myRect.top + 2.0)
					ResizeRow(where, myCell.v - 1);
				else
					SelectRow(where, myCell.v - 1);
			}
			return;
		}
	
		myRect.Set(fBorderWidth, 0.0, bounds.right, fBorderHeight);
	
		if (myRect.Contains(where))
		{
			if (optional)
				BorderMenu(where);
			else
			{
				do
				{
					myCell.h++;
					GetCellRect(myCell, myRect);
				}
				while (myRect.left + 2.0 <= where.x);
		
				if (where.x >= myRect.left - 2.0 && where.x <= myRect.left + 2.0)
					ResizeCol(where, myCell.h - 1);
				else
					SelectCol(where, myCell.h - 1);
			}
			return;
		}
	
		myRect.Set(0.0, 0.0, fBorderWidth, fBorderHeight);
	
		if (myRect.Contains(where))
		{
			if (!fEntering)
				SetSelection(range(1, 1, kColCount, kRowCount));
			else
				beep();
		}
	}
	
	catch(CErr& e)
	{
		CATCHED;
		e.DoError();
		return;
	}
	
	catch(...)
	{
		CATCHED;
		ASSERT(FALSE);
	}
}
示例#24
0
void BaseGrid::OnKeyDown(wxKeyEvent &event) {
	int w,h;
	GetClientSize(&w,&h);

	int key = event.GetKeyCode();
	bool ctrl = event.CmdDown();
	bool alt = event.AltDown();
	bool shift = event.ShiftDown();

	int dir = 0;
	int step = 1;
	if (key == WXK_UP) dir = -1;
	else if (key == WXK_DOWN) dir = 1;
	else if (key == WXK_PAGEUP) {
		dir = -1;
		step = h / lineHeight - 2;
	}
	else if (key == WXK_PAGEDOWN) {
		dir = 1;
		step = h / lineHeight - 2;
	}
	else if (key == WXK_HOME) {
		dir = -1;
		step = GetRows();
	}
	else if (key == WXK_END) {
		dir = 1;
		step = GetRows();
	}

	if (!dir) {
		event.Skip();
		return;
	}

	int old_extend = extendRow;
	int next = mid(0, GetDialogueIndex(active_line) + dir * step, GetRows() - 1);
	SetActiveLine(GetDialogue(next));

	// Move selection
	if (!ctrl && !shift && !alt) {
		SelectRow(next);
		return;
	}

	// Move active only
	if (alt && !shift && !ctrl) {
		Refresh(false);
		return;
	}

	// Shift-selection
	if (shift && !ctrl && !alt) {
		extendRow = old_extend;
		// Set range
		int begin = next;
		int end = extendRow;
		if (end < begin)
			std::swap(begin, end);

		// Select range
		Selection newsel;
		for (int i = begin; i <= end; i++)
			newsel.insert(GetDialogue(i));

		SetSelectedSet(newsel);

		MakeCellVisible(next, 0, false);
		return;
	}
}