Button(C++/FLTK)

So, here is the problem I am having. I created a button with fltk in a function that when pressed just outputs "Appointment Added". However, right now I want to do more than just display that output to the screen. Here is what I want to function to do. If the Add Event button is pressed get the input from the Event Name text box and the Event Date text box and store that information in my appointment file called list.txt

This is my code so far:

#include "std_lib_facilities_3.h"
#include "Simple_window.h"
#include "Graph.h"
#include "calendar.h"
#include "GUI.h"
using namespace Graph_lib;

//static void get_next(Address,Address pw){
//function to move the calendar to the next month goes here
//cout << "THINGS ARE HAPPENING!!"<<'\n';
//}

//static void get_prev(Address,Address pw){
//function to move the calendar to the previous month goes here
//cout << "STUFF IS GOING ON!!"<<'\n';
//}

static void add_appt(Address,Address pw){
//If the Add Event button is pressed
//get the input from the Event Name text box and the Event Date text box
//and store that information in your appointment file(list.txt)
cout << "Appointment Added"<<'\n';
}

int main()
{
int month;
int year;
string filename;
Vector<string> dateVector;
Vector<string> contentVector;

cout <<"Welcome to group 122's 'Make My Day' Program. This is a monthly planner page program along the lines of Microsoft Outlook."<< 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('list.txt'):"<< endl;
cin >> filename;
ifstream ifs(filename.c_str(),ios_base::in); //Reads the file
if (!ifs.is_open()) error("can't open input file",filename); //Displays an error if the file cannot be open
//getline(cin,filename);
//vector<Date>
//string
while(!ifs.eof())
{
string s;
string sd;
//xDate d;

ifs >> sd >> s;

cout << sd << ' ' << s << "\n";
//cout << "debug\n";
dateVector.push_back(sd);
contentVector.push_back(s);

//tranform and push sd to the Date vector
//puth s to the constent (string) vector
}
ifs.close();

Color outline_blue(fl_rgb_color(142,175,217));
Color header(fl_rgb_color(227,239,255));

Point tl(100,100);
Simple_window win(tl,1000,900,"Calendar");

Vector_ref<Rectangle> calendar;
for (int i=0; i<7; ++i)
for (int j=0; j<7; j++){
calendar.push_back(new Rectangle(Point(i*100,j*125),100,125));
calendar[calendar.size()-1].set_color(outline_blue);
calendar[calendar.size()-1].set_fill_color(Color::white);
win.attach(calendar[calendar.size()-1]);
}

Rectangle Header(Point(0,0),700,125);
Header.set_fill_color(header);
Header.set_color(outline_blue);
win.attach(Header);

Line day1(Point(100,100),Point(100,125));
day1.set_color(outline_blue);
day1.set_style(Line_style(Line_style::solid,2));
win.attach(day1);
Line day2(Point(200,100),Point(200,125));
day2.set_color(outline_blue);
day2.set_style(Line_style(Line_style::solid,2));
win.attach(day2);
Line day3(Point(300,100),Point(300,125));
day3.set_color(outline_blue);
day3.set_style(Line_style(Line_style::solid,2));
win.attach(day3);
Line day4(Point(400,100),Point(400,125));
day4.set_color(outline_blue);
day4.set_style(Line_style(Line_style::solid,2));
win.attach(day4);
Line day5(Point(500,100),Point(500,125));
day5.set_color(outline_blue);
day5.set_style(Line_style(Line_style::solid,2));
win.attach(day5);
Line day6(Point(600,100),Point(600,125));
day6.set_color(outline_blue);
day6.set_style(Line_style(Line_style::solid,2));
win.attach(day6);
Text sun(Point(35,123), "Sun");
sun.set_font_size(15);
win.attach(sun);
Text mon(Point(135,123), "Mon");
mon.set_font_size(15);
win.attach(mon);
Text tues(Point(230,123), "Tues");
tues.set_font_size(15);
win.attach(tues);
Text wed(Point(330,123), "Wed");
wed.set_font_size(15);
win.attach(wed);
Text thurs(Point(425,123), "Thurs");
thurs.set_font_size(15);
win.attach(thurs);
Text fri(Point(540,123), "Fri");
fri.set_font_size(15);
win.attach(fri);
Text sat(Point(640,123), "Sat");
sat.set_font_size(15);
win.attach(sat);

for(int i=0; i < dateVector.size(); i++) {
istringstream is;
string delimiter = "/";
size_t pos = 0;
int day;
int month;
int year;

string tempStr = dateVector[i];

pos = tempStr.find(delimiter);
string strMonth = tempStr.substr(0, pos);
tempStr.erase(0, pos + delimiter.length());
//cout << "month:" << strMonth << "\n";
month = atoi(strMonth.c_str());
cout << "month:" << month << "\n";

pos = tempStr.find(delimiter);
string strDay = tempStr.substr(0, pos);
tempStr.erase(0, pos + delimiter.length());
//cout << "day:" << strDay << "\n";
day = atoi(strDay.c_str());
cout << "day:" << day << "\n";

pos = tempStr.find(delimiter);
string strYear = tempStr.substr(0, pos);
tempStr.erase(0, pos + delimiter.length());
//cout << "year:" << strYear << "\n";
year = atoi(strYear.c_str());
cout << "year:" << year << "\n";
}

//Button nextmon(Point(875,80),120,30,"Next Month",get_next);
//win.attach(nextmon);

//Button prevmon(Point(875,120),120,30,"Previous Month",get_prev);
//win.attach(prevmon);

Text appt(Point(840,190), "Add an Event");
appt.set_font_size(15);
win.attach(appt);

In_box userappt(Point(880,200),125,20,"Enter Event Name:");
win.attach(userappt);

In_box userappt_date(Point(880,225),125,20,"Enter Event Date:");
win.attach(userappt_date);

Button addappt(Point(850,250),120,30,"Add Event",add_appt); //Add Event button
win.attach(addappt);

win.wait_for_button();
}
Topic archived. No new replies allowed.