Enlightenment CVS committal Author : rbdpngn Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src Modified Files: ewl_entry.c ewl_entry.h ewl_enums.h ewl_misc.c ewl_object.c ewl_overlay.c ewl_scrollbar.c ewl_scrollbar.h ewl_scrollpane.c ewl_scrollpane.h Log Message: * Automatically show and hide scrollbars. * Start of text wrapping support. * Addition of object flags. =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_entry.c,v retrieving revision 1.125 retrieving revision 1.126 diff -u -3 -r1.125 -r1.126 --- ewl_entry.c 30 Dec 2004 21:02:38 -0000 1.125 +++ ewl_entry.c 3 Feb 2005 15:30:54 -0000 1.126 @@ -631,6 +631,42 @@ } /** + * @param e: the entry widget to change wrapping + * @param wrap: a boolean that indicates wrapping + * @brief Changes whether the entry wraps or clips to it's available area + * @return Returns no value. + * + * Changes + */ +void ewl_entry_wrap_set(Ewl_Entry *e, int wrap) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("e", e); + + /* + * If the wrapping changes notify the parent to configure the entry. + */ + if (wrap != e->wrap) { + e->wrap = wrap; + if (EWL_WIDGET(e)->parent) + ewl_widget_configure(EWL_WIDGET(e)->parent); + } + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** + * @param e: the entry widget to retrieve wrapping + * @brief Retrieves the current wrapping of the entry + * @return Returns TRUE if wrapping is enabled, otherwise FALSE. + */ +int ewl_entry_wrap_get(Ewl_Entry *e) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DRETURN_INT(e->wrap, DLEVEL_STABLE); +} + +/** * @param e: the entry widget to map a coordinate to a character index * @param x: the x coordinate over the desired character * @param y: the y coordinate over the desired character @@ -716,8 +752,9 @@ * Update the etox position and size. */ if (e->etox) { + etox_set_word_wrap(e->etox, e->wrap); evas_object_move(e->etox, xx, yy); - evas_object_resize(e->etox, ww, hh); + evas_object_resize(e->etox, ww, hh); evas_object_layer_set(e->etox, ewl_widget_layer_sum_get(w)); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_entry.h,v retrieving revision 1.47 retrieving revision 1.48 diff -u -3 -r1.47 -r1.48 --- ewl_entry.h 24 Dec 2004 22:16:41 -0000 1.47 +++ ewl_entry.h 3 Feb 2005 15:30:55 -0000 1.48 @@ -48,6 +48,7 @@ double start_time; /**< Time timer started */ int in_select_mode; /**< keyboard cursor movements select? */ int multiline; /**< Deal with multiple lines of text? */ + int wrap; /**< Enable wrapping of the text */ }; Ewl_Widget *ewl_entry_new(char *text); @@ -80,6 +81,9 @@ void ewl_entry_align_set(Ewl_Entry *e, unsigned int align); unsigned int ewl_entry_align_get(Ewl_Entry *e); +void ewl_entry_wrap_set(Ewl_Entry *e, int wrap); +int ewl_entry_wrap_get(Ewl_Entry *e); + void ewl_entry_index_select(Ewl_Entry *e, int si, int ei); void ewl_entry_coord_select(Ewl_Entry *e, int sx, int sy, int ex, int ey); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_enums.h,v retrieving revision 1.53 retrieving revision 1.54 diff -u -3 -r1.53 -r1.54 --- ewl_enums.h 21 Dec 2004 04:15:56 -0000 1.53 +++ ewl_enums.h 3 Feb 2005 15:30:55 -0000 1.54 @@ -86,23 +86,23 @@ * The alignment enumeration allows for specifying how an element is * aligned within it's container. */ - EWL_FLAG_ALIGN_CENTER = ETOX_ALIGN_CENTER, /**< Center align bit */ - EWL_FLAG_ALIGN_LEFT = ETOX_ALIGN_LEFT, /**< Left align bit */ - EWL_FLAG_ALIGN_RIGHT = ETOX_ALIGN_RIGHT, /**< Right align bit */ - EWL_FLAG_ALIGN_TOP = ETOX_ALIGN_TOP, /**< Top align bit */ - EWL_FLAG_ALIGN_BOTTOM = ETOX_ALIGN_BOTTOM, /**< Bottom align bit */ + EWL_FLAG_ALIGN_CENTER = 0, /**< Center align bit */ + EWL_FLAG_ALIGN_LEFT = 0x1, /**< Left align bit */ + EWL_FLAG_ALIGN_RIGHT = 0x2, /**< Right align bit */ + EWL_FLAG_ALIGN_TOP = 0x4, /**< Top align bit */ + EWL_FLAG_ALIGN_BOTTOM = 0x8, /**< Bottom align bit */ /* * Fill policy identifies to containers whether child widgets should be * stretched to fill available space or keep their current size. */ EWL_FLAG_FILL_NONE = 0, /**< Do not fill or shrink in any direction */ - EWL_FLAG_FILL_HSHRINK = 0x1000, /**< Horizontally shrink bit */ - EWL_FLAG_FILL_VSHRINK = 0x2000, /**< Horizontally shrink bit */ + EWL_FLAG_FILL_HSHRINK = 0x10, /**< Horizontally shrink bit */ + EWL_FLAG_FILL_VSHRINK = 0x20, /**< Horizontally shrink bit */ EWL_FLAG_FILL_SHRINK = EWL_FLAG_FILL_HSHRINK | EWL_FLAG_FILL_VSHRINK, /**< Shrink bit */ - EWL_FLAG_FILL_HFILL = 0x4000, /**< Horizontal fill bit */ - EWL_FLAG_FILL_VFILL = 0x8000, /**< Vertical fill bit */ + EWL_FLAG_FILL_HFILL = 0x40, /**< Horizontal fill bit */ + EWL_FLAG_FILL_VFILL = 0x80, /**< Vertical fill bit */ EWL_FLAG_FILL_FILL = EWL_FLAG_FILL_HFILL | EWL_FLAG_FILL_VFILL, /**< Fill bit */ EWL_FLAG_FILL_ALL = EWL_FLAG_FILL_FILL | EWL_FLAG_FILL_SHRINK, /**< Shrunk and fill bit */ @@ -110,32 +110,39 @@ * Flags identifying the visibility status of the widget */ EWL_FLAG_VISIBLE_HIDDEN = 0, - EWL_FLAG_VISIBLE_SHOWN = 0x10000, - EWL_FLAG_VISIBLE_REALIZED = 0x20000, - EWL_FLAG_VISIBLE_OBSCURED = 0x40000, - EWL_FLAG_VISIBLE_NOCLIP = 0x80000, - - EWL_FLAG_PROPERTY_RECURSIVE = 0x100000, - EWL_FLAG_PROPERTY_TOPLEVEL = 0x200000, - EWL_FLAG_PROPERTY_INTERNAL = 0x400000, + EWL_FLAG_VISIBLE_SHOWN = 0x100, + EWL_FLAG_VISIBLE_REALIZED = 0x200, + EWL_FLAG_VISIBLE_OBSCURED = 0x400, + EWL_FLAG_VISIBLE_NOCLIP = 0x800, + + /* + * Behavior modifying properties. + */ + EWL_FLAG_PROPERTY_RECURSIVE = 0x1000, + EWL_FLAG_PROPERTY_TOPLEVEL = 0x2000, + EWL_FLAG_PROPERTY_INTERNAL = 0x4000, /* * Flags to indicate queues this object is on. */ - EWL_FLAG_QUEUED_CSCHEDULED = 0x800000, - EWL_FLAG_QUEUED_RSCHEDULED = 0x1000000, - EWL_FLAG_QUEUED_DSCHEDULED = 0x2000000, + EWL_FLAG_QUEUED_CSCHEDULED = 0x8000, + EWL_FLAG_QUEUED_RSCHEDULED = 0x10000, + EWL_FLAG_QUEUED_DSCHEDULED = 0x20000, + + EWL_FLAG_QUEUED_CPROCESS = 0x40000, + EWL_FLAG_QUEUED_RPROCESS = 0x80000, + EWL_FLAG_QUEUED_DPROCESS = 0x100000, /* * The state enum specifies the current state of a widget, ie. has it * been clicked, does it have the keyboard focus, etc. */ EWL_FLAG_STATE_NORMAL = 0, - EWL_FLAG_STATE_HILITED = 0x4000000, - EWL_FLAG_STATE_PRESSED = 0x8000000, - EWL_FLAG_STATE_SELECTED = 0x10000000, - EWL_FLAG_STATE_DND = 0x20000000, - EWL_FLAG_STATE_DISABLED = 0x40000000 + EWL_FLAG_STATE_HILITED = 0x200000, + EWL_FLAG_STATE_PRESSED = 0x400000, + EWL_FLAG_STATE_SELECTED = 0x8000000, + EWL_FLAG_STATE_DND = 0x1000000, + EWL_FLAG_STATE_DISABLED = 0x2000000 }; #define EWL_FLAG_FILL_NORMAL (EWL_FLAG_FILL_FILL) @@ -155,7 +162,9 @@ EWL_FLAG_PROPERTY_TOPLEVEL | EWL_FLAG_PROPERTY_INTERNAL) #define EWL_FLAGS_QUEUED_MASK (EWL_FLAG_QUEUED_CSCHEDULED | \ - EWL_FLAG_QUEUED_RSCHEDULED | EWL_FLAG_QUEUED_DSCHEDULED) + EWL_FLAG_QUEUED_RSCHEDULED | EWL_FLAG_QUEUED_DSCHEDULED | \ + EWL_FLAG_QUEUED_CPROCESS | EWL_FLAG_QUEUED_RPROCESS | \ + EWL_FLAG_QUEUED_DPROCESS) #define EWL_FLAGS_STATE_MASK (EWL_FLAG_STATE_NORMAL | \ EWL_FLAG_STATE_HILITED | EWL_FLAG_STATE_PRESSED | \ @@ -213,14 +222,14 @@ /** * @enum Ewl_Scrollbar_Flags */ -enum Ewl_Scrollbar_Flags +enum Ewl_ScrollPane_Flags { - EWL_SCROLLBAR_FLAG_NONE, - EWL_SCROLLBAR_FLAG_AUTO_VISIBLE, - EWL_SCROLLBAR_FLAG_ALWAYS_HIDDEN + EWL_SCROLLPANE_FLAG_NONE, + EWL_SCROLLPANE_FLAG_AUTO_VISIBLE, + EWL_SCROLLPANE_FLAG_ALWAYS_HIDDEN }; -typedef enum Ewl_Scrollbar_Flags Ewl_ScrollBar_Flags; +typedef enum Ewl_ScrollPane_Flags Ewl_ScrollPane_Flags; /** * @enum Ewl_Filedialog_Type =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_misc.c,v retrieving revision 1.87 retrieving revision 1.88 diff -u -3 -r1.87 -r1.88 --- ewl_misc.c 24 Dec 2004 22:16:41 -0000 1.87 +++ ewl_misc.c 3 Feb 2005 15:30:55 -0000 1.88 @@ -418,6 +418,9 @@ if (ewl_object_queued_has(EWL_OBJECT(w), EWL_FLAG_QUEUED_DSCHEDULED)) DRETURN(DLEVEL_STABLE); + if (ewl_object_queued_has(EWL_OBJECT(w), EWL_FLAG_QUEUED_CPROCESS)) + DRETURN(DLEVEL_STABLE); + emb = ewl_embed_widget_find(w); if (!emb) DRETURN(DLEVEL_STABLE); @@ -595,7 +598,10 @@ ewl_object_queued_remove(EWL_OBJECT(w), EWL_FLAG_QUEUED_CSCHEDULED); + ewl_object_queued_add(EWL_OBJECT(w), EWL_FLAG_QUEUED_CPROCESS); ewl_callback_call(w, EWL_CALLBACK_CONFIGURE); + ewl_object_queued_remove(EWL_OBJECT(w), + EWL_FLAG_QUEUED_CPROCESS); } } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_object.c,v retrieving revision 1.60 retrieving revision 1.61 diff -u -3 -r1.60 -r1.61 --- ewl_object.c 1 Sep 2004 04:18:54 -0000 1.60 +++ ewl_object.c 3 Feb 2005 15:30:55 -0000 1.61 @@ -240,6 +240,11 @@ ewl_container_child_resize(EWL_WIDGET(o), new_size - old_size, EWL_ORIENTATION_HORIZONTAL); + /* + if (EWL_WIDGET(o)->parent) + ewl_widget_configure(EWL_WIDGET(o)->parent); + */ + DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -289,6 +294,11 @@ ewl_container_child_resize(EWL_WIDGET(o), new_size - old_size, EWL_ORIENTATION_VERTICAL); + /* + if (EWL_WIDGET(o)->parent) + ewl_widget_configure(EWL_WIDGET(o)->parent); + */ + DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -671,6 +681,11 @@ if (CURRENT_W(o) < w) ewl_object_w_request(o, w); + /* + if (EWL_WIDGET(o)->parent) + ewl_widget_configure(EWL_WIDGET(o)->parent); + */ + DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -715,6 +730,11 @@ if (CURRENT_H(o) < h) ewl_object_h_request(o, h); + /* + if (EWL_WIDGET(o)->parent) + ewl_widget_configure(EWL_WIDGET(o)->parent); + */ + DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -878,6 +898,11 @@ if (CURRENT_W(o) > w) ewl_object_h_request(o, w); + /* + if (EWL_WIDGET(o)->parent) + ewl_widget_configure(EWL_WIDGET(o)->parent); + */ + DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -916,6 +941,11 @@ if (CURRENT_H(o) > h) ewl_object_h_request(o, h); + /* + if (EWL_WIDGET(o)->parent) + ewl_widget_configure(EWL_WIDGET(o)->parent); + */ + DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -1064,6 +1094,11 @@ ewl_container_child_resize(EWL_WIDGET(o), dv, EWL_ORIENTATION_VERTICAL); + /* + if (EWL_WIDGET(o)->parent) + ewl_widget_configure(EWL_WIDGET(o)->parent); + */ + DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -1184,6 +1219,11 @@ ewl_container_child_resize(EWL_WIDGET(o), dv, EWL_ORIENTATION_VERTICAL); + /* + if (EWL_WIDGET(o)->parent) + ewl_widget_configure(EWL_WIDGET(o)->parent); + */ + DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -1285,8 +1325,10 @@ ewl_object_flags_remove(o, EWL_FLAGS_ALIGN_MASK, EWL_FLAGS_ALIGN_MASK); ewl_object_flags_add(o, align, EWL_FLAGS_ALIGN_MASK); + /* if (EWL_WIDGET(o)->parent) ewl_widget_configure(EWL_WIDGET(o)->parent); + */ DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -1394,8 +1436,10 @@ PREFERRED_H(o), EWL_ORIENTATION_VERTICAL); */ + /* if (EWL_WIDGET(o)->parent) ewl_widget_configure(EWL_WIDGET(o)->parent); + */ DLEAVE_FUNCTION(DLEVEL_STABLE); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_overlay.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- ewl_overlay.c 24 Dec 2004 22:16:41 -0000 1.10 +++ ewl_overlay.c 3 Feb 2005 15:30:56 -0000 1.11 @@ -72,17 +72,18 @@ */ ecore_list_goto_first(EWL_CONTAINER(w)->children); while ((child = ecore_list_next(EWL_CONTAINER(w)->children))) { + int width, height; /* * Try to give the child the full size of the overlay from it's * base position. The object will constrict it based on the * fill policy. Don't add the TOP and LEFT insets since * they've already been accounted for. */ - ewl_object_size_request(child, - CURRENT_W(w) - - ewl_object_current_x_get(child), - CURRENT_H(w) - - ewl_object_current_y_get(child)); + width = CURRENT_W(w) + CURRENT_X(w); + width -= ewl_object_current_x_get(child); + height = CURRENT_H(w) + CURRENT_Y(w); + height -= ewl_object_current_y_get(child); + ewl_object_size_request(child, width, height); } DLEAVE_FUNCTION(DLEVEL_STABLE); =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_scrollbar.c,v retrieving revision 1.38 retrieving revision 1.39 diff -u -3 -r1.38 -r1.39 --- ewl_scrollbar.c 9 Dec 2004 05:26:09 -0000 1.38 +++ ewl_scrollbar.c 3 Feb 2005 15:30:56 -0000 1.39 @@ -322,39 +322,6 @@ DLEAVE_FUNCTION(DLEVEL_STABLE); } -/** - * @param s: the scrollbar to set the flags - * @param f: the flags to set for the scrollbar - * @return Returns no value. - * @brief Set the flag mask for a scrollbar - * - * Sets the flags @a f for the scrollbar @a s. - */ -void ewl_scrollbar_flag_set(Ewl_Scrollbar * s, Ewl_ScrollBar_Flags f) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("s", s); - - s->flag = f; - ewl_widget_configure(EWL_WIDGET(s)); - - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param s: the scrollbar to retrieve the flags - * @return Returns the flags from the scrollbars @a s. - * @brief Retrieve the current flags of a scrollbar - */ -Ewl_ScrollBar_Flags ewl_scrollbar_flag_get(Ewl_Scrollbar * s) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("s", s, 0); - - DRETURN_INT(s->flag, DLEVEL_STABLE); -} - - /* * Decrement the value of the scrollbar's seeker portion */ =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_scrollbar.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- ewl_scrollbar.h 29 Aug 2004 02:47:39 -0000 1.14 +++ ewl_scrollbar.h 3 Feb 2005 15:30:56 -0000 1.15 @@ -54,7 +54,6 @@ double fill_percentage; /**< The ratio of size for draggable */ double start_time; /**< Time scrolling began */ Ecore_Timer *timer; /**< Repeating timer for scrolling */ - Ewl_ScrollBar_Flags flag; /**< Flags to indicate part visibility */ signed char direction; }; @@ -80,10 +79,6 @@ double ewl_scrollbar_step_get(Ewl_Scrollbar *s); void ewl_scrollbar_step_set(Ewl_Scrollbar * s, double v); -void ewl_scrollbar_flag_set(Ewl_Scrollbar * s, - Ewl_ScrollBar_Flags f); -Ewl_ScrollBar_Flags ewl_scrollbar_flag_get(Ewl_Scrollbar * s); - /* * Internally used callbacks, override at your own risk. */ =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_scrollpane.c,v retrieving revision 1.48 retrieving revision 1.49 diff -u -3 -r1.48 -r1.49 --- ewl_scrollpane.c 9 Dec 2004 05:26:10 -0000 1.48 +++ ewl_scrollpane.c 3 Feb 2005 15:30:56 -0000 1.49 @@ -40,6 +40,7 @@ if (!ewl_container_init(EWL_CONTAINER(s), "scrollpane")) DRETURN_INT(FALSE, DLEVEL_STABLE); + ewl_widget_inherit(w, "scrollpane"); ewl_container_show_notify_set(EWL_CONTAINER(s), @@ -48,6 +49,8 @@ (Ewl_Child_Resize) ewl_scrollpane_child_resize_cb); ewl_object_fill_policy_set(EWL_OBJECT(s), EWL_FLAG_FILL_ALL); + s->hflag = EWL_SCROLLPANE_FLAG_AUTO_VISIBLE; + s->vflag = EWL_SCROLLPANE_FLAG_AUTO_VISIBLE; s->overlay = ewl_overlay_new(); ewl_object_fill_policy_set(EWL_OBJECT(s->overlay), EWL_FLAG_FILL_ALL); @@ -99,7 +102,6 @@ ewl_scrollpane_hscroll_cb, s); ewl_callback_append(s->vscrollbar, EWL_CALLBACK_VALUE_CHANGED, ewl_scrollpane_vscroll_cb, s); - ewl_callback_append(w, EWL_CALLBACK_MOUSE_WHEEL, ewl_scrollpane_wheel_scroll_cb, NULL); @@ -115,12 +117,13 @@ * The scrollbar flags for the horizontal scrollbar are set to @a f. */ void -ewl_scrollpane_hscrollbar_flag_set(Ewl_ScrollPane * s, Ewl_ScrollBar_Flags f) +ewl_scrollpane_hscrollbar_flag_set(Ewl_ScrollPane * s, Ewl_ScrollPane_Flags f) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("s", s); - ewl_scrollbar_flag_set(EWL_SCROLLBAR(s->hscrollbar), f); + s->hflag = f; + ewl_widget_configure(EWL_WIDGET(s)); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -134,12 +137,13 @@ * The scrollbar flags for the vertical scrollbar are set to @a f. */ void -ewl_scrollpane_vscrollbar_flag_set(Ewl_ScrollPane * s, Ewl_ScrollBar_Flags f) +ewl_scrollpane_vscrollbar_flag_set(Ewl_ScrollPane * s, Ewl_ScrollPane_Flags f) { DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("s", s); - ewl_scrollbar_flag_set(EWL_SCROLLBAR(s->vscrollbar), f); + s->vflag = f; + ewl_widget_configure(EWL_WIDGET(s)); DLEAVE_FUNCTION(DLEVEL_STABLE); } @@ -149,16 +153,12 @@ * @return Returns the flags of the horizontal scrollbar, 0 on failure. * @brief Get flags for horizontal scrollbar */ -Ewl_ScrollBar_Flags ewl_scrollpane_hscrollbar_flag_get(Ewl_ScrollPane * s) +Ewl_ScrollPane_Flags ewl_scrollpane_hscrollbar_flag_get(Ewl_ScrollPane * s) { - Ewl_ScrollBar_Flags f; - DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("s", s, 0); - f = ewl_scrollbar_flag_get(EWL_SCROLLBAR(s->hscrollbar)); - - DRETURN_INT(f, DLEVEL_STABLE); + DRETURN_INT(s->hflag, DLEVEL_STABLE); } /** @@ -166,16 +166,12 @@ * @return Returns the flags of the vertical scrollbar on success, 0 on failure. * @brief Get flags for vertical scrollbar */ -Ewl_ScrollBar_Flags ewl_scrollpane_vscrollbar_flag_get(Ewl_ScrollPane * s) +Ewl_ScrollPane_Flags ewl_scrollpane_vscrollbar_flag_get(Ewl_ScrollPane * s) { - Ewl_ScrollBar_Flags f; - DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("s", s, 0); - f = ewl_scrollbar_flag_get(EWL_SCROLLBAR(s->vscrollbar)); - - DRETURN_INT(f, DLEVEL_STABLE); + DRETURN_INT(s->vflag, DLEVEL_STABLE); } /** @@ -273,12 +269,13 @@ */ void ewl_scrollpane_configure_cb(Ewl_Widget * w, void *ev_data, void *user_data) { - int b_width, b_height; Ewl_ScrollPane *s; int vs_width = 0; int hs_height = 0; + int b_width, b_height; int content_w, content_h; - double step; + unsigned int box_fill = EWL_FLAG_FILL_FILL; + double hstep = 1.0, vstep = 1.0; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR("w", w); @@ -294,46 +291,98 @@ /* * Determine the space used by the contents. */ - content_w = CURRENT_W(w) - vs_width; - content_h = CURRENT_H(w) - hs_height; + content_w = CURRENT_W(w); + content_h = CURRENT_H(w); + + /* + * FIXME: This is exposing box internals, should probably just make a + * dumb box for the scrollpane. + * Force the box to recalculate preferred size to work around children + * with shrink fill policies. + */ + ewl_container_largest_prefer(EWL_CONTAINER(s->box), + EWL_ORIENTATION_HORIZONTAL); + ewl_container_sum_prefer(EWL_CONTAINER(s->box), + EWL_ORIENTATION_VERTICAL); /* - * A rare case where we need to know the preferred size over the - * minimum size. + * Get the preferred size of contents to scroll correctly. */ b_width = ewl_object_preferred_w_get(EWL_OBJECT(s->box)); b_height = ewl_object_preferred_h_get(EWL_OBJECT(s->box)); /* - * Adjust the scrollbar internal stepping to match the contents. + * Calculate initial steps. */ - if (content_w < b_width) { - double val; + if (content_w < b_width) + hstep = (double)content_w / (double)b_width; + if (content_h < b_height) + vstep = (double)content_h / (double)b_height; - val = ewl_scrollbar_value_get(EWL_SCROLLBAR(s->hscrollbar)); - step = (double)content_w / (double)b_width; - b_width = (int)(val * (double)(b_width - content_w)); - } + /* + * Determine visibility of scrollbars based on the flags. + */ + if (s->hflag == EWL_SCROLLPANE_FLAG_NONE || + (hstep < 1.0 && + s->hflag == EWL_SCROLLPANE_FLAG_AUTO_VISIBLE)) + ewl_widget_show(s->hscrollbar); else { - step = 1.0; - b_width = 0; + box_fill |= EWL_FLAG_FILL_HSHRINK; + ewl_widget_hide(s->hscrollbar); } - ewl_scrollbar_step_set(EWL_SCROLLBAR(s->hscrollbar), step); + if (s->vflag == EWL_SCROLLPANE_FLAG_NONE || + (vstep < 1.0 && + s->vflag == EWL_SCROLLPANE_FLAG_AUTO_VISIBLE)) + ewl_widget_show(s->vscrollbar); + else { + box_fill |= EWL_FLAG_FILL_VSHRINK; + ewl_widget_hide(s->vscrollbar); + } - if (content_h < b_height) { - double val; - val = ewl_scrollbar_value_get(EWL_SCROLLBAR(s->vscrollbar)); - step = (double)content_h / (double)b_height; - b_height= (int)(val * (double)(b_height - content_h)); + /* + * Adjust the step and width dependant on scrollbar visibility. + */ + if (VISIBLE(s->hscrollbar)) { + content_w -= vs_width; + if (content_h < b_height) + vstep = (double)content_h / (double)b_height; } - else { - step = 1.0; - b_height = 0; + + if (VISIBLE(s->vscrollbar)) { + content_w -= vs_width; + if (content_w < b_width) + hstep = (double)content_w / (double)b_width; } - ewl_scrollbar_step_set(EWL_SCROLLBAR(s->vscrollbar), step); + /* + * Ensure the step is not negative. + */ + if (hstep == 1.0) + b_width = content_w; + + if (vstep == 1.0) + b_height = content_h; + + /* + * Calcuate the offset for the box position + */ + b_width = (int)(ewl_scrollbar_value_get(EWL_SCROLLBAR(s->hscrollbar)) * + (double)(b_width - content_w)); + b_height = (int)(ewl_scrollbar_value_get(EWL_SCROLLBAR(s->vscrollbar)) * + (double)(b_height - content_h)); + + /* + * Assign the step values to the scrollbars to adjust scale. + */ + ewl_scrollbar_step_set(EWL_SCROLLBAR(s->hscrollbar), hstep); + ewl_scrollbar_step_set(EWL_SCROLLBAR(s->vscrollbar), vstep); + + /* + * Set the fill policy on the box based on scrollbars visible. + */ + ewl_object_fill_policy_set(EWL_OBJECT(s->box), box_fill); /* * Position the horizontal scrollbar. @@ -361,6 +410,11 @@ CURRENT_Y(w) - b_height, content_w + b_width, content_h + b_height); + /* + * Reset the default fill policy on the box to get updated sizes.. + */ + ewl_object_fill_policy_set(EWL_OBJECT(s->box), EWL_FLAG_FILL_FILL); + DLEAVE_FUNCTION(DLEVEL_STABLE); } =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_scrollpane.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -3 -r1.15 -r1.16 --- ewl_scrollpane.h 18 Aug 2004 04:13:38 -0000 1.15 +++ ewl_scrollpane.h 3 Feb 2005 15:30:57 -0000 1.16 @@ -33,24 +33,26 @@ */ struct Ewl_ScrollPane { - Ewl_Container container; /**< Inherit from Ewl_Container */ + Ewl_Container container; /**< Inherit from Ewl_Container */ - Ewl_Widget *overlay; /**< The area displaying the enclosed widget */ - Ewl_Widget *box; /**< The area laying out enclosed widget */ - Ewl_Widget *hscrollbar; /**< Horizontal scrollbar */ - Ewl_Widget *vscrollbar; /**< Vertical scrollbar */ + Ewl_Widget *overlay; /**< Clips the enclosed widget */ + Ewl_Widget *box; /**< Lays out enclosed widget */ + Ewl_Widget *hscrollbar; /**< Horizontal scrollbar */ + Ewl_Widget *vscrollbar; /**< Vertical scrollbar */ + Ewl_ScrollPane_Flags hflag; /**< Flags for horizontal scrollbar */ + Ewl_ScrollPane_Flags vflag; /**< Flags for vertical scrollbar */ }; Ewl_Widget *ewl_scrollpane_new(void); int ewl_scrollpane_init(Ewl_ScrollPane * s); void ewl_scrollpane_hscrollbar_flag_set(Ewl_ScrollPane * s, - Ewl_ScrollBar_Flags f); + Ewl_ScrollPane_Flags f); void ewl_scrollpane_vscrollbar_flag_set(Ewl_ScrollPane * s, - Ewl_ScrollBar_Flags f); + Ewl_ScrollPane_Flags f); -Ewl_ScrollBar_Flags ewl_scrollpane_hscrollbar_flag_get(Ewl_ScrollPane * s); -Ewl_ScrollBar_Flags ewl_scrollpane_vscrollbar_flag_get(Ewl_ScrollPane * s); +Ewl_ScrollPane_Flags ewl_scrollpane_hscrollbar_flag_get(Ewl_ScrollPane * s); +Ewl_ScrollPane_Flags ewl_scrollpane_vscrollbar_flag_get(Ewl_ScrollPane * s); double ewl_scrollpane_hscrollbar_value_get(Ewl_ScrollPane *s); double ewl_scrollpane_vscrollbar_value_get(Ewl_ScrollPane *s); @@ -66,6 +68,8 @@ */ void ewl_scrollpane_configure_cb(Ewl_Widget * w, void *ev_data, void *user_data); +void ewl_scrollpane_box_configure_cb(Ewl_Widget * w, void *ev_data, + void *user_data); void ewl_scrollpane_hscroll_cb(Ewl_Widget * w, void *ev_data, void *user_data); void ewl_scrollpane_vscroll_cb(Ewl_Widget * w, void *ev_data, ------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs