YATiSh
Yet Another TIme SHeet
yatishDlgName.cpp
Go to the documentation of this file.
1 #include "wx_pch.h"
2 #include "yatishDlgName.h"
3 
4 #ifndef WX_PRECOMP
5  //(*InternalHeadersPCH(yatishDlgName)
6  #include <wx/string.h>
7  #include <wx/intl.h>
8  //*)
9 #endif
10 //(*InternalHeaders(yatishDlgName)
11 //*)
12 
13 //(*IdInit(yatishDlgName)
14 const long yatishDlgName::idTextCtrl = wxNewId();
15 //*)
16 
17 BEGIN_EVENT_TABLE (yatishDlgName, wxDialog)
18  //(*EventTable(yatishDlgName)
19  //*)
20 END_EVENT_TABLE()
21 
22 
23 yatishDlgName::yatishDlgName (yatishDBsqlite * p_db, tableID t_id, long sql_id) {
24  BuildContent();
25  pdb = p_db;
26  tid = t_id;
27  id = sql_id;
28  name = pdb->ReadName (tid, id);
29  textCtrl->SetValidator ( wxTextValidator (wxFILTER_ASCII, &name) );
30  SetLabel ( wxString(_("Table: yatish_") ) + yatishDB::tableName[tid] );
31  Fit(); SetMaxSize ( GetSize() );
32 }
33 
36  BuildContent();
37  staticBoxSizer->GetStaticBox()->SetLabel (_("New row") );
38  pdb = p_db;
39  tid = t_id;
40  buttonSave->Disable();
41  name = wxEmptyString;
42  textCtrl->SetValidator ( wxTextValidator (wxFILTER_ASCII, &name) );
43  SetLabel ( wxString(_("Table: yatish_") ) + yatishDB::tableName[tid] );
44  Fit(); SetMaxSize ( GetSize() );
45 }
46 
48  //(*Initialize(yatishDlgName)
49  wxBoxSizer* BoxSizer1;
50  wxBoxSizer* BoxSizer2;
51  wxButton* buttonCancel;
52  wxButton* buttonNew;
53  wxStaticText* StaticText;
54 
55  Create(0, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("wxID_ANY"));
56  BoxSizer1 = new wxBoxSizer(wxVERTICAL);
57  staticBoxSizer = new wxStaticBoxSizer(wxHORIZONTAL, this, _("(previously selected row)"));
58  StaticText = new wxStaticText(this, wxID_ANY, _("Name:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
59  staticBoxSizer->Add(StaticText, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
60  textCtrl = new wxTextCtrl(this, idTextCtrl, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("idTextCtrl"));
61  textCtrl->SetMaxLength(20);
62  staticBoxSizer->Add(textCtrl, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
63  BoxSizer1->Add(staticBoxSizer, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
64  BoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
65  buttonCancel = new wxButton(this, wxID_CANCEL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("wxID_CANCEL"));
66  BoxSizer2->Add(buttonCancel, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
67  buttonSave = new wxButton(this, wxID_SAVE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("wxID_SAVE"));
68  BoxSizer2->Add(buttonSave, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
69  buttonNew = new wxButton(this, wxID_NEW, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("wxID_NEW"));
70  BoxSizer2->Add(buttonNew, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
71  BoxSizer1->Add(BoxSizer2, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
72  SetSizer(BoxSizer1);
73  BoxSizer1->Fit(this);
74  BoxSizer1->SetSizeHints(this);
75 
76  Connect(wxID_SAVE,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&yatishDlgName::OnButtonSaveClick);
77  Connect(wxID_NEW,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&yatishDlgName::OnButtonNewClick);
78  //*)
79 }
80 
82  //(*Destroy(yatishDlgName)
83  //*)
84 }
85 
86 void yatishDlgName::OnButtonSaveClick (wxCommandEvent& event) {
87  TransferDataFromWindow();
88  if ( pdb->RecordName (tid, id, name) )
89  EndModal (wxID_SAVE);
90  else
91  EndModal (wxID_CANCEL);
92 }
93 
94 void yatishDlgName::OnButtonNewClick (wxCommandEvent& event) {
95  TransferDataFromWindow();
96  if ( pdb->RecordName (tid, wxNOT_FOUND, name) )
97  EndModal (wxID_NEW);
98  else
99  EndModal (wxID_CANCEL);
100 }
static const char * tableName[]
Must be defined in the same order as enum tableID.
Definition: yatishDB.h:44
Interacts with yatish tables in a SQLite database.
bool RecordName(tableID, long, const wxString &)
Modifies or creates a record with only one field (called name).
wxTextCtrl * textCtrl
Definition: yatishDlgName.h:30
void OnButtonNewClick(wxCommandEvent &event)
yatishDBsqlite * pdb
Definition: yatishDlgName.h:32
wxButton * buttonSave
Definition: yatishDlgName.h:28
void OnButtonSaveClick(wxCommandEvent &event)
static const long idTextCtrl
Definition: yatishDlgName.h:25
yatishDlgName(yatishDBsqlite *, tableID, long)
This constructor initializes the dialog box with data from the SQL record identified by sql_id.
wxStaticBoxSizer * staticBoxSizer
Definition: yatishDlgName.h:29
wxString name
Definition: yatishDlgName.h:35
tableID
Definition: yatishDB.h:13