User Tools

Site Tools


windowmanager_overview.htm
Navigation:  ABC Library Reference > WindowManager >====== WindowManager Overview C6H0009.jpg ====== Previous pageReturn to chapter overviewNext page

The WindowManager class declares a Window Manager that provides highly structured, consistent, flexible, and convenient processing for Clarion window procedures. The WindowManager class is actually a window procedure manager. This includes almost every template generated procedure, including Process and Report procedures.

WindowManager Concepts

A Structured Window Procedure Manager

The WindowManager object initializes the procedure, runs the procedure by handling all ACCEPT loop events for the WINDOW, then shuts down the procedure. The WindowManager handles events primarily by forwarding the events to other ABC Library objects for processing.

The WindowManager is a fairly generic base class and therefore handles events and processes that are common across most Windows applications. For an example of a process-specific WindowManager implementation, see Print Preview Class and Report Manager Class.

Implements Update Procedure Policy

In addition to its function as a general purpose window procedure manager, the WindowManager may be configured to implement a variety of options for update procedures–window procedures that support record inserts, changes, and deletes. The WindowManager carries out the specified options for these update procedures (forms).

Integrated with other ABC Library Objects

The WindowManager is closely integrated with several other ABC Library objects; in particular, the BrowseClass, ToolbarClass, FileDropClass, and FileDropComboClass objects. These objects register their presence with each other, set each other's properties, and call each other's methods to accomplish their goals.

These integrated objects could override the WindowManager's methods (such as TakeAccepted) to perform their jobs; however, because the WindowManager is programmed to understand these ABC objects, once they are registered (AddItem), the WindowManager drives them directly according to their documented interfaces.

Encapsulated Event Processing

The WindowManager provides separate virtual methods to group the handling of all ACCEPT loop events into logical, convenient containers (virtual methods), so that, should you need to implement custom (non-default) event handling, you can implement your changes within the relatively small scope of the specific virtual method that implements the default event handling you wish to change. This logical grouping of window event handling is as follows:

TakeEvent (handle all events)
TakeWindowEvent (handle all non-field events–do default processing forcommon non-field events)
TakeAccepted (do default EVENT:Accepted processing)
TakeRejected (do default EVENT:Rejected processing)
TakeSelected (do default EVENT:Selected processing)
TakeNewSelection (do default EVENT:NewSelection processing)
TakeCompleted (do default EVENT:Completed processing)
TakeCloseEvent (do default EVENT:Close processing)
TakeFieldEvent (handle all field events–do custom processing for field events)

WindowManager ABC Template Implementation

The ABC Templates derive a class from the WindowManager class for each procedure that drives an interactive window, including Report and Process procedures. The derived class is called ThisWindow, and its methods and behavior can be modified on the Window Behavior Classes tab.

The ABC Templates generate virtual methods as needed to provide procedure specific initialization, event handling, and shut down.

WindowManager Relationship to Other Application Builder Classes

The WindowManager is closely integrated with several other ABC Library objects–in particular, the BrowseClass, FileDropClass, FileDropComboClass, and ToolbarClass objects. These objects register their presence with the WindowManager, set each other's properties, and call each other's methods as needed to accomplish their respective goals.

The BrowseClass uses the WindowManager to refresh the window as needed. Therefore, if your program instantiates the BrowseClass, it must also instantiate the WindowManager. Much of this is automatic when you INCLUDE the BrowseClass header (ABBROWSE.INC) in your program's data section. See the Conceptual Example and see Browse Class for more information.

The WindowManager serves as the foundation of the PrintPreviewClass and the ReportManager. That is, both the PrintPreviewClass and the ReportManager are derived from the WindowManager, because both derived classes manage a window procedure.

PrintPreviewClass–Print Preview Window Manager

The PrintPreviewClass implements a full featured print preview window. See Print Preview Class for more information.

ReportManager–Progress Window Manager

The ReportManager implements a progress window that monitors and displays the status of a report. See Report Manager Class for more information.

WindowManager Source Files

The WindowManager source code is installed by default to the Clarion \LIBSRC folder. The WindowManager source code and its respective components are contained in:

ABWINDOW.INC WindowManager declarations
ABWINDOW.CLW WindowManager method definitions

WindowManager Conceptual Example

The following example shows a typical sequence of statements to declare, instantiate, initialize, use, and terminate a WindowManager and related objects. This example performs repetitive inserts to a Customer file and also adds phone numbers for each customer to a related Phones file. It uses the WindowManager to call a procedure to validate the customer's state code against a States file.

Note that the WindowManager is aware of other ABC objects, such as BrowseClass objects, Toolbar objects, FileDrop objects, etc. This example shows the interaction between the WindowManager object and a FileManager object and a BrowseClass object.

 PROGRAM

  INCLUDE('ABWINDOW.INC')           !declare WindowManager

  INCLUDE('ABFILE.INC')             !declare File,View&Relation Mgrs

  INCLUDE('ABBROWSE.INC')           !declare BrowseClass

  MAP

