interface canvas : widget {
canvas(char *p, char* options="");
canvas(widget* w, char *p, char* options="");
void tag(int id, char* tag);
char* tags(int id);
void move(int id, int x, int y);
void move(char* id, int x, int y);
item bitmap(int x1, int y1, char* bitmap, char* options="");
item line(int x1, int y1, int x2, int y2, char* options="");
item line(char* linespec, char* options="");
item circle(int x1, int y1, int rad, char* options="");
item oval(int x1, int y1, int x2, int y2, char* options="");
item polygon(char* linespec, char* options="");
item rectangle(int x1, int y1, int x2, int y2, char* options="");
item text(int x1, int y1, char* txt, char* options="");
item window(int x1, int y1, char* win, char* options="");
item window(int x1, int y1, widget* win, char* options="");
item current();
item overlapping(int x, int y);
itemconfigure(int it, char* options);
itemconfigure(char* tag, char* options);
itembind(int it, char* s, binding* a, char* args = "" );
itembind(char* tag, char* s, binding* a, char* args = "" );
void postscript(char* file, char* options="");
protected:
install(binding*, char* args);
};
slide: The canvas class
Currently, the graphic items bitmap, line,
oval, polygon and rectangle may created
and, in addition, text items and window items consisting
of a widget.
The function overlapping may be used to retrieve
the item overlapping a particular position.
In addition, the canvas class offers auxiliary functions
needed to support
the functionality provided by the item class.
The canvas may be written as Postscript to a file
with the function canvas::postscript.
Frame widgets may used to combine widgets.
A frame has no functionality or bindings of its own.
interface frame : widget {
frame(char* p, char * options = "");
frame(widget* w, char* p, char * options = "");
};
slide: The frame class
The frame widget class has the toplevel
and menubar as subclasses.
The toplevel widget is used when the widget
must be independently mapped to the screen.
The menubar widget is used as a special
frame to collect button widgets including menubutton
widgets.
The scrollbar allows the user to scroll
through widgets
that are only partly displayed.
interface scrollbar : widget {
scrollbar(char* p, char* options = "");
scrollbar(widget* w, char* p, char* options = "");
void orient(char* opts="vertical"); // orientation
xview(widget* w); // widget to scroll
yview(widget* w); // widget to scroll
};
slide: The scrollbar class
The default orientation of a scrollbar is vertical.
A scrollbar must be explicitly attached to a widget w
by calling the scrollbar::yview functions for
vertical scrollbars and scrollbar::xview for
horizontal scrollbars.
To obtain the proper geometrical layout, the
scrollbar and the widget it controls must
usually be packed in a frame.
The listbox widget is used to allow the
user to select an item from a list of
alternatives.
interface listbox : widget {
listbox(char* p, char* options = "");
listbox(widget* w, char* p, char* options = "");
void insert(char* s);
char* get(int d); // entry with index d
void singleselect();
protected:
install(binding*, char* args);
};
slide: The listbox class
The listbox may be filled by using insert.
When a handler is attached to the widget, it
is activated when the user double clicks
on an item.
The selected entry is passed as an additional parameter
to the handler.
The entry may also be obtained by either
kit::selection or listbox::get.
An entry widget may be used to display
text or allow the user to type a short
text.
interface entry : widget {
entry(char* p, char* options = "");
entry(widget* w,char* p, char* options = "");
void insert(char* s); // insert text
char* get(); // to get the text
protected:
install(binding*, char* args);
};
slide: The entry class
When a handler is attached
to the entry widget it is activated
whenever the user double clicks on the widget
or presses the return key.
The contents of the entry are added as an argument
when calling the handler.
The hypertext widget may be used to display
text with embedded Tcl code.
interface hypertext : widget {
hypertext(char* p, char* options = "");
hypertext(widget* w, char* p, char* options = "");
void file(char* f); // to read in hypertext file
};
slide: The hypertext class
Apart from the standard constructors,
it offers the function file to read in a hypertext file.
Such a hypertext file allows to embed widgets
in the text by inserting them in escape sequences.
intro
Tcl/Tk
programs
handler actions to events
widgets
graphics
appendix