NoteBookView.st
changeset 2279 5a50cd5af676
parent 2278 1ce91d0009e8
child 2280 93b2df2d91fd
--- a/NoteBookView.st	Fri Oct 11 19:18:34 2002 +0200
+++ b/NoteBookView.st	Sat Oct 12 14:28:21 2002 +0200
@@ -11,8 +11,6 @@
 "
 
 
-'From Smalltalk/X, Version:4.1.5 on 11-oct-2002 at 06:31:23 pm'                 !
-
 "{ Package: 'stx:libwidg2' }"
 
 View subclass:#NoteBookView
@@ -126,10 +124,10 @@
 
 test:aDirection level:aLevel
 "
-NoteBookView test:#top
-NoteBookView test:#bottom
-NoteBookView test:#left
-NoteBookView test:#right
+NoteBookView test:#top    level:1
+NoteBookView test:#bottom level:2
+NoteBookView test:#left   level:1
+NoteBookView test:#right  level:2
 "
     |top tab|
 
@@ -269,33 +267,6 @@
     ].
 !
 
-canvasFrameLevel
-    "ignorred
-    "
-    ^ 0
-!
-
-canvasFrameLevel:anInteger
-    "ignorred
-    "
-!
-
-canvasInset
-    "inset of the canvas relativr to my frame
-    "
-    ^ canvasInset
-!
-
-canvasInset:anInset
-    "inset of the canvas relativr to my frame
-    "
-    anInset ~~ canvasInset ifTrue:[
-        canvasInset := anInset.
-        self recomputeList.
-        self invalidate.
-    ].
-!
-
 list
     "return the list of Tabs or Labels
     "
@@ -375,22 +346,6 @@
 
 !
 
-tabLevel
-    "the level of the tabs and noteBokk frame
-    "
-    ^ tabLevel
-!
-
-tabLevel:aLevel
-    "the level of the tabs and noteBokk frame
-    "
-    aLevel ~~ tabLevel ifTrue:[
-        tabLevel := aLevel.
-        self recomputeList.
-        self invalidate.
-    ].
-!
-
 useIndex
     "use index instead of name
     "
@@ -536,64 +491,7 @@
     ]
 ! !
 
-!NoteBookView methodsFor:'accessing-dimension'!
-
-maxTabHeight
-    |e y|
-
-    e := self preferredExtent.
-    y := self isHorizontal ifTrue:[e y] ifFalse:[e x].
-  ^ y - (expandSelection y)
-!
-
-preferredExtent
-    "compute max extent x/y based on one line
-    "
-    |x "{ Class:SmallInteger }"
-     y "{ Class:SmallInteger }"
-     b "{ Class:SmallInteger }"
-     c "{ Class:SmallInteger }"
-    |
-    preferredExtent notNil ifTrue:[ ^ preferredExtent ].
-
-    y := 0.
-    x := expandSelection x.
-    b := (tabLevel abs) max:1.
-    c := b + b.
-
-    list notEmpty ifTrue:[
-        list do:[:aTab|
-            x := x + c + (aTab preferredExtentX).
-            y := y max:(aTab preferredExtentY).
-        ]
-    ].
-    y := y + b + (expandSelection y).
-
-    self isHorizontal ifTrue:[ preferredExtent := x @ y ]
-                     ifFalse:[ preferredExtent := y @ x ].        
-
-    ^ preferredExtent
-!
-
-preferredSizeXorY
-    "returns preferred size dependant on the current view layout and
-     the direction of the tabs
-    "
-    |e y|
-
-    list isEmpty ifTrue:[^ 0].
-
-    y := self maxTabHeight.
-    e := expandSelection y.
-
-    numberOfLines isNil ifTrue:[
-        self shown ifFalse:[^ y + e ].
-        self recomputeList.
-    ].
-    ^ numberOfLines * y + e
-! !
-
-!NoteBookView methodsFor:'accessing-look'!
+!NoteBookView methodsFor:'accessing-colors'!
 
 activeForegroundColor
     "get the color to be used for drawing text
@@ -690,8 +588,88 @@
     ]
 ! !
 
