ColorEditDialog.st
author Claus Gittinger <cg@exept.de>
Wed, 29 Jul 2009 20:02:02 +0200
changeset 2570 4e663bc64364
parent 2521 5cfd5fcd7bd3
child 2574 ae2448675efb
permissions -rw-r--r--
changed #requestPackage
cg@1840
     1
"
cg@1840
     2
 COPYRIGHT (c) 1995 by eXept Software AG
cg@1840
     3
              All Rights Reserved
cg@1840
     4
cg@1840
     5
 This software is furnished under a license and may be used
cg@1840
     6
 only in accordance with the terms of that license and with the
cg@1840
     7
 inclusion of the above copyright notice.   This software may not
cg@1840
     8
 be provided or otherwise made available to, or used by, any
cg@1840
     9
 other person.  No title to or ownership of the software is
cg@1840
    10
 hereby transferred.
cg@1840
    11
"
cg@1840
    12
"{ Package: 'stx:libtool2' }"
cg@1840
    13
cg@1840
    14
SimpleDialog subclass:#ColorEditDialog
cg@2224
    15
	instanceVariableNames:'red green blue hue light saturation colorNameHolder
cg@2266
    16
		htmlColorNameHolder previewBox'
cg@1840
    17
	classVariableNames:''
cg@1840
    18
	poolDictionaries:''
cg@1840
    19
	category:'Interface-UIPainter'
cg@1840
    20
!
cg@1840
    21
cg@1840
    22
!ColorEditDialog class methodsFor:'documentation'!
cg@1840
    23
cg@1840
    24
copyright
cg@1840
    25
"
cg@1840
    26
 COPYRIGHT (c) 1995 by eXept Software AG
cg@1840
    27
              All Rights Reserved
cg@1840
    28
cg@1840
    29
 This software is furnished under a license and may be used
cg@1840
    30
 only in accordance with the terms of that license and with the
cg@1840
    31
 inclusion of the above copyright notice.   This software may not
cg@1840
    32
 be provided or otherwise made available to, or used by, any
cg@1840
    33
 other person.  No title to or ownership of the software is
cg@1840
    34
 hereby transferred.
cg@1840
    35
"
cg@1840
    36
!
cg@1840
    37
cg@1840
    38
documentation
cg@1840
    39
"
cg@1840
    40
    An edit-dialog for colors.
cg@1840
    41
"
cg@1840
    42
!
cg@1840
    43
cg@1840
    44
examples
cg@1840
    45
"
cg@1840
    46
                                                                                [exBegin]                                      
cg@1840
    47
    |editor color|
cg@1840
    48
cg@1846
    49
    editor := ColorEditDialog new.
cg@1840
    50
    editor color:(Color green).
cg@1840
    51
    editor open.
cg@1840
    52
    editor accepted ifTrue:[
cg@1840
    53
        editor color inspect.
cg@1840
    54
    ]
cg@1840
    55
                                                                                [exEnd]
cg@1840
    56
"
cg@1840
    57
! !
cg@1840
    58
cg@2266
    59
!ColorEditDialog class methodsFor:'help specs'!
cg@2266
    60
cg@2266
    61
flyByHelpSpec
cg@2266
    62
    "This resource specification was automatically generated
cg@2266
    63
     by the UIHelpTool of ST/X."
cg@2266
    64
cg@2266
    65
    "Do not manually edit this!! If it is corrupted,
cg@2266
    66
     the UIHelpTool may not be able to read the specification."
cg@2266
    67
cg@2266
    68
    "
cg@2266
    69
     UIHelpTool openOnClass:ColorEditDialog    
cg@2266
    70
    "
cg@2266
    71
cg@2266
    72
    <resource: #help>
cg@2266
    73
cg@2266
    74
    ^ super flyByHelpSpec addPairsFrom:#(
cg@2266
    75
cg@2266
    76
#pickColor
cg@2266
    77
'Pick a Color from the Screen'
cg@2266
    78
cg@2266
    79
)
cg@2266
    80
!
cg@2266
    81
cg@2266
    82
helpSpec
cg@2266
    83
    "This resource specification was automatically generated
cg@2266
    84
     by the UIHelpTool of ST/X."
cg@2266
    85
cg@2266
    86
    "Do not manually edit this!! If it is corrupted,
cg@2266
    87
     the UIHelpTool may not be able to read the specification."
cg@2266
    88
cg@2266
    89
    "
cg@2266
    90
     UIHelpTool openOnClass:ColorEditDialog    
cg@2266
    91
    "
cg@2266
    92
cg@2266
    93
    <resource: #help>
cg@2266
    94
cg@2266
    95
    ^ super helpSpec addPairsFrom:#(
cg@2266
    96
cg@2266
    97
#copyToClipboard
cg@2266
    98
'Copy the color to the clipboard'
cg@2266
    99
cg@2266
   100
#hlsMixer
cg@2266
   101
'Mix color from hls (hue-light-saturation) components'
cg@2266
   102
cg@2266
   103
#pasteFromClipboard
cg@2266
   104
'Paste color from the Clipboard'
cg@2266
   105
cg@2266
   106
#rgbMixer
cg@2266
   107
