You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.




Widget Library
Author: Kevin McCluskey
Updated: 10/8/98

Overview
The widget library provides a cross-platform abstraction for user interface widgets, windows and events.

Initially, the widget library was used to implement HTML form elements, event handlers, the web-widget container window and the JavaScript interfaces to form elements.  It is being expanded to support other applications which require cross-platform widget support.

The HTML form elements place specific requirements on the widget library. The HTML form elements define input widgets such as textboxes, textareas, listboxes, radiobutton, checkboxes, comboboxes and file selectors. These input widgets take on the look and feel of the platform the application is running  on. The web-widget container window has a scrollbar and receives mouse and keyboard notification messages. The JavaScript interface to form elements include additional attributes and widget behaviors which can be accessed only through JavaScript.

Major Components
The widgets library includes the following:
Name Purpose Interface
window Rectangular window for rendering graphics (using the gfx library) and attaching widgets. nsIWidget
child window Rectangular region within a window for rendering graphics (using the gfx library) and attaching widgets nsIChildWidget
textbox Single line of text input. nsITextWidget
textarea Multiple lines of text input. nsITextArea
button Push button. nsIButton
listbox Presents multiple items with one or more items selected nsIListBox
combobox Combines a text box with a drop down list. The current selection from the drop down list is displayed in the text box. nsIComboBox
tab Presents multiple tabs. Tab selection events are generated when the user clicks on each tab. nsITabWidget
radiobutton Presents a button when can be shown in a checked or unchecked state. It's appearance indicates it is mutually exclusive among a group of radio button's. nsIRadioButton
checkbox Presents a button when can be shown in a checked or unchecked state nsICheckButton
scrollbar A horizontal or vertical scrollbar when sends events when the user moves the thumb of the scrollbar nsIScrollbar
fileselector A dialog box which allows the user to browse the file system and select a file or directory for saving or loading nsIFileWidget
events Windows and other widgets generate events based on user-input or programmatic changes. nsGUIEvent
dialog Provide both modal and modeless dialog boxes. nsIDialog
look and feel Provides platform specific look and feel values. such as the windows native background and foreground colors nsILookAndFeel
message pump Message pump for the windowing environment. Events are dispached when the message pump is running. nsIAppShell
tool tip Hot region within a window or childwindow that gets notified with the mouse pointer has lingered over it. nsIToolTipWidget
Implementation

  • The actual implementation for the widget library abstraction uses the native toolkit's capabilities as much as is feasible. The widget library will be implemented initially for Windows 95, Windows NT, MacOS, and variants of Unix running XLIB and MOTIF. In the future we envision many other platforms being supported.

  • HTML event handlers provide a unique challenge for the widget library. Since HTML event handlers can be used to capture low-level events such as mouse down and decide to discard the event, A widget can not assume that when the user click's on it it will receive focus or when the user presses a key in a text box that it will be entered. The widget  must pass events to a registered event handler which decides whether the event is consumed or the widget should perform it's default behavior.

  • To display all of characters in many languages a two-byte unicode character must be used rather than a single byte ascii character. This presents challenges on platforms which don't normally support unicode throughout their native toolkit.

  • Printing requires widgets to render into a graphics context. Again, this can present difficulties if the native toolkit does  not provide sufficient capability for the rendering of widgets.
Dependencies

  • GFX, NSPR

  • Windows95, NT  -  Win32 API (Note: it is not dependent on MFC)

  • Mac - MacOS

  • Unix or Linux - XLIB X11R5 and MOTIF 1.2.

  • Other OS's/windowing systems.
Roadmap
The current abstract set of widgets is sufficient to support cross-platform HTML forms and a viewer test app.
The widgets have been implented for WIN32.  They are mostly complete for Linux and Irix running Motif 1.2 , X11R5.
The widgets are under development for Mac and should be done within the next month or two.

Next steps:

Unix

  • Add support for tab and tooltip controls
MacOs

  •  The Mac widgets are currently under development. Windows, child windows and textfields, check button, radio button, events, file widget, message pump are working. The next step is the fill in the implementations for the rest of the widgets.
All platforms

  • Add  internationalization and printing support to all platforms Win32, Unix, and MacOS.

  • Additonal widget and events will be added as needed to support additional browser features such as toolbars and popup menus.
Known Bugs

Win32

  • Can not set the background and foreground color for each Widget

  • Can not set the caret within a text box

  • The rectangular widget background for checkbox's and radio buttons is not transparent. This causes a white box to always be drawn around these widgets.
Unix (Motif 1.2/ X11R6)

  • Tooltips and tab controls are not implemented
MacOS

  • Only a subset of the widgets are implemented.
Looking for help with
Mac and Unix platform ports / Performance tuning.

Mac

  • Printing

  • Performance tuning

  • Testing
Unix (Motif 1.2/ X11R6)

  • Testing under Lesstif, SunOS (running Motif 1.x, 2.x)

  • Performance tuning
Widget Module Owner - Kevin McCluskey
The  widget module owner is responsible for coordinating widget development and integrating source code from both Net and Netscape developers. Please send suggestions or offers to help to the widget owner