ToolApplicationModel.st
changeset 872 a1606dcbd38b
parent 871 5d3b1dd9bac5
child 876 585929b1fec2
equal deleted inserted replaced
871:5d3b1dd9bac5 872:a1606dcbd38b
   107     ^label trimBlanks
   107     ^label trimBlanks
   108 !
   108 !
   109 
   109 
   110 settings
   110 settings
   111 
   111 
   112     ^settings ? (settings := IdentityDictionary new)
   112     settings isNil ifTrue: [settings := IdentityDictionary new].
       
   113     ^settings
   113 !
   114 !
   114 
   115 
   115 showHelp
   116 showHelp
   116 
   117 
   117     ^showHelp ? (showHelp := true)
   118     showHelp isNil ifTrue: [showHelp := true].
       
   119     ^showHelp
   118 !
   120 !
   119 
   121 
   120 showHelp: aBoolean
   122 showHelp: aBoolean
   121 
   123 
   122     ^showHelp := aBoolean
   124     ^showHelp := aBoolean
   736      
   738      
   737        #(#FullSpec
   739        #(#FullSpec
   738           #window: 
   740           #window: 
   739            #(#WindowSpec
   741            #(#WindowSpec
   740               #name: 'Info Bar'
   742               #name: 'Info Bar'
   741               #layout: #(#LayoutFrame 431 0 352 0 930 0 697 0)
   743               #layout: #(#LayoutFrame 160 0 423 0 659 0 453 0)
   742               #label: 'Info Bar'
   744               #label: 'Info Bar'
   743               #min: #(#Point 400 320)
   745               #min: #(#Point 400 320)
   744               #max: #(#Point 1152 900)
   746               #max: #(#Point 1152 900)
   745               #bounds: #(#Rectangle 431 352 931 698)
   747               #bounds: #(#Rectangle 160 423 660 454)
   746               #menu: #menu
   748               #menu: #menu
   747               #usePreferredExtent: false
   749               #usePreferredExtent: false
   748           )
   750           )
   749           #component: 
   751           #component: 
   750            #(#SpecCollection
   752            #(#SpecCollection
   761                               #name: 'infoLabel'
   763                               #name: 'infoLabel'
   762                               #layout: #(#LayoutFrame 2 0 1 0.0 -81 1 -1 1.0)
   764                               #layout: #(#LayoutFrame 2 0 1 0.0 -81 1 -1 1.0)
   763                               #labelChannel: #valueOfInfoLabel
   765                               #labelChannel: #valueOfInfoLabel
   764                               #level: -1
   766                               #level: -1
   765                               #adjust: #left
   767                               #adjust: #left
       
   768                               #resizeForLabel: false
   766                           )
   769                           )
   767                            #(#LabelSpec
   770                            #(#LabelSpec
   768                               #name: 'timeLabel'
   771                               #name: 'timeLabel'
   769                               #layout: #(#LayoutFrame -79 1 1 0.0 -1 1.0 -1 1.0)
   772                               #layout: #(#LayoutFrame -79 1 1 0.0 -1 1.0 -1 1.0)
   770                               #labelChannel: #valueOfTimeLabel
   773                               #labelChannel: #valueOfTimeLabel
   771                               #level: -1
   774                               #level: -1
   772                               #adjust: #right
   775                               #adjust: #right
       
   776                               #resizeForLabel: false
   773                           )
   777                           )
   774                         )
   778                         )
   775                     )
   779                     )
   776                 )
   780                 )
   777               )
   781               )
   838      
   842      
   839        #(#Menu
   843        #(#Menu
   840           
   844           
   841            #(
   845            #(
   842              #(#MenuItem
   846              #(#MenuItem
   843                 #label: 'Label Font...'
   847                 #label: 'Menu...'
       
   848                 #value: #chooseFont:
       
   849                 #argument: 'Menu Font'
       
   850             )
       
   851              #(#MenuItem
       
   852                 #label: 'Label...'
   844                 #value: #chooseFont:
   853                 #value: #chooseFont:
   845                 #argument: 'Label Font'
   854                 #argument: 'Label Font'
   846             )
   855             )
   847              #(#MenuItem
   856              #(#MenuItem
   848                 #label: 'Button Font...'
   857                 #label: 'Button...'
   849                 #value: #chooseFont:
   858                 #value: #chooseFont:
   850                 #argument: 'Button Font'
   859                 #argument: 'Button Font'
   851             )
   860             )
   852              #(#MenuItem
   861              #(#MenuItem
   853                 #label: 'Edit Font...'
   862                 #label: 'Edit...'
   854                 #value: #chooseFont:
   863                 #value: #chooseFont:
   855                 #argument: 'Edit Font'
   864                 #argument: 'Edit Font'
   856             )
   865             )
   857              #(#MenuItem
   866              #(#MenuItem
   858                 #label: 'List Font...'
   867                 #label: 'List...'
   859                 #value: #chooseFont:
   868                 #value: #chooseFont:
   860                 #argument: 'List Font'
   869                 #argument: 'List Font'
   861             )
   870             )
   862              #(#MenuItem
   871              #(#MenuItem
   863                 #label: 'Tree List Font...'
   872                 #label: 'Tree List...'
   864                 #value: #chooseFont:
   873                 #value: #chooseFont:
   865                 #argument: 'Tree List Font'
   874                 #argument: 'Tree List Font'
   866             )
   875             )
   867              #(#MenuItem
   876              #(#MenuItem
       
   877                 #label: 'Note Book...'
       
   878                 #value: #chooseFont:
       
   879                 #argument: 'Note Book Font'
       
   880             )
       
   881              #(#MenuItem
       
   882                 #label: 'Framed Box...'
       
   883                 #value: #chooseFont:
       
   884                 #argument: 'Framed Box Font'
       
   885             )
       
   886              #(#MenuItem
   868                 #label: '-'
   887                 #label: '-'
   869             )
   888             )
   870              #(#MenuItem
   889              #(#MenuItem
   871                 #label: 'Reset Fonts'
   890                 #label: 'Reset'
   872                 #value: #resetFonts
   891                 #value: #resetFonts
   873             )
   892             )
   874           ) nil
   893           ) nil
   875           nil
   894           nil
   876       )
   895       )
  1195     ^window minExtent max: (preferredExtentOfWindow min: window maxExtent)
  1214     ^window minExtent max: (preferredExtentOfWindow min: window maxExtent)
  1196 ! !
  1215 ! !
  1197 
  1216 
  1198 !ToolApplicationModel methodsFor:'settings'!
  1217 !ToolApplicationModel methodsFor:'settings'!
  1199 
  1218 
       
  1219 allFontViewsDo: aBlock
       
  1220     "evaluate aBlock for all views with fonts"
       
  1221 
       
  1222     |fontViews|
       
  1223 
       
  1224     fontViews := OrderedCollection new.
       
  1225 
       
  1226     self builder windowGroup views do: [:v| v class = MenuPanel ifTrue: [fontViews add: v]]. 
       
  1227 
       
  1228     builder namedComponents do: 
       
  1229     [:aView|    
       
  1230         aView allSubViewsDo: 
       
  1231         [:v|
       
  1232             v font notNil ifTrue: [fontViews add: v]
       
  1233         ] 
       
  1234     ].
       
  1235     fontViews do: aBlock
       
  1236 !
       
  1237 
  1200 chooseFont: viewFont
  1238 chooseFont: viewFont
  1201     "choose a font for viewFont and put it into the settings dictionary;
  1239     "choose a font for viewFont and put it into the settings dictionary;
  1202      finally update all my views"
  1240      finally update all my views"
  1203 
  1241 
  1204     |defaultFont font|
  1242     |defaultFont font|
  1205 
  1243 
  1206     viewFont = 'Label Font'     ifTrue: [defaultFont := Label defaultFont].
  1244     viewFont = 'Menu Font'       ifTrue: [defaultFont := MenuPanel defaultFont].
  1207     viewFont = 'Button Font'    ifTrue: [defaultFont := Button defaultFont].
  1245     viewFont = 'Label Font'      ifTrue: [defaultFont := Label defaultFont].
  1208     viewFont = 'Edit Font'      ifTrue: [defaultFont := TextView defaultFont].
  1246     viewFont = 'Button Font'     ifTrue: [defaultFont := Button defaultFont].
  1209     viewFont = 'List Font'      ifTrue: [defaultFont := ListView defaultFont].
  1247     viewFont = 'Edit Font'       ifTrue: [defaultFont := TextView defaultFont].
  1210     viewFont = 'Tree List Font' ifTrue: [defaultFont := SelectionInTreeView defaultFont].
  1248     viewFont = 'List Font'       ifTrue: [defaultFont := ListView defaultFont].
       
  1249     viewFont = 'Tree List Font'  ifTrue: [defaultFont := SelectionInTreeView defaultFont].
       
  1250     viewFont = 'Note Book Font'  ifTrue:[defaultFont := NoteBookView defaultFont].
       
  1251     viewFont = 'Framed Box Font' ifTrue: [defaultFont := FramedBox defaultFont].
  1211 
  1252 
  1212     (font := FontPanel 
  1253     (font := FontPanel 
  1213         fontFromUserInitial: (self class settings at: viewFont asSymbol ifAbsent: nil) ? defaultFont
  1254         fontFromUserInitial: (self class settings at: viewFont asSymbol ifAbsent: nil) ? defaultFont
  1214         title: 'Choose ', viewFont) notNil
  1255         title: 'Choose ', viewFont) notNil
  1215     ifTrue:
  1256     ifTrue:
  1216     [   
  1257     [      
  1217         self class settings at: viewFont asSymbol put: (font on: device).
  1258         self class settings at: viewFont asSymbol put: (font on: device).
  1218         self updateFonts
  1259         self updateFonts
  1219     ].
  1260     ].
  1220     ^font
  1261     ^font
  1221 !
  1262 !
  1222 
  1263 
  1223 resetFonts
  1264 resetFonts
  1224     "set the fonts in the settings to nil and set the views to its default font"
  1265     "set the fonts in the settings to nil and set the views to its default font"
  1225 
  1266 
  1226     (self class settings) 
  1267     (self class settings)
  1227         removeKey: #'Label Font'     ifAbsent: nil;
  1268         removeKey: #'Menu Font'       ifAbsent: nil;
  1228         removeKey: #'Button Font'    ifAbsent: nil;
  1269         removeKey: #'Label Font'      ifAbsent: nil;
  1229         removeKey: #'Edit Font'      ifAbsent: nil;
  1270         removeKey: #'Button Font'     ifAbsent: nil;
  1230         removeKey: #'List Font'      ifAbsent: nil;
  1271         removeKey: #'Edit Font'       ifAbsent: nil;
  1231         removeKey: #'Tree List Font' ifAbsent: nil.
  1272         removeKey: #'List Font'       ifAbsent: nil;
  1232 
  1273         removeKey: #'Tree List Font'  ifAbsent: nil;
  1233     builder namedComponents do: 
  1274         removeKey: #'Note Book Font'  ifAbsent: nil;
  1234     [:aView|    
  1275         removeKey: #'Framed Box Font' ifAbsent: nil.
  1235         aView allSubViewsDo: 
  1276 
  1236         [:aSubView|
  1277     self allFontViewsDo: 
  1237             aSubView font: aSubView class defaultFont.
  1278     [:v|    
  1238             aSubView realize
  1279         v font: v class defaultFont.
  1239         ] 
  1280         v invalidate
  1240     ]
  1281     ]
  1241      
  1282 
  1242 !
  1283 !
  1243 
  1284 
  1244 updateFonts
  1285 updateFonts
  1245     "take defined fonts from the settings and set them to the corresponding views"
  1286     "take defined fonts from the settings and set them to the corresponding views"
  1246 
  1287 
  1247     |settings labelFont buttonFont editFont listFont treeListFont|
  1288     |settings labelFont buttonFont menuFont editFont listFont treeListFont noteBookFont framedBoxFont updateFontsBlock|
  1248 
  1289 
  1249     settings     := self class settings.
  1290     settings     := self class settings.
  1250 
  1291 
  1251     labelFont    := settings at: #'Label Font'     ifAbsent: nil.
  1292     labelFont     := settings at: #'Label Font'      ifAbsent: nil.
  1252     buttonFont   := settings at: #'Button Font'    ifAbsent: nil.
  1293     buttonFont    := settings at: #'Button Font'     ifAbsent: nil.
  1253     editFont     := settings at: #'Edit Font'      ifAbsent: nil.
  1294     menuFont      := settings at: #'Menu Font'       ifAbsent: nil.
  1254     listFont     := settings at: #'List Font'      ifAbsent: nil.
  1295     editFont      := settings at: #'Edit Font'       ifAbsent: nil.
  1255     treeListFont := settings at: #'Tree List Font' ifAbsent: nil.
  1296     listFont      := settings at: #'List Font'       ifAbsent: nil.
  1256 
  1297     treeListFont  := settings at: #'Tree List Font'  ifAbsent: nil.
  1257     builder namedComponents do: 
  1298     noteBookFont  := settings at: #'Note Book Font'  ifAbsent: nil.
  1258     [:aView|
  1299     framedBoxFont := settings at: #'Framed Box Font' ifAbsent: nil.
  1259         aView allSubViewsDo: 
  1300 
  1260         [:aSubView|
  1301     updateFontsBlock :=
  1261             (labelFont notNil and: [aSubView font ~= labelFont and: [(aSubView class == Label) or: [(aSubView isKindOf: Toggle) or: [aSubView class = FramedBox or: [aSubView class == NoteBookView]]]]])
  1302     [:v|     
  1262                 ifTrue: [aSubView font: labelFont; fixSize; sizeChanged:nil; invalidate].
  1303         (labelFont notNil and: [v font ~= labelFont and: [(v class == Label) or: [v isKindOf: Toggle]]])
  1263             (buttonFont notNil and: [aSubView font ~= buttonFont and: [aSubView class == Button or: [aSubView class == PopUpList]]])
  1304             ifTrue: [v font: labelFont; fixSize; sizeChanged:nil; invalidate].
  1264                 ifTrue: [aSubView label isString ifTrue: [aSubView sizeFixed: true. aSubView font: buttonFont; invalidate]].
  1305         (buttonFont notNil and: [v font ~= buttonFont and: [v class == Button or: [v class == PopUpList]]])
  1265             (editFont  notNil and: [aSubView font ~= editFont and: [aSubView isKindOf: TextView]])
  1306             ifTrue: [v label isString ifTrue: [v sizeFixed: true. v font: buttonFont; invalidate]].
  1266                 ifTrue: [aSubView font: editFont; invalidate].
  1307         (menuFont notNil and: [v font ~= menuFont and: [v class == MenuPanel]])
  1267             (listFont notNil and: [aSubView font ~= listFont and: [aSubView class = SelectionInListView or: [aSubView class = DataSetView]]])
  1308             ifTrue: [v font: menuFont; invalidate].
  1268                 ifTrue: [aSubView font: listFont. aSubView invalidate].
  1309         (editFont  notNil and: [v font ~= editFont and: [v isKindOf: TextView]])
  1269             (treeListFont notNil and: [aSubView font ~= treeListFont and: [aSubView isKindOf: SelectionInTreeView]])
  1310             ifTrue: [v font: editFont; invalidate].
  1270                 ifTrue: [aSubView font: treeListFont; invalidate].
  1311         (listFont notNil and: [v font ~= listFont and: [v class = SelectionInListView or: [v class = DataSetView]]])
  1271         ]
  1312             ifTrue: [v font: listFont. v invalidate].
  1272     ]
  1313         (treeListFont notNil and: [v font ~= treeListFont and: [v isKindOf: SelectionInTreeView]])
       
  1314             ifTrue: [v font: treeListFont; invalidate].
       
  1315         (noteBookFont notNil and: [v font ~= noteBookFont and: [v class == NoteBookView]])
       
  1316             ifTrue: [v font: noteBookFont; invalidate].
       
  1317         (framedBoxFont notNil and: [v font ~= framedBoxFont and: [v class == FramedBox]])
       
  1318             ifTrue: [v font: framedBoxFont; invalidate]
       
  1319     ].
       
  1320 
       
  1321     self allFontViewsDo: [:v| updateFontsBlock value: v] 
       
  1322 
  1273 ! !
  1323 ! !
  1274 
  1324 
  1275 !ToolApplicationModel methodsFor:'startup / release'!
  1325 !ToolApplicationModel methodsFor:'startup / release'!
  1276 
  1326 
  1277 allButOpenInterface:aSymbol
  1327 allButOpenInterface:aSymbol
  1337 ! !
  1387 ! !
  1338 
  1388 
  1339 !ToolApplicationModel class methodsFor:'documentation'!
  1389 !ToolApplicationModel class methodsFor:'documentation'!
  1340 
  1390 
  1341 version
  1391 version
  1342     ^ '$Header: /cvs/stx/stx/libview2/ToolApplicationModel.st,v 1.48 1998-03-20 20:18:57 tz Exp $'
  1392     ^ '$Header: /cvs/stx/stx/libview2/ToolApplicationModel.st,v 1.49 1998-03-23 21:41:56 tz Exp $'
  1343 ! !
  1393 ! !