By Kenneth C. Feldt
Book Price: $59.99 USD
£42.50 GBP
PDF Price: $41.99
Cover | Table of Contents | Colophon
vim and emacs to more user-friendly tools such as Anjuta and KDevelop. It is also possible to use the Eclipse cross-platform development environment for the exercises in this book.
<?xml version="1.0"?>
window:
<window>
... some children
</window>
<>). Each opening tag (<tag>) must include a closing or terminating tag (</tag>). Elements enclosed by an opening and closing tag are said to be children of the tag.=attributeValue and are declared within the element's opening tag. In the case of a XUL window, attributes must be defined to set the window's height and width:
height="heightInPixels" width="widthInPixels"
id<?xml version="1.0"?>
window:
<window>
... some children
</window>
<>). Each opening tag (<tag>) must include a closing or terminating tag (</tag>). Elements enclosed by an opening and closing tag are said to be children of the tag.=attributeValue and are declared within the element's opening tag. In the case of a XUL window, attributes must be defined to set the window's height and width:
height="heightInPixels" width="widthInPixels"
id (used when JavaScript scripts need to get a reference to the window), title (for interface display), and orient (to set the initial layout direction of children).xmlns attribute, which defines the namespace to be used within the document.body, head, div, and others.xmlns namespace declaration is a mechanism for defining what namespace a specific element belongs to, providing the browser engine with a pointer or reference to a dictionary that describes the required structure of a tag.<box> container—all XUL interfaces are a collection of nested boxes that contain any number of other boxes. Most developers will use two box subclasses: a <vbox> that lays out child elements in a vertical alignment, and an <hbox> that presents children in a horizontal alignment.orient attribute: a value of horizontal will result in a box's children being placed along a horizontal axis and a value of vertical will result in content being placed along the vertical axis. The Firefox framework supports <vbox> and <hbox> elements as a shortcut alternative to using the orient attribute.label element. Adding child elements to the different forms of boxes illustrates the difference in how vboxes and hboxes work:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window
id="theWindow"
title="The Window"
orient="horizontal"
width = "400"
height = "300"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
>
<hbox>
<label value="label 1"/>
<label value="label 2"/>
<label value="label 3"/>
</hbox>
<vbox>
<label value="label 4"/>
<label value="label 5"/>
<label value="label 6"/>
</vbox>
</window>
<label value="My Label"/>
labelimagedirnormal (default)reverseorienthorizontal (default)vertical
textbox element. The default nature of a textbox is to support a one-line entry, but several attributes affect the nature of the entry area:
maxlengthmultilinetrue, pressing Enter during text entry forces a new line entry; otherwise, all text is combined in a single text line.rowssizewrapoff disables word wrapping.listbox container with listitem children. Listitems display the contents of the label attribute, but they also support a value attribute that scripts use to obtain some data that the designer chooses not to be rendered in the interface.listboxes into multiple columns in a fashion very similar to that of the HTML table element. For multiple-column lists, the first child of a listbox is a <listhead> element that contains one <listheader> child for each column to be displayed with a header. Following the <listheader> child is the <listcols> entry with one child for each column to be displayed.<listitem> children, but unlike the simplest single-column implementation (and similar to the table layout), multicolumn list items contain <listcell> children that are rendered in the columns. An example of multicolumn lists is shown in the following code fragment and in :
<hbox flex="1" class="test_b">
<listbox>
<listhead>
<listheader label="Column 1"/>
<listheader label="Column 2"/>
<listheader label="Column 3"/>
</listhead>
<listcols>
<listcol/>
<listcol/>
<listcol flex="1"/>
</listcols>
<listitem>
<listcell label="R1C1"/>
<listcell label="R1C2"/>
<listcell label="R1C3"/>
</listitem>
<listitem>
<listcell label="R2C1"/>
<listcell label="R2C2"/>
<listcell label="R2C3"/>
</listitem>
<listitem>
<listcell label="R3C1"/>
<listcell label="R3C2"/>
<listcell label="R2C3"/>
</listitem>
<listitem>
<listcell label="R4C1"/>
<listcell label="R4C2"/>
<listcell label="R4C3"/>
</listitem>
</listbox>
</hbox>
<tabbox> element provides a family of containers that represent the tabbed-index collection of panels.<tabbox> element starts with a <tabs> element, whose <tab> children represent the buttons attached to their respective content panels.<tabpanels> element, which contains <tabpanel> children. The tab panels are the topmost container for the interface widgets bound to the tab. The following code and illustrate the use of a tab box:
<tabbox flex="1">
<tabs>
<tab label="Sports"/>
<tab label="News"/>
<tab label="Weather"/>
<tab label="Entertainment"/>
</tabs>
<tabpanels flex="1">
<tabpanel id="sports">
<vbox flex="1">
<label value="Sports"/>
</vbox>
</tabpanel>
<tabpanel id="news">
<vbox flex="1">
<label value="News"/>
</vbox>
</tabpanel>
<tabpanel id="Weather">
<vbox flex="1">
<label value="Weather"/>
</vbox>
</tabpanel>
<tabpanel id="Entertainment">
<vbox flex="1">
<label value="Entertainment"/>
</vbox>
</tabpanel>
</tabpanels>
</tabbox>
flex attribute can significantly affect the appearance of tab boxes.flex attribute on the <tabbox> affects the amount of horizontal space the tab box occupies; setting the flex attribute on the <tabpanels> element changes the amount of vertical space the entire box occupies.<hbox> elements divide the area into vertical segments. Splitters in src of a content panel points to a web page through a URL. The three basic types of content panels are iframes (generally used when the interface is managing user navigation through heavy use of scripting), browser (used to provide additional navigational features), and tabbrowser (a browser embedded within a tabbox). The following code shows how to add an iframe element within a tabpanel, and shows the result:
<tabpanel class="test_a" id="news">
<vbox >
<label value="News"/>
</vbox>
</tabpanel>
<tabpanel id="Weather">
<iframe flex="1" src="http://www.weather.com/"/>
</tabpanel>
<tabpanel id="Entertainment">
<vbox flex="1">
<label value="Entertainment"/>
</vbox>
</tabpanel>
flex attribute on the iframe element. Omitting this step can result in very tiny slices of a web page being displayed.<spacer>flex and pack attributes to organize widgets in the manner desired. Spacer widgets act as invisible "springs." Setting the flex attribute of a spacer allows the designer to push elements to one side of a parent container.<statusbar><statusbar> contains a <statuspanel> child, which includes label attributes. Developers can access the label property of a statuspanel to provide feedback to the user:
<statusbar pack="end"> <statusbarpanel label="Still waiting...."/> </statusbar>
<progressmeter>value attribute represents an integer percentage of completion. When the mode attribute is set to determined, the meter changes to show the percentage of completion. When the mode attribute is set to undetermined, the meter displays a graphic to indicate ongoing activity. Developers use the determined mode when an activity consists of known steps of completion and they want to indicate task progression. They use the undetermined mode to indicate an ongoing task.<description>label fields to display short lines of text, you can use a <description> element to display longer segments of text. The contents will wrap as the enclosing box changes size.<description style="color:gray;"> We are currently processing your order. Please do not press any buttons unless you are really tired of waiting. </description> <statusbar > <progressmeter mode="undetermined" /> <spacer flex="1"/> <statusbarpanel label="Still waiting...."/> </statusbar> ...
labels provide a control attribute that supports a binding to GUI controls to specify which control receives focus when the label is clicked. Setting the value of the control attribute of a label will result in shifting input focus to the control with the matching id attribute.tabindex provides the same functionality available in most interface models that allow the user to quickly traverse through a series of text entry and control fields:
tabindex="someIndex"
tabindex set to the first element of the box.tabindex is operating-system-specific. Windows platforms traverse focus to include buttons and checkboxes; OS X implementations may send focus only to text entry fields depending on a control panel setting.control attribute and tabindex to several fields. and illustrate the differences between Windows and OS X implementations.
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="data:text/css,
.test_a {
background-color: #808080;
border-color:black;
border-style:dashed;
border-width: thin;
}
.test_b {
background-color: #c0c0c0;
border-color:black;
border-style:solid;
border-width: thin;
}
type="text/css"?>
<window
id="theWindow"
title="The Window"
orient="horizontal"
width = "400"
height = "300"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
>
<vbox flex="1">
<vbox>
<hbox>
<groupbox flex="1">
<caption>
<label value="Please send me info:"/>
</caption>
<hbox>
<label control="cmt" value="Comments:"/>
<textbox tabindex="1" id="cmt" flex="1"/>
</hbox>
<checkbox tabindex="2" label="Touring in the British Isles"/>
<checkbox tabindex="3" label="Cycling in France"/>
<checkbox tabindex="4" label="Skiing in Switzerland"/>
</groupbox>
<radiogroup pack="center" >
<radio tabindex="5" label="Option 1"/>
<radio label="Option 2"/>
<radio label="Option 3"/>
</radiogroup>
</hbox>
<grid class="test_b" flex="1">
<columns>
<column/>
<column flex="1"/>
</columns>
<rows>
<row>
<label control="Nm" value="Name:"/>
<textbox tabindex="6" id="Nm"/>
</row>
<row>
<label control="Addr" value="Address:"/>
<textbox tabindex="7" id="Addr" />
</row>
<row>
<label control="Ph" value="Phone:"/>
<textbox tabindex="8" id="Ph" />
</row>
<hbox pack="center">
<button tabindex="9" label="Send" />
</hbox>
</rows>
</grid>
</vbox>
</vbox>
</window>
tagName : {
someStyleAttribute: someValue;
someOtherStyleAttribute: someOtherValue;
....
}
tagName (e.g., div elements).
hbox.myClass {
-moz-box-pack:center;
}
hbox elements that have the class attribute set to myClass will have the pack property set to end.pack works the way XUL designers expect. Use of the pseudoproperties allows the broad assignment of Firefox- (and XUL-) specific styling to interface elements.
<?xml version="1.0"?>
<?xml-stylesheet href="testStyles.css" type="text/css"?>
<window
id="theMainWindow"
title="Test Window"
orient="horizontal"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!-- main top level container -->
<hbox flex="1" >
<!-- a container for some kind of list -->
<vbox style="background-color:yellow;" flex="2" >
<description id="tocDescription">
Table of contents
</description>
</vbox>
<!-- container for content and tool areas -->
<vbox flex="2" >
<!-- used to display content -->
<hbox style="background-color:green;" flex="3" >
<description id="msgDescription">
Content to be displayed
</description>
</hbox>
<!-- used to display typing area -->
<hbox style="background-color:blue;" flex="3" >
<description id="noteDescription">
Note area
</description>
</hbox>
<!-- used to display tool area-->
<hbox flex="1" >
<spacer flex="1"/>
<vbox>
<spacer flex="1"/>
<hbox>
<button id="B1" label="B1" />
<button id="B2" label="B2"/>
<button id="B3" label="B3"/>
<button label="B4"/>
</hbox>
<spacer flex="1"/>
</vbox>
<spacer flex="1"/>
</hbox>
</vbox>
<!-- container for messages and tool areas -->
</hbox>
<!-- main container -->
</window>
<?xml version="1.0"?>
<?xml-stylesheet href="testStyles.css" type="text/css"?>
<window
id="theMainWindow"
title="Test Window"
orient="horizontal"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!-- main top level container -->
<hbox flex="1" >
<!-- a container for some kind of list -->
<vbox style="background-color:yellow;" flex="2" >
<description id="tocDescription">
Table of contents
</description>
</vbox>
<!-- container for content and tool areas -->
<vbox flex="2" >
<!-- used to display content -->
<hbox style="background-color:green;" flex="3" >
<description id="msgDescription">
Content to be displayed
</description>
</hbox>
<!-- used to display typing area -->
<hbox style="background-color:blue;" flex="3" >
<description id="noteDescription">
Note area
</description>
</hbox>
<!-- used to display tool area-->
<hbox flex="1" >
<spacer flex="1"/>
<vbox>
<spacer flex="1"/>
<hbox>
<button id="B1" label="B1" />
<button id="B2" label="B2"/>
<button id="B3" label="B3"/>
<button label="B4"/>
</hbox>
<spacer flex="1"/>
</vbox>
<spacer flex="1"/>
</hbox>
</vbox>
<!-- container for messages and tool areas -->
</hbox>
<!-- main container -->
</window>
<textbox> element. Textboxes also have attributes to define password entries and a maximum length attribute.
<!-- used to display message -->
<hbox flex="3" >
<spacer flex="1"/>
<vbox> <!-- stack message and login controls vertically -->
<spacer flex="1"/>
<description id="msgDescription">
Waiting for login.
</description>
<label value="User Name:" control="userName"/>
<textbox id="userName"/>
<label value="Password:" control="userName"/>
<textbox id="password" type="password" maxlength="8"/>
<button id="loginButton " label="Logon"/>
<spacer flex="1"/>
</vbox>
<spacer flex="1"/>
</hbox>
<!-- used to display message -->
vbox {
/*
border-style:groove;
background-color:#888888;
*/
}
hbox {
/*
border-style:groove;
background-color:#cccccc;
*/
}
TRACE statements during program execution.
<!-- a container for some kind of list -->
<vbox flex="1 > <!-- quote intentionally left out -->
</vbox>
initialize function:
function initialize( ) {
try {
document.getElementById("B1").addEventListener("command",
genericBtnHandler,true;
// Oops no closing paren