TabSpecRuler.st
author Claus Gittinger <cg@exept.de>
Fri, 05 Mar 2004 13:44:20 +0100
changeset 2672 7a308cf0b29e
parent 2659 3af857eb52fb
child 2741 cc19b3a131b8
permissions -rw-r--r--
clear -> clearView To allow subclasses of GraphicsContext to redefine #clear with more clearing (i.e. a TextCollector, to clear its contents)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2672
7a308cf0b29e clear -> clearView
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
     1
"{ Encoding: utf8 }"
7a308cf0b29e clear -> clearView
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
     2
38
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
     3
"
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
     4
 COPYRIGHT (c) 1994 by Claus Gittinger
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
     5
	      All Rights Reserved
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
     6
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
     7
 This software is furnished under a license and may be used
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
     8
 only in accordance with the terms of that license and with the
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    10
 be provided or otherwise made available to, or used by, any
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    11
 other person.  No title to or ownership of the software is
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    12
 hereby transferred.
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    13
"
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    14
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 1445
diff changeset
    15
"{ Package: 'stx:libwidg2' }"
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 1445
diff changeset
    16
49
claus
parents: 40
diff changeset
    17
SimpleView subclass:#TabSpecRuler
342
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    18
	instanceVariableNames:'tabSpec titles handleStyle handleCursor movedTabIndex movedTabX
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    19
		synchronousOperation handleWidth fixedTabs tabsAreVariable
1445
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
    20
		hiddenTabs masterView'
200
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    21
	classVariableNames:'DefaultHandleStyle'
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    22
	poolDictionaries:''
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    23
	category:'Views-Misc'
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
    24
!
b1663ac8f532 Initial revision
claus
parents:
diff changeset
    25
b1663ac8f532 Initial revision
claus
parents:
diff changeset
    26
!TabSpecRuler class methodsFor:'documentation'!
b1663ac8f532 Initial revision
claus
parents:
diff changeset
    27
38
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    28
copyright
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    29
"
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    30
 COPYRIGHT (c) 1994 by Claus Gittinger
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    31
	      All Rights Reserved
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    32
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    33
 This software is furnished under a license and may be used
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    34
 only in accordance with the terms of that license and with the
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    35
 inclusion of the above copyright notice.   This software may not
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    36
 be provided or otherwise made available to, or used by, any
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    37
 other person.  No title to or ownership of the software is
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    38
 hereby transferred.
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    39
"
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    40
!
858ec30d05fe *** empty log message ***
claus
parents: 36
diff changeset
    41
36
160b8f0dfd7d *** empty log message ***
claus
parents: 29
diff changeset
    42
documentation
160b8f0dfd7d *** empty log message ***
claus
parents: 29
diff changeset
    43
"
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    44
    It shows the tabulator positions of a TabulatorSpecification
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    45
    and allows its tab positions to be manipulated.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    46
    (as shown in a FileBrowser, when the longList is enabled).
200
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    47
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    48
    [author]
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    49
        Claus Gittinger
200
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    50
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    51
    [see also:]
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    52
        TabulatorSpecification
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    53
        Ruler
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
    54
        ListView
36
160b8f0dfd7d *** empty log message ***
claus
parents: 29
diff changeset
    55
"
160b8f0dfd7d *** empty log message ***
claus
parents: 29
diff changeset
    56
!
160b8f0dfd7d *** empty log message ***
claus
parents: 29
diff changeset
    57
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
    58
examples
b1663ac8f532 Initial revision
claus
parents:
diff changeset
    59
"
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    60
                                                                [exBegin]
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    61
    |top head spec|
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
    62
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    63
    top := View new.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    64
    top extent:300@100.
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
    65
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    66
    head := TabSpecRuler in:top.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    67
    head width:1.0.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    68
    head level:1.
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
    69
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    70
    spec := TabulatorSpecification new.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    71
    spec unit:#inch.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    72
    spec positions:#(0     1     2.5    3.5    4       5        ).
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    73
    spec align:    #(#left #left #right #right #center #decimal ).
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
    74
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    75
    head tabulatorSpecification:spec.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    76
    top open.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
    77
                                                                [exEnd]
