summaryrefslogtreecommitdiffabout
path: root/src/sleep_history.h
Unidiff
Diffstat (limited to 'src/sleep_history.h') (more/less context) (ignore whitespace changes)
-rw-r--r--src/sleep_history.h113
1 files changed, 113 insertions, 0 deletions
diff --git a/src/sleep_history.h b/src/sleep_history.h
new file mode 100644
index 0000000..7837711
--- a/dev/null
+++ b/src/sleep_history.h
@@ -0,0 +1,113 @@
1#ifndef __N_SLEEP_HISTORY_H
2#define __N_SLEEP_HISTORY_H
3
4#include <string>
5#include <gtkmm/scrolledwindow.h>
6#include <gtkmm/treeview.h>
7#include <gtkmm/liststore.h>
8#include <napkin/types.h>
9#include "db.h"
10
11namespace napkin {
12 namespace gtk {
13 using std::string;
14
15 class sleep_history_t : public Gtk::ScrolledWindow {
16 public:
17 class basic_textrenderer : public Gtk::CellRendererText {
18 public:
19 basic_textrenderer();
20 void render_vfunc(
21 const Glib::RefPtr<Gdk::Drawable>& window, Gtk::Widget& widget,
22 const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area,
23 const Gdk::Rectangle& expose_area, Gtk::CellRendererState flags);
24 virtual const string get_text(const hypnodata_t& hd) const = 0;
25 };
26
27 class date_render_t : public basic_textrenderer {
28 public:
29 const string get_text(const hypnodata_t& hd) const;
30 };
31 class tobed_render_t : public basic_textrenderer {
32 public:
33 const string get_text(const hypnodata_t& hd) const;
34 };
35 class alarm_render_t : public basic_textrenderer {
36 public:
37 const string get_text(const hypnodata_t& hd) const;
38 };
39 class window_render_t : public basic_textrenderer {
40 public:
41 window_render_t();
42 const string get_text(const hypnodata_t& hd) const;
43 };
44 class nawakes_render_t : public basic_textrenderer {
45 public:
46 nawakes_render_t();
47 const string get_text(const hypnodata_t& hd) const;
48 };
49 class data_a_render_t : public basic_textrenderer {
50 public:
51 const string get_text(const hypnodata_t& hd) const;
52 };
53
54 class sleep_timeline_render_t : public Gtk::CellRenderer {
55 public:
56 const sleep_history_t& sleep_history;
57
58 sleep_timeline_render_t(const sleep_history_t& sh);
59 void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window, Gtk::Widget&/*widget*/,
60 const Gdk::Rectangle&/*background_area*/, const Gdk::Rectangle& cell_area,
61 const Gdk::Rectangle&/*expose_area*/, Gtk::CellRendererState/*flags*/);
62 };
63
64 class columns_t : public Gtk::TreeModel::ColumnRecord {
65 public:
66 Gtk::TreeModelColumn<hypnodata_ptr_t> c_hypnodata;
67 Gtk::TreeModelColumn<void*> c_hypnodata_ptr;
68
69 columns_t() {
70 add(c_hypnodata); add(c_hypnodata_ptr);
71 }
72 };
73
74 columns_t cols;
75 Gtk::TreeView w_tree;
76 Glib::RefPtr<Gtk::ListStore> store;
77 date_render_t r_date;
78 tobed_render_t r_to_bed;
79 alarm_render_t r_alarm;
80 window_render_t r_window;
81 nawakes_render_t r_nawakes;
82 data_a_render_t r_data_a;
83 sleep_timeline_render_t r_sleep_timeline;
84 Gtk::TreeView::Column *c_timeline;
85
86 sigc::signal<void> double_click_signal;
87 sigc::signal<void>& signal_double_click() { return double_click_signal; }
88
89 time_t min_tobed, max_alarm;
90
91 db_t& db;
92
93 sleep_history_t(db_t& d);
94
95 Gtk::TreeView::Column *append_c(const string& title,Gtk::CellRenderer& renderer);
96
97 bool on_button_press(GdkEventButton* geb);
98 bool on_query_tooltip(int x,int y,bool keyboard_tooltip, const Glib::RefPtr<Gtk::Tooltip>& tooltip);
99
100
101 void set_data(list<napkin::hypnodata_ptr_t> data);
102
103 Glib::SignalProxy0<void> signal_cursor_changed() {
104 return w_tree.signal_cursor_changed();
105 }
106
107 const hypnodata_ptr_t get_current();
108
109 };
110 }
111}
112
113#endif /* __N_SLEEP_HISTORY_H */