eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'TabulatorSpecification':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: TabulatorSpecification


Inheritance:

   Object
   |
   +--Model
      |
      +--TabulatorSpecification

Package:
stx:libwidg2
Category:
Views-Support
Version:
rev: 1.17 date: 2016/04/02 14:29:33
user: cg
file: TabulatorSpecification.st directory: libwidg2
module: stx stc-classLibrary: libwidg2
Author:
Claus Gittinger

Description:


This is a helper class for table widgets and tabular data in
lists.
A tabulatorSpecification keeps track of where the tabs are,
and how they align. They are to be used in conjunction with
MultiColumnListEntry or the upcoming TableWidget.
However, they may also be useful to represent tabs in a
paragraph of text.


Related information:

    Ruler
    TabSpecRuler
    ListView

Class protocol:

instance creation
o  unit: unit positions: positions
TabulatorSpecification unit:#inch positions:#(0 3)


Instance protocol:

accessing
o  align
return the align-vector

o  align: types
an array of tab-types; each one is
#left
#right
#center
#decimal
or a symbol which gives align of all tabs


o  moveTabAtIndex: index to: unitPosition
set an individual position

o  positions
return the position-vector

o  positions: tabs
set the position-vector

o  size
return the number of tabs in this spec

o  unit
return the unit

o  unit: aSymbol
set the unit.
allowed are: #inch, #mm, #cm, #pixel and #col

o  unitRelativeTo: someObject
set for a relative unit. someObject should return its width
and the tabs are set fraction-relative to this number (in pixel).

o  widths
return a width-vector

o  widths: fieldWidths
set the position-vector from a vector of field widths

queries
o  pixelsPerUnitOn: aGC
return the number of device pixels one unit of my tabs
takes on aGC

o  positionOfTab: index forString: aString on: aGC
return the position (in device units) of the string to be drawn
at position index.

o  positionOfTab: index on: aGC
return the position (in device units) of the tab at index

o  typeOfTab: index
return the type of the tab at position index.

o  unitsPerPixelOn: aGC
return the number of units that one device pixels
takes on aGC


Examples:


Example use (in a ListView):
    |listView tabSpec entry|

    listView := ListView new.

    tabSpec := TabulatorSpecification new.
    tabSpec unit:#inch.
    tabSpec positions:#(0     1     2.5    3.5    4       5        ).
    tabSpec align:    #(#left #left #right #right #center #decimal ).

    entry := MultiColListEntry new.
    entry tabulatorSpecification:tabSpec.
    entry colAt:1 put:'left';
          colAt:2 put:'left';
          colAt:3 put:'right';
          colAt:4 put:'right';
          colAt:5 put:'center';
          colAt:6 put:'.decimal'.

    listView at:1 put:entry.

    entry := MultiColListEntry new.
    entry tabulatorSpecification:tabSpec.
    entry colAt:1 put:'col1';
          colAt:2 put:'col2';
          colAt:3 put:'col3';
          colAt:4 put:'col4';
          colAt:5 put:'col5';
          colAt:6 put:'col6.decimal'.

    listView at:2 put:entry.

    entry := MultiColListEntry new.
    entry tabulatorSpecification:tabSpec.
    entry colAt:1 put:'foo';
          colAt:2 put:'fooBar';
          colAt:3 put:'bar';
          colAt:4 put:'barFoo';
          colAt:5 put:'baz';
          colAt:6 put:'1234.56'.

    listView at:3 put:entry.
    (ScrollableView forView:listView) open
defining field positions in millimeter :
    |listView tabSpec entry|

    listView := ListView new.

    tabSpec := TabulatorSpecification new.
    tabSpec unit:#mm.
    tabSpec positions:#(0 10 20 40).
    tabSpec align:    #left.          

    entry := MultiColListEntry new.
    entry tabulatorSpecification:tabSpec.
    entry colAt:1 put:'1';
          colAt:2 put:'2';
          colAt:3 put:'3';
          colAt:4 put:'4'.

    listView at:1 put:entry.

    entry := MultiColListEntry new.
    entry tabulatorSpecification:tabSpec.
    entry colAt:1 put:'aa';
          colAt:2 put:'bb';
          colAt:3 put:'cc';
          colAt:4 put:'dd'.

    listView at:2 put:entry.

    listView open
defining field widths in millimeter :
    |listView tabSpec entry|

    listView := ListView new.

    tabSpec := TabulatorSpecification new.
    tabSpec unit:#mm.
    tabSpec widths:#(10 10 20 10).
    tabSpec align:    #left.        

    entry := MultiColListEntry new.
    entry tabulatorSpecification:tabSpec.
    entry colAt:1 put:'1';
          colAt:2 put:'2';
          colAt:3 put:'3';
          colAt:4 put:'4'.

    listView at:1 put:entry.

    entry := MultiColListEntry new.
    entry tabulatorSpecification:tabSpec.
    entry colAt:1 put:'aa';
          colAt:2 put:'bb';
          colAt:3 put:'cc';
          colAt:4 put:'dd'.

    listView at:2 put:entry.

    listView open
