예제 #1
0
/// Left-click
void InstanceCtrl::OnLeftClick(wxMouseEvent& event)
{
	SetFocus();
	VisualCoord clickedIndex;
	HitTest(event.GetPosition(), clickedIndex);
	if(clickedIndex.isItem())
	{
		int flags = 0;
		if (event.ControlDown())
			flags |= wxINST_CTRL_DOWN;
		if (event.ShiftDown())
			flags |= wxINST_SHIFT_DOWN;
		if (event.AltDown())
			flags |= wxINST_ALT_DOWN;
			
		EnsureVisible(clickedIndex);
		DoSelection(clickedIndex);
		SetIntendedColumn(clickedIndex);
	}
	else if(clickedIndex.isHeaderTicker())
	{
		ToggleGroup(clickedIndex.groupIndex);
	}
	else ClearSelections();
}
예제 #2
0
void SaveButton::OnMouseUnclick(int x, int y, unsigned int button)
{
	if(button != 1)
	{
		return; //left click only!
	}

	if(x>=Size.X-20 && y>=6 && y<=20 && x<=Size.X-6 && selectable)
	{
		selected = !selected;
		DoSelection();
		return;
	}

	if(isButtonDown)
	{
		isButtonDown = false;
		if(isMouseInsideHistory)
			DoAltAction();
		else if(isMouseInsideAuthor)
			DoAltAction2();
		else
			DoAction();
	}
}
bool CSelectionKeyHandler::KeyPressed(unsigned short key)
{
	// TODO: sort the vector, and do key-based fast lookup
	for(vector<HotKey>::iterator hi=hotkeys.begin();hi!=hotkeys.end();++hi){
		if(key==hi->key && hi->shift==!!keys[SDLK_LSHIFT] && hi->control==!!keys[SDLK_LCTRL] && hi->alt==!!keys[SDLK_LALT]){
			DoSelection(hi->select);
			return true;
		}
	}
	return false;
}
예제 #4
0
void SaveButton::OnMouseClick(int x, int y, unsigned int button)
{
	if(button == SDL_BUTTON_RIGHT)
	{
		if(menu)
			menu->Show(GetScreenPos() + ui::Point(x, y));
	}
	else
	{
		isButtonDown = true;
		if(button !=1 && selectable)
		{
			selected = !selected;
			DoSelection();
		}
		
	}
}
예제 #5
0
void SaveButton::OnContextMenuAction(int item)
{
	switch(item)
	{
	case 0:
		DoAction();
		break;
	case 1:
		selected = !selected;
		DoSelection();
		break;
	case 2:
		DoAltAction();
		break;
	case 3:
		DoAltAction2();
		break;
	}
}
예제 #6
0
void DirectoryTree::SetPath(const wxString& sNewPath)
  {
  wxLogTrace(DIRECTORYTREE_EVENTS, wxT("SetPath('%s')"), sNewPath.c_str());
	if(!wxDirExists(sNewPath))
		{
		// TBI: should find best fit and set that
    wxLogDebug(wxT("SetPath(): the path '%s' does not exist"), sNewPath.c_str());
		return;
		}

  wxTreeItemId tid = PopulatePath(sNewPath);
	if(!tid.IsOk())
		{
    wxLogDebug(wxT("SetPath(): invalid wxTreeItemId returned by PopulatePath() %u"), (int) tid);
		return;
		}

	DoSelection(tid);
  }
