1 #include "frmContactEditorVendor.h"
2 #include <wx/tokenzr.h>
3 #include "../common/textprocessing.h"
5 frmContactEditorVendor::frmContactEditorVendor( wxWindow* parent )
7 frmContactEditorVendorADT( parent )
12 void frmContactEditorVendor::SetEditorMode(bool EditMode)
14 // Set if the editor is adding or editing an address.
18 if (EditMode == FALSE){
21 btnAction->SetLabel(_("Add"));
22 this->SetTitle(_("Add Vendor Namespace"));
24 } else if (EditMode == TRUE){
27 btnAction->SetLabel(_("Modify"));
28 this->SetTitle(_("Add Vendor Namespace"));
30 std::map<int,int>::iterator intiter;
31 std::map<int,wxString>::iterator striter;
34 // Get the vendor PEN.
36 striter = VendorListPENPtr->find(VendorListIndex);
38 if (striter->first == VendorListIndex){
40 strValue = striter->second;
44 txtPEN->SetValue(strValue);
48 // Get the vendor element.
50 striter = VendorListElementPtr->find(VendorListIndex);
52 if (striter->first == VendorListIndex){
54 strValue = striter->second;
58 txtElement->SetValue(strValue);
62 // Get the vendor value.
64 striter = VendorListPtr->find(VendorListIndex);
66 if (striter->first == VendorListIndex){
68 strValue = striter->second;
72 txtValue->SetValue(strValue);
80 void frmContactEditorVendor::ProcessAction( wxCommandEvent& event )
83 if (EditorMode == FALSE){
90 coldata.SetId(VendorListIndex);
91 coldata.SetData(VendorListIndex);
92 ListCtrlIndex = VendorListCtrlPtr->InsertItem(coldata);
96 strValue = txtPEN->GetValue();
97 VendorListPENPtr->insert(std::make_pair(VendorListIndex, strValue));
99 // Get Vendor Element.
101 strValue = txtElement->GetValue();
102 VendorListElementPtr->insert(std::make_pair(VendorListIndex, strValue));
106 strValue = txtValue->GetValue();
107 VendorListPtr->insert(std::make_pair(VendorListIndex, strValue));
111 strVNDID = txtPEN->GetValue() + wxT("-") + txtElement->GetValue();
113 VendorListCtrlPtr->SetItem(ListCtrlIndex, 0, strVNDID);
117 } else if (EditorMode == TRUE){
119 long longSelected = -1;
123 longSelected = VendorListCtrlPtr->GetNextItem(longSelected,
125 wxLIST_STATE_SELECTED);
127 if (longSelected == -1){
131 // Update Vendor PEN.
133 VendorListPENPtr->erase(VendorListIndex);
134 strValue = txtPEN->GetValue();
135 VendorListPENPtr->insert(std::make_pair(VendorListIndex, strValue));
137 // Update Vendor Element.
139 VendorListElementPtr->erase(VendorListIndex);
140 strValue = txtValue->GetValue();
141 VendorListElementPtr->insert(std::make_pair(VendorListIndex, strValue));
143 // Update Vendor Value.
145 VendorListPtr->erase(VendorListIndex);
146 strValue = txtValue->GetValue();
147 VendorListPtr->insert(std::make_pair(VendorListIndex, strValue));
151 strVNDID = txtPEN->GetValue() + wxT("-") + txtElement->GetValue();
152 VendorListCtrlPtr->SetItem(longSelected, 0, strVNDID);
159 void frmContactEditorVendor::SetupPointers( std::map<int, wxString> *VendorList,
160 std::map<int, wxString> *VendorListPEN,
161 std::map<int, wxString> *VendorListElement,
162 wxListCtrl *VendorListCtrl,
166 VendorListPtr = VendorList;
167 VendorListPENPtr = VendorListPEN;
168 VendorListElementPtr = VendorListElement;
169 VendorListCtrlPtr = VendorListCtrl;
170 VendorListIndex = VendorIndex;
174 void frmContactEditorVendor::CloseWindow( wxCommandEvent& event )