'Mix color from rgb (red-green-blue) components'
cg@2266
   108
cg@2266
   109
)
cg@2266
   110
! !
cg@2266
   111
cg@2266
   112
!ColorEditDialog class methodsFor:'image specs'!
cg@2266
   113
cg@2266
   114
pickColorIcon
cg@2266
   115
    ^ ToolbarIconLibrary pipette16x16Icon
cg@2266
   116
! !
cg@2266
   117
cg@1840
   118
!ColorEditDialog class methodsFor:'interface specs'!
cg@1840
   119
cg@1840
   120
windowSpec
cg@1840
   121
    "This resource specification was automatically generated
cg@1840
   122
     by the UIPainter of ST/X."
cg@1840
   123
cg@1840
   124
    "Do not manually edit this!! If it is corrupted,
cg@1840
   125
     the UIPainter may not be able to read the specification."
cg@1840
   126
cg@1840
   127
    "
cg@2224
   128
     UIPainter new openOnClass:ColorEditDialog andSelector:#windowSpec
cg@2224
   129
     ColorEditDialog new openInterface:#windowSpec
cg@2224
   130
     ColorEditDialog open
cg@1840
   131
    "
cg@1840
   132
cg@1840
   133
    <resource: #canvas>
cg@1840
   134
cg@1840
   135
    ^ 
cg@1840
   136
     #(FullSpec
cg@1840
   137
        name: windowSpec
cg@1840
   138
        window: 
cg@1840
   139
       (WindowSpec
cg@1840
   140
          label: 'Define Color'
cg@1840
   141
          name: 'Define Color'
cg@2224
   142
          min: (Point 440 300)
cg@2224
   143
          max: (Point 440 300)
cg@2266
   144
          bounds: (Rectangle 0 0 440 300)
cg@1840
   145
        )
cg@1840
   146
        component: 
