## widget-style.api
### "Three may keep a secret,
### if two of them are dead, "
###
### -- Ben Franklin
api Widget_Style {
type comp_name = quark::quark
type attribute_name = quark::quark
type style_name = List( comp_name )
# A style_name is a key for searching a style database. A style
# name is a non-empty list of non-null component names taken from
# the following character set: A..Z a..z 0..9 _ -
type style_view
# a style_view is a search key for finding attributes in a style.
# It consists of a name and an ordered list of aliases.
type Style
exception BAD_STYLE_NAME
my extendName: (style_name * String) -> style_name
# extend a style name by the component
my mkView: { name: style_name, aliases: List( style_name ) } -> style_view
# make a style_view from a name and list of aliases; the order of the
# list defines the search order.
my nameOfView: style_view -> style_name
# return the name part of the view
my aliasesOfView: style_view -> List( style_name )
# return the list of aliases that defines the view.
my extendView: (style_view * String) -> style_view
# extend each of the names in the view by the component
my meldViews: (style_view * style_view) -> style_view
# Concatenate two views; the first view has priority over the second.
my appendAlias: (style_view * style_name) -> style_view
my prependAlias: (style_name * style_view) -> style_view
# Add a alias to the back or front of a view
my emptyStyle: xclient::Screen -> Style
# Create an empty style
my style: Style -> Style
# Create a style that is the logical child of another style
# NOTE: we may want to distinguish between "dynamic" and "static" attributes
type attribute_spec = { attribute: attribute_name, value: String }
my addAttrs: Style -> List (style_name * List( attribute_spec ) ) -> Void
# add a list of (attribute, value) pairs to a style; this will propagate
# to any listeners.
my deleteAttr: Style -> (style_name * attribute_name) -> Void
# Delete an attribute value from a style
my mkStyle: Style -> List (style_name * List( attribute_spec ) ) -> Style
# create a new style from an existing style and a list of attribute
# value definitions. This is equivalent to (addAttrs o style).
my findAttr: Style -> (style_view * List( attribute_name) )
-> List( attribute_name * Null_Or( String ) )
# Look up the given attribute in the given style. This returns NULL,
# if the attribute is undefined. Note that the partial application of
# this function computes a list of fingers into the style database
# so that the actual searching for attributes will be faster.
enum attribute_change
= ADD_ATTRIBUTE of String
| CHANGE_ATTRIBUTE of String
| DELETE_ATTRIBUTE
my listen: Style -> (style_view * List( attribute_name ) )
-> List( attribute_name * attribute_change threadkit::event )
# express an interest in changes to an attribute in a style. This
# event will be enabled once for each change to the style that occurs
# after the event is created.
};
## COPYRIGHT (c) 1994 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.