342
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    78
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    79
                                                                [exBegin]
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    80
    |top head spec|
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    81
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    82
    top := View new.
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    83
    top extent:300@100.
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    84
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    85
    head := TabSpecRuler in:top.
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    86
    head width:1.0.
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    87
    head level:1.
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    88
    head titles:#('col1' 'col2' 'col3' 'col4' 'col5' 'col6').
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    89
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    90
    spec := TabulatorSpecification new.
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    91
    spec unit:#inch.
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    92
    spec positions:#(0     1     2.5    3.5    4       5        ).
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    93
    spec align:    #(#left #left #right #right #center #decimal ).
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    94
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    95
    head tabulatorSpecification:spec.
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    96
    top open.
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
    97
                                                                [exEnd]
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
    98
"
b1663ac8f532 Initial revision
claus
parents:
diff changeset
    99
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   100
! !
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   101
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   102
!TabSpecRuler class methodsFor:'defaults'!
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   103
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   104
updateStyleCache
566
11ca5c6ba3d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   105
    <resource: #style (#'tabRuler.handleStyle')>
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   106
566
11ca5c6ba3d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   107
    DefaultHandleStyle := StyleSheet at:'tabRuler.handleStyle'.
11ca5c6ba3d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   108
11ca5c6ba3d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 365
diff changeset
   109
    "Modified: 20.10.1997 / 15:14:47 / cg"
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   110
! !
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   111
200
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   112
!TabSpecRuler methodsFor:'accessing'!
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   113
328
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   114
fixedTabs
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   115
    "return the collection of tabIndices which are fixed;
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   116
     or nil, if all are variable"
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   117
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   118
    ^ fixedTabs
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   119
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   120
    "Created: 28.3.1997 / 15:02:29 / cg"
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   121
    "Modified: 28.3.1997 / 15:03:05 / cg"
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   122
!
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   123
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   124
fixedTabs:something
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   125
    "set the collection of tabIndices which are fixed;
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   126
     nil, if all are to be variable"
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   127
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   128
    fixedTabs := something.
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   129
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   130
    "Created: 28.3.1997 / 15:02:29 / cg"
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   131
    "Modified: 28.3.1997 / 15:03:18 / cg"
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   132
!
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   133
330
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   134
hiddenTabs
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   135
    "return the collection of tabs which are to be hidden
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   136
     (or nil if all are to be shown)"
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   137
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   138
    ^ hiddenTabs
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   139
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   140
    "Created: 28.3.1997 / 15:35:54 / cg"
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   141
    "Modified: 28.3.1997 / 15:36:18 / cg"
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   142
!
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   143
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   144
hiddenTabs:something
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   145
    "set the collection of tabs which are to be hidden
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   146
     (or nil if all are to be shown)"
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   147
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   148
    hiddenTabs := something.
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   149
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   150
    "Created: 28.3.1997 / 15:35:54 / cg"
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   151
    "Modified: 28.3.1997 / 15:36:24 / cg"
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   152
!
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   153
1445
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   154
masterView:aView
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   155
    "set my master view - if non-nil, I will follow the masters scroll-offset"
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   156
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   157
    masterView notNil ifTrue:[
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   158
        masterView removeDependent:self
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   159
    ].
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   160
    masterView := aView.
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   161
    masterView notNil ifTrue:[
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   162
        masterView addDependent:self
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   163
    ].
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   164
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   165
!
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   166
328
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   167
synchronousOperation
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   168
    "return the synchronousOperation mode settings value"
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   169
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   170
    ^ synchronousOperation
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   171
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   172
    "Created: 28.3.1997 / 15:01:17 / cg"
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   173
    "Modified: 28.3.1997 / 15:02:20 / cg"
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   174
!
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   175
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   176
synchronousOperation:something
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   177
    "set/clear synchronousOperation mode;
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   178
     if on, a move is immediately forwarded to dependents;
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   179
     of off, its forwarded when the mouse button is released."
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   180
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   181
    synchronousOperation := something.
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   182
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   183
    "Modified: 28.3.1997 / 15:02:07 / cg"
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   184
!
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   185
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   186
tabsAreVariable
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   187
    "return the value of the instance variable 'tabsAreVariable' (automatically generated)"
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   188
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   189
    ^ tabsAreVariable
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   190
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   191
    "Created: 28.3.1997 / 15:05:27 / cg"
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   192
!
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   193
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   194
tabsAreVariable:something
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   195
    "set/clear movability of tabs. If false, tab positions are only
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   196
     displayed - but cannot be moved by the user.
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   197
     The default is true."
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   198
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   199
    tabsAreVariable := something.
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   200
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   201
    "Created: 28.3.1997 / 15:05:27 / cg"
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   202
    "Modified: 28.3.1997 / 15:06:19 / cg"
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   203
!
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   204
200
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   205
tabulatorSpecification:aTabSpec
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   206
    "set my tabulator specification"
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   207
365
4228b1451bc9 redraw when the spec is changed
Claus Gittinger <cg@exept.de>
parents: 342
diff changeset
   208
    tabSpec := aTabSpec.
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 1445
diff changeset
   209
    self invalidate
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   210
365
4228b1451bc9 redraw when the spec is changed
Claus Gittinger <cg@exept.de>
parents: 342
diff changeset
   211
    "Modified: 18.4.1997 / 18:16:07 / cg"
