1 #ifndef ELM_WIDGET_CTXPOPUP_H
2 #define ELM_WIDGET_CTXPOPUP_H
4 #include "elm_widget_layout.h"
10 * @section elm-ctxpopup-class The Elementary Ctxpopup Class
12 * Elementary, besides having the @ref Ctxpopup widget, exposes its
13 * foundation -- the Elementary Ctxpopup Class -- in order to create other
14 * widgets which are a ctxpopup with some more logic on top.
18 * @def ELM_CTXPOPUP_CLASS
20 * Use this macro to cast whichever subclass of
21 * #Elm_Ctxpopup_Smart_Class into it, so to access its fields.
25 #define ELM_CTXPOPUP_CLASS(x) ((Elm_Ctxpopup_Smart_Class *)x)
28 * @def ELM_CTXPOPUP_DATA
30 * Use this macro to cast whichever subdata of
31 * #Elm_Ctxpopup_Smart_Data into it, so to access its fields.
35 #define ELM_CTXPOPUP_DATA(x) ((Elm_Ctxpopup_Smart_Data *)x)
38 * @def ELM_CTXPOPUP_SMART_CLASS_VERSION
40 * Current version for Elementary ctxpopup @b base smart class, a value
41 * which goes to _Elm_Ctxpopup_Smart_Class::version.
45 #define ELM_CTXPOPUP_SMART_CLASS_VERSION 1
48 * @def ELM_CTXPOPUP_SMART_CLASS_INIT
50 * Initializer for a whole #Elm_Ctxpopup_Smart_Class structure, with
51 * @c NULL values on its specific fields.
53 * @param smart_class_init initializer to use for the "base" field
54 * (#Evas_Smart_Class).
56 * @see EVAS_SMART_CLASS_INIT_NULL
57 * @see EVAS_SMART_CLASS_INIT_NAME_VERSION
58 * @see ELM_CTXPOPUP_SMART_CLASS_INIT_NULL
59 * @see ELM_CTXPOPUP_SMART_CLASS_INIT_NAME_VERSION
63 #define ELM_CTXPOPUP_SMART_CLASS_INIT(smart_class_init) \
64 {smart_class_init, ELM_CTXPOPUP_SMART_CLASS_VERSION}
67 * @def ELM_CTXPOPUP_SMART_CLASS_INIT_NULL
69 * Initializer to zero out a whole #Elm_Ctxpopup_Smart_Class structure.
71 * @see ELM_CTXPOPUP_SMART_CLASS_INIT_NAME_VERSION
72 * @see ELM_CTXPOPUP_SMART_CLASS_INIT
76 #define ELM_CTXPOPUP_SMART_CLASS_INIT_NULL \
77 ELM_CTXPOPUP_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
80 * @def ELM_CTXPOPUP_SMART_CLASS_INIT_NAME_VERSION
82 * Initializer to zero out a whole #Elm_Ctxpopup_Smart_Class structure and
83 * set its name and version.
85 * This is similar to #ELM_CTXPOPUP_SMART_CLASS_INIT_NULL, but it will
86 * also set the version field of #Elm_Ctxpopup_Smart_Class (base field)
87 * to the latest #ELM_CTXPOPUP_SMART_CLASS_VERSION and name it to the
90 * It will keep a reference to the name field as a <c>"const char *"</c>,
91 * i.e., the name must be available while the structure is
92 * used (hint: static or global variable!) and must not be modified.
94 * @see ELM_CTXPOPUP_SMART_CLASS_INIT_NULL
95 * @see ELM_CTXPOPUP_SMART_CLASS_INIT
99 #define ELM_CTXPOPUP_SMART_CLASS_INIT_NAME_VERSION(name) \
100 ELM_CTXPOPUP_SMART_CLASS_INIT(ELM_LAYOUT_SMART_CLASS_INIT_NAME_VERSION(name))
103 * Elementary ctxpopup base smart class. This inherits directly from
104 * #Elm_Layout_Smart_Class and is meant to build widgets extending the
105 * behavior of a ctxpopup.
107 * All of the functions listed on @ref Ctxpopup namespace will work for
108 * objects deriving from #Elm_Ctxpopup_Smart_Class.
110 typedef struct _Elm_Ctxpopup_Smart_Class
112 Elm_Layout_Smart_Class base;
114 int version; /**< Version of this smart class definition */
115 } Elm_Ctxpopup_Smart_Class;
117 typedef struct _Elm_Ctxpopup_Item Elm_Ctxpopup_Item;
120 * Base widget smart data extended with ctxpopup instance data.
122 typedef struct _Elm_Ctxpopup_Smart_Data Elm_Ctxpopup_Smart_Data;
124 struct _Elm_Ctxpopup_Item
134 struct _Elm_Ctxpopup_Smart_Data
136 Elm_Layout_Smart_Data base;
145 Evas_Object *content;
148 Elm_Ctxpopup_Direction dir;
149 Elm_Ctxpopup_Direction dir_priority[4];
151 Eina_Bool horizontal : 1;
152 Eina_Bool visible : 1;
153 Eina_Bool auto_hide : 1;
154 Eina_Bool mouse_down : 1;
163 EAPI extern const char ELM_CTXPOPUP_SMART_NAME[];
164 EAPI const Elm_Ctxpopup_Smart_Class
165 *elm_ctxpopup_smart_class_get(void);
167 #define ELM_CTXPOPUP_DATA_GET(o, sd) \
168 Elm_Ctxpopup_Smart_Data * sd = evas_object_smart_data_get(o)
170 #define ELM_CTXPOPUP_DATA_GET_OR_RETURN(o, ptr) \
171 ELM_CTXPOPUP_DATA_GET(o, ptr); \
174 CRITICAL("No widget data for object %p (%s)", \
175 o, evas_object_type_get(o)); \
179 #define ELM_CTXPOPUP_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
180 ELM_CTXPOPUP_DATA_GET(o, ptr); \
183 CRITICAL("No widget data for object %p (%s)", \
184 o, evas_object_type_get(o)); \
188 #define ELM_CTXPOPUP_CHECK(obj) \
189 if (!obj || !elm_widget_type_check((obj), \
190 ELM_CTXPOPUP_SMART_NAME, __func__)) \