SelectState PROCEDURE                !procedure to validate State

  END

GlobalErrors  ErrorClass             !declare GlobalErrors object

GlobalRequest  BYTE(0),THREAD        !inter procedure communication

GlobalResponse BYTE(0),THREAD        !inter procedure communication

VCRRequest   LONG(0),THREAD          !inter procedure communication

Customer   FILE,DRIVER('TOPSPEED'),PRE(CUS),CREATE,THREAD

BYNUMBER   KEY(CUS:CUSTNO),NOCASE,OPT,PRIMARY

Record      RECORD,PRE()

CUSTNO       LONG

Name         STRING(30)

State        STRING(2)

           END

          END

Phones    FILE,DRIVER('TOPSPEED'),PRE(PH),CREATE,THREAD

IDKEY     KEY(PH:ID),DUP,NOCASE

Record     RECORD,PRE()

ID          LONG

NUMBER      STRING(20)

          END

         END

State     FILE,DRIVER('TOPSPEED'),PRE(ST),CREATE,THREAD

StateCodeKey KEY(ST:STATECODE),NOCASE,OPT

Record       RECORD,PRE()

STATECODE     STRING(2)

STATENAME     STRING(20)

            END

         END

Access:State CLASS(FileManager)        !declare Access:State object

Init          PROCEDURE

            END

Relate:State CLASS(RelationManager)    !declare Relate:State object

Init          PROCEDURE

            END

Access:Customer CLASS(FileManager)     !declare Access:Customer object

Init             PROCEDURE

               END

Relate:Customer CLASS(RelationManager) !declare Relate:Customer object

Init             PROCEDURE

               END

Access:Phones   CLASS(FileManager)     !declare Access:Phones object

Init             PROCEDURE

               END

Relate:Phones   CLASS(RelationManager) !declare Relate:Phones object

Init             PROCEDURE

               END

PhoneView VIEW(Phones)                 !declare Phones VIEW

         END

PhoneQ  QUEUE                          !declare PhoneQ for browse list

PH:ID      LIKE(PH:ID)

PH:NUMBER  LIKE(PH:NUMBER)

ViewPos    STRING(512)

       END

CUS:Save  LIKE(CUS:RECORD),STATIC      !declare save area for Cus ditto key

CUSWindow WINDOW('Add Customer'),AT(,,146,128),IMM,SYSTEM,GRAY

     SHEET,AT(4,4,136,102),USE(?CurrentTab)

      TAB('General'),USE(?GeneralTab)       !General tab

       PROMPT('ID:'),AT(8,35),USE(?CUSTNO:Prompt)

       ENTRY(@n-14),AT(42,35,41,10),USE(CUS:CUSTNO),RIGHT(1) ! Customer ID

       PROMPT('Name:'),AT(8,49),USE(?NAME:Prompt)

       ENTRY(@s30),AT(42,49,90,10),USE(CUS:NAME)! Customer Name

       PROMPT('State:'),AT(8,63),USE(?State:Prompt)

       ENTRY(@s2),AT(42,63,40,10),USE(CUS:State)! Customer State

      END

      TAB('Phones'),USE(?PhoneTab)         !Phones tab

       LIST,AT(8,20,128,63),USE(?PhoneList),IMM,HVSCROLL,FROM(PhoneQ),|

        FORMAT('38R(2)|M~ID~C(0)@n-14@80L(2)|M~NUMBER~@s20@')

       BUTTON('&Insert'),AT(8,87),USE(?Insert)

       BUTTON('&Change'),AT(53,87),USE(?Change)

       BUTTON('&Delete'),AT(103,87),USE(?Delete)

      END

     END

     BUTTON('OK'),AT(68,110),USE(?OK),DEFAULT

     BUTTON('Cancel'),AT(105,110),USE(?Cancel)

    END

ThisWindow CLASS(WindowManager)             !declare derived ThisWindow object

Init     PROCEDURE(),BYTE,PROC,VIRTUAL      !procedure specific initialization

Kill     PROCEDURE(),BYTE,PROC,VIRTUAL      !procedure specific shut down

Run      PROCEDURE(USHORT Number,BYTE Request),BYTE,PROC,VIRTUAL !run a procedure

TakeAccepted PROCEDURE(),BYTE,PROC,VIRTUAL  !non-default EVENT:Accepted handling

          END

PhBrowse CLASS(BrowseClass)                 !declare PhBrowse object

Q         &PhoneQ                           !which works with ThisWindow object

        END

 CODE

 ThisWindow.Run()                !run the program / procedure

 !(Init, Ask, Kill)

ThisWindow.Init  PROCEDURE()      !setup and “program” ThisWindow

