예제 #1
0
/// Key press
void InstanceCtrl::OnChar(wxKeyEvent& event)
{
	int flags = 0;
	if (event.ControlDown())
		flags |= wxINST_CTRL_DOWN;
	if (event.ShiftDown())
		flags |= wxINST_SHIFT_DOWN;
	if (event.AltDown())
		flags |= wxINST_ALT_DOWN;
	
	if (event.GetKeyCode() == WXK_LEFT ||
	    event.GetKeyCode() == WXK_RIGHT ||
	    event.GetKeyCode() == WXK_UP ||
	    event.GetKeyCode() == WXK_DOWN ||
	    event.GetKeyCode() == WXK_HOME ||
	    event.GetKeyCode() == WXK_PAGEUP ||
	    event.GetKeyCode() == WXK_PAGEDOWN ||
	    event.GetKeyCode() == WXK_END)
	{
		Navigate(event.GetKeyCode(), flags);
	}

	if (event.GetKeyCode() == WXK_RETURN)
	{
		InstanceCtrlEvent cmdEvent(
		    wxEVT_COMMAND_INST_ACTIVATE,
		    GetId());
		cmdEvent.SetEventObject(this);
		cmdEvent.SetFlags(flags);
		GetEventHandler()->ProcessEvent(cmdEvent);
	}
	else if (event.GetKeyCode() == WXK_DELETE)
	{
		InstanceCtrlEvent cmdEvent(
		    wxEVT_COMMAND_INST_DELETE,
		    GetId());
		cmdEvent.SetEventObject(this);
		cmdEvent.SetFlags(flags);
		GetEventHandler()->ProcessEvent(cmdEvent);
	}
	else if (event.GetKeyCode() == WXK_F2)
	{
		InstanceCtrlEvent cmdEvent(
		    wxEVT_COMMAND_INST_RENAME,
		    GetId());
		cmdEvent.SetEventObject(this);
		cmdEvent.SetFlags(flags);
		GetEventHandler()->ProcessEvent(cmdEvent);
	}
	else
		event.Skip();
}
예제 #2
0
void CompareDlg::OnCompare(wxCommandEvent& )
{
  if ( Validate() && TransferDataFromWindow()) {
    if (wxFileName(m_dbPanel->m_filepath).SameAs(towxstring(m_otherCore->GetCurFile())) ||
        ReadCore(*m_otherCore, m_dbPanel->m_filepath, m_dbPanel->m_combination,
                 true, this, true) == PWScore::SUCCESS) {
      m_otherCore->SetCurFile(tostringx(m_dbPanel->m_filepath));
      m_otherCore->SetReadOnly(true);

      // TODO: must copy the selectionCriteria from advanced options pane.  Or else
      // the search would always be conducted on default field criteria
      m_current->data.clear();
      m_comparison->data.clear();
      m_conflicts->data.clear();
      m_identical->data.clear();

      m_conflicts->pane->Collapse();
      m_current->pane->Collapse();
      m_comparison->pane->Collapse();
      m_identical->pane->Collapse();

      wxCommandEvent cmdEvent(EVT_START_COMPARISON, GetId());
      GetEventHandler()->AddPendingEvent(cmdEvent);
    }
  }
  else {
    m_otherCore->SetCurFile(StringX());
  }
}
예제 #3
0
void InstanceCtrl::OnMouseMotion(wxMouseEvent& event)
{
	// Only start DnD if the mouse is over the selected instance.
	VisualCoord coord;
	HitTest(event.GetPosition(), coord);
	InstanceVisual *instVisual = GetItem(coord);

	if (event.Dragging() && instVisual && m_instList->GetSelectedInstance() == instVisual->GetInstance())
	{
		int flags = 0;
		if (event.ControlDown())
			flags |= wxINST_CTRL_DOWN;
		if (event.ShiftDown())
			flags |= wxINST_SHIFT_DOWN;
		if (event.AltDown())
			flags |= wxINST_ALT_DOWN;

		InstanceCtrlEvent cmdEvent(
			wxEVT_COMMAND_INST_DRAG,
			GetId());
		cmdEvent.SetEventObject(this);
		cmdEvent.SetFlags(flags);
		GetEventHandler()->ProcessEvent(cmdEvent);
	}
	else
	{
		event.Skip();
	}
}
예제 #4
0
/// Left-double-click
void InstanceCtrl::OnLeftDClick(wxMouseEvent& event)
{
	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;
			
		InstanceCtrlEvent cmdEvent(
		    wxEVT_COMMAND_INST_ACTIVATE,
		    GetId());
		cmdEvent.SetEventObject(this);
		cmdEvent.SetItemIndex(clickedIndex);
		int clickedID = IDFromIndex(clickedIndex);
		cmdEvent.SetItemID(clickedID);
		cmdEvent.SetFlags(flags);
		cmdEvent.SetPosition(event.GetPosition());
		GetEventHandler()->ProcessEvent(cmdEvent);
	}
	else if(clickedIndex.isHeader())
	{
		ToggleGroup(clickedIndex.groupIndex);
	}
}
예제 #5
0
 void Command::HandlerListener::HandlerChanged(HandlerEvent::Pointer handlerEvent) {
   bool enabledChanged = handlerEvent->IsEnabledChanged();
   bool handledChanged = handlerEvent->IsHandledChanged();
   CommandEvent::Pointer cmdEvent(new CommandEvent(Command::Pointer(command), false,
       false, false, handledChanged, false, false, false,
       false, enabledChanged));
   command->FireCommandChanged(cmdEvent);
 }
