Show TOC Welcome to the QLIB 1.0 Online Reference
QLIB 

QWndCtrl


Extends:QControl
Requires:
<script language="JavaScript" src="js/qlib/control.js"></script>
<script language="JavaScript" src="js/qlib/wndctrl.js"></script>

Description

QWndCtrl is a base class for all window controls such as: popup boxes, control panels, tab controls, popup menus etc. This class provides DHTML implementation of a window for wide range of modern and archaic browsers on different platforms. This list includes IE4+, all DOM1/DOM2 compatible browsers (Netscape 6.x, Netscape 7.x, Mozilla 1.0, Opera 6, Opera 7 and others). Additionally this class provides special implementation for Netscape 4.x, which is based on deprecated now <LAYER> tag.

QWndCtrl is an abstraction and has no visual representation. It extends QControl class and inherits all its methods and properties. New window class derived from QWndCtrl must call create method in the instance constructor (after this the window gets materialized in HTML).

A window is a rectangle area on the screen which content is clipped if exceeds the client area. According to DHTML principals, the height of a window is optional. If this property is missed, the window automatically selects the proper height to fit the content size.

When a window control is created, the following properties must be specified: absolute screen coordinates of the top left corner (x and y); the client area dimensions (width and optionally height); the content (content). The content property should be either a string or a function. If it's a string, it should contain HTML code that is expected to appear in the window. The functional content is used to create QLIB controls within the window or to create nested windows which are allowed.

Along with required properties, there're optional ones: initial visibility (visible); effects mask (see the Implementation section for details); opacity (opacity) and index of stacking order (zindex). By default a window appears visible right after it's created, has no effects, is a 100% opaque and its stacking order is corresponds to the creation order.

Implementation Notes

Basically the implementation of a window depends on the browser capabilities. Some old browsers do not provide all features required for extended effects. If a browser is not able to render the effect or to execute the method, this effect/method is ignored with no output to user.

setSize method has special behavior in a Netscape 4.x browser. Unlike any other browser, the content of a window doesn't get relayouted when the size changes. In fact Netscape 4.x only adjusts the clipping area. Opera 6 doesn't resize auto-height windows.

Since opacity of an element is not a part of any public standard so far, many browsers have its own syntax on this matter. A few browsers do not support semi-transparency at all. The following table gives an idea how setOpacity method is supported:

MS IE4+Netscape 4.xNetscape 6.x, 7.xMozilla 1.0Opera 6, 7
supported - supportedsupported -
QWndCtrl brings up an easy way to enhance your web page with variety of transition effects. When a window is created, an optional set of effects can be provided. In addition QLIB introduces setEffects method that allows to adjust effects after the window has been created. There're two kinds of effects: static and dynamic. Effects from the both categories can be mixed together. The following table gives an idea how the effects are supported:

Effect \ BrowserMS IE4+Netscape 4.xNetscape 6.x, 7.xMozilla 1.0Opera 6, 7
Static Effects
QWndCtrl.GRAYYesNoNoNoNo
QWndCtrl.XRAYYesNoNoNoNo
QWndCtrl.INVERTYesNoNoNoNo
QWndCtrl.SHADOWYesNoNoNoNo
 
Dynamic Effects
QWndCtrl.FADEINYesNoYesYesNo
QWndCtrl.FADEOUTYesNoYesYesNo
QWndCtrl.BOXINYesNoNoNoNo
QWndCtrl.BOXOUTYesNoNoNoNo
QWndCtrl.CIRCLEINYesNoNoNoNo
QWndCtrl.CIRCLEOUTYesNoNoNoNo
QWndCtrl.WIPEINYesNoNoNoNo
QWndCtrl.WIPEOUTYesNoNoNoNo
QWndCtrl.HBARNINYesNoNoNoNo
QWndCtrl.HBARNOUTYesNoNoNoNo
QWndCtrl.VBARNINYesNoNoNoNo
QWndCtrl.VBARNOUTYesNoNoNoNo
QWndCtrl.DISSOLVEINYesNoNoNoNo
QWndCtrl.DISSOLVEOUTYesNoNoNoNo
QWndCtrl.HBLINDSINYesNoNoNoNo
QWndCtrl.HBLINDSOUTYesNoNoNoNo
QWndCtrl.VBLINDSINYesNoNoNoNo
QWndCtrl.VBLINDSOUTYesNoNoNoNo

See Also

Windowing

Constructor

QWndCtrl()
Creates new prototype instance for class that you want to be derived from QWndCtrl (see JavaScript prototype property for details). Example: to derive MyControl from QWndCtrl you should assign: MyControl.prototype = new QWndCtrl();

Properties

PropertyAccessDescription
xR / WX coordinate of the window top left corner (pixels).
yR / WY coordinate of the window top left corner (pixels).
widthR / WWidth in pixels of the window client area.
heightR / WHeight in pixels of the window client area (can be null for auto-size).
contentR / WThe window content (must be either a string or a function).
visibleR / WCurrent visibility state.
effectsR / WCurrent effects mask.
opacityR / WThe window opacity from 0 (transparent) to 100 (opaque).
zindexR / WThe window stacking order. Can be null for auto-stack.
 