예제 #7
0
/// Right-click
void InstanceCtrl::OnRightClick(wxMouseEvent& event)
{
	SetFocus();
	VisualCoord clickedIndex;
	int flags = 0;
	if (event.ControlDown())
		flags |= wxINST_CTRL_DOWN;
	if (event.ShiftDown())
		flags |= wxINST_SHIFT_DOWN;
	if (event.AltDown())
		flags |= wxINST_ALT_DOWN;
	HitTest(event.GetPosition(), clickedIndex);
	if (clickedIndex.isItem())
	{
		EnsureVisible(clickedIndex);
		DoSelection(clickedIndex);
		SetIntendedColumn(clickedIndex);
	}
	else
	{
		ClearSelections();
	}
	
	InstanceCtrlEvent cmdEvent(wxEVT_COMMAND_INST_MENU, GetId());
	cmdEvent.SetEventObject(this);
	cmdEvent.SetItemIndex(clickedIndex);
	int clickedID = IDFromIndex(clickedIndex);
	cmdEvent.SetItemID(clickedID);
	cmdEvent.SetFlags(flags);
	cmdEvent.SetPosition(event.GetPosition());
	if (clickedIndex.isGroup())
	{
		cmdEvent.SetGroup(m_groups[clickedIndex.groupIndex].m_group);
	}
	GetEventHandler()->ProcessEvent(cmdEvent);
}
예제 #8
0
void DirectoryTree::RemoveItem(const wxString& sPath)
  {
  // Find the item
  wxTreeItemId tidToWastebin = GetItemFromPath(sPath, false);
  if(!tidToWastebin.IsOk())
    {
    wxLogTrace(DIRECTORYTREE_EVENTS, wxT("\tNothing to remove."));
    return;
    }
  
  wxLogTrace(DIRECTORYTREE_EVENTS, wxT("GetItemFromPath('%s') returned %u"), sPath.c_str(), (int) tidToWastebin);
	// Sort out the new selection
  wxTreeItemId tidSelection = GetSelection();
  if(!tidSelection.IsOk())
    // FIXME: Should throw exception
    return;

  wxTreeItemId tidNewSelection;
  if(tidSelection == tidToWastebin)
    tidNewSelection = GetItemParent(tidSelection);
  else
    {
		// If we are in or below the path, climb up to directory above
    bool bIsParent = IsAncestorOf(tidToWastebin, tidSelection);
    wxLogTrace(DIRECTORYTREE_EVENTS, wxT("\tIsAncestorOf() returned %u"), bIsParent);
    if(bIsParent)
      tidNewSelection = GetItemParent(tidSelection);
    }

  // Remove item
  Delete(tidToWastebin);

  // Re select if necessary
  if(tidNewSelection.IsOk())
    DoSelection(tidNewSelection);
	}