342
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   212
!
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   213
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   214
titles:aCollectionOfStrings
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   215
    titles := aCollectionOfStrings
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   216
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   217
    "Created: 1.4.1997 / 13:52:37 / cg"
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   218
! !
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   219
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   220
!TabSpecRuler methodsFor:'event handling'!
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   221
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   222
buttonMotion:state x:x y:y
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   223
    "mouse-button was moved while pressed;
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   224
     redraw thumb at its new position and, if scroll-mode is asynchronous, 
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   225
     the scroll action is performed"
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   226
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   227
    |left right limit1 limit2 minSpacing newX|
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   228
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   229
    movedTabIndex notNil ifTrue:[
328
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   230
        minSpacing := 5.
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   231
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   232
        left := limit1 := 0.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   233
        movedTabIndex > 1 ifTrue:[
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   234
            left := self positionOfTabAtIndex:(movedTabIndex-1).
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   235
            limit1 := left + minSpacing.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   236
        ].
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   237
        right := limit2 := width.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   238
        movedTabIndex < tabSpec size ifTrue:[
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   239
            right := self positionOfTabAtIndex:(movedTabIndex+1).
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   240
            limit2 := right - minSpacing.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   241
        ].
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   242
        newX := (x max:limit1) min:limit2.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   243
        x ~= newX ifTrue:[
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   244
            self cursor:Cursor stop.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   245
        ] ifFalse:[
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   246
            self cursor:handleCursor
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   247
        ].
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   248
        newX ~= movedTabX ifTrue:[
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   249
            movedTabX := newX.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   250
            self clearRectangleX:left+handleWidth y:0 
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   251
                           width:(right-left-handleWidth-handleWidth) height:height.
342
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   252
            movedTabIndex ~~ 1 ifTrue:[
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   253
                self redrawTitleAtIndex:(movedTabIndex - 1).
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   254
            ].
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   255
            self redrawTabAtIndex:movedTabIndex.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   256
            synchronousOperation == true ifTrue:[
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   257
                self moveTabAtIndex:movedTabIndex toX:movedTabX
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   258
            ]
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   259
        ]
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   260
    ] ifFalse:[
328
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   261
        (self canMoveTabAtX:x) ifTrue:[
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   262
            self cursor:handleCursor
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   263
        ] ifFalse:[
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   264
            self cursor:(Cursor normal)
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   265
        ]
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   266
    ]
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   267
342
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   268
    "Modified: 1.4.1997 / 15:21:16 / cg"
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   269
!
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   270
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   271
buttonPress:button x:x y:y
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   272
    "mouse-button was pressed;
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   273
     start moving the tab"
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   274
328
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   275
    movedTabIndex := nil.
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   276
    (self canMoveTabAtX:x) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   277
        movedTabIndex := self indexOfTabAtX:x.
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   278
        self cursor:handleCursor.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   279
    ]
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   280
328
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   281
    "Modified: 28.3.1997 / 15:13:15 / cg"
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   282
!
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   283
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   284
buttonRelease:button x:x y:y
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   285
    "mouse-button was pressed;
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   286
     start moving the tab"
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   287
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   288
    |idx|
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   289
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   290
    idx := movedTabIndex.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   291
    movedTabIndex := nil.
