BBjStandardGrid

Description

A BBjStandardGrid provides methods for manipulating a standard grid control in BBj. For Data Aware grids see BBjDataAwareGrid. The BBjStandardGrid extends the BBjGrid object and therefore implements all methods in the BBjGrid. A BBjStandardGrid can be converted to a BBjDataAwareGrid using the method BBjStandardGrid::convertToDataAware. After conversion, the BBjStandardGrid object is no longer valid.

Implemented Interfaces

CommonGrid, Focusable, MouseWheelEnabled, TabTraversable, Validateable

Creation

BBjAPI > BBjSysGui > BBjWindow > BBjStandardGrid

A BBjStandardGrid object is created through the following BBjWindow methods:

Return Value Method
BBjStandardGrid addGrid()
BBjStandardGrid addGrid(int ID)
BBjStandardGrid addGrid(int ID, int rowHeaderID, int columnHeaderID, number x, number y, number w, number h)
BBjStandardGrid addGrid(int ID, int rowHeaderID, int columnHeaderID, number x, number y, number w, number h, string flags)
BBjStandardGrid addGrid(int ID, int rowHeaderID, int columnHeaderID, number x, number y, number w, number h, string flags, int rows, int columns)
BBjStandardGrid addGrid(int ID, number x, number y, number w, number h)
BBjStandardGrid addGrid(int ID, number x, number y, number w, number h, string flags)
BBjStandardGrid addGrid(int ID, number x, number y, number w, number h, string flags, int rows, int columns)
BBjStandardGrid addGrid(int ID, string flags)
BBjStandardGrid addGrid(int ID, string flags, int rows, int columns)
BBjStandardGrid addGrid(string flags)
BBjStandardGrid addGrid(string flags, int rows, int columns)

Methods of BBjStandardGrid – Grid Headers

Return Value

Method

int

getHasRowHeader()

BBjGridHeader

getRowHeader()

int

getRowHeaderWidth()

void

setHasRowHeader(int header)

void

setRowHeaderWidth(int width)

Methods of BBjStandardGrid – Grid Rows and Columns

Return Value

Method

void

clearRowHeader()

void

clearRowHeader(int p_row)

void

clearColumnHeader()

void

clearColumnHeader(int p_column)

void

deleteColumn(int column)

void

deleteRow(int row)

BBjVector

getHiddenColumns()

BBjVector

getHiddenColumns(int p_startColumn, int p_endColumn)

BBjVector

getHiddenRows()

BBjVector

getHiddenRows(int p_startRow, int p_endRow)

int

getMaxColumns() - Deprecated in BBj 12.00

int

getMaxRows()

int

getRowModelIndexFromViewIndex(int index)

int

getRowViewIndexFromModelIndex(int index)

int

getSortByMultipleColumns()

void

hideColumn(int p_column)

void

hideColumns(BBjVector p_columns)

void

hideColumns(int p_startColumn, int p_endColumn)

void

hideRow(int p_row)

void

hideRows(BBjVector p_rows)

void

hideRows(int p_startRow, int p_endRow)

void

insertColumn(int index)

void

insertRow(int index)

boolean

isColumnHidden(int p_column)

boolean

isColumnSortedByRelatedData(int columnIndex)

boolean

isColumnUserSortable(int columnIndex)

boolean

isRowHidden(int p_row)

void

resort()

void

setAllColumnsUserSortable(boolean p_sortable)

void

setColumnUserSortable(int columnIndex, boolean p_sortable)

void

sortByColumn(int columnIndex, int sortOrder)

void

setColumnSortedByRelatedData(int columnIndex, int isByRelatedData)

void

setMaxColumns(int max) - Deprecated in BBj 12.00

void

setMaxRows(int max)

void

setNumColumns(int columns)

void

setNumRows(int rows)

void

setSortByMultipleColumns(boolean sortByMultiple)

void

unhideColumn(int p_column)

void

unhideColumns()

void

unhideColumns(BBjVector p_columns)

void

unhideColumns(int p_startColumn, int p_endColumn)

void

unhideRow(int p_row)

void

unhideRows()

void

unhideRows(BBjVector p_rows)

void

