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