# text-canvas.api
# Compiled by:
#
src/lib/x-kit/widget/xkit-widget.sublibstipulate
include package threadkit; # threadkit is from
src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.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 Text_Canvas {
Text_Canvas;
#
# A text canvas is a proto-widget
# for drawing text.
make_text_canvas
:
{
window: xc::Window,
size: g2d::Size,
font: xc::Font,
#
foreground: Null_Or( xc::Color_Spec ),
background: Null_Or( xc::Color_Spec )
}
->
Text_Canvas;
clear: Text_Canvas -> Void;
#
# Clear a canvas to its background color.
Typeball;
#
# Specifies canvas, font, color, etc. for writing text.
Typeball_Val
= TBV_FONT xc::Font # Font.
| TBV_LINEHEIGHT Int
# Total height of line.
| TBV_ASCENT Int
# Height of line above baseline.
| TBV_UNDERLINE Bool
# Underline mode.
#
| TBV_FOREGROUND xc::Color_Spec
# Foreground (text) color.
| TBV_BACKGROUND xc::Color_Spec
# Background color.
| TBV_UNDERGRND xc::Color_Spec
# Color of underline.
;
make_typeball
:
(Text_Canvas, List( Typeball_Val ))
->
Typeball;
#
# Create a new typeball.
default_typeball
:
Text_Canvas -> Typeball;
#
# Return the default typeball for the canvas.
copy_typeball
:
(Typeball, List( Typeball_Val ))
->
Typeball;
#
# Copy a typeball, updating some traits.
Text_Elem
#
= TEXT { tb: Typeball,
text: String
}
| FILL { tb: Typeball,
chr_wid: Int,
pix_wid: Int
}
;
pix_width_of: Text_Elem -> Int;
#
# Return the width (in pixels) of a text element.
chr_width_of
:
Text_Elem -> Int;
#
# Return the width (in characters)
# of a text element.
text_width: Typeball -> String -> Int;
#
# Return the width of a text string
# using the given typeball.
substr: (Text_Elem, Int, Int) -> Text_Elem;
#
# Return the substring of a text element.
font_of: Typeball -> xc::Font;
#
# Return the font of the typeball.
blt: Text_Canvas
->
{ to_pos: g2d::Point,
from_box: g2d::Box
}
->
Mailop( List( g2d::Box ) );
#
# Do a copy_blt on the canvas.
clear_box: Text_Canvas -> g2d::Box -> Void;
#
# Clear the specified rectangle
# to the background color.
draw: { at: g2d::Point, elems: List( Text_Elem ) }
->
Void;
draw_text: Typeball -> { at: g2d::Point, text: String } -> Void;
draw_fill: Typeball -> { at: g2d::Point, wid: Int } -> Void;
/**
# Cursors
enum text_cursor
= NoCursor
| BoxCursor of ??
| OutlineCursor of ??
| CaretCursor of ??
| BarCursor of ??
| XtermCursor of ??
| GlyphCursor of ??
my setCursor: (text_canvas * text_cursor) -> Void
# set the type of the cursor
my moveCursor: (text_canvas * char_coord) -> Void
# set the current cursor position
my cursorOn: text_canvas -> Void
# enable display of the text cursor
my cursorOff: text_canvas -> Void
# Disable display of the text cursor
**/
}; # api Text_Canvas
end;