unhideRows(int p_startRow, int p_endRow)

void

unsort()

void

unsort(boolean revertAllSortByRelated, boolean revertAllUserSortable)

Methods of BBjStandardGrid – Grid Cell Contents

Return Value

Method

void

clear()

void

clear(int p_row, int p_column)

void

clearGrid()- Deprecated in BBj 19.00, use clear()

void

clearImage()

void

clearImage(int p_row, int p_column)

void

clearMainGrid()- Deprecated in BBj 19.00

void

clearRelated()

void

clearRelated(int p_row, int p_column)

void

clearRestore()

void

clearRestore(int p_row, int p_column)

void

clearText()

void

clearText(int p_row, int p_column)

string

getCellMask(int row, int column)

string

getCellRelated(int row, int column)

string

getCellRestore(int row, int column)

boolean

getInputNBeep()

string

getInputNCommaCharacter()

string

getInputNDotCharacter()

boolean

getInputNUseEditCommas()

string

getRowHeaderCellText(int row)

int

getRowHeaderWidth()

int

getUpdateCached()

void

restoreCell(int row, int col)

void

restoreRow(int row)

void

setCellData(int row, int column, string text, string related)

void

setCellIcon(int imageListID, int index, int row, int column)

void

setCellImage(int row, int column, BBjImage image!)

void

setCellImage(BBjVector p_cells, BBjImage image!)

void

setCellMask(int row, int column, string mask)

void

setCellRelated(int row, int col, string text)

void

setCellRelated(int startRow, int startCol, BBjVector strings!)

void

setCellRestore(int row, int column, string restore)

void

setCellText(BBjVector strings!)

void

setCellText(int row, int column, string text)

void

setCellText(int startRow, int startCol, BBjVector strings!)

void

setDefaultColumnText(int column, string text)

void

setInputNBeep(boolean shouldBeep)

void

setInputNCommaCharacter(string charString)

void

setInputNDotCharacter(string charString)

void

setInputNUseEditCommas(boolean shouldUse)

void

setRowHeaderCellIcon(int imageListID, int index, int row)

void

setRowHeaderCellImage(int row, BBjImage image!)

void

setRowHeaderCellText(int row, string text)

void

setRowHeaderText(BBjVector strings!)

void

setRowHeaderWidth(int width)

void

setUpdateCached(boolean update)

Methods of BBjStandardGrid – Grid Cell Editing

Return Value

Method

int

isCellEditable(int row, int column)

void

setCellEditable(int row, int column, int editable)

int

isGridEditable() – Deprecated, useisEditable()

void

setGridEditable() – Deprecated, usesetEditable(int editable)

Methods of BBjStandardGrid – Grid Cell Style

Return Value

Method

int

getCellState(int row, int column)

int

getCellStyle(int row, int column)

int

getRowHeaderCellStyle(int row)

int

getRowHeaderStyle()

void

setCellState(int row, int column, int state)

void

setCellStyle(int row, int column, int style)

void

setRowHeaderCellStyle(int row, int style)

void

setRowHeaderStyle(int style)

void

setRowStyle(int row, int style)

Methods of BBjStandardGrid – Grid Cell Alignment

Return Value

Method

int

getRowHeaderVerticalAlignment()

int

getRowHeaderCellVerticalAlignment(int row)

void

setRowHeaderVerticalAlignment(int align)

void

setRowHeaderCellAlignment(int row, int align)

void

setRowHeaderCellVerticalAlignment (int row, int align)

Methods of BBjStandardGrid – Grid Cell Query

Return Value

Method

boolean

getCellHasQuery(int row, int column)

boolean

getColumnHasQuery(int column)

void

setCellHasQuery(int row, int column, boolean hasQuery)

void

setColumnHasQuery(int column, boolean hasQuery)

Methods of BBjStandardGrid – Grid Colors

Return Value

Method

BBjColor

getCellBackColor(int row, int column)

BBjColor

getCellForeColor(int row, int column)

BBjColor

getRowHeaderBackColor()

BBjColor

getRowHeaderCellBackColor(int row)

BBjColor

getRowHeaderCellForeColor(int row)

BBjColor

getRowHeaderForeColor()

