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
|
/*
* Copyright 2016 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://floralicense.org/license/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <Elementary.h>
#include "log.h"
#include "index.h"
#define PRIVATE_DATA_KEY_CUR "pdkc"
void _index_destroy(Evas_Object *index)
{
ret_if(NULL == index);
evas_object_data_del(index, PRIVATE_DATA_KEY_CUR);
elm_index_item_clear(index);
evas_object_del(index);
}
Evas_Object *_index_create(Evas_Object *ui_manager, unsigned int count)
{
Evas_Object *index = NULL;
register int i = 0;
retv_if(NULL == ui_manager, NULL);
index = elm_index_add(ui_manager);
retv_if(NULL == index, NULL);
elm_object_style_set(index, "pagecontrol");
elm_index_horizontal_set(index, EINA_TRUE);
elm_index_autohide_disabled_set(index, EINA_TRUE);
for (; i < count; i++) {
elm_index_item_append(index, NULL, NULL, (void *) i);
}
elm_index_level_go(index, 0);
evas_object_data_set(index, PRIVATE_DATA_KEY_CUR, NULL);
evas_object_show(index);
return index;
}
void _index_update(Evas_Object *index, unsigned int count)
{
register int i = 0;
int cur_index = 0;
elm_index_item_clear(index);
for (; i < count; i++) {
elm_index_item_append(index, NULL, NULL, (void *) i);
}
elm_index_level_go(index, 0);
evas_object_show(index);
cur_index = (int) evas_object_data_get(index, PRIVATE_DATA_KEY_CUR);
_index_bring_in(index, cur_index);
}
void _index_bring_in(Evas_Object *index, int idx)
{
Elm_Object_Item *idx_it;
idx_it = elm_index_item_find(index, (void *) idx);
ret_if(NULL == idx_it);
elm_index_item_selected_set(idx_it, EINA_TRUE);
evas_object_data_set(index, PRIVATE_DATA_KEY_CUR, (void *) idx);
}
|