UISpecificationTool.st
author Claus Gittinger <cg@exept.de>
Wed, 29 Jul 2009 20:02:02 +0200
changeset 2570 4e663bc64364
parent 2545 cd5d45739973
child 2631 8d74338aa3bd
permissions -rw-r--r--
changed #requestPackage
ca@164
     1
"
ca@164
     2
 COPYRIGHT (c) 1995 by eXept Software AG
ca@164
     3
              All Rights Reserved
ca@164
     4
ca@164
     5
 This software is furnished under a license and may be used
ca@164
     6
 only in accordance with the terms of that license and with the
ca@164
     7
 inclusion of the above copyright notice.   This software may not
ca@164
     8
 be provided or otherwise made available to, or used by, any
ca@164
     9
 other person.  No title to or ownership of the software is
ca@164
    10
 hereby transferred.
ca@164
    11
"
cg@1386
    12
"{ Package: 'stx:libtool2' }"
cg@1386
    13
ca@164
    14
ApplicationModel subclass:#UISpecificationTool
ca@759
    15
	instanceVariableNames:'modifiedHolder aspects specification selection specChannel
ca@1307
    16
		buildInView listOfSpecViews'
ca@164
    17
	classVariableNames:''
ca@164
    18
	poolDictionaries:''
ca@164
    19
	category:'Interface-UIPainter'
ca@164
    20
!
ca@164
    21
ca@1307
    22
ViewScroller subclass:#BuildInView
ca@1573
    23
	instanceVariableNames:''
ca@1307
    24
	classVariableNames:''
ca@1307
    25
	poolDictionaries:''
ca@1307
    26
	privateIn:UISpecificationTool
ca@1307
    27
!
ca@1307
    28
ca@164
    29
!UISpecificationTool class methodsFor:'documentation'!
ca@164
    30
ca@164
    31
copyright
ca@164
    32
"
ca@164
    33
 COPYRIGHT (c) 1995 by eXept Software AG
ca@164
    34
              All Rights Reserved
ca@164
    35
ca@164
    36
 This software is furnished under a license and may be used
ca@164
    37
 only in accordance with the terms of that license and with the
ca@164
    38
 inclusion of the above copyright notice.   This software may not
ca@164
    39
 be provided or otherwise made available to, or used by, any
ca@164
    40
 other person.  No title to or ownership of the software is
ca@164
    41
 hereby transferred.
ca@164
    42
"
ca@164
    43
ca@164
    44
ca@164
    45
ca@164
    46
!
ca@164
    47
ca@164
    48
documentation
ca@164
    49
"
ca@164
    50
    used by the UIPainter to manipulate the specifications of the selected component
ca@164
    51
ca@164
    52
    [author:]
ca@164
    53
        Claus Atzkern
ca@164
    54
ca@164
    55
    [see also:]
ca@164
    56
        UIPainter
ca@164
    57
        UILayoutTool
ca@164
    58
        UIHelpTool
ca@164
    59
"
ca@164
    60
! !
ca@164
    61
cg@1963
    62
!UISpecificationTool class methodsFor:'help specs'!
cg@1963
    63
cg@1963
    64
helpSpec
cg@1963
    65
    "This resource specification was automatically generated
cg@1963
    66
     by the UIHelpTool of ST/X."
cg@1963
    67
cg@1963
    68
    "Do not manually edit this!! If it is corrupted,
cg@1963
    69
     the UIHelpTool may not be able to read the specification."
cg@1963
    70
cg@1963
    71
    "
cg@1963
    72
     UIHelpTool openOnClass:UISpecificationTool    
cg@1963
    73
    "
cg@1963
    74
cg@1963
    75
    <resource: #help>
cg@1963
    76
cg@1963
    77
    ^ super helpSpec addPairsFrom:#(
cg@1963
    78
sv@2316
    79
#allowSymbolicColors
cg@2335
    80
