MultiViewToolApplication.st
changeset 7650 12fcca896ba0
parent 7475 54b889153fc7
child 7653 71f20b5aab8d
--- a/MultiViewToolApplication.st	Mon Feb 19 16:05:35 2007 +0100
+++ b/MultiViewToolApplication.st	Mon Feb 19 16:06:19 2007 +0100
@@ -13,7 +13,7 @@
 
 ToolApplicationModel subclass:#MultiViewToolApplication
 	instanceVariableNames:'workspaces tabList selectedWorkspaceIndexHolder workspaceHolder'
-	classVariableNames:''
+	classVariableNames:'DefaultInfoVisible'
 	poolDictionaries:''
 	category:'Interface-Smalltalk'
 !
@@ -43,6 +43,39 @@
 "
 ! !
 
+!MultiViewToolApplication class methodsFor:'help specs'!
+
+helpSpec
+    "This resource specification was automatically generated
+     by the UIHelpTool of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the UIHelpTool may not be able to read the specification."
+
+    "
+     UIHelpTool openOnClass:MultiViewToolApplication    
+    "
+
+    <resource: #help>
+
+    ^ super helpSpec addPairsFrom:#(
+
+#hideToolBar
+''
+
+)
+! !
+
+!MultiViewToolApplication class methodsFor:'image specs'!
+
+hideToolBarIcon
+    <resource: #programImage>
+
+    ^ ToolbarIconLibrary hideToolBarIcon
+
+    "Created: / 18-02-2007 / 14:53:38 / cg"
+! !
+
 !MultiViewToolApplication class methodsFor:'interface specs'!
 
 windowSpec
@@ -53,9 +86,9 @@
      the UIPainter may not be able to read the specification."
 
     "
-     UIPainter new openOnClass:WorkspaceApplication andSelector:#windowSpec
-     WorkspaceApplication new openInterface:#windowSpec
-     WorkspaceApplication open
+     UIPainter new openOnClass:MultiViewToolApplication andSelector:#windowSpec
+     MultiViewToolApplication new openInterface:#windowSpec
+     MultiViewToolApplication open
     "
 
     <resource: #canvas>
@@ -74,8 +107,36 @@
         component: 
        (SpecCollection
           collection: (
+           (ViewSpec
+              name: 'ToolBar'
+              layout: (LayoutFrame 0 0 0 0 0 1 30 0)
+              visibilityChannel: toolBarVisibleHolder
+              component: 
+             (SpecCollection
+                collection: (
+                 (ActionButtonSpec
+                    label: 'hideToolBarIcon'
+                    name: 'HideToolBarButton'
+                    layout: (LayoutFrame 0 0 0 0 13 0 0 1)
+                    activeHelpKey: hideToolBar
+                    hasCharacterOrientedLabel: false
+                    translateLabel: true
+                    model: hideToolbar
+                    postBuildCallback: hideToolBarButtonCreated:
+                  )
+                 (MenuPanelSpec
+                    name: 'ToolBarMenu'
+                    layout: (LayoutFrame 13 0.0 0 0.0 0 1.0 0 1.0)
+                    visibilityChannel: toolBarVisibleHolder
+                    menu: toolBarMenu
+                    textDefault: true
+                  )
+                 )
+               
+              )
+            )
            (NoteBookViewSpec
-              name: 'NoteBook1'
+              name: 'NoteBook'
               layout: (LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
               model: selectedWorkspaceIndexHolder
               menu: tabList
@@ -201,6 +262,12 @@
             )
           )
          (MenuItem
+            label: 'View'
+            translateLabel: true
+            submenuChannel: viewMenu
+            keepLinkedMenu: true
+          )
+         (MenuItem
             label: 'Edit'
             translateLabel: true
             submenu: 
@@ -257,6 +324,8 @@
         nil
         nil
       )
+
+    "Modified: / 18-02-2007 / 15:18:25 / cg"
 !
 
 tabMenu
@@ -305,6 +374,78 @@
         nil
         nil
       )
+!
+
+toolBarMenu
+    "This resource specification was automatically generated
+     by the MenuEditor of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the MenuEditor may not be able to read the specification."
+
+    "
+     MenuEditor new openOnClass:MultiViewToolApplication andSelector:#toolBarMenu
+     (Menu new fromLiteralArrayEncoding:(MultiViewToolApplication toolBarMenu)) startUp
+    "
+
+    <resource: #menu>
+
+    ^ 
+     #(Menu
+        (
+         (MenuItem
+            label: ''
+          )
+         (MenuItem
+"/            activeHelpKey: addWorkspace
+            label: 'Add Buffer'
+            itemValue: addWorkspace
+            translateLabel: true
+            isButton: true
+            labelImage: (ResourceRetriever ToolbarIconLibrary addBufferIcon)
+          )
+         )
+        nil
+        nil
+      )
+
+    "Modified: / 18-02-2007 / 14:59:21 / cg"
+!
+
+viewMenu
+    "This resource specification was automatically generated
+     by the MenuEditor of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the MenuEditor may not be able to read the specification."
+
+    "
+     MenuEditor new openOnClass:WorkspaceApplication andSelector:#viewMenu
+     (Menu new fromLiteralArrayEncoding:(WorkspaceApplication viewMenu)) startUp
+    "
+
+    <resource: #menu>
+
+    ^ 
+     #(Menu
+        (
+         (MenuItem
+            label: 'Toolbar'
+            translateLabel: true
+            hideMenuOnActivated: false
+            indication: toolBarVisibleHolder
+          )
+         (MenuItem
+            label: 'Info'
+            translateLabel: true
+            isVisible: false
+            hideMenuOnActivated: false
+            indication: codeInfoVisible
+          )
+         )
+        nil
+        nil
+      )
 ! !
 
 !MultiViewToolApplication class methodsFor:'queries'!
