BBjGrid::getColumnStyleNames

Description

In BBj 13.0 and higher, this method gets a list of all CSS styles names that have been added to a grid column.

Syntax

Return Value

Method

BBjVector

getColumnStyleNames(int column)

Parameters

Variable

Description

column

Specifies the column number.

Return Value

Returns a BBjVector containing a list of all styles that have been added to the grid column.

Remarks

For more details, see CSS API.

Example

rem ' gridcss.txt

sysgui = unt
open (sysgui)"X0"
sysgui! = bbjapi().getSysGui()
o$=opts,o$(8,1)=ior(o$(8,1),$10$); setopts o$; rem ' Visual PRO/5 compatible
grid = 101, colhdr = 102, rowhdr = 103
rows = 4
cols = 4
title$ = cvs(sys,3)+" "+cvs(rev,3)

if pos(" 6 "=sys) then title$=title$+" "+info(1,4)
window! = sysgui!.addWindow(25,25,500,500,title$,$00090003$,$$)
window!.setCallback(window!.ON_CLOSE,"eoj")

grid! = window!.addGrid(grid,rowhdr,colhdr,10,10,480,180,$81ce$,rows,cols)
grid!.setRowHeight(30)
grid!.setFitToGrid(1)
grid!.setAllColumnsUserSortable(1)
grid!.setSortByMultipleColumns(0)
grid!.setEditable(1)

for row = 0 to rows-1
  for col = 0 to cols-1
    text$ = "xyzzy " + str(row)+","+str(col)
    grid!.setCellText(row,col,text$)
  next col
next row

mode$ = "Cell"
getStyles! = window!.addButton(1,10,200,150,25,"getStyles",$$)
getStyles!.setCallback(getStyles!.ON_BUTTON_PUSH,"getStyles")
clearStyles! = window!.addButton(2,170,200,150,25,"clearStyls",$$)
clearStyles!.setCallback(clearStyles!.ON_BUTTON_PUSH,"clearStyles")
resetStyles! = window!.addButton(3,330,200,160,25,"Clear All Styles",$$)
resetStyles!.setCallback(resetStyles!.ON_BUTTON_PUSH,"resetStyles")
cellMode! = window!.addRadioButton(4,10,250,150,25,"Cell Mode",$0024$)
cellMode!.setCallback(cellMode!.ON_CHECK_ON,"cellMode")
columnMode! = window!.addRadioButton(5,170,250,150,25,"Column Mode",$0020$)
columnMode!.setCallback(columnMode!.ON_CHECK_ON,"columnMode")
rowMode! = window!.addRadioButton(6,330,250,160,25,"Row Mode",$0020$)
rowMode!.setCallback(rowMode!.ON_CHECK_ON,"rowMode")
buttons! = bbjapi().makeVector()
buttons!.add(cellMode!)
buttons!.add(columnMode!)
buttons!.add(rowMode!)
radiogroup! = window!.addRadioGroup(buttons!)
backgroundStyle! = window!.addButton(201,10,300,180,25,"backgroundStyle",$$)
backgroundStyle!.setCallback(backgroundStyle!.ON_BUTTON_PUSH,"toggleStyle")
fontStyle! = window!.addButton(202,10,350,180,25,"fontStyle",$$)
fontStyle!.setCallback(fontStyle!.ON_BUTTON_PUSH,"toggleStyle")
italicStyle! = window!.addButton(203,10,400,180,25,"italicStyle",$$)
italicStyle!.setCallback(italicStyle!.ON_BUTTON_PUSH,"toggleStyle")
boldStyle! = window!.addButton(204,10,450,180,25,"boldStyle",$$)
boldStyle!.setCallback(boldStyle!.ON_BUTTON_PUSH,"toggleStyle")

gosub setMode
process_events

eoj:
release

cellMode:
  mode$ = "Cell"
  gosub setMode
return

columnMode:
  mode$ = "Column"
  gosub setMode
return

rowMode:
  mode$ = "Row"
  gosub setMode
return

setMode:
  getStyles!.setText("get" + mode$ + "StyleNames")
  clearStyles!.setText("clear" + mode$ + "StyleNames")
  backgroundStyle!.setToolTipText("Toggle " + mode$ + " " + backgroundStyle!.getText())
  fontStyle!.setToolTipText("Toggle " + mode$ + " " + fontStyle!.getText())
  italicStyle!.setToolTipText("Toggle " + mode$ + " " + italicStyle!.getText())
  boldStyle!.setToolTipText("Toggle " + mode$ + " " + boldStyle!.getText())
