Window Widget
The Window is the basic widget of Wise. It has a Ruby
part and a native part. You will never touch the native part. The Ruby part talks to the native part and allows you to do
everything with the native window that is necessary.
Window initializer
Making a window is easy enough:
Wise::Window.new(parent)
where the parent may be nil for a toplevel window or another window. This alone
does not do anything useful but pop up a window. To improve on that, there are
several options that can be passed via a hashtable to the window:
- :fg, the foreground color,
- :bg, the background color,
- :font, the font to be used,
- :border, the width of the border to be used,
- :space, the space between the border and the content,
- ...
That would look like:
require 'wise'
Window.new(parent, :fg=>Color.new(120, 160, 200), :space=>5)
Many of those options are inherited by the children of the window. This allows
you to set the background color (or background image, when implemented) of all
widgets, by just setting it in the toplevel window.
Window Layout
For layout, these extra options are available, but may or may not be used by
the layout manager. See the layout section.
- :x, :y, the position within the parent the window requests,
- :width, :height, the dimension the window requests,
Layout can be a bit weird, as some layout mamagers will be interested in
properties of the children (e.g. the default manager will look at :side for its
children).
Toplevel Window
A toplevel window is a window that has no parents and is usually managed by the
window manager. It is what a typical user would call a window.
A toplevel window has a few extra options:
- :display, the display to be used
- :dock=>true, the WM should dock the window (name may change,
because it means a dock should take the window, not the WM),
- :override=>true, the WM should ignore the window,
- :modal=>true, the window should be transient, i.e. always above
its parent,
- :map=>false, the window must remain unmapped until map()
is called,
- :title, the title of the window,
- :grab, the window should grab mouse and keyboard (typically done
by a popup, automatically, not implemented, yet),
Window methods
Now that we have window, we may want to do several things with it:
- Set the background color,
- Draw a line,
- Draw a string,
- (un)map the window,
- ...
While a window exists, call map() or unmap(). Setting
background and other fields for each widget will cause the siblings to change
their setting, too (but that's not updated on the screen immediately, yet;
enforcing a redraw will show it, though).
Some (toplevel) options can not be changed, ever: modal, dock and
override. Others may not have been implemented to change after creation.
Kero