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