HatchKeeper  0.90
The Free Open-Source Egg Incubation Software
/home/millj/Documents/1-Code/HatchKeeper/HatchKeeper.cpp
Go to the documentation of this file.
1 /**************************H*A*T*C*H*K*E*E*P*E*R************************
2 *
3 * HatchKeeper v0.90.dev (C) 2017 - 2023 The HatchKeeper Team.
4 *
5 * Free Open-Source Egg Incubation Software.
6 *
7 * *** *** *** ***
8 * *** *** *** ***
9 * *********** *** ***
10 * *********** *** ***
11 * *** *** *** ***
12 * *** *** *** ***
13 *
14 * This program is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published
16 * by the Free Software Foundation, version 3 of the License.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 *
26 *****************************************************************H*K*T*/
27 #include "HatchKeeper.h" //HatchFrame Class
28 
29 int HatchCondition = 0; //Read from condition File at startup
30 
31 static HatchFrame* frame = NULL; //for running in background
32 static wxNotificationMessage * TheNotification = NULL;
33 static wxGenericNotificationMessage * TheGenNotification = NULL;
34 bool UsedGen = true; //Which Notification was actually used
35 
36 static bool ActuallyExit = false;
37 
38 DECLARE_APP(HatchApp)
39 
40 IMPLEMENT_APP(HatchApp)
41 
42 BEGIN_EVENT_TABLE(HatchApp, wxApp)
43  EVT_END_SESSION(HatchApp::OnExitSession)
44  EVT_QUERY_END_SESSION(HatchApp::OnExitSession)
45 END_EVENT_TABLE()
46 
47 //Main Frame events
48 BEGIN_EVENT_TABLE(HatchFrame, wxFrame)
49  EVT_TOOL(ON_IMPORT,HatchFrame::OnImport)
50  EVT_TOOL(ON_BATCH,HatchFrame::OnNewBatch)
51  EVT_TOOL(ON_SCH,HatchFrame::OnSchedule)
52  EVT_TOOL(ON_PREF,HatchFrame::OnPreference)
53 #ifndef __NO_GRAPH__
55 #endif //__NO_GRAPH__
59  EVT_TOOL(ON_QUIT,HatchFrame::OnQuit)
61  EVT_SPINCTRL(ON_EGG, HatchFrame::OnEggSpinner)
68  EVT_CALENDAR_PAGE_CHANGED(CAL_CHANGE, HatchFrame::OnCalChange)
69  EVT_CHOICE(ON_SORT, HatchFrame::OnSort)
71 
72  //Advanced
76  EVT_SPINCTRLDOUBLE(ADV_WEIGHT, HatchFrame::OnWeightChange)
79  EVT_DATE_CHANGED(ADV_RES_DATE, HatchFrame::OnAdvResultDate)
81 
82  //Groups
83  EVT_BUTTON(GR_ADD, HatchFrame::OnAddGroup)
87 
88  EVT_CLOSE(HatchFrame::OnCloseWindow)
89  EVT_TIMER(TIMER1,HatchFrame::OnTimer)
90 END_EVENT_TABLE()
91 
92 //Taskbar and notifications
93 BEGIN_EVENT_TABLE(HatchTaskBarIcon, wxTaskBarIcon)
94  EVT_MENU(ON_RESHOW, HatchTaskBarIcon::OnWindowRestore)
95  EVT_MENU(ON_EXIT, HatchTaskBarIcon::OnWindowExit)
96 END_EVENT_TABLE()
97 
98 
99 #ifndef __WXMSW__
101 void HatchTerm(int signum)
102 {
103  //Write a int to tell inform HatchKeeper on start-up
104  string FileFolder = HATCHKEEPER_DATA + "Condition";
105  FILE *fp;
106 
107  if ((fp = fopen(FileFolder.c_str(), "w"))== NULL)
108  fprintf(stderr,"Error Creating HatchKeeper Condition File!");
109  else {
110  fprintf(fp,"1");
111  fclose(fp);
112  }
113 
114  ActuallyExit = true;
115  frame->Close(true);
116 }
117 #endif //__WXMSW__
118 
121 {
122  wxLogNull nolog; //remove stale lockfile warning
123 
124  //Check For Previous Instance.
125  h_checker = new wxSingleInstanceChecker;
126  if ( h_checker->IsAnotherRunning()) {
127  //Create a client and connect to Previous Instance
128  h_client = new HatchClient;
129  bool value = h_client->Connect(IPC_HOST, IPC_SERVICE, IPC_TOPIC);
130  if (!value)
131  wxDELETE(h_client);
132 
133  wxString s = wxT("HatchKeeper");
134  h_client->GetConnection()->Execute(s);
135  h_client->Disconnect();
136 
137  delete h_server;
138  h_server = NULL;
139 
140  delete h_client;
141  h_client = NULL;
142 
143  delete h_checker;
144  h_checker = NULL;
145 
146  //Exit This Instance
147  return false;
148  }
149 
150  //else start a server.
151  h_server = new HatchServer;
152  if (!h_server->Create(IPC_SERVICE)) {
153  std::cout<<"Server %s failed to start\n";
154  wxDELETE(h_server);
155  }
156 
157 //set up for sigterm under Linux
158 #ifndef __WXMSW__
159  struct sigaction action;
160  memset(&action, 0, sizeof(struct sigaction));
161  action.sa_handler = HatchTerm;
162  sigaction(SIGTERM, &action, NULL);
163 #endif //__WXMSW__
164 
165  //See what stopped HatchKeeper
166  string FileFolder = HATCHKEEPER_DATA + "Condition";
167  FILE *fp;
168  cout<<FileFolder<<endl;
169  if ((fp = fopen(FileFolder.c_str(), "r"))== NULL)
170  fprintf(stderr,"Warning, HatchKeeper Condition File Not Found!");
171  else {
172  fscanf(fp,"%d", &HatchCondition);
173  fclose(fp);
174  }
175 
176  frame = new HatchFrame();
177 
178  if(HatchCondition == 0)
179  frame->Show(true);
180  else
181  frame->Show(false); //System startup
182 
183  return true;
184 }
185 
188 {
189  delete h_checker;
190  h_checker = NULL;
191 
192  delete h_server;
193  h_server = NULL;
194 
195  delete h_client;
196  h_client = NULL;
197 
198  return false;
199 }
200 
203 
205 void HatchApp::OnExitSession(wxCloseEvent& evt)
206 {
207  string FileFolder = HATCHKEEPER_DATA + "Condition";
208 
209  //Write a int to tell inform HatchKeeper on start-up
210  FILE *fp;
211 
212  if ((fp = fopen(FileFolder.c_str(), "w"))== NULL) {
213  fprintf(stderr,"Error Creating HatchKeeper Condition File!");
214  //return;
215  }
216  else {
217  fprintf(fp,"1");
218  fclose(fp);
219  }
220 
221  frame->Close(true);
222  evt.Skip();
223 }
224 
227 
229 void HatchFrame::OnCloseWindow(wxCloseEvent &evt)
230 {
231  if( evt.CanVeto() && ActuallyExit == false) {
232  Show(false);
233  evt.Veto();
234  return;
235  }
236  else {
237  //close
238  evt.Skip();
239  }
240 }
241 
243 void HatchFrame::OnQuit(wxCommandEvent& )
244 {
245  int answer = wxMessageBox(
246  l("Exit Completely?") + "\n" + l("Yes( No Notifications! )") + "\n" + l("No( Run In Background )"),
247  l("Confirm"),
248  wxYES_NO | wxCANCEL,
249  this
250  );
251  if (answer == wxYES) {
252  string FileFolder = HATCHKEEPER_DATA + "Condition";
253 
254  //Write a int to tell inform HatchKeeper on start-up
255  FILE *fp;
256 
257  if ((fp = fopen(FileFolder.c_str(), "w"))== NULL)
258  fprintf(stderr,"Error Creating HatchKeeper Condition File!");
259  else {
260  fprintf(fp,"0");
261  fclose(fp);
262  }
263  m_taskBarIcon->Destroy();
264  ActuallyExit = true;
265  frame->Close(true);
266  }
267 
268  if (answer == wxNO) {
269  ActuallyExit = false;
270  Show(false);
271  }
272 }
273 
275 void HatchFrame::OnImport(wxCommandEvent&)
276 {
277  wxFileDialog importDialog(
278  NULL,
279  l("Import Batch File"),
280  wxEmptyString,
281  wxEmptyString,
282  "HatchKeeper Batch Files (*.hkbf)|*.hkbf",
283  wxFD_OPEN|wxFD_FILE_MUST_EXIST,
284  wxDefaultPosition,
285  wxDefaultSize,
286  l("Batches")
287  );
288 
289  if (importDialog.ShowModal() == wxID_CANCEL)
290  return;
291 
292  vector<string> SQL = ExportImport.ImportHKBF(
293  importDialog.GetPath().ToStdString(),
294  &Batches,
295  &Groups,
296  &Types,
297  &Breeds,
298  &Schedules
299  );
300 
301  if(SQL.size() < 1) {
302  ShowMsg(l("Error! Couldn't Read File!"));
303  return;
304  }
305 
306  if(!Database.Execute(SQL))
307  ShowMsg("Sqlite Error: " + Database.GetErrors());
308 
309  Today.Reset();
310  ShowBatches(false);
311  ShowGroups(true);
312 }
313 
315 void HatchFrame::OnNewBatch(wxCommandEvent& )
316 {
317  MainList->Select(MainList->GetFirstSelected(),false);//Unselect
318 
319  BatchDialog* dialog = new BatchDialog(this,200,l("New Batch"));
320  dialog->ShowModal();
321  bool isCancel = dialog->WasCanceled();
322  dialog->Destroy();
323 
324  if(!isCancel)
325  ShowBatches(true);
326 }
327 
329 void HatchFrame::OnSort(wxCommandEvent&)
330 {
331  MainList->Select(MainList->GetFirstSelected(),false);//Unselect
332 
333  Settings.SetValue("BatchSortState", to_string(SortBatchChoice->GetSelection()));
334  ShowBatches(true);
335 
336  string SQL = "UPDATE Settings SET Value = '" + Settings.GetValue("BatchSortState") + "' WHERE Key = 'BatchSortState';";
337  if(!Database.Execute(SQL))
338  ShowMsg("Sqlite Error: " + Database.GetErrors());
339 }
340 
342 void HatchFrame::OnSchedule(wxCommandEvent& )
343 {
344  MainList->Select(MainList->GetFirstSelected(),false);//Unselect
345 
346  ScheduleDialog* dialog = new ScheduleDialog(this,9999,l("Schedule A Hatch Date"));
347  dialog->ShowModal();
348  dialog->Destroy();
349 }
350 
352 void HatchFrame::OnRemind(wxCommandEvent& )
353 {
354  MainList->Select(MainList->GetFirstSelected(),false);//Unselect
355 
356  ReminderDialog *dialog = new ReminderDialog(this,903,l("Reminders"));
357  dialog->ShowModal();
358  dialog->Destroy();
359 }
360 
362 void HatchFrame::OnPreference(wxCommandEvent& )
363 {
364  int sel = MainList->GetFirstSelected();
365  MainList->Select(sel,false);//unselect
366 
367  PrefDialog* dialog = new PrefDialog(this,9900,l("Settings"));
368  dialog->ShowModal();
369  dialog->Destroy();
370 
371  //update colors
372  vector<int> ColorRed = Settings.GetIntArray("ColorRed");
373  vector<int> ColorGreen = Settings.GetIntArray("ColorGreen");
374  vector<int> ColorBlue = Settings.GetIntArray("ColorBlue");
375  //Main Window
376  this->SetBackgroundColour(wxColor(ColorRed[0],ColorGreen[0],ColorBlue[0],225) );
377 
378  //Calendar
379  wxFont CalFont(Settings.GetInt("CalTextSize"), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD, true);
380  MainCalendar->SetOwnFont(CalFont);
381  MainCalendar->SetBackgroundColour(wxColor(ColorRed[1],ColorGreen[1],ColorBlue[1],225));
382  MainCalendar->SetForegroundColour(wxColor(ColorRed[2],ColorGreen[2],ColorBlue[2],225));
383 
384  //Batch List
385  MainList->SetBackgroundColour(wxColor(ColorRed[3],ColorGreen[3],ColorBlue[3],225) );
386  MainList->SetForegroundColour(wxColor(ColorRed[4],ColorGreen[4],ColorBlue[4],225));
387 
388  //NoteBook Panels
389  BatchPanel->SetBackgroundColour( wxColor(ColorRed[5],ColorGreen[5],ColorBlue[5],225));
390  BatchPanel->SetForegroundColour( wxColor(ColorRed[6],ColorGreen[6],ColorBlue[6],225));
391 
392  GroupPanel->SetBackgroundColour( wxColor(ColorRed[5],ColorGreen[5],ColorBlue[5],225));
393  GroupPanel->SetForegroundColour( wxColor(ColorRed[6],ColorGreen[6],ColorBlue[6],225));
394 
395  NotePanel->SetBackgroundColour( wxColor(ColorRed[5],ColorGreen[5],ColorBlue[5],225));
396  NotePanel->SetForegroundColour( wxColor(ColorRed[6],ColorGreen[6],ColorBlue[6],225));
397 
398  NoteList->SetBackgroundColour(wxColor(ColorRed[9],ColorGreen[9],ColorBlue[9],225) );
399  NoteList->SetForegroundColour(wxColor(ColorRed[10],ColorGreen[10],ColorBlue[10],225));
400 
401  //Refresh it all
402  this->Refresh();
403 
404  ShowBatches(true);
405  ShowGroups(true);
406 }
407 #ifndef __NO_GRAPH__
409 void HatchFrame::OnGraph(wxCommandEvent&)
410 {
411  GraphDialog* dialog = new GraphDialog(this,9569,l("Graphs"));
412  dialog->ShowModal();
413  dialog->Destroy();
414 }
415 #endif //__NO_GRAPH__
416 
418 void HatchFrame::OnRefresh(wxCommandEvent& )
419 {
420  int sel = MainList->GetFirstSelected();
421  MainList->Select(sel,false);//Unselect
422 
423  Today.Reset();
424  MainCalendar->SetDate(wxDateTime::Now()); //Refresh MainCalendar.
425 
426  ShowBatches(true);
427 }
428 
430 void HatchFrame::OnAbout(wxCommandEvent&)
431 {
432  MainList->Select(MainList->GetFirstSelected(),false);//unselect
433 
434  HelpDialog* dialog = new HelpDialog(this,9909,l("About"));
435  dialog->ShowModal();
436  dialog->Destroy();
437 }
438 
440 void HatchFrame::OnSearch(wxCommandEvent&)
441 {
442  SearchDialog* dialog = new SearchDialog(this,9911,l("Search"));
443  dialog->ShowModal();
444  dialog->Destroy();
445 }
446 
448 void HatchFrame::OnColumnClick(wxListEvent& evt) {
449  if(evt.GetColumn() == 4) {
450  switch(Settings.GetInt("ShowDaysLeft")) {
451  case 0: {
452  Settings.SetValue("ShowDaysLeft", "1");
453  break;
454  }
455  case 1: {
456  Settings.SetValue("ShowDaysLeft", "2");
457  break;
458  }
459  case 2: {
460  Settings.SetValue("ShowDaysLeft", "0");
461  break;
462  }
463  }
464  ShowBatches(false);
465 
466  string SQL = "UPDATE Settings SET Value = '" + Settings.GetValue("ShowDaysLeft") + "' WHERE Key = 'ShowDaysLeft';";
467  if(!Database.Execute(SQL))
468  ShowMsg("Sqlite Error: " + Database.GetErrors());
469  }
470 }
471 
473 void HatchFrame::OnListSelect(wxListEvent&)
474 {
475  BatchPanel->Enable(true);
476 
477  wxDateTime calTime;
478  int calYear, calMonth2;
479  string calMonth;
480 
481  RemoveAttr();
482 
483  //unselect GroupList
484  int listSel2 = GroupList->GetFirstSelected();
485  GroupList->Select(listSel2, false);
486 
487  //switch view to BatchStatPanel
488  if(m_notebook2->GetSelection() == 2 || m_notebook2->GetSelection() == 3)
489  m_notebook2->SetSelection(0);
490 
491  listSel = MainList->GetFirstSelected();
492 
493  //Setup Stats
495 
496  //Setup Graph
497  if(Batches.GetEggs(listSel) > 0)
499 
500  //Setup Calendar Attrs
501  calTime = MainCalendar->GetDate();
502  calYear = calTime.GetYear();
503 
504  calMonth = calTime.GetMonthName(calTime.GetMonth());
505 
506  calMonth2 = Today.MonthToInt(calMonth);
507 
508  HK_Date Start = Batches.GetStart(listSel);
509  HK_Date Candle = Batches.GetCandle(listSel);
511  HK_Date Hatch = Batches.GetHatch(listSel);
512 
513  if(calYear != Start.GetYear() &&
514  calYear != Candle.GetYear() &&
515  calYear != Lock.GetYear() &&
516  calYear != Hatch.GetYear() )
517  return;
518 
519  if(calMonth2 != Start.GetMonth() &&
520  calMonth2 != Candle.GetMonth() &&
521  calMonth2 != Lock.GetMonth() &&
522  calMonth2 != Hatch.GetMonth())
523  return;
524 
525  wxCalendarDateAttr* Attr1 = new wxCalendarDateAttr(wxCAL_BORDER_NONE );
526  Attr1->SetBackgroundColour (wxColour(128,0,128));
527 
528  wxCalendarDateAttr* Attr2 = new wxCalendarDateAttr(wxCAL_BORDER_NONE );
529  Attr2->SetBackgroundColour (wxColour(0,0,255));
530 
531  wxCalendarDateAttr* Attr3 = new wxCalendarDateAttr(wxCAL_BORDER_NONE );
532  Attr3->SetBackgroundColour (wxColour(0,128,0));
533 
534  wxCalendarDateAttr* Attr4 = new wxCalendarDateAttr(wxCAL_BORDER_NONE );
535  Attr4->SetBackgroundColour (wxColour(255,0,0));
536 
537  if(calMonth2 == Start.GetMonth()) {
538  MainCalendar->SetAttr( Start.GetDay(), Attr1);
539  daysWAttr[dwAttr] = Start.GetDay();
540  dwAttr++;
541  }
542 
543  if(calMonth2 == Candle.GetMonth()) {
544  MainCalendar->SetAttr( Candle.GetDay(), Attr2);
545  daysWAttr[dwAttr] = Candle.GetDay();
546  dwAttr++;
547  }
548 
549  if(calMonth2 == Lock.GetMonth()) {
550  MainCalendar->SetAttr( Lock.GetDay(), Attr3);
551  daysWAttr[dwAttr] = Lock.GetDay();
552  dwAttr++;
553  }
554 
555  if(calMonth2 == Hatch.GetMonth()) {
556  MainCalendar->SetAttr( Hatch.GetDay(), Attr4);
557  daysWAttr[dwAttr] = Hatch.GetDay();
558  dwAttr++;
559  }
560  MainCalendar->Refresh();
561 }
562 
564 void HatchFrame::OnListDESelect(wxListEvent& evt)
565 {
566  if(Batches.IsDirty(listSel))
567  ShowMsg(l("Unsaved Batch Changes! Reselect Batch And Click Update To Save Changes"));
568 
569  UnsetBatchStats();
570  RemoveAttr();
571  BatchPanel->Disable();
572  EggPanel->Disable();
573 }
574 
577 {
578  //Get Batch
579  HK_Batch Batch = Batches.GetBatch(sel);
580 
581  //Set BatchName
582  BPNameCtrl->ChangeValue(Batch.GetName().c_str());
583 
584  int count1, sel2 = -1;
585 
586  //Set BirdType
587  BPTypeChoice->Clear();
588 
589  if(Batch.GetAdv() == 0) {
590  for(count1 = 0; count1 < Types.GetCount(); count1++) {
591  BPTypeChoice->Append(Types.GetName(count1).c_str());
592  if(Types.GetName(count1) == Batch.GetType())
593  sel2 = count1;
594  }
595  if(sel2 == -1) {
596  BPTypeChoice->Append(Batch.GetType().c_str());
597  BPTypeChoice->SetSelection(count1);
598  }
599  else
600  BPTypeChoice->SetSelection(sel2);
601  BPTypeChoice->SetToolTip(l("Edit Type"));
602  }
603  else {
604  BPTypeChoice->Append(Batch.GetType().c_str());
605  BPTypeChoice->SetSelection(0);
606  BPTypeChoice->SetToolTip(l("Editing Type Is Disabled When Advanced Is Enabled"));
607  }
608 
609  sel2 = -1;
610 
611  //Set Breed
612  BPBreedChoice->Clear();
613  int z = 0;
614  for(count1 = 0; count1 < Breeds.GetCount(); count1++) {
615  if(Batch.GetType() == Breeds.GetText(count1)) {
616  BPBreedChoice->Append(Breeds.GetName(count1).c_str());
617  if(Breeds.GetName(count1) == Batch.GetBreed())
618  sel2 = z;
619  z++;
620  }
621  }
622  if(sel2 == -1) {
623  BPBreedChoice->Append(Batch.GetBreed().c_str());
624  BPBreedChoice->SetSelection(count1);
625  }
626  else
627  BPBreedChoice->SetSelection(sel2);
628 
629  sel2 = -1;
630  //Set Group
631  BPGroupChoice->Clear();
632  for(count1 = 0; count1 < Groups.GetCount(); count1++) {
633  BPGroupChoice->Append(Groups.GetName(count1).c_str());
634  if(Groups.GetName(count1) == Batch.GetGroup())
635  sel2 = count1;
636  }
637  BPGroupChoice->SetSelection(sel2);
638 
639  sel2 = -1;
640  //Set Incubator
641  BPIncubatorChoice->Clear();
642  vector<string> Inc = Settings.GetArray("Incubators");
643  for(count1 = 0; count1 < Inc.size(); count1++) {
644  BPIncubatorChoice->Append(Inc[count1].c_str());
645  if(Batch.GetIncubator() == Inc[count1])
646  sel2 = count1;
647  }
648 
649  if(sel2 == -1) {
650  BPIncubatorChoice->Append(Batch.GetIncubator().c_str());
651  BPIncubatorChoice->SetSelection(count1);
652  }
653  else
654  BPIncubatorChoice->SetSelection(sel2);
655 
656  //Set Eggs and the Fertile Spinner range
657  BPEggSpin->SetValue(Batch.GetEggs());
658 
659  //Set Fertile Spinner
660  BPFertileSpin->SetRange(0 , Batch.GetEggs());
661  BPFertileSpin->SetValue(Batch.GetFertile());
662 
663  //Set HatchedChicks
664  BPChicksHatchSpin->SetRange(0 , Batch.GetFertile());
665  BPChicksHatchSpin->SetValue(Batch.GetChicks());
666 
667  //Set number of Fertile unhatched
668  BPFerUnStat->SetLabel(wxString::Format(wxT("%d %s"),Batch.FertileUnhatched(),l("Fertile Unhatched")));
669  BPPerWerFerStat->Refresh();
670 
671  //Set Percent Were Fertile
672  BPPerWerFerStat->SetLabel(wxString::Format(wxT("%d%% %s"), Batch.PercentFertile(),l("Were Fertile")));
673  BPPerWerFerStat->Refresh();
674 
675  //Set Percent OF Fertile Hatched
676  BPPerOfFerStat->SetLabel(wxString::Format(wxT("%d%% %s"),Batch.PercentOfFertile(),l("Of Fertile Hatched")));
677  BPPerOfFerStat->Refresh();
678 
679  //Set % Of Total Hatched
680  BPPerOfTotalStat->SetLabel(wxString::Format(wxT("%d%% %s"), Batch.PercentOfTotal(),l("Of Total Hatched")));
681  BPPerOfTotalStat->Refresh();
682 
683  //Set % Unhatched of total
684  BPPerUnhatchStat->SetLabel(wxString::Format(wxT("%d%% %s"), Batch.PercentOfTotalUnhatched(),l("Of Total Unhatched")));
685  BPPerUnhatchStat->Refresh();
686 
687  //Set Comments
688  BPCommentCtrl->ChangeValue(Batch.GetComments().c_str());
689  BPCommentCtrl->SetInsertionPoint(0);
690 
691  bool UseGauge = true;
692  wxDateTime Date1;
693  wxDateTime Date4;
694  HK_Date Start = Batch.GetStart();
695  //Set StartDate
696  if(Start.IsValid()) {
697  wxDateTime startD(Start.GetDay(),
698  wxDateTime::Month(wxDateTime::Jan + Start.GetMonth() - 1),
699  Start.GetYear(),
700  0,0,0,0);
701 
702  BPStartDateCtrl->SetValue(startD);
703  Date1 = startD;
704  }
705  else {
706  UseGauge = false;
707  cout<<"Log: Invalid Start Date!"<<endl;
708  }
709 
710  //Set CandleDate
711  HK_Date Candle = Batch.GetCandle();
712  if(Candle.IsValid()) {
713  wxDateTime startC(Candle.GetDay(),
714  wxDateTime::Month(wxDateTime::Jan + Candle.GetMonth() - 1),
715  Candle.GetYear(),
716  0,0,0,0);
717 
718  BPCandleDateCtrl->SetValue(startC);
719  }
720  else
721  cout<<"Log: Invalid Candle Date"<<endl;
722 
723  //Set LockdownDate
724  HK_Date Lock = Batch.GetLockdown();
725  if(Lock.IsValid()) {
726  wxDateTime startT(Lock.GetDay(),
727  wxDateTime::Month(wxDateTime::Jan + Lock.GetMonth() - 1),
728  Lock.GetYear(),
729  0,0,0,0);
730  BPLockDateCtrl->SetValue(startT);
731  }
732  else
733  cout<<"Log: Invalid Lockdown Date"<<endl;
734 
735  //Set HatchDate
736  HK_Date Hatch = Batch.GetHatch();
737  if(Hatch.IsValid()) {
738  wxDateTime startH(Hatch.GetDay(),
739  wxDateTime::Month(wxDateTime::Jan + Hatch.GetMonth() - 1),
740  Hatch.GetYear(),
741  0,0,0,0);
742  BPHatchDateCtrl->SetValue(startH);
743  Date4 = startH;
744  }
745  else {
746  cout<<"Log: Invalid Hatch Date"<<endl;
747  UseGauge = false;
748  }
749 
750  wxDateTime Now1 = wxDateTime::Today();
751 
752  //Set Progress Gauge
753  if(UseGauge) {
754  if(Now1.IsBetween(Date1,Date4)) {
755  wxTimeSpan timeS = Date4.Subtract(Date1);
756  BPProgressGauge->SetRange(timeS.GetDays());
757 
758  wxTimeSpan timeS2 = Now1.Subtract(Date1);
759  BPProgressGauge->SetValue(timeS2.GetDays());
760  }
761  else {
762  if(Now1.IsEarlierThan(Date1))
763  BPProgressGauge->SetValue(0);
764 
765  if(Now1.IsLaterThan(Date4)) {
766  BPProgressGauge->SetRange(10);
767  BPProgressGauge->SetValue(10);
768  }
769  }
770  }
771 
772  //More Actions
773  if(Batch.GetAdv() == 0) {
774  MoreActionsChoice->Append(l("Enable Advanced"));
775  AdvMoreChoice->Append(l("Enable Advanced"));
776  }
777  else {
778  MoreActionsChoice->Append(l("Disable Advanced"));
779  AdvMoreChoice->Append(l("Disable Advanced"));
780  ShowAdvanced();
781  }
782 }
783 
786 {
787  BPNameCtrl->ChangeValue(" ");
788  BPTypeChoice->Clear();
789  BPBreedChoice->Clear();
790  BPGroupChoice->Clear();
791  BPIncubatorChoice->Clear();
792  BPEggSpin->SetValue(0);
793  BPFertileSpin->SetValue(0);
794  BPChicksHatchSpin->SetValue(0);
795 
796  BPFerUnStat->SetLabel(wxString::Format(wxT("0 %s"),l("Fertile Unhatched")));
797  BPFerUnStat->Refresh();
798 
799  BPPerWerFerStat->SetLabel(wxString::Format(wxT("0%% %s"),l("Where Fertile")));
800  BPPerWerFerStat->Refresh();
801 
802  BPPerOfFerStat->SetLabel(wxString::Format(wxT("0%% %s"),l("Of Fertile Hatched")));
803  BPPerOfFerStat->Refresh();
804 
805  BPPerOfTotalStat->SetLabel(wxString::Format(wxT("0%% %s"),l("Of Total Hatched")));
806  BPPerOfTotalStat->Refresh();
807 
808  BPPerUnhatchStat->SetLabel(wxString::Format(wxT("0%% %s"),l("Of Total Unhatched")));
809  BPPerUnhatchStat->Refresh();
810 
811  BPProgressGauge->SetValue(0);
812 
813  //Reset DatePickers
814  BPStartDateCtrl->SetValue(wxDateTime::Today());
815  BPCandleDateCtrl->SetValue(wxDateTime::Today());
816  BPLockDateCtrl->SetValue(wxDateTime::Today());
817  BPHatchDateCtrl->SetValue(wxDateTime::Today());
818 
819  BPCommentCtrl->ChangeValue(l("Comments: "));
820 
821  //More Actions
822  MoreActionsChoice->Delete(MoreActionsChoice->GetCount() - 1);
823  AdvMoreChoice->Delete(AdvMoreChoice->GetCount() - 1);
824 
825  //Clear Avanced Data
826  ClearAdvPanel();
827 }
828 
831 {
832 #ifndef __NO_GRAPH__
833  wxString title = l("Batch"); //graph title
834 
835  wxString names[2];
836  double values1[2];
837  double values2[2];
838  double values3[2];
839  double values4[2];
840 
841  names[0] = Batches.GetName(sel);
842  values1[0] = Batches.PercentFertile(sel);
843  values2[0] = Batches.PercentOfFertile(sel);
844  values3[0] = Batches.PercentOfTotal(sel);
845  values4[0] = Batches.PercentOfTotalUnhatched(sel);
846 
847  names[1] = " ";
848  values1[1] = 0;
849  values2[1] = 0;
850  values3[1] = 0;
851  values4[1] = 0;
852 
853  // Create dataset
854  CategorySimpleDataset *dataset = new CategorySimpleDataset(names, WXSIZEOF(names));
855 
856  // add series to it
857  dataset->AddSerie(wxT("% Were Fertile"), values1, WXSIZEOF(values1));
858  dataset->AddSerie(wxT("% Of Fertile Hatched"), values2, WXSIZEOF(values2));
859  dataset->AddSerie(wxT("% Of Total Hatched"), values3, WXSIZEOF(values3));
860  dataset->AddSerie(wxT("% Of Total UnHatched"), values4, WXSIZEOF(values4));
861 
862  // create layered bar type with width=40 and base=0
863  BarType *barType = new LayeredBarType(40, 0);
864 
865  // Set bar renderer for it, with layered bar type
866  BarRenderer *renderer = new BarRenderer(barType);
867 
868  // Some eye-candy: gradient bars
869  renderer->SetBarDraw(0, new GradientAreaDraw(*wxBLUE, wxColor(0,171,255),
870  wxColor(0,171,255).ChangeLightness(150), wxNORTH));
871  renderer->SetBarDraw(1, new GradientAreaDraw(*wxYELLOW, wxColor(215,215,35),
872  wxColor(215,215,35).ChangeLightness(150), wxNORTH));
873 
874  renderer->SetBarDraw(2, new GradientAreaDraw(*wxRED, wxColor(255,0,0),
875  wxColor(255,0,0).ChangeLightness(150), wxNORTH));
876 
877  renderer->SetBarDraw(3, new GradientAreaDraw(*wxGREEN, wxColor(0,128,0),
878  wxColor(0,128,0).ChangeLightness(150), wxNORTH));
879 
880  // assign renderer to dataset
881  dataset->SetRenderer(renderer);
882 
883  // Create bar plot
884  BarPlot *plot = new BarPlot();
885 
886  // Add left category axis
887  NumberAxis *leftAxis = new NumberAxis(AXIS_LEFT);
888  leftAxis->SetMargins(0, 0);
889  plot->AddAxis(leftAxis);
890 
891  // Add bottom number axis
892  CategoryAxis *bottomAxis = new CategoryAxis(AXIS_BOTTOM);
893  bottomAxis->SetMargins(20, 20);
894  plot->AddAxis(bottomAxis);
895 
896  // Add dataset to plot
897  plot->AddDataset(dataset);
898 
899  // Link first dataset with first horizontal axis
900  plot->LinkDataHorizontalAxis(0, 0);
901 
902  // Link first dataset with first vertical axis
903  plot->LinkDataVerticalAxis(0, 0);
904 
905  // and finally construct and return chart
906  BatchGraphPanel->SetChart(new Chart(plot, title));
907 #endif
908 }
909 
911 void HatchFrame::OnCalChange(wxCalendarEvent&)
912 {
913  int sel = MainList->GetFirstSelected();
914 
915  if(sel != -1)
916  MainList->Select(sel,false);//unselect
917 
918  RemoveAttr();
919 
920  if(sel != -1)
921  MainList->Select(sel,true);//Reselect
922 }
923 
925 void HatchFrame::OnHideChange(wxCommandEvent&)
926 {
927  bool sel = HideCheckBox->GetValue();
928 
929  if(sel)
930  Settings.SetValue("HideHatched","1");
931  else
932  Settings.SetValue("HideHatched","0");
933 
934  ShowBatches(false);
935 
936  //Save
937  string SQL = "UPDATE Settings SET Value = '" + Settings.GetValue("HideHatched");
938  SQL += "' WHERE Key = 'HideHatched';";
939  if(!Database.Execute(SQL)) {
940  ShowMsg("Sqlite Error: " + Database.GetErrors());
941  return;
942  }
943 }
944 
946 void HatchFrame::OnCalPrn(wxCommandEvent&)
947 {
948  wxDateTime selDate = MainCalendar->GetDate();
949  HK_Date CalDate(
950  selDate.GetDay(wxDateTime::Local),
951  selDate.GetMonth(wxDateTime::Local) + 1,
952  selDate.GetYear(wxDateTime::Local)
953  );
954  string HTML = ExportImport.HTMLCalendar(CalDate,Batches);
955 
956  wxHtmlEasyPrinting* htmlPrn = new wxHtmlEasyPrinting(l("Printing"), NULL);
957  htmlPrn->SetHeader("<h2 style='text-align:center;'>"+CalDate.MonthName()+"</h2>");
958  htmlPrn->SetFooter("<h6 style='text-align:center;'>Automatically Generated By HatchKeeper On @DATE@</h6>");
959 
960  htmlPrn->PrintText(HTML);
961 
962  delete htmlPrn;
963  htmlPrn = NULL;
964 }
965 
968 {
969  for(int counter = 0; counter < dwAttr; counter++)
970  MainCalendar->ResetAttr(daysWAttr[counter]);
971 
972  dwAttr = 0;
973  MainCalendar->Refresh();
974  listSel = -1;
975 }
976 
978 void HatchFrame::ShowBatches(bool Scan)
979 {
980  if(Scan)
981  Batches = Database.ReadBatches(SortBatchChoice->GetSelection());
982 
983  MainList->ClearAll();//Clear the previous list items
984  MainList->InsertColumn(0,l("Name" ), wxLIST_FORMAT_LEFT, 160);
985  MainList->InsertColumn(1,l("# of Eggs" ), wxLIST_FORMAT_LEFT, wxLIST_AUTOSIZE);
986  MainList->InsertColumn(2,l("Type" ), wxLIST_FORMAT_LEFT, wxLIST_AUTOSIZE );
987  MainList->InsertColumn(3,l("Breed" ), wxLIST_FORMAT_LEFT, 120 );
988 
989  if(Settings.GetValue("ShowDaysLeft") != "Error!") {
990  switch(Settings.GetInt("ShowDaysLeft")) {
991  case 0: {
992  MainList->InsertColumn(4,l("Group" ), wxLIST_FORMAT_LEFT, 150 );
993  break;
994  }
995  case 1: {
996  MainList->InsertColumn(4,l("Days Left" ), wxLIST_FORMAT_LEFT, 150 );
997  break;
998  }
999  case 2: {
1000  MainList->InsertColumn(4,l("On Day" ), wxLIST_FORMAT_LEFT, 150 );
1001  break;
1002  }
1003  }
1004  }
1005  else
1006  MainList->InsertColumn(4,l("Group" ), wxLIST_FORMAT_LEFT, 150 );
1007 
1008  //Colors
1009  vector<int> ColorRed = Settings.GetIntArray("ColorRed");
1010  vector<int> ColorGreen = Settings.GetIntArray("ColorGreen");
1011  vector<int> ColorBlue = Settings.GetIntArray("ColorBlue");
1012 
1013  Today.Reset();//In case the window is open for several days
1014  HK_Batch Batch;
1015  HK_Date Date;
1016  for (int count1 = 0; count1 < Batches.GetCount(); count1++) {
1017  Batch = Batches.GetBatch(count1);
1018  MainList->InsertItem(count1, wxString::Format(wxT("%s"), Batch.GetName().c_str()));
1019  MainList->SetItem(count1, 1,wxString::Format(wxT("%d"), Batch.GetEggs()) );
1020  MainList->SetItem(count1, 2,wxString::Format(wxT("%s"), Batch.GetType().c_str()));
1021  MainList->SetItem(count1, 3,wxString::Format(wxT("%s"), Batch.GetBreed()) );
1022 
1023  if(Settings.GetValue("ShowDaysLeft") != "Error!") {
1024  switch(Settings.GetInt("ShowDaysLeft")) {
1025  case 0: {
1026  MainList->SetItem(count1, 4,wxString::Format(wxT("%s"), Batch.GetGroup().c_str()));
1027  break;
1028  }
1029  case 1: {
1030  MainList->SetItem(count1, 4,wxString::Format(wxT("%d"), Batch.GetDaysLeft()));
1031  break;
1032  }
1033  case 2: {
1034  MainList->SetItem(count1, 4,wxString::Format(wxT("%s"), to_string(Batch.OnDay()) + " "+l("Of")+" " + to_string(Batch.GetStart().Difference(Batch.GetHatch()))) );
1035  break;
1036  }
1037  }
1038  }
1039  else
1040  MainList->SetItem(count1, 4,wxString::Format(wxT("%s"), Batch.GetGroup().c_str()));
1041 
1042  //mark batches that are hatched
1043  if(Settings.GetInt("HideHatched")) {
1044  Date = Batch.GetHatch();
1045  if(Today.GetYear() < Date.GetYear()) {
1046  ;//Do Nothing
1047  }
1048  else if(Date.GetYear() < Today.GetYear()) {
1049  MainList->SetItemTextColour(count1,wxColor(ColorRed[3],ColorGreen[3],ColorBlue[3],225));
1050  }
1051  else {
1052  //batchHYear == todayYear
1053  if(Date.GetMonth() > Today.GetMonth()) {
1054  ;//Do Nothing
1055  }
1056  else if(Date.GetMonth() < Today.GetMonth()) {
1057  MainList->SetItemTextColour(count1,wxColor(ColorRed[3],ColorGreen[3],ColorBlue[3],225));
1058  }
1059  else {
1060  //todayMonth == batchHMonth
1061  if(Date.GetDay() < Today.GetDay()) {
1062  MainList->SetItemTextColour(count1, wxColor(ColorRed[3],ColorGreen[3],ColorBlue[3],225));
1063  }
1064  }
1065  }
1066  }
1067  }
1068  BatchPanel->Enable(false);
1069 }
1070 
1072 void HatchFrame::OnBatchName(wxCommandEvent&)
1073 {
1074  int sel = MainList->GetFirstSelected();
1075 
1076  if(sel == -1)
1077  return;
1078 
1079  HK_Batch Batch = Batches.GetBatch(sel);
1080 
1081  Batch.SetName(BPNameCtrl->GetLineText(0).ToStdString());
1082  Batches.SetBatch(sel, Batch);
1083 }
1084 
1086 void HatchFrame::OnBatchType(wxCommandEvent&)
1087 {
1088  int sel = MainList->GetFirstSelected();
1089 
1090  if(sel == -1)
1091  return;
1092 
1093  HK_Batch Batch = Batches.GetBatch(sel);
1094  string Type = BPTypeChoice->GetString(BPTypeChoice->GetSelection()).ToStdString();
1095  Batch.SetType(Type);
1096 
1097  //Set Breed
1098  BPBreedChoice->Clear();
1099  BPBreedChoice->Append("Unknown");
1100  int z = 0, count1;
1101  for(count1 = 0; count1 < Breeds.GetCount(); count1++) {
1102  if(Batch.GetType() == Breeds.GetText(count1)) {
1103  BPBreedChoice->Append(Breeds.GetName(count1).c_str());
1104  z++;
1105  }
1106  }
1107  BPBreedChoice->SetSelection(0);
1108  Batch.SetBreed("Unknown");
1109 
1110  Batches.SetBatch(sel, Batch);
1111 }
1112 
1114 void HatchFrame::OnBatchBreed(wxCommandEvent&)
1115 {
1116  int sel = MainList->GetFirstSelected();
1117 
1118  if(sel == -1)
1119  return;
1120 
1121  HK_Batch Batch = Batches.GetBatch(sel);
1122 
1123  Batch.SetBreed(BPBreedChoice->GetString(BPBreedChoice->GetSelection()).ToStdString());
1124  Batches.SetBatch(sel, Batch);
1125 }
1126 
1128 void HatchFrame::OnBatchGroup(wxCommandEvent&)
1129 {
1130  int sel = MainList->GetFirstSelected();
1131 
1132  if(sel == -1)
1133  return;
1134 
1135  HK_Batch Batch = Batches.GetBatch(sel);
1136 
1137  Batch.SetGroup(BPGroupChoice->GetString(BPGroupChoice->GetSelection()).ToStdString());
1138  Batches.SetBatch(sel, Batch);
1139 }
1140 
1142 void HatchFrame::OnBatchIncubator(wxCommandEvent&)
1143 {
1144  int sel = MainList->GetFirstSelected();
1145 
1146  if(sel == -1)
1147  return;
1148 
1149  HK_Batch Batch = Batches.GetBatch(sel);
1150 
1151  Batch.SetIncubator(BPIncubatorChoice->GetString(BPIncubatorChoice->GetSelection()).ToStdString());
1152  Batches.SetBatch(sel, Batch);
1153 }
1154 
1156 void HatchFrame::OnEggSpinner(wxSpinEvent&)
1157 {
1158  int sel = MainList->GetFirstSelected();
1159  if(sel == -1)
1160  return;
1161 
1162  if(Batches.GetAdv(sel) == 1) {
1163  BPEggSpin->SetValue(Batches.GetEggs(sel));
1164  return;
1165  }
1166  BPFertileSpin->SetRange(0, BPEggSpin->GetValue());
1167 
1168  HK_Batch Batch = Batches.GetBatch(sel);
1169 
1170  Batch.SetEggs(BPEggSpin->GetValue());
1171  Batches.SetBatch(sel, Batch);
1172 }
1173 
1175 void HatchFrame::OnFertileSpin(wxSpinEvent&)
1176 {
1177  int sel = MainList->GetFirstSelected();
1178  if(sel == -1)
1179  return;
1180 
1181  if(Batches.GetAdv(sel) == 1){
1182  BPFertileSpin->SetValue(Batches.GetFertile(sel));
1183  return;
1184  }
1185  BPChicksHatchSpin->SetRange(0, BPFertileSpin->GetValue());
1186 
1187  HK_Batch Batch = Batches.GetBatch(sel);
1188  Batch.SetFertile(BPFertileSpin->GetValue());
1189  Batches.SetBatch(sel, Batch);
1190 }
1191 
1193 void HatchFrame::OnHatchedSpin(wxSpinEvent&)
1194 {
1195  int sel = MainList->GetFirstSelected();
1196  if(sel == -1)
1197  return;
1198 
1199  if(Batches.GetAdv(sel) == 1) {
1200  BPChicksHatchSpin->SetValue(Batches.GetChicks(sel));
1201  return;
1202  }
1203 
1204  HK_Batch Batch = Batches.GetBatch(sel);
1205  Batch.SetChicks(BPChicksHatchSpin->GetValue());
1206  Batches.SetBatch(sel, Batch);
1207 }
1208 
1210 void HatchFrame::OnBatchDates(wxDateEvent&)
1211 {
1212  int sel = MainList->GetFirstSelected();
1213  if(sel == -1)
1214  return;
1215 
1216  wxDateTime selDate = BPStartDateCtrl->GetValue();
1217  HK_Date Start(
1218  selDate.GetDay(wxDateTime::Local),
1219  selDate.GetMonth(wxDateTime::Local) + 1,
1220  selDate.GetYear(wxDateTime::Local)
1221  );
1222 
1223  selDate = BPCandleDateCtrl->GetValue();
1224  HK_Date Candle(
1225  selDate.GetDay(wxDateTime::Local),
1226  selDate.GetMonth(wxDateTime::Local) + 1,
1227  selDate.GetYear(wxDateTime::Local)
1228  );
1229 
1230  selDate = BPLockDateCtrl->GetValue();
1231  HK_Date Lock(
1232  selDate.GetDay(wxDateTime::Local),
1233  selDate.GetMonth(wxDateTime::Local) + 1,
1234  selDate.GetYear(wxDateTime::Local)
1235  );
1236 
1237  selDate = BPHatchDateCtrl->GetValue();
1238  HK_Date Hatch(
1239  selDate.GetDay(wxDateTime::Local),
1240  selDate.GetMonth(wxDateTime::Local) + 1,
1241  selDate.GetYear(wxDateTime::Local)
1242  );
1243 
1244  HK_Batch Batch = Batches.GetBatch(sel);
1245  Batch.SetStart(Start);
1246  Batch.SetCandle(Candle);
1247  Batch.SetLockdown(Lock);
1248  Batch.SetHatch(Hatch);
1249  Batches.SetBatch(sel, Batch);
1250 }
1251 
1253 void HatchFrame::OnBatchComments(wxCommandEvent&)
1254 {
1255  int sel = MainList->GetFirstSelected();
1256  if(sel == -1)
1257  return;
1258 
1259  int lines = BPCommentCtrl->GetNumberOfLines();
1260  string Comment = "";
1261 
1262  if(lines == 1)
1263  Comment = BPCommentCtrl->GetLineText(0);
1264  else {
1265  for (int c = 0;c < lines; c++) {
1266  if(c == 0)
1267  Comment += BPCommentCtrl->GetLineText(c);
1268  else
1269  Comment += "\n" + BPCommentCtrl->GetLineText(c);
1270  }
1271  }
1272 
1273  HK_Batch Batch = Batches.GetBatch(sel);
1274  Batch.SetComments(Comment);
1275  Batches.SetBatch(sel, Batch);
1276 }
1277 
1279 void HatchFrame::OnDelete(wxCommandEvent&)
1280 {
1281  int really,sel = MainList->GetFirstSelected();
1282 
1283  if(sel == -1) {
1284  ShowMsg(l("No Batch Selected!"));
1285  return;
1286  }
1287 
1288  really = wxMessageBox(
1289  wxString::Format(wxT("Delete %s ?"),
1290  Batches.GetName(sel).c_str()),
1291  l("Delete?"),
1292  wxOK| wxCANCEL
1293  );
1294 
1295  MainList->Select(sel,false);
1296 
1297  if (really == 4) {
1298  if(Batches.GetAdv(sel) == 1) {
1299  if(!Database.Execute("DELETE FROM Advanced where ID = " + to_string(Batches.GetID(sel)) + ";")) {
1300  ShowMsg("Sqlite Error: " + Database.GetErrors());
1301  return;
1302  }
1303  }
1304  if(!Database.Execute("DELETE FROM Batches where ID = " + to_string(Batches.GetID(sel)) + ";")) {
1305  ShowMsg("Sqlite Error: " + Database.GetErrors());
1306  return;
1307  }
1308  ShowBatches(true);
1309  }
1310 }
1311 
1313 void HatchFrame::OnUpdate(wxCommandEvent&)
1314 {
1315  int sel = MainList->GetFirstSelected();
1316 
1317  if(sel == -1) {
1318  ShowMsg(l("No Batch Selected"));
1319  return;
1320  }
1321  vector<string> SQL = Batches.GetBatch(sel).GetUpdate();
1322  if(!Database.Execute(SQL)) {
1323  ShowMsg("Sqlite Error: " + Database.GetErrors());
1324  return;
1325  }
1326  Batches.SetClean(sel);
1327  MainList->Select(sel,false);
1328  ShowBatches(false);
1329  MainList->Select(sel,true);
1330 }
1331 
1333 void HatchFrame::OnMoreActions(wxCommandEvent&)
1334 {
1335  int MoreSel = -1;
1336 
1337  if(MoreActionsChoice->GetSelection() != 0)
1338  MoreSel = MoreActionsChoice->GetSelection();
1339  else
1340  MoreSel = AdvMoreChoice->GetSelection();
1341 
1342 
1343  int sel = MainList->GetFirstSelected();
1344 
1345  if(sel == -1) {
1346  ShowMsg(l("No Batch Selected!"));
1347  MoreActionsChoice->SetSelection(0);
1348  AdvMoreChoice->SetSelection(0);
1349  return;
1350  }
1351  MainList->Select(sel,false);
1352 
1353  switch(MoreSel) {
1354  case 1: {
1355  wxHtmlEasyPrinting* htmlPrn = new wxHtmlEasyPrinting("Printing", NULL);
1356  htmlPrn->SetHeader("<h2 style='text-align:center;'>"+Batches.GetName(sel)+"</h2>");
1357  htmlPrn->SetFooter("<h6 style='text-align:center;'>Automatically Generated By HatchKeeper On @DATE@</h6>");
1358 
1360  if(!htmlPrn->PrintText(HTML)) {
1361  wxMessageDialog dialog(NULL,
1362  l("Error Printing!"));
1363  dialog.ShowModal();
1364  }
1365 
1366  delete htmlPrn;
1367  htmlPrn = NULL;
1368 
1369  break;
1370  }
1371  case 2: {
1372  wxFileDialog exportDialog(NULL,
1373  l("Export Report File"),
1374  wxEmptyString,
1375  Batches.GetName(sel).c_str(),
1376  "Text Files (*.txt)|*.txt",
1377  wxFD_SAVE|wxFD_OVERWRITE_PROMPT,
1378  wxDefaultPosition,
1379  wxDefaultSize,
1380  "Batches"
1381  );
1382 
1383  if (exportDialog.ShowModal() == wxID_CANCEL)
1384  break;
1385 
1386  string path = exportDialog.GetPath().ToStdString();
1387  wxFileName fname(path.c_str());
1388 
1389  if(fname.GetExt() != "txt")
1390  path = path + ".txt";
1391 
1392  string Report = ExportImport.BatchTextReport(Batches.GetBatch(sel), Settings);
1393  Report += "\n\n\nAutomatically Generated By HatchKeeper on " + Today.ToReadable("/",Settings.GetInt("DateMode"));
1394 
1395  if(!Files.WriteTextFile(path , Report))
1396  ShowMsg(l("Error Writing File!"));
1397 
1398  break;
1399  }
1400  case 3: {
1401  //Get Batch
1402  HK_Batches batches;
1403  HK_Storage groups;
1404  batches.Add(Batches.GetBatch(sel));
1405 
1406  for(int a = 0; a < Groups.GetCount(); a++)
1407  if(Batches.GetGroup(sel) == Groups.GetName(a))
1408  groups.Add(Groups.GetName(a),Groups.GetID(a),Groups.GetText(a));
1409 
1410  wxFileDialog exDialog(NULL,
1411  l("Export Batch File"),
1412  wxEmptyString,
1413  Batches.GetName(sel).c_str(),
1414  "HatchKeeper Batch Files (*.hkbf)|*.hkbf",
1415  wxFD_SAVE|wxFD_OVERWRITE_PROMPT,
1416  wxDefaultPosition,
1417  wxDefaultSize,
1418  "Batches"
1419  );
1420 
1421  if (exDialog.ShowModal() == wxID_CANCEL)
1422  return;
1423 
1424  string path = exDialog.GetPath().ToStdString();
1425 
1426  wxFileName fname(path.c_str());
1427  if(fname.GetExt() != "hkbf")
1428  path += ".hkbf";
1429 
1430  ExportImport.ExportHKBF(path, batches, groups);
1431 
1432  break;
1433  }
1434  case 4: {
1435  wxFileDialog exportDialog(NULL,
1436  l("Export Calendar File"),
1437  wxEmptyString,
1438  Batches.GetName(sel).c_str(),
1439  "iCal Files (*.ics)|*.ics",
1440  wxFD_SAVE|wxFD_OVERWRITE_PROMPT,
1441  wxDefaultPosition,
1442  wxDefaultSize,
1443  "Batches"
1444  );
1445 
1446  if (exportDialog.ShowModal() == wxID_CANCEL)
1447  break;
1448 
1449  string path = exportDialog.GetPath().ToStdString();
1450  wxFileName fname(path.c_str());
1451 
1452  if(fname.GetExt() != "ics")
1453  path += ".ics";
1454 
1455  if(!Files.WriteTextFile(path,ExportImport.BatchICal(Batches.GetBatch(sel),false)))
1456  ShowMsg("Error Writing File!");
1457 
1458  break;
1459  }
1460  case 5: {
1461  string Report = ExportImport.BatchTextReport(Batches.GetBatch(sel),Settings);
1462  // Write Report To Clipboard
1463  if (wxTheClipboard->Open()) {
1464  wxTheClipboard->SetData( new wxTextDataObject(Report) );
1465  wxTheClipboard->Close();
1466  }
1467  break;
1468  }
1469  case 6: {
1470  int really;
1471  if(Batches.GetAdv(sel) == 0) {
1472  really = wxMessageBox(
1473  wxString::Format(wxT("%s %s ?"), l("Enable Advanced For"),
1474  Batches.GetName(sel).c_str()),
1475  "Enable?",
1476  wxOK| wxCANCEL
1477  );
1478 
1479  if(really == 4) {
1480  if(!SetBatchAsAdvanced(sel)) {
1481  ShowMsg(l("Sqlite Error: ") + Database.GetErrors());
1482  return;
1483  }
1484 
1485  if(!Database.Execute("UPDATE Batches set AdvEnabled = 1 where ID = " + to_string(Batches.GetID(sel)) + ";"))
1486  ShowMsg(l("Sqlite Error: ") + Database.GetErrors());
1487  }
1488  }
1489  else {
1490  really = wxMessageBox(
1491  wxString::Format(wxT("Disable Advanced For %s ?\nThis Will Delete All Advanced Data For This Batch!"),
1492  Batches.GetName(sel).c_str()),
1493  l("Disable?"),
1494  wxOK| wxCANCEL
1495  );
1496 
1497  if(really == 4) {
1498  if(!Database.Execute("UPDATE Batches set AdvEnabled = 0 where ID = " + to_string(Batches.GetID(sel)) + ";")) {
1499  ShowMsg(l("Sqlite Error: ") + Database.GetErrors());
1500  return;
1501  }
1502 
1503  DeleteAdvanced(sel);
1504  }
1505  }
1506  ShowBatches(true);
1507  MainList->Select(sel, true);
1508  break;
1509  }
1510  }
1511  MoreActionsChoice->SetSelection(0);
1512  AdvMoreChoice->SetSelection(0);
1513 }
1514 
1516 void HatchFrame::ShowGroups(bool Scan)
1517 {
1518  if(Scan)
1520 
1521  GroupList->ClearAll();//Clear the previous list items
1522  GroupList->InsertColumn(0,l("Name"), wxLIST_FORMAT_LEFT, 200);
1523 
1524  for (int G = 0; G < Groups.GetCount(); G++)
1525  GroupList->InsertItem(G, wxString::Format(wxT("%s"), Groups.GetName(G).c_str()));
1526 
1527  //Disable Buttons
1528  GrUpateButton->Enable(false);
1529  GrMoreChoice->Enable(false);
1530  GrDeleteButton->Enable(false);
1531 }
1532 
1534 void HatchFrame::AddGroup(string Name, string Comments)
1535 {
1536  string SQL = "INSERT INTO Groups VALUES(" + to_string(Groups.GetValidID());
1537  SQL += ",'" + Name + "','" + Comments + " ');";
1538 
1539  if(!Database.Execute(SQL))
1540  ShowMsg("Sqlite Error: " + Database.GetErrors());
1541 }
1542 
1544 void HatchFrame::OnAddGroup(wxCommandEvent&)
1545 {
1546  string GName;
1547  wxTextValidator textVal(wxFILTER_INCLUDE_CHAR_LIST);
1548  textVal.SetCharIncludes(Info.GetValidChars().c_str());
1549 
1550  wxTextEntryDialog dlg(this, l("Enter Group Name"),l("Enter Name"),wxEmptyString,wxOK|wxCANCEL,wxDefaultPosition);
1551  dlg.SetTextValidator(textVal);
1552 
1553  if ( dlg.ShowModal() == wxID_OK )
1554  GName = dlg.GetValue();
1555  else
1556  return;
1557 
1558  if(GName == "")
1559  return;
1560 
1561  if(!Groups.IsValidName(GName)) {
1562  ShowMsg(l("Name Exists! Please Enter A New Name!"));
1563  return;
1564  }
1565 
1566  AddGroup(GName," ");
1567  ShowGroups(true);
1568 }
1569 
1571 void HatchFrame::OnDelGroup(wxCommandEvent&)
1572 {
1573  int listSel3 = GroupList->GetFirstSelected();
1574 
1575  GroupList->Select(listSel3, false);
1576 
1577  if(listSel3 == -1) {
1578  ShowMsg(l("No Group Is Selected"));
1579  return;
1580  }
1581 
1582  if(Groups.GetName(listSel3) == "None") {
1583  ShowMsg(l("This Group Can't Be Deleted"));
1584  return;
1585  }
1586 
1587  //Get Batches
1588  HK_Batches GrBatches;
1589  for(int C = 0; C < Batches.GetCount(); C++)
1590  if(Batches.GetGroup(C) == Groups.GetName(listSel3))
1591  GrBatches.Add(Batches.GetBatch(C));
1592 
1593  if(GrBatches.GetCount() < 1) {
1594  wxMessageDialog dialog(this,l("There Are No Batches In This Group!\nAre You Sure You Want To Delete"),l("Delete?"),wxCANCEL|wxOK);
1595  if ( dialog.ShowModal() == wxID_OK ) {
1596  if(!Database.Execute("DELETE FROM Groups where ID = " + to_string(Groups.GetID(listSel3)) + ";"))
1597  ShowMsg("Sqlite Error: " + Database.GetErrors());
1598  ShowGroups(true);
1599  }
1600  return;
1601  }
1602  else {
1603  string GDWarning = "Deleting This Group Will Delete " + to_string(GrBatches.GetCount());
1604  GDWarning +=" Batches\nAre You Sure You Want To Delete?";
1605 
1606  wxMessageDialog dialog(this,l(GDWarning).c_str(),l("Delete?"),wxCANCEL|wxOK);
1607 
1608  if(dialog.ShowModal() == wxID_OK){
1609  for(int C = 0; C < GrBatches.GetCount(); C++) {
1610  if(!Database.Execute("DELETE FROM Batches WHERE ID = " + to_string(GrBatches.GetID(C)) + ";"))
1611  ShowMsg("Sqlite Error: " + Database.GetErrors());
1612  }
1613 
1614  //And Remove The Group
1615  if(!Database.Execute("DELETE FROM Groups WHERE ID = " + to_string(Groups.GetID(listSel3)) + ";"))
1616  ShowMsg("Sqlite Error: " + Database.GetErrors());
1617 
1618  //Rescan
1619  ShowGroups(true);
1620  ShowBatches(true);
1621  }
1622  }
1623 }
1624 
1626 void HatchFrame::OnGroupSelect(wxListEvent&)
1627 {
1628  //Enable Buttons
1629  GrUpateButton->Enable(true);
1630  GrMoreChoice->Enable(true);
1631  GrDeleteButton->Enable(true);
1632 
1633  int sel = MainList->GetFirstSelected();
1634  int GrSel = GroupList->GetFirstSelected();
1635 
1636  MainList->Select(sel,false);//Unselect
1637 
1638  HK_Batches GrBatches;
1639 
1640  //Copy All Needed Batches into One HK_Batches Instance
1641  for(int A = 0; A < Batches.GetCount(); A++) {
1642  if(Batches.GetGroup(A) == Groups.GetName(GrSel))
1643  GrBatches.Add(Batches.GetBatch(A));
1644  }
1645 
1646  //Set Group Comments
1647  GrCommentCtrl->Clear();
1648  GrCommentCtrl->AppendText(Groups.GetText(GrSel).c_str());
1649 
1650  //Return If There Aren't Any Batches
1651  if(GrBatches.GetCount() == 0)
1652  return;
1653 
1654  //and fill in GrBatchList
1655  GrBatchList->ClearAll();//Clear the previous list items
1656  GrBatchList->InsertColumn(0,l(("Batch Name") ), wxLIST_FORMAT_LEFT, 170);
1657  GrBatchList->InsertColumn(1,l(("# Of Eggs" )), wxLIST_FORMAT_LEFT, -1);
1658 
1659  for(int A = 0; A < GrBatches.GetCount(); A++) {
1660  GrBatchList->InsertItem(A, wxString::Format(wxT("%s"), GrBatches.GetName(A).c_str()));
1661  GrBatchList->SetItem(A, 1,wxString::Format(wxT("%d"), GrBatches.GetEggs(A)) );
1662  }
1663 
1664  //Add Totals
1665  GrTEggCtrl->AppendText(wxString::Format(wxT("%d"),GrBatches.TotalEggs()));
1666  GrTChickCtrl->AppendText(wxString::Format(wxT("%d"),GrBatches.TotalChicks()));
1667 
1668  //And Averages
1669  GrAWFerStat->SetLabel(wxString::Format(wxT("%d%% %s"),GrBatches.AvgFertile(), l("Avg % Fertile")));
1670  GrAWFerStat->Wrap( 250 );
1671  GrAWFerStat->Refresh();
1672  GrAOTHatchStat->SetLabel(wxString::Format(wxT("%d%% %s"),GrBatches.AvgTotalHatch(), l("Avg % Of Fertile Hatched")));
1673  GrAOTHatchStat->Wrap( 250 );
1674  GrAOTHatchStat->Refresh();
1675  GrAOFHatchStat->SetLabel(wxString::Format(wxT("%d%% %s"),GrBatches.AvgFertileHatch(), l("Avg % of Total Hatched")));
1676  GrAOTHatchStat->Wrap( 250 );
1677  GrAOFHatchStat->Refresh();
1678  GrAOTUnHatchStat->SetLabel(wxString::Format(wxT("%d%% %s"),GrBatches.AvgTotalUnHatch(), l("Avg % of Total Unhatched")));
1679  GrAOTUnHatchStat->Wrap( 250 );
1680  GrAOTUnHatchStat->Refresh();
1681 }
1682 
1685 {
1686  GrBatchList->ClearAll();
1687  GrTEggCtrl->Clear();
1688  GrTChickCtrl->Clear();
1689  GrAWFerStat->SetLabel(wxString::Format(wxT("0%% %s"), l("Avg % Fertile")));
1690  GrAWFerStat->Wrap( 250 );
1691  GrAWFerStat->Refresh();
1692  GrAOTHatchStat->SetLabel(wxString::Format(wxT("0%% %s"), l("Avg % Of Fertile Hatched")));
1693  GrAOTHatchStat->Wrap( 250 );
1694  GrAOTHatchStat->Refresh();
1695  GrAOFHatchStat->SetLabel(wxString::Format(wxT("0%% %s"), l("Avg % of Total Hatched")));
1696  GrAOFHatchStat->Wrap( 250 );
1697  GrAOFHatchStat->Refresh();
1698  GrAOTUnHatchStat->SetLabel(wxString::Format(wxT("0%% %s"), l("Avg % of Total Unhatched")));
1699  GrAOTUnHatchStat->Wrap( 250 );
1700  GrAOTUnHatchStat->Refresh();
1701  GrCommentCtrl->Clear();
1702  GrCommentCtrl->AppendText(l("Comments:"));
1703 
1704  //Disable Buttons
1705  GrUpateButton->Enable(false);
1706  GrMoreChoice->Enable(false);
1707  GrDeleteButton->Enable(false);
1708 }
1709 
1711 void HatchFrame::OnGrComment(wxCommandEvent&)
1712 {
1713  int lines = GrCommentCtrl->GetNumberOfLines();
1714  int sel = GroupList->GetFirstSelected();
1715  string forComment = "", sql;
1716 
1717  if(sel == -1)
1718  return;
1719 
1720  if(lines == 1) {
1721  forComment = GrCommentCtrl->GetLineText(0);
1722  }else {
1723  for (int count1 = 0;count1 < lines; count1++) {
1724  if(count1 == 0)
1725  forComment = forComment + GrCommentCtrl->GetLineText(count1);
1726  else
1727  forComment = forComment + "\n" + GrCommentCtrl->GetLineText(count1);
1728  }
1729  }
1730 
1731  if(forComment != Groups.GetText(sel)) {
1732  Groups.SetText(sel, forComment);
1733  sql = "UPDATE Groups set GroupComments = '" + forComment;
1734  sql += "' where ID = " + to_string(Groups.GetID(sel)) + ";";
1735 
1736  if(!Database.Execute(sql))
1737  ShowMsg("Sqlite Error: " + Database.GetErrors());
1738 
1739  GroupList->Select(sel, false);
1740 
1741  ShowGroups(true);
1742 
1743  GroupList->Select(sel, true);
1744  }
1745 }
1746 
1748 void HatchFrame::OnMoreGroupActions(wxCommandEvent&)
1749 {
1750  int sel = GroupList->GetFirstSelected();
1751  int MoreSel = GrMoreChoice->GetSelection();
1752  string path;
1753 
1754  if(sel == -1) {
1755  ShowMsg(l("No Group Selected!"));
1756  GrMoreChoice->SetSelection(0);
1757  return;
1758  }
1759 
1760  //Get Batches
1761  HK_Batches GrBatches;
1762  for(int A = 0; A < Batches.GetCount(); A++)
1763  if(Groups.GetName(sel) == Batches.GetGroup(A))
1764  GrBatches.Add(Batches.GetBatch(A));
1765 
1766  //check for batches
1767  if(GrBatches.GetCount() < 1) {
1768  ShowMsg(l("Sorry This Group Contains No Batches!"));
1769  GrMoreChoice->SetSelection(0);
1770  return;
1771  }
1772 
1773  //Unselect
1774  GroupList->Select(sel,false);
1775 
1776  switch(MoreSel) {
1777  case 1: {
1778  wxFileDialog exportDialog(NULL,
1779  l("Export Report File"),
1780  wxEmptyString, Groups.GetName(sel).c_str(),
1781  "Text Files (*.txt)|*.txt",
1782  wxFD_SAVE|wxFD_OVERWRITE_PROMPT,
1783  wxDefaultPosition, wxDefaultSize,
1784  "Batches"
1785  );
1786 
1787  if (exportDialog.ShowModal() == wxID_CANCEL)
1788  return;
1789 
1790  path = exportDialog.GetPath().ToStdString();
1791  wxFileName fname(path.c_str());
1792 
1793  if(fname.GetExt().ToStdString() != "txt")
1794  path += ".txt";
1795 
1796  //Generate And Write Text File
1798  ShowMsg(l("Error Writing File!"));
1799  break;
1800  }
1801  case 2: {
1802  wxHtmlEasyPrinting* htmlPrn = new wxHtmlEasyPrinting(l("Printing"), NULL);
1803  string HTML = ExportImport.GroupHTMLReport(GrBatches,Groups.GetName(sel),Groups.GetText(sel),Settings);
1804 
1805  htmlPrn->PrintText(HTML);
1806 
1807  delete htmlPrn;
1808  htmlPrn = NULL;
1809 
1810  break;
1811  }
1812  case 3: {
1813  //get path
1814  wxFileDialog exportDialog(NULL, l("Export Group File"), wxEmptyString,
1815  Groups.GetName(sel).c_str(), "HatchKeeper Batch Files (*.hkbf)|*.hkbf",
1816  wxFD_SAVE|wxFD_OVERWRITE_PROMPT, wxDefaultPosition, wxDefaultSize,
1817  l("Groups"));
1818 
1819  if (exportDialog.ShowModal() == wxID_CANCEL)
1820  return;
1821 
1822  path = exportDialog.GetPath();
1823  wxFileName fname(path.c_str());
1824 
1825  if(fname.GetExt().ToStdString() != "hkbf")
1826  path += ".hkbf";
1827  HK_Storage groups;
1828  groups.Add(Groups.GetName(sel),Groups.GetID(sel),Groups.GetText(sel));
1829 
1830  if(!ExportImport.ExportHKBF(path, GrBatches, groups))
1831  ShowMsg(l("Error Writing File!"));
1832 
1833  break;
1834  }
1835  case 4: {
1836  wxFileDialog exportDialog(NULL,
1837  l("Export Calendar File"),
1838  wxEmptyString, Groups.GetName(sel).c_str(),
1839  "iCal Files (*.ics)|*.ics",
1840  wxFD_SAVE|wxFD_OVERWRITE_PROMPT,
1841  wxDefaultPosition,
1842  wxDefaultSize,
1843  "Batches"
1844  );
1845 
1846  if (exportDialog.ShowModal() == wxID_CANCEL)
1847  return;
1848 
1849  path = exportDialog.GetPath();
1850  wxFileName fname(path.c_str());
1851 
1852  if(fname.GetExt().ToStdString() != "ics")
1853  path = path + ".ics";
1854 
1855  if(!Files.WriteTextFile(path,ExportImport.GroupICal(GrBatches, Groups.GetName(sel))))
1856  ShowMsg(l("Error Saving iCal File!"));
1857  break;
1858  }
1859  }
1860 
1861  GrMoreChoice->SetSelection(0);
1862 }
1863 
1865 /*Advanced Panel*/
1867 
1869 {
1870  EggPanel->Enable(true);
1871  AdvEggList->ClearAll();//Clear the previous list items
1872  AdvEggList->InsertColumn(0,l("Egg"), wxLIST_FORMAT_LEFT, wxLIST_AUTOSIZE);
1873  AdvEggList->InsertColumn(1,l("Weight Loss"), wxLIST_FORMAT_LEFT, wxLIST_AUTOSIZE);
1874 
1875  HK_Advanced AdvEggs = Batches.GetAdvanced(MainList->GetFirstSelected());
1876 
1877  for(int a = 0;a < AdvEggs.GetEggCount();a++) {
1878  AdvEggList->InsertItem(a, wxString::Format(wxT("%s %d"),l("Egg") ,a + 1));
1879  AdvEggList->SetItem(a, 1, wxString::Format(wxT("%d%%"),AdvEggs.GetEgg(a).CalcTotalLoss()));
1880  }
1881 }
1882 
1883 
1884 
1887 {
1888  int a,b,c;
1889 
1890  vector<HK_Egg> Eggs;
1891  HK_Batch Batch = Batches.GetBatch(sel);
1892  HK_Date TempDate = Batch.GetStart();
1893  int Days = Batch.GetStart().Difference(Batch.GetHatch());
1894 
1895  vector<HK_Weight> DayWeight;
1896  vector< string > DayComments;
1897 
1898  //Day Weight
1899  for(b = 0; b < Days; b++) {
1900  HK_Weight Weight;
1901  DayWeight.push_back(Weight);
1902  }
1903 
1904  //Day Comments
1905  for(b = 0; b < Days; b++) {
1906  TempDate.AddDays(1);
1907  DayComments.push_back("Day " + to_string(b+1) + ": " + TempDate.ToReadable("/",Settings.GetInt("DateMode")) + ": ");
1908  }
1909 
1910  for(a = 0; a < Batch.GetEggs(); a++) {
1911  HK_Egg Egg;
1912  Egg.Set("None","None","None",0,0,-1,Batch.GetHatch(),"Comments: ",DayWeight,DayComments);
1913  Eggs.push_back(Egg);
1914  }
1915 
1916  HK_Advanced Advanced;
1917  Advanced.Set(Batch.GetID(), Settings.GetInt("WeightUnit"),Days,Eggs);
1918  Batch.SetAdvanced(Advanced);
1919  Batches.SetBatch(sel,Batch);
1920 
1921  return Database.Execute(Advanced.GetSQL());
1922 }
1923 
1925 {
1926  if(!Database.Execute("DELETE FROM Advanced where ID = " + to_string(Batches.GetID(sel)) + ";"))
1927  ShowMsg("Sqlite Error: " + Database.GetErrors());
1928 }
1929 
1931 void HatchFrame::OnSelectEgg(wxListEvent&)
1932 {
1933  //Get Batch Advanced Data
1934  int sel = MainList->GetFirstSelected();
1935  HK_Advanced Adv = Batches.GetAdvanced(sel);
1936 
1937  HK_Egg Egg = Adv.GetEgg(AdvEggList->GetFirstSelected());
1938  unsigned int a, found = -1;
1939 
1940  vector<string> AdvTag1Data = Settings.GetArray("Tag1");
1941 
1942  AdvTag1Choice->Clear();
1943  for(a = 0; a < AdvTag1Data.size(); a++) {
1944  AdvTag1Choice->Append(AdvTag1Data[a]);
1945  if(AdvTag1Data[a] == Egg.GetTag1())
1946  found = a;
1947  }
1948 
1949  if(found == -1) {
1950  if(Egg.GetTag1() == "None")
1951  AdvTag1Choice->SetSelection(0);
1952  else {
1953  AdvTag1Choice->Append(Egg.GetTag1());
1954  AdvTag1Choice->SetSelection(a);
1955  }
1956  }
1957  else
1958  AdvTag1Choice->SetSelection(found);
1959 
1960  //Set Tag2
1961  found = -1;
1962 
1963  vector<string> AdvTag2Data = Settings.GetArray("Tag2");
1964 
1965  AdvTag2Choice->Clear();
1966  for(a = 0; a < AdvTag2Data.size(); a++) {
1967  AdvTag2Choice->Append(AdvTag2Data[a]);
1968  if(AdvTag2Data[a] == Egg.GetTag2())
1969  found = a;
1970  }
1971 
1972  if(found == -1) {
1973  if(Egg.GetTag2() == "None")
1974  AdvTag2Choice->SetSelection(0);
1975  else {
1976  AdvTag2Choice->Append(Egg.GetTag2());
1977  AdvTag2Choice->SetSelection(a);
1978  }
1979  }
1980  else
1981  AdvTag2Choice->SetSelection(found);
1982 
1983  //Set Tag3
1984  found = -1;
1985 
1986  vector<string> AdvTag3Data = Settings.GetArray("Tag3");
1987 
1988  AdvTag3Choice->Clear();
1989  for(a = 0; a < AdvTag3Data.size(); a++) {
1990  AdvTag3Choice->Append(AdvTag3Data[a]);
1991  if(AdvTag3Data[a] == Egg.GetTag3())
1992  found = a;
1993  }
1994 
1995  if(found == -1) {
1996  if(Egg.GetTag3() == "None")
1997  AdvTag3Choice->SetSelection(0);
1998  else {
1999  AdvTag3Choice->Append(Egg.GetTag3());
2000  AdvTag3Choice->SetSelection(a);
2001  }
2002  }
2003  else
2004  AdvTag3Choice->SetSelection(found);
2005 
2006  //Set Fertile
2007  if(Egg.GetFertile() == 0)
2008  AdvFertileCheckbox->SetValue(false);
2009  else
2010  AdvFertileCheckbox->SetValue(true);
2011 
2012  //Set Pipped
2013  if(Egg.GetPipped() == 0)
2014  AdvPipCheckbox->SetValue(false);
2015  else
2016  AdvPipCheckbox->SetValue(true);
2017 
2018  //Set Result
2019  if(Egg.GetResult() == -1)
2020  AdvResultChoice->SetSelection(0);
2021  else if(Egg.GetResult() == 0)
2022  AdvResultChoice->SetSelection(1);
2023  else
2024  AdvResultChoice->SetSelection(2);
2025 
2026  //Set Result Date
2027  HK_Date D = Egg.GetDate();
2028  wxDateTime resultD(D.GetDay(),wxDateTime::Month(wxDateTime::Jan + D.GetMonth() - 1), D.GetYear(),0,0,0,0);
2029  if(D.IsValid())
2030  AdvResultDate->SetValue(resultD);
2031  else
2032  cout<<"Log: Invalid Result Date!"<<endl;
2033 
2034 
2035  //Set Comment
2036  AdvCommentCtrl->ChangeValue(Egg.GetComments().c_str());
2037 
2038  //Weight
2039  ShowAdvWeight(Egg, -1);
2040 
2041  //Loss Fix
2042  AdvTotalLossStat->SetLabel( wxString::Format(wxT("%d%% %s"), Egg.CalcTotalLoss(),l("Total Weight Loss")));
2043  AdvTotalLossStat->Refresh();
2044 
2045  AdvAvgBatchLossStat->SetLabel( wxString::Format(wxT("%d%% %s"), Adv.CalcAvgLoss(),l("Avg Weight Loss For All Eggs In Batch")));
2046  AdvAvgBatchLossStat->Wrap( 150 );
2047  AdvAvgBatchLossStat->Refresh();
2048 
2049  //Select Day
2050  HK_Date Date;
2051  int Diff = Batches.GetStart(sel).Difference(Date);
2052 
2053  if( Diff > Adv.GetDays()) {
2054  AdvWeightList->Select(Adv.GetDays() - 1,true);
2055  AdvWeightList->EnsureVisible(Adv.GetDays() - 1);
2056  }
2057  else if (Diff < 1) {
2058  AdvWeightList->Select(0,true);
2059  AdvWeightList->EnsureVisible(0);
2060  }
2061  else {
2062  AdvWeightList->Select(Diff - 1,true);
2063  AdvWeightList->EnsureVisible(Diff - 1);
2064  }
2065 }
2066 
2068 void HatchFrame::OnUnSelectEgg(wxListEvent&)
2069 {
2070  AdvWeightList->ClearAll();//Clear the previous list items
2071  AdvCommentCtrl->ChangeValue(" ");
2072  AdvDayCommentCtrl->ChangeValue(" ");
2073 
2074  //Tags
2075  AdvTag1Choice->SetSelection(0);
2076  AdvTag2Choice->SetSelection(0);
2077  AdvTag3Choice->SetSelection(0);
2078 
2079  AdvFertileCheckbox->SetValue(false);
2080  AdvPipCheckbox->SetValue(false);
2081 
2082  AdvResultChoice->SetSelection(0);
2083 
2084  AdvWeightCtrl->SetValue(0.000);
2085  AdvTotalLossStat->SetLabel("0%" + l("Total Weight Loss"));
2086  AdvTotalLossStat->Refresh();
2087 }
2088 
2091 {
2092  //Clear Lists
2093  AdvEggList->ClearAll();
2094  AdvWeightList->ClearAll();
2095 
2096  AdvFertileCheckbox->SetValue(false);
2097  AdvPipCheckbox->SetValue(false);
2098 
2099  AdvResultDate->SetValue(wxDateTime::Today());
2100  AdvCommentCtrl->ChangeValue(" ");
2101 
2102  AdvWeightCtrl->SetValue(0.000);
2103  AdvTotalLossStat->SetLabel("0%" + l("Total Weight Loss"));
2104  AdvTotalLossStat->Refresh();
2105  AdvDayCommentCtrl->ChangeValue(" ");
2106 }
2107 
2109 void HatchFrame::OnAdvDaySelect(wxListEvent&)
2110 {
2111  //Weight
2112  HK_Advanced Adv = Batches.GetAdvanced(MainList->GetFirstSelected());
2113  HK_Egg Egg = Adv.GetEgg(AdvEggList->GetFirstSelected());
2114  int sel2 = AdvWeightList->GetFirstSelected();
2115 
2116  AdvWeightCtrl->SetValue(Egg.GetDayWeight()[sel2].GetFloat());
2117 
2118  //Loss
2119  AdvTotalLossStat->SetLabel(wxString::Format(wxT("%d%% %s"), Egg.CalcTotalLoss(),l("Total Weight Loss")));
2120  AdvTotalLossStat->Refresh();
2121 
2122  AdvDayLossStat->SetLabel(wxString::Format(wxT("%d%% %s %d"), Egg.CalcDayLoss(sel2),l("Loss On Day"),(sel2+1)));
2123  AdvDayLossStat->Refresh();
2124  //Day Comment
2125  AdvDayCommentCtrl->ChangeValue(Egg.GetDayComments()[sel2].c_str());
2126 }
2127 
2130 {
2131  AdvWeightCtrl->SetValue(0.000);
2132  AdvDayCommentCtrl->ChangeValue(" ");
2133 }
2134 
2136 void HatchFrame::OnEggCommentChange(wxCommandEvent&)
2137 {
2138  int sel = AdvEggList->GetFirstSelected();
2139 
2140  if(sel == -1 || MainList->GetFirstSelected() == -1)
2141  return;
2142 
2143  HK_Egg Egg = Batches.GetAdvanced(MainList->GetFirstSelected()).GetEgg(sel);
2144 
2145  //Comments
2146  int lines = AdvCommentCtrl->GetNumberOfLines();
2147  string forComment = "";
2148 
2149  if(lines == 1) {
2150  forComment = AdvCommentCtrl->GetLineText(0);
2151  }
2152  else {
2153  for (int a = 0;a < lines; a++) {
2154  if(a == 0)
2155  forComment += AdvCommentCtrl->GetLineText(a);
2156  else
2157  forComment += "\n" + AdvCommentCtrl->GetLineText(a);
2158  }
2159  }
2160  Egg.SetComments(forComment);
2161  Batches.SetAdvEgg(MainList->GetFirstSelected(),Egg,sel);
2162  Batches.SetAdvUpdate(MainList->GetFirstSelected(),true);
2163 }
2164 
2166 void HatchFrame::OnTagsChange(wxCommandEvent&)
2167 {
2168  int sel = AdvEggList->GetFirstSelected();
2169 
2170  if(sel == -1 || MainList->GetFirstSelected() == -1)
2171  return;
2172 
2173  HK_Egg Egg = Batches.GetAdvanced(MainList->GetFirstSelected()).GetEgg(sel);
2174 
2175  Egg.SetTag1(AdvTag1Choice->GetString(AdvTag1Choice->GetSelection()).ToStdString());
2176  Egg.SetTag2(AdvTag2Choice->GetString(AdvTag2Choice->GetSelection()).ToStdString());
2177  Egg.SetTag3(AdvTag3Choice->GetString(AdvTag3Choice->GetSelection()).ToStdString());
2178  Batches.SetAdvEgg(MainList->GetFirstSelected(),Egg,sel);
2179  Batches.SetAdvUpdate(MainList->GetFirstSelected(),true);
2180 }
2181 
2183 void HatchFrame::OnAdvFertileChecked(wxCommandEvent&)
2184 {
2185  int sel = AdvEggList->GetFirstSelected();
2186 
2187  if(sel == -1 || MainList->GetFirstSelected() == -1) {
2188  AdvFertileCheckbox->SetValue(false);
2189  return;
2190  }
2191 
2192  HK_Egg Egg = Batches.GetAdvanced(MainList->GetFirstSelected()).GetEgg(sel);
2193 
2194 
2195  if(AdvFertileCheckbox->GetValue())
2196  Egg.SetFertile(1);
2197  else {
2198  //Has To Be Fertile If Pipped
2199  if(AdvPipCheckbox->GetValue())
2200  AdvFertileCheckbox->SetValue(true);
2201  else
2202  Egg.SetFertile(0);
2203  }
2204  Batches.SetAdvEgg(MainList->GetFirstSelected(),Egg,sel);
2205  Batches.SetAdvUpdate(MainList->GetFirstSelected(),true);
2206 }
2207 
2209 void HatchFrame::OnAdvPippedChecked(wxCommandEvent&)
2210 {
2211  int sel = AdvEggList->GetFirstSelected();
2212 
2213  if(sel == -1 || MainList->GetFirstSelected() == -1) {
2214  AdvPipCheckbox->SetValue(false);
2215  return;
2216  }
2217 
2218  HK_Egg Egg = Batches.GetAdvanced(MainList->GetFirstSelected()).GetEgg(sel);
2219 
2220  if(AdvPipCheckbox->GetValue()) {
2221  Egg.SetPipped(1);
2222  if(!AdvFertileCheckbox->GetValue()) {
2223  AdvFertileCheckbox->SetValue(true);
2224  Egg.SetFertile(1);
2225  }
2226  }
2227  else {
2228  //Has To Be Pipped If Hatched
2229  if(AdvResultChoice->GetSelection() == 1)
2230  AdvPipCheckbox->SetValue(true);
2231  else
2232  Egg.SetPipped(0);
2233  }
2234 
2235  Batches.SetAdvEgg(MainList->GetFirstSelected(),Egg,sel);
2236  Batches.SetAdvUpdate(MainList->GetFirstSelected(),true);
2237 }
2238 
2240 void HatchFrame::OnAdvResultChoice(wxCommandEvent&)
2241 {
2242  int sel = AdvEggList->GetFirstSelected();
2243 
2244  if(sel == -1 || MainList->GetFirstSelected() == -1)
2245  return;
2246 
2247  HK_Egg Egg = Batches.GetAdvanced(MainList->GetFirstSelected()).GetEgg(sel);
2248 
2249  if(AdvResultChoice->GetSelection() == 0)
2250  Egg.SetResult(-1);
2251  else if(AdvResultChoice->GetSelection() == 1) {
2252  Egg.SetResult(0);
2253 
2254  //Set Fertile And Pipped As Well
2255  if(!AdvPipCheckbox->GetValue()) {
2256  Egg.SetPipped(1);
2257  AdvPipCheckbox->SetValue(true);
2258  }
2259 
2260  if(!AdvFertileCheckbox->GetValue()) {
2261  Egg.SetFertile(1);
2262  AdvFertileCheckbox->SetValue(true);
2263  }
2264  }
2265  else
2266  Egg.SetResult(2);
2267 
2268  Batches.SetAdvEgg(MainList->GetFirstSelected(),Egg,sel);
2269  Batches.SetAdvUpdate(MainList->GetFirstSelected(),true);
2270 }
2271 
2274 {
2275  int sel = AdvEggList->GetFirstSelected();
2276 
2277  if(sel == -1 || MainList->GetFirstSelected() == -1) {
2278  AdvPipCheckbox->SetValue(false);
2279  return;
2280  }
2281 
2282  HK_Egg Egg = Batches.GetAdvanced(MainList->GetFirstSelected()).GetEgg(sel);
2283 
2284  wxDateTime NewD = AdvResultDate->GetValue();
2285  HK_Date Date(
2286  NewD.GetDay(wxDateTime::Local),
2287  NewD.GetMonth(wxDateTime::Local) + 1,
2288  NewD.GetYear(wxDateTime::Local)
2289  );
2290  Egg.SetDate(Date);
2291 
2292  Batches.SetAdvEgg(MainList->GetFirstSelected(),Egg,sel);
2293  Batches.SetAdvUpdate(MainList->GetFirstSelected(),true);
2294 }
2295 
2297 void HatchFrame::ShowAdvWeight(HK_Egg Egg, int Select)
2298 {
2299  //Set Day Weight
2300  AdvWeightList->ClearAll();//Clear the previous list items
2301  AdvWeightList->InsertColumn(0,l("Day"), wxLIST_FORMAT_LEFT, 50);
2302  AdvWeightList->InsertColumn(1,l("Weight"), wxLIST_FORMAT_LEFT, 60);
2303 
2304  for(int b = 0;b < Egg.GetDays();b++) {
2305  AdvWeightList->InsertItem(b, wxString::Format(wxT("%s %d"),l("Day"), b + 1));
2306  if(Batches.GetAdvanced(MainList->GetFirstSelected()).GetUnit() == 0)
2307  AdvWeightList->SetItem(b, 1, wxString::Format(wxT("%.3foz"), Egg.GetDayWeight()[b].GetFloat()));
2308  else
2309  AdvWeightList->SetItem(b, 1, wxString::Format(wxT("%.3fg"), Egg.GetDayWeight()[b].GetFloat()));
2310  }
2311 
2312  if(Select != -1)
2313  AdvWeightList->Select(Select, true);
2314 }
2315 
2317 void HatchFrame::OnWeightChange(wxSpinDoubleEvent&)
2318 {
2319  int sel = AdvEggList->GetFirstSelected();
2320 
2321  if(sel == -1 || MainList->GetFirstSelected() == -1)
2322  return;
2323 
2324  HK_Egg Egg = Batches.GetAdvanced(MainList->GetFirstSelected()).GetEgg(sel);
2325 
2326  int sel2 = AdvWeightList->GetFirstSelected();
2327 
2328  if(sel2 == -1)
2329  return;
2330  vector<HK_Weight> W = Egg.GetDayWeight();
2331 
2332  W[sel2].Set(AdvWeightCtrl->GetValue());
2333 
2334  Egg.SetDayWeight(W);
2335  Batches.SetAdvEgg(MainList->GetFirstSelected(),Egg,sel);
2336  Batches.SetAdvUpdate(MainList->GetFirstSelected(),true);
2337 
2338  //Update Controls
2339  if(Batches.GetAdvanced(MainList->GetFirstSelected()).GetUnit() == 0)
2340  AdvWeightList->SetItem(sel2, 1, wxString::Format(wxT("%.3foz"), AdvWeightCtrl->GetValue()));
2341  else
2342  AdvWeightList->SetItem(sel2, 1, wxString::Format(wxT("%.3fg"), AdvWeightCtrl->GetValue()));
2343  AdvEggList->SetItem(sel, 1, wxString::Format(wxT("%d%%"),Egg.CalcTotalLoss()));
2344 
2345  AdvTotalLossStat->SetLabel(wxString::Format(wxT("%d%% %s"), Egg.CalcTotalLoss(), l("Total Weight Loss")));
2346  AdvTotalLossStat->Refresh();
2347 
2348  AdvDayLossStat->SetLabel(wxString::Format(wxT("%d%% %s %d"), Egg.CalcDayLoss(sel2),l("Loss On Day"),(sel2+1)));
2349  AdvDayLossStat->Refresh();
2350 
2351  AdvAvgBatchLossStat->SetLabel( wxString::Format(wxT("%d%% %s"), Batches.GetAdvanced(MainList->GetFirstSelected()).CalcAvgLoss(), l("Avg Weight Loss For All Eggs In Batch")));
2352  AdvAvgBatchLossStat->Wrap( 150 );
2353  AdvAvgBatchLossStat->Refresh();
2354 }
2355 
2357 void HatchFrame::OnDayCommentChange(wxCommandEvent&)
2358 {
2359  int sel = AdvEggList->GetFirstSelected();
2360 
2361  if(sel == -1 || MainList->GetFirstSelected() == -1)
2362  return;
2363 
2364  HK_Egg Egg = Batches.GetAdvanced(MainList->GetFirstSelected()).GetEgg(sel);
2365 
2366  int sel2 = AdvWeightList->GetFirstSelected();
2367  //Comments
2368  int lines = AdvDayCommentCtrl->GetNumberOfLines();
2369  string forComment = "";
2370 
2371  if(lines == 1)
2372  forComment = AdvDayCommentCtrl->GetLineText(0);
2373 
2374  else {
2375  for (int a = 0;a < lines; a++) {
2376  if(a == 0)
2377  forComment += AdvDayCommentCtrl->GetLineText(a);
2378  else
2379  forComment += "\n" + AdvDayCommentCtrl->GetLineText(a);
2380 
2381  }
2382  }
2383  vector<string> C = Egg.GetDayComments();
2384  C[sel2] = forComment;
2385 
2386  Egg.SetDayComments(C);
2387  Batches.SetAdvEgg(MainList->GetFirstSelected(),Egg,sel);
2388  Batches.SetAdvUpdate(MainList->GetFirstSelected(),true);
2389 }
2390 
2392 /*Notification*/
2395 void HatchFrame::ShowMsg(string Msg)
2396 {
2397  wxMessageDialog dialog(this,Msg.c_str());
2398  dialog.ShowModal();
2399 }
2400 
2403 
2405 void HatchTaskBarIcon::OnWindowExit(wxCommandEvent& )
2406 {
2407  string FileFolder = HATCHKEEPER_DATA + "Condition";
2408 
2409  //Write a int to tell inform HatchKeeper on start-up
2410  FILE *fp;
2411 
2412  if ((fp = fopen(FileFolder.c_str(), "w"))== NULL)
2413  fprintf(stderr,"Error Creating HatchKeeper Condition File!");
2414  else {
2415  fprintf(fp,"0");
2416  fclose(fp);
2417  }
2418 
2419  ActuallyExit = true;
2420 
2421  //Clean up some stuff to prevent segfault
2422  this->Destroy(); //HatchTaskBarIcon
2423  frame->Close(true);
2424 }
2425 
2427 void HatchFrame::OnTimer(wxTimerEvent&){ShowNotifications();}
2428 
2431 {
2432  unsigned int A = 0;
2433  vector<string> Updates = Notify.CheckDates(Batches, Remind);
2434 
2435  for(A = 0; A < Updates.size(); A++) {
2436  if(!Database.Execute(Updates[A]))
2437  ShowMsg("Sqlite Error: " + Database.GetErrors());
2438 
2439  }
2441 
2442  bool rescan = false;
2443  string notifyNote,sql;
2444 
2445  //And show them
2446  HK_Date hkDate;
2447 
2448  NoteList->ClearAll();//Clear the previous list items
2449  NoteList->InsertColumn(0,l("Name" ), wxLIST_FORMAT_LEFT, 125);
2450  NoteList->InsertColumn(1,l("Description" ), wxLIST_FORMAT_LEFT, 260);
2451  NoteList->InsertColumn(2,l("Date Issued" ), wxLIST_FORMAT_LEFT, 90);
2452  NoteList->InsertColumn(3,l("Days Old" ), wxLIST_FORMAT_LEFT, 70);
2453 
2454  for (A = 0; A < Notify.GetCount(); A++) {
2455 
2456  hkDate = Notify.GetDate(A);
2457  wxDateTime date(
2458  hkDate.GetDay(),
2459  wxDateTime::Month(wxDateTime::Jan + hkDate.GetMonth() - 1),
2460  hkDate.GetYear(),
2461  0,0,0,0
2462  );
2463 
2464  wxDateTime now = wxDateTime::Now();
2465  wxTimeSpan timeS = now.Subtract(date);
2466 
2467  NoteList->InsertItem(A, wxString::Format(wxT("%s"), Notify.GetName(A).c_str()));
2468  NoteList->SetItem(A, 1,wxString::Format(wxT("%s"), Notify.GetText(A).c_str()) );
2469  NoteList->SetItem(A, 2,wxString::Format(wxT("%s"), hkDate.ToReadable("/",Settings.GetInt("DateMode")).c_str()) );
2470  NoteList->SetItem(A, 3,wxString::Format(wxT("%d"), timeS.GetDays()) );
2471 
2472  if(Notify.GetNumber(A) == 0) {
2473  notifyNote = Notify.GetText(A);
2474 
2475  if(Settings.GetInt("UseGenNotify") == 0){
2476  TheGenNotification = new wxGenericNotificationMessage(
2477  "HatchKeeper_Reminder ",
2478  notifyNote.c_str(),
2479  NULL);
2480 
2481  TheGenNotification->SetIcon(TaskBar_xpm);
2482 
2483  TheGenNotification->Show(wxNotificationMessage::Timeout_Never);
2484  TheGenNotification->Bind(wxEVT_NOTIFICATION_MESSAGE_CLICK, &HatchFrame::OnNotificationClicked, this);
2485  TheGenNotification->Bind(wxEVT_NOTIFICATION_MESSAGE_DISMISSED, &HatchFrame::OnNotificationDismissed, this);
2486  UsedGen = true;
2487  }
2488  else {
2489  TheNotification = new wxNotificationMessage(
2490  "HatchKeeper_Reminder ",
2491  notifyNote.c_str(),
2492  NULL);
2493 
2494  TheNotification->SetIcon(TaskBar_xpm);
2495 
2496 //Under Windows we Bind the notification to the taskbaricon
2497 #if defined(__WXMSW__) && wxUSE_TASKBARICON
2498  wxNotificationMessage::UseTaskBarIcon(m_taskBarIcon);
2499 #endif
2500  TheNotification->Show(wxNotificationMessage::Timeout_Never);
2501  TheNotification->Bind(wxEVT_NOTIFICATION_MESSAGE_CLICK, &HatchFrame::OnNotificationClicked, this);
2502  TheNotification->Bind(wxEVT_NOTIFICATION_MESSAGE_DISMISSED, &HatchFrame::OnNotificationDismissed, this);
2503 
2504  UsedGen = false;
2505  }
2506 
2507  //Update LocalStorage
2508  Notify.SetNumber(A, 1);
2509  //Update Database
2510  if(!Database.Execute("UPDATE Notifications SET IsNotified = 1 WHERE ID = " + to_string(Notify.GetID(A)) + ";"))
2511  ShowMsg("Sqlite Error: " + Database.GetErrors());
2512  }
2513 
2514  if(timeS.GetDays() > 3)
2515  if(!Database.Execute("DELETE FROM Notifications where ID = " + to_string(Notify.GetID(A)) + ";"))
2516  ShowMsg("Sqlite Error: " + Database.GetErrors());
2517  }
2518 }
2519 
2522 {
2523  if(Settings.GetInt("OpenOnClick") == 0) {
2524  int hold;
2525  //turn off splash
2526  hold = Settings.GetInt("ShowSplash");
2527  Settings.SetValue("ShowSplash", "1");
2528 
2529  ShowFrame();
2530 
2531  m_notebook2->SetSelection(3);
2532 
2533  Settings.SetValue("ShowSplash", to_string(hold));
2534  }
2535 
2536  //Clean Up
2537  if(UsedGen) {
2538  delete TheGenNotification;
2539  TheGenNotification = NULL;
2540  }
2541 //Under OSX it crashes if we delete native notifications
2542 #ifndef __WXOSX__
2543  else {
2544  delete TheNotification;
2545  TheNotification = NULL;
2546  }
2547 #endif //__WXOSX__
2548 }
2549 
2552 {
2553  if(Settings.GetInt("OpenOnDismiss") == 0) {
2554  //turn off splash
2555  int hold = Settings.GetInt("ShowSplash");
2556  Settings.SetValue("ShowSplash", "1");
2557 
2558  ShowFrame();
2559 
2560  m_notebook2->SetSelection(3);
2561 
2562  Settings.SetValue("ShowSplash", to_string(hold));
2563  }
2564  //Clean Up
2565  if(UsedGen) {
2566  delete TheGenNotification;
2567  TheGenNotification = NULL;
2568  }
2569 //Under OSX it crashes if we delete native notifications
2570 #ifndef __WXOSX__
2571  else {
2572  delete TheNotification;
2573  TheNotification = NULL;
2574  }
2575 #endif //__WXOSX__
2576 }
2577 
2580 {
2581  if (Settings.GetInt("ShowSplash") == 0) {
2582  wxBitmap bitmap;
2583 
2584  string FileFolder = HATCHKEEPER_DATA + "Images/Splash.png";
2585  if (bitmap.LoadFile(FileFolder.c_str(), wxBITMAP_TYPE_PNG)) {
2586  wxSplashScreen* splash = new wxSplashScreen(bitmap,
2587  wxSPLASH_CENTRE_ON_PARENT|wxSPLASH_TIMEOUT,
2588  3000, NULL, -1, wxDefaultPosition, wxDefaultSize,
2589  wxBORDER_SIMPLE|wxSTAY_ON_TOP|wxHORIZONTAL|wxCENTER_ON_SCREEN);
2590  }
2591  }
2592  frame->Show(true);
2593  frame->Raise();
2594 }
HK_KeyValue Settings
Definition: Declare.h:36
HK_Info Info
Definition: Declare.h:34
HK_Date Today
Definition: Declare.h:33
HK_Notifications Notify
Definition: Declare.h:42
HK_Batches Batches
Definition: Declare.h:44
HK_Storage Types
Definition: Declare.h:38
HK_Storage Remind
Definition: Declare.h:40
std::string HATCHKEEPER_DATA
Definition: Declare.h:30
HK_File Files
Definition: Declare.h:47
HK_Storage Breeds
Definition: Declare.h:37
HK_Database Database(HATCHKEEPER_DATA+"HatchKeeper.db")
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_Documents ExportImport
Definition: Declare.h:46
int HatchCondition
Definition: HatchKeeper.cpp:29
void HatchTerm(int signum)
Handles Sigterm(Shutdown) Under Linux And Cleans Up.
bool UsedGen
Definition: HatchKeeper.cpp:34
void ShowFrame()
Shows Splash Screen Then Shows And Raises Main Frame.
Holds stuff related to the main window.
const int TIMER1
Definition: HatchKeeper.h:61
const int GR_ADD
Definition: HatchKeeper.h:86
const int ON_ABOUT
Definition: HatchKeeper.h:69
const int ON_IMPORT
Definition: HatchKeeper.h:70
const int HIDE_HATCH
Definition: HatchKeeper.h:79
const int ON_FERTILE
Definition: HatchKeeper.h:82
const int ADV_FERTILE
Definition: HatchKeeper.h:94
const int GR_DELETE
Definition: HatchKeeper.h:87
const int ADV_TAG_CH
Definition: HatchKeeper.h:100
const int ON_PREF
Definition: HatchKeeper.h:66
const int ON_CALPRN
Definition: HatchKeeper.h:76
const int ON_HATCHED
Definition: HatchKeeper.h:83
const int ON_REFR
Definition: HatchKeeper.h:67
const int CAL_CHANGE
Definition: HatchKeeper.h:78
const int ON_SEARCH
Definition: HatchKeeper.h:60
const int ON_UPDATE
Definition: HatchKeeper.h:73
const int ON_SORT
Definition: HatchKeeper.h:57
const int ADV_EGG_COM
Definition: HatchKeeper.h:92
const int ADV_RES_CH
Definition: HatchKeeper.h:98
const int ON_GRAPH
Definition: HatchKeeper.h:58
const int ADV_RES_DATE
Definition: HatchKeeper.h:99
const int ADV_DAY_COM
Definition: HatchKeeper.h:96
const int ON_DELETE
Definition: HatchKeeper.h:74
const int ON_BATCH
Definition: HatchKeeper.h:64
const int ADV_PIP
Definition: HatchKeeper.h:93
const int GR_MORE
Definition: HatchKeeper.h:88
const int ON_EGG
Definition: HatchKeeper.h:81
const int ON_MORE
Definition: HatchKeeper.h:75
const int ADV_WEIGHT
Definition: HatchKeeper.h:95
const int ON_SCH
Definition: HatchKeeper.h:65
const int GR_COMMENT
Definition: HatchKeeper.h:89
const int ON_REMIND
Definition: HatchKeeper.h:68
const int ON_QUIT
Definition: HatchKeeper.h:71
HatchServer * h_server
#define IPC_HOST
wxSingleInstanceChecker * h_checker
HatchClient * h_client
#define IPC_SERVICE
#define IPC_TOPIC
const int ON_EXIT
Definition: TaskbarIcon.cpp:13
const int ON_RESHOW
Definition: TaskbarIcon.cpp:12
A Dialog For Adding A New Batch.
Definition: BatchDialog.cpp:23
bool WasCanceled()
Returns True If The Cancel Button Was Clicked.
A Dialog For Viewing Graph Stats.
Definition: GraphDialog.cpp:29
A Class For Managing Multiple HK_Egg Instances.
Definition: Advanced.h:20
HK_Egg GetEgg(int Select)
Returns The Selected Egg.
Definition: HK_Advanced.cpp:50
int GetEggCount()
Returns The Number Of Eggs.
Definition: HK_Advanced.cpp:52
string GetSQL()
Definition: HK_Advanced.cpp:78
int GetDays()
Returns Incubation Days.
Definition: HK_Advanced.cpp:46
int CalcAvgLoss()
Returns The Average Weight Loss For All Eggs In Batch.
Definition: HK_Advanced.cpp:14
int GetUnit()
Returns Weight Unit.
Definition: HK_Advanced.cpp:44
void Set(int ID, int Unit, int Days, vector< HK_Egg > Eggs)
Initialize In One Function Call.
Holds Data For One Batch, Includes Basic Set/Get Methods.
Definition: Batch.h:22
int PercentOfTotal()
Returns The Percentage Of Total Eggs That Hatched.
Definition: HK_Batch.cpp:290
int PercentFertile()
Returns The Percentage Of Eggs That Were Fertile.
Definition: HK_Batch.cpp:278
void SetAdvanced(HK_Advanced Adv)
Sets Batch Advanced Data.
Definition: HK_Batch.cpp:132
void SetCandle(HK_Date Candle)
Sets Batch Candle Date.
Definition: HK_Batch.cpp:122
int GetChicks()
Returns Number Of Hatched Eggs In Batch, If Advanced Is Enabled It Returns HK_Advanced::GetChicks()
Definition: HK_Batch.cpp:166
HK_Date GetCandle()
Returns Batch Candle Date.
Definition: HK_Batch.cpp:177
string GetName()
Returns Batch Name.
Definition: HK_Batch.cpp:142
int GetFertile()
Returns Number Of Fertile Eggs In Batch, If Advanced Is Enabled It Returns HK_Advanced::GetFertile()
Definition: HK_Batch.cpp:157
void SetFertile(int Fertile)
Sets Batch Fertile Eggs.
Definition: HK_Batch.cpp:116
void SetName(string Name)
Sets Batch Name.
Definition: HK_Batch.cpp:102
HK_Date GetStart()
Returns Batch Start Date.
Definition: HK_Batch.cpp:175
string GetIncubator()
Returns The Incubator As A String.
Definition: HK_Batch.cpp:152
vector< string > GetUpdate()
Returns A String That Updates This Batch In Database.
Definition: HK_Batch.cpp:210
string GetGroup()
Returns Batch Group.
Definition: HK_Batch.cpp:148
int OnDay()
Returns The Number Of Days Left In Incubation Period.
Definition: HK_Batch.cpp:266
int GetEggs()
Returns Number Of Eggs In Batch.
Definition: HK_Batch.cpp:154
void SetType(string Type)
Sets Batch Type.
Definition: HK_Batch.cpp:104
void SetIncubator(string Incubator)
Sets Batch Incubator.
Definition: HK_Batch.cpp:112
HK_Date GetLockdown()
Returns Batch Lockdown Date.
Definition: HK_Batch.cpp:179
void SetChicks(int Chicks)
Sets Batch Hatched Eggs.
Definition: HK_Batch.cpp:118
void SetComments(string Comments)
Sets Batch Comments.
Definition: HK_Batch.cpp:110
string GetComments()
Returns Batch Comments.
Definition: HK_Batch.cpp:150
void SetBreed(string Breed)
Sets Batch Breed.
Definition: HK_Batch.cpp:106
int GetDaysLeft()
Returns The Number Of Days Left In Incubation Period.
Definition: HK_Batch.cpp:254
int FertileUnhatched()
Returns The Number Of Fertile Eggs That Didn't Hatch.
Definition: HK_Batch.cpp:296
string GetBreed()
Returns Batch Breed.
Definition: HK_Batch.cpp:146
void SetHatch(HK_Date Hatch)
Sets Batch Hatch Date.
Definition: HK_Batch.cpp:126
void SetEggs(int Eggs)
Sets Batch Eggs.
Definition: HK_Batch.cpp:114
int PercentOfTotalUnhatched()
Returns The Percentage Of Total Eggs That Didn't Hatch.
Definition: HK_Batch.cpp:302
int PercentOfFertile()
Returns The Percentage Of Fertile Eggs That Hatched.
Definition: HK_Batch.cpp:284
void SetStart(HK_Date Start)
Sets Batch Start Date.
Definition: HK_Batch.cpp:120
int GetID()
Returns Batch ID.
Definition: HK_Batch.cpp:140
int GetAdv()
Returns Batch Advanced Status.
Definition: HK_Batch.cpp:185
string GetType()
Returns Batch Type.
Definition: HK_Batch.cpp:144
void SetLockdown(HK_Date Lockdown)
Sets Batch Lockdown Date.
Definition: HK_Batch.cpp:124
void SetGroup(string Group)
Sets Batch Group.
Definition: HK_Batch.cpp:108
HK_Date GetHatch()
Returns Batch Hatch Date.
Definition: HK_Batch.cpp:181
A Class For Managing Mulitple HK_Batch Objects.
Definition: Batches.h:22
HK_Advanced GetAdvanced(int Select)
Returns Advanced Egg Data Selected Batch.
Definition: HK_Batches.cpp:93
HK_Date GetHatch(int Select)
Returns Hatch Date For Selected Batch.
Definition: HK_Batches.cpp:87
int GetID(int Select)
Returns Batch ID For Selected Batch.
Definition: HK_Batches.cpp:61
int PercentOfTotalUnhatched(int Select)
Returns The Percentage Of Total Eggs That Didn't Hatch For The Selected Batch.
Definition: HK_Batches.cpp:129
HK_Date GetStart(int Select)
Returns Start Date For Selected Batch.
Definition: HK_Batches.cpp:81
void Add(HK_Batch Batch)
Adds Another HK_Batch.
Definition: HK_Batches.cpp:15
void SetClean(int Select)
Clears Dirty Mark For Selected Batch.
Definition: HK_Batches.cpp:259
int AvgTotalUnHatch()
Returns Average Percentage Of Total Eggs That Did Not Hatch In This HK_Batches Instance.
Definition: HK_Batches.cpp:181
int AvgFertileHatch()
Returns Average Percentage Of Fertile Eggs That Hatched In This HK_Batches Instance.
Definition: HK_Batches.cpp:172
void SetAdvUpdate(int Select, bool Status)
Sets The Update Status HK_Advanced.
Definition: HK_Batches.cpp:250
int GetAdv(int Select)
Returns Advanced Status For Selected Batch.
Definition: HK_Batches.cpp:91
int AvgFertile()
Returns Average Percentage Of Eggs Fertile In This HK_Batches Instance.
Definition: HK_Batches.cpp:154
void SetBatch(int Select, HK_Batch Batch)
Replaces Batch In Selected Position In Array. Use Add() To Add A Batch.
Definition: HK_Batches.cpp:253
int GetChicks(int Select)
Returns Number Of Hatched Eggs For Selected Batch.
Definition: HK_Batches.cpp:79
bool IsDirty(int Select)
Returns True If Batch Has Dirty Mark Set.
Definition: HK_Batches.cpp:102
int GetFertile(int Select)
Returns Number Of Fertile Eggs For Selected Batch.
Definition: HK_Batches.cpp:77
int PercentOfTotal(int Select)
Returns The Percentage Of Total Eggs That Hatched For The Selected Batch.
Definition: HK_Batches.cpp:117
HK_Date GetCandle(int Select)
Returns Candle Date For Selected Batch.
Definition: HK_Batches.cpp:83
int TotalEggs()
Returns Total Number Of Eggs In This HK_Batches Instance.
Definition: HK_Batches.cpp:136
int AvgTotalHatch()
Returns Average Percentage Of Total Eggs That Hatched In This HK_Batches Instance.
Definition: HK_Batches.cpp:163
HK_Batch GetBatch(int Select)
Returns The Selected Batch.
Definition: HK_Batches.cpp:55
string GetGroup(int Select)
Returns Batch Group For Selected Batch.
Definition: HK_Batches.cpp:69
void SetAdvEgg(int Select, HK_Egg Egg, int EggSelect)
Sets The Selected Egg For HK_Advanced.
Definition: HK_Batches.cpp:244
int GetEggs(int Select)
Returns Number Of Eggs For Selected Batch.
Definition: HK_Batches.cpp:75
int PercentFertile(int Select)
Returns The Percentage Of Egg That Were Fertile For The Selected Batch.
Definition: HK_Batches.cpp:105
int GetCount()
Returns The Number Of Batches Stored.
Definition: HK_Batches.cpp:191
int PercentOfFertile(int Select)
Returns The Percentage Of Fertile Eggs That Hatched For The Selected Batch.
Definition: HK_Batches.cpp:111
HK_Date GetLockdown(int Select)
Returns Lockdown Date For Selected Batch.
Definition: HK_Batches.cpp:85
int TotalChicks()
Returns Total Number Of Chicks In This HK_Batches Instance.
Definition: HK_Batches.cpp:145
string GetName(int Select)
Returns Batch Name For Selected Batch.
Definition: HK_Batches.cpp:63
HK_Notifications ReadNotify()
Scans Notifications Into A HK_Storage Object.
bool Execute(string SQL)
Executes SQL Statments.
string GetErrors()
Returns sqlite3_errmsg(HK_DB))
HK_Storage ReadGroups()
Scans Groups Into A HK_Storage Object.
HK_Batches ReadBatches(int Sort)
Scans Batches Into HK_Batches Object.
A Class For Managing Dates.
Definition: Date.h:25
int GetMonth()
Returns Month Value.
Definition: HK_Date.cpp:60
int Difference(HK_Date Date)
Returns The Number Of Days Difference Between This HK_Date And The Supplied Date.
Definition: HK_Date.cpp:84
std::string MonthName()
Returns HK_Month's Name As String.
Definition: HK_Date.cpp:188
void Reset()
Resets Date To Today.
Definition: HK_Date.cpp:400
std::string ToReadable(std::string Separator, int Mode)
Generate A Readable String.
Definition: HK_Date.cpp:132
bool AddDays(int Days)
Adds Days To This HK_Date.
Definition: HK_Date.cpp:70
bool IsValid()
Checks If This HK_Date Contains A Valid Date.
Definition: HK_Date.cpp:194
int GetDay()
Returns Day Value.
Definition: HK_Date.cpp:57
int GetYear()
Returns Year Value.
Definition: HK_Date.cpp:63
int MonthToInt(std::string Month)
Converts Month Name To An Int.
Definition: HK_Date.cpp:175
string BatchTextReport(HK_Batch Batch, HK_KeyValue Settings)
Returns A Text Batch Report For Archiving Batch Data.
string BatchICal(HK_Batch Batch, bool DatesOnly)
Generates iCal Text With Batch Data.
vector< string > ImportHKBF(string Filename, HK_Batches *Batches, HK_Storage *Groups, HK_Storage *Types, HK_Storage *Breeds, HK_Storage *Schedules)
Tries Reading And Generating HK_Batch Objects From HKBF.
string GroupHTMLReport(HK_Batches GrBatches, string GroupName, string Comments, HK_KeyValue Settings)
string GroupTextReport(HK_Batches GrBatches, string GroupName, string Comments, HK_KeyValue Settings)
Generates A Text Group Report For Archiving.
string GroupICal(HK_Batches GrBatches, string GroupName)
Generates iCal Text With Group Data.
string BatchHTMLReport(HK_Batch Batch, HK_KeyValue Settings)
Returns An HTML String For Printing Reports.
string HTMLCalendar(HK_Date Selection, HK_Batches Batches)
Generates A HTML Calendar For This HK_Month Using Dates From Batches.
bool ExportHKBF(string Filename, HK_Batches Batches, HK_Storage Groups)
Overloaded: Exports Multiple Batches, and a Group To A hkbf(xml) File.
A Class For Storing And Retieving Data For One Egg.
Definition: Egg.h:24
int GetResult()
Returns -1 If No Result, 0 If Hatched, And 2 If Egg Quit.
Definition: HK_Egg.cpp:58
string GetComments()
Returns Egg Comments.
Definition: HK_Egg.cpp:64
int CalcDayLoss(int Day)
Returns The Percentage Of Weight Lost From Previous Weighing.
Definition: HK_Egg.cpp:24
void SetDayWeight(vector< HK_Weight > Weight)
Sets Weight For All Days.
Definition: HK_Egg.cpp:153
void SetDate(HK_Date Date)
Sets Result Date.
Definition: HK_Egg.cpp:149
void SetComments(string Comments)
Sets Egg Comments.
Definition: HK_Egg.cpp:151
int GetDays()
Returns The Number Of Days For This Egg.
Definition: HK_Egg.cpp:62
string GetTag2()
Returns Tag 2 As A String.
Definition: HK_Egg.cpp:50
void Set(string Tag1, string Tag2, string Tag3, int Fertile, int Pipped, int Result, HK_Date Date, string Comments, vector< HK_Weight > DayWeight, vector< string > DayComments)
Sets All Data In One Function.
Definition: HK_Egg.cpp:111
int CalcTotalLoss()
Returns The Total Percentage Of Weight Lost By This Egg.
Definition: HK_Egg.cpp:38
void SetResult(int Result)
Sets Result Status.
Definition: HK_Egg.cpp:147
HK_Date GetDate()
Returns The Date For The Result.
Definition: HK_Egg.cpp:60
string GetTag3()
Returns Tag 3 As A String.
Definition: HK_Egg.cpp:52
void SetTag3(string Tag)
Sets The Third Tag.
Definition: HK_Egg.cpp:141
void SetTag1(string Tag)
Sets The First Tag.
Definition: HK_Egg.cpp:137
void SetFertile(int Fertile)
Sets Fertile Status.
Definition: HK_Egg.cpp:143
vector< string > GetDayComments()
Returns An Array Containing A Comment For Every Day.
Definition: HK_Egg.cpp:68
vector< HK_Weight > GetDayWeight()
Returns An Array Containing A Weight For Every Day.
Definition: HK_Egg.cpp:66
void SetPipped(int Pipped)
Sets Pip Status.
Definition: HK_Egg.cpp:145
void SetTag2(string Tag)
Sets The Second Tag.
Definition: HK_Egg.cpp:139
int GetPipped()
Returns 0 If Egg Is Not Pipped And 1 If It Is.
Definition: HK_Egg.cpp:56
string GetTag1()
Returns Tag 1 As A String.
Definition: HK_Egg.cpp:48
int GetFertile()
Returns 0 If Egg Is Not Fertile And 1 If It Is.
Definition: HK_Egg.cpp:54
void SetDayComments(vector< string > Comments)
Sets Comments For All Days.
Definition: HK_Egg.cpp:157
bool WriteTextFile(string FileName, string Text)
Opens Filename And Writes Text.
Definition: HK_File.cpp:86
std::string GetValidChars()
Returns Chars That Are Allowed In Text Controls.
Definition: HK_Info.cpp:12
vector< string > GetArray(int Selection)
Returns The Selected Value As An Array Of Strings.
void SetValue(int Selection, string Value)
Sets Value For Selection. Sets Dirty As Well.
vector< int > GetIntArray(int Selection)
Returns The Selected Value As An Array Of Integers.
int GetInt(int Selection)
Returns The Selected Setting Value As An Integer.
Definition: HK_KeyValue.cpp:49
string GetValue(int Selection)
Returns The Selected Setting Value As A String.
Definition: HK_KeyValue.cpp:67
vector< string > CheckDates(HK_Batches Batches, HK_Storage Reminders)
Checks The HK_Batches and HK_Storage Objects For New Notifications.
A Class For Storing Values.
Definition: Storage.h:26
bool IsValidName(string Name)
Returns True If Name Isn't Already In Use.
Definition: HK_Storage.cpp:128
HK_Date GetDate(int Select)
Returns The Selected Stored Date.
Definition: HK_Storage.cpp:71
int GetValidID()
Returns A Valid ID For Adding Entries To The Database.
Definition: HK_Storage.cpp:106
int GetCount()
Returns The Number Of Elements Stored.
Definition: HK_Storage.cpp:101
int GetNumber(int Select)
Returns The Selected Stored Number.
Definition: HK_Storage.cpp:96
void SetNumber(int Select, int Number)
Sets The Selected Stored Number.
Definition: HK_Storage.cpp:207
string GetName(int Select)
Returns The Selected Stored Name.
Definition: HK_Storage.cpp:61
string GetText(int Select)
Returns The Selected Stored Text.
Definition: HK_Storage.cpp:91
void Add(string Name, int ID, HK_Date Date, string Text, int Number)
Adds An Item To Storage.
Definition: HK_Storage.cpp:15
int GetID(int Select)
Returns The Selected Stored ID.
Definition: HK_Storage.cpp:66
void SetText(int Select, string Text)
Sets The Selected Stored Text.
Definition: HK_Storage.cpp:202
A Class For Managing Data For One Weight.
Definition: Weight.h:24
virtual bool OnInit()
Initializes The App.
int OnExit()
Clean Up On Exit.
virtual void MacReopenApp()
Needed under Mac, Calls ShowFrame()
void OnExitSession(wxCloseEvent &evt)
Cleans up on Windows and Mac.
A localhost Client Used For Single Instance.
HatchConnection * GetConnection()
bool Connect(const wxString &sHost, const wxString &sService, const wxString &sTopic)
Atempts To Connect To Server Of Previous Instance.
void Disconnect()
Disconnect From Server.
The Main Window.
Definition: HatchKeeper.h:116
wxChoice * BPGroupChoice
Definition: HatchKeeper.h:233
wxChoice * AdvMoreChoice
Definition: HatchKeeper.h:318
void OnNotificationClicked(wxCommandEvent &)
Opens Main Frame When Notification Clicked.
wxStaticText * AdvTotalLossStat
Definition: HatchKeeper.h:312
void OnNotificationDismissed(wxCommandEvent &)
Opens Main Frame When Notification Dismissed.
void OnRefresh(wxCommandEvent &)
Refreshes Today Variable And Rescans Batches.
void OnWeightChange(wxSpinDoubleEvent &)
Fired When User Edits Day Weight.
void UnsetBatchStats(void)
Clears The Statistics Panel.
void OnCalPrn(wxCommandEvent &)
Prints A Calendar With All Batch Date For Month Selected In MainCalendar.
wxChoice * SortBatchChoice
Definition: HatchKeeper.h:270
wxCheckBox * AdvPipCheckbox
Definition: HatchKeeper.h:304
wxListView * MainList
Definition: HatchKeeper.h:268
void OnHideChange(wxCommandEvent &)
Fired When HideCheckBox Changes.
wxCheckBox * AdvFertileCheckbox
Definition: HatchKeeper.h:303
wxPanel * NotePanel
Definition: HatchKeeper.h:263
void OnFertileSpin(wxSpinEvent &)
Fired When BPFertileSpin Changes. Reverts Change If Batches.GetAdv(sel) == 1.
void OnUnSelectEgg(wxListEvent &)
Resets Ctrls With Default Values.
void OnSchedule(wxCommandEvent &)
Opens A ScheduleDialog Instance.
wxGenericCalendarCtrl * MainCalendar
Definition: HatchKeeper.h:227
wxStaticText * BPPerWerFerStat
Definition: HatchKeeper.h:245
wxStaticText * BPPerOfFerStat
Definition: HatchKeeper.h:247
wxStaticText * GrAOFHatchStat
Definition: HatchKeeper.h:288
void ShowGroups(bool Scan)
Populates GroupList.
void OnMoreActions(wxCommandEvent &)
Fired When MoreActionsChoice Selection Changes.
void ShowAdvWeight(HK_Egg Egg, int Select)
Fired When User Edits Day Weight.
wxSpinCtrlDouble * AdvWeightCtrl
Definition: HatchKeeper.h:311
void OnAdvResultDate(wxDateEvent &)
Fired When User Changes Result Date For Egg.
void OnCalChange(wxCalendarEvent &)
Gets Fired When The MainCalendar Month Changes.
void OnBatchName(wxCommandEvent &)
Fired When BPNameCtrl Is Edited. Updates Batches With New Name.
wxTextCtrl * AdvCommentCtrl
Definition: HatchKeeper.h:308
void RemoveAttr(void)
Removes Attr From MainCalendar.
void OnBatchGroup(wxCommandEvent &)
Fired When BPGroupChoice Is Changed. Updates Batches With New Group Name.
void ShowBatches(bool Scan)
Populates MainList With Data From Batches.
wxStaticText * AdvDayLossStat
Definition: HatchKeeper.h:313
wxStaticText * BPFerUnStat
Definition: HatchKeeper.h:244
wxPanel * GroupPanel
Definition: HatchKeeper.h:278
wxListView * AdvEggList
Definition: HatchKeeper.h:298
wxChoice * BPTypeChoice
Definition: HatchKeeper.h:231
wxSpinCtrl * BPEggSpin
Definition: HatchKeeper.h:236
int daysWAttr[5]
Definition: HatchKeeper.h:167
void DeleteAdvanced(int sel)
void OnCloseWindow(wxCloseEvent &evt)
Hides Window If ActuallyExit == False, Else Exits App.
wxDatePickerCtrl * AdvResultDate
Definition: HatchKeeper.h:307
void OnImport(wxCommandEvent &)
Allows The User To Select A File Then Add It's Data To Database.
bool SetBatchAsAdvanced(int sel)
Generates An Advanced Profile For Selected Batch.
wxChoice * AdvResultChoice
Definition: HatchKeeper.h:306
wxChoice * AdvTag1Choice
Definition: HatchKeeper.h:299
wxChoice * BPBreedChoice
Definition: HatchKeeper.h:232
wxListView * GroupList
Definition: HatchKeeper.h:279
wxChoice * GrMoreChoice
Definition: HatchKeeper.h:292
wxButton * GrDeleteButton
Definition: HatchKeeper.h:293
wxButton * GrUpateButton
Definition: HatchKeeper.h:281
void OnAdvDayUnSelect(wxListEvent &)
Called When Day Is Unselected.
void OnGroupUnSelect(wxListEvent &)
Fired When A GroupList Item Gets Unselected.
wxStaticText * GrAOTHatchStat
Definition: HatchKeeper.h:289
void ClearAdvPanel()
Resets Ctrls To Default Value.
wxChoice * BPIncubatorChoice
Definition: HatchKeeper.h:235
void OnAdvPippedChecked(wxCommandEvent &)
Fired When Pip Status Changes.
wxPanel * EggPanel
Definition: HatchKeeper.h:297
void OnTimer(wxTimerEvent &)
Calls ShowNotifications() At A Set Interval.
wxDatePickerCtrl * BPStartDateCtrl
Definition: HatchKeeper.h:250
void AddGroup(string Name, string Comment)
Adds A Group To The Database.
wxChartPanel * BatchGraphPanel
Definition: HatchKeeper.h:274
void OnSearch(wxCommandEvent &)
Opens SearchDialog.
void OnMoreGroupActions(wxCommandEvent &)
Fired If GrMoreChoice Selection Changes.
void OnDayCommentChange(wxCommandEvent &)
Fired When User Edits Day Comment.
void OnDelete(wxCommandEvent &)
Deletes A Batch From The Database.
wxDatePickerCtrl * BPCandleDateCtrl
Definition: HatchKeeper.h:252
wxStaticText * BPPerOfTotalStat
Definition: HatchKeeper.h:246
void OnBatchComments(wxCommandEvent &)
Fired When Batch Comments Are Edited.
void ShowBatchGraph(int sel)
Generates And Shows Graph In BatchGraphPanel For Selected Batch.
wxSpinCtrl * BPChicksHatchSpin
Definition: HatchKeeper.h:240
wxSpinCtrl * BPFertileSpin
Definition: HatchKeeper.h:238
void OnSelectEgg(wxListEvent &)
Fired When An Egg Is Selected.
void OnEggCommentChange(wxCommandEvent &)
Fired When AdvCommentCtrl Changes.
wxChoice * MoreActionsChoice
Definition: HatchKeeper.h:261
wxStaticText * GrAWFerStat
Definition: HatchKeeper.h:287
void ShowMsg(string Msg)
Uses wxMessageDialog To Display Message.
wxListView * NoteList
Definition: HatchKeeper.h:264
void OnAdvDaySelect(wxListEvent &)
Called When User Selects A Day.
void SetupBatchStats(int sel)
Sets Up The Statistics Panel.
wxChoice * AdvTag2Choice
Definition: HatchKeeper.h:300
void OnGraph(wxCommandEvent &)
Opens GraphDialog Instance.
wxTextCtrl * GrCommentCtrl
Definition: HatchKeeper.h:280
wxNotebook * m_notebook2
Definition: HatchKeeper.h:228
void ShowAdvanced()
wxTextCtrl * AdvDayCommentCtrl
Definition: HatchKeeper.h:315
void OnHatchedSpin(wxSpinEvent &)
Fired When BPChicksHatchSpin Changes. Reverts Change If Batches.GetAdv(sel) == 1.
wxStaticText * GrAOTUnHatchStat
Definition: HatchKeeper.h:290
void OnQuit(wxCommandEvent &)
Allows You To Completely Exit App Without Using TaskBar Icon.
void OnNewBatch(wxCommandEvent &)
Creates And Shows A BatchDialog Instance.
void OnAdvResultChoice(wxCommandEvent &)
Fired When Egg Result Is Changed.
wxCheckBox * HideCheckBox
Definition: HatchKeeper.h:272
wxStaticText * AdvAvgBatchLossStat
Definition: HatchKeeper.h:314
void OnAddGroup(wxCommandEvent &)
Wrapper To AddGroup()
void OnGroupSelect(wxListEvent &)
Fires When A GroupList Item Get Selected.
wxTextCtrl * GrTEggCtrl
Definition: HatchKeeper.h:284
void OnColumnClick(wxListEvent &evt)
Switches Groups Column.
void OnBatchBreed(wxCommandEvent &)
Fired When BPBreedChoice Is Changed. Updates Batches With New Breed.
wxGauge * BPProgressGauge
Definition: HatchKeeper.h:234
wxTextCtrl * BPCommentCtrl
Definition: HatchKeeper.h:258
void OnPreference(wxCommandEvent &)
Opens PrefDialog Instance And Applies Some Changes When It Closes.
void OnAbout(wxCommandEvent &)
Opens An Instance Of HelpDialog.
~HatchFrame()
Deconstructor.
void OnBatchType(wxCommandEvent &)
Fired When BPTypeChoice Is Changed. Updates Batches With New Type And Sets Breed To Unknown.
wxTextCtrl * GrTChickCtrl
Definition: HatchKeeper.h:286
void OnEggSpinner(wxSpinEvent &)
Fired When BPEggSpin Changes. Reverts Change If Batches.GetAdv(sel) == 1.
void OnGrComment(wxCommandEvent &)
Fired When Update Groups Button Is Clicked.
void OnUpdate(wxCommandEvent &)
Saves Batch Changes To Database.
void OnDelGroup(wxCommandEvent &)
Deletes One Group From Database, All Batches For This Group Get Deleted As Well.
void OnRemind(wxCommandEvent &)
Opens A ReminderDialog Instance.
HatchTaskBarIcon * m_taskBarIcon
Definition: HatchKeeper.h:321
void OnListSelect(wxListEvent &)
Fired When A MainList Item Gets Selected.
void OnBatchDates(wxDateEvent &)
Fired When Any Of The Batch Dates Are Changed.
void OnSort(wxCommandEvent &)
Fired When SortBatchChoice Is Changed. Rescans The Batches With New Sorting.
void OnBatchIncubator(wxCommandEvent &)
Fired When BPIncubatorChoice Is Changed. Updates Batches With New Incubator.
wxDatePickerCtrl * BPLockDateCtrl
Definition: HatchKeeper.h:254
wxStaticText * BPPerUnhatchStat
Definition: HatchKeeper.h:248
wxTextCtrl * BPNameCtrl
Definition: HatchKeeper.h:230
void OnTagsChange(wxCommandEvent &)
Gets Called When Any Of The 3 Tags Change.
void OnAdvFertileChecked(wxCommandEvent &)
Fired When Fertile Status Changes.
wxDatePickerCtrl * BPHatchDateCtrl
Definition: HatchKeeper.h:256
void OnListDESelect(wxListEvent &evt)
Fired When A MainList Item Gets Unselected.
wxListView * GrBatchList
Definition: HatchKeeper.h:282
wxPanel * BatchPanel
Definition: HatchKeeper.h:229
wxListView * AdvWeightList
Definition: HatchKeeper.h:310
void ShowNotifications()
Shows Popup Notifications To User And Adds Them To NoteList.
wxChoice * AdvTag3Choice
Definition: HatchKeeper.h:301
A localhost Server Used For Single Instance.
A Taskbar Icon That Is Visable When HatchKeeper Is Running.
Definition: TaskbarIcon.cpp:22
void OnWindowRestore(wxCommandEvent &)
Calls ShowFrame()
void OnWindowExit(wxCommandEvent &)
Exits The App Completely.
A Dialog For Displaying Version, Help, Credits And More.
Definition: HelpDialog.cpp:21
Manages App Settings.
Definition: PrefDialog.cpp:400
A Dialog For Managing Reminders.
Manage Scheduled Hatch Dates.
03.24.2020