VDBTabbingContainer.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 21 Sep 2019 18:31:45 +0100
changeset 185 bb863cb24c1a
parent 124 3cce4791af34
child 193 e6393500a665
permissions -rw-r--r--
Do not try to raise transcript window if `Transcript` is not graphical ...but - for instance - a `StdOut` or `StdErr`.

"
jv:vdb - Visual / VM Debugger
Copyright (C) 2015-now Jan Vrany

This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'

You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
"
"{ Package: 'jv:vdb' }"

"{ NameSpace: Smalltalk }"

VDBAbstractContainer subclass:#VDBTabbingContainer
	instanceVariableNames:'tabSelectionIndexHolder tabSelectionViewHolder'
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-UI-Containers'
!

!VDBTabbingContainer class methodsFor:'documentation'!

copyright
"
jv:vdb - Visual / VM Debugger
Copyright (C) 2015-now Jan Vrany

This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'

You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
"
! !

!VDBTabbingContainer class methodsFor:'interface specs'!

windowSpec
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIPainter may not be able to read the specification."

    "
     UIPainter new openOnClass:VDBTabbingContainer andSelector:#windowSpec
     VDBTabbingContainer new openInterface:#windowSpec
     VDBTabbingContainer open
    "

    <resource: #canvas>

    ^ 
    #(FullSpec
       name: windowSpec
       window: 
      (WindowSpec
         label: 'Tabbed Dock'
         name: 'Tabbed Dock'
         min: (Point 10 10)
         bounds: (Rectangle 0 0 733 447)
       )
       component: 
      (SpecCollection
         collection: (
          (NoteBookViewSpec
             name: 'Tabs'
             layout: (LayoutFrame 0 0 0 0 0 1 0 1)
             model: tabSelectionIndexHolder
             menu: tabLabelList
             useIndex: true
             canvas: tabSelectionViewHolder
             keepCanvasAlive: true
           )
          )
        
       )
     )
! !

!VDBTabbingContainer class methodsFor:'plugIn spec'!

aspectSelectors
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this. If it is corrupted,
     the UIPainter may not be able to read the specification."

    "Return a description of exported aspects;
     these can be connected to aspects of an embedding application
     (if this app is embedded in a subCanvas)."

    ^ #(
        #debuggerHolder
      ).

! !

!VDBTabbingContainer methodsFor:'adding & removing components'!

addComponent: aView labeled: aString beforeIndex: anInteger
    super addComponent: aView labeled: aString beforeIndex: anInteger.

    "/ Sigh, this is not called when a sib-view is used in 
    "/ notebook. Why the hell it is so?
    aView isApplicationSubView ifTrue:[ 
        aView application commonPostBuild.
    ].

    "Created: / 07-10-2018 / 21:33:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBTabbingContainer methodsFor:'aspects'!

tabLabelList
    <resource: #uiAspect>

    ^ labels

    "Modified: / 10-06-2014 / 17:00:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

tabSelectionIndexHolder
    "return/create the 'tabSelectionIndexHolder' value holder (automatically generated)"

    tabSelectionIndexHolder isNil ifTrue:[
        tabSelectionIndexHolder := ValueHolder new.
        tabSelectionIndexHolder addDependent:self.
    ].
    ^ tabSelectionIndexHolder
!

tabSelectionViewHolder
    <resource: #uiAspect>

    "automatically generated by UIPainter ..."

    "*** the code below creates a default model when invoked."
    "*** (which may not be the one you wanted)"
    "*** Please change as required and accept it in the browser."
    "*** (and replace this comment by something more useful ;-)"

    tabSelectionViewHolder isNil ifTrue:[
        tabSelectionViewHolder := ValueHolder new.
"/ if your app needs to be notified of changes, uncomment one of the lines below:
"/       tabSelectionViewHolder addDependent:self.
"/       tabSelectionViewHolder onChangeSend:#tabSelectionViewHolderChanged to:self.
    ].
    ^ tabSelectionViewHolder.
! !

!VDBTabbingContainer methodsFor:'change & update'!

update:aspect with:param from:changedObject
    "Invoked when an object that I depend upon sends a change notification."

    "stub code automatically generated - please change as required"

    changedObject == components ifTrue:[
        self tabSelectionIndexHolder value isNil ifTrue:[ 
            components notEmpty ifTrue:[ 
                self tabSelectionIndexHolder value: 1.
            ].
        ].
        ^ self.
    ].
    changedObject == tabSelectionIndexHolder ifTrue:[            
        | i v |

        components notEmpty ifTrue:[ 
            i := self tabSelectionIndexHolder value ? 0.
            i := i max: 1.
            i := i min: components size.
            v := components at: i.
        ] ifFalse:[ 
            v := nil.
        ].
        self tabSelectionViewHolder value: v.
        ^ self.
    ].   

    super update:aspect with:param from:changedObject

    "Created: / 10-06-2014 / 15:53:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified (format): / 10-06-2014 / 17:08:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBTabbingContainer methodsFor:'initialization & release'!

initialize
    super initialize.
    components addDependent: self.

    "Created: / 10-06-2014 / 17:01:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBTabbingContainer methodsFor:'selection'!

selectApplication: anApplication
    | component |

    component := components detect:[ :each | each application == anApplication ].
    self selectComponent: component.

    "Created: / 01-10-2018 / 11:58:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

selectApplicationClass: aClass
    | component |

    component := components detect:[ :each | each application class == aClass ].
    self selectComponent: component.

    "Created: / 01-10-2018 / 11:58:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

selectComponent: aView
    | index |

    index := components indexOf: aView.
    self assert: index ~= 0.
    self tabSelectionIndexHolder value: index

    "Created: / 01-10-2018 / 11:57:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

selectedApplication
    ^ self selectedComponent application

    "Created: / 01-10-2018 / 12:00:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

selectedApplicationClass
    ^ self selectedApplication class

    "Created: / 01-10-2018 / 12:00:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

selectedComponent
    ^ components at: self tabSelectionIndexHolder value

    "Created: / 01-10-2018 / 11:59:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!VDBTabbingContainer class methodsFor:'documentation'!

version_HG

    ^ '$Changeset: <not expanded> $'
! !