BBjStandardGrid::getCellStyle

Description

Returns the style of a cell in the BBjStandardGrid.

Syntax

Return Value

Method

int

getCellStyle(int row, int column)

Parameters

Variable

Description

row

Specifies the 0-based row.

column

Specifies the 0-based column.

Return Value

Returns one of the following styles of the specified cell listed below:

Style Value Constants:

 

GRID_STYLE_BUTTON_DOWN

Recessed button

GRID_STYLE_BUTTON_UP

Raised button

GRID_STYLE_CHECKED

Checked checkbox

GRID_STYLE_INPUTD

InputD

GRID_STYLE_INPUTE

InputE

GRID_STYLE_INPUTN

InputN

GRID_STYLE_PASSWORD

Password edit box

GRID_STYLE_TEXT

Text field

GRID_STYLE_UNCHECKED

Unchecked checkbox

Remarks

By default, the default cell style is GRID_STYLE_INPUTE. Cell styles GRID_STYLE_TEXT support HTML tags.

Example

rem 'Get the style of a cell in a BBjGrid object

rem 'Obtain the instance of the BBjAPI object
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 'Create the main window and control objects
GOSUB CreateCalendar

rem 'Display the initial data
GOSUB DisplayMonth

rem 'Determine the cell style of the cell at (1,1) in the calendar
CELL_STYLE = Calendar!.getCellStyle(1,1)
SWITCH CELL_STYLE
    CASE mySysGui!.GRID_STYLE_INPUTE
        CELL_STYLE_STR$="InputE"
        break
    CASE mySysGui!.GRID_STYLE_BUTTON_UP
        CELL_STYLE_STR$="Raised Button"
        break
    CASE mySysGui!.GRID_STYLE_BUTTON_DOWN
        CELL_STYLE_STR$="Recessed Button"
        break
    CASE mySysGui!.GRID_STYLE_CHECKED
        CELL_STYLE_STR$="Checked Checkbox"
        break
    CASE mySysGui!.GRID_STYLE_UNCHECKED
        CELL_STYLE_STR$="Unchecked Checkbox"
        break
    CASE mySysGui!.GRID_STYLE_TEXT
        CELL_STYLE_STR$="Text Field"
        break
    CASE mySysGui!.GridInputN
        CELL_STYLE_STR$="InputN"
        break
    CASE DEFAULT
        CELL_STYLE_STR$="Undefined"
        break
SWEND

rem 'Print out the cell style, this will print out "InputE"
PRINT "CELL (1,1) STYLE = " + CELL_STYLE_STR$

rem 'Display the main window
MainWindow!.setVisible(mySysGui!.TRUE)

rem 'Register the CALLBACK routines
CALLBACK(ON_CLOSE,DoAppClose,CalendarContext)

rem 'Process Events
process_events

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

rem 'Subroutine called to display the days in the current selected month/year
DisplayMonth:
    let DayNum=0
    let FirstDayOfMonth=DayTable!.get(DATE(JUL(CurrentYear,CurrentMonth,1):"%Ds"))
    let DaysInMonth=FNDaysInMonth(CurrentYear,CurrentMonth)
    MonthVector!.clear()
    if (CurrentDay>DaysInMonth+1) then
        CurrentDay=DaysInMonth+1
    endif
    let CurrentJul=JUL(CurrentYear,CurrentMonth,CurrentDay)

    rem 'Week 0
    FOR DayOfWeek=0 TO 6
        if (FirstDayOfMonth>DayOfWeek) then
            let Item$=STR(0:DayMask$)
        else
            let Item$=STR(DayNum+1:DayMask$)
            let DayNum=DayNum+1
        endif
        MonthVector!.addItem(Item$)
    NEXT DayOfWeek

    rem 'Week 1-3
    FOR Week=1 TO 3
        FOR DayOfWeek=0 TO 6
            let Item$=STR(DayNum+1:DayMask$)
            let DayNum=DayNum+1
            MonthVector!.addItem(Item$)
        NEXT DayOfWeek
    NEXT Week

    rem 'Week 4-5
    FOR week=4 TO 5
        FOR DayOfWeek=0 TO 6
            if (DayNum>DaysInMonth) then
                let Item$=STR(0:DayMask$)
            else
                let Item$=STR(DayNum+1:DayMask$)
                let DayNum=DayNum+1
            endif
            MonthVector!.addItem(Item$)
        NEXT DayOfWeek
    NEXT week

    rem 'Set the current information
    Calendar!.setCellText(MonthVector!)
    let CurrRow=INT((FirstDayOfMonth+CurrentDay-1)/7)
    let CurrCol=MOD(FirstDayOfMonth+CurrentDay-1,7)
    Calendar!.setSelectedCell(CurrRow,CurrCol)
    let CurrentMonthYear$=DATE(CurrentJul:"%Ml %Y")
    CurrDate!.setText(CurrentMonthYear$)
    Calendar!.setCellText(5,5," To")
    Calendar!.setCellText(5,6,"day ")
