Navigation: ABC Library Reference > WindowResizeClass >====== WindowResizeClass Overview ====== | |
The WindowResizeClass lets the end user resize windows that have traditionally been fixed in size due to the controls they contain (List boxes, entry controls, buttons, nested controls, etc.). The WindowResizeClass intelligently repositions the controls, resizes the controls, or both, when the end user resizes the window.
WindowResizeClass Concepts
The intelligent repositioning is accomplished by recognizing there are many different types of controls that each have unique repositioning and resizing requirements. The WindowResizeClass also recognizes that controls are often nested, and considers whether a given control's coordinates are more closely related to the window's coordinates or to another control's coordinates. That is, intelligent repositioning correctly identifies each control's parent. See SetParentControl for more information on the parent concept.
The intelligent repositioning includes several overall strategies that apply to all window controls, as well as custom per-control strategies for resizing and repositioning individual controls. The overall strategies include:
Surface | Makes the most of the available pixels by positioning other controls to maximize the size of LIST, SHEET, PANEL, and IMAGE controls. We recommend this strategy for template generated windows. |
Spread | Maintains the design-time look and feel of the window by applying a strategy specific to each control type. For example, BUTTON sizes are not changed but their positions are tied to the nearest window edge. In contrast, LIST sizes and positions are scaled in proportion to the window. |
Resize | Rescales all controls in proportion to the window. |
See SetStrategy for more information on resizing strategies for individual controls.
To allow window resizing you must set the WINDOW's frame type to Resizable. We also recommend adding the MAX attribute. See The Window Formatter--The Window Properties Dialog for more information on these settings.
WindowResizeClass Relationship to Other Application Builder Classes
The WindowResizeClass is independent of the other Application Builder Classes. It does not rely on other ABC classes, nor do other ABC classes rely on it.
WindowResizeClass ABC Template Implementation
The ABC Templates instantiate a WindowResizeClass object for each WindowResize template in the application, typically one for each procedure that manages a window. The templates may also derive a class from the WindowResizeClass. The derived class (and its object) is called Resizer. The ABC Templates provide the derived class so you can use the WindowResize template Classes tab to easily modify the Resizer's behavior on an instance-by-instance basis.
The object instantiated from the derived class is called Resizer. This object supports all the functionality specified in the WindowResize template. See Other Templates--Window Resize for more information on the template implementation of this class.
WindowResizeClass Source Files
The WindowResizeClass source code is installed by default to the Clarion \LIBSRC folder. The WindowResizeClass source code and its respective components are contained in:
ABRESIZE.INC | WindowResizeClass declarations | |
ABRESIZE.CLW | WindowResizeClass method definitions |
WindowResizeClass Conceptual Example
The following example shows a typical sequence of statements to declare, instantiate, initialize, use, and terminate a WindowResizeClass object. This example illustrates the Surface strategy plus some custom strategies for specific controls. The program does nothing except present a window with a typical variety of controls.
PROGRAM
INCLUDE('ABRESIZE.INC') !declare WindowResizeClass
MAP
END
Resizer WindowResizeClass !declare Resizer object
ClientQ QUEUE,PRE(CLI) !declare LIST QUEUE
Name STRING(20)
State STRING(2)
END
!WINDOW needs IMM & RESIZE
window WINDOW('Client Information'),AT(,,185,100),IMM,GRAY,MAX,RESIZE
SHEET,AT(3,3,180,78),USE(?Sheet1)
TAB('Client List'),USE(?ListTab)
LIST,AT(10,20,165,55),USE(?List1),FROM(ClientQ),|
FORMAT('87L~Name~@s20@8L~State Code~@s2@')
END
TAB('Client Logo'),USE(?LogoTab)
IMAGE('SV.gif'),AT(50,35),USE(?CLI:Logo)
END
END
PROMPT('Locate:'),AT(7,87),USE(?LocatorPrompt)
ENTRY(@s20),AT(33,86,61,12),USE(CLI:Name)
BUTTON('Restore'),AT(110,84),USE(?Restore)
BUTTON('Close'),AT(150,84),USE(?Close)
END
CODE
OPEN(window)
window{PROP:MinWidth}=window{PROP:Width} !set window's minimum width
window{PROP:MinHeight}=window{PROP:Height} !set window's minimum height
Resizer.Init(AppStrategy:Surface) !initialize Resizer object
Resizer.SetStrategy(?LocatorPrompt,| !set control specific strategy:
Resize:FixLeft+Resize:FixBottom,Resize:LockSize) ! at bottom left & fixed size
Resizer.SetStrategy(?CLI:Name,| !set control specific strategy:
Resize:FixLeft+Resize:FixBottom,Resize:LockHeight)! at bottom left & fixed height
ACCEPT
CASE EVENT()
OF EVENT:CloseWindow !on close window,
Resizer.Kill ! shut down Resizer object
OF EVENT:Sized !on sized window,
Resizer.Resize ! resize & reposition controls
END ! applying above strategies
CASE ACCEPTED()
OF ?Restore
Resizer.RestoreWindow !restore window to initial size
OF ?Close
POST(Event:CloseWindow)
END
END