debian: made the changelog more verbose as per intrigeri's feedback
[barry.git] / desktop / src / MimeExportDlg.cc
blob835c5443352dcc72df5299f9133c764ef7efa05d
1 ///
2 /// \file MimeExportDlg.cc
3 /// Dialog class to handle viewing/exporting of MIME card data
4 ///
6 /*
7 Copyright (C) 2012, 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"
24 #include <iostream>
25 #include <fstream>
27 using namespace std;
29 //////////////////////////////////////////////////////////////////////////////
30 // MimeExportDlg class
32 BEGIN_EVENT_TABLE(MimeExportDlg, wxDialog)
33 EVT_BUTTON (Dialog_MimeExport_SaveButton,
34 MimeExportDlg::OnSaveButton)
35 END_EVENT_TABLE()
37 MimeExportDlg::MimeExportDlg(wxWindow* parent,
38 const std::string &vdata,
39 const std::string &file_types)
40 : wxDialog(parent, Dialog_MimeExport, _T("MIME Card Data"))
41 , m_vdata(vdata)
42 , m_file_types(file_types)
44 bottom_buttons = CreateButtonSizer(wxOK);
46 text_ctrl_1 = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
47 save_button = new wxButton(this, Dialog_MimeExport_SaveButton, _T("Save..."));
49 set_properties();
50 do_layout();
54 void MimeExportDlg::set_properties()
56 text_ctrl_1->SetMinSize(wxSize(400, 240));
57 text_ctrl_1->SetValidator(wxTextValidator(wxFILTER_NONE, m_strings.Add(m_vdata)));
61 void MimeExportDlg::do_layout()
63 wxBoxSizer* sizer_1 = new wxBoxSizer(wxVERTICAL);
64 sizer_1->Add(text_ctrl_1, 2, wxALL|wxEXPAND, 10);
65 bottom_buttons->Insert(0, save_button, 0, wxRIGHT, 5);
66 sizer_1->Add(bottom_buttons, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 10);
68 SetSizer(sizer_1);
69 sizer_1->Fit(this);
70 Layout();
73 void MimeExportDlg::OnSaveButton(wxCommandEvent &event)
75 wxString ftypes(m_file_types.c_str(), wxConvUTF8);
77 wxFileDialog dlg(this, _T("Save Card as..."), _T(""), _T(""),
78 ftypes,
79 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_PREVIEW);
80 if( dlg.ShowModal() == wxID_OK ) {
81 ofstream ofs(dlg.GetPath().utf8_str(), ios::binary);
82 ofs.write(m_vdata.data(), m_vdata.size());
83 ofs.close();