1 #include "frmContactEditorXToken.h"
2 #include <wx/tokenzr.h>
3 #include "../common/textprocessing.h"
5 frmContactEditorXToken::frmContactEditorXToken( wxWindow* parent )
7 frmContactEditorXTokenADT( parent )
12 void frmContactEditorXToken::ProcessAction( wxCommandEvent& event )
17 if (EditorMode == FALSE){
22 coldata.SetId(XTokenListIndex);
23 coldata.SetData(XTokenListIndex);
24 ListCtrlIndex = XTokenListCtrlPtr->InsertItem(coldata);
26 // Get the X-Token value.
28 strValue = txtValue->GetValue();
29 XTokenListPtr->insert(std::make_pair(XTokenListIndex, strValue));
31 // Get the X-Token name.
33 strValue = txtTokenName->GetValue();
34 XTokenListTokensPtr->insert(std::make_pair(XTokenListIndex, strValue));
38 XTokenListCtrlPtr->SetItem(ListCtrlIndex, 0, strValue);
42 } else if (EditorMode == TRUE){
44 long longSelected = -1;
47 longSelected = XTokenListCtrlPtr->GetNextItem(longSelected,
49 wxLIST_STATE_SELECTED);
51 if (longSelected == -1){
55 // Update X-Token value.
57 XTokenListPtr->erase(XTokenListIndex);
58 strValue = txtValue->GetValue();
59 XTokenListPtr->insert(std::make_pair(XTokenListIndex, strValue));
61 // Update X-Token name.
63 XTokenListTokensPtr->erase(XTokenListIndex);
64 strValue = txtTokenName->GetValue();
65 XTokenListTokensPtr->insert(std::make_pair(XTokenListIndex, strValue));
69 XTokenListCtrlPtr->SetItem(longSelected, 0,strValue);
77 void frmContactEditorXToken::SetEditorMode(bool EditMode)
79 // Set if the editor is adding or editing an address.
83 if (EditMode == FALSE){
86 btnAction->SetLabel(_("Add"));
87 this->SetTitle(_("Add X-Token"));
89 } else if (EditMode == TRUE){
92 btnAction->SetLabel(_("Modify"));
93 this->SetTitle(_("Add X-Token"));
95 std::map<int,int>::iterator intiter;
96 std::map<int,wxString>::iterator striter;
99 // Get the X-Token name.
101 striter = XTokenListTokensPtr->find(XTokenListIndex);
103 if (striter->first == XTokenListIndex){
105 strValue = striter->second;
109 txtTokenName->SetValue(strValue);
113 // Get the X-Token value.
115 striter = XTokenListPtr->find(XTokenListIndex);
117 if (striter->first == XTokenListIndex){
119 strValue = striter->second;
123 txtValue->SetValue(strValue);
131 void frmContactEditorXToken::SetupPointers( std::map<int, wxString> *XTokenList,
132 std::map<int, wxString> *XTokenListTokens,
133 wxListCtrl *XTokenListCtrl,
137 XTokenListPtr = XTokenList;
138 XTokenListTokensPtr = XTokenListTokens;
139 XTokenListCtrlPtr = XTokenListCtrl;
140 XTokenListIndex = XTokenIndex;
144 void frmContactEditorXToken::CloseWindow( wxCommandEvent& event )