The project is to write a C++/FLTK GUI monthly planner page program along the li
ID: 3535053 • Letter: T
Question
The project is to write a C++/FLTK GUI monthly planner page program along the lines of Outlook. The program should start with a description of what it does and then ask for a month and year and the file name of the appointment file (described below). The program then displays the requested month with appointments from the file. You need 6 rows for some months. Allow the user to add additional appointments, which are then displayed on the calendar and also added to the appointment file (hint: "append" to the existing file). For teams of 3, implement the "previous month" and "next month" buttons (at the top left of the picture above), which will display the new month and reread the appointments file. Hint: To calculate the day of the week the month starts on, look up "Zeller's congruence." Here is the format for the appointments file: Each line begins with either a month/day or month/day/year. For example, 1/1 New Year's Day 4/1 April Fool's Day 3/26/2013 Passover 4/15/2014 Passover 3/31/2013 Easter 4/20/2014 Easter 11/4/2013 Hijri New Year 10/24/2014 Hijri New Year 7/4 Independence Day 12/25 Christmas Extra credit (up to 10 points) will be given for additional features such as implementing the "Search Calendar" box, calculating and displaying full moon days, etc.Explanation / Answer
This is what I have so far:
#include "Chrono.h"
#include "std_lib_facilities_3.h"
int main()
{
int month;
int year;
string filename;
cout <<"Welcome to group 122's 'Make My Day' Program. This is a monthly planner page program along the lines of Microsoft Outlook."<< endl << endl;
cout <<"Please enter a two-digit month"<< endl;
cin >> month;
cout <<"Please enter a four-digit year"<< endl;
cin >> year;
cout <<"Enter the name of the appointment file"<< endl;
cin >> filename;
ofstream ofs(filename.c_str(),ios_base::app); //Allows the user to add additional appointments
if (!ofs) error("can't open file",filename); //Displays an error if the file cannot be open
keep_window_open();
}
For starters, I am trying to get everything to run in a command line before I transfer this to fltk. So, right now I am stuck on the part regarding the appointment file. The project says I have to ask for the file name of the appointment file. Then display the requested month with appointments from the file.
Here is the format for the appointments file: Each line begins with either a month/day or month/day/year. For example,
1/1 New Year's Day
4/1 April Fool's Day
3/26/2013 Passover
4/15/2014 Passover
3/31/2013 Easter
4/20/2014 Easter
11/4/2013 Hijri New Year
10/24/2014 Hijri New Year
7/4 Independence Day
12/25 Christmas
or
#include "std_facilities_lib_3.h"#include <iostream>#include <sstream>#include "Graph.h" // get access to our graphics library facilities#include "GUI.h"#include "Window.h" using namespace Graph_lib; using namespace std; struct Lines_window : Window { Lines_window(Point xy, int w, int h, const string& title ); Open_polyline lines; private: Button next_button; // add (next_x,next_y) to lines Button quit_button; In_box next_x; In_box next_y; Out_box xy_out; static void cb_next(Address, Address); // callback for next_button void next(); static void cb_quit(Address, Address); // callback for quit_button void quit(); }; Lines_window::Lines_window(Point xy, int w, int h, const string& title) :Window(xy,w,h,title), next_button(Point(x_max()-150,0), 70, 20, "Next point", cb_next), quit_button(Point(x_max()-70,0), 70, 20, "Quit", cb_quit), next_x(Point(x_max()-310,0), 50, 20, "next x:"), next_y(Point(x_max()-210,0), 50, 20, "next y:"), xy_out(Point(100,0), 100, 20, "current (x,y):") { attach(next_button); attach(quit_button); attach(next_x); attach(next_y); attach(xy_out); attach(lines); } void Lines_window::cb_quit(Address, Address pw) // "the usual"{ reference_to<Lines_window>(pw).quit(); } void Lines_window::quit() { hide(); // curious FLTK idiom for delete window} void Lines_window::cb_next(Address, Address pw) // "the usual"{ reference_to<Lines_window>(pw).next(); } void Lines_window::next() { int x = next_x.get_int(); int y = next_y.get_int(); lines.add(Point(x,y)); // update current position readout: stringstream ss; ss << '(' << x << ',' << y << ')'; xy_out.put(ss.str()); redraw(); } int main() try { Lines_window win(Point(100,100),600,400,"lines"); return gui_main(); } catch(exception& e) { cerr << "exception: " << e.what() << ' '; return 1; } catch (...) { cerr << "Some exception "; return 2; }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.