'ColorMenu is allowed to return a symbolic color name'
cg@2335
    81
cg@2335
    82
#allowSymbolicFonts
cg@2335
    83
'FontMenu is allowed to return a symbolic font name'
sv@2316
    84
cg@1963
    85
#autoScrollHorizontal
cg@1963
    86
''
cg@1963
    87
cg@2209
    88
#browseAction
cg@2209
    89
'Browse/Create the Action method.'
cg@2209
    90
cg@2237
    91
#browseAspectMethod
cg@2237
    92
'Browse/Create the Aspect method.'
cg@2237
    93
sv@2283
    94
#editListSpec
sv@2283
    95
'Edit the contents of the list (inline)'
sv@2283
    96
cg@2239
    97
#formatString
cg@2239
    98
''
cg@2239
    99
sv@2316
   100
#labelsAreColored
sv@2316
   101
'Show color in ColorMenuLabels'
sv@2316
   102
cg@2377
   103
#showFrame
cg@2377
   104
'Show the frame'
cg@2377
   105
cg@2239
   106
#textModel
cg@2239
   107
''
cg@2239
   108
cg@2377
   109
#translateLabel
cg@2377
   110
''
cg@2377
   111
cg@1963
   112
)
cg@1963
   113
! !
cg@1963
   114
cg@2209
   115
!UISpecificationTool class methodsFor:'image specs'!
cg@2209
   116
cg@2209
   117
browseActionImage
cg@2209
   118
    ^ UIPainter browseActionImage
sv@2283
   119
!
sv@2283
   120
sv@2283
   121
editTableIcon
sv@2283
   122
    ^ UIPainter editTableIcon
cg@2209
   123
! !
cg@2209
   124
ca@164
   125
!UISpecificationTool class methodsFor:'interface specs'!
ca@164
   126
ca@164
   127
windowSpec
ca@1307
   128
    "This resource specification was automatically generated
ca@1307
   129
     by the UIPainter of ST/X."
ca@164
   130
ca@1307
   131
    "Do not manually edit this!! If it is corrupted,
ca@1307
   132
     the UIPainter may not be able to read the specification."
ca@164
   133
ca@164
   134
    "
ca@164
   135
     UIPainter new openOnClass:UISpecificationTool andSelector:#windowSpec
ca@164
   136
     UISpecificationTool new openInterface:#windowSpec
ca@1307
   137
     UISpecificationTool open
ca@164
   138
    "
ca@164
   139
ca@164
   140
    <resource: #canvas>
ca@164
   141
ca@1307
   142
    ^ 
ca@1307
   143
     #(#FullSpec
ca@1307
   144
        #name: #windowSpec
ca@1307
   145
        #window: 
ca@1307
   146
       #(#WindowSpec
ca@1307
   147
          #label: 'unnamed canvas'
ca@1307
   148
          #name: 'unnamed canvas'
ca@1313
   149
          #bounds: #(#Rectangle 12 22 312 322)
ca@1307
   150
        )
ca@1307
   151
        #component: 
ca@1307
   152
       #(#SpecCollection
ca@1307
   153
          #collection: #(
ca@1307
   154
           #(#ArbitraryComponentSpec
ca@1313
   155
              #name: 'BuildInView'
ca@1307
   156
              #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
ca@1313
   157
              #hasVerticalScrollBar: true
ca@1313
   158
              #miniScrollerVertical: true
ca@1313
   159
              #autoHideScrollBars: true
ca@1307
   160
              #hasBorder: false
ca@1313
   161
              #component: #buildInView
ca@1307
   162
            )
ca@1307
   163
           )
ca@1307
   164
         
ca@1307
   165
        )
ca@164
   166
      )
ca@164
   167
! !
ca@164
   168
cg@1781
   169
!UISpecificationTool class methodsFor:'resources'!
cg@1781
   170
cg@1781
   171
classResources
cg@1781
   172
    "my translations are found in the UIPainter classes resources"