@@ -380,6 +521,19 @@
 
 !MultiViewToolApplication methodsFor:'aspects'!
 
+infoVisibleHolder
+    |holder|
+
+    (holder := builder bindingAt:#infoVisibleHolder) isNil ifTrue:[
+        holder := (DefaultInfoVisible ? true) asValue.
+        builder aspectAt:#infoVisibleHolder put: holder.
+        holder addDependent:self.
+    ].
+    ^ holder
+
+    "Created: / 18-02-2007 / 15:01:05 / cg"
+!
+
 selectedWorkspaceIndexHolder
     selectedWorkspaceIndexHolder isNil ifTrue:[
         selectedWorkspaceIndexHolder := 1 asValue.
@@ -393,6 +547,19 @@
         tabList := List new.
     ].
     ^ tabList.
+!
+
+toolBarVisibleHolder
+    |holder|
+
+    (holder := builder bindingAt:#toolBarVisibleHolder) isNil ifTrue:[
+        holder := (DefaultToolBarVisible ? false) asValue.
+        builder aspectAt:#toolBarVisibleHolder put: holder.
+        holder addDependent:self.
+    ].
+    ^ holder
+
+    "Created: / 18-02-2007 / 14:43:39 / cg"
 ! !
 
 !MultiViewToolApplication methodsFor:'aspects-queries'!
@@ -417,6 +584,18 @@
     ^ v notNil and:[v selectionAsString size > 0]
 ! !
 
+!MultiViewToolApplication methodsFor:'change & update'!
+
+update:something with:aParameter from:changedObject
+    changedObject == self toolBarVisibleHolder ifTrue:[
+        self toolBarVisibilityChanged.
+        ^ self
+    ].
+    ^ super update:something with:aParameter from:changedObject
+
+    "Modified: / 18-02-2007 / 14:45:53 / cg"
+! !
+
 !MultiViewToolApplication methodsFor:'defaults'!
 
 defaultFileNameForLoad
@@ -443,6 +622,25 @@
     "Created: / 25-10-2006 / 14:57:18 / cg"
 ! !
 
+!MultiViewToolApplication methodsFor:'initialization'!
+
+hideToolBarButtonCreated:aButton
+    aButton passiveLevel:(MenuPanel defaultLevel). 
+"/    aButton passiveLevel:1.
+    aButton activeLevel:-1.
+    aButton backgroundColor:(MenuPanel defaultBackgroundColor).
+
+    "Created: / 18-02-2007 / 14:48:28 / cg"
+!
+
+postBuildWith:aBuilder
+    super postBuildWith:aBuilder.
+    self infoVisibleHolder value ifTrue:[ self infoVisibilityChanged ].
+    self toolBarVisibleHolder value ifTrue:[ self toolBarVisibilityChanged ].
+
+    "Created: / 18-02-2007 / 15:03:08 / cg"
+! !
+
 !MultiViewToolApplication methodsFor:'menu-actions'!
 
 addWindow:aWindow named:name
@@ -788,8 +986,63 @@
     ^ view
 ! !
 
+!MultiViewToolApplication methodsFor:'user actions'!
+
+hideToolbar
+    self toolBarVisibleHolder value:false
+
+    "Created: / 18-02-2007 / 14:55:54 / cg"
+!
+
+infoVisibilityChanged
+    |visible cFrame bottomOffset|
+
+    visible := self infoVisibleHolder value.
+
+    cFrame := builder findComponentAt:#EditorNoteBook. "/ #CodeView.
+    cFrame notNil ifTrue:[    
+        visible ifFalse:[
+            bottomOffset := 0.   
+        ] ifTrue:[
+            bottomOffset := -25.   
+        ].
+        cFrame layout bottomOffset:bottomOffset.   
+        cFrame container notNil ifTrue:[
+            cFrame containerChangedSize.
+        ].
+    ].
+    DefaultInfoVisible := visible
+
+    "Created: / 18-02-2007 / 15:01:55 / cg"
+!
+
+toolBarVisibilityChanged
+    |visible toolBar noteBook topOffset|
+
+    toolBar := self componentAt:#ToolBar.
+    toolBar isNil ifTrue:[
+        topOffset := 0.
+    ] ifFalse:[
+        visible := self toolBarVisibleHolder value.
+        DefaultToolBarVisible := visible.
+        visible ifTrue:[
+            topOffset := toolBar height.
+        ]
+    ].
+
+    noteBook := self componentAt:#NoteBook.
+    noteBook notNil ifTrue:[
+        noteBook layout topOffset:topOffset.
+        noteBook container notNil ifTrue:[
+            noteBook containerChangedSize.
+        ].
+    ].
+
+    "Created: / 18-02-2007 / 14:46:22 / cg"
+! !
+
 !MultiViewToolApplication class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/MultiViewToolApplication.st,v 1.12 2006-10-25 13:03:36 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/MultiViewToolApplication.st,v 1.13 2007-02-19 15:06:19 cg Exp $'
 ! !