void

setCellBackColor(int row, int column, BBjColor color!)

void

setCellForeColor(int row, int column, BBjColor color!)

void

setRowBackColor(int row, BBjColor color!)

void

setRowForeColor(int row, BBjColor color!)

void

setRowHeaderBackColor(BBjColor color!)

void

setRowHeaderCellBackColor(int row, BBjColor color!)

void

setRowHeaderCellForeColor(int row, BBjColor color!)

void

setRowHeaderForeColor(BBjColor color!)

Methods of BBjStandardGrid – Grid Fonts

Return Value

Method

BBjFont

getCellFont(int row, int column)

BBjFont

getRowFont(int row)

BBjFont

getRowHeaderFont()

void

setCellFont(int row, int column, BBjFont font!)

void

setRowFont(int row, BBjFont font!)

void

setRowHeaderFont(BBjFont font!)

Methods of BBjStandardGrid – List Control in Grid

Return Value

Method

BBjComboBox

getCellListControl(int row, int column)

int

getCellListSelection(int row, int column)

BBjComboBox

getColumnListControl(int column)

int

getColumnListSelection(int column)

void

setCellListControl(int row, int column, BBjComboBox list!)

void

setCellListSelection(int row, int column, int sel, int redraw)

void

setColumnListControl(int column, BBjComboBox list!)

void

setColumnListSelection(int column, int index, int repaint)

void

setSelectedCell(int row, int column)

void

setSelectedCell(BBjGridCell gridCell!)

Methods of BBjStandardGrid inherited from BBjGrid

Methods of BBjStandardGrid inherited from BBjControl

Methods of BBjStandardGrid – Miscellaneous Grid Functions

Return Value

Method

BBjDataAwareGrid

convertToDataAware(int channel, string template)

Methods of BBjStandardGrid implemented for CommonGrid

Return Value

Method

void

endEdit()

int

endEdit(int suppress)

int

getColumnStyle(int column)

int

getDefaultGridStyle()

void

setColumnStyle(int column, int style)

void

setDefaultGridStyle(int style)

void

startEdit(int row, int col)

Methods of BBjStandardGrid implemented for Focusable

Return Value Method
boolean isFocusable()
void setFocusable(boolean focus)

Methods of BBjStandardGrid implemented for MouseWheelEnabled

Return Value Method
int getScrollWheelBehavior()
void setScrollWheelBehavior(int trav)

Methods of BBjStandardGrid implemented for TabTraversable

Return Value Method
boolean isTabTraversable()
void setTabTraversable(boolean trav)

Methods of BBjStandardGrid implemented for Validateable

Return Value Method
void accept(boolean valid)
string getValidationText()

Events

Remarks

None.

Events

Callback Code

Object-oriented Event

Read Record Event

Code

ON_GRID_CELL_QUERY

BBjGridCellQueryEvent

Grid Cell Query Event

N (Notify code 33)

Constants

BBjStandardGrid Constants

GRID_STYLE_INPUTE

GRID_STYLE_CHECKED

GRID_STYLE_UNCHECKED

GRID_STYLE_TEXT

GRID_STYLE_INPUTN

GRID_STYLE_INPUTD

SORT_ASCENDING

SORT_DESCENDING

SORT_NONE

Constants inherited from BBjGrid

Constants inherited from BBjControl

Example

rem 'Create a calendar using 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 'Display the main window
MainWindow!.setVisible(mySysGui!.TRUE)

rem 'Register the CALLBACK routines
CALLBACK(ON_TOOL_BUTTON_PUSH,DoForwardMonth,CalendarContext,myFwdMonth!.getID())
CALLBACK(ON_TOOL_BUTTON_PUSH,DoForwardYear,CalendarContext,myFwdYear!.getID())
CALLBACK(ON_TOOL_BUTTON_PUSH,DoBackMonth,CalendarContext,myBackMonth!.getID())
CALLBACK(ON_TOOL_BUTTON_PUSH,DoBackYear,CalendarContext,myBackYear!.getID())
CALLBACK(ON_GRID_DOUBLE_CLICK,DoSelectDay,CalendarContext,Calendar!.getID())
CALLBACK(ON_GRID_MOUSE_DOWN,DoHighlightDay,CalendarContext,Calendar!.getID())
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 'Callback routine called when the user selects the back year button
DoBackYear:
    let CurrentYear=CurrentYear-1
    GOSUB DisplayMonth