+!NoteBookView methodsFor:'accessing-dimension'!
+
+maxTabHeight
+    "returns my preferred tab-height
+    "
+    |preferredExtent preferredHeight|
+
+    preferredExtent := self preferredExtent.
+
+    self isHorizontal ifTrue:[ preferredHeight := preferredExtent y ]
+                     ifFalse:[ preferredHeight := preferredExtent x ].
+
+    ^ preferredHeight - (expandSelection y)
+!
+
+preferredExtent
+    "compute max extent x/y based on one line
+    "
+    |x "{ Class:SmallInteger }"
+     y "{ Class:SmallInteger }"
+     b "{ Class:SmallInteger }"
+     c "{ Class:SmallInteger }"
+    |
+    preferredExtent notNil ifTrue:[ ^ preferredExtent ].
+
+    y := 0.
+    x := expandSelection x.
+    b := (tabLevel abs) max:1.
+    c := b + b.
+
+    list notEmpty ifTrue:[
+        list do:[:aTab|
+            x := x + c + (aTab preferredExtentX).
+            y := y max:(aTab preferredExtentY).
+        ]
+    ].
+    y := y + b + (expandSelection y).
+
+    self isHorizontal ifTrue:[ preferredExtent := x @ y ]
+                     ifFalse:[ preferredExtent := y @ x ].        
+
+    ^ preferredExtent
+!
+
+preferredSizeXorY
+    "returns preferred size dependant on the current view layout and
+     the direction of the tabs
+    "
+    |e y|
+
+    list isEmpty ifTrue:[^ 0].
+
+    y := self maxTabHeight.
+    e := expandSelection y.
+
+    numberOfLines isNil ifTrue:[
+        self shown ifFalse:[^ y + e ].
+        self recomputeList.
+    ].
+    ^ numberOfLines * y + e
+! !
+
 !NoteBookView methodsFor:'accessing-style'!
 
+canvasInset
+    "inset of the canvas relative to my frame
+        tabLevel + canvasInset == origin of canvas
+    "
+    ^ canvasInset
+!
+
+canvasInset:anInset
+    "inset of the canvas relative to my frame
+        tabLevel + canvasInset == origin of canvas
+    "
+    anInset ~~ canvasInset ifTrue:[
+        canvasInset := anInset.
+        self recomputeList.
+        self invalidate.
+    ].
+!
+
 direction
     "returns the direction of tabs as symbol. On default the value is
      set to #top. Valid symbols are:
@@ -736,20 +714,20 @@
     fitLastRow := aBool
 !
 
-tabModus
-    ^ tabModus
+tabLevel
+    "the level of the tabs and noteBook frame
+    "
+    ^ tabLevel
 !
 
-tabModus:aBoolean
-
-    tabModus ~~ aBoolean ifTrue:[
-        (aBoolean and:[canvas notNil]) ifFalse:[
-            tabModus := aBoolean.
-            numberOfLines := nil.
-            shown ifTrue:[self invalidate]
-        ]
-    ]
-
+tabLevel:aLevel
+    "the level of the tabs and noteBook frame
+    "
+    aLevel ~~ tabLevel ifTrue:[
+        tabLevel := aLevel.
+        self recomputeList.
+        self invalidate.
+    ].
 ! !
 
 !NoteBookView methodsFor:'change & update'!
@@ -837,20 +815,22 @@
 !NoteBookView methodsFor:'drawing'!
 
 drawFocusFor:aTab
-    "draw focus frame; only #win95 supported yet
+    "draw focus frame if supported
     "
-    |inset layout|
+    |layout extent voffs hoffs|
 