return

getStyles:
  if mode$ = "Cell"
     row = grid!.getSelectedRow()
     col = grid!.getSelectedColumn()
     if row >= 0 and col >= 0 then
        i = msgbox(grid!.getCellStyleNames(row,col).toString(),0,"getCellStyleNames(" + str(row)+"," + str(col) + ")")
     endif
  endif

  if mode$ = "Column"
     col = grid!.getSelectedColumn()
     if col >= 0 then
        i = msgbox(grid!.getColumnStyleNames(col).toString(),0,"getColumnStyleNames(" + str(col)+")")
     endif
  endif

  if mode$ = "Row"
     row = grid!.getSelectedRow()
     if row >= 0 then
        i = msgbox(grid!.getRowStyleNames(row).toString(),0,"getRowStyleNames(" + str(row) + ")")
     endif
  endif
return

clearStyles:
  if mode$ = "Cell"
     row = grid!.getSelectedRow()
     col = grid!.getSelectedColumn()
     if row >= 0 and col >= 0 then
        grid!.clearCellStyleNames(row,col)
     endif
  endif

  if mode$ = "Column"
     col = grid!.getSelectedColumn()
     if col >= 0 then
        grid!.clearColumnStyleNames(col)
     endif
  endif

  if mode$ = "Row"
     row = grid!.getSelectedRow()
     if row >= 0 then
        grid!.clearRowStyleNames(row)
     endif
  endif
return

resetStyles:
  for row = 0 to rows-1
    grid!.clearRowStyleNames(row)
  next row

  for col = 0 to cols-1
    grid!.clearColumnStyleNames(col)
  next col

  for row = 0 to rows-1
    for col = 0 to cols-1
      grid!.clearCellStyleNames(row,col)
    next col
  next row

return

toggleStyle:
  event! = sysgui!.getLastEvent()
  control! = event!.getControl()
  style$ = control!.getText()
  if mode$ = "Cell"
     row = grid!.getSelectedRow()
     col = grid!.getSelectedColumn()

     if row >= 0 and col >= 0 then
        if grid!.getCellStyleNames(row,col).contains(style$) then
           grid!.removeCellStyleName(row,col,style$)
        else
           grid!.addCellStyleName(row,col,style$)
        endif
     endif
  endif

  if mode$ = "Column"
     col = grid!.getSelectedColumn()

     if col >= 0 then
        if grid!.getColumnStyleNames(col).contains(style$) then
           grid!.removeColumnStyleName(col,style$)
        else
           grid!.addColumnStyleName(col,style$)
        endif
     endif
  endif

  if mode$ = "Row"
     row = grid!.getSelectedRow()

     if row >= 0 then
        if grid!.getRowStyleNames(row).contains(style$) then
           grid!.removeRowStyleName(row,style$)
        else
           grid!.addRowStyleName(row,style$)
        endif
     endif
  endif

return

CSS Example


.backgroundStyle
{
  background: yellow !important;
  color: blue !important;
}

.fontStyle
{
  font-family: "Courier New"
}

.italicStyle
{
  font-style: italic;
}

.boldStyle
{
  font-weight: bold;
}

.BBjGrid .bbj-selected
{
  background: rgb(73,155,234);
  background: -moz-linear-gradient(top,  rgba(73,155,234,1) 0%, rgba(32,124,229,1) 100%);
  background: -webkit-gradient(linear, left top, left bottom,
color-stop(0%,rgba(73,155,234,1)), color-stop(100%,rgba(32,124,229,1)));
  background: -webkit-linear-gradient(top,  rgba(73,155,234,1) 0%,rgba(32,124,229,1) 100%);
  background: -o-linear-gradient(top,  rgba(73,155,234,1) 0%,rgba(32,124,229,1) 100%);
  background: -ms-linear-gradient(top,  rgba(73,155,234,1) 0%,rgba(32,124,229,1) 100%);
  background: linear-gradient(to bottom,  rgba(73,155,234,1) 0%,rgba(32,124,229,1) 100%);
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#499bea',
endColorstr='#207ce5',GradientType=0 );
  box-shadow: 7px 7px 5px rgba(69, 117, 210, 0.5);
}

.BBjGrid-editingCell
{
  box-shadow: 7px 7px 5px rgba(50, 50, 50, 0.5);
}

See Also

BBjAPI

BBjSysGui

BBjWindow

CSS API

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