123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- class IUP_FLAT_SCROLL_BOX
- -- Creates a native container that allows its child to be scrolled. It inherits
- -- from IUP_CANVAS. The difference from IUP_SCROLL_BOX is that its scrollbars
- -- are drawn.
- --
- -- The box allows the application to create a virtual space for the dialog that
- -- is actually larger than the visible area. The current size of the box
- -- defines the visible area. The natural size of the child (and its children)
- -- defines the virtual space size.
- --
- -- So the IUP_FLAT_SCROLL_BOX does not depend on its child size or expansion,
- -- and its natural size is always 0x0, except for the first time when it
- -- expands to the child natural size.
- --
- -- The user can move the box contents by dragging the background. Also the
- -- mouse wheel scrolls the contents vertically.
- --
- -- The box can be created with no elements and be dynamic filled using "append"
- -- or "insert".
- inherit
- IUP_CANVAS
- redefine
- set_rgb_background_color,
- set_border,
- set_can_focus,
- set_scroll_bar,
- set_wheel_drop_focus
- end
- IUP_WIDGET_CLIENTSIZE
- IUP_WIDGET_CLIENTOFFSET
- IUP_WIDGET_FLAT_SCROLL_BOX
- create {ANY}
- flat_scroll_box_empty,
- flat_scroll_box
- feature {ANY}
- -- Creation
- flat_scroll_box_empty
- -- An empty flat scroll box.
- local
- a_flat_scroll_box, p: POINTER
- do
- a_flat_scroll_box := int_flat_scroll_box (p)
- set_widget(a_flat_scroll_box)
- end
- flat_scroll_box (child: IUP_WIDGET)
- -- Create a flat scroll box with the child.
- --
- -- child: Identifier of an interface element which will receive the flat
- -- scroll box around.
- local
- a_flat_scroll_box: POINTER
- do
- a_flat_scroll_box := int_flat_scroll_box (child.widget)
- set_widget(a_flat_scroll_box)
- end
- -- Redefinitions
- set_rgb_background_color (red: INTEGER; green: INTEGER; blue: INTEGER)
- -- Will always use the background color of the native parent.
- do
- Precursor (red, green, blue)
- end
- set_border (state: BOOLEAN)
- -- (creation only): it is always "False".
- do
- Precursor (state)
- end
- set_can_focus (state: BOOLEAN)
- -- (creation only) (non inheritable): enables the focus traversal of the
- -- control. In Windows the canvas will respect CANFOCUS differently to
- -- some other controls. Default: False.
- do
- Precursor (state)
- end
- -- Attributes
- set_canvas_box (state: BOOLEAN)
- -- (non inheritable): enable the behavior of a canvas box instead of a
- -- regular container. Default: "False".
- do
- iup_open.set_attribute(Current, "CANVASBOX", boolean_to_yesno(state))
- end
- set_child_offset (horizontal, vertical: INTEGER)
- -- Allow to specify a position offset for the child. Available for native
- -- containers only. It will not affect the natural size, and allows to
- -- position controls outside the client area. Horizontal and vertical are
- -- integer values in pixels. Default: 0x0.
- local
- str: STRING
- do
- create str.make_from_string(horizontal.out)
- str.append_string("x")
- str.append_string(vertical.out)
-
- iup_open.set_attribute(Current, "CHILDOFFSET", str)
- end
- get_child_offset: TUPLE[INTEGER, INTEGER]
- local
- offset: STRING
- do
- offset := iup_open.get_attribute(Current, "CHILDOFFSET")
- Result := components_of_size(offset)
- end
- set_layout_drag (state: BOOLEAN)
- -- (non inheritable): When the scrollbar is moved automatically update
- -- the children layout. Default: "True". If set to "False" then the
- -- layout will be updated only when the mouse drag is released.
- do
- iup_open.set_attribute(Current, "LAYOUTDRAG", boolean_to_yesno(state))
- end
- set_scroll_bar (state: BOOLEAN)
- -- Is always "False". So the IUP_CANVAS native scrollbars
- -- are hidden. See the FLATSCROLLBAR attribute bellow. YAUTOHIDE and
- -- XAUTOHIDE will be always "True".
- do
- Precursor (state)
- end
- set_wheel_drop_focus (state: BOOLEAN)
- -- If set to True when the wheel is used the focus control close any dropdown
- -- opened. The default is True.
- do
- Precursor (state)
- end
- -- Operations
- scroll_to (x, y: INTEGER)
- -- Position the scroll at the given x,y coordinates relative to the box
- -- top-left corner.
- local
- str: STRING
- do
- str := x.out
- str.append_string(",")
- str.append_string(y.out)
- iup_open.set_attribute(Current, "SCROLLTO", str)
- end
- scroll_to_top
- do
- iup_open.set_attribute(Current, "SCROLLTO", "TOP")
- end
- scroll_to_bottom
- do
- iup_open.set_attribute(Current, "SCROLLTO", "BOTTOM")
- end
-
- scroll_to_child (name: STRING)
- -- Position the scroll at the top-left corner of the given child located
- -- by its name. Use set_widget_name to associate an image to a name.
- -- The child must be contained in the Scrollbox hierarchy.
- do
- iup_open.set_attribute(Current, "SCROLLTOCHILD", name)
- end
- scroll_to_child_widget (control: IUP_WIDGET)
- -- Scroll to the given control.
- do
- iup_open.set_attribute_widget(Current, "SCROLLTOCHILD_HANDLE", control)
- end
- feature {NONE}
- -- Internals
-
- int_flat_scroll_box (wgt: POINTER): POINTER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupFlatScrollBox ($wgt);"
- end
- end
- -- The MIT License (MIT)
- -- Copyright (c) 2017, 2019, 2021 by German A. Arias
- -- Permission is hereby granted, free of charge, to any person obtaining a copy
- -- of this software and associated documentation files (the "Software"), to deal
- -- in the Software without restriction, including without limitation the rights
- -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- -- copies of the Software, and to permit persons to whom the Software is
- -- furnished to do so, subject to the following conditions:
- --
- -- The above copyright notice and this permission notice shall be included in
- -- all copies or substantial portions of the Software.
- --
- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- -- SOFTWARE.
|