예제 #9
0
// Event handler for Page up/down and direction keys
void CodeView::OnKeyPress(wxKeyEvent& event)
{
    int key;
    ProgramAddress address;
    key = event.GetKeyCode();

    wxCommandEvent evtMakeData(wxEVT_MENU, idPOPUP_MAKEDATA);
    wxCommandEvent evtDisassemble(wxEVT_MENU, idPOPUP_DISASM);
    wxScrollWinEvent evtLineDown(wxEVT_SCROLLWIN_LINEDOWN);
    wxScrollWinEvent evtLineUp(wxEVT_SCROLLWIN_LINEUP);
    wxScrollWinEvent evtPageDown(wxEVT_SCROLLWIN_PAGEDOWN);
    wxScrollWinEvent evtPageUp(wxEVT_SCROLLWIN_PAGEUP);

#define C_KEY   67
#define D_KEY   68

    switch (key)
    {
        case WXK_DOWN:
                        if (line_info.cursorPosition < static_cast<int>(m_CodeViewLine->GetCount() - 1))
                        {
                            if (!MultiSelection)
                                line_info.cursorLastPosition = line_info.cursorPosition;

                            line_info.cursorPosition++;

                            ClearCursor();
                            DoSelection();

                            if (line_info.cursorPosition > GetLastLine())
                                AddPendingEvent(evtLineDown);
                            else
                                RefreshRect(CalcCursorRfshRect());

                            if (line_info.selectedLineCount == 1)
                                TreatSingleSelection();
                            else
                                if (line_info.selectedLineCount > 1)
                                    TreatMultiSelection();

                            if (Selecting)
                                LogIt(wxString::Format("Selection = (%d, %d)", line_info.firstLine, line_info.lastLine));
                        }
                        break;
        case WXK_UP:
                        if (line_info.cursorPosition > 0)
                        {
                            if (!MultiSelection)
                                line_info.cursorLastPosition = line_info.cursorPosition;

                            line_info.cursorPosition--;

                            ClearCursor();
                            DoSelection();

                            if (line_info.cursorPosition < GetFirstLine())
                                AddPendingEvent(evtLineUp);
                            else
                                RefreshRect(CalcCursorRfshRect());

                            if (line_info.selectedLineCount == 1)
                                TreatSingleSelection();
                            else
                                if (line_info.selectedLineCount > 1)
                                    TreatMultiSelection();

                            if (Selecting)
                                LogIt(wxString::Format("Selection = (%d, %d)", line_info.firstLine, line_info.lastLine));
                        }
                        break;
        case WXK_NUMPAD_PAGEDOWN:
        case WXK_PAGEDOWN:
                        AddPendingEvent(evtPageDown);
                        break;
        case WXK_NUMPAD_PAGEUP:
        case WXK_PAGEUP:
                        AddPendingEvent(evtPageUp);
                        break;
        case WXK_SHIFT:
                        if (!Selecting)
							Selecting = true;
                        MultiSelection = true;
                        break;
        case C_KEY:
                        AddPendingEvent(evtDisassemble);
                        break;
        case D_KEY:
                        AddPendingEvent(evtMakeData);
                        break;
        case WXK_F3:
                        if (Process->SearchInstructionArgumentContinue(address))
                        {
                            CenterAddress(address);
                        }

                        LogIt("F3 Key pressed !");
                        break;

        default:
                        LogIt(wxString::Format("%X pressed !",key));
                        event.Skip();
    }
}
예제 #10
0
/// Keyboard navigation
bool InstanceCtrl::Navigate(int keyCode, int flags)
{
	if (GetCount() == 0)
		return false;
	
	wxSize clientSize = GetClientSize();
	int perRow = GetItemsPerRow();
	
	VisualCoord focus = m_focusItem;
	if (focus.isVoid())
		focus = m_selectedItem;
	
	if (focus.isVoid())
	{
		m_selectedItem = VisualCoord(0,0);
		DoSelection(m_selectedItem);
		EnsureVisible(m_selectedItem);
		SetIntendedColumn(m_selectedItem);
		Refresh();
		return true;
	}
	VisualCoord next = focus;
	
	GroupVisual & gv = m_groups[next.groupIndex];
	
	if (keyCode == WXK_RIGHT)
	{
		if(next.itemIndex < gv.items.Count() - 1)
		{
			next.itemIndex ++;
		}
		else if(next.groupIndex < m_groups.size() - 1)
		{
			next.itemIndex = 0;
			while(next.groupIndex < m_groups.size() - 1)
			{
				next.groupIndex++;
				if(m_groups[next.groupIndex].IsExpanded())
				{
					DoSelection(next);
					EnsureVisible(next);
					SetIntendedColumn(next);
					return true;
				}
			}
			return false;
		}
		else
		{
			return false;
		}
		DoSelection(next);
		EnsureVisible(next);
		SetIntendedColumn(next);
	}
	else if (keyCode == WXK_LEFT)
	{
		if(next.itemIndex > 0)
		{
			next.itemIndex --;
		}
		else if(next.groupIndex > 0)
		{
			while (next.groupIndex > 0)
			{
				next.groupIndex--;
				next.itemIndex = m_groups[next.groupIndex].items.size() - 1;
				if(m_groups[next.groupIndex].IsExpanded())
				{
					DoSelection(next);
					EnsureVisible(next);
					SetIntendedColumn(next);
					return true;
				}
			}
			return false;
		}
		else
		{
			return false;
		}
		DoSelection(next);
		EnsureVisible(next);
		SetIntendedColumn(next);
	}
	else if (keyCode == WXK_UP)
	{
		if (next.itemIndex >= m_itemsPerRow)
		{
			int row = next.itemIndex / m_itemsPerRow;
			int prev = row - 1;
			next.itemIndex = prev * m_itemsPerRow + m_intended_column;
		}
		else if(next.groupIndex > 0)
		{
			while(next.groupIndex > 0)
			{
				next.groupIndex--;
				if(!m_groups[next.groupIndex].IsExpanded())
					continue;
				int num_items = m_groups[next.groupIndex].items.size();
				int lastRowItems = num_items % m_itemsPerRow;
				int lastRow = num_items / m_itemsPerRow;
				if(!lastRowItems)
				{
					lastRowItems = m_itemsPerRow;
					lastRow --;
				}
				if(m_intended_column < lastRowItems)
				{
					next.itemIndex = lastRow * m_itemsPerRow + m_intended_column;
				}
				else
				{
					next.itemIndex = num_items - 1;
				}
				DoSelection(next);
				EnsureVisible(next);
				return true;
			}
			return false;
		}
		else
		{
			return false;
		}
		DoSelection(next);
		EnsureVisible(next);
	}
	else if (keyCode == WXK_DOWN)
	{
		// some fun little numbers that decide what to do
		int numitems = gv.items.size();
		int rows = numitems / m_itemsPerRow + (numitems % m_itemsPerRow != 0);
		int row = next.itemIndex / m_itemsPerRow;
		//int rowpos = next.itemIndex % m_itemsPerRow;
		
		if (next.itemIndex + m_itemsPerRow < gv.items.size())
		{
			next.itemIndex += m_itemsPerRow;
		}
		// there is an another row in this group, but it's not full. move to the last item in group
		else if(row < rows - 1)
		{
			next.itemIndex = gv.items.size() - 1;
		}
		else if(next.groupIndex < m_groups.size() - 1)
		{
			while (next.groupIndex < m_groups.size() - 1)
			{
				next.groupIndex ++;
				if(!m_groups[next.groupIndex].IsExpanded())
					continue;
				int num_items = m_groups[next.groupIndex].items.size();
				if(m_intended_column < num_items)
				{
					next.itemIndex = m_intended_column;
				}
				else
				{
					next.itemIndex = num_items - 1;
				}
				DoSelection(next);
				EnsureVisible(next);
				return true;
			}
			return false;
		}
		else
		{
			return false;
		}
		DoSelection(next);
		EnsureVisible(next);
	}
	else if (keyCode == WXK_HOME)
	{
		if(next.itemIndex != 0 && gv.IsExpanded())
		{
			// go to start of this group
			next.itemIndex = 0;
		}
		else
		{
			// go to first item of first visible group
			for(int i = 0; i < m_groups.size(); i++)
			{
				if(m_groups[i].IsExpanded())
				{
					next.groupIndex = i;
					next.itemIndex = 0;
					break;
				}
			}
		}
		DoSelection(next);
		EnsureVisible(next);
		SetIntendedColumn(next);
	}
	else if (keyCode == WXK_END)
	{
		if(next.itemIndex != gv.items.size() - 1 && gv.IsExpanded())
		{
			// go to end of this group
			next.itemIndex = gv.items.size() - 1;
		}
		else
		{
			// go to last item of last visible group
			for(int i = m_groups.size() - 1; i >=0 ; i--)
			{
				if(m_groups[i].IsExpanded())
				{
					next.groupIndex = i;
					next.itemIndex = m_groups[i].items.size() - 1;
					break;
				}
			}
		}
		DoSelection(next);
		EnsureVisible(next);
		SetIntendedColumn(next);
	}
	/*
	else if (keyCode == WXK_TAB)
	{
		int next = focus;
		if (flags & wxINST_SHIFT_DOWN)
			next --;
		else
			next ++;
		if (next >= 0 && next < GetCount())
		{
			DoSelection(next);
			ScrollIntoView(next, keyCode);
		}
	}*/
	return true;
}