예제 #6
0
bool Command::SetHandler(const IHandler::Pointer handler)
{
  if (handler == this->handler)
  {
    return false;
  }

  // Swap the state around.
  const QList<QString> stateIds(this->GetStateIds());
  for (int i = 0; i < stateIds.size(); ++i)
  {
    const QString stateId = stateIds[i];
    if (IObjectWithState::Pointer stateHandler = this->handler.Cast<IObjectWithState>())
    {
      stateHandler->RemoveState(stateId);
    }
    if (IObjectWithState::Pointer stateHandler = handler.Cast<IObjectWithState>())
    {
      const State::Pointer stateToAdd(this->GetState(stateId));
      stateHandler->AddState(stateId, stateToAdd);
    }
  }

  bool enabled = this->IsEnabled();
  if (this->handler)
  {
    this->handler->RemoveHandlerListener(this->GetHandlerListener());
  }

  // Update the handler, and flush the string representation.
  this->handler = handler;
  if (this->handler)
  {
    this->handler->AddHandlerListener(this->GetHandlerListener());
  }
  this->str = "";

  // Debugging output
  if ((DEBUG_HANDLERS)
      && ((DEBUG_HANDLERS_COMMAND_ID.isEmpty()) || (DEBUG_HANDLERS_COMMAND_ID == id)))
  {
    QString buffer("Command('");
    buffer += id + "') has changed to ";
    if (!handler) {
      buffer += "no handler";
    } else {
      buffer += "\'" + handler->ToString() + "' as its handler";
    }
    CommandTracing::PrintTrace("HANDLERS", buffer);
  }

  // Send notification
  CommandEvent::Pointer cmdEvent(new CommandEvent(Command::Pointer(this), false, false, false, true,
                                                  false, false, false, false, enabled != this->IsEnabled()));
  this->FireCommandChanged(cmdEvent);

  return true;
}
예제 #7
0
void Command::HandlerChanged(const SmartPointer<HandlerEvent>& handlerEvent)
{
  bool enabledChanged = handlerEvent->IsEnabledChanged();
  bool handledChanged = handlerEvent->IsHandledChanged();
  CommandEvent::Pointer cmdEvent(new CommandEvent(Command::Pointer(this), false,
                                                  false, false, handledChanged, false, false, false,
                                                  false, enabledChanged));
  this->FireCommandChanged(cmdEvent);
}
예제 #8
0
void Command::Undefine()
{
  bool enabledChanged = this->IsEnabled();

  str = "";

  const bool definedChanged = defined;
  defined = false;

  const bool nameChanged = !name.isEmpty();
  name = "";

  const bool descriptionChanged = !description.isEmpty();
  description = "";

  const bool categoryChanged = category;
  category = nullptr;

  const bool parametersChanged = !parameters.empty();
  parameters.clear();

  const bool returnTypeChanged = returnType;
  returnType = nullptr;

  const QList<QString> stateIds(this->GetStateIds());
  if (IObjectWithState::Pointer handlerWithState = handler.Cast<IObjectWithState>())
  {
    for (int i = 0; i < stateIds.size(); i++)
    {
      const QString stateId(stateIds[i]);
      handlerWithState->RemoveState(stateId);

      const State::Pointer state(this->GetState(stateId));
      this->RemoveState(stateId);
      //state.dispose();
    }
  }
  else
  {
    for (int i = 0; i < stateIds.size(); ++i)
    {
      const QString stateId(stateIds[i]);
      const State::Pointer state(this->GetState(stateId));
      this->RemoveState(stateId);
      //state.dispose();
    }
  }

  CommandEvent::Pointer cmdEvent(new CommandEvent(Command::Pointer(this), categoryChanged,
                                                  definedChanged, descriptionChanged, false, nameChanged,
                                                  parametersChanged, returnTypeChanged, false, enabledChanged));
  this->FireCommandChanged(cmdEvent);
}
예제 #9
0
파일: spinctrl.cpp 프로젝트: pc1cp/pappsdr
void wxCustomSpinCtrl::onTextEnter( wxCommandEvent& WXUNUSED( event ) )
{
    double number;
    if( m_TextControl->GetValue().ToDouble(&number) )
    {
        m_Value = number;

        wxSpinEvent event;
        event.SetId( m_ID );
        m_Parent->GetEventHandler()->AddPendingEvent( event );

        wxCommandEvent cmdEvent(wxEVT_CUSTOM_SPINCTRL);
        cmdEvent.SetId( m_ID );
        m_Parent->GetEventHandler()->AddPendingEvent( cmdEvent );
    }
    printValue( m_Value );
}
예제 #10
0
파일: spinctrl.cpp 프로젝트: pc1cp/pappsdr
void wxCustomSpinCtrl::onSpinUp( wxSpinEvent& WXUNUSED(event) )
{
    m_Value += m_Increment;
    if( m_Value > m_MaxValue )
    {
        m_Value = m_MaxValue;
    }

    printValue( m_Value );

    wxSpinEvent event;
    event.SetId( m_ID );
    m_Parent->GetEventHandler()->AddPendingEvent( event );
    std::cerr << "wxSpinEvent sent.\n";

    wxCommandEvent cmdEvent(wxEVT_CUSTOM_SPINCTRL);
    cmdEvent.SetId( m_ID );
    m_Parent->GetEventHandler()->AddPendingEvent( cmdEvent );
}
예제 #11
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);
}
예제 #12
0
void CompareDlg::DoCompare(wxCommandEvent& /*evt*/)
{
  bool treatWhitespacesAsEmpty = false;
  m_currentCore->Compare(m_otherCore,
                         m_selCriteria->GetSelectedFields(),
                         m_selCriteria->HasSubgroupRestriction(),
                         treatWhitespacesAsEmpty,
                         tostdstring(m_selCriteria->SubgroupSearchText()),
                         m_selCriteria->SubgroupObject(),
                         m_selCriteria->SubgroupFunction(),
                         m_current->data,
                         m_comparison->data,
                         m_conflicts->data,
                         m_identical->data);

  struct {
    ComparisonData* cd;
    bool expand;
    bool multiSource;
    bool useComparisonSafe; ////unused if multisource is true
  } sections[] = { {m_conflicts,  true,  true,  false},
                   {m_current,    true,  false, false},
                   {m_comparison, true,  false, true},
                   {m_identical,  false, false, false}
  };
  wxSizerItem* prevSizer = 0;
  for(size_t idx =0; idx < WXSIZEOF(sections); ++idx) {
    ComparisonGridTable* table;
    if (sections[idx].multiSource) {
      table = new MultiSafeCompareGridTable(m_selCriteria,
                                            &sections[idx].cd->data,
                                            m_currentCore,
                                            m_otherCore);
    }
    else {
      table = new UniSafeCompareGridTable(m_selCriteria,
                                          &sections[idx].cd->data,
                                          sections[idx].useComparisonSafe? m_otherCore: m_currentCore,
                                          sections[idx].useComparisonSafe? &st_CompareData::uuid1: &st_CompareData::uuid0,
                                          sections[idx].useComparisonSafe? ComparisonBackgroundColor: CurrentBackgroundColor);
    }
    sections[idx].cd->grid->SetTable(table, true, wxGrid::wxGridSelectRows);
    wxCollapsiblePane* pane = sections[idx].cd->pane;
    //expand the columns to show these fields fully, as these are usually small(er) strings
    table->AutoSizeField(CItemData::GROUP);
    table->AutoSizeField(CItemData::TITLE);
    table->AutoSizeField(CItemData::USER);
    table->AutoSizeField(CItemData::PASSWORD);
    /*
    // wxCollapsiblePane::GetLabel() doesn't work
    wxString newLabel(pane->GetLabel());
    newLabel << wxT(" (") << sections[idx].cd->data.size() << wxT(")");
    pane->SetLabel(newLabel);
    */
    if (!sections[idx].cd->data.empty()) {
      pane->Show();
      //if the next pane is displayed, show the sizer below this pane
      if (prevSizer)
        prevSizer->Show(true);
      prevSizer = sections[idx].cd->sizerBelow;
    }
    else {
      pane->Collapse();
      pane->Hide();
    }
  }
  wxCommandEvent cmdEvent(EVT_EXPAND_DATA_PANELS, GetId());
  GetEventHandler()->AddPendingEvent(cmdEvent);
}
예제 #13
0
void CSafeCombinationEntry::CreateControls()
{
////@begin CSafeCombinationEntry content construction
  CSafeCombinationEntry* itemDialog1 = this;

  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
  itemDialog1->SetSizer(itemBoxSizer2);

  wxStaticBitmap* itemStaticBitmap3 = new wxStaticBitmap( itemDialog1, wxID_STATIC, itemDialog1->GetBitmapResource(wxT("graphics/cpane.xpm")), wxDefaultPosition, itemDialog1->ConvertDialogToPixels(wxSize(49, 46)), 0 );
  itemBoxSizer2->Add(itemStaticBitmap3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

  wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL);
  itemBoxSizer2->Add(itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

  wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL);
  itemBoxSizer4->Add(itemBoxSizer5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);

  wxStaticBitmap* itemStaticBitmap6 = new wxStaticBitmap( itemDialog1, wxID_STATIC, itemDialog1->GetBitmapResource(wxT("graphics/psafetxt.xpm")), wxDefaultPosition, wxDefaultSize, 0 );
  itemBoxSizer5->Add(itemStaticBitmap6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

  m_version = new wxStaticText( itemDialog1, wxID_STATIC, _("VX.YY"), wxDefaultPosition, wxDefaultSize, 0 );
  itemBoxSizer5->Add(m_version, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

  wxStaticText* itemStaticText8 = new wxStaticText( itemDialog1, wxID_STATIC, _("Open Password Database:"), wxDefaultPosition, wxDefaultSize, 0 );
  itemBoxSizer4->Add(itemStaticText8, 0, wxALIGN_LEFT|wxALL, 3);

  wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxHORIZONTAL);
  itemBoxSizer4->Add(itemBoxSizer9, 50, wxGROW|wxALL, 5);

  wxArrayString m_filenameCBStrings;
  m_filenameCB = new wxComboBox( itemDialog1, ID_DBASECOMBOBOX, wxEmptyString, wxDefaultPosition, wxSize(itemDialog1->ConvertDialogToPixels(wxSize(140, -1)).x, -1), m_filenameCBStrings, wxCB_DROPDOWN );
  itemBoxSizer9->Add(m_filenameCB, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 0);

  wxButton* itemButton11 = new wxButton( itemDialog1, ID_ELLIPSIS, wxT("..."), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
  itemBoxSizer9->Add(itemButton11, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

  wxStaticText* itemStaticText12 = new wxStaticText( itemDialog1, wxID_STATIC, _("Safe Combination:"), wxDefaultPosition, wxDefaultSize, 0 );
  itemBoxSizer4->Add(itemStaticText12, 0, wxALIGN_LEFT|wxALL, 3);

  m_combinationEntry = new CSafeCombinationCtrl( itemDialog1, ID_COMBINATION, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
  itemBoxSizer4->Add(m_combinationEntry, 0, wxGROW|wxRIGHT|wxTOP|wxBOTTOM, 5);

  wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxHORIZONTAL);
  itemBoxSizer4->Add(itemBoxSizer14, 0, wxGROW|wxALL, 5);

  wxCheckBox* itemCheckBox15 = new wxCheckBox( itemDialog1, ID_READONLY, _("Open as read-only"), wxDefaultPosition, wxDefaultSize, 0 );
  itemCheckBox15->SetValue(false);
  itemBoxSizer14->Add(itemCheckBox15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);

  itemBoxSizer14->Add(120, 10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);

  wxButton* itemButton17 = new wxButton( itemDialog1, ID_NEWDB, _("New..."), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
  itemBoxSizer14->Add(itemButton17, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);

  wxBoxSizer* itemBoxSizer18 = new wxBoxSizer(wxHORIZONTAL);
  itemBoxSizer4->Add(itemBoxSizer18, 0, wxGROW|wxALL, 5);

#ifndef NO_YUBI
  m_YubiBtn = new wxBitmapButton( itemDialog1, ID_YUBIBTN, itemDialog1->GetBitmapResource(wxT("graphics/Yubikey-button.xpm")), wxDefaultPosition, itemDialog1->ConvertDialogToPixels(wxSize(40, 15)), wxBU_AUTODRAW );
  itemBoxSizer18->Add(m_YubiBtn, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM|wxSHAPED, 5);

  m_yubiStatusCtrl = new wxStaticText( itemDialog1, ID_YUBISTATUS, _("Please insert your YubiKey"), wxDefaultPosition, wxDefaultSize, 0 );
  itemBoxSizer18->Add(m_yubiStatusCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
#endif

  wxStdDialogButtonSizer* itemStdDialogButtonSizer21 = new wxStdDialogButtonSizer;

  itemBoxSizer4->Add(itemStdDialogButtonSizer21, 0, wxGROW|wxALL, 0);
  wxButton* itemButton22 = new wxButton( itemDialog1, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
  itemButton22->SetDefault();
  itemStdDialogButtonSizer21->AddButton(itemButton22);

  wxButton* itemButton23 = new wxButton( itemDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
  itemStdDialogButtonSizer21->AddButton(itemButton23);

  wxButton* itemButton24 = new wxButton( itemDialog1, wxID_HELP, _("&Help"), wxDefaultPosition, wxDefaultSize, 0 );
  itemStdDialogButtonSizer21->AddButton(itemButton24);

  itemStdDialogButtonSizer21->Realize();

  // Set validators
  m_filenameCB->SetValidator( wxGenericValidator(& m_filename) );
  itemCheckBox15->SetValidator( wxGenericValidator(& m_readOnly) );
////@end CSafeCombinationEntry content construction
  m_combinationEntry->SetValidatorTarget(& m_password);

#if (REVISION == 0)
  m_version->SetLabel(wxString::Format(wxT("V%d.%d %ls"),
                                       MAJORVERSION, MINORVERSION, SPECIALBUILD));
#else
  m_version->SetLabel(wxString::Format(wxT("V%d.%d.%d %ls"),
                                       MAJORVERSION, MINORVERSION,
                                       REVISION, SPECIALBUILD));
#endif
  wxArrayString recentFiles;
  wxGetApp().recentDatabases().GetAll(recentFiles);
  m_filenameCB->Append(recentFiles);
  // The underlying native combobox widget might not yet be ready
  //  to hand back the string we just added
  wxCommandEvent cmdEvent(wxEVT_COMMAND_COMBOBOX_SELECTED, m_filenameCB->GetId());
  GetEventHandler()->AddPendingEvent(cmdEvent);
  SetIcons(wxGetApp().GetAppIcons());
}