## widget-base.api
#
# Definitions for basic widget types.
# Compiled by:
#
src/lib/x-kit/widget/xkit-widget.sublib# This api is implemented in:
#
src/lib/x-kit/widget/old/basic/widget-base.pkgstipulate
include package threadkit; # threadkit is from
src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.pkg #
package si = shade_imp_old; # shade _imp_old is from
src/lib/x-kit/widget/old/lib/shade-imp-old.pkg package xc = xclient; # xclient is from
src/lib/x-kit/xclient/xclient.pkg package g2d= geometry2d; # geometry2d is from
src/lib/std/2d/geometry2d.pkgherein
api Widget_Base {
Shades = si::Shades;
# Size Preferences
# ================
#
# Motivating example: We would like
# to allow a text editor window holding
# text in a fixed-with font to change
# size in units of one character width.
# To do this, we need a language for
# communicating such constraints from
# the leaf widgets which desire them
# to the compound widgets which manage
# their sizes.
#
# Our Int_Preference type provides a
# mechanism for expressing such a constraint
# upon the width-in-pixels or height-in-pixels
# of a sub-window.
#
# Example, if our characters are eight pixels wide
# and we want to allow two blank pixels on each
# side for a total of four pixels of padding,
# and to allow the text edit window to vary in
# width from 24 to 132 chars with a preferred
# width of 80 characters, we would specify a
# width constraint of
#
# INT_PREFERENCE
# { start_at => 4, # Total pixels of padding.
# step_by => 8, # Pixels per character.
# #
# min_steps => 24, # Minimum width in characters.
# max_steps => THE 132, # NULL would set no maximum.
# best_steps => 80 # Preferred width in characters.
# };
#
exception BAD_STEP;
#
Int_Preference
=
INT_PREFERENCE
{ start_at: Int, # Should be non-negative.
step_by: Int, # Should be positive. (Because X does not allow width-zero or height-zero windows.)
#
min_steps: Int, # Should be positive.
max_steps: Null_Or(Int), # Should be positive or NULL.
best_steps: Int # Should be positive.
};
# Specify minimum, maximum and preferred
# values for both widget height and width
# in pixels. This is just one Int_Preference
# each for width and height.
#
Widget_Size_Preference;
make_widget_size_preference
:
{ col_preference: Int_Preference, # Width in pixels.
row_preference: Int_Preference # Height in pixels.
}
->
Widget_Size_Preference;
tight_preference: Int -> Int_Preference; # Fix value to a specific integer.
loose_preference: Int -> Int_Preference; # Allow value to be any non-negative integer.
preferred_length: Int_Preference -> Int;
minimum_length: Int_Preference -> Int;
maximum_length: Int_Preference -> Null_Or(Int);
make_tight_size_preference: (Int, Int) -> Widget_Size_Preference;
is_between_length_limits: (Int_Preference, Int) -> Bool;
is_within_size_limits: (Widget_Size_Preference, g2d::Size) -> Bool;
Window_Args;
make_child_window
:
(xc::Window, g2d::Box, Window_Args)
->
xc::Window;
#
# Create a subwindow of a given window,
# of a given size, in a given relative
# position. Raises BAD_ARG if any of
# the box location or size values are
# zero or negative:
wrap_queue: Mailop(X) -> Mailop(X);
#
# Wrap a queue around given input mailop.
# This is useful for a parent widget which
# needs to remain responsive to its child
# (to the extent of accepting mail) while
# otherwise occupied. The queue thread
# will accept the mail on its behalf and
# queue it up for later processing:
};
end;
## COPYRIGHT (c) 1991 by AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.