cg@1840
   147
       (SpecCollection
cg@1840
   148
          collection: (
cg@1840
   149
           (VerticalPanelViewSpec
cg@1840
   150
              name: 'RGBLabelPanel'
cg@2266
   151
              layout: (LayoutFrame 0 0 0 0 70 0 76 0)
cg@1840
   152
              horizontalLayout: fit
cg@1840
   153
              verticalLayout: spreadSpace
cg@1840
   154
              horizontalSpace: 3
cg@1840
   155
              verticalSpace: 3
cg@1840
   156
              component: 
cg@1840
   157
             (SpecCollection
cg@1840
   158
                collection: (
cg@1840
   159
                 (LabelSpec
cg@1840
   160
                    label: 'Red:'
cg@1840
   161
                    name: 'RedLabel'
cg@1840
   162
                    translateLabel: true
cg@1840
   163
                    adjust: right
cg@1840
   164
                    useDefaultExtent: true
cg@1840
   165
                  )
cg@1840
   166
                 (LabelSpec
cg@1840
   167
                    label: 'Green:'
cg@1840
   168
                    name: 'GreenLabel'
cg@1840
   169
                    translateLabel: true
cg@1840
   170
                    adjust: right
cg@1840
   171
                    useDefaultExtent: true
cg@1840
   172
                  )
cg@1840
   173
                 (LabelSpec
cg@1840
   174
                    label: 'Blue:'
cg@1840
   175
                    name: 'BlueLabel'
cg@1840
   176
                    translateLabel: true
cg@1840
   177
                    adjust: right
cg@1840
   178
                    useDefaultExtent: true
cg@1840
   179
                  )
cg@1840
   180
                 )
cg@1840
   181
               
cg@1840
   182
              )
cg@1840
   183
            )
cg@1840
   184
           (VerticalPanelViewSpec
cg@1840
   185
              name: 'RGBSliderPanel'
cg@2266
   186
              layout: (LayoutFrame 70 0 0 0 -177 1 76 0)
cg@1840
   187
              horizontalLayout: fit
cg@1840
   188
              verticalLayout: spreadSpace
cg@1840
   189
              horizontalSpace: 3
cg@1840
   190
              verticalSpace: 3
cg@1840
   191
              component: 
cg@1840
   192
             (SpecCollection
cg@1840
   193
                collection: (
cg@1840
   194
                 (SliderSpec
cg@1840
   195
                    name: 'RedSlider'
cg@1840
   196
                    tabable: false
cg@1840
   197
                    model: red
cg@1840
   198
                    orientation: horizontal
cg@1840
   199
                    stop: 255
cg@1840
   200
                    step: 1
cg@1840
   201
                    backgroundColor: (Color 100.0 0.0 0.0)
cg@2266
   202
                    extent: (Point 193 16)
cg@1840
   203
                  )
cg@1840
   204
                 (SliderSpec
cg@1840
   205
                    name: 'GreenSlider'
cg@1840
   206
                    tabable: false
cg@1840
   207
                    model: green
cg@1840
   208
                    orientation: horizontal
cg@1840
   209
                    stop: 255
cg@1840
   210
                    step: 1
cg@1840
   211
                    backgroundColor: (Color 0.0 100.0 0.0)
cg@2266
   212
                    extent: (Point 193 16)
cg@1840
   213
                  )
cg@1840
   214
                 (SliderSpec
cg@1840
   215
                    name: 'BlueSlider'
cg@1840
   216
                    tabable: false
cg@1840
   217
                    model: blue
cg@1840
   218
                    orientation: horizontal
cg@1840
   219
                    stop: 255
cg@1840
   220
                    step: 1
cg@1840
   221
                    backgroundColor: (Color 0.0 0.0 100.0)
cg@2266
   222
                    extent: (Point 193 16)
cg@1840
   223
                  )
cg@1840
   224
                 )
cg@1840
   225
               
cg@1840
   226
              )
cg@1840
   227
            )
cg@1840
   228
           (VerticalPanelViewSpec
cg@1840
   229
              name: 'RGBFieldPanel'
cg@2224
   230
              layout: (LayoutFrame -173 1 0 0 -143 1 76 0)
cg@1840
   231
              horizontalLayout: fit
cg@1840
   232
              verticalLayout: spreadSpace
cg@1840
   233
              horizontalSpace: 3
cg@1840
   234
              verticalSpace: 3
cg@1840
   235
              component: 
cg@1840
   236
             (SpecCollection
cg@1840
   237
                collection: (
cg@1840
   238
                 (InputFieldSpec
cg@1840
   239
                    name: 'RedField'
cg@1840
   240
                    model: red
cg@1840
   241
                    type: numberInRange
cg@1840
   242
                    numChars: 3
cg@1840
   243
                    minValue: 0
cg@1840
   244
                    maxValue: 255
cg@1840
   245
                    acceptOnPointerLeave: false
cg@2224
   246
                    extent: (Point 30 20)
cg@1840
   247
                  )
cg@1840
   248
                 (InputFieldSpec
cg@1840
   249
                    name: 'GreenField'
cg@1840
   250
                    model: green
cg@1840
   251
                    type: numberInRange
cg@1840
   252
                    numChars: 3
cg@1840
   253
                    minValue: 0
cg@1840
   254
                    maxValue: 255
cg@1840
   255
                    acceptOnPointerLeave: false
cg@2224
   256
                    extent: (Point 30 20)
cg@1840
   257
                  )
cg@1840
   258
                 (InputFieldSpec
cg@1840
   259
                    name: 'BlueField'
cg@1840
   260
                    model: blue
cg@1840
   261
                    type: numberInRange
cg@1840
   262
                    numChars: 3
cg@1840
   263
                    minValue: 0
cg@1840
   264
                    maxValue: 255
cg@1840
   265
                    acceptOnPointerLeave: false
cg@2224
   266
                    extent: (Point 30 20)
cg@2224
   267
                  )
cg@2224
   268
                 )
cg@2224
   269
               
cg@2224
   270
              )
cg@2224
   271
            )
cg@2224
   272
           (VerticalPanelViewSpec
cg@2224
   273
              name: 'RGBFieldPanelHex'
cg@2274
   274
              layout: (LayoutFrame -141 1 0 0 -119 1 76 0)
cg@2224
   275
              horizontalLayout: fit
cg@2224
   276
              verticalLayout: spreadSpace
cg@2224
   277
              horizontalSpace: 3
cg@2224
   278
              verticalSpace: 3
cg@2224
   279
              component: 
cg@2224
   280
             (SpecCollection
cg@2224
   281
                collection: (
cg@2224
   282
                 (InputFieldSpec
cg@2224
   283
                    name: 'EntryField4'
cg@2224
   284
                    model: red
cg@2224
   285
                    type: hexIntegerInRange
cg@2224
   286
                    numChars: 3
cg@2224
   287
                    minValue: 0
cg@2224
   288
                    maxValue: 255
cg@2224
   289
                    acceptOnPointerLeave: false
cg@2274
   290
                    extent: (Point 22 20)
cg@2224
   291
                  )
cg@2224
   292
                 (InputFieldSpec
cg@2224
   293
                    name: 'EntryField5'
cg@2224
   294
                    model: green
cg@2224
   295
                    type: hexIntegerInRange
cg@2224
   296
                    numChars: 3
cg@2224
   297
                    minValue: 0
cg@2224
   298
                    maxValue: 255
cg@2224
   299
                    acceptOnPointerLeave: false
cg@2274
   300
                    extent: (Point 22 20)
cg@2224
   301
                  )
cg@2224
   302
                 (InputFieldSpec
cg@2224
   303
                    name: 'EntryField6'
cg@2224
   304
                    model: blue
cg@2224
   305
                    type: hexIntegerInRange
cg@2224
   306
                    numChars: 3
cg@2224
   307
                    minValue: 0
cg@2224
   308
                    maxValue: 255
cg@2224
   309
                    acceptOnPointerLeave: false
cg@2274
   310
                    extent: (Point 22 20)
cg@1840
   311
                  )
cg@1840
   312
                 )
cg@1840
   313
               
cg@1840
   314
              )
cg@1840
   315
            )
cg@1840
   316
           (VerticalPanelViewSpec
cg@1840
   317
              name: 'HLSLabelPanel'
cg@2266
   318
              layout: (LayoutFrame 0 0 86 0 70 0 163 0)
cg@1840
   319
              horizontalLayout: fit
cg@1840
   320
              verticalLayout: spreadSpace
cg@1840
   321
              horizontalSpace: 3
cg@1840
   322
              verticalSpace: 3
cg@1840
   323
              component: 
cg@1840
   324
             (SpecCollection
cg@1840
   325
                collection: (
cg@1840
   326
                 (LabelSpec
cg@1840
   327
                    label: 'Hue:'
cg@1840
   328
                    name: 'Label1'
cg@1840
   329
                    translateLabel: true
cg@1840
   330
                    adjust: right
cg@1840
   331
                    useDefaultExtent: true
cg@1840
   332
                  )
cg@1840
   333
                 (LabelSpec
cg@1840
   334
                    label: 'Light:'
cg@1840
   335
                    name: 'Label2'
cg@1840
   336
                    translateLabel: true
cg@1840
   337
                    adjust: right
cg@1840
   338
                    useDefaultExtent: true
cg@1840
   339
                  )
cg@1840
   340
                 (LabelSpec
cg@2266
   341
                    label: 'Saturation:'
cg@1840
   342
                    name: 'Label3'
cg@1840
   343
                    translateLabel: true
cg@1840
   344
                    adjust: right
cg@1840
   345
                    useDefaultExtent: true
cg@1840
   346
                  )
cg@1840
   347
                 )
cg@1840
   348
               
cg@1840
   349
              )
cg@1840
   350
            )
cg@1840
   351
           (VerticalPanelViewSpec
cg@1840
   352
              name: 'HLSSliderPanel'
cg@2266
   353
              layout: (LayoutFrame 70 0 86 0 -177 1 163 0)
cg@1840
   354
              horizontalLayout: fit
cg@1840
   355
              verticalLayout: spreadSpace
cg@1840
   356
              horizontalSpace: 3
cg@1840
   357
              verticalSpace: 3
cg@1840
   358
              component: 
cg@1840
   359
             (SpecCollection
cg@1840
   360
                collection: (
cg@1840
   361
                 (SliderSpec
cg@1840
   362
                    name: 'Slider1'
cg@1840
   363
                    tabable: false
cg@1840
   364
                    model: hue
cg@1840
   365
                    orientation: horizontal
cg@1840
   366
                    stop: 359
cg@1840
   367
                    step: 1
cg@1840
   368
                    keyboardStep: 1
cg@2266
   369
                    extent: (Point 193 16)
cg@1840
   370
                  )
cg@1840
   371
                 (SliderSpec
cg@1840
   372
                    name: 'Slider2'
cg@1840
   373
                    tabable: false
cg@1840
   374
                    model: light
cg@1840
   375
                    orientation: horizontal
cg@1840
   376
                    step: 1
cg@2224
   377
                    backgroundColor: (Color 66.999313344015 66.999313344015 66.999313344015)
cg@1840
   378
                    keyboardStep: 1
cg@2266
   379
                    extent: (Point 193 16)
cg@1840
   380
                  )
cg@1840
   381
                 (SliderSpec
cg@1840
   382
                    name: 'Slider3'
cg@1840
   383
                    tabable: false
cg@1840
   384
                    model: saturation
cg@1840
   385
                    orientation: horizontal
cg@1840
   386
                    step: 1
cg@2224
   387
                    backgroundColor: (Color 66.999313344015 66.999313344015 66.999313344015)
cg@1840
   388
                    keyboardStep: 1
cg@2266
   389
                    extent: (Point 193 16)
cg@1840
   390
                  )
cg@1840
   391
                 )
cg@1840
   392
               
cg@1840
   393
              )
cg@1840
   394
            )
cg@1840
   395
           (VerticalPanelViewSpec
cg@1840
   396
              name: 'HLSFieldPanel'
cg@2224
   397
              layout: (LayoutFrame -173 1 86 0 -143 1 163 0)
cg@1840
   398
              horizontalLayout: fit
cg@1840
   399
              verticalLayout: spreadSpace
cg@1840
   400
              horizontalSpace: 3
cg@1840
   401
              verticalSpace: 3
cg@1840
   402
              component: 
cg@1840
   403
             (SpecCollection
cg@1840
   404
                collection: (
cg@1840
   405
                 (InputFieldSpec
cg@1840
   406
                    name: 'EntryField1'
cg@1840
   407
                    model: hue
cg@1840
   408
                    type: numberInRange
cg@1840
   409
                    numChars: 3
cg@1840
   410
                    minValue: 0
cg@1840
   411
                    maxValue: 359
cg@1840
   412
                    acceptOnPointerLeave: false
cg@2224
   413
                    extent: (Point 30 20)
cg@1840
   414
                  )
cg@1840
   415
                 (InputFieldSpec
cg@1840
   416
                    name: 'EntryField2'
cg@1840
   417
                    model: light
cg@1840
   418
                    type: numberInRange
cg@1840
   419
                    numChars: 3
cg@1840
   420
                    minValue: 0
cg@1840
   421
                    maxValue: 100
cg@1840
   422
                    acceptOnPointerLeave: false
cg@2224
   423
                    extent: (Point 30 20)
cg@1840
   424
                  )
cg@1840
   425
                 (InputFieldSpec
cg@1840
   426
                    name: 'EntryField3'
cg@1840
   427
                    model: saturation
cg@1840
   428
                    type: numberInRange
cg@1840
   429
                    numChars: 3
cg@1840
   430
                    minValue: 0
cg@1840
   431
                    maxValue: 100
cg@1840
   432
                    acceptOnPointerLeave: false
cg@2224
   433
                    extent: (Point 30 20)
cg@1840
   434
                  )
cg@1840
   435
                 )
cg@1840
   436
               
cg@1840
   437
              )
cg@1840
   438
            )
cg@1840
   439
           (ViewSpec
cg@2266
   440
              name: 'PreviewBoxFrame'
cg@1840
   441
              layout: (LayoutFrame -117 1 4 0.0 -3 1.0 -39 1.0)
cg@1840
   442
              level: 1
cg@1840
   443
              component: 
cg@1840
   444
             (SpecCollection
cg@1840
   445
                collection: (
cg@1840
   446
                 (LabelSpec
cg@1840
   447
                    label: 'Preview'
cg@1840
   448
                    name: 'PreviewBox'
cg@1840
   449
                    layout: (LayoutFrame 2 0.0 2 0.0 -2 1.0 -2 1.0)
cg@1840
   450
                    level: -1
cg@1840
   451
                    translateLabel: true
cg@2266
   452
                    postBuildCallback: postBuildPreviewBox:
cg@1840
   453
                  )
cg@1840
   454
                 )
cg@1840
   455
               
cg@1840
   456
              )
cg@1840
   457
            )
cg@1840
   458
           (LabelSpec
cg@1840
   459
              label: 'Color Name:'
cg@1840
   460
              name: 'ColorNameLabel'
cg@2224
   461
              layout: (LayoutFrame 0 0 176 0 106 0 198 0)
cg@1840
   462
              translateLabel: true
cg@1840
   463
              adjust: right
cg@1840
   464
            )
cg@1840
   465
           (InputFieldSpec
cg@1840
   466
              name: 'ColorNameField'
cg@2224
   467
              layout: (LayoutFrame 108 0 176 0 -162 1 198 0)
cg@1840
   468
              model: colorNameHolder
cg@2326
   469
              immediateAccept: false
cg@1840
   470
              acceptOnReturn: true
cg@1840
   471
              acceptOnTab: true
cg@1840
   472
              acceptOnLostFocus: true
cg@2326
   473
              acceptOnPointerLeave: true
cg@2326
   474
            )
cg@2326
   475
           (LabelSpec
cg@2326
   476
              label: 'HTML Color Name:'
cg@2326
   477
              name: 'HTMLColorNameLabel'
cg@2326
   478
              layout: (LayoutFrame 4 0 204 0 110 0 226 0)
cg@2326
   479
              translateLabel: true
cg@2326
   480
              adjust: right
cg@2326
   481
            )
cg@2326
   482
           (InputFieldSpec
cg@2326
   483
              name: 'MLHTColorNameFieldField'
cg@2326
   484
              layout: (LayoutFrame 108 0 204 0 -162 1 226 0)
cg@2326
   485
              model: htmlColorNameHolder
cg@2326
   486
              immediateAccept: false
cg@2326
   487
              acceptOnReturn: true
cg@2326
   488
              acceptOnTab: true
cg@2326
   489
              acceptOnLostFocus: true
cg@2326
   490
              acceptOnPointerLeave: true
cg@2326
   491
            )
cg@2326
   492
           (ActionButtonSpec
cg@2326
   493
              label: 'Copy Color'
cg@2326
   494
              name: 'CopyColor'
cg@2326
   495
              layout: (LayoutFrame 12 0 236 0 100 0 258 0)
cg@2326
   496
              activeHelpKey: hlsMixer
cg@2326
   497
              translateLabel: true
cg@2326
   498
              resizeForLabel: true
cg@2326
   499
              tabable: true
cg@2326
   500
              model: copyColor
cg@2326
   501
            )
cg@2326
   502
           (ActionButtonSpec
cg@2326
   503
              label: 'Paste Color'
cg@2326
   504
              name: 'PasteColor'
cg@2326
   505
              layout: (LayoutFrame 108 0 236 0 196 0 258 0)
cg@2326
   506
              translateLabel: true
cg@2326
   507
              resizeForLabel: true
cg@2326
   508
              tabable: true
cg@2326
   509
              model: pasteColor
cg@2326
   510
            )
cg@2326
   511
           (ActionButtonSpec
cg@2326
   512
              label: 'pickColorIcon'
cg@2326
   513
              name: 'Button1'
cg@2326
   514
              layout: (LayoutFrame 285 0 236 0 312 0 263 0)
cg@2326
   515
              activeHelpKey: pickColor
cg@2326
   516
              hasCharacterOrientedLabel: false
cg@2326
   517
              translateLabel: true
cg@2326
   518
              resizeForLabel: true
cg@2326
   519
              tabable: true
cg@2326
   520
              model: pickColor
cg@1840
   521
            )
cg@1840
   522
           (HorizontalPanelViewSpec
cg@1840
   523
              name: 'HorizontalPanel1'
cg@1840
   524
              layout: (LayoutFrame 0 0.0 -32 1 0 1.0 0 1.0)
cg@1840
   525
              horizontalLayout: fitSpace
cg@1840
   526
              verticalLayout: centerMax
cg@1840
   527
              horizontalSpace: 3
cg@1840
   528
              verticalSpace: 3
cg@1840
   529
              reverseOrderIfOKAtLeft: true
cg@1840
   530
              component: 
cg@1840
   531
             (SpecCollection
cg@1840
   532
                collection: (
cg@1840
   533
                 (ActionButtonSpec
cg@1840
   534
                    label: 'Cancel'
cg@1840
   535
                    name: 'CancelButton'
cg@1840
   536
                    translateLabel: true
cg@1840
   537
                    resizeForLabel: false
cg@1840
   538
                    tabable: true
cg@1840
   539
                    model: cancel
cg@1840
   540
                    useDefaultExtent: true
cg@1840
   541
                  )
cg@1840
   542
                 (ActionButtonSpec
cg@1840
   543
                    label: 'OK'
cg@1840
   544
                    name: 'OKButton'
cg@1840
   545
                    translateLabel: true
cg@1840
   546
                    resizeForLabel: false
cg@1840
   547
                    tabable: true
cg@1840
   548
                    model: accept
cg@1840
   549
                    isDefault: true
cg@1840
   550
                    defaultable: true
cg@1840
   551
                    useDefaultExtent: true
cg@1840
   552
                  )
cg@1840
   553
                 )
cg@1840
   554
               
cg@1840
   555
              )
cg@1840
   556
            )
cg@1840
   557
           )
cg@1840
   558
         
cg@1840
   559
        )
