Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Stk_xml.LayoutSourceCreating widgets from XML tree.
Functions of this module should only be used by code handling specific XML nodes, through the function provided to the XML view with the View.xmlview.set_of_node method.
type of_node = {ctx : ctx;widget : Stk.Widget.widget option;before : Stk.Widget.widget option;after : Stk.Widget.widget option;subs_handled : bool;}This structure is returned by functions called on a node.
Type of a function called to handle a node. None as result means that the function did not handle this kind of node. In this case, the default function default_of_node will handle it.
and ctx = {of_node : of_node_fun;container : Stk.Widget.widget;css_rules : Iri.t Css.S.rule_ list;root_props : Css.C.t;props : Css.C.t;font_desc : Stk.Font.font_desc;path : Xml.node list list;nodes : Doc.node list;node_count : int;item_map : Doc.node WMap.t;id_map : Doc.node Stk.Smap.t;load_resource : Iri.t ->
[ `Error of string | `None | `Ok of Ldp.Types.resource ] Lwt.t;iri : Iri.t option;base_iri : Iri.t option;}The context with the information needed to create nodes.
of_node_none ctx returns { ctx ; widget = None ; before = None ; after = None ; subs_handled = false }.
val pack :
container:Stk.Widget.widget ->
?kind:Stk.Flex.item_kind ->
Stk.Widget.widget ->
unitpack ~container widget will pack widget into container, depending on the widget type of container: by now widgets can only be packed into Stk.Flex.flex widgets. Trying to pack into a table will do nothing and an error message will be issued when trying to pack into another type of container.
The optional argument kind can be used to specify how to handle the packed widget. If no value is provided, the Stk.Flex.item_kind property is not set and its default value will be used.
pack_break container () packs a break into the container. As for pack, this functions should be called only with flex containers. Optional argument props can be used to specify properties for the Stk.Flex.break widget inserted.
Same as pack_break but inserts a Stk.Flex.space.
build_text ctx cdata creates a label widget from the given cdata and inserts it into ctx.container. If cdata is "\n" (resp. " "), a break (resp. a space) is packed into the ctx.container and no widget is returned.
build_image ctx width height props creates a Stk.Image.image widget from given width, height and props and packs it into ctx.container. The created image is returned.
image ctx ?xml iri node creates and packs an image widget from the given node, using value of "src" node attribute as image IRI. Image IRI is resolved using iri as base. If no valid image IRI is found, no widget is created. Else an image is created, using width and height if present in node attributes. The image is loaded in a Lwt.async and the newly created widget is returned through the of_node structure.
set_container_borders widget computed_css sets widget properties for border widths and colors according to computed_css.
flex_of_props computed_css creates a Stk.Flex.flex widget with properties from computed_css.
table_of_props computed_css creates a Stk.Table.table widget with properties from computed_css.
ctx_new_block ~name ctx creates a new block context from ctx. To do so, it creates a flex widget with name, which is set as container is the returned context.
default_of_node ctx node is the default function creating widgets from XML node. When the View.xmlview has no of_node function or if it returns None for an XML node, this default_of_node function will be called to handle the XML node.