Properties inherited from QControl
nameRName of the control. Serves as a direct reference to this object when evaluated.
idRAlphanumerical unique identifier of the control.
parentRReference to the parent control (if any, null otherwise).
tagR / WCan refer any value or object, tag is always passed to all event handlers as the last parameter.
windowR / WThis property is a reference to JavaScript window object in which the control exists.
documentR / WRefers to document object in which the corresponding HTML elements exist. Normally all elements of a DOM2 compatible browser are children of the top document object. If the control creates new document scope (i.e. printing tags like <IFRAME>, <LAYER>), it should assign this document to this property.

Methods

create()
Creates DHTML code for the window. This method is claimed to be protected. That means that only subclasses of QWndCtrl may call it. This method requires the following properties to be initialized before the call: window position (x, y); dimensions (width, height); content (content); initial visibility (visible); effects mask (effects); opacity (opacity) and stacking order (zindex).
show(show)
Shows or hides the window. "IN" and "OUT" transitions can be assigned to show and hide actions respectively (see setEffects method). In this case the window does not show/hide promptly, instead the window smoothly changes its visibility through animation.
Parameters
show - Desirable state as follows: true - make it visible, false - hide the window.
focus()
Gives the focus to the window. This brings it to the top of the stacking order.
center()
Centers the window on page.
moveTo(x, y)
Moves the window to specified position. If the window has been created in document context, it gets positioned in absolute page coordinates. If the window is nested in another one, it's positioned in relative coordinates of the parent window (see CSS positon property for more details).
Parameters
x - X coordinate in pixels.
y - Y coordinate in pixels.
setSize(w, hopt)
Resizes the window. The content gets relayouted to fill the area changed. See Implementation Notes for details of cross-browser support.
Parameters
w - The window width in pixels.
h - Optional. The window height in pixels. The window automatically selects the proper height is this parameter is skipped or null
setZIndex(z)
Changes the stacking order of the window. Window with higher index appear on the screen first obscuring underlying windows with lower indices.
Parameters
z - Desirable stacking index (starting from 1).
setOpacity(op)
Changes the window opacity. See Implementation Notes for details and how this method is supported.
Parameters
op - Desirable opacity as follows: 0 - transparent, 100 - opaque.
setEffects(fx)
Sets effects mask. There're two kinds of effects: static and dynamic. Static effects change the default appearance of the window (for example, a window casts shadow when it's set by QWndCtrl.SHADOW). On the other hand, dynamic effects are transitions that get activated when window changes its visibility state. A dynamic effect can be either "IN" or "OUT". The first type is played when a window appears. The second one is activated on the hiding. Effects of all types can be mixed together to bring up a composite effect (example: "QWndCtrl.SHADOW + QWndCtrl.BOXIN + QWndCtrl.FADEOUT" - makes a window to cast shadow, it appears with "box" effect, hides itself fading out from view).
Parameters
fx - Mix of effects to apply.

Event Handlers

onShow(visible, tag)
This handler is fired when the window becomes visible or vanishes. When transitions are enabled, the handler is fired after the animation completes.
Parameters
visible - Visibility state of the window.
tag - Tag is commonly used to parameterize the event handler. Each control can be optionally assigned by a tag.
Returns
The return value is ignored.

Class Variables

VariableDescription
QWndCtrl.TOPZINDEXStacking order of the topmost window.

Class Constants

ConstantDescription
QWndCtrl.GRAYStatic effect that displays the window in black-and-white mode.
QWndCtrl.XRAYThis gives an effect of xray shot.
QWndCtrl.INVERTThis static effect inverses the colors.
QWndCtrl.SHADOWMakes the window to cast shadow.
QWndCtrl.FADEINThis is a fade transition that gets activated when the window becomes visible.
QWndCtrl.FADEOUTThis is a fade transition that gets activated when the window hides.
QWndCtrl.BOXINThe window appears as an opening box.
QWndCtrl.BOXOUTThe window hides when the box gets collapsed.
QWndCtrl.CIRCLEINThe window appears as a growing circle.
QWndCtrl.CIRCLEOUTThe window hides when the circle gets collapsed.
QWndCtrl.WIPEINThe window wipes down when appears.
QWndCtrl.WIPEOUTThe window wipes up when hides.
QWndCtrl.HBARNINCreates an effect of opening doors when the window appears.
QWndCtrl.HBARNOUTCreates an effect of closing doors when the window hides.
QWndCtrl.VBARNINCreates an effect of vertically opening shutter when the window appears.
QWndCtrl.VBARNOUTCreates an effect of vertically closing shutter when the window hides.
QWndCtrl.DISSOLVEINRandom dissolve on appear.
QWndCtrl.DISSOLVEOUTRandom dissolve on hide.
QWndCtrl.HBLINDSINHorizontal blinds when the window appears.
QWndCtrl.HBLINDSOUTHorizontal blinds when the window hides.
QWndCtrl.VBLINDSINVertical blinds when the window appears.
QWndCtrl.VBLINDSOUTVertical blinds when the window hides.

CSS Class Selectors

CSS ClassDescriptionExample (defined in a CSS file)
DIV.qwindowDefines style properties of the window DIV element.DIV.qwindow { background-color: red } /* sets the window background to red. */