package stk
Install
    
    dune-project
 Dependency
Authors
Maintainers
Sources
md5=c334ffabde8b710f1eba6699db0f601a
    
    
  sha512=7978e3f10bc196ee6177ded9ae0313a5ba65e1a74e501fbecbe5ebc216ca6ee7117deaff5bc4c414083a4a55851a81e5dedaa8d0a880ad72689b3f56f3b064f5
    
    
  doc/stk/Stk/Widget/class-widget/index.html
Class Widget.widgetSource
The base widget class. It contains methods to be called by children widgets, event if the base class does not handle child widgets.
Setting and getting property values should be done by using get_... and set_... methods. When a property has no set_... method, it should not be modified from out of the class (but can be set by inheriting classes).
inherit Stk.Object.omethod as_widget : widgetAll widgets should have a as_... method to coerce to its own class.
method coerce : widgetw#coerce returns the widget coerced to widget type.
method equal : widget -> boolWidget equality based on their unique Object.o.id.
method parent : widget optionReturns parent widget, is any.
method top_widget : widgetReturns the top widget, going up through parent widgets until the one with no parent.
method top_window : Tsdl.Sdl.window optionw#top_window returns the SDL window the widget is displayed in, if any.
Widget data
method wdata : wdata optionmethod set_wdata : wdata option -> unitGeometry
method geometry : Stk.G.tGeometry of widget, relative to its parent.
method g_inner : Stk.G.tInner geometry, relative to top-left corner of the widget. This is the rectangle used by widget after removing border widths and paddings from its allocated geometry.
w#desktop_coords ~x ~y converts the given coordinates relative to widget top-left corner to desktop coordinates.
w#to_top_window_coords ~x ~y converts the given coordinates relative to widget top-left corner to coordinates relative to top widget's top window.
Freezing and resizing
A frozen widget will not ask for rendering (but can render). This is useful when a lot of computations are performed and each may require rendering. Freezing a widget will block rendering request from children widgets, until all is ready. They unfreezing the widget will ask for its rendering.
A widget may require a resizing, i.e. ask its parent to compute its allocated geometry, typically because its size constraints changed. A widget can ignore its own requests for resizing or the ones from its children, for example when doing some updates that will need many resizings it is more performant to do one resizing when everything is computed. The Flex.flex widget uses this.
Properties
A Props.selected widget will render differently, using different background and foreground colors.
method font : Tsdl_ttf.Ttf.fontGet the SDL font from the widget properties.
method bg_color : Stk.Color.tmethod set_bg_color : Stk.Color.t -> unitProps.bg_color property.
method bg_color_selected : Stk.Color.tmethod set_bg_color_selected : Stk.Color.t -> unitProps.bg_color_selected property.
method bg_color_focused : Stk.Color.tmethod set_bg_color_focused : Stk.Color.t -> unitProps.bg_color_focused property.
method bg_color_hover : Stk.Color.tmethod set_bg_color_hover : Stk.Color.t -> unitProps.bg_color_hover property.
method fg_color : Stk.Color.tmethod set_fg_color : Stk.Color.t -> unitProps.fg_color property.
method fg_color_selected : Stk.Color.tmethod set_fg_color_selected : Stk.Color.t -> unitProps.fg_color_selected property.
method fg_color_focused : Stk.Color.tmethod set_fg_color_focused : Stk.Color.t -> unitProps.fg_color_focused property.
method fg_color_hover : Stk.Color.tmethod set_fg_color_hover : Stk.Color.t -> unitProps.fg_color_hover property.
method padding : int Stk.Props.trblmethod set_padding : int Stk.Props.trbl -> unitmethod margin : int Stk.Props.trblmethod set_margin : int Stk.Props.trbl -> unitmethod border_width : int Stk.Props.trblmethod set_border_width : int Stk.Props.trbl -> unitmethod border_color : Stk.Color.t Stk.Props.trblmethod set_border_color : Stk.Color.t Stk.Props.trbl -> unitmethod set_border_color_ : Stk.Color.t ->
  Stk.Color.t ->
  Stk.Color.t ->
  Stk.Color.t ->
  unitmethod set_border_color__ : Stk.Color.t -> unitProps.border_color property.
method border_color_selected : Stk.Color.t Stk.Props.trblmethod set_border_color_selected : Stk.Color.t Stk.Props.trbl -> unitmethod set_border_color_selected_ : Stk.Color.t ->
  Stk.Color.t ->
  Stk.Color.t ->
  Stk.Color.t ->
  unitmethod set_border_color_selected__ : Stk.Color.t -> unitProps.border_color_selected property.
method border_color_focused : Stk.Color.t Stk.Props.trblmethod set_border_color_focused : Stk.Color.t Stk.Props.trbl -> unitmethod set_border_color_focused_ : Stk.Color.t ->
  Stk.Color.t ->
  Stk.Color.t ->
  Stk.Color.t ->
  unitmethod set_border_color_focused__ : Stk.Color.t -> unitProps.border_color_focused property.
method border_color_hover : Stk.Color.t Stk.Props.trblmethod set_border_color_hover : Stk.Color.t Stk.Props.trbl -> unitmethod set_border_color_hover_ : Stk.Color.t ->
  Stk.Color.t ->
  Stk.Color.t ->
  Stk.Color.t ->
  unitmethod set_border_color_hover__ : Stk.Color.t -> unitProps.border_color_hover property.
method text_valign : Stk.Props.text_valignmethod set_text_valign : Stk.Props.text_valign -> unitProps.text_valign property.
Showing (parts of) widget
method show_rect : Stk.G.t -> unitmethod show_child_rect : Stk.G.t -> unitmethod visible_rect : Stk.G.tReturns the visible rectangle of the widget.
Returns the visible rectangle of the given child widget.
Focus
method focused_widget : widget optionw#grab_focus() make widget v tries to grab focus. The widget must be visible and sensitive, with Props.can_focus and Props.focusable set to true. The last optional argument is used internally by some widgets containing various children. Returns true if the focus could be grabbed, else false.
Misc
w#set_handle_hovering b sets handling hovering to b. Handling hovering means that mouse cursor motions are tracked to trigger Mouse_enter and Mouse_leave events. Default is to ignore hovering to avoid computations. It is used for some wigets, like menu item or buttons for which such a visual feedback is important. Mouse cursor hovering affect the background, foreground and border colors of a widget.
method bg_color_now : Stk.Color.tCurrent background color, depending on mouse hovering, Props.is_focus and Props.selected properties.
method fg_color_now : Stk.Color.tCurrent foreground color, depending on mouse hovering, Props.is_focus and Props.selected properties.
method border_color_now : Stk.Color.t Stk.Props.trblCurrent border color, depending on mouse hovering, Props.is_focus and Props.selected properties.