|
|
Micro Window-Gadgets
[ news |
download |
about |
technical |
screenshots |
gadgets |
properties
]
Recent UWG happenings:
- 03/12/2006 released version 0.2.0
- 25/08/2006 released version 0.1.6
- 26/06/2006 released version 0.1.5
- 26/02/2006 released version 0.1.4
- 01/06/2005 released version 0.1.3 (still under development)
- 25/07/2004 released version 0.1.2 (still early days)
- 12/07/2004 released version 0.1.1 (in extreme development)
Micro WG is a C `version' of WG. In general, UWG is somewhat more light-weight than WG. Firstly because it's written in C and not C++. Secondly
because it does not yet provide all the features of WG. Also, it should be significantly easier to `connect' UWG to KRoC.
Why UWG ? It's now the case that there are many `widget libraries' for programmers to choose from. The traditional X11 widget libraries (X Toolkit Intrinsics), GTK,
QT, Motif, wxWindows, TK, etc.. GTK and QT are probably the most common for an average user's desktop system -- as the graphics libraries of Gnome and KDE respectively.
C++, used by WG, provides a largely type-safe environment for gadget programming -- i.e. the structure/nature of gadgets fit neatly into the C++ type (class) heirarchy.
However, C++ ultimately suffers from the same problems as some other `object-orientated' languages -- namely leaky encapsulation. When writing WG, some of the limitations
(maybe features) of C++ caused significant problems, particularly in the function-pointer department. Object-orientation is a fine model for data, but it does not work well
when `bolted-on' to sequential languages -- C++ and Java in particular. Forcing a sequential flow-of-control through something that we tried to break into objects only
leads to problems. E.g. when executing inside the method of one object, is it safe to delete another object ? -- well, only if that other object wasn't involved (and still
is involved) in the flow-of-control. And this you cannot easily tell. Furthermore, in many cases, `delete' may be substituted for any object interaction (method-call).
Also, a lot of modern GUI toolkits seem unnecessarily bloated. C++ (and other `frilly' languages) can be blamed for some of this, but not all of it. WG isn't bloated yet,
but it's not far off. UWG is therefore an attempt at a lightweight (size and speed) gadget toolkit for X11, programmed in C.
Here are the downloads for UWG. At the moment, the distribution is fairly basic, but it should work. Prior to version 0.1.6, UWG didn't really install itself anywhere. Now
it will attempt to park itself in the right places.
- uwg_prefs preferences file (for UWG 0.2.0 and later), edit as desired and copy to ~/.uwg_prefs (default included in distribution)
UWG, by default, will configure itself for a regular installation -- i.e. it expects to be installed (this is because the generated uwg_config.h contains the locations of
files which other packages can scan for). You can park it somewhere else in the usual way, for example:
bash:~/uwg-0.2.0/$ ./configure --prefix=/home/fred/uwg
bash:~/uwg-0.2.0/$ make install
Then unpack the other packages (ubuildinit, uwg-examples), configure with:
bash:~/ubuildinit-0.2.0/$ ./configure --prefix=/home/fred/uwg \
--with-uwg-config=/home/fred/uwg/include/uwg
bash:~/ubuildinit-0.2.0/$ make install
bash:~/uwg-examples-0.2.0/$ ./configure --with-uwg-config=/home/fred/uwg/include/uwg
bash:~/uwg-examples-0.2.0/$ make
One slight disadvantage to not using C++ is that the code gets uglier. The gadget types are C structures that contain the gadget's state, along with various
function-pointers for performing actions, etc. Instead of the multitude of `get/set' methods, gadgets have single `get' and `set'
methods, that use a `uwg_prop_t' parameter and var-args. As part of the gadget's state is a `UWGVisual' pointer. This is a generic visual gadget
that replaces `WGVisual' in WG. Gadget callbacks are now wrapped up in a separate structure, rather than being part of the gadget structure, e.g. `UWGButtonCB'.
Gadgets maintain a pointer to their callbacks.
The various event callbacks (e.g. `xc_paint') are still separate. However, since these are now function-pointers, gadgets can override the default behaviours of
other gadgets -- e.g. the UWGVDE gadget does this to control interactions with its children. As far as looking after children goes, WG used to maintain the visual heirarchy
of gadgets. It no longer does this. Gadgets that need to be aware of their children can use the `xc_addchild' and `xc_delchild' callbacks, invoked by
gadgets when created on them. To maintain a complete visual heirarchy, the `xc_{add,del}child' callbacks can be re-assigned as new gadgets
are created; the intervening code can then decide whether to keep the event for itself, or pass it on to the original gadget (if it has an appropriate handler).
The central-point of UWG is the `UWGXContext' virtual gadget. This abstracts a connection to an X11 server, used by the various gadgets and the application.
Unlike some other gadget toolkits, a UWG application can connect to many X servers -- if desired. This might be useful for multi-client applications -- e.g. a simple multi-user
game. However, the first aim of UWG is to provide a toolkit -- application `help' is secondary, but still considered.
The use of C and functions with variable numbers of arguments creates a number of potential pitfalls -- such as calling a var-args function with incorrect parameters, that will
most likely (and currently) result in a run-time error or undefined behaviour. The gadgets themselves will perform some checks, but mostly it is down to correct application
programming. E.g. an attempt to set a gadget property that doesn't exist is benign, but an attempt to set a property using a different type than was expected will cause serious
problems.
Fortunately, and much like WG, it is not expected that programmers write the code for creating and initialising (visual) interfaces themselves. WG uses a tool called
`buildinit' to transform HPD (heirarchial program description) files into C++ code that creates (and destroys) whole interfaces -- typically top-level windows.
UWG posesses a similar tool, but one that converts XHPD files into C code. XHPD files are `XML heirarchial program description' files, that use XML to describe
the interface. A related program, RAPP (remote applications), can already process these XHPD files usefully. Rather than generating code,
RAPP dynamically creates the described interface.
The follow shows an example of XHPD, that describes a simple button:
<gadget type="UWGBitBtn" name="button2">
<property name="geometry" value="100,32,144,40" />
<property name="hint" value="this is a hint!" />
<property name="font" value="fixed" />
<property name="caption" value="more click!" />
<property name="style" value="popup" />
<property name="img-up" value="/usr/include/X11/pixmaps/screen.xpm" />
<property set="cpref" />
<action name="on_click">
<property name="shadow" />
<property source="mylabel" name="font" />
</action>
</gadget>
This particular example is designed for RAPP -- where the contents of the `<action>' tag are properties to be reported with the event. For producing C code to create
interfaces, more useful would be application code. For example:
<action name="on_click">
<![CDATA[
]]>
</action>
<update> and <command> blocks are interpreted by both "ubuildinit" and RAPP. For example:
<action name="on_create">
<command name="add_item">
<arg value="UWGPanel" />
</command>
</action>
Here are some screenshots of UWG. Note that more will appear as development progresses..
 |
 |
 |
| UWG testapp screenshot |
another (ubuildinit-generated) XHPD example |
initial VDE efforts in action, XHPD file |
Here is the current list of supported gadgets. There is an on-going process of converting WG gadgets into UWG gadgets -- it's
not too difficult, but is quite time consuming. Gadgets will be added to this list as they are dealt with. See the WG gadget-list
for `missing' content.
| Gadget | Version | State | Description |
| UWGBitBtn | 0.9 | nearly there | Button with an image |
| UWGButton | 0.9 | nearly there | Basic button |
| UWGCanvas | 0.1 | just starting | General canvas gadget |
| UWGCheckBox | 0.9 | nearly there | Basic check-box |
| UWGChildProcess | 0.9 | nearly there | Child-process gadget (piped stdin/stdout) |
| UWGCMessageWin | 0.9 | nearly there | Colour-capable message window |
| UWGComboBox | 0.1 | in progress | Drop-down combo box |
| UWGContainer | 0.9 | nearly there | Container gadget (e.g. for tab pages) |
| UWGCrypto | 0.9 | nearly there | Cryptographic key handling (uses libgcrypt) |
| UWGDave | 0.9 | nearly there | Dave gadget |
| UWGEdit | 0.9 | in progress | Edit box |
| UWGFred | 0.9 | nearly there | Fred gadget |
| UWGGroupBox | 0.9 | nearly there | Framed/captioned box |
| UWGIcon | 0.1 | in progress | Icon gadget (with label) |
| UWGImage | 0.9 | nearly there | Image gadget |
| UWGIniFile | 0.9 | deprecated | .ini-file style reader/writer (deprecated in favour of UWGSpecsFile) |
| UWGIDGramSvr | 0.1 | in progress | UDP socket server |
| UWGISockCli | 0.9 | in progress | TCP socket client |
| UWGISockSvr | 0.1 | in progress | TCP socket server |
| UWGKarim | 0.9 | nearly there | Karim gadget |
| UWGLabel | 0.9 | nearly there | Basic label |
| UWGLayout | 0.1 | in progress | Automatic layout gadget |
| UWGLcarsButton | 0.9 | nearly there | Star-trek style button |
| UWGLcarsCheckBox | 0.9 | nearly there | Star-trek style check-box |
| UWGLcarsContainer | 0.9 | nearly there | Star-trek style container, to fit in the panel |
| UWGLcarsEButton | 0.9 | in progress | Star-trek style bigger button |
| UWGLcarsMeter | 0.9 | nearly there | Star-trek style gauge/meter, fits in the panel |
| UWGLcarsPanel | 0.9 | in progress | Star-trek style panel |
| UWGLcarsSection | 0.9 | in progress | Star-trek style section title (along the top) |
| UWGLcarsSplit | 0.1 | queued | Star-trek style splitter |
| UWGLcarsTButton | 0.2 | in progress | Star-trek style tab buttons |
| UWGLcarsTitle | 0.9 | in progress | Star-trek style title (stick out from the side type) |
| UWGListBox | 0.9 | in progress | Basic list-box |
| UWGMainMenu | 0.9 | nearly there | Main-menu gadget |
| UWGMitShm | 0.2 | in progress | MIT-SHM gadget |
| UWGMVLayout | 0.9 | nearly there | Movement (drag-around) layout manager |
| UWGPanel | 0.9 | nearly there | Basic panel |
| UWGPaul | 0.9 | nearly there | Paul gadget |
| UWGPicture | 0.1 | just starting | Picture gadget |
| UWGPopup | 0.5 | in progress | Popup menu |
| UWGPropSet | 0.1 | in progress | Gadget `property-set' wrapper |
| UWGRadioBtn | 0.1 | just starting | One-of-many selection buttons |
| UWGScrollBar | 0.9 | nearly there | Horizontal/vertical scroll-bar |
| UWGSpecsFile | 0.1 | in progress | "specs" file reader/writer |
| UWGSpeedBtn | 0.9 | nearly there | Image-only button |
| UWGSteve | 0.9 | nearly there | Steve gadget |
| UWGStringTree | 0.2 | in progress | Hashed tree of strings (nodes + leaves) |
| UWGSDLAudio | 0.1 | just starting | Non-visual gadget providing sound fuctionality via SDL |
| UWGTabTops | 0.9 | nearly there | Tab-tops |
| UWGTiledArena | 0.1 | just starting | Tiled arena gadget |
| UWGTiledArenaMap | 0.1 | just starting | Minature map for a UWGTiledArena |
| UWGTimer | 0.1 | just starting | Timer gadget |
| UWGVDE | 0.1 | in progress | `Visual Design Environment' from WGBuilder |
| UWGVGraph | 0.2 | in progress | Visual graph (nodes and edges) |
| UWGWindow | 0.9 | nearly there | Top-level window |
| UWGXMLParser | 0.2 | in progress | XML parser gadget |
Gadgets typically have `get_property' and `set_property' ``methods'' (function-pointers). These take a property constant and some values. `get_property'
always takes a pointer to the type that `set_property' takes -- and if a pointer is `returned', it is the gadget's own, not a copy (e.g. string properties).
Here is the current list of properties; the `Property' is a C enumeration (as a type called `uwg_prop_t').
| Property | Type(s) | Description |
| PROP_ACTIVE_BACKGROUND | unsigned long pixel | active background color value |
| PROP_ACTIVE_BACKGROUND_STR | char *color | active background color string |
| PROP_ALERT_COLOR | unsigned long pixel | `alert' pixel value |
| PROP_ALERT_COLOR_STR | char *color | `alert' colour string |
| PROP_ALIGN_TO_GRID | int atg | truth value indicating whether child gadgets should be aligned to the parent grid |
| PROP_ALIGNMENT | uwg_align_t align | text alignment |
| PROP_ALLOW_TYPE | int allow | truth value indicating whether a gadget that accepts text should allow typing |
| PROP_ANGLES | int count, int a1, int a2, ... | angles for certain gadgets |
| PROP_ANGLES_STR | char *str | comma-separated list of angles for certain gadgets |
| PROP_APP_NAME | char *str | application name (for the window-manager) |
| PROP_APP_CLASS | char *str | application class (for the window-manager) |
| PROP_ARGS | int count, char *arg1, char *arg2, ... | arguments for certain gadgets |
| PROP_ARGS_STR | char *str | comma-separated list of arguments for certain gadgets |
| PROP_BACKGROUND | unsigned long pixel | background pixel value |
| PROP_BACKGROUND_STR | char *color | background colour string |
| PROP_BORDER_PIXEL | unsigned long pixel | border pixel value |
| PROP_BORDER_PIXEL_STR | char *color | border colour string |
| PROP_BORDER_WIDTH | int bwidth | border width |
| PROP_BTNSTYLE | uwg_btnstyle_t style | button style |
| PROP_CAPTION | char *str | caption text |
| PROP_COPY_FROM_PARENT | int cfp | truth value indicating whether child gadgets should inherit properties from their parent |
| PROP_DIRECTION | int dir | direction value for certain gadgets/effects |
| PROP_DROP_IMAGE | int drop | truth value indicating whether images on buttons (and others) should move when the button is pressed |
| PROP_ENABLED | int visible | truth value indicating whether the gadget is enabled |
| PROP_EXPOSURES | int expose | truth value indicating whether a gadget should generate exposure events (if it doesn't by default) |
| PROP_FOCUS_GADGET | UWGVisual *gadget | focused gadget within a window |
| PROP_FOCUSED | int focused | truth value indicating whether a gadget has keyboard focus |
| PROP_FONT | char *fname | font |
| PROP_FOREGROUND | unsigned long pixel | foreground pixel value |
| PROP_FOREGROUND_STR | char *color | foreground colour string |
| PROP_GEOM_X | int x | X position of the gadget (parent relative) |
| PROP_GEOM_Y | int y | Y position of the gadget (parent relative) |
| PROP_GEOM_WIDTH | int width | width of the gadget |
| PROP_GEOM_HEIGHT | int height | height of the gadget |
| PROP_GEOMETRY | int x, y, width, height | geometry of the gadget |
| PROP_HIGHLIGHT | unsigned long pixel | 3D highlight pixel value |
| PROP_HIGHLIGHT_STR | char *color | 3D highlight colour string |
| PROP_HINT | char *hint | popup `hint' text |
| PROP_HINT_BACKGROUND | unsigned long pixel | hint background pixel value |
| PROP_HINT_BACKGROUND_STR | char *color | hint background colour string |
| PROP_HINT_DELAY | int secs, usecs | delay before a gadget hint is displayed |
| PROP_HINT_FONT | char *font | font used for gadget hints |
| PROP_HINT_FOREGROUND | unsigned long pixel | hint foreground pixel value |
| PROP_HINT_FOREGROUND_STR | char *color | hint foreground colour string |
| PROP_HOST | char *hostname | host-name (for socket gadgets, etc.) |
| PROP_ICON_NAME | char *str | icon-name text (for the window-manager) |
| PROP_IECOLOR | unsigned long pixel | `interesting extra' pixel value, generally used for highlighting on mouse-over |
| PROP_IECOLOR_STR | char *color | `interesting extra' colour string |
| PROP_IMG_DISABLED_FILE | char *filename | filename of the image used for the `disabled' state on some gadgets |
| PROP_IMG_DOWN_FILE | char *filename | filename of the image used for the `down' state on some gadgets |
| PROP_IMG_OFF_FILE | char *filename | filename of the image used for the `off' state on some gadgets |
| PROP_IMG_UP_FILE | char *filename | filename of the image used for the `up' state on some gadgets (also the default image) |
| PROP_INACTIVE_BACKGROUND | unsigned long pixel | inactive background color value |
| PROP_INACTIVE_BACKGROUND_STR | char *color | inactive background color string |
| PROP_INACTIVE_FOREGROUND | unsigned long pixel | inactive foreground color value |
| PROP_INACTIVE_FOREGROUND_STR | char *color | inactive foreground color string |
| PROP_INDENT | int indent | `indentation' for 3D effect |
| PROP_INVALID | | generic invalid property |
| PROP_KEYBTN | int button | button value for a click event when the keyboard is used (on the focused gadget) |
| PROP_LAYOUT | uwg_layout_t layout | layout of gadget (for child gadgets of a layout) |
| PROP_LCARS1 | unsigned long pixel | pixel value for star-trek style lcars-gadgets |
| PROP_LCARS1_STR | char *str | colour string for start-trek style lcars-gadgets |
| PROP_LCARS2 | unsigned long pixel | pixel value for star-trek style lcars-gadgets |
| PROP_LCARS2_STR | char *str | colour string for start-trek style lcars-gadgets |
| PROP_LCARS3 | unsigned long pixel | pixel value for star-trek style lcars-gadgets |
| PROP_LCARS3_STR | char *str | colour string for start-trek style lcars-gadgets |
| PROP_LCARS4 | unsigned long pixel | pixel value for star-trek style lcars-gadgets |
| PROP_LCARS4_STR | char *str | colour string for start-trek style lcars-gadgets |
| PROP_LEADING_SPACE | int pixels | leading space for some gadgets |
| PROP_LIMIT_MAX | int max | maximum limit for some gadgets |
| PROP_LIMIT_MIN | int min | minimum limit for some gadgets |
| PROP_LIMITS | int min, max | minimum and maximum limits for some gadgets |
| PROP_LOCK_TO_PARENT | int ltp | truth value indicating whether child gadgets should be wholly inside their parent window |
| PROP_MASK_DISABLED_FILE | char *filename | filename of the mask used for the `disabled' state on some gadgets |
| PROP_MASK_DOWN_FILE | char *filename | filename of the mask used for the `down' state on some gadgets |
| PROP_MASK_OFF_FILE | char *filename | filename of the mask used for the `off' state on some gadgets |
| PROP_MASK_UP_FILE | char *filename | filename of the mask used for the `up' state on some gadgets (also the default mask) |
| PROP_MAX_SIZE | int max | maximum text-entry size |
| PROP_MOUSE_MOTION | int motion | whether or not the gadget reports mouse movements |
| PROP_NAMED | char *propname, ... | non-standard named properties |
| PROP_ORDER | uwg_order_t order | ordering of items |
| PROP_PARENT | UWGVisual *gadget | parent gadget |
| PROP_PASSWORD_CHAR | int ch | character to be displayed instead of text |
| PROP_PATH | char *path | path (file or directory) for certain gadgets |
| PROP_PORT | int port | port (for socket gadgets, etc.) |
| PROP_POSITION | uwg_winpos_t pos | window positioning |
| PROP_SAVE_UNDER | int save_under | truth value indicating whether the contents underneath a window should be saved |
| PROP_SCROLLER | UWGScrollBar *scroller | associated scrollbar gadget |
| PROP_SCROLLTYPE | uwg_scroll_t stype | scroller type |
| PROP_SEL_BACKGROUND | unsigned long pixel | selected background pixel value |
| PROP_SEL_BACKGROUND_STR | char *color | selected background colour string |
| PROP_SEL_FOREGROUND | unsigned long pixel | selected foreground pixel value |
| PROP_SEL_FOREGROUND_STR | char *color | selected foreground colour string |
| PROP_SEL_INDEX | int idx | index of selected item |
| PROP_SEL_MODE | uwg_sel_t | selection mode |
| PROP_SHADOW | unsigned long pixel | 3D shadow pixel value |
| PROP_SHADOW_STR | char *color | 3D shadow colour string |
| PROP_SHOW_BOUNDARY | int show | shows boundaries on certain gadgets (vde, layout) |
| PROP_SIZE | int size | size value for certain gadgets/effects |
| PROP_SPLIT_DATA | int split | number of colums |
| PROP_STATUS | int status | status for certain gadgets |
| PROP_STEPPING | int step | increment/decrement for some gadgets |
| PROP_STYLE | uwg_winstyle_t style | window style |
| PROP_SWALLOW_KEYS | int skeys | truth value indicating whether the gadget swallows all keystrokes when focused |
| PROP_TAB_STOP | int ts | tab-stop ordering (for switching focus) |
| PROP_TENTRY | unsigned long pixel | background pixel value for text-entry boxes |
| PROP_TENTRY_STR | char *color | background colour string for text-entry boxes |
| PROP_TEXT | char *str | text-entry text |
| PROP_TIMEOUT | int timeout | timeout in milli-seconds |
| PROP_TOP_INDEX | int tidx | index of first displayed item |
| PROP_WARNING_COLOR | unsigned long pixel | `warning' pixel value |
| PROP_WARNING_COLOR_STR | char *color | `warning' colour string |
| PROP_VALUE | int val | value for some gadgets |
| PROP_VISIBLE | int visible | truth value indicating whether the gadget is visible |
| PROP_VISIBLE_VALUE | int vval | visible `value-range' for some gadgets |
UWG has various enumerated types for certain properties. In WG, these sorts of things were pre-processor `#define's.
| Constant/Type | Description |
| uwg_align_t | text alignment |
| ALIGN_LEFT | left aligned |
| ALIGN_CENTER | centre aligned |
| ALIGN_RIGHT | right aligned |
| uwg_btnstyle_t | bustrongon style |
| BUTTON_NORMAL | ordinary style bustrongon |
| BUTTON_POPUP | popup style bustrongon |
| uwg_cpref_t | preferable colours |
| CPREF_FOREGROUND | preferred foreground colour |
| CPREF_BACKGROUND | preferred background colour |
| CPREF_HIGHLIGHT | preferred highlight colour |
| CPREF_SHADOW | preferred shadow colour |
| CPREF_EXTRA | preferred `extra' colour |
| CPREF_TENTRY | preferred text-entry background colour |
| CPREF_SELBACK | preferred selected background colour |
| CPREF_SELFORE | preferred selected foreground colour |
| uwg_layout_t | gadget layout |
| LAYOUT_NONE | fixed layout |
| LAYOUT_FLOAT_LEFT | gadget floats left |
| LAYOUT_FLOAT_RIGHT | gadget floats right |
| LAYOUT_FLOAT_TOP | gadget floats towards the top |
| LAYOUT_FLOAT_BOT | gadget floats towards the bottom |
| LAYOUT_STRETCH_HORIZ | gadget stretches horizontally |
| LAYOUT_STRETCH_VERT | gadget stretches vertically |
| uwg_order_t | item ordering |
| ORDER_NONE | use created order |
| ORDER_ALPHA_ASCEND | order alphabetically, ascending |
| ORDER_ALPHA_DESCEND | order alphabetically, descending |
| uwg_sel_t | selection mode |
| SELECT_NONE | do not allow any selection |
| SELECT_ONE | allow one item to be selected |
| SELECT_MANY | allow many items to be selected |
| uwg_winstyle_t | window style |
| WINDOW_BORDER | non-resizable with border |
| WINDOW_BORDERLESS | non-resizable without border |
| WINDOW_SIZEABLE | resizable with border |
| uwg_winpos_t | window position |
| WINPOS_EXPLICIT | use given position |
| WINPOS_CENTER | place in the center of the screen |
| WINPOS_USER | window-manager/user to place the window |
| uwg_open_t | open-mode constants |
| OPEN_READ | open read-only |
| OPEN_WRITE | open write-only |
| OPEN_RW | open read-write |
| uwg_sel_t | selection style constants |
| SELECT_NONE | nothing allowed to be selected |
| SELECT_ONE | allow a single item to be selected |
| SELECT_MANY | allow multiple items to be selected |
| uwg_scroll_t | scrollbar-style constants |
| SCROLL_HORIZ | horizontal scroll-bar |
| SCROLL_VERT | vertical scroll-bar |
| uwg_order_t | item ordering constants |
| ORDER_NONE | use program-given order |
| ORDER_ALPHA_ASCEND | order alphabetically, ascending |
| ORDER_ALPHA_DESCEND | order alphabetically, descending |
| uwg_visflags_t | flags controlling behaviour of UWGVisual |
| VISFLAG_NONE | default/unset |
| VISFLAG_HOLDMSG | hold UWGMessage delivery for this gadget |
|