1 #ifndef ELM_WIDGET_SEGMENT_CONTROL_H
2 #define ELM_WIDGET_SEGMENT_CONTROL_H
4 #include "elm_widget_layout.h"
10 * @section elm-segment-control-class The Elementary Segment control Class
12 * Elementary, besides having the @ref SegmentControl widget, exposes
13 * its foundation -- the Elementary Segment control Class -- in order
14 * to create other widgets which are a segment control with some more
19 * @def ELM_SEGMENT_CONTROL_CLASS
21 * Use this macro to cast whichever subclass of
22 * #Elm_Segment_Control_Smart_Class into it, so to access its fields.
26 #define ELM_SEGMENT_CONTROL_CLASS(x) ((Elm_Segment_Control_Smart_Class *)x)
29 * @def ELM_SEGMENT_CONTROL_DATA
31 * Use this macro to cast whichever subdata of
32 * #Elm_Segment_Control_Smart_Data into it, so to access its fields.
36 #define ELM_SEGMENT_CONTROL_DATA(x) ((Elm_Segment_Control_Smart_Data *)x)
39 * @def ELM_SEGMENT_CONTROL_SMART_CLASS_VERSION
41 * Current version for Elementary segment control @b base smart class, a value
42 * which goes to _Elm_Segment_Control_Smart_Class::version.
46 #define ELM_SEGMENT_CONTROL_SMART_CLASS_VERSION 1
49 * @def ELM_SEGMENT_CONTROL_SMART_CLASS_INIT
51 * Initializer for a whole #Elm_Segment_Control_Smart_Class structure, with
52 * @c NULL values on its specific fields.
54 * @param smart_class_init initializer to use for the "base" field
55 * (#Evas_Smart_Class).
57 * @see EVAS_SMART_CLASS_INIT_NULL
58 * @see EVAS_SMART_CLASS_INIT_NAME_VERSION
59 * @see ELM_SEGMENT_CONTROL_SMART_CLASS_INIT_NULL
60 * @see ELM_SEGMENT_CONTROL_SMART_CLASS_INIT_NAME_VERSION
64 #define ELM_SEGMENT_CONTROL_SMART_CLASS_INIT(smart_class_init) \
65 {smart_class_init, ELM_SEGMENT_CONTROL_SMART_CLASS_VERSION}
68 * @def ELM_SEGMENT_CONTROL_SMART_CLASS_INIT_NULL
70 * Initializer to zero out a whole #Elm_Segment_Control_Smart_Class structure.
72 * @see ELM_SEGMENT_CONTROL_SMART_CLASS_INIT_NAME_VERSION
73 * @see ELM_SEGMENT_CONTROL_SMART_CLASS_INIT
77 #define ELM_SEGMENT_CONTROL_SMART_CLASS_INIT_NULL \
78 ELM_SEGMENT_CONTROL_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
81 * @def ELM_SEGMENT_CONTROL_SMART_CLASS_INIT_NAME_VERSION
83 * Initializer to zero out a whole #Elm_Segment_Control_Smart_Class
84 * structure and set its name and version.
86 * This is similar to #ELM_SEGMENT_CONTROL_SMART_CLASS_INIT_NULL, but
87 * it will also set the version field of
88 * #Elm_Segment_Control_Smart_Class (base field) to the latest
89 * #ELM_SEGMENT_CONTROL_SMART_CLASS_VERSION and name it to the
92 * It will keep a reference to the name field as a <c>"const char *"</c>,
93 * i.e., the name must be available while the structure is
94 * used (hint: static or global variable!) and must not be modified.
96 * @see ELM_SEGMENT_CONTROL_SMART_CLASS_INIT_NULL
97 * @see ELM_SEGMENT_CONTROL_SMART_CLASS_INIT
101 #define ELM_SEGMENT_CONTROL_SMART_CLASS_INIT_NAME_VERSION(name) \
102 ELM_SEGMENT_CONTROL_SMART_CLASS_INIT \
103 (ELM_LAYOUT_SMART_CLASS_INIT_NAME_VERSION(name))
106 * Elementary segment control base smart class. This inherits directly from
107 * #Elm_Layout_Smart_Class and is meant to build widgets extending the
108 * behavior of a segment control.
110 * All of the functions listed on @ref SegmentControl namespace will work for
111 * objects deriving from #Elm_Segment_Control_Smart_Class.
113 typedef struct _Elm_Segment_Control_Smart_Class
115 Elm_Layout_Smart_Class base;
117 int version; /**< Version of this smart class definition */
118 } Elm_Segment_Control_Smart_Class;
121 * Base layout smart data extended with segment control instance data.
123 typedef struct _Elm_Segment_Control_Smart_Data Elm_Segment_Control_Smart_Data;
124 typedef struct _Elm_Segment_Item Elm_Segment_Item;
126 struct _Elm_Segment_Control_Smart_Data
128 Elm_Layout_Smart_Data base;
131 Elm_Segment_Item *selected_item;
136 struct _Elm_Segment_Item
149 EAPI extern const char ELM_SEGMENT_CONTROL_SMART_NAME[];
150 EAPI const Elm_Segment_Control_Smart_Class
151 *elm_segment_control_smart_class_get(void);
154 #define ELM_SEGMENT_CONTROL_DATA_GET(o, sd) \
155 Elm_Segment_Control_Smart_Data * sd = evas_object_smart_data_get(o)
157 #define ELM_SEGMENT_CONTROL_DATA_GET_OR_RETURN(o, ptr) \
158 ELM_SEGMENT_CONTROL_DATA_GET(o, ptr); \
161 CRITICAL("No widget data for object %p (%s)", \
162 o, evas_object_type_get(o)); \
166 #define ELM_SEGMENT_CONTROL_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
167 ELM_SEGMENT_CONTROL_DATA_GET(o, ptr); \
170 CRITICAL("No widget data for object %p (%s)", \
171 o, evas_object_type_get(o)); \
175 #define ELM_SEGMENT_CONTROL_CHECK(obj) \
176 if (!obj || !elm_widget_type_check \
177 ((obj), ELM_SEGMENT_CONTROL_SMART_NAME, __func__)) \
180 #define ELM_SEGMENT_CONTROL_ITEM_CHECK(it) \
181 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, ); \
182 ELM_SEGMENT_CONTROL_CHECK(it->base.widget);
184 #define ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, ...) \
185 ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item *)it, __VA_ARGS__); \
186 ELM_SEGMENT_CONTROL_CHECK(it->base.widget) __VA_ARGS__;