EditClass Conceptual Example

Top  Previous  Next

The following example shows a sequence of statements to declare, instantiate, initialize, use, and terminate several EditClass objects and a related BrowseClass object. The example page-loads a LIST of fieldnames and associated control attributes (such as color, icon, etc.), then edits the list items with a variety of edit-in-place objects. Note that the BrowseClass object calls the "registered" EditClass objects' methods as needed.

 PROGRAM

_ABCDllMode_  EQUATE(0)

_ABCLinkMode_ EQUATE(1)

 

  INCLUDE('ABWINDOW.INC')     !declare WindowManager

  INCLUDE('ABBROWSE.INC')     !declare BrowseClass

  INCLUDE('ABEIP.INC')        !declare Edit-in-place classes

  MAP

  END

 

Property  FILE,DRIVER('TOPSPEED'),PRE(PR),CREATE,BINDABLE,THREAD

NameKey    KEY(PR:FieldName),NOCASE,OPT

Record     RECORD,PRE()

FieldName   STRING(30)

Color       STRING(20)

Hidden      STRING(1)

IconFile    STRING(30)

ControlType STRING(12)

          END

         END

 

PropView   VIEW(Property)

          END

 

PropQ     QUEUE

PR:FieldName   LIKE(PR:FieldName)

PR:Color       LIKE(PR:Color)

PR:ControlType LIKE(PR:ControlType)

PR:Hidden      LIKE(PR:Hidden)

PR:IconFile    LIKE(PR:IconFile)

ViewPosition   STRING(1024)            

         END

PropWindow WINDOW('Browse Field Properties'),AT(,,318,137),IMM,SYSTEM,GRAY

       LIST,AT(8,4,303,113),USE(?PropList),IMM,HVSCROLL,FROM(PropQ),|

       FORMAT( '50L(2)|_M~Field Name~@s30@[70L(2)|_M~Color~@s20@' &|

           '60L(2)|_M~Control Type~@s12@' &|

           '20L(2)|_M~Hide~L(0)@s1@/130L(2)|_M~Icon File~@s30@]|M')

       BUTTON('&Insert'),AT(169,121),USE(?Insert)

       BUTTON('&Change'),AT(218,121),USE(?Change),DEFAULT

       BUTTON('&Delete'),AT(267,121),USE(?Delete)

          END

Edit:PR:FieldName  EditEntryClass !declare Edit:PR:FieldName-EIP ENTRY control

 

Edit:PR:Color CLASS(EditColorClass) !declare Edit:PR:Color-EIP color dialog

Init         PROCEDURE(UNSIGNED FieldNumber,UNSIGNED ListBox,*? UseVar),VIRTUAL

             END

 

Edit:PR:Hide  CLASS(EditCheckClass) !declare Edit:PR:Color-EIP CHECK control

Init         PROCEDURE(UNSIGNED FieldNumber,UNSIGNED ListBox,*? UseVar),VIRTUAL

             END

Edit:PR:IconFile CLASS(EditFileClass)!declare Edit:PR:IconFile-EIP file dialog

Init         PROCEDURE(UNSIGNED FieldNumber,UNSIGNED ListBox,*? UseVar),VIRTUAL

                END

 

Edit:PR:ControlType CLASS(EditDropListClass) !declare Edit:PR:ContolType-EIP droplist

Init         PROCEDURE(UNSIGNED FieldNumber,UNSIGNED ListBox,*? UseVar),VIRTUAL

                   END

 

ThisWindow CLASS(WindowManager)

Init          PROCEDURE(),BYTE,PROC,VIRTUAL

Kill          PROCEDURE(),BYTE,PROC,VIRTUAL

          END

 

BRW1       CLASS(BrowseClass)  !declare BRW1, the BrowseClass object

Q           &PropQ         ! that drives the EditClass objects--

          END           ! i.e. calls Init, TakeEvent, Kill

 

GlobalErrors    ErrorClass

Access:Property   CLASS(FileManager)

Init          PROCEDURE

                 END

 

Relate:Property  CLASS(RelationManager)

Init         PROCEDURE

Kill         PROCEDURE,VIRTUAL

                END

GlobalRequest    BYTE(0),THREAD

GlobalResponse   BYTE(0),THREAD

VCRRequest       LONG(0),THREAD

CODE

GlobalErrors.Init

Relate:Property.Init

GlobalResponse = ThisWindow.Run()

Relate:Property.Kill

