32 static wxNotificationMessage * TheNotification = NULL;
33 static wxGenericNotificationMessage * TheGenNotification = NULL;
36 static bool ActuallyExit =
false;
107 if ((fp = fopen(FileFolder.c_str(),
"w"))== NULL)
108 fprintf(stderr,
"Error Creating HatchKeeper Condition File!");
133 wxString s = wxT(
"HatchKeeper");
153 std::cout<<
"Server %s failed to start\n";
159 struct sigaction action;
160 memset(&action, 0,
sizeof(
struct sigaction));
162 sigaction(SIGTERM, &action, NULL);
168 cout<<FileFolder<<endl;
169 if ((fp = fopen(FileFolder.c_str(),
"r"))== NULL)
170 fprintf(stderr,
"Warning, HatchKeeper Condition File Not Found!");
212 if ((fp = fopen(FileFolder.c_str(),
"w"))== NULL) {
213 fprintf(stderr,
"Error Creating HatchKeeper Condition File!");
231 if( evt.CanVeto() && ActuallyExit ==
false) {
245 int answer = wxMessageBox(
246 l(
"Exit Completely?") +
"\n" +
l(
"Yes( No Notifications! )") +
"\n" +
l(
"No( Run In Background )"),
251 if (answer == wxYES) {
257 if ((fp = fopen(FileFolder.c_str(),
"w"))== NULL)
258 fprintf(stderr,
"Error Creating HatchKeeper Condition File!");
268 if (answer == wxNO) {
269 ActuallyExit =
false;
277 wxFileDialog importDialog(
279 l(
"Import Batch File"),
282 "HatchKeeper Batch Files (*.hkbf)|*.hkbf",
283 wxFD_OPEN|wxFD_FILE_MUST_EXIST,
289 if (importDialog.ShowModal() == wxID_CANCEL)
293 importDialog.GetPath().ToStdString(),
302 ShowMsg(
l(
"Error! Couldn't Read File!"));
336 string SQL =
"UPDATE Settings SET Value = '" +
Settings.
GetValue(
"BatchSortState") +
"' WHERE Key = 'BatchSortState';";
364 int sel =
MainList->GetFirstSelected();
376 this->SetBackgroundColour(wxColor(ColorRed[0],ColorGreen[0],ColorBlue[0],225) );
379 wxFont CalFont(
Settings.
GetInt(
"CalTextSize"), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,wxFONTWEIGHT_BOLD,
true);
381 MainCalendar->SetBackgroundColour(wxColor(ColorRed[1],ColorGreen[1],ColorBlue[1],225));
382 MainCalendar->SetForegroundColour(wxColor(ColorRed[2],ColorGreen[2],ColorBlue[2],225));
385 MainList->SetBackgroundColour(wxColor(ColorRed[3],ColorGreen[3],ColorBlue[3],225) );
386 MainList->SetForegroundColour(wxColor(ColorRed[4],ColorGreen[4],ColorBlue[4],225));
389 BatchPanel->SetBackgroundColour( wxColor(ColorRed[5],ColorGreen[5],ColorBlue[5],225));
390 BatchPanel->SetForegroundColour( wxColor(ColorRed[6],ColorGreen[6],ColorBlue[6],225));
392 GroupPanel->SetBackgroundColour( wxColor(ColorRed[5],ColorGreen[5],ColorBlue[5],225));
393 GroupPanel->SetForegroundColour( wxColor(ColorRed[6],ColorGreen[6],ColorBlue[6],225));
395 NotePanel->SetBackgroundColour( wxColor(ColorRed[5],ColorGreen[5],ColorBlue[5],225));
396 NotePanel->SetForegroundColour( wxColor(ColorRed[6],ColorGreen[6],ColorBlue[6],225));
398 NoteList->SetBackgroundColour(wxColor(ColorRed[9],ColorGreen[9],ColorBlue[9],225) );
399 NoteList->SetForegroundColour(wxColor(ColorRed[10],ColorGreen[10],ColorBlue[10],225));
420 int sel =
MainList->GetFirstSelected();
449 if(evt.GetColumn() == 4) {
466 string SQL =
"UPDATE Settings SET Value = '" +
Settings.
GetValue(
"ShowDaysLeft") +
"' WHERE Key = 'ShowDaysLeft';";
478 int calYear, calMonth2;
484 int listSel2 =
GroupList->GetFirstSelected();
502 calYear = calTime.GetYear();
504 calMonth = calTime.GetMonthName(calTime.GetMonth());
513 if(calYear != Start.
GetYear() &&
525 wxCalendarDateAttr* Attr1 =
new wxCalendarDateAttr(wxCAL_BORDER_NONE );
526 Attr1->SetBackgroundColour (wxColour(128,0,128));
528 wxCalendarDateAttr* Attr2 =
new wxCalendarDateAttr(wxCAL_BORDER_NONE );
529 Attr2->SetBackgroundColour (wxColour(0,0,255));
531 wxCalendarDateAttr* Attr3 =
new wxCalendarDateAttr(wxCAL_BORDER_NONE );
532 Attr3->SetBackgroundColour (wxColour(0,128,0));
534 wxCalendarDateAttr* Attr4 =
new wxCalendarDateAttr(wxCAL_BORDER_NONE );
535 Attr4->SetBackgroundColour (wxColour(255,0,0));
543 if(calMonth2 == Candle.
GetMonth()) {
567 ShowMsg(
l(
"Unsaved Batch Changes! Reselect Batch And Click Update To Save Changes"));
584 int count1, sel2 = -1;
606 BPTypeChoice->SetToolTip(
l(
"Editing Type Is Disabled When Advanced Is Enabled"));
643 for(count1 = 0; count1 < Inc.size(); count1++) {
691 bool UseGauge =
true;
697 wxDateTime startD(Start.
GetDay(),
698 wxDateTime::Month(wxDateTime::Jan + Start.
GetMonth() - 1),
707 cout<<
"Log: Invalid Start Date!"<<endl;
713 wxDateTime startC(Candle.
GetDay(),
714 wxDateTime::Month(wxDateTime::Jan + Candle.
GetMonth() - 1),
721 cout<<
"Log: Invalid Candle Date"<<endl;
726 wxDateTime startT(Lock.
GetDay(),
727 wxDateTime::Month(wxDateTime::Jan + Lock.
GetMonth() - 1),
733 cout<<
"Log: Invalid Lockdown Date"<<endl;
738 wxDateTime startH(Hatch.
GetDay(),
739 wxDateTime::Month(wxDateTime::Jan + Hatch.
GetMonth() - 1),
746 cout<<
"Log: Invalid Hatch Date"<<endl;
754 if(Now1.IsBetween(Date1,Date4)) {
755 wxTimeSpan timeS = Date4.Subtract(Date1);
758 wxTimeSpan timeS2 = Now1.Subtract(Date1);
762 if(Now1.IsEarlierThan(Date1))
765 if(Now1.IsLaterThan(Date4)) {
796 BPFerUnStat->SetLabel(wxString::Format(wxT(
"0 %s"),
l(
"Fertile Unhatched")));
799 BPPerWerFerStat->SetLabel(wxString::Format(wxT(
"0%% %s"),
l(
"Where Fertile")));
802 BPPerOfFerStat->SetLabel(wxString::Format(wxT(
"0%% %s"),
l(
"Of Fertile Hatched")));
805 BPPerOfTotalStat->SetLabel(wxString::Format(wxT(
"0%% %s"),
l(
"Of Total Hatched")));
808 BPPerUnhatchStat->SetLabel(wxString::Format(wxT(
"0%% %s"),
l(
"Of Total Unhatched")));
833 wxString title =
l(
"Batch");
854 CategorySimpleDataset *dataset =
new CategorySimpleDataset(names, WXSIZEOF(names));
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));
863 BarType *barType =
new LayeredBarType(40, 0);
866 BarRenderer *renderer =
new BarRenderer(barType);
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));
874 renderer->SetBarDraw(2,
new GradientAreaDraw(*wxRED, wxColor(255,0,0),
875 wxColor(255,0,0).ChangeLightness(150), wxNORTH));
877 renderer->SetBarDraw(3,
new GradientAreaDraw(*wxGREEN, wxColor(0,128,0),
878 wxColor(0,128,0).ChangeLightness(150), wxNORTH));
881 dataset->SetRenderer(renderer);
884 BarPlot *plot =
new BarPlot();
887 NumberAxis *leftAxis =
new NumberAxis(AXIS_LEFT);
888 leftAxis->SetMargins(0, 0);
889 plot->AddAxis(leftAxis);
892 CategoryAxis *bottomAxis =
new CategoryAxis(AXIS_BOTTOM);
893 bottomAxis->SetMargins(20, 20);
894 plot->AddAxis(bottomAxis);
897 plot->AddDataset(dataset);
900 plot->LinkDataHorizontalAxis(0, 0);
903 plot->LinkDataVerticalAxis(0, 0);
913 int sel =
MainList->GetFirstSelected();
937 string SQL =
"UPDATE Settings SET Value = '" +
Settings.
GetValue(
"HideHatched");
938 SQL +=
"' WHERE Key = 'HideHatched';";
950 selDate.GetDay(wxDateTime::Local),
951 selDate.GetMonth(wxDateTime::Local) + 1,
952 selDate.GetYear(wxDateTime::Local)
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>");
960 htmlPrn->PrintText(HTML);
969 for(
int counter = 0; counter <
dwAttr; counter++)
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 );
992 MainList->InsertColumn(4,
l(
"Group" ), wxLIST_FORMAT_LEFT, 150 );
996 MainList->InsertColumn(4,
l(
"Days Left" ), wxLIST_FORMAT_LEFT, 150 );
1000 MainList->InsertColumn(4,
l(
"On Day" ), wxLIST_FORMAT_LEFT, 150 );
1006 MainList->InsertColumn(4,
l(
"Group" ), wxLIST_FORMAT_LEFT, 150 );
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()) );
1026 MainList->SetItem(count1, 4,wxString::Format(wxT(
"%s"), Batch.
GetGroup().c_str()));
1040 MainList->SetItem(count1, 4,wxString::Format(wxT(
"%s"), Batch.
GetGroup().c_str()));
1049 MainList->SetItemTextColour(count1,wxColor(ColorRed[3],ColorGreen[3],ColorBlue[3],225));
1057 MainList->SetItemTextColour(count1,wxColor(ColorRed[3],ColorGreen[3],ColorBlue[3],225));
1062 MainList->SetItemTextColour(count1, wxColor(ColorRed[3],ColorGreen[3],ColorBlue[3],225));
1074 int sel =
MainList->GetFirstSelected();
1088 int sel =
MainList->GetFirstSelected();
1116 int sel =
MainList->GetFirstSelected();
1130 int sel =
MainList->GetFirstSelected();
1144 int sel =
MainList->GetFirstSelected();
1158 int sel =
MainList->GetFirstSelected();
1177 int sel =
MainList->GetFirstSelected();
1195 int sel =
MainList->GetFirstSelected();
1212 int sel =
MainList->GetFirstSelected();
1218 selDate.GetDay(wxDateTime::Local),
1219 selDate.GetMonth(wxDateTime::Local) + 1,
1220 selDate.GetYear(wxDateTime::Local)
1225 selDate.GetDay(wxDateTime::Local),
1226 selDate.GetMonth(wxDateTime::Local) + 1,
1227 selDate.GetYear(wxDateTime::Local)
1232 selDate.GetDay(wxDateTime::Local),
1233 selDate.GetMonth(wxDateTime::Local) + 1,
1234 selDate.GetYear(wxDateTime::Local)
1239 selDate.GetDay(wxDateTime::Local),
1240 selDate.GetMonth(wxDateTime::Local) + 1,
1241 selDate.GetYear(wxDateTime::Local)
1255 int sel =
MainList->GetFirstSelected();
1260 string Comment =
"";
1265 for (
int c = 0;c < lines; c++) {
1281 int really,sel =
MainList->GetFirstSelected();
1288 really = wxMessageBox(
1289 wxString::Format(wxT(
"Delete %s ?"),
1315 int sel =
MainList->GetFirstSelected();
1343 int sel =
MainList->GetFirstSelected();
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>");
1360 if(!htmlPrn->PrintText(HTML)) {
1361 wxMessageDialog dialog(NULL,
1362 l(
"Error Printing!"));
1372 wxFileDialog exportDialog(NULL,
1373 l(
"Export Report File"),
1376 "Text Files (*.txt)|*.txt",
1377 wxFD_SAVE|wxFD_OVERWRITE_PROMPT,
1383 if (exportDialog.ShowModal() == wxID_CANCEL)
1386 string path = exportDialog.GetPath().ToStdString();
1387 wxFileName fname(path.c_str());
1389 if(fname.GetExt() !=
"txt")
1390 path = path +
".txt";
1410 wxFileDialog exDialog(NULL,
1411 l(
"Export Batch File"),
1414 "HatchKeeper Batch Files (*.hkbf)|*.hkbf",
1415 wxFD_SAVE|wxFD_OVERWRITE_PROMPT,
1421 if (exDialog.ShowModal() == wxID_CANCEL)
1424 string path = exDialog.GetPath().ToStdString();
1426 wxFileName fname(path.c_str());
1427 if(fname.GetExt() !=
"hkbf")
1435 wxFileDialog exportDialog(NULL,
1436 l(
"Export Calendar File"),
1439 "iCal Files (*.ics)|*.ics",
1440 wxFD_SAVE|wxFD_OVERWRITE_PROMPT,
1446 if (exportDialog.ShowModal() == wxID_CANCEL)
1449 string path = exportDialog.GetPath().ToStdString();
1450 wxFileName fname(path.c_str());
1452 if(fname.GetExt() !=
"ics")
1456 ShowMsg(
"Error Writing File!");
1463 if (wxTheClipboard->Open()) {
1464 wxTheClipboard->SetData(
new wxTextDataObject(Report) );
1465 wxTheClipboard->Close();
1472 really = wxMessageBox(
1473 wxString::Format(wxT(
"%s %s ?"),
l(
"Enable Advanced For"),
1490 really = wxMessageBox(
1491 wxString::Format(wxT(
"Disable Advanced For %s ?\nThis Will Delete All Advanced Data For This Batch!"),
1522 GroupList->InsertColumn(0,
l(
"Name"), wxLIST_FORMAT_LEFT, 200);
1536 string SQL =
"INSERT INTO Groups VALUES(" + to_string(
Groups.
GetValidID());
1537 SQL +=
",'" + Name +
"','" + Comments +
" ');";
1547 wxTextValidator textVal(wxFILTER_INCLUDE_CHAR_LIST);
1550 wxTextEntryDialog dlg(
this,
l(
"Enter Group Name"),
l(
"Enter Name"),wxEmptyString,wxOK|wxCANCEL,wxDefaultPosition);
1551 dlg.SetTextValidator(textVal);
1553 if ( dlg.ShowModal() == wxID_OK )
1554 GName = dlg.GetValue();
1562 ShowMsg(
l(
"Name Exists! Please Enter A New Name!"));
1573 int listSel3 =
GroupList->GetFirstSelected();
1577 if(listSel3 == -1) {
1578 ShowMsg(
l(
"No Group Is Selected"));
1583 ShowMsg(
l(
"This Group Can't Be Deleted"));
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 ) {
1603 string GDWarning =
"Deleting This Group Will Delete " + to_string(GrBatches.
GetCount());
1604 GDWarning +=
" Batches\nAre You Sure You Want To Delete?";
1606 wxMessageDialog dialog(
this,
l(GDWarning).c_str(),
l(
"Delete?"),wxCANCEL|wxOK);
1608 if(dialog.ShowModal() == wxID_OK){
1609 for(
int C = 0; C < GrBatches.
GetCount(); C++) {
1633 int sel =
MainList->GetFirstSelected();
1634 int GrSel =
GroupList->GetFirstSelected();
1656 GrBatchList->InsertColumn(0,
l((
"Batch Name") ), wxLIST_FORMAT_LEFT, 170);
1657 GrBatchList->InsertColumn(1,
l((
"# Of Eggs" )), wxLIST_FORMAT_LEFT, -1);
1659 for(
int A = 0; A < GrBatches.
GetCount(); A++) {
1660 GrBatchList->InsertItem(A, wxString::Format(wxT(
"%s"), GrBatches.
GetName(A).c_str()));
1689 GrAWFerStat->SetLabel(wxString::Format(wxT(
"0%% %s"),
l(
"Avg % Fertile")));
1692 GrAOTHatchStat->SetLabel(wxString::Format(wxT(
"0%% %s"),
l(
"Avg % Of Fertile Hatched")));
1695 GrAOFHatchStat->SetLabel(wxString::Format(wxT(
"0%% %s"),
l(
"Avg % of Total Hatched")));
1698 GrAOTUnHatchStat->SetLabel(wxString::Format(wxT(
"0%% %s"),
l(
"Avg % of Total Unhatched")));
1714 int sel =
GroupList->GetFirstSelected();
1715 string forComment =
"", sql;
1723 for (
int count1 = 0;count1 < lines; count1++) {
1725 forComment = forComment +
GrCommentCtrl->GetLineText(count1);
1727 forComment = forComment +
"\n" +
GrCommentCtrl->GetLineText(count1);
1733 sql =
"UPDATE Groups set GroupComments = '" + forComment;
1734 sql +=
"' where ID = " + to_string(
Groups.
GetID(sel)) +
";";
1750 int sel =
GroupList->GetFirstSelected();
1768 ShowMsg(
l(
"Sorry This Group Contains No Batches!"));
1778 wxFileDialog exportDialog(NULL,
1779 l(
"Export Report File"),
1781 "Text Files (*.txt)|*.txt",
1782 wxFD_SAVE|wxFD_OVERWRITE_PROMPT,
1783 wxDefaultPosition, wxDefaultSize,
1787 if (exportDialog.ShowModal() == wxID_CANCEL)
1790 path = exportDialog.GetPath().ToStdString();
1791 wxFileName fname(path.c_str());
1793 if(fname.GetExt().ToStdString() !=
"txt")
1802 wxHtmlEasyPrinting* htmlPrn =
new wxHtmlEasyPrinting(
l(
"Printing"), NULL);
1805 htmlPrn->PrintText(HTML);
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,
1819 if (exportDialog.ShowModal() == wxID_CANCEL)
1822 path = exportDialog.GetPath();
1823 wxFileName fname(path.c_str());
1825 if(fname.GetExt().ToStdString() !=
"hkbf")
1836 wxFileDialog exportDialog(NULL,
1837 l(
"Export Calendar File"),
1839 "iCal Files (*.ics)|*.ics",
1840 wxFD_SAVE|wxFD_OVERWRITE_PROMPT,
1846 if (exportDialog.ShowModal() == wxID_CANCEL)
1849 path = exportDialog.GetPath();
1850 wxFileName fname(path.c_str());
1852 if(fname.GetExt().ToStdString() !=
"ics")
1853 path = path +
".ics";
1856 ShowMsg(
l(
"Error Saving iCal File!"));
1872 AdvEggList->InsertColumn(0,
l(
"Egg"), wxLIST_FORMAT_LEFT, wxLIST_AUTOSIZE);
1873 AdvEggList->InsertColumn(1,
l(
"Weight Loss"), wxLIST_FORMAT_LEFT, wxLIST_AUTOSIZE);
1878 AdvEggList->InsertItem(a, wxString::Format(wxT(
"%s %d"),
l(
"Egg") ,a + 1));
1890 vector<HK_Egg> Eggs;
1895 vector<HK_Weight> DayWeight;
1896 vector< string > DayComments;
1899 for(b = 0; b < Days; b++) {
1901 DayWeight.push_back(Weight);
1905 for(b = 0; b < Days; b++) {
1907 DayComments.push_back(
"Day " + to_string(b+1) +
": " + TempDate.
ToReadable(
"/",
Settings.
GetInt(
"DateMode")) +
": ");
1910 for(a = 0; a < Batch.
GetEggs(); a++) {
1912 Egg.
Set(
"None",
"None",
"None",0,0,-1,Batch.
GetHatch(),
"Comments: ",DayWeight,DayComments);
1913 Eggs.push_back(Egg);
1934 int sel =
MainList->GetFirstSelected();
1938 unsigned int a, found = -1;
1943 for(a = 0; a < AdvTag1Data.size(); a++) {
1945 if(AdvTag1Data[a] == Egg.
GetTag1())
1966 for(a = 0; a < AdvTag2Data.size(); a++) {
1968 if(AdvTag2Data[a] == Egg.
GetTag2())
1989 for(a = 0; a < AdvTag3Data.size(); a++) {
1991 if(AdvTag3Data[a] == Egg.
GetTag3())
2028 wxDateTime resultD(D.
GetDay(),wxDateTime::Month(wxDateTime::Jan + D.
GetMonth() - 1), D.
GetYear(),0,0,0,0);
2032 cout<<
"Log: Invalid Result Date!"<<endl;
2057 else if (Diff < 1) {
2140 if(sel == -1 ||
MainList->GetFirstSelected() == -1)
2147 string forComment =
"";
2153 for (
int a = 0;a < lines; a++) {
2170 if(sel == -1 ||
MainList->GetFirstSelected() == -1)
2187 if(sel == -1 ||
MainList->GetFirstSelected() == -1) {
2213 if(sel == -1 ||
MainList->GetFirstSelected() == -1) {
2244 if(sel == -1 ||
MainList->GetFirstSelected() == -1)
2277 if(sel == -1 ||
MainList->GetFirstSelected() == -1) {
2286 NewD.GetDay(wxDateTime::Local),
2287 NewD.GetMonth(wxDateTime::Local) + 1,
2288 NewD.GetYear(wxDateTime::Local)
2302 AdvWeightList->InsertColumn(1,
l(
"Weight"), wxLIST_FORMAT_LEFT, 60);
2304 for(
int b = 0;b < Egg.
GetDays();b++) {
2305 AdvWeightList->InsertItem(b, wxString::Format(wxT(
"%s %d"),
l(
"Day"), b + 1));
2321 if(sel == -1 ||
MainList->GetFirstSelected() == -1)
2361 if(sel == -1 ||
MainList->GetFirstSelected() == -1)
2369 string forComment =
"";
2375 for (
int a = 0;a < lines; a++) {
2384 C[sel2] = forComment;
2397 wxMessageDialog dialog(
this,Msg.c_str());
2412 if ((fp = fopen(FileFolder.c_str(),
"w"))== NULL)
2413 fprintf(stderr,
"Error Creating HatchKeeper Condition File!");
2419 ActuallyExit =
true;
2435 for(A = 0; A < Updates.size(); A++) {
2442 bool rescan =
false;
2443 string notifyNote,sql;
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);
2459 wxDateTime::Month(wxDateTime::Jan + hkDate.
GetMonth() - 1),
2464 wxDateTime now = wxDateTime::Now();
2465 wxTimeSpan timeS = now.Subtract(date);
2470 NoteList->SetItem(A, 3,wxString::Format(wxT(
"%d"), timeS.GetDays()) );
2476 TheGenNotification =
new wxGenericNotificationMessage(
2477 "HatchKeeper_Reminder ",
2481 TheGenNotification->SetIcon(TaskBar_xpm);
2483 TheGenNotification->Show(wxNotificationMessage::Timeout_Never);
2489 TheNotification =
new wxNotificationMessage(
2490 "HatchKeeper_Reminder ",
2494 TheNotification->SetIcon(TaskBar_xpm);
2497 #if defined(__WXMSW__) && wxUSE_TASKBARICON
2500 TheNotification->Show(wxNotificationMessage::Timeout_Never);
2514 if(timeS.GetDays() > 3)
2538 delete TheGenNotification;
2539 TheGenNotification = NULL;
2544 delete TheNotification;
2545 TheNotification = NULL;
2566 delete TheGenNotification;
2567 TheGenNotification = NULL;
2572 delete TheNotification;
2573 TheNotification = NULL;
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);
std::string HATCHKEEPER_DATA
HK_Database Database(HATCHKEEPER_DATA+"HatchKeeper.db")
std::string l(std::string Text)
A Helper Function For HK_Language.
HK_Documents ExportImport
void HatchTerm(int signum)
Handles Sigterm(Shutdown) Under Linux And Cleans Up.
void ShowFrame()
Shows Splash Screen Then Shows And Raises Main Frame.
Holds stuff related to the main window.
wxSingleInstanceChecker * h_checker
A Dialog For Adding A New Batch.
bool WasCanceled()
Returns True If The Cancel Button Was Clicked.
A Dialog For Viewing Graph Stats.
A Class For Managing Multiple HK_Egg Instances.
HK_Egg GetEgg(int Select)
Returns The Selected Egg.
int GetEggCount()
Returns The Number Of Eggs.
int GetDays()
Returns Incubation Days.
int CalcAvgLoss()
Returns The Average Weight Loss For All Eggs In Batch.
int GetUnit()
Returns Weight Unit.
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.
int PercentOfTotal()
Returns The Percentage Of Total Eggs That Hatched.
int PercentFertile()
Returns The Percentage Of Eggs That Were Fertile.
void SetAdvanced(HK_Advanced Adv)
Sets Batch Advanced Data.
void SetCandle(HK_Date Candle)
Sets Batch Candle Date.
int GetChicks()
Returns Number Of Hatched Eggs In Batch, If Advanced Is Enabled It Returns HK_Advanced::GetChicks()
HK_Date GetCandle()
Returns Batch Candle Date.
string GetName()
Returns Batch Name.
int GetFertile()
Returns Number Of Fertile Eggs In Batch, If Advanced Is Enabled It Returns HK_Advanced::GetFertile()
void SetFertile(int Fertile)
Sets Batch Fertile Eggs.
void SetName(string Name)
Sets Batch Name.
HK_Date GetStart()
Returns Batch Start Date.
string GetIncubator()
Returns The Incubator As A String.
vector< string > GetUpdate()
Returns A String That Updates This Batch In Database.
string GetGroup()
Returns Batch Group.
int OnDay()
Returns The Number Of Days Left In Incubation Period.
int GetEggs()
Returns Number Of Eggs In Batch.
void SetType(string Type)
Sets Batch Type.
void SetIncubator(string Incubator)
Sets Batch Incubator.
HK_Date GetLockdown()
Returns Batch Lockdown Date.
void SetChicks(int Chicks)
Sets Batch Hatched Eggs.
void SetComments(string Comments)
Sets Batch Comments.
string GetComments()
Returns Batch Comments.
void SetBreed(string Breed)
Sets Batch Breed.
int GetDaysLeft()
Returns The Number Of Days Left In Incubation Period.
int FertileUnhatched()
Returns The Number Of Fertile Eggs That Didn't Hatch.
string GetBreed()
Returns Batch Breed.
void SetHatch(HK_Date Hatch)
Sets Batch Hatch Date.
void SetEggs(int Eggs)
Sets Batch Eggs.
int PercentOfTotalUnhatched()
Returns The Percentage Of Total Eggs That Didn't Hatch.
int PercentOfFertile()
Returns The Percentage Of Fertile Eggs That Hatched.
void SetStart(HK_Date Start)
Sets Batch Start Date.
int GetID()
Returns Batch ID.
int GetAdv()
Returns Batch Advanced Status.
string GetType()
Returns Batch Type.
void SetLockdown(HK_Date Lockdown)
Sets Batch Lockdown Date.
void SetGroup(string Group)
Sets Batch Group.
HK_Date GetHatch()
Returns Batch Hatch Date.
A Class For Managing Mulitple HK_Batch Objects.
HK_Advanced GetAdvanced(int Select)
Returns Advanced Egg Data Selected Batch.
HK_Date GetHatch(int Select)
Returns Hatch Date For Selected Batch.
int GetID(int Select)
Returns Batch ID For Selected Batch.
int PercentOfTotalUnhatched(int Select)
Returns The Percentage Of Total Eggs That Didn't Hatch For The Selected Batch.
HK_Date GetStart(int Select)
Returns Start Date For Selected Batch.
void Add(HK_Batch Batch)
Adds Another HK_Batch.
void SetClean(int Select)
Clears Dirty Mark For Selected Batch.
int AvgTotalUnHatch()
Returns Average Percentage Of Total Eggs That Did Not Hatch In This HK_Batches Instance.
int AvgFertileHatch()
Returns Average Percentage Of Fertile Eggs That Hatched In This HK_Batches Instance.
void SetAdvUpdate(int Select, bool Status)
Sets The Update Status HK_Advanced.
int GetAdv(int Select)
Returns Advanced Status For Selected Batch.
int AvgFertile()
Returns Average Percentage Of Eggs Fertile In This HK_Batches Instance.
void SetBatch(int Select, HK_Batch Batch)
Replaces Batch In Selected Position In Array. Use Add() To Add A Batch.
int GetChicks(int Select)
Returns Number Of Hatched Eggs For Selected Batch.
bool IsDirty(int Select)
Returns True If Batch Has Dirty Mark Set.
int GetFertile(int Select)
Returns Number Of Fertile Eggs For Selected Batch.
int PercentOfTotal(int Select)
Returns The Percentage Of Total Eggs That Hatched For The Selected Batch.
HK_Date GetCandle(int Select)
Returns Candle Date For Selected Batch.
int TotalEggs()
Returns Total Number Of Eggs In This HK_Batches Instance.
int AvgTotalHatch()
Returns Average Percentage Of Total Eggs That Hatched In This HK_Batches Instance.
HK_Batch GetBatch(int Select)
Returns The Selected Batch.
string GetGroup(int Select)
Returns Batch Group For Selected Batch.
void SetAdvEgg(int Select, HK_Egg Egg, int EggSelect)
Sets The Selected Egg For HK_Advanced.
int GetEggs(int Select)
Returns Number Of Eggs For Selected Batch.
int PercentFertile(int Select)
Returns The Percentage Of Egg That Were Fertile For The Selected Batch.
int GetCount()
Returns The Number Of Batches Stored.
int PercentOfFertile(int Select)
Returns The Percentage Of Fertile Eggs That Hatched For The Selected Batch.
HK_Date GetLockdown(int Select)
Returns Lockdown Date For Selected Batch.
int TotalChicks()
Returns Total Number Of Chicks In This HK_Batches Instance.
string GetName(int Select)
Returns Batch Name For Selected Batch.
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.
int GetMonth()
Returns Month Value.
int Difference(HK_Date Date)
Returns The Number Of Days Difference Between This HK_Date And The Supplied Date.
std::string MonthName()
Returns HK_Month's Name As String.
void Reset()
Resets Date To Today.
std::string ToReadable(std::string Separator, int Mode)
Generate A Readable String.
bool AddDays(int Days)
Adds Days To This HK_Date.
bool IsValid()
Checks If This HK_Date Contains A Valid Date.
int GetDay()
Returns Day Value.
int GetYear()
Returns Year Value.
int MonthToInt(std::string Month)
Converts Month Name To An Int.
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.
int GetResult()
Returns -1 If No Result, 0 If Hatched, And 2 If Egg Quit.
string GetComments()
Returns Egg Comments.
int CalcDayLoss(int Day)
Returns The Percentage Of Weight Lost From Previous Weighing.
void SetDayWeight(vector< HK_Weight > Weight)
Sets Weight For All Days.
void SetDate(HK_Date Date)
Sets Result Date.
void SetComments(string Comments)
Sets Egg Comments.
int GetDays()
Returns The Number Of Days For This Egg.
string GetTag2()
Returns Tag 2 As A String.
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.
int CalcTotalLoss()
Returns The Total Percentage Of Weight Lost By This Egg.
void SetResult(int Result)
Sets Result Status.
HK_Date GetDate()
Returns The Date For The Result.
string GetTag3()
Returns Tag 3 As A String.
void SetTag3(string Tag)
Sets The Third Tag.
void SetTag1(string Tag)
Sets The First Tag.
void SetFertile(int Fertile)
Sets Fertile Status.
vector< string > GetDayComments()
Returns An Array Containing A Comment For Every Day.
vector< HK_Weight > GetDayWeight()
Returns An Array Containing A Weight For Every Day.
void SetPipped(int Pipped)
Sets Pip Status.
void SetTag2(string Tag)
Sets The Second Tag.
int GetPipped()
Returns 0 If Egg Is Not Pipped And 1 If It Is.
string GetTag1()
Returns Tag 1 As A String.
int GetFertile()
Returns 0 If Egg Is Not Fertile And 1 If It Is.
void SetDayComments(vector< string > Comments)
Sets Comments For All Days.
bool WriteTextFile(string FileName, string Text)
Opens Filename And Writes Text.
std::string GetValidChars()
Returns Chars That Are Allowed In Text Controls.
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.
string GetValue(int Selection)
Returns The Selected Setting Value As A String.
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.
bool IsValidName(string Name)
Returns True If Name Isn't Already In Use.
HK_Date GetDate(int Select)
Returns The Selected Stored Date.
int GetValidID()
Returns A Valid ID For Adding Entries To The Database.
int GetCount()
Returns The Number Of Elements Stored.
int GetNumber(int Select)
Returns The Selected Stored Number.
void SetNumber(int Select, int Number)
Sets The Selected Stored Number.
string GetName(int Select)
Returns The Selected Stored Name.
string GetText(int Select)
Returns The Selected Stored Text.
void Add(string Name, int ID, HK_Date Date, string Text, int Number)
Adds An Item To Storage.
int GetID(int Select)
Returns The Selected Stored ID.
void SetText(int Select, string Text)
Sets The Selected Stored Text.
A Class For Managing Data For One Weight.
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.
void OnNotificationClicked(wxCommandEvent &)
Opens Main Frame When Notification Clicked.
wxStaticText * AdvTotalLossStat
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
wxCheckBox * AdvPipCheckbox
void OnHideChange(wxCommandEvent &)
Fired When HideCheckBox Changes.
wxCheckBox * AdvFertileCheckbox
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
wxStaticText * BPPerWerFerStat
wxStaticText * BPPerOfFerStat
wxStaticText * GrAOFHatchStat
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
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
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
wxStaticText * BPFerUnStat
void DeleteAdvanced(int sel)
void OnCloseWindow(wxCloseEvent &evt)
Hides Window If ActuallyExit == False, Else Exits App.
wxDatePickerCtrl * AdvResultDate
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
wxButton * GrDeleteButton
void OnAdvDayUnSelect(wxListEvent &)
Called When Day Is Unselected.
void OnGroupUnSelect(wxListEvent &)
Fired When A GroupList Item Gets Unselected.
wxStaticText * GrAOTHatchStat
void ClearAdvPanel()
Resets Ctrls To Default Value.
wxChoice * BPIncubatorChoice
void OnAdvPippedChecked(wxCommandEvent &)
Fired When Pip Status Changes.
void OnTimer(wxTimerEvent &)
Calls ShowNotifications() At A Set Interval.
wxDatePickerCtrl * BPStartDateCtrl
void AddGroup(string Name, string Comment)
Adds A Group To The Database.
wxChartPanel * BatchGraphPanel
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
wxStaticText * BPPerOfTotalStat
void OnBatchComments(wxCommandEvent &)
Fired When Batch Comments Are Edited.
void ShowBatchGraph(int sel)
Generates And Shows Graph In BatchGraphPanel For Selected Batch.
wxSpinCtrl * BPChicksHatchSpin
wxSpinCtrl * BPFertileSpin
void OnSelectEgg(wxListEvent &)
Fired When An Egg Is Selected.
void OnEggCommentChange(wxCommandEvent &)
Fired When AdvCommentCtrl Changes.
wxChoice * MoreActionsChoice
wxStaticText * GrAWFerStat
void ShowMsg(string Msg)
Uses wxMessageDialog To Display Message.
void OnAdvDaySelect(wxListEvent &)
Called When User Selects A Day.
void SetupBatchStats(int sel)
Sets Up The Statistics Panel.
void OnGraph(wxCommandEvent &)
Opens GraphDialog Instance.
wxTextCtrl * GrCommentCtrl
wxTextCtrl * AdvDayCommentCtrl
void OnHatchedSpin(wxSpinEvent &)
Fired When BPChicksHatchSpin Changes. Reverts Change If Batches.GetAdv(sel) == 1.
wxStaticText * GrAOTUnHatchStat
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
wxStaticText * AdvAvgBatchLossStat
void OnAddGroup(wxCommandEvent &)
Wrapper To AddGroup()
void OnGroupSelect(wxListEvent &)
Fires When A GroupList Item Get Selected.
void OnColumnClick(wxListEvent &evt)
Switches Groups Column.
void OnBatchBreed(wxCommandEvent &)
Fired When BPBreedChoice Is Changed. Updates Batches With New Breed.
wxGauge * BPProgressGauge
wxTextCtrl * BPCommentCtrl
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
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
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
wxStaticText * BPPerUnhatchStat
void OnTagsChange(wxCommandEvent &)
Gets Called When Any Of The 3 Tags Change.
void OnAdvFertileChecked(wxCommandEvent &)
Fired When Fertile Status Changes.
wxDatePickerCtrl * BPHatchDateCtrl
void OnListDESelect(wxListEvent &evt)
Fired When A MainList Item Gets Unselected.
wxListView * AdvWeightList
void ShowNotifications()
Shows Popup Notifications To User And Adds Them To NoteList.
A localhost Server Used For Single Instance.
A Taskbar Icon That Is Visable When HatchKeeper Is Running.
void OnWindowRestore(wxCommandEvent &)
Calls ShowFrame()
void OnWindowExit(wxCommandEvent &)
Exits The App Completely.
A Dialog For Displaying Version, Help, Credits And More.
A Dialog For Managing Reminders.
Manage Scheduled Hatch Dates.