menu: added new Keywords tag to .desktop files
[barry.git] / desktop / src / MemoEditDlg.cc
blobd8f959029078fbba565896e02e1ef8151bb3a403
1 ///
2 /// \file MemoEditDlg.cc
3 /// Dialog class to handle the editing of the Memo record
4 ///
6 /*
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 "MemoEditDlg.h"
23 #include "windowids.h"
24 #include "wxi18n.h"
26 // begin wxGlade: ::extracode
27 // end wxGlade
30 //////////////////////////////////////////////////////////////////////////////
31 // MemoEditDlg class
33 MemoEditDlg::MemoEditDlg(wxWindow* parent,
34 Barry::Memo &rec,
35 bool editable)
36 : wxDialog(parent, Dialog_MemoEdit, _W("Memo Record"))
37 , m_rec(rec)
39 m_rec.Categories.CategoryList2Str(m_category_list);
41 if( editable ) {
42 bottom_buttons = CreateButtonSizer(wxOK | wxCANCEL);
44 else {
45 bottom_buttons = CreateButtonSizer(wxCANCEL);
48 // begin wxGlade: MemoEditDlg::MemoEditDlg
49 label_1 = new wxStaticText(this, wxID_ANY, _W("Title:"));
50 text_ctrl_2 = new wxTextCtrl(this, wxID_ANY, wxEmptyString);
51 label_2 = new wxStaticText(this, wxID_ANY, _W("Categories:"));
52 text_ctrl_3 = new wxTextCtrl(this, wxID_ANY, wxEmptyString);
53 text_ctrl_1 = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
55 set_properties();
56 do_layout();
57 // end wxGlade
61 void MemoEditDlg::set_properties()
63 // begin wxGlade: MemoEditDlg::set_properties
64 SetTitle(_W("Memo"));
65 text_ctrl_2->SetMinSize(wxSize(300, -1));
66 text_ctrl_2->SetFocus();
67 text_ctrl_2->SetValidator(wxTextValidator(wxFILTER_NONE, m_strings.Add(m_rec.Title)));
68 label_2->SetToolTip(_W("Comma separated"));
69 text_ctrl_3->SetMinSize(wxSize(300, -1));
70 text_ctrl_3->SetToolTip(_W("Comma separated list of categories (can be empty)"));
71 text_ctrl_3->SetValidator(wxTextValidator(wxFILTER_NONE, m_strings.Add(m_category_list)));
72 text_ctrl_1->SetMinSize(wxSize(-1, 240));
73 text_ctrl_1->SetToolTip(_W("Body of memo"));
74 text_ctrl_1->SetValidator(wxTextValidator(wxFILTER_NONE, m_strings.Add(m_rec.Body)));
75 // end wxGlade
79 void MemoEditDlg::do_layout()
81 // begin wxGlade: MemoEditDlg::do_layout
82 wxBoxSizer* sizer_1 = new wxBoxSizer(wxVERTICAL);
83 wxFlexGridSizer* grid_sizer_1 = new wxFlexGridSizer(2, 2, 10, 5);
84 grid_sizer_1->Add(label_1, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 0);
85 grid_sizer_1->Add(text_ctrl_2, 1, wxALIGN_CENTER_VERTICAL, 0);
86 grid_sizer_1->Add(label_2, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 0);
87 grid_sizer_1->Add(text_ctrl_3, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 0);
88 sizer_1->Add(grid_sizer_1, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 10);
89 sizer_1->Add(text_ctrl_1, 2, wxALL|wxEXPAND, 10);
90 // end wxGlade
92 sizer_1->Add(bottom_buttons, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 10);
94 // NOTE: watch that wxGlade doesn't add these again above, if
95 // you regenerate the code... we need this here, so that we
96 // can add the button spacer.
97 SetSizer(sizer_1);
98 sizer_1->Fit(this);
99 Layout();
102 bool MemoEditDlg::TransferDataFromWindow()
104 if( !wxDialog::TransferDataFromWindow() )
105 return false;
107 m_strings.Sync();
108 m_rec.Categories.CategoryStr2List(m_category_list);
110 // make sure that the title contains something
111 if( !m_rec.Title.size() ) {
112 wxMessageBox(_W("Please enter a title for your memo."),
113 _W("Required Fields"),
114 wxOK | wxICON_INFORMATION, this);
115 return false;
118 return true;