test
[apps/core/preloaded/calendar.git] / src / timeblock.h
1 /*
2   *
3   *  Copyright 2012  Samsung Electronics Co., Ltd
4   *
5   *  Licensed under the Flora License, Version 1.0 (the "License");
6   *  you may not use this file except in compliance with the License.
7   *  You may obtain a copy of the License at
8   *
9   *       http://www.tizenopensource.org/license
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  distributed under the License is distributed on an "AS IS" BASIS,
13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   */
17
18
19 #ifndef __CALENDAR_TIMEBLOCK_H__
20 #define __CALENDAR_TIMEBLOCK_H__
21
22 #include "cld.h"
23
24 #define TIMEBLOCK_INDEX 24
25 #define EVENTBLOCK_INDEX 48
26
27 enum timeblock_event_type {
28         TIMEBLOCK_CLICKED,
29         EVENT_CLICKED,
30         MORE_EVENT_CLICKED,
31 };
32
33 struct timeblock_slice {
34         struct timeblock *tb;
35         int idx;
36
37         Evas_Object *ly;
38         Evas_Coord x;
39         Evas_Coord y;
40         Evas_Coord h;
41
42         Eina_Bool hide_text;
43
44         int cnt;
45 };
46
47 struct eventblock_slice {
48         struct timeblock *tb;
49         const Evas_Object *base;
50         Eina_List *list; // evt list
51         int maxsize;
52         int real_sz;
53         int start_index;
54 };
55
56 struct timeblock_event {
57         int cid;
58         Evas_Object *ly;
59         int idx;
60         int sz;
61         struct timeblock *tb;
62         cal_struct *cs;
63
64         Evas_Coord initial_coord_x;
65         Evas_Coord initial_coord_y;
66         Evas_Coord mouse_down_y;
67
68         int origin_ebs_idx;
69 };
70
71 struct eventblock_overlap
72 {
73         int start_idx;
74         int end_idx;
75         int size;
76 };
77
78 struct timeblock {
79         Evas_Object *parent; //scroller
80         Evas_Object *clip;
81
82         struct timeblock_slice tbs[TIMEBLOCK_INDEX];
83         Evas_Coord x;
84         Evas_Coord y;
85         Evas_Coord w;
86         Evas_Coord h;
87
88         Evas_Coord normal_height;
89         Evas_Coord expand_height;
90
91         struct eventblock_slice ebs[EVENTBLOCK_INDEX];
92         int color;
93
94         Evas_Object *dn;
95         Eina_Bool lock;
96
97         void (*cb)(void *data, struct timeblock *tb, enum timeblock_event_type e, void *event_info);
98         void *cb_d;
99
100         Eina_List *ebs_list;
101         Eina_List *more_ev_list;
102
103         Ecore_Timer* long_press_timer;
104         struct timeblock_event *long_pressed_event;
105         Eina_Bool is_block_update;
106
107         struct appdata *ad;
108 };
109
110
111
112
113 struct timeblock* cal_time_block_create_time_block(Evas_Object *p, Evas_Object *clip, struct appdata *ad);
114 void cal_time_block_delete_time_block(struct timeblock **tb);
115
116 void cal_time_block_move(struct timeblock *tb, Evas_Coord x, Evas_Coord y);
117 void cal_time_block_resize(struct timeblock *tb, Evas_Coord y, Evas_Coord h);
118 void cal_time_block_get_geometry(struct timeblock *tb, Evas_Coord_Rectangle *r);
119 Evas_Coord cal_time_block_get_first_event_y(struct timeblock *tb);
120
121 void cal_time_block_add_event(struct timeblock *tb, int cid, int hh, int sz, const char *text, cal_struct *cs);
122 void cal_time_block_set_event_lock(struct timeblock *tb, Eina_Bool lock);
123 void cal_time_block_clear_event(struct timeblock *tb);
124
125 Evas_Coord cal_time_block_get_min();
126 Evas_Coord cal_time_block_get_max(struct timeblock *tb);
127 Evas_Coord cal_time_block_get_expand_max(struct timeblock *tb);
128 Evas_Coord cal_time_block_get_current(struct timeblock *tb);
129
130 void cal_time_block_set_callback(struct timeblock *tb, void (*cb)(void *data, struct timeblock *tb, enum timeblock_event_type e, void *event_info), void *data);
131 void cal_time_block_unset_callback(struct timeblock *tb);
132
133 void cal_time_block_show_current_time_line(struct timeblock *tb, int hour);
134 void cal_time_block_hide_current_time_line(struct timeblock *tb);
135
136 int cal_time_block_get_default_current_height(void);
137
138 #endif /* __CALENDAR_TIMEBLOCK_H__ */
139