328
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   292
    idx notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   293
        synchronousOperation == true ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   294
            self moveTabAtIndex:idx toX:movedTabX
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   295
        ]
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   296
    ]
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   297
328
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   298
    "Modified: 28.3.1997 / 15:10:23 / cg"
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   299
!
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   300
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   301
pointerLeave:state
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   302
    "mouse left view - restore cursor."
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   303
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   304
    self cursor:(Cursor normal).
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   305
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   306
    "Created: 28.3.1997 / 13:37:52 / cg"
1445
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   307
!
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   308
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   309
update:something with:aParameter from:changedObject
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   310
    changedObject == masterView ifTrue:[
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   311
        something == #originOfContents ifTrue:[
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   312
            self scrollTo:(masterView viewOrigin x @ 0).
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   313
        ].
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   314
    ].
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   315
! !
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   316
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   317
!TabSpecRuler methodsFor:'initialization'!
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   318
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   319
initStyle
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   320
    super initStyle.
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   321
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   322
    handleStyle := DefaultHandleStyle.
1157
7e64e555a971 pass device to #cursorForOrientation.
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
   323
    handleCursor := (VariablePanel cursorForOrientation:#horizontal onDevice:device) onDevice:device.
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   324
    self is3D ifTrue:[
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   325
        handleWidth := 2.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   326
    ] ifFalse:[
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   327
        handleWidth := 1
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   328
    ]
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   329
1157
7e64e555a971 pass device to #cursorForOrientation.
Claus Gittinger <cg@exept.de>
parents: 1120
diff changeset
   330
    "Modified: / 30.9.1998 / 18:20:20 / cg"
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   331
!
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   332
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   333
initialize
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   334
    super initialize.
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   335
328
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   336
    tabsAreVariable := true.
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   337
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   338
    self enableMotionEvents.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   339
    self enableEnterLeaveEvents.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   340
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   341
    self height:(font height + (2 * font descent)). 
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   342
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   343
    "
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   344
     TabSpecRuler new open
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   345
    "
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   346
328
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   347
    "Modified: 28.3.1997 / 15:06:29 / cg"
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   348
! !
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   349
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   350
!TabSpecRuler methodsFor:'private'!
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   351
328
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   352
canMoveTabAtX:x
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   353
    |idx|
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   354
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   355
    tabsAreVariable ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   356
        (idx := self indexOfTabAtX:x) ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   357
            (fixedTabs notNil and:[fixedTabs includes:idx]) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   358
                ^ true
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   359
            ]
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   360
        ]
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   361
    ].
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   362
    ^ false
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   363
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   364
    "Created: 28.3.1997 / 15:12:05 / cg"
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   365
    "Modified: 28.3.1997 / 15:19:01 / cg"
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   366
!
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   367
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   368
indexOfTabAtX:x
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   369
    |xTab minDelta bestIndex|
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   370
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   371
    tabSpec isNil ifTrue:[^ 0].
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   372
    bestIndex := 0.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   373
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   374
    1 to:tabSpec size do:[:i |
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   375
        xTab := tabSpec positionOfTab:i on:self.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   376
        (x between:(xTab-5) and:(xTab+5)) ifTrue:[
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   377
            (minDelta isNil 
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   378
            or:[(x - xTab) abs < minDelta]) ifTrue:[
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   379
                minDelta := (x - xTab) abs.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   380
                bestIndex := i.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   381
            ]
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   382
        ]
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   383
    ].
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   384
    ^ bestIndex
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   385
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   386
    "Modified: 28.3.1997 / 13:43:47 / cg"
328
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   387
    "Created: 28.3.1997 / 15:12:09 / cg"
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   388
!
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   389
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   390
moveTabAtIndex:idx toX:movedTabX
328
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   391
    |unitPosition|
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   392
328
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   393
    unitPosition := (tabSpec unitsPerPixelOn:self) * movedTabX.
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   394
    tabSpec moveTabAtIndex:idx to:unitPosition.
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   395
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   396
    "Modified: 28.3.1997 / 14:54:58 / cg"
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   397
! !
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   398
1445
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   399
!TabSpecRuler methodsFor:'queries'!
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   400
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   401
widthOfContents
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   402
    masterView notNil ifTrue:[^ masterView heightOfContents].
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   403
    ^ super heightOfContents.
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   404
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   405
! !
b272f318bdef allow hooking me to a masterView.
Claus Gittinger <cg@exept.de>
parents: 1157
diff changeset
   406
