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.18 date: 2021/01/20 14:40:42
user: cg
file: TabulatorSpecification.st directory: libwidg2
module: stx stc-classLibrary: libwidg2

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.

copyright

COPYRIGHT (c) 1994 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

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

Usage example(s):

     |spec|

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

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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 06:35:18 GMT