Add Elevator Number to Elevators
[cs356-p1-elevator.git] / elevatorgui.hpp
1 #ifndef ELEVATORGUI_HPP
2 #define ELEVATORGUI_HPP
3
4 #include <gtkmm.h>
5 #include <iostream>
6 #include <iomanip>
7 #include <vector>
8 #include <sstream>
9
10 #include "elevatorcontroller.hpp"
11
12 #include "elevatordoor.hpp"
13 #include "callbutton.hpp"
14 #include "positionlabel.hpp"
15 #include "requestbutton.hpp"
16
17
18 typedef std::vector<CallButton*> CallButtonVector;
19 typedef std::vector<PositionLabel*> PositionLabelVector;
20 typedef std::vector<RequestButton*> RequestButtonVector;
21 typedef std::vector<ElevatorDoor*> ElevatorDoorVector;
22
23
24 class ElevatorGUI : public Gtk::Window
25 {
26         public:
27                 ElevatorGUI (int floors, int elevators);
28
29                 /* Functions to be called from Elevator to change GUI status */
30                 void gui_update_position_label (int elevator, float new_position);
31                 void gui_unpress_call_button (int floor, Direction direction);
32                 void gui_unpress_request_button (int elevator, int floor);
33                 void gui_open_door (int elevator, int floor);
34                 void gui_close_door (int elevator, int floor);
35
36         private:
37                 /* Callbacks from button presses */
38                 void on_call_button_toggled (CallButton *button);
39                 void on_request_button_toggled (RequestButton *button);
40                 void on_playpause_button_clicked ();
41                 void on_stop_button_clicked ();
42                 void on_quit_button_clicked ();
43
44                 /* Timer Function */
45                 bool on_timer_tick ();
46                 sigc::connection timer_;
47                 static const int timer_tick_ms_ = 500;
48
49                 int number_of_floors_;
50                 int number_of_elevators_;
51
52                 enum { STOPPED, RUNNING, PAUSED } simulation_status_;
53                 
54                 ElevatorController ec_;
55
56                 // holds custom CallButton which knows it's direction and floor#
57                 CallButtonVector call_buttons_;
58
59                 // holds custom position label which knows it's elevator#
60                 PositionLabelVector position_labels_;
61
62                 // holds custom RequestButton which knows it's elevator# and floor#
63                 RequestButtonVector request_buttons_;
64
65                 // holds custom ElevatorDoor which knows it's elevator# and floor#
66                 ElevatorDoorVector elevator_doors_;
67
68                 // Holds the Play / Pause button, Stop button, and Quit button
69                 Gtk::Button button_playpause_, button_stop_, button_quit_;
70
71                 // Holds the Table which holds everything
72                 Gtk::Table table_;
73 };
74
75 #endif /* ELEVATORGUI_HPP */
76
77 /* vim: set ts=4 sts=4 sw=4 noet tw=112: */