cg@1840
   560
      )
cg@1840
   561
! !
cg@1840
   562
cg@2347
   563
!ColorEditDialog class methodsFor:'startup'!
cg@2347
   564
cg@2347
   565
openOn:aColor
cg@2347
   566
    ^ self new
cg@2347
   567
        color:aColor;
cg@2347
   568
        open;
cg@2347
   569
        yourself
cg@2347
   570
cg@2347
   571
    "
cg@2347
   572
     self openOn:Color red
cg@2347
   573
    "
cg@2347
   574
! !
cg@2347
   575
cg@1840
   576
!ColorEditDialog methodsFor:'accessing'!
cg@1840
   577
cg@1840
   578
color
sv@2279
   579
    |colorName|
sv@2279
   580
sv@2279
   581
    colorName := self colorName.
sv@2279
   582
    colorName notEmptyOrNil ifTrue:[
cg@2326
   583
        "/ ^ Color name:(colorName asSymbol)
sv@2279
   584
        ^ colorName asSymbol
sv@2279
   585
    ].
cg@2326
   586
    ^ Color redByte:(red value) greenByte:(green value) blueByte:(blue value)
cg@1840
   587
!
cg@1840
   588
sv@2279
   589
color:aColor
sv@2279
   590
    aColor isNil ifTrue:[
sv@2279
   591
        ^ self
sv@2279
   592
    ].