defining field widths in pixels :
    |listView tabSpec entry|

    listView := ListView new.

    tabSpec := TabulatorSpecification new.
    tabSpec unit:#pixel.
    tabSpec widths:#(50 30 30 50).
    tabSpec align:    #left.        

    entry := MultiColListEntry new.
    entry tabulatorSpecification:tabSpec.
    entry colAt:1 put:'1';
          colAt:2 put:'2';
          colAt:3 put:'3';
          colAt:4 put:'4'.

    listView at:1 put:entry.

    entry := MultiColListEntry new.
    entry tabulatorSpecification:tabSpec.
    entry colAt:1 put:'aa';
          colAt:2 put:'bb';
          colAt:3 put:'cc';
          colAt:4 put:'dd'.

    listView at:2 put:entry.

    listView open
same as first example, but adding a TabSpecRuler to show where the tabs are:
    |top ruler listView tabSpec entry|

    top := StandardSystemView extent:300@300.

    ruler := TabSpecRuler origin:0.0@0.0 corner:1.0@20 in:top.
    ruler level:0.
    ruler tabsAreVariable:false.

    listView := ListView in:top.
    listView origin:0.0@0.0 corner:1.0@1.0.
    listView topInset:20.

    tabSpec := TabulatorSpecification new.
    tabSpec unit:#inch.
    tabSpec positions:#(0     1     2.5    3.5    4       5        ).
    tabSpec align:    #(#left #left #right #right #center #decimal ).

    ruler tabulatorSpecification:tabSpec.

    entry := MultiColListEntry new.
    entry tabulatorSpecification:tabSpec.
    entry colAt:1 put:'left';
          colAt:2 put:'left';
          colAt:3 put:'right';
          colAt:4 put:'right';
          colAt:5 put:'center';
          colAt:6 put:'.decimal'.

    listView at:1 put:entry.

    entry := MultiColListEntry new.
    entry tabulatorSpecification:tabSpec.
    entry colAt:1 put:'col1';
          colAt:2 put:'col2';
          colAt:3 put:'col3';
          colAt:4 put:'col4';
          colAt:5 put:'col5';
          colAt:6 put:'col6.decimal'.

    listView at:2 put:entry.

    entry := MultiColListEntry new.
    entry tabulatorSpecification:tabSpec.
    entry colAt:1 put:'foo';
          colAt:2 put:'fooBar';
          colAt:3 put:'bar';
          colAt:4 put:'barFoo';
          colAt:5 put:'baz';
          colAt:6 put:'1234.56'.

    listView at:3 put:entry.
    top open
much like previous example, but allow some tab positions to be changed (with synchronousOperation):
    |top ruler listView tabSpec entry|

    top := StandardSystemView extent:300@300.

    ruler := TabSpecRuler origin:0.0@0.0 corner:1.0@20 in:top.
    ruler level:0.
    ruler fixedTabs:#(1).
    ruler synchronousOperation:true.

    listView := ListView in:top.
    listView origin:0.0@0.0 corner:1.0@1.0.
    listView topInset:20.

    tabSpec := TabulatorSpecification new.
    tabSpec unit:#inch.
    tabSpec positions:#(0     1     2.5    3.5    4       5        ).
    tabSpec align:    #(#left #left #left #left #left #decimal ).

    ruler tabulatorSpecification:tabSpec.

    entry := MultiColListEntry new.
    entry tabulatorSpecification:tabSpec.
    entry colAt:1 put:'left';
          colAt:2 put:'left';
          colAt:3 put:'left';
          colAt:4 put:'left';
          colAt:5 put:'left';
          colAt:6 put:'.decimal'.

    listView at:1 put:entry.

    entry := MultiColListEntry new.
    entry tabulatorSpecification:tabSpec.
    entry colAt:1 put:'col1';
          colAt:2 put:'col2';
          colAt:3 put:'col3';
          colAt:4 put:'col4';
          colAt:5 put:'col5';
          colAt:6 put:'col6'.

    listView at:2 put:entry.

    entry := MultiColListEntry new.
    entry tabulatorSpecification:tabSpec.
    entry colAt:1 put:'foo';
          colAt:2 put:'fooBar';
          colAt:3 put:'bar';
          colAt:4 put:'barFoo';
          colAt:5 put:'baz';
          colAt:6 put:'1234.56'.

    listView at:3 put:entry.

    entry := MultiColListEntry new.
    entry tabulatorSpecification:tabSpec.
    entry colAt:1 put:'hello';
          colAt:2 put:'world';
          colAt:3 put:'how';
          colAt:4 put:'about';
          colAt:5 put:'this';
          colAt:6 put:'0.2345'.
    listView at:4 put:entry.

    tabSpec onChangeSend:#redraw to:listView.
    top open


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 29 Mar 2024 06:01:04 GMT