GlobalErrors.Kill

 

ThisWindow.Init PROCEDURE()

ReturnValue    BYTE,AUTO

CODE

SELF.Request = GlobalRequest

ReturnValue = PARENT.Init()

SELF.FirstField = ?PropList

SELF.VCRRequest &= VCRRequest

SELF.Errors &= GlobalErrors

Relate:Property.Open

BRW1.Init(?PropList,PropQ.ViewPosition,PropView,PropQ,Relate:Property,SELF)

OPEN(PropWindow)

SELF.Opened=True

?PropList{PROP:LineHeight}=12   !enlarge rows to accomodate EditClass icons

 BRW1.Q &= PropQ

 BRW1.AddSortOrder(,PR:NameKey)

 BRW1.AddField(PR:FieldName,BRW1.Q.PR:FieldName)

 BRW1.AddField(PR:Color,BRW1.Q.PR:Color)

 BRW1.AddField(PR:ControlType,BRW1.Q.PR:ControlType)

 BRW1.AddField(PR:Hidden,BRW1.Q.PR:Hidden)

 BRW1.AddField(PR:IconFile,BRW1.Q.PR:IconFile)

 BRW1.AddEditControl(Edit:PR:FieldName,1)   !Register Edit:PR:FieldName with BRW1

 BRW1.AddEditControl(Edit:PR:Color,2)       !Register Edit:PR:Color with BRW1

 BRW1.AddEditControl(Edit:PR:ControlType,3) !Register Edit:PR:ControlType with BRW1

 BRW1.AddEditControl(Edit:PR:Hide,4)        !Register Edit:PR:Hide with BRW1

 BRW1.AddEditControl(Edit:PR:IconFile,5)    !Register Edit:PR:IconFile with BRW1

 BRW1.ArrowAction = EIPAction:Default+EIPAction:Remain+EIPAction:RetainColumn

 BRW1.InsertControl=?Insert

 BRW1.ChangeControl=?Change

 BRW1.DeleteControl=?Delete

 SELF.SetAlerts()

 RETURN ReturnValue

 

ThisWindow.Kill PROCEDURE()

ReturnValue    BYTE,AUTO

 CODE

 ReturnValue = PARENT.Kill()

 Relate:Property.Close

 RETURN ReturnValue

 

Edit:PR:Color.Init PROCEDURE(UNSIGNED FieldNumber,UNSIGNED ListBox,*? UseVar)

CODE

PARENT.Init(FieldNumber,ListBox,UseVar)

SELF.Title='Select field color'   !set EIP color dialog title

 

Edit:PR:Hide.Init PROCEDURE(UNSIGNED FieldNumber,UNSIGNED ListBox,*? UseVar)

CODE

PARENT.Init(FieldNumber,ListBox,UseVar)

SELF.Feq{PROP:Text}='Hide '     !set EIP check box text

SELF.Feq{PROP:Value,1}='Y'      !set EIP check box true value

SELF.Feq{PROP:Value,2}='N'      !set EIP check box false value

 

Edit:PR:IconFile.Init PROCEDURE(UNSIGNED FieldNumber,UNSIGNED ListBox,*? UseVar)

 CODE

 PARENT.Init(FieldNumber,ListBox,UseVar)

 SELF.Title='Select icon file'               !set EIP file dialog title

 SELF.FilePattern='Icon files *.ico|*.ico'   !set EIP file dialog file masks

 SELF.FileMask=FILE:KeepDir+FILE:LongName    !set EIP file dialog behavior flag

 

Edit:PR:ControlType.Init PROCEDURE(UNSIGNED FieldNumber,UNSIGNED ListBox,*? UseVar)

CODE

PARENT.Init(FieldNumber,ListBox,UseVar)

SELF.Feq{PROP:From}='ENTRY|SPIN|TEXT|STRING' !set ControlType droplist choices

 

Access:Property.Init PROCEDURE                !initialize FileManager

CODE

PARENT.Init(Property,GlobalErrors)

SELF.FileNameValue = 'Property'

SELF.Buffer &= PR:Record

SELF.Create = 1

SELF.AddKey(PR:NameKey,'PR:NameKey',0)

 

Relate:Property.Init PROCEDURE                !initialize RelationManager

CODE

Access:Property.Init

PARENT.Init(Access:Property,1)

 

Relate:Property.Kill PROCEDURE                !shut down RelationManager

CODE

Access:Property.Kill

PARENT.Kill