Navigation: ABC Library Reference > ToolbarListBoxClass >====== ToolbarListBoxClass Overview ====== | |
The ToolbarListBoxClass is a ToolbarTarget that handles events for a BrowseClass LIST. See BrowseClass and Control Templates--BrowseBox for more information.
ToolbarListboxClass Concepts
ToolbarListBoxClass objects implement the event handling specific to a BrowseClass LIST. The LIST specific events are primarily scrolling events, but also include the event to select a single list item (EVENT:Accepted for a Select button). There may be zero or several ToolbarTarget objects within a procedure; however, only one is active at a time.
ToolbarListBoxClass Relationship to Other Application Builder Classes
The ToolbarListboxClass is derived from the ToolbarTarget class.
The ToolbarClass keeps a list of ToolbarTarget objects (including ToolbarListboxClass objects) so it can forward events and method calls to a particular target.
ToolbarListBoxClass ABC Template Implementation
The ToolbarListboxClass is completely encapsulated within the BrowseClass and is not referenced in the template-generated code.
ToolbarListboxClass Source Files
The ToolbarListboxClass source code is installed by default to the Clarion \LIBSRC folder. The ToolbarListboxClass source code and its respective components are contained in:
ABTOOLBA.INC | ToolbarListboxClass declarations |
ABTOOLBA.CLW | ToolbarListboxClass method definitions |
ToolbarListBoxClass Conceptual Example
The following example shows a typical sequence of statements to declare, instantiate, initialize, use, and terminate a ToolbarClass object and related ToolbarListboxClass objects.
This example uses a global toolbar to drive two separate but related LISTs within a single MDI procedure. The primary LIST shows client information and the related LIST shows phone numbers for the selected client. The toolbar drives whichever list has focus. See also ToolbarUpdateClass–Conceptual Example.
The program POSTs toolbar events to the active MDI window using the SYSTEM{Prop:Active} property. Then the local ToolbarClass object calls on the active ToolbarTarget object to handle the event.
PROGRAM
INCLUDE('ABBROWSE.INC') !declare BrowseClass
INCLUDE('ABTOOLBA.INC') !declare Toolbar classes
INCLUDE('ABWINDOW.INC') !declare WindowManager
CODE
!program code
Main PROCEDURE !contains global toolbar
AppFrame APPLICATION('Toolbars'),AT(,,275,175),SYSTEM,MAX,RESIZE,IMM
MENUBAR
ITEM('Browse Customers'),USE(?BrowseCustomer)
END
TOOLBAR,AT(0,0,400,22) !must use ABTOOLBA.INC EQUATES:
BUTTON,AT(4,2),USE(?Top,Toolbar:Top),DISABLE,ICON('VCRFIRST.ICO'),FLAT
BUTTON,AT(16,2),USE(?PageUp,Toolbar:PageUp),DISABLE,ICON('VCRPRIOR.ICO'),FLAT
BUTTON,AT(28,2),USE(?Up,Toolbar:Up),DISABLE,ICON('VCRUP.ICO'),FLAT
BUTTON,AT(40,2),USE(?Down,Toolbar:Down),DISABLE,ICON('VCRDOWN.ICO'),FLAT
BUTTON,AT(52,2),USE(?PageDown,Toolbar:PageDown),DISABLE,ICON('VCRNEXT.ICO'),FLAT
BUTTON,AT(64,2),USE(?Bottom,Toolbar:Bottom),DISABLE,ICON('VCRLAST.ICO'),FLAT
END
END
Frame CLASS(WindowManager)
Init PROCEDURE(),BYTE,PROC,VIRTUAL
TakeAccepted PROCEDURE(),BYTE,PROC,VIRTUAL
END
Toolbar ToolbarClass !declare Toolbar object
CODE
Frame.Run()
Frame.Init PROCEDURE()
ReturnValue BYTE,AUTO
CODE
ReturnValue = PARENT.Init()
SELF.VCRRequest &= VCRRequest
SELF.Errors &= GlobalErrors
SELF.AddItem(Toolbar) !register Toolbar with WindowManager
OPEN(AppFrame)
SELF.Opened=True
SELF.SetAlerts()
RETURN ReturnValue
Frame.TakeAccepted PROCEDURE()
ReturnValue BYTE,AUTO
Looped BYTE
CODE
CASE ACCEPTED()
OF Toolbar:First TO Toolbar:Last !for EVENT:Accepted on toolbar
POST(EVENT:Accepted,ACCEPTED(),SYSTEM{Prop:Active}) !transfer it to active thread
RETURN Level:Notify
OF ?BrowseCustomer
START(BrowseCustomer,050000)
END
RETURN PARENT.TakeAccepted()
BrowseCustomer PROCEDURE !contains local Toolbar and targets
CusView VIEW(Customer)
END
CusQ QUEUE
CUS:CUSTNO LIKE(CUS:CUSTNO)
CUS:NAME LIKE(CUS:NAME)
ViewPosition STRING(512)
END
PhView VIEW(Phones)
END
PhQ QUEUE
PH:NUMBER LIKE(PH:NUMBER)
PH:ID LIKE(PH:ID)
ViewPosition STRING(512)
END
CusWindow WINDOW('Browse Customers'),AT(,,246,131),IMM,SYSTEM,GRAY,MDI
LIST,AT(8,7,160,100),USE(?CusList),IMM,HVSCROLL,FROM(CusQ),|
FORMAT('51R(2)|M~CUSTNO~C(0)@n-14@80L(2)|M~NAME~@s30@')
BUTTON('&Insert'),AT(17,111,45,14),USE(?InsertCus),SKIP
BUTTON('&Change'),AT(66,111,45,14),USE(?ChangeCus),SKIP,DEFAULT
BUTTON('&Delete'),AT(115,111,45,14),USE(?DeleteCus),SKIP
LIST,AT(176,7,65,100),USE(?PhList),IMM,FROM(PhQ),|
FORMAT('80L~Phones~L(1)@s20@')
BUTTON('&Insert'),AT(187,41,42,12),USE(?InsertPh),HIDE
BUTTON('&Change'),AT(187,54,42,12),USE(?ChangePh),HIDE
BUTTON('&Delete'),AT(187,67,42,12),USE(?DeletePh),HIDE
END
ThisWindow CLASS(WindowManager) !declare ThisWindow object
Init PROCEDURE(),BYTE,PROC,VIRTUAL
Kill PROCEDURE(),BYTE,PROC,VIRTUAL
TakeSelected PROCEDURE(),BYTE,PROC,VIRTUAL
END
Toolbar ToolbarClass !declare Toolbar object to receive
! and process toolbar events from Main
CusBrowse CLASS(BrowseClass) !declare CusBrowse object
Q &CusQ
END
PhBrowse CLASS(BrowseClass) !declare PhBrowse object
Q &PhQ
END
CODE
ThisWindow.Run()
ThisWindow.Init PROCEDURE()
ReturnValue BYTE,AUTO
CODE
ReturnValue = PARENT.Init()
SELF.FirstField = ?CusList !CusList gets initial focus
SELF.VCRRequest &= VCRRequest
SELF.Errors &= GlobalErrors
SELF.AddItem(Toolbar) !register Toolbar with WindowManager
Relate:Customer.Open
CusBrowse.Init(?CusList,CusQ.ViewPosition,CusView,CusQ,Relate:Customer,SELF)
PhBrowse.Init(?PhList,PhQ.ViewPosition,PhView,PhQ,Relate:Phones,SELF)
OPEN(CusWindow)
SELF.Opened=True
CusBrowse.Q &= CusQ
CusBrowse.AddSortOrder(,CUS:BYNUMBER)
CusBrowse.AddField(CUS:CUSTNO,CusBrowse.Q.CUS:CUSTNO)
CusBrowse.AddField(CUS:NAME,CusBrowse.Q.CUS:NAME)
PhBrowse.Q &= PhQ
PhBrowse.AddSortOrder(,PH:IDKEY)
PhBrowse.AddRange(PH:ID,Relate:Phones,Relate:Customer)
PhBrowse.AddField(PH:NUMBER,PhBrowse.Q.PH:NUMBER)
PhBrowse.AddField(PH:ID,PhBrowse.Q.PH:ID)
CusBrowse.InsertControl=?InsertCus
CusBrowse.ChangeControl=?ChangeCus
CusBrowse.DeleteControl=?DeleteCus
CusBrowse.AddToolbarTarget(Toolbar) !Make CusBrowse a toolbar target
PhBrowse.InsertControl=?InsertPh
PhBrowse.ChangeControl=?ChangePh
PhBrowse.DeleteControl=?DeletePh
PhBrowse.AddToolbarTarget(Toolbar) !Make PhBrowse a toolbar target
SELF.SetAlerts()
RETURN ReturnValue
ThisWindow.Kill PROCEDURE()
ReturnValue BYTE,AUTO
CODE
ReturnValue = PARENT.Kill()
Relate:Customer.Close
RETURN ReturnValue
ThisWindow.TakeSelected PROCEDURE()
ReturnValue BYTE,AUTO
CODE
ReturnValue = PARENT.TakeSelected()
CASE FIELD()
OF ?CusList !if selected,
Toolbar.SetTarget(?CusList) ! make ?CusList the active target
OF ?PhList !if selected
IF RECORDS(PhBrowse.Q) > 1 !and contains more than one record,
Toolbar.SetTarget(?PhList) ! make ?PhList the active target
END
END
RETURN ReturnValue