-    (styleSheet at:#'focusHighlightStyle') == #win95 ifFalse:[^ self].
+    self supportsFocusOnTab ifFalse:[^ self].
 
-    layout := aTab layout.
-    inset  := tabLevel abs.
-    inset  := inset + 2.
+    layout  := aTab layout.
+    extent  := aTab extent.
 
-    self displayDottedRectangleX:(layout left   + inset)
-                               y:(layout top    + inset)
-                           width:(layout width  - (inset + inset))
-                          height:(layout height - (inset + inset)).
+    voffs := (layout height - extent y) // 2 max:0.
+    hoffs := (layout width  - extent x) // 2 max:0.
+
+    self displayDottedRectangleX:(layout left   + hoffs         - 1)
+                               y:(layout top    + voffs         - 1)
+                           width:(layout width  - hoffs - hoffs + 2)
+                          height:(layout height - voffs - voffs + 2).
 !
 
 drawTabEdgesFor:aTab
@@ -1119,23 +1099,23 @@
     "
     |idx tab recv menu|
 
-    (enabled and:[list notEmpty]) ifFalse:[
-        ^ self
-    ].
-    (    (idx := list findFirst:[:aTab|aTab containsPointX:x y:y]) == 0
-     or:[(tab := list at:idx ifAbsent:nil) isNil
-     or:[tab isEnabled not]]
-    ) ifTrue:[
-        ^ self
-    ].
+    enabled     ifFalse:[ ^ self ].
+    list isEmpty ifTrue:[ ^ self ].
+
+    idx := list findFirst:[:aTab| aTab containsPointX:x y:y ].
+    idx == 0 ifTrue:[ ^ self ].
+
+    tab := list at:idx.
+    tab isEnabled ifFalse:[ ^ self ].
 
     ((button == 2) or:[button == #menu]) ifFalse:[
         "/ change the selection
         ^ self selection:idx
     ].
-    (accessTabMenuAction notNil and:[(menu := accessTabMenuAction value:idx) notNil]) ifFalse:[
-        ^ self
-    ].
+    accessTabMenuAction isNil ifTrue:[ ^ self ].
+    menu := accessTabMenuAction value:idx.
+    menu isNil ifTrue:[ ^ self ].
+
     menu isArray ifTrue:[
         menu := menu decodeAsLiteralArray
     ].
@@ -1231,30 +1211,38 @@
 showFocus:explicit
     "got the keyboard focus 
     "
-    |tab|
+    |selectedTab|
 
-    (styleSheet at:#'focusHighlightStyle') == #win95 ifTrue:[
-        (tab := self selectedTab) notNil ifTrue:[
-            self invalidateTab:tab
+    self supportsFocusOnTab ifTrue:[
+        selectedTab := self selectedTab.
+        selectedTab notNil ifTrue:[
+            self invalidateTab:selectedTab
         ]
     ] ifFalse:[
         super showFocus:explicit
     ]
-
 !
 
 showNoFocus:explicit
     "lost the keyboard focus 
     "
-    |tab|
+    |selectedTab|
 
-    (styleSheet at:#'focusHighlightStyle') == #win95 ifTrue:[
-        (tab := self selectedTab) notNil ifTrue:[
-            self invalidateTab:tab
-        ]
+    self supportsFocusOnTab ifTrue:[
+        selectedTab := self selectedTab.
+
+        selectedTab notNil ifTrue:[
+            self invalidateTab:selectedTab
+        ].
     ] ifFalse:[
         super showNoFocus:explicit
     ]
+!
+
+supportsFocusOnTab
+    "returns true if focus is supported
+    "
+    ^ (styleSheet at:#'focusHighlightStyle') == #win95
 ! !
 
 !NoteBookView methodsFor:'help'!
@@ -1410,13 +1398,10 @@
         tab notNil ifTrue:[
             l := tab layout.
 
-            direction == #top ifTrue:[
-                yT := l bottom
-            ] ifFalse:[ direction == #bottom ifTrue:[
-                yB := l top
-            ] ifFalse:[ direction == #left   ifTrue:[
-                xL := l right
-            ] ifFalse:[
+                      direction == #top    ifTrue:[ yT := l bottom ]
+            ifFalse:[ direction == #bottom ifTrue:[ yB := l top    ]
+            ifFalse:[ direction == #left   ifTrue:[ xL := l right  ]
+            ifFalse:[
                 xR := l left
             ]]]
         ]
@@ -1729,6 +1714,17 @@
 
 !NoteBookView methodsFor:'obsolete'!
 
+canvasFrameLevel
+    "ignorred
+    "
+    ^ 0
+!
+
+canvasFrameLevel:anInteger
+    "ignorred
+    "
+!
+
 labels
     "return the list of labels
     "
@@ -1751,27 +1747,6 @@
     "set the model, which keeps the list of Tabs or Labels
     "
     self listHolder:aValueHolder. 
-!
-
-moveSelectedRow
-     ^ true
-!
-
-moveSelectedRow:something
-!
-
-oneTabPerLine
-    ^ false
-!
-
-oneTabPerLine:something
-!
-
-tabWidget
-    ^ nil
-!
-
-tabWidget:something
 ! !
 
 !NoteBookView methodsFor:'private'!
@@ -1846,26 +1821,33 @@
 !
 
 isFirstTabInLine:aTab
-    |idx tab|
+    "returns true if the tab is the first tab in the line
+     used by drawing
+    "
+    |idx prevTab|
 
     idx := list identityIndexOf:aTab.
-    tab := list at:(idx - 1) ifAbsent:nil.
-  ^ (tab isNil or:[tab lineNr ~~ aTab lineNr])
+    prevTab := list at:(idx - 1) ifAbsent:nil.
+
+  ^ prevTab isNil or:[prevTab lineNr ~~ aTab lineNr]
 !
 
 isHorizontal
     "returns true in case of direction is #top or #bottom
     "
-    ^ (direction == #top or:[direction == #bottom])
-
+    ^ direction == #top or:[direction == #bottom]
 !
 
 isLastTabInLine:aTab
-    |index tab|
+    "returns true if the tab is the last tab in the line
+     used by drawing
+    "
+    |index nextTab|
 
-    index := list identityIndexOf:aTab.
-    tab := list at:(index + 1) ifAbsent:nil.
-  ^ (tab isNil or:[tab lineNr ~~ aTab lineNr])
+    index   := list identityIndexOf:aTab.
+    nextTab := list at:(index + 1) ifAbsent:nil.
+
+  ^ nextTab isNil or:[nextTab lineNr ~~ aTab lineNr]
 ! !
 
 !NoteBookView methodsFor:'selection'!
@@ -1885,7 +1867,10 @@
 selectedTab
     "returns the selected tab ot nil
     "
-    ^ selection notNil ifTrue:[list at:selection] ifFalse:[nil]
+    (selection notNil and:[selection ~~ 0]) ifTrue:[
+        ^ list at:selection ifAbsent:nil
+    ].
+    ^ nil
 !
 
 selection
@@ -1986,6 +1971,8 @@
 !NoteBookView::Tab methodsFor:'accessing'!
 
 accessCharacter
+    "returns the access character or nil
+    "
     ^ accessCharacter
 !
 
@@ -2025,17 +2012,17 @@
 !
 
 lineNr
-    "get the line number
+    "get the line number within the noteBook view
+     1 -> on top of the wizard
     "
     ^ lineNr
-
 !
 
 lineNr:aLineNr
-    "set the line number
+    "set the line number within the noteBook view
+     1 -> on top of the wizard
     "
     lineNr := aLineNr
-
 !
 
 model
@@ -2071,19 +2058,15 @@
 !NoteBookView::Tab methodsFor:'accessing-dimensions'!
 
 extent
-    "returns the extent of the label
+    "returns the extent of the label, the minimum size required by the tab
     "
     ^ extent
-
-
 !
 
 layout
-    "get the tab's layout
+    "get the tab's layout, set by the noteBook view
     "
     ^ layout
-
-
 !
 
 layout:aLayout
@@ -2246,20 +2229,16 @@
 containsPointX:x y:y
     "return true, if the point defined by x@y is contained in the tab.
     "
-    ^ layout notNil ifTrue:[layout containsPointX:x y:y]
-                   ifFalse:[false].
-
-
+    layout isNil ifTrue:[^ false].
+  ^ layout containsPointX:x y:y
 !
 
 intersects:aRectangle
     "return true, if the intersection between the argument, aRectangle
      and the tab is not empty
     "
-    ^ layout notNil ifTrue:[layout intersects:aRectangle]
-                   ifFalse:[false].
-
-
+    layout isNil ifTrue:[^ false].
+  ^ layout intersects:aRectangle
 !
 
 isEnabled
@@ -2273,5 +2252,5 @@
 !NoteBookView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/NoteBookView.st,v 1.60 2002-10-11 17:18:34 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/NoteBookView.st,v 1.61 2002-10-12 12:28:21 ca Exp $'
 ! !