HatchKeeper  0.90
The Free Open-Source Egg Incubation Software
SearchDialog.cpp
Go to the documentation of this file.
1 #include <wx/srchctrl.h>
3 #include <wx/checkbox.h>
4 #include <wx/listctrl.h>
5 
6 
10 class SearchDialog : public wxDialog
11 {
12  private:
13 
14  protected:
15  wxSearchCtrl* SearchCtrl;
16  wxCheckBox* SearchBatches;
17  wxCheckBox* SearchEggs;
18  wxCheckBox* SearchSchedules;
19  wxCheckBox* SearchGroups;
20  wxCheckBox* SearchSettings;
21  wxCheckBox* SearchReminders;
22  wxListCtrl* SearchList;
23  wxButton* SearchClose;
24 
25  void OnSearch(wxCommandEvent& evt);
26  void OnClose(wxCommandEvent&);
27 
28  public:
29 
30  SearchDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 503,395 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
31  ~SearchDialog();
32 
33 };
34 
35 
36 SearchDialog::SearchDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
37 {
38  //Colors
39  vector<int> ColorRed = Settings.GetIntArray("ColorRed");
40  vector<int> ColorGreen = Settings.GetIntArray("ColorGreen");
41  vector<int> ColorBlue = Settings.GetIntArray("ColorBlue");
42  this->SetForegroundColour( wxColor(ColorRed[8],ColorGreen[8],ColorBlue[8]) );
43  this->SetBackgroundColour( wxColor(ColorRed[7],ColorGreen[7],ColorBlue[7]) );
44 
45  this->SetSizeHints( wxDefaultSize, wxDefaultSize );
46 
47  wxBoxSizer* SBSizer1;
48  SBSizer1 = new wxBoxSizer( wxVERTICAL );
49 
50  SearchCtrl = new wxSearchCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
51  #ifndef __WXMAC__
52  SearchCtrl->ShowSearchButton( true );
53  #endif
54  SearchCtrl->ShowCancelButton( false );
55  SBSizer1->Add( SearchCtrl, 0, wxALL|wxEXPAND, 5 );
56 
57  wxGridSizer* SGSizer1;
58  SGSizer1 = new wxGridSizer( 0, 3, 0, 0 );
59 
60  SearchBatches = new wxCheckBox( this, wxID_ANY, l("Batches"), wxDefaultPosition, wxDefaultSize, 0 );
61  SearchBatches->SetValue(true);
62  SGSizer1->Add( SearchBatches, 0, wxALL, 5 );
63 
64  SearchEggs = new wxCheckBox( this, wxID_ANY, l("Advanced Data"), wxDefaultPosition, wxDefaultSize, 0 );
65  SearchEggs->SetValue(true);
66  SGSizer1->Add( SearchEggs, 0, wxALL, 5 );
67 
68  SearchSchedules = new wxCheckBox( this, wxID_ANY, l("Schedules"), wxDefaultPosition, wxDefaultSize, 0 );
69  SearchSchedules->SetValue(true);
70  SGSizer1->Add( SearchSchedules, 0, wxALL, 5 );
71 
72  SearchGroups = new wxCheckBox( this, wxID_ANY, l("Groups"), wxDefaultPosition, wxDefaultSize, 0 );
73  SearchGroups->SetValue(true);
74  SGSizer1->Add( SearchGroups, 0, wxALL, 5 );
75 
76  SearchSettings = new wxCheckBox( this, wxID_ANY, l("Settings"), wxDefaultPosition, wxDefaultSize, 0 );
77  SearchSettings->SetValue(true);
78  SGSizer1->Add( SearchSettings, 0, wxALL, 5 );
79 
80  SearchReminders = new wxCheckBox( this, wxID_ANY, l("Reminders"), wxDefaultPosition, wxDefaultSize, 0 );
81  SearchReminders->SetValue(true);
82  SGSizer1->Add( SearchReminders, 0, wxALL, 5 );
83 
84 
85  SBSizer1->Add( SGSizer1, 0, wxEXPAND, 5 );
86 
87  SearchList = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT );
88  SBSizer1->Add( SearchList, 1, wxALL|wxEXPAND, 5 );
89 
90  SearchClose = new wxButton( this, wxID_ANY, l("Close"), wxDefaultPosition, wxDefaultSize, 0 );
91  SBSizer1->Add( SearchClose, 0, wxALL|wxEXPAND, 5 );
92 
93 
94  SearchCtrl->Bind(wxEVT_SEARCH, &SearchDialog::OnSearch, this);
95  SearchClose->Bind(wxEVT_BUTTON, &SearchDialog::OnClose, this);
96 
97  this->SetSizer( SBSizer1 );
98  this->Layout();
99 
100  this->Centre( wxBOTH );
101 }
102 
105 {
106 }
107 
109 void SearchDialog::OnSearch(wxCommandEvent& evt)
110 {
111  HK_KeyValue Results;
112  if(SearchBatches->IsChecked() || SearchEggs->IsChecked())
113  Results.Add(Batches.Search(evt.GetString().ToStdString(),SearchBatches->IsChecked(), SearchEggs->IsChecked()));
114 
115  if(SearchGroups->IsChecked())
116  Results.Add(Groups.Search("Group",evt.GetString().ToStdString()));
117 
118  if(SearchSchedules->IsChecked())
119  Results.Add(Schedules.Search("Schedule",evt.GetString().ToStdString()));
120 
121  if(SearchReminders->IsChecked())
122  Results.Add(Remind.Search("Remind",evt.GetString().ToStdString()));
123 
124  if(SearchSettings->IsChecked()) {
125  Results.Add(Types.Search("Type",evt.GetString().ToStdString()));
126  Results.Add(Breeds.Search("Breed",evt.GetString().ToStdString()));
127  Results.Add(Settings.Search(evt.GetString().ToStdString()));
128  }
129 
130  SearchList->ClearAll();//Clear the previous list items
131  SearchList->InsertColumn(0,l("Location" ), wxLIST_FORMAT_LEFT, 225);
132  SearchList->InsertColumn(1,l("String" ), wxLIST_FORMAT_LEFT, 225);
133 
134  string Temp;
135  for(int A = 0; A < Results.GetCount(); A++) {
136  SearchList->InsertItem(A, wxString::Format(wxT("%s"),Results.GetKey(A).c_str()));
137  SearchList->SetItem(A, 1,wxString::Format(wxT("%s"), Results.GetValue(A).c_str()) );
138  }
139 
140 }
141 
143 void SearchDialog::OnClose(wxCommandEvent&){EndModal(0);}
HK_KeyValue Settings
Definition: Declare.h:36
HK_Batches Batches
Definition: Declare.h:44
HK_Storage Types
Definition: Declare.h:38
HK_Storage Remind
Definition: Declare.h:40
HK_Storage Breeds
Definition: Declare.h:37
std::string l(std::string Text)
A Helper Function For HK_Language.
Definition: Declare.h:52
HK_Storage Groups
Definition: Declare.h:41
HK_Storage Schedules
Definition: Declare.h:39
HK_KeyValue Search(string Value, bool SearchBatch, bool SearchAdv)
Returned HK_KeyValue's Key Holds Name And Value Holds String Where Match Was Found.
Definition: HK_Batches.cpp:233
A Key and Value Type Storage.
Definition: KeyValue.h:25
string GetKey(int Selection)
Returns The Selected Key As A String.
Definition: HK_KeyValue.cpp:61
void Add(string Key, string Value)
Adds A Key And Value;.
Definition: HK_KeyValue.cpp:33
vector< int > GetIntArray(int Selection)
Returns The Selected Value As An Array Of Integers.
int GetCount()
Return The Amount Of Setting Keys Stored.
Definition: HK_KeyValue.cpp:26
string GetValue(int Selection)
Returns The Selected Setting Value As A String.
Definition: HK_KeyValue.cpp:67
HK_KeyValue Search(string Value)
Returns A HK_KeyValue Object With Matches To Value.
Definition: HK_KeyValue.cpp:84
HK_KeyValue Search(string Prefix, string Value)
Returned HK_KeyValue's Key Holds Name And Value Holds String Where Match Was Found.
Definition: HK_Storage.cpp:138
03.24.2020
~SearchDialog()
Deconstructor.
SearchDialog(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(503, 395), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxCheckBox * SearchSchedules
wxButton * SearchClose
void OnClose(wxCommandEvent &)
Closes Dialog.
wxCheckBox * SearchEggs
wxCheckBox * SearchBatches
wxSearchCtrl * SearchCtrl
wxCheckBox * SearchSettings
wxCheckBox * SearchGroups
void OnSearch(wxCommandEvent &evt)
Searches For Matches Then Shows Them In SearchList.
wxCheckBox * SearchReminders
wxListCtrl * SearchList