// generated by Fast Light User Interface Designer (fluid) version 1.0109

#include "BankInterestUI.h"
#include <FL/fl_message.H>
#include "BankInterest.h"
static float widthdrawals[4]; 

void update_balance() {
  widthdrawals[0] = w1->value();
widthdrawals[1] = w2->value();
widthdrawals[2] = w3->value();
widthdrawals[3] = w4->value();
balance->value(
calc_balance(init_bal->value(), rate->value(), widthdrawals, 4));
}

Fl_Value_Input *init_bal=(Fl_Value_Input *)0;

static void cb_init_bal(Fl_Value_Input*, void*) {
  update_balance();
}

Fl_Value_Input *rate=(Fl_Value_Input *)0;

static void cb_rate(Fl_Value_Input*, void*) {
  update_balance();
}

Fl_Value_Input *w1=(Fl_Value_Input *)0;

static void cb_w1(Fl_Value_Input*, void*) {
  update_balance();
}

Fl_Value_Input *w2=(Fl_Value_Input *)0;

static void cb_w2(Fl_Value_Input*, void*) {
  update_balance();
}

Fl_Value_Input *w3=(Fl_Value_Input *)0;

static void cb_w3(Fl_Value_Input*, void*) {
  update_balance();
}

Fl_Value_Input *w4=(Fl_Value_Input *)0;

static void cb_w4(Fl_Value_Input*, void*) {
  update_balance();
}

Fl_Value_Output *balance=(Fl_Value_Output *)0;

static void cb_Ok(Fl_Button*, void*) {
  fl_message("Press Escape to Quit");
}

int main(int argc, char **argv) {
  Fl_Double_Window* w;
  { Fl_Double_Window* o = new Fl_Double_Window(320, 265, "BankInterest");
    w = o;
    o->tooltip("A simple bank interest calculator.");
    { init_bal = new Fl_Value_Input(165, 20, 60, 25, "Starting balance:");
      init_bal->tooltip("How much money is initially in your account");
      init_bal->maximum(9999);
      init_bal->callback((Fl_Callback*)cb_init_bal);
    } // Fl_Value_Input* init_bal
    { rate = new Fl_Value_Input(165, 45, 45, 25, "Interest rate:");
      rate->tooltip("Enter \"12\" for an account earning twelve percent.");
      rate->callback((Fl_Callback*)cb_rate);
    } // Fl_Value_Input* rate
    { w1 = new Fl_Value_Input(217, 75, 55, 25, "First Quarter widthdrawal:");
      w1->tooltip("How much to take out after the first quarter");
      w1->callback((Fl_Callback*)cb_w1);
    } // Fl_Value_Input* w1
    { w2 = new Fl_Value_Input(217, 100, 55, 25, "Second Quarter widthdrawal:");
      w2->tooltip("How much to take out after the second quarter");
      w2->callback((Fl_Callback*)cb_w2);
    } // Fl_Value_Input* w2
    { w3 = new Fl_Value_Input(217, 125, 55, 25, "Third Quarter widthdrawal:");
      w3->tooltip("How much to take out after the third quarter");
      w3->callback((Fl_Callback*)cb_w3);
    } // Fl_Value_Input* w3
    { w4 = new Fl_Value_Input(217, 150, 55, 25, "Fourth Quarter widthdrawal:");
      w4->tooltip("How much to take out after the fourth quarter");
      w4->callback((Fl_Callback*)cb_w4);
    } // Fl_Value_Input* w4
    { balance = new Fl_Value_Output(165, 205, 80, 25, "Ending Balance: ");
      balance->tooltip("How much money is left in the account");
      balance->maximum(9999);
      balance->step(0.01);
    } // Fl_Value_Output* balance
    { Fl_Button* o = new Fl_Button(245, 230, 70, 30, "Ok bye!");
      o->callback((Fl_Callback*)cb_Ok);
    } // Fl_Button* o
    o->end();
  } // Fl_Double_Window* o
  w->show(argc, argv);
  return Fl::run();
}