ReturnValue     BYTE,AUTO

 CODE

 GlobalErrors.Init               !initialize GlobalErrors object

 Relate:Customer.Init            !initialize Relate:Customer object

 Relate:State.Init               !initialize Relate:State object

 Relate:Phones.Init              !initialize Relate:Phones object

 ReturnValue = PARENT.Init()     !call base class WindowManager.Init

 Relate:Customer.Open            !open Customer & related files

 Relate:State.Open               !open State & related files

 !Program ThisWindow object:

 SELF.Request = InsertRecord     ! insert records only

 SELF.FirstField = ?CUSTNO:Prompt! CustNo is firstfield for ThisWindow

 SELF.VCRRequest &= VCRRequest   ! set VCRRequest for ThisWindow

 SELF.Errors &= GlobalErrors     ! set error handler for ThisWindow

 SELF.HistoryKey = 734           ! set ditto key (CTRL')

 SELF.AddHistoryFile(CUS:Record,CUS:Save) ! set ditto file

 SELF.AddHistoryField(?CUS:CUSTNO,1)! set ditto (restorable) field

 SELF.AddHistoryField(?CUS:NAME,2)  ! set ditto (restorable) field

 SELF.AddHistoryField(?CUS:State,3) ! set ditto (restorable) field

 SELF.AddUpdateFile(Access:Customer)! register FileManager with ThisWindow

 SELF.Primary &= Relate:Customer    ! register RelationMgr with ThisWindow

 SELF.AddItem(?Cancel,RequestCancelled)! set action for Cancel button

 SELF.InsertAction = Insert:Batch      ! set insert action (repetitive)

 SELF.OkControl = ?OK                  ! set OK button

 IF SELF.PrimeUpdate() THEN RETURN Level:Notify. !prepare record for add

 OPEN(CUSWindow)                       !open the window

 SELF.Opened=True                      ! flag it as open

                         !Program PhBrowse object, including

                         ! registering ThisWindow (SELF)

 PhBrowse.Init(?PhoneList,PhoneQ.ViewPos,PhoneView,PhoneQ,Relate:Phones,SELF)

 PhBrowse.Q &= PhoneQ

 PhBrowse.AddSortOrder(,PH:IDKEY)

 PhBrowse.AddRange(PH:ID,Relate:Phones,Relate:Customer)

 PhBrowse.AddField(PH:ID,PhBrowse.Q.PH:ID)

 PhBrowse.AddField(PH:NUMBER,PhBrowse.Q.PH:NUMBER)

 PhBrowse.InsertControl=?Insert

 PhBrowse.ChangeControl=?Change

 PhBrowse.DeleteControl=?Delete

 SELF.SetAlerts()                    !alert keys for ThisWindow

 RETURN ReturnValue

ThisWindow.Kill  PROCEDURE()          !shut down ThisWindow

ReturnValue    BYTE,AUTO

 CODE

 ReturnValue = PARENT.Kill()         !call base class WindowManager.Kill

 Relate:Customer.Close               !close Customer & related files

 Relate:State.Close                  !close State & related files

 Relate:Customer.Kill                !shut down Relate:Customer object

 Relate:State.Kill                   !shut down Relate:State object

 Relate:Phones.Kill                  !shut down Relate:Phones object

 GlobalErrors.Kill                   !shut down GlobalErrors object

 RETURN ReturnValue

ThisWindow.Run  PROCEDURE(USHORT Number,BYTE Request)!call other procedures

ReturnValue    BYTE,AUTO

 CODE

 GlobalRequest = Request             !set inter procedure request

 EXECUTE Number                      !run specified procedure

   SelectState

 END

 ReturnValue = GlobalResponse        !set inter procedure response

 RETURN ReturnValue

ThisWindow.TakeAccepted  PROCEDURE()  !EVENT:Accepted handling

ReturnValue        BYTE,AUTO

Looped BYTE

CODE

LOOP

 IF Looped THEN RETURN Level:Notify ELSE Looped = 1.!allow CYCLE to work

 ReturnValue = PARENT.TakeAccepted()   !do standard EVENT:Accepted

 CASE ACCEPTED()                       !do special EVENT:Accepted

 OF ?CUS:State                         ! on State field

  ST:STATECODE = CUS:State             ! lookup State code

  IF Access:State.Fetch(ST:StateCodeKey) ! if not found

   IF SELF.Run(1,SelectRecord) = RequestCompleted ! let user select one

    CUS:State = ST:STATECODE           ! set selected state

   ELSE                                ! if user didn't select one

    SELECT(?CUS:State)                 ! focus on State field

    CYCLE                              ! start over

   END

  END

  ThisWindow.Reset()                   !reset ThisWindow if needed

 END

 RETURN ReturnValue

END

windowmanager_overview.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1