Download

Support

lib/ewl_object.h

Go to the documentation of this file.
00001 /* vim: set sw=8 ts=8 sts=8 expandtab: */
00002 #ifndef EWL_OBJECT_H
00003 #define EWL_OBJECT_H
00004 
00016 #define EWL_OBJECT_MIN_SIZE (1)
00017 
00022 #define EWL_OBJECT_MAX_SIZE (INT_MAX)
00023 
00028 typedef struct Ewl_Object Ewl_Object;
00029 
00034 #define EWL_OBJECT(object) ((Ewl_Object *) object)
00035 
00065 struct Ewl_Object
00066 {
00067         struct
00068         {
00069                 int x, 
00070                     y; 
00071                 int w, 
00072                     h; 
00073         } current; 
00075         struct
00076         {
00077                 int w, 
00078                     h; 
00079         }
00080         preferred, 
00081         maximum, 
00082         minimum; 
00084         struct
00085         {
00086                 short l, 
00087                       r, 
00088                       t, 
00089                       b; 
00090         } pad, 
00091         insets; 
00093         unsigned int flags; 
00094 };
00095 
00096 int                 ewl_object_init(Ewl_Object *o);
00097 void                 ewl_object_current_geometry_get(Ewl_Object *o, int *x, int *y,
00098                                                 int *w, int *h);
00099 
00100 void                 ewl_object_current_size_get(Ewl_Object *o, int *w, int *h);
00101 int                 ewl_object_current_x_get(Ewl_Object *o);
00102 int                 ewl_object_current_y_get(Ewl_Object *o);
00103 int                 ewl_object_current_w_get(Ewl_Object *o);
00104 int                 ewl_object_current_h_get(Ewl_Object *o);
00105 
00106 void                 ewl_object_preferred_inner_size_set(Ewl_Object *o, int w, int h);
00107 void                 ewl_object_preferred_inner_size_get(Ewl_Object *o, int *w, int *h);
00108 void                 ewl_object_preferred_size_get(Ewl_Object *o, int *w, int *h);
00109 
00110 void                 ewl_object_preferred_inner_w_set(Ewl_Object *o, int w);
00111 int                 ewl_object_preferred_w_get(Ewl_Object *o);
00112 int                 ewl_object_preferred_inner_w_get(Ewl_Object *o);
00113 
00114 void                 ewl_object_preferred_inner_h_set(Ewl_Object *o, int h);
00115 int                 ewl_object_preferred_inner_h_get(Ewl_Object *o);
00116 int                 ewl_object_preferred_h_get(Ewl_Object *o);
00117 
00118 void                 ewl_object_geometry_request(Ewl_Object *o, int x, int y,
00119                                                     int w, int h);
00120 void                 ewl_object_size_request(Ewl_Object *o, int w, int h);
00121 void                 ewl_object_position_request(Ewl_Object *o, int x, int y);
00122 void                ewl_object_x_request(Ewl_Object *o, int x);
00123 void                ewl_object_y_request(Ewl_Object *o, int y);
00124 void                 ewl_object_w_request(Ewl_Object *o, int w);
00125 void                 ewl_object_h_request(Ewl_Object *o, int h);
00126 
00127 void                 ewl_object_minimum_size_set(Ewl_Object *o, int w, int h);
00128 void                ewl_object_minimum_w_set(Ewl_Object *o, int w);
00129 void                ewl_object_minimum_h_set(Ewl_Object *o, int h);
00130 
00131 void                  ewl_object_minimum_size_get(Ewl_Object *o, int *w, int *h);
00132 int                ewl_object_minimum_w_get(Ewl_Object *o);
00133 int                ewl_object_minimum_h_get(Ewl_Object *o);
00134 
00135 void                  ewl_object_maximum_size_set(Ewl_Object *o, int w, int h);
00136 void                ewl_object_maximum_w_set(Ewl_Object *o, int w);
00137 void                ewl_object_maximum_h_set(Ewl_Object *o, int h);
00138 
00139 void                  ewl_object_maximum_size_get(Ewl_Object *o, int *w, int *h);
00140 int                ewl_object_maximum_w_get(Ewl_Object *o);
00141 int                ewl_object_maximum_h_get(Ewl_Object *o);
00142 
00143 unsigned int    ewl_object_alignment_get(Ewl_Object *o);
00144 void                ewl_object_alignment_set(Ewl_Object *o, unsigned int align);
00145 void                 ewl_object_place(Ewl_Object *o, int x, int y, int w, int h);
00146 
00147 unsigned int    ewl_object_fill_policy_get(Ewl_Object *o);
00148 void                ewl_object_fill_policy_set(Ewl_Object *o, unsigned int fill);
00149 
00150 /*
00151  * Padding setting and retrieval functions.
00152  */
00153 void                 ewl_object_padding_set(Ewl_Object *o, int l, int r, int t,
00154                                        int b);
00155 void                 ewl_object_padding_get(Ewl_Object *o, int *l, int *r, int *t,
00156                                        int *b);
00157 int                 ewl_object_padding_top_get(Ewl_Object *o);
00158 int                 ewl_object_padding_bottom_get(Ewl_Object *o);
00159 int                 ewl_object_padding_left_get(Ewl_Object *o);
00160 int                 ewl_object_padding_right_get(Ewl_Object *o);
00161 
00162 /*
00163  * Inset setting and retrieval functions.
00164  */
00165 void                 ewl_object_insets_set(Ewl_Object *o, int l, int r, int t,
00166                                       int b);
00167 void                 ewl_object_insets_get(Ewl_Object *o, int *l, int *r, int *t,
00168                                       int *b);
00169 int                 ewl_object_insets_top_get(Ewl_Object *o);
00170 int                 ewl_object_insets_bottom_get(Ewl_Object *o);
00171 int                 ewl_object_insets_left_get(Ewl_Object *o);
00172 int                 ewl_object_insets_right_get(Ewl_Object *o);
00173 
00174 void                 ewl_object_flags_add(Ewl_Object *o, unsigned int flags,
00175                                      unsigned int mask);
00176 void                 ewl_object_flags_remove(Ewl_Object *o, unsigned int flags,
00177                                         unsigned int mask);
00178 
00185 #define ewl_object_flags_get(o, mask) \
00186         (EWL_OBJECT(o)->flags & mask)
00187 
00195 #define ewl_object_flags_has(o, check_flags, mask) \
00196         (!!(EWL_OBJECT(o)->flags & ((check_flags) & mask)))
00197 
00205 #define ewl_object_flags_has_all(o, check_flags, mask) \
00206         ((EWL_OBJECT(o)->flags & ((check_flags) & mask)) == ((check_flags) & mask))
00207 
00215 #define ewl_object_recursive_set(o, val) \
00216         (val ? ewl_object_flags_add(o, EWL_FLAG_PROPERTY_RECURSIVE, \
00217                                     EWL_FLAGS_PROPERTY_MASK) : \
00218          ewl_object_flags_remove(o, EWL_FLAG_PROPERTY_RECURSIVE, \
00219                                     EWL_FLAGS_PROPERTY_MASK));
00220 
00227 #define ewl_object_recursive_get(o) \
00228         (ewl_object_flags_get(o, EWL_FLAG_PROPERTY_RECURSIVE))
00229 
00237 #define ewl_object_toplevel_set(o, val) \
00238         (val ? ewl_object_flags_add(o, EWL_FLAG_PROPERTY_TOPLEVEL, \
00239                                     EWL_FLAGS_PROPERTY_MASK) : \
00240          ewl_object_flags_remove(o, EWL_FLAG_PROPERTY_TOPLEVEL, \
00241                                     EWL_FLAGS_PROPERTY_MASK));
00242 
00249 #define ewl_object_toplevel_get(o) \
00250         (ewl_object_flags_get(o, EWL_FLAG_PROPERTY_TOPLEVEL))
00251 
00258 #define ewl_object_state_add(o, state) \
00259         ewl_object_flags_add(o, state, EWL_FLAGS_STATE_MASK)
00260 
00267 #define ewl_object_state_remove(o, state) \
00268         ewl_object_flags_remove(o, state, EWL_FLAGS_STATE_MASK)
00269 
00276 #define ewl_object_state_has(o, state) \
00277         ewl_object_flags_has(o, state, EWL_FLAGS_STATE_MASK)
00278 
00285 #define ewl_object_state_get(o, state) \
00286         ewl_object_flags_get(o, state, EWL_FLAGS_STATE_MASK)
00287 
00294 #define ewl_object_queued_add(o, queued) \
00295         ewl_object_flags_add(o, queued, EWL_FLAGS_QUEUED_MASK)
00296 
00301 #define ewl_object_queued_remove(o, queued) \
00302         ewl_object_flags_remove(o, queued, EWL_FLAGS_QUEUED_MASK)
00303 
00308 #define ewl_object_queued_has(o, queued) \
00309         ewl_object_flags_has(o, queued, EWL_FLAGS_QUEUED_MASK)
00310 
00315 #define ewl_object_queued_get(o, queued) \
00316         ewl_object_flags_get(o, queued, EWL_FLAGS_QUEUED_MASK)
00317 
00322 #define ewl_object_visible_add(o, visible) \
00323         ewl_object_flags_add(o, visible, EWL_FLAGS_VISIBLE_MASK)
00324 
00329 #define ewl_object_visible_remove(o, visible) \
00330         ewl_object_flags_remove(o, visible, EWL_FLAGS_VISIBLE_MASK)
00331 
00336 #define ewl_object_visible_has(o, visible) \
00337         ewl_object_flags_has(o, visible, EWL_FLAGS_VISIBLE_MASK)
00338 
00343 #define ewl_object_visible_get(o, visible) \
00344         ewl_object_flags_get(o, visible, EWL_FLAGS_VISIBLE_MASK)
00345 
00350 #define PADDING_TOP(o) ((const Ewl_Object *)(o))->pad.t
00351 
00356 #define PADDING_BOTTOM(o) ((const Ewl_Object *)(o))->pad.b
00357 
00362 #define PADDING_LEFT(o) ((const Ewl_Object *)(o))->pad.l
00363 
00368 #define PADDING_RIGHT(o) ((const Ewl_Object *)(o))->pad.r
00369 
00374 #define PADDING_HORIZONTAL(o) (EWL_OBJECT(o)->pad.l + EWL_OBJECT(o)->pad.r)
00375 
00380 #define PADDING_VERTICAL(o) (EWL_OBJECT(o)->pad.t + EWL_OBJECT(o)->pad.b)
00381 
00386 #define INSET_LEFT(o) ((const Ewl_Object *)(o))->insets.l
00387 
00392 #define INSET_RIGHT(o) ((const Ewl_Object *)(o))->insets.r
00393 
00398 #define INSET_TOP(o) ((const Ewl_Object *)(o))->insets.t
00399 
00404 #define INSET_BOTTOM(o) ((const Ewl_Object *)(o))->insets.b
00405 
00410 #define INSET_HORIZONTAL(o) (EWL_OBJECT(o)->insets.l + EWL_OBJECT(o)->insets.r)
00411 
00416 #define INSET_VERTICAL(o) (EWL_OBJECT(o)->insets.t + EWL_OBJECT(o)->insets.b)
00417 
00422 #define CURRENT_X(o) ((const Ewl_Object *)(o))->current.x
00423 
00428 #define CURRENT_Y(o) ((const Ewl_Object *)(o))->current.y
00429 
00434 #define CURRENT_W(o) ((const Ewl_Object *)(o))->current.w
00435 
00440 #define CURRENT_H(o) ((const Ewl_Object *)(o))->current.h
00441 
00446 #define PREFERRED_W(o) ((const Ewl_Object *)(o))->preferred.w
00447 
00452 #define PREFERRED_H(o) ((const Ewl_Object *)(o))->preferred.h
00453 
00458 #define MAXIMUM_W(o) ((const Ewl_Object *)(o))->maximum.w
00459 
00464 #define MAXIMUM_H(o) ((const Ewl_Object *)(o))->maximum.h
00465 
00470 #define MINIMUM_W(o) ((const Ewl_Object *)(o))->minimum.w
00471 
00476 #define MINIMUM_H(o) ((const Ewl_Object *)(o))->minimum.h
00477 
00485 #define ewl_object_custom_size_set(o, w, h) \
00486         { \
00487                 ewl_object_minimum_size_set(o, w, h); \
00488                 ewl_object_maximum_size_set(o, w, h); \
00489                  ewl_object_fill_policy_set(o, EWL_FLAG_FILL_NONE); \
00490         }
00491 
00498 #define ewl_object_custom_w_set(o, w) \
00499         { \
00500                 ewl_object_maximum_w_set(o, w); \
00501                 ewl_object_minimum_w_set(o, w); \
00502                 ewl_object_fill_policy_set(o, ewl_object_fill_policy_get(o) & \
00503                                 ~(EWL_FLAG_FILL_HFILL | EWL_FLAG_FILL_HSHRINK)); \
00504         }
00505 
00512 #define ewl_object_custom_h_set(o, h) \
00513         { \
00514                 ewl_object_maximum_h_set(o, h); \
00515                 ewl_object_minimum_h_set(o, h); \
00516                 ewl_object_fill_policy_set(o, ewl_object_fill_policy_get(o) & \
00517                                 ~(EWL_FLAG_FILL_VFILL | EWL_FLAG_FILL_VSHRINK)); \
00518         }
00519 
00524 #define RECURSIVE(o) (EWL_OBJECT(o)->flags & EWL_FLAG_PROPERTY_RECURSIVE)
00525 
00530 #define REALIZED(o) (EWL_OBJECT(o)->flags & EWL_FLAG_VISIBLE_REALIZED)
00531 
00536 #define VISIBLE(o) (EWL_OBJECT(o)->flags & EWL_FLAG_VISIBLE_SHOWN)
00537 
00542 #define REVEALED(o) (EWL_OBJECT(o)->flags & EWL_FLAG_VISIBLE_REVEALED)
00543 
00548 #define HIDDEN(o) (!(EWL_OBJECT(o)->flags & EWL_FLAG_VISIBLE_SHOWN))
00549 
00554 #define DESTROYED(o) (ewl_object_queued_has(EWL_OBJECT(o), \
00555                                         EWL_FLAG_QUEUED_SCHEDULED_DESTROY) \
00556                         || ewl_object_queued_has(EWL_OBJECT(o), \
00557                                         EWL_FLAG_QUEUED_PROCESS_DESTROY))
00558 
00563 #define CONFIGURED(o) (ewl_object_queued_has(EWL_OBJECT(o), \
00564                                         EWL_FLAG_QUEUED_SCHEDULED_CONFIGURE) \
00565                         || ewl_object_queued_has(EWL_OBJECT(o), \
00566                                         EWL_FLAG_QUEUED_PROCESS_CONFIGURE))
00567 
00572 #define DISABLED(o) (ewl_object_state_has(EWL_OBJECT(o), EWL_FLAG_STATE_DISABLED))
00573 
00580 #define ewl_object_in_tab_list_get(o) \
00581         (ewl_object_flags_get(o, EWL_FLAG_PROPERTY_IN_TAB_LIST))
00582 
00590 #define ewl_object_in_tab_list_set(o, val) \
00591         (val ? ewl_object_flags_add(o, EWL_FLAG_PROPERTY_IN_TAB_LIST, \
00592                                     EWL_FLAGS_PROPERTY_MASK) : \
00593          ewl_object_flags_remove(o, EWL_FLAG_PROPERTY_IN_TAB_LIST, \
00594                                     EWL_FLAGS_PROPERTY_MASK));
00595 
00600 #endif

Copyright © Enlightenment.org

Enlightened Widget Library Documentation Generated: Sat May 17 16:49:06 2008