BBjPrintPreview::getIndex

Description

In BBj 7.0 and higher, this BBjPrintPreview method gets the index of the currently displayed page.

Syntax

Return Value

Method

int

getIndex()

Parameters

None.

Return Value

Returns the index of the current page.

Remarks

None.

Example

rem ' BBjPrintPreview::getIndex

let myAPI! = BBjAPI()

rem 'Open the SysGui device
SYSGUI = UNT
OPEN (SYSGUI)"X0"

rem 'Obtain the instance of the BBjSysGui object
let mySysGui! = myAPI!.getSysGui()

rem 'Set addWindow param values
X = 10
Y = 10
WIDTH = 800
HEIGHT = 600
TITLE$="BBjPrintPreview::getIndex"

rem 'Set the current context
mySysGui!.setContext(0)

rem 'Create a window
myWindow! = mySysGui!.addWindow(X,Y,WIDTH,HEIGHT,TITLE$,$00010003$)

rem 'Add a print preview control to the window
myPreview! = myWindow!.addPrintPreview(101,50,100,700,450,"",$$)
myPreview!.fitToWidth()

myImageManager! = mySysGui!.getImageManager()

myFirst! = myWindow!.addMenuButton(102,50,50,24,24,"",$$)
first$ = "com/basis/bbj/images/first.gif"
first! = myImageManager!.loadImageFromServerJar(first$)
myFirst!.setImage(first!)
myFirst!.setToolTipText("First page")

myPrevious! = myWindow!.addMenuButton(103,75,50,24,24,"",$$)
previous$ = "com/basis/bbj/images/prev.gif"
previous! = myImageManager!.loadImageFromServerJar(previous$)
myPrevious!.setImage(previous!)
myPrevious!.setToolTipText("Previous page")

myNext! = myWindow!.addMenuButton(104,100,50,24,24,"",$$)
next$ = "com/basis/bbj/images/next.gif"
next! = myImageManager!.loadImageFromServerJar(next$)
myNext!.setImage(next!)
myNext!.setToolTipText("Next page")

myLast! = myWindow!.addMenuButton(105,125,50,24,24,"",$$)
last$ = "com/basis/bbj/images/last.gif"
last! = myImageManager!.loadImageFromServerJar(last$)
myLast!.setImage(last!)
myLast!.setToolTipText("Last page")

myMessage! = myWindow!.addStaticText(107,700,50,50,24,"",$8000$)

form! = myAPI!.getBBjPrinter(0).getForm(0)
for page = 0 to 9
    page! = form!.createPage()
    for para = 0 to 19
        para! = page!.newParagraph()
        para!.setPosition(para,para*20)
        para!.setHorizontalFill(1)
        para$ = "Sample text for print job "+str(para)
        para!.setText(para$)
        page!.add(para!)
    next para
next page
form!.preview(myPreview!)

gosub PageNumber

rem 'Register the CALLBACK routines
CALLBACK(ON_CLOSE,APP_CLOSE,mySysGui!.getContext())
CALLBACK(ON_BUTTON_PUSH,FIRST_PAGE,mySysGui!.getContext(),myFirst!.getID())
CALLBACK(ON_BUTTON_PUSH,PREV_PAGE,mySysGui!.getContext(),myPrevious!.getID())
CALLBACK(ON_BUTTON_PUSH,NEXT_PAGE,mySysGui!.getContext(),myNext!.getID())
CALLBACK(ON_BUTTON_PUSH,LAST_PAGE,mySysGui!.getContext(),myLast!.getID())

rem 'Process Events
process_events

rem 'Callback routine called when the user closes the application window
APP_CLOSE:
release

FIRST_PAGE:
    myPreview!.setIndex(0)
    gosub PageNumber
return

PREV_PAGE:
    myPreview!.setIndex(myPreview!.getIndex() - 1)
    gosub PageNumber
return

NEXT_PAGE:
    myPreview!.setIndex(myPreview!.getIndex() + 1)
    gosub PageNumber
return

LAST_PAGE:
    myPreview!.setIndex(myPreview!.getPageCount() - 1)
    gosub PageNumber
return

PageNumber:
    myMessage!.setText("Page: "+STR(myPreview!.getIndex()+1))
return

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.