200
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   407
!TabSpecRuler methodsFor:'redrawing'!
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   408
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   409
drawHandleAtX:x type:handleType
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   410
    "redraw a tabulator handle"
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   411
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   412
    self paint:Black.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   413
    self displayLineFromX:x y:0 toX:x y:height - 1.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   414
    self is3D ifTrue:[
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   415
        self paint:White.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   416
        self displayLineFromX:x+1 y:0 toX:x+1 y:height - 1
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   417
    ]
200
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   418
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   419
    "Modified: 28.3.1997 / 14:35:48 / cg"
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   420
!
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   421
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   422
positionOfTabAtIndex:idx
328
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   423
    ^ ( tabSpec positionOfTab:idx on:self ) rounded.
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   424
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   425
    "Created: 28.3.1997 / 14:26:28 / cg"
328
Claus Gittinger <cg@exept.de>
parents: 326
diff changeset
   426
    "Modified: 28.3.1997 / 15:14:03 / cg"
200
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   427
!
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   428
200
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   429
redraw
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   430
    "redraw the handles from by tabSpec"
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   431
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   432
    tabSpec isNil ifTrue:[^ self].
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   433
    shown ifFalse:[^ self].
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   434
2672
7a308cf0b29e clear -> clearView
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
   435
    self clearView.
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   436
    1 to:tabSpec size do:[:idx |
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   437
        self redrawTabAtIndex:idx.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   438
    ]
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   439
342
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   440
    "Modified: 1.4.1997 / 15:13:16 / cg"
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   441
!
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   442
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   443
redrawTabAtIndex:idx
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   444
    "redraw a single handle"
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   445
342
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   446
    |x s|
200
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   447
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   448
    tabSpec isNil ifTrue:[^ self].
342
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   449
    idx == movedTabIndex ifTrue:[
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   450
        x := movedTabX
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   451
    ] ifFalse:[
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   452
        x := self positionOfTabAtIndex:idx.
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   453
    ].
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   454
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   455
    (hiddenTabs notNil and:[hiddenTabs includes:idx]) ifFalse:[
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   456
        self drawHandleAtX:x type:(tabSpec typeOfTab:idx).
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   457
    ].
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   458
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   459
    titles notNil ifTrue:[
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   460
        s := titles at:idx.
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   461
        self paint:Color black.
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   462
        s displayOn:self x:x+3 y:(font ascent).
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   463
    ].
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   464
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   465
    "Created: 28.3.1997 / 13:57:54 / cg"
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   466
    "Modified: 1.4.1997 / 15:29:19 / cg"
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   467
!
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   468
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   469
redrawTitleAtIndex:idx
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   470
    "redraw a single handle"
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   471
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   472
    |x s|
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   473
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   474
    tabSpec isNil ifTrue:[^ self].
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   475
    titles isNil ifTrue:[^ self].
330
e216c5a56f88 hiding tabs
Claus Gittinger <cg@exept.de>
parents: 328
diff changeset
   476
326
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   477
    idx == movedTabIndex ifTrue:[
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   478
        x := movedTabX
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   479
    ] ifFalse:[
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   480
        x := self positionOfTabAtIndex:idx.
7abb145cb6f4 moving - not yet finished
Claus Gittinger <cg@exept.de>
parents: 200
diff changeset
   481
    ].
200
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   482
342
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   483
    s := titles at:idx.
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   484
    self paint:Color black.
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   485
    s displayOn:self x:x+3 y:(font ascent).
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   486
9e7148fb27c4 prepared to show titles
Claus Gittinger <cg@exept.de>
parents: 330
diff changeset
   487
    "Modified: 1.4.1997 / 15:20:31 / cg"
29
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   488
! !
b1663ac8f532 Initial revision
claus
parents:
diff changeset
   489
200
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   490
!TabSpecRuler class methodsFor:'documentation'!
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   491
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   492
version
2672
7a308cf0b29e clear -> clearView
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
   493
    ^ '$Header: /cvs/stx/stx/libwidg2/TabSpecRuler.st,v 1.18 2004-03-05 12:44:20 cg Exp $'
200
e1ba0782f37c comments
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   494
! !