Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Initial import of code already done for Xestia Address Book
[xestiaab/.git] / source / contacteditor / frmContactEditorXToken.cpp
1 #include "frmContactEditorXToken.h"
2 #include <wx/tokenzr.h>
3 #include "../common/textprocessing.h"
5 frmContactEditorXToken::frmContactEditorXToken( wxWindow* parent )
6 :
7 frmContactEditorXTokenADT( parent )
8 {
10 }
12 void frmContactEditorXToken::ProcessAction( wxCommandEvent& event )
13 {
15         long ListCtrlIndex;
16         
17         if (EditorMode == FALSE){
19                 wxString strValue;
20                 wxListItem coldata;             
21                 
22                 coldata.SetId(XTokenListIndex);
23                 coldata.SetData(XTokenListIndex);
24                 ListCtrlIndex = XTokenListCtrlPtr->InsertItem(coldata);         
25                 
26                 // Get the X-Token value.
27                 
28                 strValue = txtValue->GetValue();
29                 XTokenListPtr->insert(std::make_pair(XTokenListIndex, strValue));               
30                 
31                 // Get the X-Token name.
32                 
33                 strValue = txtTokenName->GetValue();
34                 XTokenListTokensPtr->insert(std::make_pair(XTokenListIndex, strValue));
35                 
36                 // Update form.
37                 
38                 XTokenListCtrlPtr->SetItem(ListCtrlIndex, 0, strValue);
39                 
40                 this->Close();
41                 
42         } else if (EditorMode == TRUE){
44                 long longSelected = -1; 
45                 wxString strValue;
46                 
47                 longSelected = XTokenListCtrlPtr->GetNextItem(longSelected, 
48                         wxLIST_NEXT_ALL,
49                         wxLIST_STATE_SELECTED);
50                         
51                 if (longSelected == -1){
52                         return;
53                 }
54                 
55                 // Update X-Token value.
56                 
57                 XTokenListPtr->erase(XTokenListIndex);
58                 strValue = txtValue->GetValue();
59                 XTokenListPtr->insert(std::make_pair(XTokenListIndex, strValue));               
60                 
61                 // Update X-Token name.
62                 
63                 XTokenListTokensPtr->erase(XTokenListIndex);
64                 strValue = txtTokenName->GetValue();
65                 XTokenListTokensPtr->insert(std::make_pair(XTokenListIndex, strValue));
66                 
67                 // Update form.
69                 XTokenListCtrlPtr->SetItem(longSelected, 0,strValue);
70                 
71                 this->Close();
72         
73         }
74         
75 }
77 void frmContactEditorXToken::SetEditorMode(bool EditMode)
78 {
79         // Set if the editor is adding or editing an address.
80         // FALSE = Add
81         // TRUE = Edit
82         
83         if (EditMode == FALSE){
84         
85                 EditorMode = FALSE;
86                 btnAction->SetLabel(_("Add"));
87                 this->SetTitle(_("Add X-Token"));
88         
89         } else if (EditMode == TRUE){
90         
91                 EditorMode = TRUE;
92                 btnAction->SetLabel(_("Modify"));
93                 this->SetTitle(_("Add X-Token"));
94                 
95                 std::map<int,int>::iterator intiter;
96                 std::map<int,wxString>::iterator striter;               
97                 wxString strValue;
98                 
99                 // Get the X-Token name.
100                 
101                 striter = XTokenListTokensPtr->find(XTokenListIndex);
102                  
103                 if (striter->first == XTokenListIndex){
104                 
105                         strValue = striter->second;
106                 
107                 }
108                 
109                 txtTokenName->SetValue(strValue);
110                 
111                 strValue.Clear();
112                 
113                 // Get the X-Token value.
115                 striter = XTokenListPtr->find(XTokenListIndex);
116                  
117                 if (striter->first == XTokenListIndex){
118                 
119                         strValue = striter->second;
120                 
121                 }
122                 
123                 txtValue->SetValue(strValue);
124                 
125                 strValue.Clear();               
126                 
127         }
128         
131 void frmContactEditorXToken::SetupPointers( std::map<int, wxString> *XTokenList,
132                         std::map<int, wxString> *XTokenListTokens,
133                         wxListCtrl *XTokenListCtrl,
134                         int XTokenIndex )
137         XTokenListPtr = XTokenList;
138         XTokenListTokensPtr = XTokenListTokens;
139         XTokenListCtrlPtr = XTokenListCtrl;
140         XTokenListIndex = XTokenIndex;
144 void frmContactEditorXToken::CloseWindow( wxCommandEvent& event )
146         this->Close();
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy