apply FSL(Flora Software License)
[apps/home/gallery.git] / src / widget / gl-button.c
1 /*
2   * Copyright 2012  Samsung Electronics Co., Ltd
3   *
4   * Licensed under the Flora License, Version 1.0 (the "License");
5   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of the License at
7   *
8   *     http://www.tizenopensource.org/license
9   *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16
17 #include "gl-debug.h"
18 #include "gl-ui-util.h"
19 #include "gl-button.h"
20 #include "gl-strings.h"
21
22 #define GL_BUT_NAME_DELETE GL_STR_DELETE
23 #define GL_BUT_NAME_CANCEL GL_STR_CANCEL
24 #define GL_BUT_NAME_DONE GL_STR_DONE
25
26 /*******************************************************
27 ** Prototype            : _gl_but_create_but
28 ** Description          : Create button
29 ** Input                : Evas_Object *parent
30 ** Input                : gl_but_mode mode
31 ** Input                : const char *style
32 ** Output               : None
33 ** Return Value         :
34 ** Calls                :
35 ** Called By            :
36 **
37 **  History             :
38 **  1.Date              : 2011/06/10
39 **    Author            : Samsung
40 **    Modification : Created function
41 **
42 *********************************************************/
43 Evas_Object *_gl_but_create_but(Evas_Object *parent, gl_but_mode mode, const char *style)
44 {
45         gl_dbg("Button mode: %d", mode);
46         Evas_Object *btn = NULL;
47
48         btn = elm_button_add(parent);
49         GL_CHECK_NULL(btn);
50         elm_object_focus_allow_set(btn, EINA_FALSE);
51         elm_object_style_set(btn, style);
52         evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
53                                          EVAS_HINT_EXPAND);
54         evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, 0.5);
55
56         switch (mode) {
57         case GL_BUT_DEL:
58                 elm_object_text_set(btn, GL_BUT_NAME_DELETE);
59                 break;
60         case GL_BUT_CANCEL:
61                 elm_object_text_set(btn, GL_BUT_NAME_CANCEL);
62                 break;
63         case GL_BUT_DONE:
64                 elm_object_text_set(btn, GL_BUT_NAME_DONE);
65                 break;
66         case GL_BUT_SHARE:
67                 elm_object_text_set(btn, GL_STR_SHARE);
68                 break;
69 #ifdef _USE_ROTATE_BG
70         case GL_BUT_MORE:
71                 elm_object_text_set(btn, GL_STR_MORE);
72                 break;
73         case GL_BUT_ROTATE_LEFT:
74                 elm_object_text_set(btn, GL_STR_ROTATE_LEFT);
75                 break;
76         case GL_BUT_ROTATE_RIGHT:
77                 elm_object_text_set(btn, GL_STR_ROTATE_RIGHT);
78                 break;
79 #endif
80         default:
81                 break;
82         }
83
84         evas_object_show(btn);
85         return btn;
86 }
87
88 Evas_Object *_gl_but_create_but_popup(Evas_Object *parent, const char *text, But_Smart_Cb cb_func, const void *data)
89 {
90         Evas_Object *btn = NULL;
91         GL_CHECK_NULL(parent);
92         GL_CHECK_NULL(text);
93         gl_dbg("Button text: %s", text);
94
95         btn = elm_button_add(parent);
96         GL_CHECK_NULL(btn);
97         elm_object_text_set(btn, text);
98
99         if (cb_func)
100                 evas_object_smart_callback_add(btn, "clicked", cb_func, data);
101
102         return btn;
103 }
104