return

rem 'Function called to return the number of days in the passed year and month
DEF FNDaysInMonth(fYear,fMonth)

rem 'calculate the number of days in a month - zero based
let DaysInMonth=30
if (fMonth<>12) then
    let DaysInMonth=NUM(DATE(JUL(fYear,fMonth+1,1)-1:"%D"))-1
endif
return DaysInMonth
FNEND

rem 'Subroutine called to create the calendar
CreateCalendar:
    rem 'Create the vector to hold month info
    let MonthVector!=mySysGui!.makeVector()

    rem 'Create a java hash table to hold day names
    let DayTable!=new java.util.Hashtable()

    rem 'Get standard date info from the STRING table
    DIM DateInfo$:"Mask:C(32*=0),SM[12]:C(3*=0),M[12]:C(32*=0),SD[7]:C(3*=0),D[7]:C(32*=0)"
    let DateInfo$=STBL("!DATE")

    rem 'Build the masks for the dates
    let dateMask$=DateInfo.Mask$
    let M=POS("%M"=dateMask$),dateMask$=dateMask$(1,M+1)+"l"+dateMask$(M+3)
    let M=POS("%Y"=dateMask$),dateMask$=dateMask$(1,M+1)+dateMask$(M+3)
    while POS("/"=dateMask$)
        let M=POS("/"=dateMask$),dateMask$(M,1)=" "
    wend

    rem 'Build the day table
    FOR X=0 TO 6
        let Item$=DateInfo.SD$[x+1]
        DayTable!.put(Item$,x)
    NEXT X

    rem 'Get current date info
    let CurrentDate$=DATE(CurrentJul:dateMask$)
    let CurrentMonthYear$=DATE(CurrentJul:"%Ml %Y")
    let CurrentDay=NUM(DATE(CurrentJul:"%Dz"))
    let CurrentMonth=NUM(DATE(CurrentJul:"%Mz"))
    let CurrentYear=NUM(DATE(CurrentJul:"%Y"))

    rem 'Misc
    let TITLE$="BBjGrid"
    let DayMask$="##B"
    let CurrentJul=0,CalX=400,CalY=400

    rem 'Get the next available context
    let CalendarContext=mySysGui!.getAvailableContext()
    mySysGui!.setContext(CalendarContext)

    rem 'Create the main window
    let MainWindow! = mySysGui!.addWindow(100,100,202,160,TITLE$,$00010013$)

    rem 'Add the calender (grid) to the main window
    let Calendar! = MainWindow!.addGrid(100,3,26,198,121)

    rem 'Set the attributes of the grid
    Calendar!.setGridEditable(1)
    blueColor! = mySysGui!.makeColor(mySysGui!.BLUE)
    Calendar!.setColumnHeaderForeColor(blueColor!)
    Calendar!.setNumRows(6)
    Calendar!.setRowHeight(20)
    Calendar!.setNumColumns(7)
    Calendar!.setMaxColumns(255)
    Calendar!.setHasColumnHeader(mySysGui!.TRUE)
    Calendar!.setVerticalLinesVisible(mySysGui!.TRUE)
    Calendar!.setHorizontalLinesVisible(mySysGui!.TRUE)
    Calendar!.setClientEdge(mySysGui!.TRUE)
    Calendar!.setSelectionMode(Calendar!.GRID_SELECT_CELL)

    rem 'Set the attributes for the grid's columns
    FOR COL = 0 TO 6
        Calendar!.setColumnWidth(COL, 25)
        Calendar!.setColumnAlignment(COL, Calendar!.GRID_ALIGN_RIGHT)
        Calendar!.setColumnForeColor(COL, blueColor!)
    NEXT COL
    Calendar!.setColumnHeaderStyle(Calendar!.GRID_STYLE_BUTTON_UP)

    rem 'Set the attributes for the grid's column headers
    myVector! = mySysGui!.makeVector()
    myVector!.addItem("S")
    myVector!.addItem("M")
    myVector!.addItem("T")
    myVector!.addItem("W")
    myVector!.addItem("T")
    myVector!.addItem("F")
    myVector!.addItem("S")
    Calendar!.setColumnHeaderText(myVector!)
    Calendar!.setColumnHeaderForeColor(blueColor!)

    rem 'Set the attributes for the current date (static text control)
    let CurrDate! = MainWindow!.addStaticText(101,45,3,90,20,"")
    CurrDate!.setClientEdge(mySysGui!.TRUE)
    CurrDate!.setForeColor(blueColor!)
return

See Also

BBjAPI

BBjSysGui

BBjControl

BBjWindow

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