Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
macOS: Added languages.cpp/.h to Xcode project.
[xestiaab/.git] / source / contacteditor / frmContactEditorXToken.cpp
1 // frmContactEditorXToken.cpp - frmContactEditorXToken form.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "frmContactEditorXToken.h"
20 #include <wx/tokenzr.h>
21 #include "../common/textprocessing.h"
23 frmContactEditorXToken::frmContactEditorXToken( wxWindow* parent )
24 :
25 frmContactEditorXTokenADT( parent )
26 {
28 }
30 void frmContactEditorXToken::ProcessAction( wxCommandEvent& event )
31 {
33         // Process action.
34         
35         long ListCtrlIndex;
36         
37         if (EditorMode == FALSE){
39                 wxString strValue;
40                 wxListItem coldata;             
41                 
42                 coldata.SetId(XTokenListIndex);
43                 coldata.SetData(XTokenListIndex);
44                 ListCtrlIndex = XTokenListCtrlPtr->InsertItem(coldata);         
45                 
46                 // Get the X-Token value.
47                 
48                 strValue = txtValue->GetValue();
49                 XTokenListPtr->insert(std::make_pair(XTokenListIndex, strValue));               
50                 
51                 // Get the X-Token name.
52                 
53                 strValue = txtTokenName->GetValue();
54                 XTokenListTokensPtr->insert(std::make_pair(XTokenListIndex, strValue));
55                 
56                 // Update form.
57                 
58                 XTokenListCtrlPtr->SetItem(ListCtrlIndex, 0, strValue);
59                 
60                 this->Close();
61                 
62         } else if (EditorMode == TRUE){
64                 long longSelected = -1; 
65                 wxString strValue;
66                 
67                 longSelected = XTokenListCtrlPtr->GetNextItem(longSelected, 
68                         wxLIST_NEXT_ALL,
69                         wxLIST_STATE_SELECTED);
70                         
71                 if (longSelected == -1){
72                         return;
73                 }
74                 
75                 // Update X-Token value.
76                 
77                 XTokenListPtr->erase(XTokenListIndex);
78                 strValue = txtValue->GetValue();
79                 XTokenListPtr->insert(std::make_pair(XTokenListIndex, strValue));               
80                 
81                 // Update X-Token name.
82                 
83                 XTokenListTokensPtr->erase(XTokenListIndex);
84                 strValue = txtTokenName->GetValue();
85                 XTokenListTokensPtr->insert(std::make_pair(XTokenListIndex, strValue));
86                 
87                 // Update form.
89                 XTokenListCtrlPtr->SetItem(longSelected, 0,strValue);
90                 
91                 this->Close();
92         
93         }
94         
95 }
97 void frmContactEditorXToken::SetEditorMode(bool EditMode)
98 {
99         // Set if the editor is adding or editing an address.
100         // FALSE = Add
101         // TRUE = Edit
102         
103         if (EditMode == FALSE){
104         
105                 EditorMode = FALSE;
106                 btnAction->SetLabel(_("Add"));
107                 this->SetTitle(_("Add X-Token"));
108         
109         } else if (EditMode == TRUE){
110         
111                 EditorMode = TRUE;
112                 btnAction->SetLabel(_("Modify"));
113                 this->SetTitle(_("Add X-Token"));
114                 
115                 std::map<int,int>::iterator intiter;
116                 std::map<int,wxString>::iterator striter;               
117                 wxString strValue;
118                 
119                 // Get the X-Token name.
120                 
121                 striter = XTokenListTokensPtr->find(XTokenListIndex);
122                  
123                 if (striter->first == XTokenListIndex &&
124                         striter != XTokenListTokensPtr->end()){
125                 
126                         strValue = striter->second;
127                 
128                 }
129                 
130                 txtTokenName->SetValue(strValue);
131                 
132                 strValue.Clear();
133                 
134                 // Get the X-Token value.
136                 striter = XTokenListPtr->find(XTokenListIndex);
137                  
138                 if (striter->first == XTokenListIndex &&
139                         striter != XTokenListPtr->end()){
140                 
141                         strValue = striter->second;
142                 
143                 }
144                 
145                 txtValue->SetValue(strValue);
146                 
147                 strValue.Clear();               
148                 
149         }
150         
153 void frmContactEditorXToken::SetupPointers( std::map<int, wxString> *XTokenList,
154                         std::map<int, wxString> *XTokenListTokens,
155                         wxListCtrl *XTokenListCtrl,
156                         int XTokenIndex )
159         // Setup the pointers.
160         
161         XTokenListPtr = XTokenList;
162         XTokenListTokensPtr = XTokenListTokens;
163         XTokenListCtrlPtr = XTokenListCtrl;
164         XTokenListIndex = XTokenIndex;
168 void frmContactEditorXToken::CloseWindow( wxCommandEvent& event )
170         
171         // Close the window.
172         
173         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