sv@2279
   593
sv@2279
   594
    aColor isSymbol ifTrue:[
sv@2279
   595
        self colorNameHolder value:aColor
sv@2279
   596
    ] ifFalse:[
cg@1840
   597
        self red value:aColor redByte.
cg@1840
   598
        self green value:aColor greenByte.
cg@1840
   599
        self blue value:aColor blueByte.
cg@1840
   600
    ]
cg@1840
   601
!
cg@1840
   602
cg@1840
   603
colorName
cg@1840
   604
    ^ colorNameHolder value
cg@2224
   605
!
cg@2224
   606
cg@2224
   607
htmlColorName
cg@2224
   608
    ^ htmlColorNameHolder value
cg@1840
   609
! !
cg@1840
   610
cg@1840
   611
!ColorEditDialog methodsFor:'actions'!
cg@1840
   612
cg@1840
   613
colorChanged
cg@2266
   614
    |clr|
cg@1840
   615
cg@1840
   616
    clr := self color.
sv@2279
   617
    clr isColor ifTrue:[
sv@2279
   618
        "not a symbol"
sv@2279
   619
        self setPreview:clr.
cg@2326
   620
        self htmlColorNameHolder value:(clr htmlPrintString) withoutNotifying:self.
sv@2279
   621
    ].
