Debian Codegraph @

DatabaseExplorer/imageexportdialog.cpp

raw
1 //////////////////////////////////////////////////////////////////////////////
2 //////////////////////////////////////////////////////////////////////////////
3 //
4 // copyright : (C) 2014 Eran Ifrah
5 // file name : imageexportdialog.cpp
6 //
7 // -------------------------------------------------------------------------
8 // A
9 // _____ _ _ _ _
10 // / __ \ | | | | (_) |
11 // | / \/ ___ __| | ___| | _| |_ ___
12 // | | / _ \ / _ |/ _ \ | | | __/ _ )
13 // | \__/\ (_) | (_| | __/ |___| | || __/
14 // \____/\___/ \__,_|\___\_____/_|\__\___|
15 //
16 // F i l e
17 //
18 // This program is free software; you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation; either version 2 of the License, or
21 // (at your option) any later version.
22 //
23 //////////////////////////////////////////////////////////////////////////////
24 //////////////////////////////////////////////////////////////////////////////
25
26 #include "imageexportdialog.h"
27
28 #include <wx/msgdlg.h>
29
30 ImageExportDialog::ImageExportDialog(wxWindow* parent)
31 : _ImageExportDialog(parent)
32 {
33 m_Scale = -1;
34 }
35
36 ImageExportDialog::~ImageExportDialog() {}
37
38 void ImageExportDialog::OnInit(wxInitDialogEvent& event) { m_textCtrlPath->SetValue(m_Path); }
39
40 void ImageExportDialog::OnOKClick(wxCommandEvent& event)
41 {
42 m_ExportCanvas = m_checkBoxBackground->IsChecked();
43
44 if(m_Path.IsEmpty()) {
45 wxMessageBox(_("Image path cannot be empty."), _("Export image"), wxOK | wxICON_ERROR);
46 m_textCtrlPath->SetFocus();
47
48 return;
49 }
50
51 if(m_radioBtnScaleCustom->GetValue()) {
52 if(!m_textCtrlScale->GetValue().ToDouble(&m_Scale)) {
53 wxMessageBox(_("Canvas scale must be decimal value."), _("Export image"), wxOK | wxICON_ERROR);
54 m_textCtrlScale->SetFocus();
55
56 return;
57 }
58 } else
59 m_Scale = -1;
60
61 EndModal(wxID_OK);
62 }
63
64 void ImageExportDialog::OnUpdateCustomScale(wxUpdateUIEvent& event) { event.Enable(m_radioBtnScaleCustom->GetValue()); }
65
66 void ImageExportDialog::OnBowseClick(wxCommandEvent& event)
67 {
68 wxFileName path(m_Path);
69 wxFileDialog dlg(this, _("Export ERD to image..."), path.GetPath(), path.GetFullName(),
70 wxT("BMP Files (*.bmp)|*.bmp|GIF Files (*.gif)|(*.gif)|XPM Files (*.xpm)|*.xpm|PNG Files "
71 "(*.png)|*.png|JPEG Files (*.jpg)|*.jpg"),
72 wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
73
74 switch(m_BitmapType) {
75 case wxBITMAP_TYPE_BMP:
76 dlg.SetFilterIndex(0);
77 break;
78 case wxBITMAP_TYPE_GIF:
79 dlg.SetFilterIndex(1);
80 break;
81 case wxBITMAP_TYPE_XPM:
82 dlg.SetFilterIndex(2);
83 break;
84 case wxBITMAP_TYPE_PNG:
85 dlg.SetFilterIndex(3);
86 break;
87 case wxBITMAP_TYPE_JPEG:
88 dlg.SetFilterIndex(4);
89 break;
90 default:
91 break;
92 }
93
94 if(dlg.ShowModal() == wxID_OK) {
95 m_Path = dlg.GetPath();
96 m_BitmapType = wxBITMAP_TYPE_BMP;
97
98 switch(dlg.GetFilterIndex()) {
99 case 0:
100 m_BitmapType = wxBITMAP_TYPE_BMP;
101 break;
102 case 1:
103 m_BitmapType = wxBITMAP_TYPE_GIF;
104 break;
105 case 2:
106 m_BitmapType = wxBITMAP_TYPE_XPM;
107 break;
108 case 3:
109 m_BitmapType = wxBITMAP_TYPE_PNG;
110 break;
111 case 4:
112 m_BitmapType = wxBITMAP_TYPE_JPEG;
113 break;
114 }
115
116 m_textCtrlPath->SetValue(m_Path);
117 }
118 }