Classes

Class XbpScrollBar() Foundation

Class function of the XbpScrollBar class.

Superclass
Description

The XbpScrollBar class provides objects that display and manage horizontal and vertical scroll bars. This dialog element is often used when all of the data to be displayed cannot be shown within a window. The scroll bars are used to scroll the drawing area of the window so that hidden data becomes visible in the window area.

A scroll bar consists of four elements that allow interaction: two scroll buttons at each end, a movable scroll box and a scroll bar where the scroll box is moved. Depending on which part of the scroll bar is clicked, different actions are performed. The :scroll callback code block or the :scroll() callback method is used to react to user interaction with the scroll bar and processes the current position of the scroll box.

Scroll bars are passive dialog elements. If the scroll box is operated using the mouse, the scroll bar object does not receive the input focus. Instead, the input focus remains on the Xbase Part that was active before the scroll bar object was manipulated. To explicitly set the input focus to an XbpScrollbar object, the function SetAppFocus() must be used.

Class methods
:new()
Creates an instance of the XbpScrollBar class.
Configuration

The instance variables in this group configure system resources. If changes are made to these values, they must either be made before the :create() method is executed or the :configure() method must be used to activate the changes.

:autoTrack
Automatically updates the position of the scroll box.
:range
Determines the value range of the scroll bar.
:scrollBoxSize
Sets the size of the scroll box.
:type
Determines whether the scroll bar is horizontal or vertical.
:excludeScrollbox
Exclude the scrollbox from the range.
Life cycle
:create()
Requests system resources for the XbpScrollBar object.
:configure()
Reconfigures the XbpScrollBar object after :create() has been executed.
:destroy()
Releases the system resources of the XbpScrollBar object.
Manipulation
:getData()
Returns the current position of the scroll box.
:setData()
Sets the current position of the scroll box.
:setRange()
Sets or returns the value range for the scroll bar.
:setScrollBoxSize()
Sets or returns the size of scroll box.
Events
:wheel / xbeM_Wheel
Mouse wheel is activated.
:scroll / xbeSB_Scroll
Scroll bar has been moved.
Examples
Moving the record pointer using a scroll bar

// This example demonstrates how the actions of a vertical 
// scroll bar can be used to navigate within a database. 
// Three SLEs are created to display field data and the 
// record number. Database navigation is performed in the 
// scrollVertical() UDF, where the possible actions are 
// handled in a DO CASE structure. 

#include "Xbp.ch" 
#include "AppEvent.ch" 

PROCEDURE Main 
   LOCAL nEvent, mp1, mp2, oXbp 
   LOCAL oSle1, oSle2, oSle3 

   SetColor( "N/W" ) 
   CLS 
   USE Customer NEW 
   // Create 3 SLEs for displaying values from the database 
   oSle1 := XbpSLE():new( ,, {100,270}, {130,30} ) 
   oSle1:dataLink := {|| Customer->LastName } 
   oSle1:create():setData() 

   oSle2 := XbpSLE():new( ,, {100,200}, {130,30} ) 
   oSle2:dataLink := {|| Customer->FirstName } 
   oSle2:create():setData() 

   oSle3 := XbpSLE():new( ,, {100,130}, {130,30} ) 
   oSle3:dataLink := {|| Transform( Customer->(Recno()),"@N" ) } 
   oSle3:create():setData() 

   // Scroll bar for database navigation 
   oXbp := XbpScrollbar():new() 
   oXbp:type := XBPSCROLL_VERTICAL 
   oXbp:range:= { 1, LastRec() }         // Max. 32768 
   oXbp:create( ,, {250,130}, {15,170} ) 
   oXbp:scroll := {|mp1| scrollVertical( mp1[1], mp1[2] ), ; 
                         oSle1:setData(), ; 
                         oSle2:setData(), ; 
                         oSle3:setData()  } 
   nEvent := 0 
   // Event loop 
   DO WHILE nEvent <> xbeP_Close 
      nEvent := AppEvent( @mp1, @mp2, @oXbp ) 
      oXbp:handleEvent( nEvent, mp1, mp2 ) 
   ENDDO 
RETURN 

// Process scroll bar events 
PROCEDURE scrollVertical( nScrlPos, nCommand ) 
   DO CASE 
   CASE nCommand == XBPSB_PREVPOS 
        SKIP -1 
   CASE nCommand == XBPSB_NEXTPOS 
        SKIP  1 
   CASE nCommand == XBPSB_PREVPAGE 
        GOTO nScrlPos 
   CASE nCommand == XBPSB_NEXTPAGE 
        GOTO nScrlPos 
   CASE nCommand == XBPSB_SLIDERTRACK 
        // Nothing 
   CASE nCommand == XBPSB_ENDTRACK 
        GOTO nScrlPos 
   CASE nCommand == XBPSB_ENDSCROLL 
        GOTO nScrlPos 
   ENDCASE 
RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.