cg@1840
   622
!
cg@1840
   623
cg@2326
   624
colorChangedTo:clr
cg@1840
   625
    "compute rgb and hls (if possible)"
cg@1840
   626
cg@2326
   627
    |h|
cg@1840
   628
sv@2279
   629
    self red   value:clr redByte withoutNotifying:self.
sv@2279
   630
    self green value:clr greenByte withoutNotifying:self.
sv@2279
   631
    self blue  value:clr blueByte withoutNotifying:self.
cg@1840
   632
cg@1840
   633
    h := clr hue.
cg@1840
   634
    h notNil ifTrue:[
sv@2279
   635
        self hue        value:(h rounded) withoutNotifying:self.
cg@1840
   636
    ].
sv@2279
   637
    self light      value:(clr light rounded) withoutNotifying:self.
sv@2279
   638
    self saturation value:(clr saturation rounded) withoutNotifying:self.
cg@1840
   639
cg@1840
   640
    self colorChanged
cg@1840
   641
!
cg@1840
   642
cg@2326
   643
colorNameChanged
cg@2326
   644
    "compute rgb and hls (if possible)"
cg@2326
   645
cg@2326
   646
    |clr|
cg@2326
   647
cg@2326
   648
    clr := Color name:colorNameHolder value ifIllegal:nil.