cg@1781
   173
cg@1781
   174
    ^ UIPainter classResources 
cg@1781
   175
! !
cg@1781
   176
cg@1331
   177
!UISpecificationTool methodsFor:'accessing-channels'!
ca@164
   178
ca@1315
   179
modifiedHolder:aValueHolder
ca@1315
   180
    "set the value holder set to true in case of modifying attributes
ca@1315
   181
    "
cg@1063
   182
ca@1315
   183
    modifiedHolder removeDependent:self.
ca@1315
   184
ca@1315
   185
    (modifiedHolder := aValueHolder) notNil ifTrue:[
ca@1315
   186
        modifiedHolder addDependent:self.
ca@1315
   187
    ].
ca@1315
   188
ca@1315
   189
! !
ca@1315
   190
cg@1331
   191
!UISpecificationTool methodsFor:'accessing-specification'!
cg@1063
   192
cg@2245
   193
listOfAspects
cg@2245
   194
    ^ masterApplication listOfAspects
cg@2245
   195
cg@2245
   196
    "Created: / 12-01-2008 / 19:24:39 / cg"
cg@2245
   197
!
cg@2245
   198
cg@2245
   199
listOfCallbacks
cg@2245
   200
    ^ masterApplication listOfCallbacks
cg@2245
   201
cg@2245
   202
    "Created: / 12-01-2008 / 19:25:05 / cg"
cg@2245
   203
!
cg@2245
   204
ca@172
   205
specification
ca@172
   206
    "gets current edit specification
ca@172
   207
    "
ca@172
   208
    ^ specification
ca@172
   209
ca@172
   210
ca@172
   211
!
ca@172
   212
ca@172
   213
specification:aSpec
ca@172
   214
    "sets current edit specification
ca@172
   215
    "
ca@1315
   216
    aSpec notNil ifTrue:[
ca@1315
   217
        "/ same type of spec - simply change the spec;  no need to setup everything
ca@1315
   218
        specification class == aSpec class ifTrue:[
ca@1315
   219
            specification := aSpec.
ca@1315
   220
            specChannel value:specification.
ca@1315
   221
          ^ self
ca@1315
   222
        ]
ca@1307
   223
    ].
ca@428
   224
ca@1315
   225
    "/ release resources
ca@1315
   226
    specChannel release.
ca@1315
   227
    aspects     release.
ca@1315
   228
    selection := listOfSpecViews := nil.
ca@1573
   229
    buildInView destroyAllClientViews.
ca@1315
   230
ca@1315
   231
    (specification := aSpec) isNil ifTrue:[
ca@1315
   232
        aspects := specChannel := nil.
ca@1315
   233
      ^ self
ca@1307
   234
    ].
ca@1307
   235
    
ca@1307
   236
    "/ some tricky specs need the builder during the addBindings phase.
ca@1307
   237
    "/ This is passed down in a special UIBindingsDictionary
ca@1307
   238
    "/ (remain backward compatible)
ca@428
   239
ca@1307
   240
    aspects := UISpecification newBindingsDictionary.
ca@1307
   241
    aspects builder:builder.
ca@1307
   242
    aspects at:#modifiedChannel put:modifiedHolder.
ca@1307
   243
    aspects at:#acceptChannel   put:self acceptChannel.
cg@893
   244
cg@2245
   245
    aspects at:#listOfAspects put:[self listOfAspects].
cg@2245
   246
    aspects at:#listOfCallbacks put:[self listOfCallbacks].
cg@2245
   247
ca@1307
   248
    specChannel := specification asValue.
ca@1307
   249
    specification class addBindingsTo:aspects for:specification channel:specChannel.
cg@893
   250
ca@1307
   251
    "/ arrange for being notified, if any aspect changes
ca@1307
   252
    aspects do:[:el| el addDependent:self ].
cg@2245
   253
cg@2245
   254
    "Modified: / 12-01-2008 / 19:28:47 / cg"
