#include "frmContactEditorXToken.h" #include #include "../common/textprocessing.h" frmContactEditorXToken::frmContactEditorXToken( wxWindow* parent ) : frmContactEditorXTokenADT( parent ) { } void frmContactEditorXToken::ProcessAction( wxCommandEvent& event ) { long ListCtrlIndex; if (EditorMode == FALSE){ wxString strValue; wxListItem coldata; coldata.SetId(XTokenListIndex); coldata.SetData(XTokenListIndex); ListCtrlIndex = XTokenListCtrlPtr->InsertItem(coldata); // Get the X-Token value. strValue = txtValue->GetValue(); XTokenListPtr->insert(std::make_pair(XTokenListIndex, strValue)); // Get the X-Token name. strValue = txtTokenName->GetValue(); XTokenListTokensPtr->insert(std::make_pair(XTokenListIndex, strValue)); // Update form. XTokenListCtrlPtr->SetItem(ListCtrlIndex, 0, strValue); this->Close(); } else if (EditorMode == TRUE){ long longSelected = -1; wxString strValue; longSelected = XTokenListCtrlPtr->GetNextItem(longSelected, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (longSelected == -1){ return; } // Update X-Token value. XTokenListPtr->erase(XTokenListIndex); strValue = txtValue->GetValue(); XTokenListPtr->insert(std::make_pair(XTokenListIndex, strValue)); // Update X-Token name. XTokenListTokensPtr->erase(XTokenListIndex); strValue = txtTokenName->GetValue(); XTokenListTokensPtr->insert(std::make_pair(XTokenListIndex, strValue)); // Update form. XTokenListCtrlPtr->SetItem(longSelected, 0,strValue); this->Close(); } } void frmContactEditorXToken::SetEditorMode(bool EditMode) { // Set if the editor is adding or editing an address. // FALSE = Add // TRUE = Edit if (EditMode == FALSE){ EditorMode = FALSE; btnAction->SetLabel(_("Add")); this->SetTitle(_("Add X-Token")); } else if (EditMode == TRUE){ EditorMode = TRUE; btnAction->SetLabel(_("Modify")); this->SetTitle(_("Add X-Token")); std::map::iterator intiter; std::map::iterator striter; wxString strValue; // Get the X-Token name. striter = XTokenListTokensPtr->find(XTokenListIndex); if (striter->first == XTokenListIndex){ strValue = striter->second; } txtTokenName->SetValue(strValue); strValue.Clear(); // Get the X-Token value. striter = XTokenListPtr->find(XTokenListIndex); if (striter->first == XTokenListIndex){ strValue = striter->second; } txtValue->SetValue(strValue); strValue.Clear(); } } void frmContactEditorXToken::SetupPointers( std::map *XTokenList, std::map *XTokenListTokens, wxListCtrl *XTokenListCtrl, int XTokenIndex ) { XTokenListPtr = XTokenList; XTokenListTokensPtr = XTokenListTokens; XTokenListCtrlPtr = XTokenListCtrl; XTokenListIndex = XTokenIndex; } void frmContactEditorXToken::CloseWindow( wxCommandEvent& event ) { this->Close(); }