cg@2326
   649
    clr isNil ifTrue:[
cg@2326
   650
        ^ self
cg@2326
   651
    ].
cg@2326
   652
    self colorChangedTo:clr.
cg@2326
   653
!
cg@2326
   654
cg@2224
   655
copyColor
cg@2224
   656
    self window setClipboardObject:self color
cg@2224
   657
!
cg@2224
   658
cg@2224
   659
copyColorName
cg@2224
   660
    self window setClipboardText:self htmlColorName
cg@2224
   661
!
cg@2224
   662
cg@1840
   663
hlsSliderChanged
cg@1840
   664
    "compute rgb"
cg@1840
   665
cg@1840
   666
    Color withRGBFromHue:hue value light:light value saturation:saturation value do:[:r :g :b |
cg@1840
   667
        red    value:(r * 255 / 100) rounded withoutNotifying:self.
cg@1840
   668
        green  value:(g * 255 / 100) rounded withoutNotifying:self.
cg@1840
   669
        blue   value:(b * 255 / 100) rounded withoutNotifying:self.
cg@1840
   670
    ].
cg@1840
   671
    colorNameHolder value:'' withoutNotifying:self.
cg@1840
   672
    self colorChanged
cg@1840
   673
!
cg@1840
   674
cg@2326
   675
htmlColorNameChanged
cg@2326
   676
    "compute rgb and hls (if possible)"
cg@2326
   677
cg@2326
   678
    |clr|
cg@2326
   679
sv@2417
   680
    htmlColorNameHolder value isEmptyOrNil ifTrue:[
sv@2417
   681
        ^ self.
sv@2417
   682
    ].
sv@2417
   683
cg@2326
   684
    clr := Color rgbValue:(Integer 
cg@2326
   685
                                readFrom:(htmlColorNameHolder value copyFrom:2)
cg@2326
   686
                                radix:16
cg@2326
   687
                                onError:nil).
cg@2326
   688
    clr isNil ifTrue:[
cg@2326
   689
        ^ self
cg@2326
   690
    ].
cg@2326
   691
    self colorNameHolder value:'' withoutNotifying:self.
cg@2326
   692
    self colorChangedTo:clr.
cg@2326
   693
!
cg@2326
   694
cg@2224
   695
pasteColor
cg@2224
   696
    |copyBufferColor|
cg@2224
   697
cg@2224
   698
    copyBufferColor := self window getClipboardObject.
cg@2224
   699
    copyBufferColor isColor ifFalse:[
cg@2521
   700
        UserPreferences current beepInEditor ifTrue:[                
cg@2521
   701
            self window beep.
cg@2521
   702
        ].
cg@2224
   703
        ^ self
cg@2224
   704
    ].
cg@2224
   705
    self color:copyBufferColor
cg@2224
   706
!
cg@2224
   707
cg@2266
   708
pickColor
cg@2266
   709
    |color|
cg@2266
   710
cg@2266
   711
    color := Color fromUserWithFeedBack:[:clr | self setPreview:clr].
cg@2266
   712
    color notNil ifTrue:[
cg@2266
   713
        self color:color.
cg@2266
   714
    ]
cg@2266
   715
!
cg@2266
   716
cg@1840
   717
rgbSliderChanged
cg@1840
   718
    "compute hls"
cg@1840
   719
cg@1840
   720
    |r g b|
cg@1840
   721
cg@1840
   722
    r := self red value.
cg@1840
   723
    g := self green value.
cg@1840
   724
    b := self blue value.
cg@1840
   725
cg@1840
   726
    Color withHLSFromRed:(r * 100 / 255) green:(g * 100 / 255) blue:(b * 100 / 255) do:[:h :l :s |
cg@1840
   727
        h isNil ifTrue:[
cg@1840
   728
            "/ achromatic
cg@1840
   729
        ] ifFalse:[
cg@1840
   730
            self hue    value:(h rounded) withoutNotifying:self.
cg@1840
   731
        ].
cg@1840
   732
        self light      value:(l rounded) withoutNotifying:self.
cg@1840
   733
        self saturation value:(s rounded) withoutNotifying:self.
cg@1840
   734
    ].
cg@1840
   735
    self colorNameHolder value:'' withoutNotifying:self.
cg@1840
   736
    self colorChanged
cg@2266
   737
!
cg@2266
   738
cg@2266
   739
setPreview:color
cg@2266
   740
    previewBox isNil ifTrue:[^ self "called before setup"].
cg@2266
   741
cg@2266
   742
    previewBox backgroundColor:color.