ca@172
   255
! !
ca@172
   256
cg@364
   257
!UISpecificationTool methodsFor:'actions'!
cg@364
   258
cg@364
   259
setMaxExtent
cg@364
   260
    "set the windows maxExtent from its current extent"
cg@364
   261
cg@364
   262
    |canvas currentExtent|
cg@364
   263
cg@2211
   264
    canvas := self masterApplication canvas.
cg@364
   265
    currentExtent := canvas extent.
cg@364
   266
    (self aspectFor:#maxX) value:currentExtent x.
cg@364
   267
    (self aspectFor:#maxY) value:currentExtent y.
cg@364
   268
cg@364
   269
    "Modified: / 29.10.1997 / 18:29:17 / cg"
cg@364
   270
!
cg@364
   271
cg@364
   272
setMinExtent
cg@364
   273
    "set the windows minExtent from its current extent"
cg@364
   274
cg@364
   275
    |canvas currentExtent|
cg@364
   276
cg@2211
   277
    canvas := self masterApplication canvas.
cg@364
   278
    currentExtent := canvas extent.
cg@364
   279
    (self aspectFor:#minX) value:currentExtent x.
cg@364
   280
    (self aspectFor:#minY) value:currentExtent y.
cg@364
   281
cg@364
   282
    "Created: / 29.10.1997 / 18:17:55 / cg"
cg@364
   283
    "Modified: / 29.10.1997 / 18:28:53 / cg"
cg@364
   284
! !
cg@364
   285
ca@164
   286
!UISpecificationTool methodsFor:'bindings'!
ca@164
   287
ca@1315
   288
acceptChannel
cg@2245
   289
    ^ masterApplication acceptChannel
ca@1315
   290
cg@2245
   291
    "Modified: / 12-01-2008 / 11:28:38 / cg"
ca@1315
   292
!
ca@1315
   293
ca@164
   294
aspectFor:aKey
cg@2245
   295
    "returns the aspect for a key or nil"
cg@2245
   296
ca@164
   297
    aspects notNil ifTrue:[
ca@164
   298
        ^ aspects at:aKey ifAbsent:nil
ca@164
   299
    ].
ca@164
   300
    ^ super aspectFor:aKey
ca@164
   301
cg@2245
   302
    "Modified: / 12-01-2008 / 11:28:52 / cg"
ca@428
   303
!
ca@428
   304
ca@1313
   305
buildInView
ca@1313
   306
    ^ buildInView
ca@1307
   307
!
ca@1307
   308
sv@584
   309
specificationFor:aKey
sv@584
   310
    "this is called if our current specification contains 
sv@584
   311
     subspecifications or subcanvases.
sv@584
   312
     Get the subspecification from the current specification"
sv@584
   313
ca@1307
   314
    specification notNil ifTrue:[
ca@1307
   315
        ^ specification class perform:aKey ifNotUnderstood:nil
sv@584
   316
    ].
sv@584
   317
    ^ nil
ca@164
   318
! !
ca@164
   319
ca@164
   320
!UISpecificationTool methodsFor:'change & update'!
ca@164
   321
ca@172
   322
update
ca@172
   323
    "reload specification
ca@172
   324
    "
ca@172
   325
    specChannel notNil ifTrue:[
ca@172
   326
        specChannel value:specification.
ca@172
   327
    ]
ca@172
   328
ca@172
   329
ca@172
   330
!
ca@172
   331
ca@164
   332
update:something with:someArgument from:someone
ca@164
   333
    "any attribute changed its state in the current specification
ca@164
   334
    "
ca@164
   335
    someone ~~ modifiedHolder ifTrue:[
cg@893
   336
        "/ any in the spec has changed.
cg@893
   337
        "/ update my modified holders value
cg@893
   338
cg@1071
   339
        modifiedHolder value:true
ca@164
   340
    ]
ca@164
   341
cg@893
   342
    "Modified: / 16.7.1998 / 19:25:59 / cg"
ca@164
   343
! !
ca@164
   344
cg@1956
   345
!UISpecificationTool methodsFor:'help'!
cg@1956
   346
cg@2524
   347
basicFlyByHelpTextForKey:aKey
cg@2524
   348
    "activeHelp interface: return some help text for a key.
cg@2524
   349
     Redefined to ask the current components Spec first."
cg@2524
   350
cg@2524
   351
    |helpText|
cg@2524
   352
cg@2524
   353
    "/ first, ask the master (a hook for expecco, to provide different help texts)
cg@2524
   354
    masterApplication notNil ifTrue:[
cg@2524
   355
        helpText := masterApplication basicFlyByHelpTextForKey:aKey.
cg@2524
   356
        helpText notNil ifTrue:[^ helpText ].
cg@2545
   357
cg@2545
   358
        "/ then, ask the master about the spec
cg@2545
   359
        helpText := masterApplication basicHelpTextFromSpecification:specification forKey:aKey.
cg@2545
   360
    ] ifFalse:[
cg@2545
   361
        "/ then, ask the spec
cg@2545
   362
        helpText := (specification helpSpec) at:aKey ifAbsent:nil.
cg@2524
   363
    ].
cg@2524
   364
    helpText notNil ifTrue:[^ helpText ].
cg@2524
   365
cg@2524
   366
    "/ finally, ask myself...
cg@2524
   367
    ^ super basicFlyByHelpTextForKey:aKey.
cg@2524
   368
!
cg@2524
   369
cg@1956
   370
basicHelpTextForKey:aKey
cg@1956
   371
    "activeHelp interface: return some help text for a key.
cg@1956
   372
     Redefined to ask the current components Spec first."
cg@1956
   373
cg@1956
   374
    |helpText|
cg@1956
   375
cg@2524
   376
    "/ first, ask the master (a hook for expecco, to provide different help texts)
cg@2524
   377
    masterApplication notNil ifTrue:[
cg@2524
   378
        helpText := masterApplication basicHelpTextForKey:aKey.
cg@2524
   379
        helpText notNil ifTrue:[^ helpText ].
cg@2545
   380
cg@2545
   381
        "/ then, ask the master about the spec
cg@2545
   382
        helpText := masterApplication basicHelpTextFromSpecification:specification forKey:aKey.
cg@2545
   383
    ] ifFalse:[
cg@2545
   384
        "/ then, ask the spec
cg@2545
   385
        helpText := (specification helpSpec) at:aKey ifAbsent:nil.
cg@2524
   386
    ].
cg@2524
   387
    helpText notNil ifTrue:[^ helpText ].
cg@1956
   388
cg@2524
   389
    "/ finally, ask myself...
cg@2524
   390
    ^ super basicHelpTextForKey:aKey.
cg@1956
   391
! !
cg@1956
   392
ca@1315
   393
!UISpecificationTool methodsFor:'initialization'!
ca@1315
   394
ca@1315
   395
initialize
ca@1315
   396
    super initialize.
ca@1315
   397
    buildInView := BuildInView new.
ca@1573
   398
    buildInView keepViews:true.
ca@1315
   399
! !
ca@1315
   400
ca@164
   401
!UISpecificationTool methodsFor:'selection'!
ca@164
   402
ca@164
   403
selection:something
ca@172
   404
    "selection changed
ca@172
   405
    "
ca@1307
   406
    |slices index spec window|
ca@164
   407
ca@172
   408
    specification notNil ifTrue:[
ca@172
   409
        slices := specification class slices.
ca@1307
   410
        index  := slices findFirst:[:aSlice| aSlice first = something ].
ca@164
   411
ca@1307
   412
        index ~~ 0 ifTrue:[
ca@1307
   413
            spec := specification class perform:((slices at:index) last)
ca@428
   414
        ]
ca@164
   415
    ].
ca@164
   416
ca@172
   417
    spec ~= selection ifTrue:[
ca@1307
   418
        (selection := spec) notNil ifTrue:[
ca@1307
   419
            listOfSpecViews isNil ifTrue:[
ca@1307
   420
                listOfSpecViews := Array new:(slices size).
ca@1307
   421
            ] ifFalse:[
ca@1307
   422
                window := listOfSpecViews at:index
ca@1307
   423
            ].
ca@1307
   424
            window isNil ifTrue:[
ca@1307
   425
                builder buildFromSpec:spec in:(window := SimpleView new).
ca@1307
   426
                listOfSpecViews at:index put:window.
ca@1307
   427
            ].
ca@1307
   428
        ].
ca@1315
   429
        buildInView scrolledView:window.
ca@164
   430
    ].
ca@164
   431
! !
ca@164
   432
ca@1307
   433
!UISpecificationTool::BuildInView methodsFor:'accessing'!
ca@759
   434
ca@2160
   435
mapped
ca@2160
   436
    super mapped.
ca@2160
   437
ca@2160
   438
    scrolledView notNil ifTrue:[
ca@2160
   439
        scrolledView beVisible.
ca@2160
   440
        scrolledView raise.
ca@2160
   441
    ].
ca@2160
   442
!
ca@2160
   443
ca@1307
   444
scrolledView:aView
ca@1307
   445
    "set the view to be scrolled"
ca@1573
   446
    |wrapper y|
ca@759
   447
ca@1307
   448
    scrolledView == aView ifTrue:[^ self].
ca@759
   449
ca@2160
   450
    scrolledView notNil ifTrue:[
ca@2160
   451
        scrolledView unmap.
ca@2160
   452
    ].
ca@2160
   453
    (scrolledView := aView) notNil ifTrue:[
ca@2160
   454
        scrolledView superView ~~ frame ifTrue:[
ca@2160
   455
            scrolledView borderWidth:0; level:0.
cg@845
   456
ca@2160
   457
            frame addSubView:scrolledView.
cg@845
   458
ca@2160
   459
            scrolledView subViews size == 1 ifTrue:[
ca@2160
   460
                wrapper := scrolledView subViews first.
ca@2160
   461
                wrapper isScrollWrapper ifTrue:[
ca@2160
   462
                    "/ give it a full-relative size, and let it do
ca@2160
   463
                    "/ the scrolling itself.
ca@2160
   464
                    y := 1.0
ca@2160
   465
                ]
ca@2160
   466
            ].
ca@2160
   467
            y isNil ifTrue:[
cg@2350
   468
                y := scrolledView preferredHeight
ca@2160
   469
            ].
ca@2160
   470
            scrolledView origin:0@0 corner:1.0 @ y.
ca@2160
   471
            scrolledView allViewBackground:(self viewBackground).
cg@1351
   472
        ].
ca@2160
   473
    ].    
ca@2160
   474
    shown ifTrue:[
ca@2160
   475
        scrolledView beVisible.
ca@2160
   476
        scrolledView raise.
ca@1307
   477
        self sizeChanged:nil.
ca@1307
   478
    ].
ca@1573
   479
    model value:scrolledView.
ca@759
   480
! !
ca@759
   481
ca@1313
   482
!UISpecificationTool::BuildInView methodsFor:'initialization'!
ca@1313
   483
ca@1313
   484
level:aLevel
ca@1313
   485
    super level:0
ca@1313
   486
!
ca@1313
   487
ca@1313
   488
realize
ca@1315
   489
ca@1313
   490
    super realize.
ca@1313
   491
    superView notNil ifTrue:[superView level:0].
ca@1313
   492
! !
ca@1313
   493
ca@164
   494
!UISpecificationTool class methodsFor:'documentation'!
ca@164
   495
ca@164
   496
version
ca@164
   497
    ^ '$Header$'
ca@164
   498
! !