return

rem 'Callback routine called when the user selects the back month button
DoBackMonth:
    let CurrentMonth=CurrentMonth-1
    if (CurrentMonth<1) then
        let CurrentMonth=12
        let CurrentYear=CurrentYear-1
    endif
    GOSUB DisplayMonth
return

rem 'Callback routine called when the user selects the forward month button
DoForwardMonth:
    let CurrentMonth=CurrentMonth+1
    if (CurrentMonth>12) then
        let CurrentMonth=1
        let CurrentYear=CurrentYear+1
    endif
    GOSUB DisplayMonth
return

rem 'Callback routine called when the user selects the forward year button
DoForwardYear:
    let CurrentYear=CurrentYear+1
    GOSUB DisplayMonth
return

rem 'Subroutine called to display the days in the current month/year
DoSelectDay:
    let CurrRow=Calendar!.getSelectedRow()
    let CurrCol=Calendar!.getSelectedColumn()
    GOSUB DoCalcCurrJul
    let answer=MSGBOX("You have selected "+DATE(CurrentJul:dateMask$),0,TITLE$)
return

DoHighlightDay:
    EVENT$=mySysGui!.getLastEventString()
    let GENERIC$=NOTICE(SYSGUI,EVENT.X%)
    DIM NOTICE$:NOTICETPL(GENERIC.OBJTYPE%,EVENT.FLAGS%)
    let NOTICE$=GENERIC$
    let CurrRow=NOTICE.ROW
    let CurrCol=NOTICE.COL
    GOSUB DoCalcCurrJul
    Calendar!.setSelectedCell(CurrRow,CurrCol)
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 'Subroutine called to calculate the current jullian day
DoCalcCurrJul:
    if (CurrRow=5 AND CurrCol>4) then
        let CurrentJul=0
    else
        let CurrentDay=NUM(Calendar!.getCellText(CurrRow,CurrCol))
        if (CurrentDay>0) then
            let CurrentJul=JUL(CurrentYear,CurrentMonth,CurrentDay)
        endif
    endif
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 'The control ID's
    let grdCalendar=100
    let txtDate=103
    let tbnForwardMonth=104
    let tbnForwardYear=105
    let tbnBackYear=106
    let tbnBackMonth=107

    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,182,180,TITLE$,$00010013$)

    rem 'Add the calender (grid) to the main window
    let Calendar! = MainWindow!.addGrid(grdCalendar,3,26,178,151)

    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)
    Calendar!.setGridEditable(mySysGui!.FALSE)

    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

    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(txtDate,45,3,90,20,"")
    CurrDate!.setClientEdge(mySysGui!.TRUE)
    CurrDate!.setForeColor(blueColor!)

    rem 'Create the tool buttons for year and month navigation
    let myFwdMonth!= MainWindow!.addToolButton(104,138,3,20,20,"")
    myFwdMonth!.setImageFile("ForwardM.bmp")
    let myFwdYear!= MainWindow!.addToolButton(105,158,3,20,20,"")
    myFwdYear!.setImageFile("ForwardY.bmp")
    let myBackYear!= MainWindow!.addToolButton(106,2,3,20,20,"")
    myBackYear!.setImageFile("BackY.bmp")
    let myBackMonth!= MainWindow!.addToolButton(107,22,3,20,20,"")
    myBackMonth!.setImageFile("BackM.bmp")

    rem 'Build the event base info templates
    DIM GENERIC$:NOTICETPL(0,0)
    DIM EVENT$:TMPL(SYSGUI)
return

See Also

BBjAPI

BBjSysGui

BBjWindow

BBjGrid

BBjDataAwareGrid

CALLBACK Verb - Register BBj Subroutine

Grid Callbacks

GRID Mnemonic - Create a Grid Control

See the BBj Object Diagram for an illustration of the relationship between BBj Objects and the Grid Tutorial 2 - Standard Grid Using BBjGrid Methods for more information.