cg@2266
   743
    previewBox foregroundColor:(color brightness < 0.5 
cg@2266
   744
                            ifTrue:[Color white] 
cg@2266
   745
                            ifFalse:[Color black]).
cg@1840
   746
! !
cg@1840
   747
cg@1840
   748
!ColorEditDialog methodsFor:'aspects'!
cg@1840
   749
cg@1840
   750
blue
cg@1840
   751
    blue isNil ifTrue:[
cg@1840
   752
        blue := 0 asValue.
cg@1840
   753
        blue addDependent:self.
cg@1840
   754
    ].
cg@1840
   755
    ^blue
cg@1840
   756
!
cg@1840
   757
cg@1840
   758
colorNameHolder
cg@1840
   759
    colorNameHolder isNil ifTrue:[
cg@1840
   760
        colorNameHolder := '' asValue.
cg@1840
   761
        colorNameHolder addDependent:self.
cg@1840
   762
    ].
cg@1840
   763
    ^colorNameHolder
cg@1840
   764
!
cg@1840
   765
cg@1840
   766
green
cg@1840
   767
    green isNil ifTrue:[
cg@1840
   768
        green := 0 asValue.
cg@1840
   769
        green addDependent:self.
cg@1840
   770
    ].
cg@1840
   771
    ^green
cg@1840
   772
!
cg@1840
   773
cg@2224
   774
htmlColorNameHolder
cg@2224
   775
    htmlColorNameHolder isNil ifTrue:[
cg@2224
   776
        htmlColorNameHolder := '' asValue.
cg@2326
   777
        htmlColorNameHolder addDependent:self.
cg@2224
   778
    ].
cg@2224
   779
    ^htmlColorNameHolder
cg@2224
   780
!
cg@2224
   781
cg@1840
   782
hue
cg@1840
   783
    hue isNil ifTrue:[
cg@1840
   784
        hue := 0 asValue.
cg@1840
   785
        hue addDependent:self.
cg@1840
   786
    ].
cg@1840
   787
    ^hue
cg@1840
   788
!
cg@1840
   789
cg@1840
   790
light
cg@1840
   791
    light isNil ifTrue:[
cg@1840
   792
        light := 0 asValue.
cg@1840
   793
        light addDependent:self.
cg@1840
   794
    ].
cg@1840
   795
    ^light
cg@1840
   796
!
cg@1840
   797
cg@1840
   798
red
cg@1840
   799
    red isNil ifTrue:[
cg@1840
   800
        red := 0 asValue.
cg@1840
   801
        red addDependent:self.
cg@1840
   802
    ].
cg@1840
   803
    ^red
cg@1840
   804
!
cg@1840
   805
cg@1840
   806
saturation
cg@1840
   807
    saturation isNil ifTrue:[
cg@1840
   808
        saturation := 0 asValue.
cg@1840
   809
        saturation addDependent:self.
cg@1840
   810
    ].
cg@1840
   811
    ^saturation
cg@1840
   812
! !
cg@1840
   813
cg@1840
   814
!ColorEditDialog methodsFor:'change & update'!
cg@1840
   815
cg@1840
   816
update:something with:aParameter from:changedObject
cg@1840
   817
    (changedObject == red
cg@1840
   818
    or:[changedObject == green
cg@1840
   819
    or:[changedObject == blue]]) ifTrue:[
cg@2326
   820
        self rgbSliderChanged.
cg@2326
   821
        ^ self
cg@1840
   822
    ].
cg@1840
   823
cg@1840
   824
    (changedObject == hue
cg@1840
   825
    or:[changedObject == light
cg@1840
   826
    or:[changedObject == saturation]]) ifTrue:[
cg@2326
   827
        self hlsSliderChanged.
cg@2326
   828
        ^ self
cg@1840
   829
    ].
cg@1840
   830
cg@1840
   831
    (changedObject == colorNameHolder) ifTrue:[
cg@2326
   832
        self colorNameChanged.
cg@2326
   833
        ^ self
cg@2326
   834
    ].
cg@2326
   835
    (changedObject == htmlColorNameHolder) ifTrue:[
cg@2326
   836
        self htmlColorNameChanged.
cg@2326
   837
        ^ self
cg@1840
   838
    ].
cg@1840
   839
cg@2326
   840
    super update:something with:aParameter from:changedObject
cg@1840
   841
! !
cg@1840
   842
cg@1840
   843
!ColorEditDialog methodsFor:'startup & release'!
cg@1840
   844
cg@2266
   845
postBuildPreviewBox:aView
cg@2266
   846
    previewBox := aView
cg@2266
   847
!
cg@2266
   848
cg@1840
   849
postBuildWith:aBuilder
cg@1840
   850
    super postBuildWith:aBuilder.
cg@1840
   851
    self colorChanged.
cg@1840
   852
cg@1840
   853
    "Modified: / 6.9.1998 / 22:55:25 / cg"
cg@1840
   854
! !
cg@1840
   855
cg@1840
   856
!ColorEditDialog class methodsFor:'documentation'!
cg@1840
   857
cg@1840
   858
version
cg@1840
   859
    ^ '$Header$'
cg@1840
   860
! !