2 /// \file MimeExportDlg.cc
3 /// Dialog class to handle viewing/exporting of MIME card data
7 Copyright (C) 2012-2013, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #include "MimeExportDlg.h"
23 #include "windowids.h"
30 //////////////////////////////////////////////////////////////////////////////
31 // MimeExportDlg class
33 BEGIN_EVENT_TABLE(MimeExportDlg
, wxDialog
)
34 EVT_BUTTON (Dialog_MimeExport_SaveButton
,
35 MimeExportDlg::OnSaveButton
)
38 MimeExportDlg::MimeExportDlg(wxWindow
* parent
,
39 const std::string
&vdata
,
40 const std::string
&file_types
)
41 : wxDialog(parent
, Dialog_MimeExport
, _W("MIME Card Data"))
43 , m_file_types(file_types
)
45 bottom_buttons
= CreateButtonSizer(wxOK
);
47 text_ctrl_1
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, wxTE_MULTILINE
);
48 save_button
= new wxButton(this, Dialog_MimeExport_SaveButton
, _W("Save..."));
55 void MimeExportDlg::set_properties()
57 text_ctrl_1
->SetMinSize(wxSize(400, 240));
58 text_ctrl_1
->SetValidator(wxTextValidator(wxFILTER_NONE
, m_strings
.Add(m_vdata
)));
62 void MimeExportDlg::do_layout()
64 wxBoxSizer
* sizer_1
= new wxBoxSizer(wxVERTICAL
);
65 sizer_1
->Add(text_ctrl_1
, 2, wxALL
|wxEXPAND
, 10);
66 bottom_buttons
->Insert(0, save_button
, 0, wxRIGHT
, 5);
67 sizer_1
->Add(bottom_buttons
, 0, wxLEFT
|wxRIGHT
|wxBOTTOM
|wxEXPAND
, 10);
74 void MimeExportDlg::OnSaveButton(wxCommandEvent
&event
)
76 wxString
ftypes(m_file_types
.c_str(), wxConvUTF8
);
78 wxFileDialog
dlg(this, _W("Save Card as..."), _T(""), _T(""),
80 wxFD_SAVE
| wxFD_OVERWRITE_PROMPT
| wxFD_PREVIEW
);
81 if( dlg
.ShowModal() == wxID_OK
) {
82 ofstream
ofs(dlg
.GetPath().utf8_str(), ios::binary
);
83 ofs
.write(m_vdata
.data(), m_vdata
.size());