2 /// \file MemoEditDlg.cc
3 /// Dialog class to handle the editing of the Memo record
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
29 //////////////////////////////////////////////////////////////////////////////
32 MemoEditDlg::MemoEditDlg(wxWindow
* parent
,
35 : wxDialog(parent
, Dialog_MemoEdit
, _T("Memo Record"))
38 m_rec
.Categories
.CategoryList2Str(m_category_list
);
41 bottom_buttons
= CreateButtonSizer(wxOK
| wxCANCEL
);
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
);
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
)));
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);
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.
101 bool MemoEditDlg::TransferDataFromWindow()
103 if( !wxDialog::TransferDataFromWindow() )
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);