-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmonthview.h
95 lines (84 loc) · 2.76 KB
/
monthview.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef CALENDARI__MONTH_VIEW_H
#define CALENDARI__MONTH_VIEW_H 1
#include "db.h"
#include "view.h"
#include <gtk/gtk.h>
#include <string>
namespace calendari {
class Calendari;
class MonthView: public View
{
public:
MonthView(Calendari& cal);
~MonthView(void);
virtual void set(time_t self_time);
virtual void draw(GtkWidget* widget, cairo_t* cr);
virtual void click(GdkEventType type, double x, double y);
virtual void motion(GtkWidget* widget, double x, double y);
virtual void leave(void);
virtual void release(void);
virtual bool drag_drop(GtkWidget*,GdkDragContext*,int x,int y,guint time);
virtual void drag_data_get(GtkSelectionData*,guint info);
virtual void drag_data_received(GdkDragContext*, int x, int y, GtkSelectionData*,guint info,guint time);
virtual void select(Occurrence* occ);
virtual void moved(Occurrence* occ);
virtual void erase(Occurrence* occ);
virtual void reload(void);
virtual void create_event(void);
virtual void ok(void);
virtual void cancel(void);
virtual View* go_today(void);
virtual View* go_up(void);
virtual View* go_right(void);
virtual View* go_down(void);
virtual View* go_left(void);
virtual View* prev(void);
virtual View* next(void);
virtual void move_here(Occurrence*);
virtual void copy_here(Occurrence*);
private:
Calendari& cal;
// Time
time_t now; ///< Current, wall-clock time.
struct tm self_local; ///< A time somewhere in the current view.
int current_cell; ///< The selected cell, or NULL_CELL.
int month_cells; ///< Num. cells in the current display (28, 35 or 42).
static const int MAX_CELLS = 7 * 6 + 1;
static const int NULL_CELL = -1000;
Day day[MAX_CELLS];
std::string dayname[7];
// Dimensions
double width;
double height;
double header_height;
double cell_width;
double cell_height;
double slot_height;
// Fonts
PangoFontDescription* head_pfont;
PangoFontDescription* body_pfont;
cairo_font_extents_t font_extents;
// Slots
size_t slots_per_cell;
size_t current_slot; ///< The selected slot, or zero.
// Statusbar
Occurrence* statusbar_occ;
unsigned int statusbar_ctx_id;
// Drag & Drop
double drag_x;
double drag_y;
void init_dimensions(GtkWidget* widget, cairo_t* cr);
void arrange_slots(void);
void draw_grid(cairo_t* cr);
void draw_cells(cairo_t* cr);
void draw_cell(cairo_t* cr, PangoLayout* pl, int cell);
void draw_occurrence(cairo_t* cr, PangoLayout* pl, int cell, int slot);
/** Find the cell, slot and (maybe) Occurrence at coordinates x,y.
* Returns TRUE if the cell and slot are valid, and FALSE otherwise. */
bool xy(
double x, double y,
int& out_cell, size_t& out_slot, Occurrence*& out_occ
) const;
};
} // end namespace calendari
#endif // CALENDARI__MONTH_VIEW_H