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(int ID, int x, int y, int width, int height)

BBjStandardGrid

addGrid(int ID, int x, int y, int width, int height, string flags)

BBjStandardGrid

addGrid(int ID, int x, int y, int width, int height, string flags, int rows, int columns)

BBjStandardGrid

addGrid(int ID, int rowHeaderID, int columnHeaderID, int x, int y, int width, int height)

BBjStandardGrid

addGrid(int ID, int rowHeaderID, int columnHeaderID, int x, int y, int width, int height, string flags)

BBjStandardGrid

addGrid(int ID, int rowHeaderID, int columnHeaderID, int x, int y, int width, int height, 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.0

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.0

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.0, use clear()

void

clearImage()

void

clearImage(int p_row, int p_column)

void

clearMainGrid()- Deprecated in BBj 19.0

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 p_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

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
FI
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
FI
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
FI
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
      FI
      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
         FI
         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)
   FI
FI
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
FI
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

BBjGrid

BBjDataAwareGrid

BBjAPI

BBjSysGui

BBjWindow

CALLBACK Verb - Register BBj Subroutine

Grid Callbacks

GRID Mnemonic - Create a Grid Control

Focusable

MouseWheelEnabled

TabTraversable

Validateable

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.