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