View | Details | Raw Unified | Return to issue 118828
Collapse All | Expand All

(-)cui/source/uno/services/makefile.mk (+40 lines)
Line 0 Link Here
1
#**************************************************************
2
#  
3
#  Licensed to the Apache Software Foundation (ASF) under one
4
#  or more contributor license agreements.  See the NOTICE file
5
#  distributed with this work for additional information
6
#  regarding copyright ownership.  The ASF licenses this file
7
#  to you under the Apache License, Version 2.0 (the
8
#  "License"); you may not use this file except in compliance
9
#  with the License.  You may obtain a copy of the License at
10
#  
11
#    http://www.apache.org/licenses/LICENSE-2.0
12
#  
13
#  Unless required by applicable law or agreed to in writing,
14
#  software distributed under the License is distributed on an
15
#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
#  KIND, either express or implied.  See the License for the
17
#  specific language governing permissions and limitations
18
#  under the License.
19
#  
20
#**************************************************************
21
22
PRJ=..$/..$/..
23
PRJNAME=cui
24
TARGET=services
25
ENABLE_EXCEPTIONS=TRUE
26
27
# --- Settings -----------------------------------------------------
28
29
.INCLUDE :  settings.mk
30
.INCLUDE :  $(PRJ)$/util$/makefile.pmk
31
32
# --- Files --------------------------------------------------------
33
34
SLOFILES+=\
35
        $(SLO)$/services.obj
36
37
# --- Targets -------------------------------------------------------
38
39
.INCLUDE :  target.mk
40
*
(-)cui/source/uno/services/services.cxx (+60 lines)
Line 0 Link Here
1
/**************************************************************
2
 * 
3
 * Licensed to the Apache Software Foundation (ASF) under one
4
 * or more contributor license agreements.  See the NOTICE file
5
 * distributed with this work for additional information
6
 * regarding copyright ownership.  The ASF licenses this file
7
 * to you under the Apache License, Version 2.0 (the
8
 * "License"); you may not use this file except in compliance
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
15
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
 * KIND, either express or implied.  See the License for the
17
 * specific language governing permissions and limitations
18
 * under the License.
19
 * 
20
 *************************************************************/
21
22
// MARKER(update_precomp.py): autogen include statement, do not remove
23
#include "precompiled_cui.hxx"
24
25
#include <com/sun/star/registry/XRegistryKey.hpp>
26
#include "sal/types.h"
27
#include "cppuhelper/factory.hxx"
28
#include <cppuhelper/implementationentry.hxx>
29
30
using rtl::OUString;
31
using namespace com::sun::star;
32
33
namespace cui {
34
extern rtl::OUString SAL_CALL ColorPicker_getImplementationName();
35
extern uno::Reference< uno::XInterface > SAL_CALL ColorPicker_createInstance( uno::Reference< uno::XComponentContext > const & ) SAL_THROW( (uno::Exception) );
36
extern uno::Sequence< rtl::OUString > SAL_CALL ColorPicker_getSupportedServiceNames() throw( uno::RuntimeException );
37
}
38
39
namespace
40
{
41
42
    cppu::ImplementationEntry entries[] = {
43
        { &::cui::ColorPicker_createInstance, &::cui::ColorPicker_getImplementationName, &::cui::ColorPicker_getSupportedServiceNames, &cppu::createSingleComponentFactory, 0, 0 },
44
        { 0, 0, 0, 0, 0, 0 }
45
    };
46
}
47
48
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( char const * implName, void * serviceManager, void * registryKey)
49
{
50
    return cppu::component_getFactoryHelper(implName, serviceManager, registryKey, entries);
51
}
52
53
54
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment ( const sal_Char ** ppEnvTypeName, uno_Environment ** )
55
{
56
    *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
57
}
58
59
// eof
60
*
(-)cui/source/dialogs/colorpicker.src (+483 lines)
Line 0 Link Here
1
/**************************************************************
2
 * 
3
 * Licensed to the Apache Software Foundation (ASF) under one
4
 * or more contributor license agreements.  See the NOTICE file
5
 * distributed with this work for additional information
6
 * regarding copyright ownership.  The ASF licenses this file
7
 * to you under the Apache License, Version 2.0 (the
8
 * "License"); you may not use this file except in compliance
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
15
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
 * KIND, either express or implied.  See the License for the
17
 * specific language governing permissions and limitations
18
 * under the License.
19
 * 
20
 *************************************************************/
21
22
#include "colorpicker.hrc"
23
24
#define DLG_WIDTH 295
25
#define DLG_HEIGHT 216
26
27
#define BUTTON_WIDTH 50
28
#define BUTTON_HEIGHT 14
29
30
#define METRIC_WIDTH 30
31
#define METRIC_HEIGHT 12
32
33
#define RADIO_WIDTH 8
34
#define RADIO_HEIGHT 8
35
36
#define LABEL_WIDTH 50
37
#define LABEL_HEIGHT 10
38
39
#define SLIDER_WIDTH 22
40
#define PREVIEW_HEIGHT 16
41
42
#define LINE_WIDTH  (3 + RADIO_WIDTH + 2 + LABEL_WIDTH + 3 + METRIC_WIDTH + 3)
43
#define LINE_HEIGHT 8
44
45
#define CONTROL_AREA_X    (DLG_WIDTH - LINE_WIDTH - 6)
46
#define CONTROL_AREA_X_RADIO (CONTROL_AREA_X + 3)
47
#define CONTROL_AREA_X_LABEL (CONTROL_AREA_X + 3 + RADIO_WIDTH + 2)
48
#define CONTROL_AREA_X_METRIC (CONTROL_AREA_X + 3 + RADIO_WIDTH + 2 + LABEL_WIDTH + 3)
49
50
#define CHOOSER_SIZE (CONTROL_AREA_X - 6 - SLIDER_WIDTH - 2 - 2 )
51
52
#define BOTTOMLINE_Y (DLG_HEIGHT - 3 - 3 - 8 - 14)
53
#define BUTTON_LINE_Y (BOTTOMLINE_Y + 8 + 3)
54
55
#define RGB_Y1 (6 + LINE_HEIGHT + 1)
56
#define RGB_Y2 (RGB_Y1 + METRIC_HEIGHT + 2)
57
#define RGB_Y3 (RGB_Y2 + METRIC_HEIGHT + 2)
58
#define RGB_Y4 (RGB_Y3 + METRIC_HEIGHT + 4)
59
#define HSB_Y0 (RGB_Y4 + METRIC_HEIGHT + 1)
60
#define HSB_Y1 (HSB_Y0 + LINE_HEIGHT + 2)
61
#define HSB_Y2 (HSB_Y1 + METRIC_HEIGHT + 2)
62
#define HSB_Y3 (HSB_Y2 + METRIC_HEIGHT + 2)
63
#define CMYK_Y0 (HSB_Y3 + METRIC_HEIGHT + 1)
64
#define CMYK_Y1 (CMYK_Y0 + LINE_HEIGHT + 1)
65
#define CMYK_Y2 (CMYK_Y1 + METRIC_HEIGHT + 2)
66
#define CMYK_Y3 (CMYK_Y2 + METRIC_HEIGHT + 2)
67
#define CMYK_Y4 (CMYK_Y3 + METRIC_HEIGHT + 2)
68
69
70
71
ModalDialog RID_CUI_DIALOG_COLORPICKER
72
{
73
    HelpID = "cui:ModalDialog:ColorPicker";
74
75
    OutputSize = TRUE ;
76
    SvLook = TRUE ;
77
    Moveable = TRUE ;
78
    Size = MAP_APPFONT ( DLG_WIDTH , DLG_HEIGHT ) ;
79
80
    Text [ en-US ] = "Color Picker" ;
81
82
    Control CT_COLORFIELD
83
    {
84
        HelpID = "cui:Control:ColorPicker:ColorField";
85
        Pos = MAP_APPFONT ( 6 , 6 ) ;
86
        Size = MAP_APPFONT ( CHOOSER_SIZE , CHOOSER_SIZE ) ;
87
        Border = TRUE;
88
        TabStop = TRUE ;
89
    };
90
91
    Control CT_COLORSLIDER
92
    {
93
        HelpID = "cui:Control:ColorPicker:ColorSlider";
94
        Pos = MAP_APPFONT ( CONTROL_AREA_X - 2 - SLIDER_WIDTH + 4 , 6 ) ;
95
        Size = MAP_APPFONT ( SLIDER_WIDTH - 8 , CHOOSER_SIZE ) ;
96
        Border = TRUE;
97
        TabStop = TRUE ;
98
    };
99
100
    Control CT_PREVIEW
101
    {
102
        HelpID = "cui:Control:ColorPicker:ColorPreview";
103
        Pos = MAP_APPFONT ( 6 , 6 + CHOOSER_SIZE + 3 ) ;
104
        Size = MAP_APPFONT ( CHOOSER_SIZE , PREVIEW_HEIGHT ) ;
105
        Border = FALSE;
106
    };
107
108
    Control CT_PREVIOUS
109
    {
110
        HelpID = "cui:Control:ColorPicker:ColorPrevious";
111
        Pos = MAP_APPFONT ( 6 + (CHOOSER_SIZE/2), 6 + CHOOSER_SIZE + 3 ) ;
112
        Size = MAP_APPFONT ( CHOOSER_SIZE/2 , PREVIEW_HEIGHT ) ;
113
        Border = FALSE;
114
        Hide = TRUE;
115
    };
116
117
    FixedImage CT_LEFT_SLIDER
118
    {
119
    };
120
121
    FixedImage CT_RIGHT_SLIDER
122
    {
123
    };
124
125
    Image CT_SLIDERIMG
126
    {
127
        ImageBitmap = Bitmap { File = "colorslider.png" ; };
128
        MaskColor = Color { Red = 0xFFFF; Green = 0x0000; Blue = 0xFFFF; };
129
    };
130
131
#if 0
132
    ImageButton PB_PICKER
133
    {
134
        HelpID = "cui:ImageButton:ColorPicker:Picker";
135
        Pos = MAP_APPFONT ( CONTROL_AREA_X - 2 - SLIDER_WIDTH + 4, 6 + CHOOSER_SIZE + 3 ) ;
136
        Size = MAP_APPFONT( SLIDER_WIDTH - 8, PREVIEW_HEIGHT );
137
        TabStop = TRUE ;
138
        QuickHelpText [ en-US ] = "Pick a color from the document" ;
139
        ButtonImage = Image
140
        {
141
            ImageBitmap = Bitmap { File = "pipette.png" ; };
142
            MaskColor = Color { Red = 0xFFFF; Green = 0x0000; Blue = 0xFFFF; } ;
143
        };
144
    };
145
#endif
146
147
    FixedLine FL_RGB
148
    {
149
        Pos = MAP_APPFONT ( CONTROL_AREA_X , 6 ) ;
150
        Size = MAP_APPFONT ( LINE_WIDTH , LINE_HEIGHT ) ;
151
        Text [ en-US ] = "RGB" ;
152
    };
153
154
    RadioButton CT_RED
155
    {
156
        HelpID = "cui:RadioButton:ColorPicker:Red";
157
        Pos = MAP_APPFONT ( CONTROL_AREA_X_RADIO , RGB_Y1+2 ) ;
158
        Size = MAP_APPFONT ( RADIO_WIDTH , RADIO_HEIGHT ) ;
159
        Group = TRUE;
160
    };
161
162
    RadioButton CT_GREEN
163
    {
164
        HelpID = "cui:RadioButton:ColorPicker:Green";
165
        Pos = MAP_APPFONT ( CONTROL_AREA_X_RADIO , RGB_Y2+2 ) ;
166
        Size = MAP_APPFONT ( RADIO_WIDTH , RADIO_HEIGHT ) ;
167
    };
168
169
    RadioButton CT_BLUE
170
    {
171
        HelpID = "cui:RadioButton:ColorPicker:Blue";
172
        Pos = MAP_APPFONT ( CONTROL_AREA_X_RADIO , RGB_Y3+2 ) ;
173
        Size = MAP_APPFONT ( RADIO_WIDTH , RADIO_HEIGHT ) ;
174
    };
175
176
    RadioButton CT_HUE
177
    {
178
        HelpID = "cui:RadioButton:ColorPicker:Hue";
179
        Pos = MAP_APPFONT ( CONTROL_AREA_X_RADIO , HSB_Y1+2 ) ;
180
        Size = MAP_APPFONT ( RADIO_WIDTH , RADIO_HEIGHT ) ;
181
        Check = TRUE ;
182
    };
183
184
    RadioButton CT_SATURATION
185
    {
186
        HelpID = "cui:RadioButton:ColorPicker:Saturation";
187
        Pos = MAP_APPFONT ( CONTROL_AREA_X_RADIO , HSB_Y2+2 ) ;
188
        Size = MAP_APPFONT ( RADIO_WIDTH , RADIO_HEIGHT ) ;
189
    };
190
191
    RadioButton CT_BRIGHTNESS
192
    {
193
        HelpID = "cui:RadioButton:ColorPicker:Brightness";
194
        Pos = MAP_APPFONT ( CONTROL_AREA_X_RADIO , HSB_Y3+2 ) ;
195
        Size = MAP_APPFONT ( RADIO_WIDTH , RADIO_HEIGHT ) ;
196
    };
197
198
    FixedText CT_RED
199
    {
200
        Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , RGB_Y1+1 ) ;
201
        Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ;
202
        Text [ en-US ] = "~Red" ;
203
    };
204
205
    MetricField CT_RED
206
    {
207
        HelpID = "cui:MetricField:ColorPicker:Red";
208
        Border = TRUE ;
209
        Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , RGB_Y1 ) ;
210
        Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ;
211
        TabStop = TRUE ;
212
        Repeat = TRUE ;
213
        Spin = TRUE ;
214
        Maximum = 255 ;
215
        Last = 255 ;
216
    };
217
218
    FixedText CT_GREEN
219
    {
220
        Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , RGB_Y2+1 ) ;
221
        Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ;
222
        Text [ en-US ] = "~Green" ;
223
    };
224
225
    MetricField CT_GREEN
226
    {
227
        HelpID = "cui:MetricField:ColorPicker:Green";
228
        Border = TRUE ;
229
        Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , RGB_Y2 ) ;
230
        Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ;
231
        TabStop = TRUE ;
232
        Repeat = TRUE ;
233
        Spin = TRUE ;
234
        Maximum = 255 ;
235
        Last = 255 ;
236
    };
237
238
    FixedText CT_BLUE
239
    {
240
        Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , RGB_Y3+1 ) ;
241
        Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ;
242
        Text [ en-US ] = "~Blue" ;
243
    };
244
245
    MetricField CT_BLUE
246
    {
247
        HelpID = "cui:MetricField:ColorPicker:Blue";
248
        Border = TRUE ;
249
        Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , RGB_Y3 ) ;
250
        Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ;
251
        TabStop = TRUE ;
252
        Repeat = TRUE ;
253
        Spin = TRUE ;
254
        Maximum = 255 ;
255
        Last = 255 ;
256
    };
257
258
    FixedText CT_HEX
259
    {
260
        Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , RGB_Y4+1 ) ;
261
        Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ;
262
        Text [ en-US ] = "Hex ~#" ;
263
    };
264
265
    Edit CT_HEX
266
    {
267
        HelpID = "cui:MetricField:ColorPicker:Hex";
268
        Border = TRUE ;
269
        Left = TRUE ;
270
        Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , RGB_Y4 ) ;
271
        Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ;
272
        TabStop = TRUE ;
273
    };
274
275
// -------------------------------------------------------------------------
276
// HSB
277
// -------------------------------------------------------------------------
278
279
    FixedLine FL_HSB
280
    {
281
        Pos = MAP_APPFONT ( CONTROL_AREA_X , HSB_Y0 ) ;
282
        Size = MAP_APPFONT ( LINE_WIDTH , LINE_HEIGHT ) ;
283
        Text [ en-US ] = "HSB" ;
284
    };
285
286
    FixedText CT_HUE
287
    {
288
        Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , HSB_Y1+1 ) ;
289
        Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ;
290
        Text [ en-US ] = "H~ue" ;
291
    };
292
293
    MetricField CT_HUE
294
    {
295
        HelpID = "cui:MetricField:ColorPicker:Hue";
296
        Border = TRUE ;
297
        Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , HSB_Y1 ) ;
298
        Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ;
299
        TabStop = TRUE ;
300
        Repeat = TRUE ;
301
        Spin = TRUE ;
302
        Maximum = 360 ;
303
        Last = 360 ;
304
        Unit = FUNIT_CUSTOM ;
305
    };
306
307
    FixedText CT_SATURATION
308
    {
309
        Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , HSB_Y2+1 ) ;
310
        Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ;
311
        Text [ en-US ] = "~Saturation" ;
312
    };
313
314
    MetricField CT_SATURATION
315
    {
316
        HelpID = "cui:MetricField:ColorPicker:Saturation";
317
        Border = TRUE ;
318
        Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , HSB_Y2 ) ;
319
        Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ;
320
        TabStop = TRUE ;
321
        Repeat = TRUE ;
322
        Spin = TRUE ;
323
        Maximum = 100 ;
324
        Last = 100 ;
325
        Unit = FUNIT_CUSTOM ;
326
        CustomUnitText = " %" ;
327
    };
328
329
    FixedText CT_BRIGHTNESS
330
    {
331
        Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , HSB_Y3+1 ) ;
332
        Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ;
333
        Text [ en-US ] = "Bright~ness" ;
334
    };
335
336
    MetricField CT_BRIGHTNESS
337
    {
338
        HelpID = "cui:MetricField:ColorPicker:Brightness";
339
        Border = TRUE ;
340
        Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , HSB_Y3 ) ;
341
        Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ;
342
        TabStop = TRUE ;
343
        Repeat = TRUE ;
344
        Spin = TRUE ;
345
        Maximum = 100 ;
346
        Last = 100 ;
347
        Unit = FUNIT_CUSTOM ;
348
        CustomUnitText = " %" ;
349
    };
350
351
// -------------------------------------------------------------------------
352
// CMYK
353
// -------------------------------------------------------------------------
354
355
    FixedLine FL_CMYK
356
    {
357
        Pos = MAP_APPFONT ( CONTROL_AREA_X , CMYK_Y0 ) ;
358
        Size = MAP_APPFONT ( LINE_WIDTH , LINE_HEIGHT ) ;
359
        Text [ en-US ] = "CMYK" ;
360
    };
361
362
    FixedText CT_CYAN
363
    {
364
        Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , CMYK_Y1+1 ) ;
365
        Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ;
366
        Text [ en-US ] = "~Cyan" ;
367
    };
368
369
    MetricField CT_CYAN
370
    {
371
        HelpID = "cui:MetricField:ColorPicker:Cyan";
372
        Border = TRUE ;
373
        Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , CMYK_Y1 ) ;
374
        Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ;
375
        TabStop = TRUE ;
376
        Repeat = TRUE ;
377
        Spin = TRUE ;
378
        Maximum = 100 ;
379
        Last = 100 ;
380
        Unit = FUNIT_CUSTOM ;
381
        CustomUnitText = " %" ;
382
    };
383
384
    FixedText CT_MAGENTA
385
    {
386
        Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , CMYK_Y2+1 ) ;
387
        Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ;
388
        Text [ en-US ] = "~Magenta" ;
389
    };
390
391
    MetricField CT_MAGENTA
392
    {
393
        HelpID = "cui:MetricField:ColorPicker:Magenta";
394
        Border = TRUE ;
395
        Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , CMYK_Y2 ) ;
396
        Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ;
397
        TabStop = TRUE ;
398
        Repeat = TRUE ;
399
        Spin = TRUE ;
400
        Maximum = 100 ;
401
        Last = 100 ;
402
        Unit = FUNIT_CUSTOM ;
403
        CustomUnitText = " %" ;
404
    };
405
406
    FixedText CT_YELLOW
407
    {
408
        Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , CMYK_Y3+1 ) ;
409
        Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ;
410
        Text [ en-US ] = "~Yellow" ;
411
    };
412
413
    MetricField CT_YELLOW
414
    {
415
        HelpID = "cui:MetricField:ColorPicker:Yellow";
416
        Border = TRUE ;
417
        Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , CMYK_Y3 ) ;
418
        Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ;
419
        TabStop = TRUE ;
420
        Repeat = TRUE ;
421
        Spin = TRUE ;
422
        Maximum = 100 ;
423
        Last = 100 ;
424
        Unit = FUNIT_CUSTOM ;
425
        CustomUnitText = " %" ;
426
    };
427
428
    FixedText CT_KEY
429
    {
430
        Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , CMYK_Y4+1 ) ;
431
        Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ;
432
        Text [ en-US ] = "~Key" ;
433
    };
434
435
    MetricField CT_KEY
436
    {
437
        HelpID = "cui:MetricField:ColorPicker:Key";
438
        Border = TRUE ;
439
        Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , CMYK_Y4 ) ;
440
        Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ;
441
        TabStop = TRUE ;
442
        Repeat = TRUE ;
443
        Spin = TRUE ;
444
        Maximum = 100 ;
445
        Last = 100 ;
446
        Unit = FUNIT_CUSTOM ;
447
        CustomUnitText = " %" ;
448
    };
449
450
    // ------------------------------------------------------
451
    // bottom buttons
452
    // ------------------------------------------------------
453
454
    FixedLine FT_BOTTOMLINE
455
    {
456
        Pos = MAP_APPFONT ( 0 , BOTTOMLINE_Y ) ;
457
        Size = MAP_APPFONT ( DLG_WIDTH , 8 ) ;
458
    };
459
460
    HelpButton BTN_HELP
461
    {
462
        Pos = MAP_APPFONT ( 3 , BUTTON_LINE_Y ) ;
463
        Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ;
464
        TabStop = TRUE ;
465
    };
466
467
    OKButton BTN_OK
468
    {
469
        Pos = MAP_APPFONT ( DLG_WIDTH - 3 - BUTTON_WIDTH - 3 - BUTTON_WIDTH, BUTTON_LINE_Y ) ;
470
        Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ;
471
        TabStop = TRUE ;
472
        DefButton = TRUE ;
473
    };
474
    CancelButton BTN_CANCEL
475
    {
476
        Pos = MAP_APPFONT ( DLG_WIDTH - 3 - BUTTON_WIDTH, BUTTON_LINE_Y ) ;
477
        Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ;
478
        TabStop = TRUE ;
479
    };
480
};
481
482
// eof
483
*
(-)cui/source/dialogs/makefile.mk (+2 lines)
Lines 43-48 Link Here
43
SRS1NAME=dialogs
43
SRS1NAME=dialogs
44
SRC1FILES =  \
44
SRC1FILES =  \
45
        about.src \
45
        about.src \
46
        colorpicker.src \
46
        charmap.src \
47
        charmap.src \
47
        commonlingui.src \
48
        commonlingui.src \
48
        cuiimapdlg.src \
49
        cuiimapdlg.src \
Lines 74-79 Link Here
74
75
75
SLOFILES+=\
76
SLOFILES+=\
76
        $(SLO)$/about.obj \
77
        $(SLO)$/about.obj \
78
        $(SLO)$/colorpicker.obj \
77
        $(SLO)$/commonlingui.obj \
79
        $(SLO)$/commonlingui.obj \
78
        $(SLO)$/cuicharmap.obj \
80
        $(SLO)$/cuicharmap.obj \
79
        $(SLO)$/cuifmsearch.obj \
81
        $(SLO)$/cuifmsearch.obj \
(-)cui/source/dialogs/colorpicker.hrc (+64 lines)
Line 0 Link Here
1
/**************************************************************
2
 * 
3
 * Licensed to the Apache Software Foundation (ASF) under one
4
 * or more contributor license agreements.  See the NOTICE file
5
 * distributed with this work for additional information
6
 * regarding copyright ownership.  The ASF licenses this file
7
 * to you under the Apache License, Version 2.0 (the
8
 * "License"); you may not use this file except in compliance
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
15
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
 * KIND, either express or implied.  See the License for the
17
 * specific language governing permissions and limitations
18
 * under the License.
19
 * 
20
 *************************************************************/
21
22
#ifndef _CUI_COLORPICKER_HRC_
23
#define _CUI_COLORPICKER_HRC_
24
25
#include <cuires.hrc>
26
27
#define FT_BOTTOMLINE   1
28
#define BTN_OK          2
29
#define BTN_CANCEL      3
30
#define BTN_HELP        4
31
32
#define CT_COLORFIELD   5
33
#define CT_COLORSLIDER  6
34
#define CT_PREVIEW      7
35
#define CT_PREVIOUS     8
36
37
#define FL_RGB          9
38
#define CT_RED          10
39
#define CT_GREEN        11
40
#define CT_BLUE         12
41
#define CT_HEX          13
42
43
#define FL_HSB          14
44
#define CT_HUE          15
45
#define CT_SATURATION   16
46
#define CT_BRIGHTNESS   17
47
48
#define FL_CMYK         18
49
#define CT_CYAN         19
50
#define CT_MAGENTA      20
51
#define CT_YELLOW       21
52
#define CT_KEY          22
53
54
#define PB_PICKER       23
55
56
#define CT_LEFT_SLIDER  24
57
#define CT_RIGHT_SLIDER 25
58
59
#define CT_SLIDERIMG    26
60
61
#endif
62
63
// eof
64
*
(-)cui/source/dialogs/colorpicker.cxx (+1705 lines)
Line 0 Link Here
1
/**************************************************************
2
 * 
3
 * Licensed to the Apache Software Foundation (ASF) under one
4
 * or more contributor license agreements.  See the NOTICE file
5
 * distributed with this work for additional information
6
 * regarding copyright ownership.  The ASF licenses this file
7
 * to you under the Apache License, Version 2.0 (the
8
 * "License"); you may not use this file except in compliance
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
15
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
 * KIND, either express or implied.  See the License for the
17
 * specific language governing permissions and limitations
18
 * under the License.
19
 * 
20
 *************************************************************/
21
22
// MARKER(update_precomp.py): autogen include statement, do not remove
23
#include "precompiled_cui.hxx"
24
25
#include <com/sun/star/uno/XComponentContext.hpp>
26
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
27
#include <com/sun/star/beans/XPropertyAccess.hpp>
28
#include <com/sun/star/lang/XInitialization.hpp>
29
#include <com/sun/star/lang/XServiceInfo.hpp>
30
#include <com/sun/star/datatransfer/XTransferable.hpp>
31
#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
32
#include <com/sun/star/awt/XWindow.hpp>
33
#include <cppuhelper/compbase4.hxx>
34
#include <comphelper/broadcasthelper.hxx>
35
#include <vcl/dialog.hxx>
36
#include <vcl/button.hxx>
37
#include <vcl/fixed.hxx>
38
#include <vcl/edit.hxx>
39
#include <vcl/field.hxx>
40
#include <vcl/bmpacc.hxx>
41
#include <vcl/decoview.hxx>
42
#include <vcl/sound.hxx>
43
#include <vcl/svapp.hxx>
44
#include <toolkit/helper/vclunohelper.hxx>
45
#include <sot/exchange.hxx>
46
#include <sot/formats.hxx>
47
#include <sax/tools/converter.hxx>
48
#include "dialmgr.hxx"
49
#include "colorpicker.hrc"
50
#include <cmath>
51
52
using rtl::OUString;
53
using namespace ::com::sun::star::uno;
54
using namespace ::com::sun::star::lang;
55
using namespace ::com::sun::star::ui::dialogs;
56
using namespace ::com::sun::star::beans;
57
58
namespace cui
59
{
60
const sal_uInt16 COLORMODE_RGB =  0x10;
61
const sal_uInt16 COLORMODE_HSV =  0x20;
62
const sal_uInt16 COLORMODE_CMYK = 0x40;
63
64
const sal_uInt16 COLORCOMP_RED   = 0x10;
65
const sal_uInt16 COLORCOMP_GREEN = 0x11;
66
const sal_uInt16 COLORCOMP_BLUE  = 0x12;
67
68
const sal_uInt16 COLORCOMP_HUE  = 0x20;
69
const sal_uInt16 COLORCOMP_SAT  = 0x21;
70
const sal_uInt16 COLORCOMP_BRI  = 0x22;
71
72
const sal_uInt16 COLORCOMP_CYAN    = 0x40;
73
const sal_uInt16 COLORCOMP_YELLOW  = 0x41;
74
const sal_uInt16 COLORCOMP_MAGENTA = 0x42;
75
const sal_uInt16 COLORCOMP_KEY     = 0x43;
76
77
// -----------------------------------------------------------------------
78
// color space conversion
79
// RGB  = 0 .. 1
80
// H    = 0 .. 360
81
// SV   = 0 .. 1
82
// CMYK = 0 .. 1
83
// -----------------------------------------------------------------------
84
85
static void RGBtoHSV( double dR, double dG, double dB, double& dH, double& dS, double& dV )
86
{
87
    // Brightness = max(R, G, B);
88
    dV = std::max( dR, std::max( dG, dB ) );
89
90
    double cDelta = dV - std::min( dR, std::min( dG, dB ) );
91
92
    // Saturation = max - min / max
93
    if( dV > 0 )
94
        dS = cDelta / dV;
95
    else
96
        dS = 0.0;
97
98
    dH = 0.0;
99
100
    if( !basegfx::fTools::equalZero( dS ) )
101
    {
102
        if( basegfx::fTools::equal( dR, dV ) )
103
        {
104
            dH = ( dG - dB ) / cDelta;
105
        }
106
        else if( basegfx::fTools::equal( dG, dV ) )
107
        {
108
            dH = 2.0 + ( dB - dR ) / cDelta;
109
        }
110
        else if ( basegfx::fTools::equal( dB, dV ) )
111
        {
112
            dH = 4.0 + ( dR - dG ) / cDelta;
113
        }
114
        dH *= 60.0;
115
116
        if( dH < 0.0 )
117
            dH += 360.0;
118
    }
119
}
120
121
static void HSVtoRGB(double dH, double dS, double dV, double& dR, double& dG, double& dB )
122
{
123
    if( basegfx::fTools::equalZero( dS ) )
124
    {
125
        dR = dV;
126
        dG = dV;
127
        dB = dV;
128
    }
129
    else
130
    {
131
        if( basegfx::fTools::equal( dH, 360.0 ) )
132
            dH = 0.0;
133
        else
134
            dH /= 60.0;
135
136
        sal_uInt16 n = (sal_uInt16) dH;
137
        double f = dH - n;
138
139
        double a = dV * ( 1.0 - dS );
140
        double b = dV * ( 1.0 - ( dS * f ) );
141
        double c = dV * ( 1.0 - ( dS * ( 1.0 - f ) ) );
142
143
        switch( n )
144
        {
145
            case 0: dR = dV; dG = c;  dB = a;  break;
146
            case 1: dR = b;  dG = dV; dB = a;  break;
147
            case 2: dR = a;  dG = dV; dB = c;  break;
148
            case 3: dR = a;  dG = b;  dB = dV; break;
149
            case 4: dR = c;  dG = a;  dB = dV; break;
150
            case 5: dR = dV; dG = a;  dB = b;  break;
151
        }
152
    }
153
}
154
155
// -----------------------------------------------------------------------
156
157
// CMYK values from 0 to 1
158
static void CMYKtoRGB( double fCyan, double fMagenta, double fYellow, double fKey, double& dR, double& dG, double& dB )
159
{
160
    fCyan = (fCyan * ( 1.0 - fKey )) + fKey;
161
    fMagenta = (fMagenta * ( 1.0 - fKey )) + fKey;
162
    fYellow = (fYellow * ( 1.0 - fKey )) + fKey;
163
164
    dR = std::max( std::min( ( 1.0 - fCyan ), 1.0), 0.0 );
165
    dG = std::max( std::min( ( 1.0 - fMagenta ), 1.0), 0.0 );
166
    dB = std::max( std::min( ( 1.0 - fYellow ), 1.0), 0.0 );
167
}
168
169
// -----------------------------------------------------------------------
170
171
// CMY results from 0 to 1
172
static void RGBtoCMYK( double dR, double dG, double dB, double& fCyan, double& fMagenta, double& fYellow, double& fKey )
173
{
174
    fCyan = 1 - dR;
175
    fMagenta = 1 - dG;
176
    fYellow = 1 - dB;
177
178
    //CMYK and CMY values from 0 to 1
179
    fKey = 1.0;
180
    if( fCyan < fKey ) fKey = fCyan;
181
    if( fMagenta < fKey ) fKey = fMagenta;
182
    if( fYellow < fKey ) fKey = fYellow;
183
184
    if( basegfx::fTools::equal( fKey, 1.0 ) )
185
    {
186
        //Black
187
       fCyan = 0.0;
188
       fMagenta = 0.0;
189
       fYellow = 0.0;
190
    }
191
    else
192
    {
193
       fCyan = ( fCyan - fKey ) / ( 1.0 - fKey );
194
       fMagenta = ( fMagenta - fKey ) / ( 1.0 - fKey );
195
       fYellow = ( fYellow - fKey ) / ( 1.0 - fKey );
196
    }
197
}
198
199
// ====================================================================
200
201
class HexColorControl : public Edit
202
{
203
public:
204
    HexColorControl( Window* pParent, const ResId& rResId );
205
206
    virtual long PreNotify( NotifyEvent& rNEvt );
207
    virtual void Paste();
208
209
    void SetColor( sal_Int32 nColor );
210
    sal_Int32 GetColor();
211
212
private:
213
    bool ImplProcessKeyInput( const KeyEvent& rKEv );
214
};
215
216
HexColorControl::HexColorControl( Window* pParent, const ResId& rResId )
217
: Edit( pParent, rResId )
218
{
219
    SetMaxTextLen( 6 );
220
}
221
222
// -----------------------------------------------------------------------
223
224
void HexColorControl::SetColor( sal_Int32 nColor )
225
{
226
    ::rtl::OUStringBuffer aBuffer;
227
    sax::Converter::convertColor( aBuffer, nColor );
228
    SetText( aBuffer.makeStringAndClear().copy(1) );
229
}
230
231
// -----------------------------------------------------------------------
232
233
sal_Int32 HexColorControl::GetColor()
234
{
235
    sal_Int32 nColor = -1;
236
237
    OUString aStr( RTL_CONSTASCII_USTRINGPARAM( "#" ) );
238
    aStr += GetText();
239
    sal_Int32 nLen = aStr.getLength();
240
    if( nLen < 7 )
241
    {
242
        static const sal_Char* pNullStr = "000000";
243
        aStr += OUString::createFromAscii( &pNullStr[nLen-1] );
244
    }
245
246
    sax::Converter::convertColor( nColor, aStr );
247
248
    if( nColor == -1 )
249
        SetControlBackground( Color( COL_RED ) );
250
    else
251
        SetControlBackground();
252
253
    return nColor;
254
}
255
256
// -----------------------------------------------------------------------
257
258
long HexColorControl::PreNotify( NotifyEvent& rNEvt )
259
{
260
    if ( (rNEvt.GetType() == EVENT_KEYINPUT) && !rNEvt.GetKeyEvent()->GetKeyCode().IsMod2() )
261
    {
262
        if ( ImplProcessKeyInput( *rNEvt.GetKeyEvent() ) )
263
            return 1;
264
    }
265
266
    return Edit::PreNotify( rNEvt );
267
}
268
269
// -----------------------------------------------------------------------
270
271
void HexColorControl::Paste()
272
{
273
    ::com::sun::star::uno::Reference<com::sun::star::datatransfer::clipboard::XClipboard> aClipboard(GetClipboard());
274
    if ( aClipboard.is() )
275
    {
276
        ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > xDataObj;
277
278
        const sal_uInt32 nRef = Application::ReleaseSolarMutex();
279
280
        try
281
        {
282
            xDataObj = aClipboard->getContents();
283
        }
284
        catch( const ::com::sun::star::uno::Exception& )
285
        {
286
        }
287
288
        Application::AcquireSolarMutex( nRef );
289
290
        if ( xDataObj.is() )
291
        {
292
            ::com::sun::star::datatransfer::DataFlavor aFlavor;
293
            SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aFlavor );
294
            try
295
            {
296
                ::com::sun::star::uno::Any aData = xDataObj->getTransferData( aFlavor );
297
                ::rtl::OUString aText;
298
                aData >>= aText;
299
300
                if( aText.getLength() && aText.matchAsciiL( "#", 1, 0 ) )
301
                    aText = aText.copy(1);
302
303
                if( aText.getLength() > 6 )
304
                    aText = aText.copy( 0, 6 );
305
306
                SetText( aText );
307
            }
308
            catch( const ::com::sun::star::uno::Exception& )
309
            {
310
            }
311
        }
312
    }
313
}
314
315
// -----------------------------------------------------------------------
316
317
bool HexColorControl::ImplProcessKeyInput( const KeyEvent& rKEv )
318
{
319
    const KeyCode& rKeyCode = rKEv.GetKeyCode();
320
321
    if( rKeyCode.GetGroup() == KEYGROUP_ALPHA && !rKeyCode.IsMod1() && !rKeyCode.IsMod2() )
322
    {
323
        if( (rKeyCode.GetCode() < KEY_A) || (rKeyCode.GetCode() > KEY_F) )
324
        {
325
            Sound::Beep();
326
            return true;
327
        }
328
    }
329
    else if( rKeyCode.GetGroup() == KEYGROUP_NUM )
330
    {
331
        if( rKeyCode.IsShift() )
332
        {
333
            Sound::Beep();
334
            return true;
335
        }
336
    }
337
    return false;
338
}
339
340
// ====================================================================
341
342
class ColorPreviewControl : public Control
343
{
344
public:
345
    ColorPreviewControl( Window* pParent, const ResId& rResId );
346
347
    virtual void        Paint( const Rectangle& rRect );
348
349
    void SetColor( const Color& rColor );
350
private:
351
    Color maColor;
352
};
353
354
// -----------------------------------------------------------------------
355
356
ColorPreviewControl::ColorPreviewControl( Window* pParent, const ResId& rResId )
357
: Control( pParent, rResId )
358
{
359
    SetFillColor( maColor );
360
    SetLineColor( maColor );
361
}
362
363
// -----------------------------------------------------------------------
364
365
void ColorPreviewControl::SetColor( const Color& rCol )
366
{
367
    if( rCol != maColor )
368
    {
369
        maColor = rCol;
370
        SetFillColor( maColor );
371
        SetLineColor( maColor );
372
        Invalidate();
373
    }
374
}
375
376
// -----------------------------------------------------------------------
377
378
void ColorPreviewControl::Paint( const Rectangle& rRect )
379
{
380
    DrawRect( rRect );
381
}
382
383
// ====================================================================
384
385
enum ColorMode { HUE, SATURATION, BRIGHTNESS, RED, GREEN, BLUE };
386
const ColorMode DefaultMode = HUE;
387
388
class ColorFieldControl : public Control
389
{
390
public:
391
    ColorFieldControl( Window* pParent, const ResId& rResId );
392
    ~ColorFieldControl();
393
394
    virtual void        MouseMove( const MouseEvent& rMEvt );
395
    virtual void        MouseButtonDown( const MouseEvent& rMEvt );
396
    virtual void        MouseButtonUp( const MouseEvent& rMEvt );
397
    virtual void        KeyInput( const KeyEvent& rKEvt );
398
    virtual void        Paint( const Rectangle& rRect );
399
    virtual void        Resize();
400
401
    void                UpdateBitmap();
402
    void                ShowPosition( const Point& rPos, bool bUpdate );
403
    void                UpdatePosition();
404
    void                Modify();
405
406
    void                SetValues( Color aColor, ColorMode eMode, double x, double y );
407
    double              GetX();
408
    double              GetY();
409
410
    void                KeyMove( int dx, int dy );
411
412
    void                SetModifyHdl( Link& rLink ) { maModifyHdl = rLink; }
413
414
private:
415
    Link maModifyHdl;
416
    ColorMode meMode;
417
    Color maColor;
418
    double mdX;
419
    double mdY;
420
    Point maPosition;
421
    Bitmap* mpBitmap;
422
    std::vector< sal_uInt8 > maRGB_Horiz;
423
    std::vector< sal_uInt16 > maGrad_Horiz;
424
    std::vector< sal_uInt16 > maPercent_Horiz;
425
    std::vector< sal_uInt8 > maRGB_Vert;
426
    std::vector< sal_uInt16 > maPercent_Vert;
427
    bool mbInit;
428
};
429
430
// -----------------------------------------------------------------------
431
432
ColorFieldControl::ColorFieldControl( Window* pParent, const ResId& rResId )
433
: Control( pParent, rResId )
434
, meMode( DefaultMode )
435
, mdX( -1.0 )
436
, mdY( -1.0 )
437
, mpBitmap( 0 )
438
, mbInit( false )
439
{
440
    SetControlBackground();
441
}
442
443
// -----------------------------------------------------------------------
444
445
ColorFieldControl::~ColorFieldControl()
446
{
447
    delete mpBitmap;
448
}
449
450
// -----------------------------------------------------------------------
451
452
void ColorFieldControl::UpdateBitmap()
453
{
454
    const Size aSize( GetOutputSizePixel() );
455
456
    if( mpBitmap && mpBitmap->GetSizePixel() != aSize )
457
        delete mpBitmap, mpBitmap = NULL;
458
459
    const sal_Int32 nWidth = aSize.Width();
460
    const sal_Int32 nHeight = aSize.Height();
461
462
    if( !mpBitmap )
463
    {
464
        mpBitmap = new Bitmap( aSize, 24 );
465
466
        maRGB_Horiz.resize( nWidth );
467
        maGrad_Horiz.resize( nWidth );
468
        maPercent_Horiz.resize( nWidth );
469
470
        sal_uInt8* pRGB = &(*maRGB_Horiz.begin());
471
        sal_uInt16* pGrad = &(*maGrad_Horiz.begin());
472
        sal_uInt16* pPercent = &(*maPercent_Horiz.begin());
473
474
        for( sal_Int32 x = 0; x < nWidth; x++ )
475
        {
476
            *pRGB++ = static_cast< sal_uInt8 >( (x * 256) / nWidth );
477
            *pGrad++ = static_cast< sal_uInt16 >( (x * 359) / nWidth );
478
            *pPercent++ = static_cast< sal_uInt16 >( (x * 100) / nWidth );
479
        }
480
481
        maRGB_Vert.resize( nHeight );
482
        maPercent_Vert.resize( nHeight );
483
484
        pRGB = &(*maRGB_Vert.begin());
485
        pPercent = &(*maPercent_Vert.begin());
486
487
        sal_Int32 y = nHeight;
488
        while( y-- )
489
        {
490
            *pRGB++ = static_cast< sal_uInt8 >( (y * 256) / nHeight );
491
            *pPercent++ = static_cast< sal_uInt16 >( (y * 100) / nHeight );
492
        }
493
    }
494
495
    sal_uInt8* pRGB_Horiz = &(*maRGB_Horiz.begin());
496
    sal_uInt16* pGrad_Horiz = &(*maGrad_Horiz.begin());
497
    sal_uInt16* pPercent_Horiz = &(*maPercent_Horiz.begin());
498
    sal_uInt8* pRGB_Vert = &(*maRGB_Vert.begin());
499
    sal_uInt16* pPercent_Vert = &(*maPercent_Vert.begin());
500
501
    BitmapWriteAccess* pWriteAccess = mpBitmap->AcquireWriteAccess();
502
    if( pWriteAccess )
503
    {
504
        BitmapColor aBitmapColor( maColor );
505
506
        sal_uInt16 nHue, nSat, nBri;
507
        maColor.RGBtoHSB( nHue, nSat, nBri );
508
509
        // this has been unlooped for performance reason, please do not merge back!
510
511
        sal_uInt16 y = nHeight,x;
512
513
        switch( meMode )
514
        {
515
        case HUE:
516
            while( y-- )
517
            {
518
                nBri = pPercent_Vert[y];
519
                x = nWidth;
520
                while( x-- )
521
                {
522
                    nSat = pPercent_Horiz[x];
523
                    pWriteAccess->SetPixel( y, x, BitmapColor( Color( Color::HSBtoRGB( nHue, nSat, nBri ) ) ) );
524
                }
525
            }
526
            break;
527
        case SATURATION:
528
            while( y-- )
529
            {
530
                nBri = pPercent_Vert[y];
531
                x = nWidth;
532
                while( x-- )
533
                {
534
                    nHue = pGrad_Horiz[x];
535
                    pWriteAccess->SetPixel( y, x, BitmapColor( Color( Color::HSBtoRGB( nHue, nSat, nBri ) ) ) );
536
                }
537
            }
538
            break;
539
        case BRIGHTNESS:
540
            while( y-- )
541
            {
542
                nSat = pPercent_Vert[y];
543
                x = nWidth;
544
                while( x-- )
545
                {
546
                    nHue = pGrad_Horiz[x];
547
                    pWriteAccess->SetPixel( y, x, BitmapColor( Color( Color::HSBtoRGB( nHue, nSat, nBri ) ) ) );
548
                }
549
            }
550
            break;
551
        case RED:
552
            while( y-- )
553
            {
554
                aBitmapColor.SetGreen( pRGB_Vert[y] );
555
                x = nWidth;
556
                while( x-- )
557
                {
558
                    aBitmapColor.SetBlue( pRGB_Horiz[x] );
559
                    pWriteAccess->SetPixel( y, x, aBitmapColor );
560
                }
561
            }
562
            break;
563
        case GREEN:
564
            while( y-- )
565
            {
566
                aBitmapColor.SetRed( pRGB_Vert[y] );
567
                x = nWidth;
568
                while( x-- )
569
                {
570
                    aBitmapColor.SetBlue( pRGB_Horiz[x] );
571
                    pWriteAccess->SetPixel( y, x, aBitmapColor );
572
                }
573
            }
574
            break;
575
        case BLUE:
576
            while( y-- )
577
            {
578
                aBitmapColor.SetGreen( pRGB_Vert[y] );
579
                x = nWidth;
580
                while( x-- )
581
                {
582
                    aBitmapColor.SetRed( pRGB_Horiz[x] );
583
                    pWriteAccess->SetPixel( y, x, aBitmapColor );
584
                }
585
            }
586
            break;
587
        }
588
589
        mpBitmap->ReleaseAccess( pWriteAccess );
590
    }
591
}
592
593
// -----------------------------------------------------------------------
594
595
void ColorFieldControl::ShowPosition( const Point& rPos, bool bUpdate )
596
{
597
    if( !mpBitmap )
598
    {
599
        UpdateBitmap();
600
        Invalidate();
601
    }
602
603
    const Size aSize( mpBitmap->GetSizePixel() );
604
605
    long nX = rPos.X();
606
    long nY = rPos.Y();
607
    if( nX < 0L )
608
        nX = 0L;
609
    else if( nX >= aSize.Width() )
610
        nX = aSize.Width() - 1L;
611
612
    if( nY < 0L )
613
        nY= 0L;
614
    else if( nY >= aSize.Height() )
615
        nY = aSize.Height() - 1L;
616
617
    Point aPos = maPosition;
618
    maPosition.X() = nX - 5;
619
    maPosition.Y() = nY - 5;
620
    Invalidate( Rectangle( aPos, Size( 11, 11) ) );
621
    Invalidate( Rectangle( maPosition, Size( 11, 11) ) );
622
623
    if( bUpdate )
624
    {
625
        mdX = (double)nX / (double)(aSize.Width()-1);
626
        mdY = (double)(aSize.Height()-1-nY) / (double)(aSize.Height()-1);
627
628
        BitmapReadAccess* pReadAccess = mpBitmap->AcquireReadAccess();
629
        if( pReadAccess != NULL )
630
        {
631
            // mpBitmap always has a bit count of 24 => use of GetPixel(...) is safe
632
            maColor = pReadAccess->GetPixel( nY, nX );
633
            mpBitmap->ReleaseAccess( pReadAccess );
634
            pReadAccess = NULL;
635
        }
636
    }
637
}
638
// -----------------------------------------------------------------------
639
640
void ColorFieldControl::MouseMove( const MouseEvent& rMEvt )
641
{
642
    if( rMEvt.IsLeft() )
643
    {
644
        ShowPosition( rMEvt.GetPosPixel(), true );
645
        Modify();
646
    }
647
}
648
649
// -----------------------------------------------------------------------
650
void ColorFieldControl::MouseButtonDown( const MouseEvent& rMEvt )
651
{
652
    if( rMEvt.IsLeft() && !rMEvt.IsShift() )
653
    {
654
        CaptureMouse();
655
        ShowPosition( rMEvt.GetPosPixel(), true );
656
        Modify();
657
    }
658
}
659
660
// -----------------------------------------------------------------------
661
void ColorFieldControl::MouseButtonUp( const MouseEvent& )
662
{
663
    if( IsMouseCaptured() )
664
        ReleaseMouse();
665
}
666
667
// -----------------------------------------------------------------------
668
669
void ColorFieldControl::KeyMove( int dx, int dy )
670
{
671
    Size aSize( GetOutputSizePixel() );
672
    Point aPos( mdX * aSize.Width(), (1.0 - mdY) * aSize.Height() );
673
    aPos.X() += dx;
674
    aPos.Y() += dy;
675
    if( aPos.X() < 0 )
676
        aPos.X() += aSize.Width();
677
    else if( aPos.X() >= aSize.Width() )
678
        aPos.X() -= aSize.Width();
679
680
    if( aPos.Y() < 0 )
681
        aPos.Y() += aSize.Height();
682
    else if( aPos.Y() >= aSize.Height() )
683
        aPos.Y() -= aSize.Height();
684
685
    ShowPosition( aPos, true );
686
    Modify();
687
}
688
689
// -----------------------------------------------------------------------
690
691
void ColorFieldControl::KeyInput( const KeyEvent& rKEvt )
692
{
693
    bool   bShift = rKEvt.GetKeyCode().IsShift();
694
    bool   bCtrl = rKEvt.GetKeyCode().IsMod1();
695
    bool   bAlt = rKEvt.GetKeyCode().IsMod2();
696
697
    if ( !bAlt && !bShift )
698
    {
699
        switch( rKEvt.GetKeyCode().GetCode() )
700
        {
701
        case KEY_DOWN:      KeyMove(  0, bCtrl ?  5  :  1 ); return;
702
        case KEY_UP:        KeyMove(  0, bCtrl ? -5  : -1 ); return;
703
        case KEY_LEFT:      KeyMove( bCtrl ? -5  : -1,  0 ); return;
704
        case KEY_RIGHT:     KeyMove( bCtrl ?  5  :  1,  0 ); return;
705
        }
706
    }
707
    Control::KeyInput( rKEvt );
708
}
709
710
// -----------------------------------------------------------------------
711
712
void ColorFieldControl::Paint( const Rectangle& rRect )
713
{
714
    if( !mpBitmap )
715
        UpdateBitmap();
716
717
    Bitmap aOutputBitmap( *mpBitmap );
718
719
    if( GetBitCount() <= 8 )
720
        aOutputBitmap.Dither();
721
722
    DrawBitmap( rRect.TopLeft(), rRect.GetSize(), rRect.TopLeft(), rRect.GetSize(), aOutputBitmap );
723
724
    // draw circle around current color
725
    if( maColor.IsDark() )
726
        SetLineColor( COL_WHITE );
727
    else
728
        SetLineColor( COL_BLACK );
729
730
    SetFillColor();
731
732
    DrawEllipse( Rectangle( maPosition, Size( 11, 11) ) );
733
}
734
735
// -----------------------------------------------------------------------
736
737
void ColorFieldControl::Resize()
738
{
739
    UpdateBitmap();
740
    Control::Resize();
741
}
742
743
// -----------------------------------------------------------------------
744
745
void ColorFieldControl::Modify()
746
{
747
    maModifyHdl.Call( this );
748
}
749
750
// -----------------------------------------------------------------------
751
752
void ColorFieldControl::SetValues( Color aColor, ColorMode eMode, double x, double y )
753
{
754
    bool bUpdateBitmap = (maColor!= aColor) || (meMode != eMode);
755
    if( bUpdateBitmap || (mdX != x) || (mdY != y) )
756
    {
757
        maColor = aColor;
758
        meMode = eMode;
759
        mdX = x;
760
        mdY = y;
761
762
        if( bUpdateBitmap )
763
            UpdateBitmap();
764
        UpdatePosition();
765
        if( bUpdateBitmap )
766
            Invalidate();
767
    }
768
}
769
770
// -----------------------------------------------------------------------
771
772
double ColorFieldControl::GetX()
773
{
774
    return mdX;
775
}
776
777
// -----------------------------------------------------------------------
778
779
double ColorFieldControl::GetY()
780
{
781
    return mdY;
782
}
783
784
// -----------------------------------------------------------------------
785
786
void ColorFieldControl::UpdatePosition()
787
{
788
    Size aSize( GetOutputSizePixel() );
789
    ShowPosition( Point( mdX * aSize.Width(), (1.0 - mdY) * aSize.Height() ), false );
790
}
791
792
// ====================================================================
793
794
class ColorSliderControl : public Control
795
{
796
public:
797
    ColorSliderControl( Window* pParent, const ResId& rResId );
798
    ~ColorSliderControl();
799
800
    virtual void        MouseMove( const MouseEvent& rMEvt );
801
    virtual void        MouseButtonDown( const MouseEvent& rMEvt );
802
    virtual void        MouseButtonUp( const MouseEvent& rMEvt );
803
    virtual void        KeyInput( const KeyEvent& rKEvt );
804
    virtual void        Paint( const Rectangle& rRect );
805
    virtual void        Resize();
806
807
    void                UpdateBitmap();
808
    void                ChangePosition( long nY );
809
    void                Modify();
810
811
    void SetValue( const Color& rColor, ColorMode eMode, double dValue );
812
    double GetValue() const { return mdValue; }
813
814
    void                KeyMove( int dy );
815
816
    void SetModifyHdl( Link& rLink ) { maModifyHdl = rLink; }
817
818
    sal_Int16 GetLevel() const { return mnLevel; }
819
820
private:
821
    Link maModifyHdl;
822
    Color maColor;
823
    ColorMode meMode;
824
    Bitmap* mpBitmap;
825
    sal_Int16 mnLevel;
826
    double mdValue;
827
};
828
829
// -----------------------------------------------------------------------
830
831
ColorSliderControl::ColorSliderControl( Window* pParent, const ResId& rResId )
832
: Control( pParent, rResId )
833
, meMode( DefaultMode )
834
, mpBitmap( 0 )
835
, mnLevel( 0 )
836
, mdValue( -1.0 )
837
{
838
    SetControlBackground();
839
}
840
841
// -----------------------------------------------------------------------
842
843
ColorSliderControl::~ColorSliderControl()
844
{
845
    delete mpBitmap;
846
}
847
848
// -----------------------------------------------------------------------
849
850
void ColorSliderControl::UpdateBitmap()
851
{
852
    Size aSize( 1, GetOutputSizePixel().Height() );
853
854
    if( mpBitmap && mpBitmap->GetSizePixel() != aSize )
855
        delete mpBitmap, mpBitmap = NULL;
856
857
    if( !mpBitmap )
858
        mpBitmap = new Bitmap( aSize, 24 );
859
860
    BitmapWriteAccess* pWriteAccess = mpBitmap->AcquireWriteAccess();
861
862
    if( pWriteAccess )
863
    {
864
        const long nY = aSize.Height()-1;
865
866
        BitmapColor aBitmapColor( maColor );
867
868
        sal_uInt16 nHue, nSat, nBri;
869
        maColor.RGBtoHSB( nHue, nSat, nBri );
870
871
        // this has been unlooped for performance reason, please do not merge back!
872
873
        switch( meMode )
874
        {
875
        case HUE:
876
            nSat = 100;
877
            nBri = 100;
878
            for( long y = 0; y <= nY; y++ )
879
            {
880
                nHue = static_cast< sal_uInt16 >( (359 * y) / nY );
881
                aBitmapColor = BitmapColor( Color( Color::HSBtoRGB( nHue, nSat, nBri ) ) );
882
                pWriteAccess->SetPixel( nY-y, 0, aBitmapColor );
883
            }
884
            break;
885
886
        case SATURATION:
887
            nBri = std::max( (sal_uInt16)32, nBri );
888
            for( long y = 0; y <= nY; y++ )
889
            {
890
                nSat = static_cast< sal_uInt16 >( (100 * y) / nY );
891
                pWriteAccess->SetPixel( nY-y, 0, BitmapColor( Color( Color::HSBtoRGB( nHue, nSat, nBri ) ) ) );
892
            }
893
            break;
894
895
        case BRIGHTNESS:
896
            for( long y = 0; y <= nY; y++ )
897
            {
898
                nBri = static_cast< sal_uInt16 >( (100 * y) / nY );
899
                pWriteAccess->SetPixel( nY-y, 0, BitmapColor( Color( Color::HSBtoRGB( nHue, nSat, nBri ) ) ) );
900
            }
901
            break;
902
903
        case RED:
904
            for( long y = 0; y <= nY; y++ )
905
            {
906
                aBitmapColor.SetRed( sal_uInt8( ((long)255 * y) / nY ) );
907
                pWriteAccess->SetPixel( nY-y, 0, aBitmapColor );
908
            }
909
            break;
910
911
        case GREEN:
912
            for( long y = 0; y <= nY; y++ )
913
            {
914
                aBitmapColor.SetGreen( sal_uInt8( ((long)255 * y) / nY ) );
915
                pWriteAccess->SetPixel( nY-y, 0, aBitmapColor );
916
            }
917
            break;
918
919
        case BLUE:
920
            for( long y = 0; y <= nY; y++ )
921
            {
922
                aBitmapColor.SetBlue( sal_uInt8( ((long)255 * y) / nY ) );
923
                pWriteAccess->SetPixel( nY-y, 0, aBitmapColor );
924
            }
925
            break;
926
        }
927
928
        mpBitmap->ReleaseAccess( pWriteAccess );
929
    }
930
}
931
932
// -----------------------------------------------------------------------
933
934
void ColorSliderControl::ChangePosition( long nY )
935
{
936
    const long nHeight = GetOutputSizePixel().Height() - 1;
937
938
    if( nY < 0L )
939
        nY = 0;
940
    else if( nY > nHeight )
941
        nY = nHeight;
942
943
    mnLevel = nY;
944
    mdValue = ((double)(nHeight - nY)) / (double)nHeight;
945
}
946
947
// -----------------------------------------------------------------------
948
949
void ColorSliderControl::MouseMove( const MouseEvent& rMEvt )
950
{
951
    if( rMEvt.IsLeft() )
952
    {
953
        ChangePosition( rMEvt.GetPosPixel().Y() );
954
        Modify();
955
    }
956
}
957
958
// -----------------------------------------------------------------------
959
void ColorSliderControl::MouseButtonDown( const MouseEvent& rMEvt )
960
{
961
    if( rMEvt.IsLeft() && !rMEvt.IsShift() )
962
    {
963
        CaptureMouse();
964
        ChangePosition( rMEvt.GetPosPixel().Y() );
965
        Modify();
966
    }
967
}
968
969
// -----------------------------------------------------------------------
970
void ColorSliderControl::MouseButtonUp( const MouseEvent& )
971
{
972
    if( IsMouseCaptured() )
973
        ReleaseMouse();
974
}
975
976
// -----------------------------------------------------------------------
977
978
void ColorSliderControl::KeyMove( int dy )
979
{
980
    ChangePosition( mnLevel + dy );
981
    Modify();
982
}
983
984
// -----------------------------------------------------------------------
985
986
void ColorSliderControl::KeyInput( const KeyEvent& rKEvt )
987
{
988
    if ( !rKEvt.GetKeyCode().IsMod2() && !rKEvt.GetKeyCode().IsShift() )
989
    {
990
        switch( rKEvt.GetKeyCode().GetCode() )
991
        {
992
        case KEY_DOWN:      KeyMove(  rKEvt.GetKeyCode().IsMod1() ?  5 :  1 ); return;
993
        case KEY_UP:        KeyMove(  rKEvt.GetKeyCode().IsMod1() ? -5 : -1 ); return;
994
        }
995
    }
996
997
    Control::KeyInput( rKEvt );
998
}
999
// -----------------------------------------------------------------------
1000
1001
void ColorSliderControl::Paint( const Rectangle& /*rRect*/ )
1002
{
1003
    if( !mpBitmap )
1004
        UpdateBitmap();
1005
1006
    const Size aSize( GetOutputSizePixel() );
1007
1008
    Bitmap aOutputBitmap( *mpBitmap );
1009
1010
    if( GetBitCount() <= 8 )
1011
        aOutputBitmap.Dither();
1012
1013
    Point aPos;
1014
    int x = aSize.Width();
1015
    while( x-- )
1016
    {
1017
        DrawBitmap( aPos, aOutputBitmap );
1018
        aPos.X() += 1;
1019
    }
1020
}
1021
1022
// -----------------------------------------------------------------------
1023
1024
void ColorSliderControl::Resize()
1025
{
1026
    UpdateBitmap();
1027
    Control::Resize();
1028
}
1029
1030
// -----------------------------------------------------------------------
1031
1032
void ColorSliderControl::Modify()
1033
{
1034
    maModifyHdl.Call( this );
1035
}
1036
1037
// -----------------------------------------------------------------------
1038
1039
void ColorSliderControl::SetValue( const Color& rColor, ColorMode eMode, double dValue )
1040
{
1041
    bool bUpdateBitmap = (rColor != maColor) || (eMode != meMode);
1042
    if( bUpdateBitmap || (mdValue != dValue))
1043
    {
1044
        maColor = rColor;
1045
        mdValue = dValue;
1046
        mnLevel = (1.0-dValue) * GetOutputSizePixel().Height();
1047
        meMode = eMode;
1048
        if( bUpdateBitmap )
1049
            UpdateBitmap();
1050
        Invalidate();
1051
    }
1052
}
1053
1054
// ====================================================================
1055
1056
const sal_uInt16 UPDATE_RGB = 0x01;
1057
const sal_uInt16 UPDATE_CMYK = 0x02;
1058
const sal_uInt16 UPDATE_HSB = 0x04;
1059
const sal_uInt16 UPDATE_COLORCHOOSER = 0x08;
1060
const sal_uInt16 UPDATE_COLORSLIDER = 0x10;
1061
const sal_uInt16 UPDATE_HEX = 0x20;
1062
const sal_uInt16 UPDATE_ALL = 0xff;
1063
1064
class ColorPickerDialog : public ModalDialog
1065
{
1066
public:
1067
    ColorPickerDialog( Window* pParent, sal_Int32 nColor, sal_Int16 nMode );
1068
1069
    void update_color( sal_uInt16 n = UPDATE_ALL );
1070
1071
    DECL_LINK( ColorModifyHdl, void * );
1072
    DECL_LINK( ModeModifyHdl, void * );
1073
1074
    sal_Int32 GetColor() const;
1075
1076
    void setColorComponent( sal_uInt16 nComp, double dValue );
1077
1078
private:
1079
    Color maPreviousColor;
1080
    sal_Int16 mnDialogMode;
1081
    ColorMode meMode;
1082
1083
    double mdRed, mdGreen, mdBlue;
1084
    double mdHue, mdSat, mdBri;
1085
    double mdCyan, mdMagenta, mdYellow, mdKey;
1086
1087
private:
1088
    ColorFieldControl  maColorField;
1089
    ColorSliderControl maColorSlider;
1090
    ColorPreviewControl maColorPreview;
1091
    ColorPreviewControl maColorPrevious;
1092
1093
    FixedImage maFISliderLeft;
1094
    FixedImage maFISliderRight;
1095
    Image maSliderImage;
1096
1097
#if 0
1098
    ImageButton maBtnPicker;
1099
#endif
1100
1101
    FixedLine maFLRGB;
1102
1103
    RadioButton maRBRed;
1104
    RadioButton maRBGreen;
1105
    RadioButton maRBBlue;
1106
    RadioButton maRBHue;
1107
    RadioButton maRBSaturation;
1108
    RadioButton maRBBrightness;
1109
1110
    FixedText maFTRed;
1111
    MetricField maMFRed;
1112
    FixedText maFTGreen;
1113
    MetricField maMFGreen;
1114
    FixedText maFTBlue;
1115
    MetricField maMFBlue;
1116
    FixedText maFTHex;
1117
    HexColorControl maEDHex;
1118
1119
    FixedLine maFLHSB;
1120
    FixedText maFTHue;
1121
    MetricField maMFHue;
1122
    FixedText maFTSaturation;
1123
    MetricField maMFSaturation;
1124
    FixedText maFTBrightness;
1125
    MetricField maMFBrightness;
1126
1127
    FixedLine maFLCMYK;
1128
    FixedText maFTCyan;
1129
    MetricField maMFCyan;
1130
    FixedText maFTMagenta;
1131
    MetricField maMFMagenta;
1132
    FixedText maFTYellow;
1133
    MetricField maMFYellow;
1134
    FixedText maFTKey;
1135
    MetricField maMFKey;
1136
1137
    FixedLine maFLBottmLine;
1138
    HelpButton maBTNHelp;
1139
    OKButton maBTNOk;
1140
    CancelButton maBTNCancel;
1141
};
1142
1143
// --------------------------------------------------------------------
1144
1145
ColorPickerDialog::ColorPickerDialog( Window* pParent, sal_Int32 nColor, sal_Int16 nMode )
1146
: ModalDialog( pParent, CUI_RES( RID_CUI_DIALOG_COLORPICKER ) )
1147
, maPreviousColor( nColor )
1148
, mnDialogMode( nMode )
1149
, meMode( DefaultMode )
1150
, maColorField( this, CUI_RES( CT_COLORFIELD ) )
1151
, maColorSlider( this, CUI_RES( CT_COLORSLIDER ) )
1152
, maColorPreview( this, CUI_RES( CT_PREVIEW ) )
1153
, maColorPrevious( this, CUI_RES( CT_PREVIOUS ) )
1154
, maFISliderLeft(  this, CUI_RES( CT_LEFT_SLIDER ) )
1155
, maFISliderRight( this, CUI_RES( CT_RIGHT_SLIDER ) )
1156
, maSliderImage( CUI_RES( CT_SLIDERIMG ) )
1157
#if 0
1158
, maBtnPicker( this, CUI_RES( PB_PICKER ) )
1159
#endif
1160
, maFLRGB( this, CUI_RES( FL_RGB ) )
1161
, maRBRed( this, CUI_RES( CT_RED ) )
1162
, maRBGreen( this, CUI_RES( CT_GREEN ) )
1163
, maRBBlue( this, CUI_RES( CT_BLUE ) )
1164
, maRBHue( this, CUI_RES( CT_HUE ) )
1165
, maRBSaturation( this, CUI_RES( CT_SATURATION ) )
1166
, maRBBrightness( this, CUI_RES( CT_BRIGHTNESS ) )
1167
, maFTRed( this, CUI_RES( CT_RED ) )
1168
, maMFRed( this, CUI_RES( CT_RED ) )
1169
, maFTGreen( this, CUI_RES( CT_GREEN ) )
1170
, maMFGreen( this, CUI_RES( CT_GREEN ) )
1171
, maFTBlue( this, CUI_RES( CT_BLUE ) )
1172
, maMFBlue( this, CUI_RES( CT_BLUE ) )
1173
, maFTHex( this, CUI_RES( CT_HEX ) )
1174
, maEDHex( this, CUI_RES( CT_HEX ) )
1175
, maFLHSB( this, CUI_RES( FL_HSB ) )
1176
, maFTHue( this, CUI_RES( CT_HUE ) )
1177
, maMFHue( this, CUI_RES( CT_HUE ) )
1178
, maFTSaturation( this, CUI_RES( CT_SATURATION ) )
1179
, maMFSaturation( this, CUI_RES( CT_SATURATION ) )
1180
, maFTBrightness( this, CUI_RES( CT_BRIGHTNESS ) )
1181
, maMFBrightness( this, CUI_RES( CT_BRIGHTNESS ) )
1182
, maFLCMYK( this, CUI_RES( FL_CMYK ) )
1183
, maFTCyan( this, CUI_RES( CT_CYAN ) )
1184
, maMFCyan( this, CUI_RES( CT_CYAN ) )
1185
, maFTMagenta( this, CUI_RES( CT_MAGENTA ) )
1186
, maMFMagenta( this, CUI_RES( CT_MAGENTA ) )
1187
, maFTYellow( this, CUI_RES( CT_YELLOW ) )
1188
, maMFYellow( this, CUI_RES( CT_YELLOW ) )
1189
, maFTKey( this, CUI_RES( CT_KEY ) )
1190
, maMFKey( this, CUI_RES( CT_KEY ) )
1191
1192
, maFLBottmLine( this, CUI_RES( FT_BOTTOMLINE ) )
1193
, maBTNHelp( this, CUI_RES( BTN_HELP ) )
1194
, maBTNOk( this, CUI_RES( BTN_OK ) )
1195
, maBTNCancel( this, CUI_RES( BTN_CANCEL ) )
1196
{
1197
    FreeResource();
1198
1199
    String sUnitText;
1200
    sUnitText.Append( ' ' );
1201
    sUnitText.Append( (sal_Unicode) 0xb0 );
1202
1203
    maMFHue.SetCustomUnitText( sUnitText );
1204
1205
    Link aLink( LINK( this, ColorPickerDialog, ColorModifyHdl ) );
1206
    maColorField.SetModifyHdl( aLink );
1207
    maColorSlider.SetModifyHdl( aLink );
1208
1209
    maMFRed.SetModifyHdl( aLink );
1210
    maMFGreen.SetModifyHdl( aLink );
1211
    maMFBlue.SetModifyHdl( aLink );
1212
1213
    maMFCyan.SetModifyHdl( aLink );
1214
    maMFMagenta.SetModifyHdl( aLink );
1215
    maMFYellow.SetModifyHdl( aLink );
1216
    maMFKey.SetModifyHdl( aLink );
1217
1218
    maMFHue.SetModifyHdl( aLink );
1219
    maMFSaturation.SetModifyHdl( aLink );
1220
    maMFBrightness.SetModifyHdl( aLink );
1221
1222
    maEDHex.SetModifyHdl( aLink );
1223
1224
    aLink = LINK( this, ColorPickerDialog, ModeModifyHdl );
1225
    maRBRed.SetToggleHdl( aLink );
1226
    maRBGreen.SetToggleHdl( aLink );
1227
    maRBBlue.SetToggleHdl( aLink );
1228
    maRBHue.SetToggleHdl( aLink );
1229
    maRBSaturation.SetToggleHdl( aLink );
1230
    maRBBrightness.SetToggleHdl( aLink );
1231
1232
    Image aSliderImage( maSliderImage );
1233
1234
    maFISliderLeft.SetImage( aSliderImage );
1235
1236
    BitmapEx aTmpBmp( maSliderImage.GetBitmapEx() );
1237
    aTmpBmp.Mirror( BMP_MIRROR_HORZ );
1238
    maFISliderRight.SetImage( Image( aTmpBmp  ) );
1239
1240
    Size aSize( maSliderImage.GetSizePixel() );
1241
    maFISliderLeft.SetSizePixel( aSize );
1242
    maFISliderRight.SetSizePixel( aSize );
1243
1244
    Point aPos( maColorSlider.GetPosPixel() );
1245
1246
    aPos.X() -= aSize.Width();
1247
    aPos.Y() -= aSize.Height() / 2;
1248
    maFISliderLeft.SetPosPixel( aPos );
1249
1250
    aPos.X() += aSize.Width() + maColorSlider.GetSizePixel().Width();
1251
    maFISliderRight.SetPosPixel( aPos );
1252
1253
    Color aColor( nColor );
1254
1255
    // modify
1256
    if( mnDialogMode == 2 )
1257
    {
1258
        maColorPreview.SetSizePixel( maColorPrevious.GetSizePixel() );
1259
        maColorPrevious.SetColor( aColor );
1260
        maColorPrevious.Show( true );
1261
    }
1262
1263
    mdRed = ((double)aColor.GetRed()) / 255.0;
1264
    mdGreen = ((double)aColor.GetGreen()) / 255.0;
1265
    mdBlue = ((double)aColor.GetBlue()) / 255.0;
1266
1267
    RGBtoHSV( mdRed, mdGreen, mdBlue, mdHue, mdSat, mdBri );
1268
    RGBtoCMYK( mdRed, mdGreen, mdBlue, mdCyan, mdMagenta, mdYellow, mdKey );
1269
1270
    update_color();
1271
}
1272
1273
// --------------------------------------------------------------------
1274
1275
static int toInt( double dValue, double bRange )
1276
{
1277
    return static_cast< int >( std::floor((dValue * bRange) + 0.5 ) );
1278
}
1279
1280
sal_Int32 ColorPickerDialog::GetColor() const
1281
{
1282
    return Color( toInt(mdRed,255.0), toInt(mdGreen,255.0), toInt(mdBlue,255.0) ).GetColor();
1283
}
1284
1285
void ColorPickerDialog::update_color( sal_uInt16 n )
1286
{
1287
    sal_uInt8 nRed = toInt(mdRed,255.0);
1288
    sal_uInt8 nGreen = toInt(mdGreen,255.0);
1289
    sal_uInt8 nBlue = toInt(mdBlue,255.0);
1290
1291
    Color aColor( nRed, nGreen, nBlue );
1292
1293
    if( n & UPDATE_RGB ) // update RGB
1294
    {
1295
        maMFRed.SetValue( nRed );
1296
        maMFGreen.SetValue( nGreen );
1297
        maMFBlue.SetValue( nBlue );
1298
    }
1299
1300
    if( n & UPDATE_CMYK ) // update CMYK
1301
    {
1302
        maMFCyan.SetValue( toInt( mdCyan, 100.0 ) );
1303
        maMFMagenta.SetValue( toInt( mdMagenta, 100.0 ) );
1304
        maMFYellow.SetValue( toInt( mdYellow, 100.0 ) );
1305
        maMFKey.SetValue( toInt( mdKey, 100.0 ) );
1306
    }
1307
1308
    if( n & UPDATE_HSB ) // update HSB
1309
    {
1310
        maMFHue.SetValue( toInt( mdHue, 1.0 ) );
1311
        maMFSaturation.SetValue( toInt( mdSat, 100.0 ) );
1312
        maMFBrightness.SetValue( toInt( mdBri, 100.0 ) );
1313
    }
1314
1315
    if( n & UPDATE_COLORCHOOSER ) // update Color Chooser 1
1316
    {
1317
        switch( meMode )
1318
        {
1319
        case HUE:           maColorField.SetValues( aColor, meMode, mdSat, mdBri ); break;
1320
        case SATURATION:    maColorField.SetValues( aColor, meMode, mdHue / 360.0, mdBri ); break;
1321
        case BRIGHTNESS:    maColorField.SetValues( aColor, meMode, mdHue / 360.0, mdSat ); break;
1322
        case RED:           maColorField.SetValues( aColor, meMode, mdBlue, mdGreen ); break;
1323
        case GREEN:         maColorField.SetValues( aColor, meMode, mdBlue, mdRed ); break;
1324
        case BLUE:          maColorField.SetValues( aColor, meMode, mdRed, mdGreen ); break;
1325
        }
1326
    }
1327
1328
    if( n & UPDATE_COLORSLIDER ) // update Color Chooser 2
1329
    {
1330
        switch( meMode )
1331
        {
1332
        case HUE:           maColorSlider.SetValue( aColor, meMode, mdHue / 360.0 ); break;
1333
        case SATURATION:    maColorSlider.SetValue( aColor, meMode, mdSat ); break;
1334
        case BRIGHTNESS:    maColorSlider.SetValue( aColor, meMode, mdBri ); break;
1335
        case RED:           maColorSlider.SetValue( aColor, meMode, mdRed ); break;
1336
        case GREEN:         maColorSlider.SetValue( aColor, meMode, mdGreen ); break;
1337
        case BLUE:          maColorSlider.SetValue( aColor, meMode, mdBlue ); break;
1338
        }
1339
    }
1340
1341
    if( n & UPDATE_HEX ) // update hex
1342
    {
1343
        maEDHex.SetColor( aColor.GetColor()  );
1344
    }
1345
1346
    {
1347
        Point aPos( 0, maColorSlider.GetLevel() + maColorSlider.GetPosPixel().Y() - 1 );
1348
1349
        aPos.X() = maFISliderLeft.GetPosPixel().X();
1350
        if( aPos != maFISliderLeft.GetPosPixel() )
1351
        {
1352
            maFISliderLeft.SetPosPixel( aPos );
1353
1354
            aPos.X() = maFISliderRight.GetPosPixel().X();
1355
            maFISliderRight.SetPosPixel( aPos );
1356
        }
1357
    }
1358
1359
    maColorPreview.SetColor( aColor );
1360
}
1361
1362
// --------------------------------------------------------------------
1363
1364
IMPL_LINK( ColorPickerDialog, ColorModifyHdl, void *, p )
1365
{
1366
    sal_uInt16 n = 0;
1367
1368
    if( p == &maColorField )
1369
    {
1370
        double x = maColorField.GetX();
1371
        double y = maColorField.GetY();
1372
1373
        switch( meMode )
1374
        {
1375
        case HUE:           mdSat = x; setColorComponent( COLORCOMP_BRI, y ); break;
1376
        case SATURATION:    mdHue = x * 360.0; setColorComponent( COLORCOMP_BRI, y ); break;
1377
        case BRIGHTNESS:    mdHue = x * 360.0; setColorComponent( COLORCOMP_SAT, y ); break;
1378
        case RED:           mdBlue = x; setColorComponent( COLORCOMP_GREEN, y ); break;
1379
        case GREEN:         mdBlue = x; setColorComponent( COLORCOMP_RED, y ); break;
1380
        case BLUE:          mdRed = x; setColorComponent( COLORCOMP_GREEN, y ); break;
1381
        }
1382
1383
        n = UPDATE_ALL&~(UPDATE_COLORCHOOSER);
1384
    }
1385
    else if( p == &maColorSlider )
1386
    {
1387
        double dValue = maColorSlider.GetValue();
1388
        switch( meMode )
1389
        {
1390
        case HUE:           setColorComponent( COLORCOMP_HUE, dValue * 360.0 ); break;
1391
        case SATURATION:    setColorComponent( COLORCOMP_SAT, dValue ); break;
1392
        case BRIGHTNESS:    setColorComponent( COLORCOMP_BRI, dValue ); break;
1393
        case RED:           setColorComponent( COLORCOMP_RED, dValue ); break;
1394
        case GREEN:         setColorComponent( COLORCOMP_GREEN, dValue ); break;
1395
        case BLUE:          setColorComponent( COLORCOMP_BLUE, dValue ); break;
1396
        }
1397
1398
        n = UPDATE_ALL&~(UPDATE_COLORSLIDER);
1399
    }
1400
    else if( p == &maMFRed )
1401
    {
1402
        setColorComponent( COLORCOMP_RED, ((double)maMFRed.GetValue()) / 255.0 );
1403
        n = UPDATE_ALL&~(UPDATE_RGB);
1404
    }
1405
    else if( p == &maMFGreen )
1406
    {
1407
        setColorComponent( COLORCOMP_GREEN, ((double)maMFGreen.GetValue()) / 255.0 );
1408
        n = UPDATE_ALL&~(UPDATE_RGB);
1409
    }
1410
    else if( p == &maMFBlue )
1411
    {
1412
        setColorComponent( COLORCOMP_BLUE, ((double)maMFBlue.GetValue()) / 255.0 );
1413
        n = UPDATE_ALL&~(UPDATE_RGB);
1414
    }
1415
    else if( p == &maMFHue )
1416
    {
1417
        setColorComponent( COLORCOMP_HUE, (double)maMFHue.GetValue() );
1418
        n = UPDATE_ALL&~(UPDATE_HSB);
1419
    }
1420
    else if( p == &maMFSaturation )
1421
    {
1422
        setColorComponent( COLORCOMP_SAT, ((double)maMFSaturation.GetValue()) / 100.0 );
1423
        n = UPDATE_ALL&~(UPDATE_HSB);
1424
    }
1425
    else if( p == &maMFBrightness )
1426
    {
1427
        setColorComponent( COLORCOMP_BRI, ((double)maMFBrightness.GetValue()) / 100.0 );
1428
        n = UPDATE_ALL&~(UPDATE_HSB);
1429
    }
1430
    else if( p == &maMFCyan )
1431
    {
1432
        setColorComponent( COLORCOMP_CYAN, ((double)maMFCyan.GetValue()) / 100.0 );
1433
        n = UPDATE_ALL&~(UPDATE_CMYK);
1434
    }
1435
    else if( p == &maMFMagenta )
1436
    {
1437
        setColorComponent( COLORCOMP_MAGENTA, ((double)maMFMagenta.GetValue()) / 100.0 );
1438
        n = UPDATE_ALL&~(UPDATE_CMYK);
1439
    }
1440
    else if( p == &maMFYellow )
1441
    {
1442
        setColorComponent( COLORCOMP_YELLOW, ((double)maMFYellow.GetValue()) / 100.0 );
1443
        n = UPDATE_ALL&~(UPDATE_CMYK);
1444
    }
1445
    else if( p == &maMFKey )
1446
    {
1447
        setColorComponent( COLORCOMP_KEY, ((double)maMFKey.GetValue()) / 100.0 );
1448
        n = UPDATE_ALL&~(UPDATE_CMYK);
1449
    }
1450
    else if( p == &maEDHex )
1451
    {
1452
        sal_Int32 nColor = maEDHex.GetColor();
1453
1454
        if( nColor != -1 )
1455
        {
1456
            Color aColor( nColor );
1457
1458
            if( aColor != GetColor() )
1459
            {
1460
                mdRed = ((double)aColor.GetRed()) / 255.0;
1461
                mdGreen = ((double)aColor.GetRed()) / 255.0;
1462
                mdBlue = ((double)aColor.GetRed()) / 255.0;
1463
1464
                RGBtoHSV( mdRed, mdGreen, mdBlue, mdHue, mdSat, mdBri );
1465
                RGBtoCMYK( mdRed, mdGreen, mdBlue, mdCyan, mdMagenta, mdYellow, mdKey );
1466
                n = UPDATE_ALL&~(UPDATE_HEX);
1467
            }
1468
        }
1469
    }
1470
1471
    if( n )
1472
        update_color( n );
1473
1474
    return 0;
1475
}
1476
1477
// --------------------------------------------------------------------
1478
1479
IMPL_LINK( ColorPickerDialog, ModeModifyHdl, void *, EMPTYARG )
1480
{
1481
    ColorMode eMode = HUE;
1482
1483
    if( maRBRed.IsChecked() )
1484
    {
1485
        eMode = RED;
1486
    }
1487
    else if( maRBGreen.IsChecked() )
1488
    {
1489
        eMode = GREEN;
1490
    }
1491
    else if( maRBBlue.IsChecked() )
1492
    {
1493
        eMode = BLUE;
1494
    }
1495
    else if( maRBSaturation.IsChecked() )
1496
    {
1497
        eMode = SATURATION;
1498
    }
1499
    else if( maRBBrightness.IsChecked() )
1500
    {
1501
        eMode = BRIGHTNESS;
1502
    }
1503
1504
    if( meMode != eMode )
1505
    {
1506
        meMode = eMode;
1507
        update_color( UPDATE_COLORCHOOSER | UPDATE_COLORSLIDER );
1508
    }
1509
1510
    return 0;
1511
}
1512
1513
// --------------------------------------------------------------------
1514
1515
void ColorPickerDialog::setColorComponent( sal_uInt16 nComp, double dValue )
1516
{
1517
    switch( nComp )
1518
    {
1519
    case COLORCOMP_RED:     mdRed = dValue; break;
1520
    case COLORCOMP_GREEN:   mdGreen = dValue; break;
1521
    case COLORCOMP_BLUE:    mdBlue = dValue; break;
1522
    case COLORCOMP_HUE:     mdHue = dValue; break;
1523
    case COLORCOMP_SAT:     mdSat = dValue; break;
1524
    case COLORCOMP_BRI:     mdBri = dValue; break;
1525
    case COLORCOMP_CYAN:    mdCyan = dValue; break;
1526
    case COLORCOMP_YELLOW:  mdYellow = dValue; break;
1527
    case COLORCOMP_MAGENTA: mdMagenta = dValue; break;
1528
    case COLORCOMP_KEY:     mdKey = dValue; break;
1529
    }
1530
1531
    if( nComp & COLORMODE_RGB )
1532
    {
1533
        RGBtoHSV( mdRed, mdGreen, mdBlue, mdHue, mdSat, mdBri );
1534
        RGBtoCMYK( mdRed, mdGreen, mdBlue, mdCyan, mdMagenta, mdYellow, mdKey );
1535
    }
1536
    else if( nComp & COLORMODE_HSV )
1537
    {
1538
        HSVtoRGB( mdHue, mdSat, mdBri, mdRed, mdGreen, mdBlue );
1539
        RGBtoCMYK( mdRed, mdGreen, mdBlue, mdCyan, mdMagenta, mdYellow, mdKey );
1540
    }
1541
    else
1542
    {
1543
        CMYKtoRGB( mdCyan, mdMagenta, mdYellow, mdKey, mdRed, mdGreen, mdBlue );
1544
        RGBtoHSV( mdRed, mdGreen, mdBlue, mdHue, mdSat, mdBri );
1545
    }
1546
}
1547
1548
// --------------------------------------------------------------------
1549
1550
typedef ::cppu::WeakComponentImplHelper4< XServiceInfo, XExecutableDialog, XInitialization, XPropertyAccess > ColorPickerBase;
1551
1552
class ColorPicker : protected ::comphelper::OBaseMutex,    // Struct for right initalization of mutex member! Must be first of baseclasses.
1553
                    public ColorPickerBase
1554
{
1555
public:
1556
    ColorPicker( Reference< XComponentContext > const & xContext );
1557
1558
    // XInitialization
1559
    virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException);
1560
1561
    // XInitialization
1562
    virtual OUString SAL_CALL getImplementationName(  ) throw (RuntimeException);
1563
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException);
1564
    virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw (RuntimeException);
1565
1566
    // XPropertyAccess
1567
    virtual Sequence< PropertyValue > SAL_CALL getPropertyValues(  ) throw (RuntimeException);
1568
    virtual void SAL_CALL setPropertyValues( const Sequence< PropertyValue >& aProps ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException);
1569
1570
    // XExecutableDialog
1571
    virtual void SAL_CALL setTitle( const OUString& aTitle ) throw (RuntimeException);
1572
    virtual sal_Int16 SAL_CALL execute(  ) throw (RuntimeException);
1573
1574
private:
1575
    Reference< XComponentContext > mxContext;
1576
    OUString msTitle;
1577
    const OUString msColorKey;
1578
    const OUString msModeKey;
1579
    sal_Int32 mnColor;
1580
    sal_Int16 mnMode;
1581
    Reference< ::com::sun::star::awt::XWindow > mxParent;
1582
};
1583
1584
// --------------------------------------------------------------------
1585
1586
OUString SAL_CALL ColorPicker_getImplementationName()
1587
{
1588
    return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.cui.ColorPicker" ) );
1589
}
1590
1591
// --------------------------------------------------------------------
1592
1593
Reference< XInterface > SAL_CALL ColorPicker_createInstance( Reference< XComponentContext > const & xContext ) SAL_THROW( (Exception) )
1594
{
1595
    return static_cast<XWeak*>( new ColorPicker( xContext ) );
1596
}
1597
1598
// --------------------------------------------------------------------
1599
1600
Sequence< OUString > SAL_CALL ColorPicker_getSupportedServiceNames() throw( RuntimeException )
1601
{
1602
    Sequence< OUString > seq(1);
1603
    seq[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.ColorPicker" ) );
1604
    return seq;
1605
}
1606
1607
// --------------------------------------------------------------------
1608
1609
ColorPicker::ColorPicker( Reference< XComponentContext > const & xContext )
1610
: ColorPickerBase( m_aMutex )
1611
, mxContext( xContext )
1612
, msColorKey( RTL_CONSTASCII_USTRINGPARAM( "Color" ) )
1613
, msModeKey( RTL_CONSTASCII_USTRINGPARAM( "Mode" ) )
1614
, mnColor( 0 )
1615
, mnMode( 0 )
1616
{
1617
}
1618
1619
// --------------------------------------------------------------------
1620
1621
// XInitialization
1622
void SAL_CALL ColorPicker::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException)
1623
{
1624
    if( aArguments.getLength() == 1 )
1625
    {
1626
        aArguments[0] >>= mxParent;
1627
    }
1628
}
1629
1630
// --------------------------------------------------------------------
1631
1632
// XInitialization
1633
OUString SAL_CALL ColorPicker::getImplementationName(  ) throw (RuntimeException)
1634
{
1635
    return ColorPicker_getImplementationName();
1636
}
1637
1638
// --------------------------------------------------------------------
1639
1640
sal_Bool SAL_CALL ColorPicker::supportsService( const OUString& sServiceName ) throw (RuntimeException)
1641
{
1642
    return sServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.ui.dialogs.ColorPicker" ) );
1643
}
1644
1645
// --------------------------------------------------------------------
1646
1647
Sequence< OUString > SAL_CALL ColorPicker::getSupportedServiceNames(  ) throw (RuntimeException)
1648
{
1649
    return ColorPicker_getSupportedServiceNames();
1650
}
1651
1652
// --------------------------------------------------------------------
1653
1654
// XPropertyAccess
1655
Sequence< PropertyValue > SAL_CALL ColorPicker::getPropertyValues(  ) throw (RuntimeException)
1656
{
1657
    Sequence< PropertyValue > props(1);
1658
    props[0].Name = msColorKey;
1659
    props[0].Value <<= mnColor;
1660
    return props;
1661
}
1662
1663
// --------------------------------------------------------------------
1664
1665
void SAL_CALL ColorPicker::setPropertyValues( const Sequence< PropertyValue >& aProps ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
1666
{
1667
    for( sal_Int32 n = 0; n < aProps.getLength(); n++ )
1668
    {
1669
        if( aProps[n].Name.equals( msColorKey ) )
1670
        {
1671
            aProps[n].Value >>= mnColor;
1672
        }
1673
        else if( aProps[n].Name.equals( msModeKey ) )
1674
        {
1675
            aProps[n].Value >>= mnMode;
1676
        }
1677
    }
1678
}
1679
1680
// --------------------------------------------------------------------
1681
1682
// XExecutableDialog
1683
void SAL_CALL ColorPicker::setTitle( const OUString& sTitle ) throw (RuntimeException)
1684
{
1685
    msTitle = sTitle;
1686
}
1687
1688
// --------------------------------------------------------------------
1689
1690
sal_Int16 SAL_CALL ColorPicker::execute(  ) throw (RuntimeException)
1691
{
1692
    ColorPickerDialog aDlg( VCLUnoHelper::GetWindow( mxParent ), mnColor, mnMode );
1693
    sal_Int16 ret = aDlg.Execute();
1694
    if( ret )
1695
        mnColor = aDlg.GetColor();
1696
1697
    return ret;
1698
}
1699
1700
// --------------------------------------------------------------------
1701
1702
}
1703
1704
// eof
1705
*
(-)cui/source/tabpages/tpcolor.cxx (+1 lines)
Lines 643-648 Link Here
643
		ConvertColorValues (aTmpColor, CM_RGB);
643
		ConvertColorValues (aTmpColor, CM_RGB);
644
644
645
	pColorDlg->SetColor (aTmpColor);
645
	pColorDlg->SetColor (aTmpColor);
646
    pColorDlg->SetMode( svtools::ColorPickerMode_MODIFY );
646
647
647
	if( pColorDlg->Execute() == RET_OK )
648
	if( pColorDlg->Execute() == RET_OK )
648
	{
649
	{
(-)cui/source/inc/cuires.hrc (+2 lines)
Lines 434-438 Link Here
434
#define RID_SVXSTR_EVENT_RIGHTCLICK                         (RID_SVX_START + 1192)
434
#define RID_SVXSTR_EVENT_RIGHTCLICK                         (RID_SVX_START + 1192)
435
#define RID_SVXSTR_EVENT_CALCULATE                          (RID_SVX_START + 1193)
435
#define RID_SVXSTR_EVENT_CALCULATE                          (RID_SVX_START + 1193)
436
#define RID_SVXSTR_EVENT_CONTENTCHANGED                     (RID_SVX_START + 1194)
436
#define RID_SVXSTR_EVENT_CONTENTCHANGED                     (RID_SVX_START + 1194)
437
438
#define RID_CUI_DIALOG_COLORPICKER                          (RID_SVX_START + 3)
437
439
438
#endif
440
#endif
(-)cui/prj/build.lst (-2 / +3 lines)
Lines 1-4 Link Here
1
cu	cui	: svx NULL
1
cu	cui	: svx sax sot NULL
2
cu	cui										usr1	-	all	cui_mkout NULL
2
cu	cui										usr1	-	all	cui_mkout NULL
3
cu	cui\inc									nmake	-	all	cui_inc NULL
3
cu	cui\inc									nmake	-	all	cui_inc NULL
4
cu	cui\source\options						nmake	-	all	cui_options cui_inc NULL
4
cu	cui\source\options						nmake	-	all	cui_options cui_inc NULL
Lines 6-9 Link Here
6
cu	cui\source\dialogs						nmake	-	all	cui_dialogs cui_inc NULL
6
cu	cui\source\dialogs						nmake	-	all	cui_dialogs cui_inc NULL
7
cu	cui\source\tabpages						nmake	-	all	cui_tabpages cui_inc NULL
7
cu	cui\source\tabpages						nmake	-	all	cui_tabpages cui_inc NULL
8
cu	cui\source\factory						nmake	-	all	cui_factory cui_inc NULL
8
cu	cui\source\factory						nmake	-	all	cui_factory cui_inc NULL
9
cu 	cui\util								nmake	-	all cui_util cui_factory cui_tabpages cui_dialogs cui_customize cui_options NULL
9
cu	cui\source\uno\services					nmake	-	all	cui_uno_services cui_inc NULL
10
cu 	cui\util								nmake	-	all cui_util cui_factory cui_tabpages cui_dialogs cui_customize cui_options cui_uno_services NULL
(-)cui/prj/d.lst (+2 lines)
Lines 6-8 Link Here
6
..\%COMMON_OUTDIR%\misc\*.hid %COMMON_DEST%\bin%_EXT%\hid\*.hid
6
..\%COMMON_OUTDIR%\misc\*.hid %COMMON_DEST%\bin%_EXT%\hid\*.hid
7
..\%__SRC%\lib\lib*.* %_DEST%\lib%_EXT%\lib*.*
7
..\%__SRC%\lib\lib*.* %_DEST%\lib%_EXT%\lib*.*
8
8
9
mkdir: %COMMON_DEST%\xml%_EXT%\component\cui\util
10
..\%__SRC%\misc\cui.component %_DEST%\xml%_EXT%\component\cui\util\cui.component
(-)cui/util/makefile.mk (-1 / +12 lines)
Lines 48-57 Link Here
48
			$(SLB)$/customize.lib  \
48
			$(SLB)$/customize.lib  \
49
			$(SLB)$/dialogs.lib  \
49
			$(SLB)$/dialogs.lib  \
50
			$(SLB)$/tabpages.lib \
50
			$(SLB)$/tabpages.lib \
51
			$(SLB)$/factory.lib
51
			$(SLB)$/factory.lib \
52
			$(SLB)$/services.lib
52
53
53
54
54
SHL1STDLIBS= \
55
SHL1STDLIBS= \
56
            $(SAXLIB) \
57
            $(SOTLIB) \
55
            $(EDITENGLIB) \
58
            $(EDITENGLIB) \
56
            $(SVXCORELIB) \
59
            $(SVXCORELIB) \
57
            $(SVXLIB) \
60
            $(SVXLIB) \
Lines 98-102 Link Here
98
101
99
# --- Targets -------------------------------------------------------
102
# --- Targets -------------------------------------------------------
100
103
104
ALLTAR : $(MISC)/cui.component
105
106
$(MISC)/cui.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
107
        cui.component
108
    $(XSLTPROC) --nonet --stringparam uri \
109
        '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \
110
        $(SOLARENV)/bin/createcomponent.xslt cui.component
111
101
.INCLUDE :  target.mk
112
.INCLUDE :  target.mk
102
113
(-)cui/util/cui.map (-1 / +3 lines)
Lines 1-7 Link Here
1
UDK_3_0_0 {
1
UDK_3_0_0 {
2
	global:
2
	global:
3
	CreateDialogFactory;
3
	CreateDialogFactory;
4
        GetSpecialCharsForEdit;
4
    GetSpecialCharsForEdit;
5
    component_getImplementationEnvironment;
6
    component_getFactory;
5
	local:
7
	local:
6
		*;
8
		*;
7
};
9
};
(-)tools/source/generic/color.cxx (+47 lines)
Lines 259-264 Link Here
259
259
260
// -----------------------------------------------------------------------
260
// -----------------------------------------------------------------------
261
261
262
// CMYK values from 0 to 1
263
ColorData Color::CMYKtoRGB( double fCyan, double fMagenta, double fYellow, double fKey )
264
{
265
    fCyan = (fCyan * ( 1.0 - fKey )) + fKey;
266
    fMagenta = (fMagenta * ( 1.0 - fKey )) + fKey;
267
    fYellow = (fYellow * ( 1.0 - fKey )) + fKey;
268
269
    sal_uInt8 nRed = static_cast< sal_uInt8 >( std::max( std::min( ( 1.0 - fCyan ) * 255.0, 255.0), 0.0 ) );
270
    sal_uInt8 nGreen = static_cast< sal_uInt8 >( std::max( std::min( ( 1.0 - fMagenta ) * 255.0, 255.0), 0.0 ) );
271
    sal_uInt8 nBlue = static_cast< sal_uInt8 >( std::max( std::min( ( 1.0 - fYellow ) * 255.0, 255.0), 0.0 ) );
272
273
    return RGB_COLORDATA( nRed, nGreen, nBlue );
274
}
275
276
// -----------------------------------------------------------------------
277
278
// RGB values from 0 to 255
279
// CMY results from 0 to 1
280
void Color::RGBtoCMYK( double& fCyan, double& fMagenta, double& fYellow, double& fKey )
281
{
282
    fCyan = 1 - ( GetRed() / 255.0 );
283
    fMagenta = 1 - ( GetGreen() / 255.0 );
284
    fYellow = 1 - ( GetBlue() / 255.0 );
285
286
    //CMYK and CMY values from 0 to 1
287
    fKey = 1.0;
288
    if( fCyan < fKey ) fKey = fCyan;
289
    if( fMagenta < fKey ) fKey = fMagenta;
290
    if( fYellow < fKey ) fKey = fYellow;
291
292
    if ( fKey == 1.0 )
293
    {
294
       //Black
295
       fCyan = 0.0;
296
       fMagenta = 0.0;
297
       fYellow = 0.0;
298
    }
299
    else
300
    {
301
       fCyan = ( fCyan - fKey ) / ( 1.0 - fKey );
302
       fMagenta = ( fMagenta - fKey ) / ( 1.0 - fKey );
303
       fYellow = ( fYellow - fKey ) / ( 1.0 - fKey );
304
    }
305
}
306
307
// -----------------------------------------------------------------------
308
262
SvStream& Color::Read( SvStream& rIStm, sal_Bool bNewFormat )
309
SvStream& Color::Read( SvStream& rIStm, sal_Bool bNewFormat )
263
{
310
{
264
	if ( bNewFormat )
311
	if ( bNewFormat )
(-)tools/inc/tools/color.hxx (-4 / +8 lines)
Lines 174-183 Link Here
174
    static ColorData    HSBtoRGB( sal_uInt16 nHue, sal_uInt16 nSat, sal_uInt16 nBri );
174
    static ColorData    HSBtoRGB( sal_uInt16 nHue, sal_uInt16 nSat, sal_uInt16 nBri );
175
    void                RGBtoHSB( sal_uInt16& nHue, sal_uInt16& nSat, sal_uInt16& nBri ) const;
175
    void                RGBtoHSB( sal_uInt16& nHue, sal_uInt16& nSat, sal_uInt16& nBri ) const;
176
176
177
	sal_Bool				operator==( const Color& rColor ) const
177
    // the range for cymk is 0 to 1.0
178
							{ return (mnColor == rColor.mnColor); }
178
    static ColorData    CMYKtoRGB( double fCyan, double fMagenta, double fYellow, double fKey );
179
	sal_Bool				operator!=( const Color& rColor ) const
179
    void                RGBtoCMYK( double& fCyan, double& fMagenta, double& fYellow, double& fKey );
180
							{ return !(Color::operator==( rColor )); }
180
181
    sal_Bool            operator==( const Color& rColor ) const
182
                        { return (mnColor == rColor.mnColor); }
183
    sal_Bool            operator!=( const Color& rColor ) const
184
                        { return !(Color::operator==( rColor )); }
181
185
182
	SvStream&			Read( SvStream& rIStm, sal_Bool bNewFormat = sal_True );
186
	SvStream&			Read( SvStream& rIStm, sal_Bool bNewFormat = sal_True );
183
	SvStream&			Write( SvStream& rOStm, sal_Bool bNewFormat = sal_True );
187
	SvStream&			Write( SvStream& rOStm, sal_Bool bNewFormat = sal_True );
(-)postprocess/packcomponents/makefile.mk (+1 lines)
Lines 51-56 Link Here
51
    charttools \
51
    charttools \
52
    chartview \
52
    chartview \
53
    component/comphelper/util/comphelp \
53
    component/comphelper/util/comphelp \
54
    component/cui/util/cui \
54
    component/drawinglayer/drawinglayer \
55
    component/drawinglayer/drawinglayer \
55
    component/framework/util/fwk \
56
    component/framework/util/fwk \
56
    component/framework/util/fwl \
57
    component/framework/util/fwl \
(-)svtools/Package_inc.mk (-1 lines)
Lines 38-44 Link Here
38
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/brwhead.hxx,svtools/brwhead.hxx))
38
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/brwhead.hxx,svtools/brwhead.hxx))
39
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/calendar.hxx,svtools/calendar.hxx))
39
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/calendar.hxx,svtools/calendar.hxx))
40
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/cliplistener.hxx,svtools/cliplistener.hxx))
40
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/cliplistener.hxx,svtools/cliplistener.hxx))
41
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/colctrl.hxx,svtools/colctrl.hxx))
42
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/collatorres.hxx,svtools/collatorres.hxx))
41
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/collatorres.hxx,svtools/collatorres.hxx))
43
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/colorcfg.hxx,svtools/colorcfg.hxx))
42
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/colorcfg.hxx,svtools/colorcfg.hxx))
44
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/colrdlg.hxx,svtools/colrdlg.hxx))
43
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/colrdlg.hxx,svtools/colrdlg.hxx))
(-)svtools/AllLangResTarget_svt.mk (-1 lines)
Lines 50-56 Link Here
50
	svtools/source/control/ctrltool.src \
50
	svtools/source/control/ctrltool.src \
51
	svtools/source/control/filectrl.src \
51
	svtools/source/control/filectrl.src \
52
	svtools/source/dialogs/addresstemplate.src \
52
	svtools/source/dialogs/addresstemplate.src \
53
	svtools/source/dialogs/colrdlg.src \
54
	svtools/source/dialogs/filedlg2.src \
53
	svtools/source/dialogs/filedlg2.src \
55
	svtools/source/dialogs/formats.src \
54
	svtools/source/dialogs/formats.src \
56
	svtools/source/dialogs/prnsetup.src \
55
	svtools/source/dialogs/prnsetup.src \
(-)svtools/Library_svt.mk (-1 lines)
Lines 150-156 Link Here
150
	svtools/source/control/valueacc \
150
	svtools/source/control/valueacc \
151
	svtools/source/control/valueset \
151
	svtools/source/control/valueset \
152
	svtools/source/dialogs/addresstemplate \
152
	svtools/source/dialogs/addresstemplate \
153
	svtools/source/dialogs/colctrl \
154
	svtools/source/dialogs/colrdlg \
153
	svtools/source/dialogs/colrdlg \
155
	svtools/source/dialogs/filedlg \
154
	svtools/source/dialogs/filedlg \
156
	svtools/source/dialogs/filedlg2 \
155
	svtools/source/dialogs/filedlg2 \
(-)svtools/source/dialogs/colrdlg.cxx (-267 / +71 lines)
Lines 26-324 Link Here
26
#ifndef GCC
26
#ifndef GCC
27
#endif
27
#endif
28
28
29
#include <svtools/svtdata.hxx>
29
#include <com/sun/star/awt/XWindow.hpp>
30
#include "colrdlg.hrc"
30
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
31
#include <svtools/colrdlg.hxx>
31
#include <com/sun/star/beans/XPropertyAccess.hpp>
32
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
33
#include <comphelper/processfactory.hxx>
34
#include <toolkit/helper/vclunohelper.hxx>
35
#include <svtools/colrdlg.hxx>
32
36
33
// ---------------
37
using rtl::OUString;
34
// - ColorDialog -
38
using namespace ::com::sun::star::uno;
35
// ---------------
39
using namespace ::com::sun::star::lang;
40
using namespace ::com::sun::star::beans;
41
using namespace ::com::sun::star::ui::dialogs;
36
42
37
SvColorDialog::SvColorDialog( Window* pWindow ) :
43
// ---------------
38
		ModalDialog		( pWindow, SvtResId( DLG_COLOR ) ),
44
// - ColorDialog -
39
		maColMixCtrl	( this, SvtResId( VAL_SET_COLOR ), 8, 8 ),
45
// ---------------
40
		maBtn1			( this, SvtResId( BTN_1 ) ),
41
		maBtn2			( this, SvtResId( BTN_2 ) ),
42
		//maBtn3			( this, SvtResId( BTN_3 ) ),
43
		//maBtn4			( this, SvtResId( BTN_4 ) ),
44
		//maFtRGB			( this, SvtResId( FT_RGB ) ),
45
		maCtlColor		( this, SvtResId( CTL_COLOR ) ),
46
46
47
		maFtCyan		( this, SvtResId( FT_CYAN ) ),
47
SvColorDialog::SvColorDialog( Window* pWindow )
48
		maNumCyan       ( this, SvtResId( NUM_CYAN ) ),
48
: mpParent( pWindow )
49
		maFtMagenta     ( this, SvtResId( FT_MAGENTA ) ),
49
, meMode( svtools::ColorPickerMode_SELECT )
50
		maNumMagenta    ( this, SvtResId( NUM_MAGENTA ) ),
51
		maFtYellow      ( this, SvtResId( FT_YELLOW ) ),
52
		maNumYellow     ( this, SvtResId( NUM_YELLOW ) ),
53
		maFtKey         ( this, SvtResId( FT_KEY ) ),
54
		maNumKey        ( this, SvtResId( NUM_KEY ) ),
55
56
		maFtRed	 		( this, SvtResId( FT_RED ) ),
57
		maNumRed		( this, SvtResId( NUM_RED ) ),
58
		maFtGreen		( this, SvtResId( FT_GREEN ) ),
59
		maNumGreen   	( this, SvtResId( NUM_GREEN ) ),
60
		maFtBlue		( this, SvtResId( FT_BLUE ) ),
61
		maNumBlue		( this, SvtResId( NUM_BLUE ) ),
62
63
		maFtHue			( this, SvtResId( FT_HUE ) ),
64
		maNumHue	   	( this, SvtResId( NUM_HUE ) ),
65
		maFtSaturation	( this, SvtResId( FT_SATURATION ) ),
66
		maNumSaturation	( this, SvtResId( NUM_SATURATION ) ),
67
		maFtLuminance	( this, SvtResId( FT_LUMINANCE ) ),
68
		maNumLuminance	( this, SvtResId( NUM_LUMINANCE ) ),
69
70
		maCtlPreview	( this, SvtResId( CTL_PREVIEW ) ),
71
		maCtlPreviewOld ( this, SvtResId( CTL_PREVIEW_OLD ) ),
72
73
		maBtnOK			( this, SvtResId( BTN_OK ) ),
74
		maBtnCancel		( this, SvtResId( BTN_CANCEL ) ),
75
		maBtnHelp		( this, SvtResId( BTN_HELP ) )
76
{
50
{
77
	FreeResource();
78
79
	maColMixCtrl.SetDoubleClickHdl( LINK( this, SvColorDialog, ClickMixCtrlHdl ) );
80
	maColMixCtrl.SetSelectHdl( LINK( this, SvColorDialog, SelectMixCtrlHdl ) );
81
82
	Link aLink( LINK( this, SvColorDialog, ColorModifyHdl ) );
83
	maCtlColor.SetModifyHdl( aLink );
84
85
	maNumRed.SetModifyHdl( aLink );
86
	maNumGreen.SetModifyHdl( aLink );
87
	maNumBlue.SetModifyHdl( aLink );
88
89
	maNumCyan.SetModifyHdl( aLink );
90
	maNumMagenta.SetModifyHdl( aLink );
91
	maNumYellow.SetModifyHdl( aLink );
92
	maNumKey.SetModifyHdl( aLink );
93
94
	maNumHue.SetModifyHdl( aLink );
95
	maNumSaturation.SetModifyHdl( aLink );
96
	maNumLuminance.SetModifyHdl( aLink );
97
98
	aLink = ( LINK( this, SvColorDialog, ClickBtnHdl ) );
99
	maBtn1.SetClickHdl( aLink );
100
	maBtn2.SetClickHdl( aLink );
101
	//maBtn3.SetClickHdl( aLink );
102
	//maBtn4.SetClickHdl( aLink );
103
104
	maColMixCtrl.SetExtraSpacing( 0 );
105
}
51
}
106
52
107
108
// -----------------------------------------------------------------------
53
// -----------------------------------------------------------------------
109
SvColorDialog::~SvColorDialog()
110
{
111
}
112
54
113
// -----------------------------------------------------------------------
114
void SvColorDialog::Initialize()
115
{
116
	maNumRed.SetValue( maColor.GetRed() );
117
	maNumGreen.SetValue( maColor.GetGreen() );
118
	maNumBlue.SetValue( maColor.GetBlue() );
119
120
	ColorCMYK aColorCMYK( maColor );
121
122
	long aCyan    = (long) ( (double)aColorCMYK.GetCyan() * 100.0 / 255.0 + 0.5 );
123
	long aMagenta = (long) ( (double)aColorCMYK.GetMagenta() * 100.0 / 255.0 + 0.5 );
124
	long aYellow  = (long) ( (double)aColorCMYK.GetYellow() * 100.0 / 255.0 + 0.5 );
125
	long aKey     = (long) ( (double)aColorCMYK.GetKey() * 100.0 / 255.0 + 0.5 );
126
	maNumCyan.SetValue( aCyan );
127
	maNumMagenta.SetValue( aMagenta );
128
	maNumYellow.SetValue( aYellow );
129
	maNumKey.SetValue( aKey );
130
131
	ColorHSB aColorHSB( maColor );
132
	maNumHue.SetValue( aColorHSB.GetHue() );
133
	maNumSaturation.SetValue( aColorHSB.GetSat() );
134
	maNumLuminance.SetValue( aColorHSB.GetBri() );
135
136
	maCtlColor.SetColor( aColorHSB );
137
138
	maColMixCtrl.SelectItem( 1 );
139
140
	maCtlPreview.SetColor( maColor );
141
	maCtlPreviewOld.SetColor( maColor );
142
}
143
144
// -----------------------------------------------------------------------
145
void SvColorDialog::SetColor( const Color& rColor )
55
void SvColorDialog::SetColor( const Color& rColor )
146
{
56
{
147
	maColor = rColor;
57
	maColor = rColor;
148
}
58
}
149
59
150
// -----------------------------------------------------------------------
60
// -----------------------------------------------------------------------
61
151
const Color& SvColorDialog::GetColor() const
62
const Color& SvColorDialog::GetColor() const
152
{
63
{
153
	return( maColor );
64
	return maColor;
154
}
65
}
155
66
156
// -----------------------------------------------------------------------
67
// -----------------------------------------------------------------------
157
IMPL_LINK( SvColorDialog, ColorModifyHdl, void *, p )
68
158
{
69
void SvColorDialog::SetMode( sal_Int16 eMode )
159
	sal_uInt16 n = 0x00; // 1 == RGB, 2 == CMYK, 4 == HSB
70
{
160
71
    meMode = eMode;
161
	if( p == &maCtlColor )
162
	{
163
		maColor = maCtlColor.GetColor();
164
		maNumRed.SetValue( maColor.GetRed() );
165
		maNumGreen.SetValue( maColor.GetGreen() );
166
		maNumBlue.SetValue( maColor.GetBlue() );
167
168
		n = 7;
169
	}
170
	else if( p == &maNumRed )
171
	{
172
		maColor.SetRed( (sal_uInt8)maNumRed.GetValue() );
173
		maCtlColor.SetColor( maColor );
174
		n = 6;
175
	}
176
	else if( p == &maNumGreen )
177
	{
178
		maColor.SetGreen( (sal_uInt8)maNumGreen.GetValue() );
179
		maCtlColor.SetColor( maColor );
180
		n = 6;
181
	}
182
	else if( p == &maNumBlue )
183
	{
184
		maColor.SetBlue( (sal_uInt8)maNumBlue.GetValue() );
185
		maCtlColor.SetColor( maColor );
186
		n = 6;
187
	}
188
	else if( p == &maNumHue ||
189
			 p == &maNumSaturation ||
190
			 p == &maNumLuminance )
191
	{
192
193
		ColorHSB aColorHSB( (sal_uInt16) maNumHue.GetValue(),
194
							(sal_uInt16) maNumSaturation.GetValue(),
195
							(sal_uInt16) maNumLuminance.GetValue() );
196
		maCtlColor.SetColor( aColorHSB );
197
		maColor = maCtlColor.GetColor();
198
		n = 3;
199
	}
200
	else if( p == &maNumCyan ||
201
			 p == &maNumMagenta ||
202
			 p == &maNumYellow ||
203
			 p == &maNumKey )
204
	{
205
		long aCyan    = (long) ( (double)maNumCyan.GetValue() * 255.0 / 100.0 + 0.5 );
206
		long aMagenta = (long) ( (double)maNumMagenta.GetValue() * 255.0 / 100.0 + 0.5 );
207
		long aYellow  = (long) ( (double)maNumYellow.GetValue() * 255.0 / 100.0 + 0.5 );
208
		long aKey     = (long) ( (double)maNumKey.GetValue() * 255.0 / 100.0 + 0.5 );
209
210
		ColorCMYK aColorCMYK( (sal_uInt16) aCyan,
211
							  (sal_uInt16) aMagenta,
212
							  (sal_uInt16) aYellow,
213
							  (sal_uInt16) aKey );
214
		maColor = aColorCMYK.GetRGB();
215
		maCtlColor.SetColor( maColor );
216
		n = 5;
217
	}
218
219
	if( n & 1 ) // RGB setzen
220
	{
221
		maNumRed.SetValue( maColor.GetRed() );
222
		maNumGreen.SetValue( maColor.GetGreen() );
223
		maNumBlue.SetValue( maColor.GetBlue() );
224
	}
225
	if( n & 2 ) // CMYK setzen
226
	{
227
		ColorCMYK aColorCMYK( maColor );
228
		long aCyan    = (long) ( (double)aColorCMYK.GetCyan() * 100.0 / 255.0 + 0.5 );
229
		long aMagenta = (long) ( (double)aColorCMYK.GetMagenta() * 100.0 / 255.0 + 0.5 );
230
		long aYellow  = (long) ( (double)aColorCMYK.GetYellow() * 100.0 / 255.0 + 0.5 );
231
		long aKey     = (long) ( (double)aColorCMYK.GetKey() * 100.0 / 255.0 + 0.5 );
232
		maNumCyan.SetValue( aCyan );
233
		maNumMagenta.SetValue( aMagenta );
234
		maNumYellow.SetValue( aYellow );
235
		maNumKey.SetValue( aKey );
236
	}
237
	if( n & 4 ) // HSB setzen
238
	{
239
		ColorHSB aColorHSB( maColor );
240
		maNumHue.SetValue( aColorHSB.GetHue() );
241
		maNumSaturation.SetValue( aColorHSB.GetSat() );
242
		maNumLuminance.SetValue( aColorHSB.GetBri() );
243
	}
244
245
	maCtlPreview.SetColor( maColor );
246
247
	return 0;
248
}
72
}
249
73
250
// -----------------------------------------------------------------------
74
// -----------------------------------------------------------------------
251
IMPL_LINK( SvColorDialog, ClickBtnHdl, void *, p )
75
252
{
76
short SvColorDialog::Execute()
253
	/*
77
{
254
	Color aColor = maCtlColor.GetColor();
78
    short ret = 0;
255
	if( p == &maBtn1 )
79
    try
256
		maColMixCtrl.SetColor( CMC_TOPLEFT, aColor );
257
	if( p == &maBtn2 )
258
		maColMixCtrl.SetColor( CMC_TOPRIGHT, aColor );
259
	if( p == &maBtn3 )
260
		maColMixCtrl.SetColor( CMC_BOTTOMLEFT, aColor );
261
	if( p == &maBtn4 )
262
		maColMixCtrl.SetColor( CMC_BOTTOMRIGHT, aColor );
263
	*/
264
265
	if( p == &maBtn1 )
266
	{
80
	{
267
		CMCPosition ePos = maColMixCtrl.GetCMCPosition();
81
        const OUString sColor( RTL_CONSTASCII_USTRINGPARAM( "Color" ) );
268
		if( ePos != CMC_OTHER )
82
        Reference< XMultiServiceFactory > xSMGR( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
269
			maColMixCtrl.SetColor( ePos, maColor );
83
84
        Reference< com::sun::star::awt::XWindow > xParent( VCLUnoHelper::GetInterface( mpParent ) );
85
86
        Sequence< Any > args(1);
87
        args[0] = Any( xParent );
88
89
        Reference< XExecutableDialog > xDialog( xSMGR->createInstanceWithArguments(::rtl::OUString::createFromAscii("com.sun.star.cui.ColorPicker"), args), UNO_QUERY_THROW );
90
        Reference< XPropertyAccess > xPropertyAccess( xDialog, UNO_QUERY_THROW );
91
92
        Sequence< PropertyValue > props( 2 );
93
        props[0].Name = sColor;
94
        props[0].Value <<= (sal_Int32) maColor.GetColor();
95
        props[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Mode" ) );
96
        props[1].Value <<= (sal_Int16) meMode;
97
98
        xPropertyAccess->setPropertyValues( props );
99
100
        ret = xDialog->execute();
101
102
        if( ret )
103
        {
104
            props = xPropertyAccess->getPropertyValues();
105
            for( sal_Int32 n = 0; n < props.getLength(); n++ )
106
            {
107
                if( props[n].Name.equals( sColor ) )
108
                {
109
                    sal_Int32 nColor = 0;
110
                    if( props[n].Value >>= nColor )
111
                    {
112
                        maColor.SetColor( nColor );
113
                    }
114
115
                }
116
            }
117
        }
270
	}
118
	}
271
	else if( p == &maBtn2 )
119
    catch(Exception&)
272
	{
120
	{
273
		sal_uInt16 nPos = maColMixCtrl.GetSelectItemId();
121
        OSL_ASSERT(false);
274
		maColor = maColMixCtrl.GetItemColor( nPos );
275
		maCtlColor.SetColor( maColor );
276
		ColorModifyHdl( &maCtlColor );
277
	}
122
	}
278
123
279
	return 0;
124
    return ret;
280
}
125
}
281
126
282
// -----------------------------------------------------------------------
127
// -----------------------------------------------------------------------
283
IMPL_LINK( SvColorDialog, ClickMixCtrlHdl, void *, EMPTYARG )
128
// eof
284
{
285
	sal_uInt16 nPos = maColMixCtrl.GetSelectItemId();
286
	CMCPosition ePos = maColMixCtrl.GetCMCPosition();
287
288
	if( ePos != CMC_OTHER )
289
		maColMixCtrl.SetColor( ePos, maColor );
290
	else
291
	{
292
		maColor = maColMixCtrl.GetItemColor( nPos );
293
		maCtlColor.SetColor( maColor );
294
		ColorModifyHdl( &maCtlColor );
295
	}
296
297
	return 0;
298
}
299
300
// -----------------------------------------------------------------------
301
IMPL_LINK( SvColorDialog, SelectMixCtrlHdl, void *, EMPTYARG )
302
{
303
	//sal_uInt16 nPos = maColMixCtrl.GetSelectItemId();
304
	//maFtRGB.SetText( maColMixCtrl.GetItemText( nPos ) );
305
306
	CMCPosition ePos = maColMixCtrl.GetCMCPosition();
307
	if( ePos == CMC_OTHER )
308
		maBtn1.Enable( sal_False );
309
	else
310
		maBtn1.Enable();
311
312
	return 0;
313
}
314
315
// -----------------------------------------------------------------------
316
short SvColorDialog::Execute()
317
{
318
	Initialize();
319
320
	short nRet = ModalDialog::Execute();
321
322
	return( nRet );
323
}
324
(-)svtools/source/dialogs/colrdlg.hrc (-65 lines)
Lines 1-65 Link Here
1
/**************************************************************
2
 * 
3
 * Licensed to the Apache Software Foundation (ASF) under one
4
 * or more contributor license agreements.  See the NOTICE file
5
 * distributed with this work for additional information
6
 * regarding copyright ownership.  The ASF licenses this file
7
 * to you under the Apache License, Version 2.0 (the
8
 * "License"); you may not use this file except in compliance
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
15
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
 * KIND, either express or implied.  See the License for the
17
 * specific language governing permissions and limitations
18
 * under the License.
19
 * 
20
 *************************************************************/
21
22
23
#define DLG_COLOR 996
24
25
#define VAL_SET_COLOR 2
26
#define BTN_1 1
27
#define BTN_2 2
28
#define BTN_3 3
29
#define BTN_4 4
30
#define FT_RGB 12
31
32
#define CTL_COLOR 1
33
34
#define FT_RED 1
35
#define NUM_RED 1
36
#define FT_GREEN 2
37
#define NUM_GREEN 2
38
#define FT_BLUE 3
39
#define NUM_BLUE 3
40
41
#define FT_CYAN 7
42
#define NUM_CYAN 7
43
#define FT_MAGENTA 8
44
#define NUM_MAGENTA 8
45
#define FT_YELLOW 9
46
#define NUM_YELLOW 9
47
#define FT_KEY 10
48
#define NUM_KEY 10
49
50
#define FT_HUE 4
51
#define NUM_HUE 4
52
#define FT_SATURATION 5
53
#define NUM_SATURATION 5
54
#define FT_LUMINANCE 6
55
#define NUM_LUMINANCE 6
56
57
#define CTL_PREVIEW 3
58
#define CTL_PREVIEW_OLD 4
59
60
#define BTN_OK 1
61
#define BTN_CANCEL 1
62
#define BTN_HELP 1
63
64
//IAccessibility2 Implementation 2009-----
65
#define STR_COLORDES 3001
(-)svtools/source/dialogs/colctrl.cxx (-686 lines)
Lines 1-686 Link Here
1
/**************************************************************
2
 * 
3
 * Licensed to the Apache Software Foundation (ASF) under one
4
 * or more contributor license agreements.  See the NOTICE file
5
 * distributed with this work for additional information
6
 * regarding copyright ownership.  The ASF licenses this file
7
 * to you under the Apache License, Version 2.0 (the
8
 * "License"); you may not use this file except in compliance
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
15
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
 * KIND, either express or implied.  See the License for the
17
 * specific language governing permissions and limitations
18
 * under the License.
19
 * 
20
 *************************************************************/
21
22
23
24
// MARKER(update_precomp.py): autogen include statement, do not remove
25
#include "precompiled_svtools.hxx"
26
27
28
#include <vcl/salbtype.hxx>
29
#include <vcl/bmpacc.hxx>
30
31
#include <svtools/colctrl.hxx>
32
33
// ----------------
34
// - ColorControl -
35
// ----------------
36
37
SvColorControl::SvColorControl( Window* pParent, WinBits nStyle ) :
38
	Control			( pParent, nStyle ),
39
	mpBitmap		( NULL ),
40
	mpReadAccess	( NULL ),
41
	mnLuminance		( 50 )
42
{
43
	Initialize();
44
}
45
46
// -----------------------------------------------------------------------
47
SvColorControl::SvColorControl( Window* pParent, const ResId& rResId ) :
48
	Control			( pParent, rResId ),
49
	mpBitmap		( NULL ),
50
	mpReadAccess	( NULL ),
51
	mnLuminance		( 50 )
52
{
53
	Initialize();
54
}
55
56
57
// -----------------------------------------------------------------------
58
SvColorControl::~SvColorControl()
59
{
60
	delete mpBitmap;
61
}
62
63
// -----------------------------------------------------------------------
64
void SvColorControl::Initialize()
65
{
66
	SetLineColor( Color( COL_BLACK ) );
67
}
68
69
// -----------------------------------------------------------------------
70
void SvColorControl::CreateBitmap()
71
{
72
	const Size aSize( GetOutputSizePixel() );
73
	
74
    if( mpBitmap && mpBitmap->GetSizePixel() != aSize )
75
		delete mpBitmap, mpBitmap = NULL;
76
77
	if( !mpBitmap )
78
		mpBitmap = new Bitmap( aSize, 24 );
79
80
	BitmapWriteAccess* pWriteAccess = mpBitmap->AcquireWriteAccess();
81
82
    if( pWriteAccess )
83
    {
84
	    sal_uInt16 nX = (sal_uInt16) aSize.Width();
85
	    sal_uInt16 nY = (sal_uInt16) aSize.Height();
86
87
	    sal_uInt16      nHue, nSat;
88
	    ColorHSB    aColHSB( 0, 0, mnLuminance );
89
90
	    for( sal_uInt16 i = 0; i < nY; i++ )
91
	    {
92
		    nSat = (sal_uInt16) FRound( 100 - ( 100.0 * i + 0.5 ) / nY );
93
94
		    for( sal_uInt16 j = 0; j < nX; j++ )
95
		    {
96
			    nHue = (sal_uInt16) FRound( ( 360.0 * j + 0.5 ) / nX );
97
98
			    aColHSB.SetHue( nHue );
99
			    aColHSB.SetSat( nSat );
100
         
101
                // mpBitmap always has a bit count of 24 => use of SetPixel(...) is safe
102
                pWriteAccess->SetPixel( i, j, BitmapColor( aColHSB.GetRGB() ) );
103
		    }
104
	    }
105
106
	    mpBitmap->ReleaseAccess( pWriteAccess );
107
    }
108
109
   	SetColor( maColor );
110
}
111
112
// -----------------------------------------------------------------------
113
void SvColorControl::ShowPosition( const Point& rPos )
114
{
115
	// Explizites Abfragen des Bereichs, da schon mal ein Wert < 0 vorhanden ist
116
	if( mpBitmap )
117
	{
118
		long nX = rPos.X();
119
		long nY = rPos.Y();
120
		if( nX < 0L )
121
			nX = 0L;
122
		else if( nX >= mpBitmap->GetSizePixel().Width() )
123
			nX = mpBitmap->GetSizePixel().Width() - 1L;
124
125
		if( nY < 0L )
126
			nY= 0L;
127
		else if( nY >= mpBitmap->GetSizePixel().Height() )
128
			nY = mpBitmap->GetSizePixel().Height() - 1L;
129
130
		Point aPos = maPosition;
131
		maPosition.X() = nX - 2;
132
		maPosition.Y() = nY - 2;
133
		Invalidate( Rectangle( aPos, Size( 5, 5) ) );
134
		Invalidate( Rectangle( maPosition, Size( 5, 5) ) );
135
136
        if( ( mpReadAccess = mpBitmap->AcquireReadAccess() ) != NULL )
137
        {
138
            // mpBitmap always has a bit count of 24 => use of GetPixel(...) is safe
139
            maColor = mpReadAccess->GetPixel( nY, nX );
140
            mpBitmap->ReleaseAccess( mpReadAccess );
141
            mpReadAccess = NULL;
142
        }
143
	}
144
}
145
// -----------------------------------------------------------------------
146
void SvColorControl::MouseMove( const MouseEvent& rMEvt )
147
{
148
	if( rMEvt.IsLeft() )
149
	{
150
		ShowPosition( rMEvt.GetPosPixel() );
151
		Modify();
152
	}
153
}
154
155
// -----------------------------------------------------------------------
156
void SvColorControl::MouseButtonDown( const MouseEvent& rMEvt )
157
{
158
	if( rMEvt.IsLeft() && !rMEvt.IsShift() )
159
	{
160
		//ShowPointer( sal_False );
161
		CaptureMouse();
162
		ShowPosition( rMEvt.GetPosPixel() );
163
		Modify();
164
	}
165
}
166
167
// -----------------------------------------------------------------------
168
void SvColorControl::MouseButtonUp( const MouseEvent& )
169
{
170
	//ShowPointer( sal_True );
171
	if( IsMouseCaptured() )
172
		ReleaseMouse();
173
}
174
175
// -----------------------------------------------------------------------
176
void SvColorControl::Paint( const Rectangle& rRect )
177
{
178
	if( !mpBitmap )
179
		CreateBitmap();
180
181
    Bitmap aOutputBitmap( *mpBitmap );
182
183
	if( GetBitCount() <= 8 )
184
		aOutputBitmap.Dither();
185
186
	DrawBitmap( rRect.TopLeft(), rRect.GetSize(), rRect.TopLeft(), rRect.GetSize(), aOutputBitmap );
187
188
	// Positions-Control (Fadenkreuz oder Aehnliches)
189
	Point aPos1( maPosition );
190
	Point aPos2( maPosition );
191
	aPos2.X() += 4;
192
	DrawLine( aPos1, aPos2 );
193
	aPos2.X() -= 4;
194
	aPos2.Y() += 4;
195
	DrawLine( aPos1, aPos2 );
196
	aPos1.Y() += 4;
197
	aPos2.X() += 4;
198
	DrawLine( aPos1, aPos2 );
199
	aPos1.X() += 4;
200
	aPos2.Y() -= 4;
201
	DrawLine( aPos1, aPos2 );
202
}
203
204
// -----------------------------------------------------------------------
205
void SvColorControl::Resize()
206
{
207
    CreateBitmap();
208
    Control::Resize();
209
}
210
211
// -----------------------------------------------------------------------
212
void SvColorControl::Modify()
213
{
214
	maModifyHdl.Call( this );
215
}
216
217
// -----------------------------------------------------------------------
218
void SvColorControl::SetColor( const ColorHSB& rCol, sal_Bool bSetColor )
219
{
220
	if( bSetColor )
221
		maColor = rCol.GetRGB();
222
223
	if( mpBitmap )
224
	{
225
		sal_uInt16  nX = (sal_uInt16) mpBitmap->GetSizePixel().Width();
226
		sal_uInt16  nY = (sal_uInt16) mpBitmap->GetSizePixel().Height();
227
		sal_Int16   nZ = rCol.GetBri();
228
		
229
        SetLuminance( nZ );
230
		nX = rCol.GetHue() * nX / 360; // Farbe
231
		nY = nY - rCol.GetSat() * nY / 100; // Saettigung
232
		ShowPosition( Point( nX, nY ) );
233
	}
234
}
235
236
// -----------------------------------------------------------------------
237
void SvColorControl::SetColor( const Color& rCol )
238
{
239
	maColor = rCol;
240
241
	if( mpBitmap )
242
	{
243
		ColorHSB aColHsb( rCol );
244
		SetColor( aColHsb, sal_False );
245
	}
246
}
247
248
// -----------------------------------------------------------------------
249
void SvColorControl::SetLuminance( short nLum )
250
{
251
	if( nLum != mnLuminance && nLum >= 0 && nLum <= 100 )
252
	{
253
		mnLuminance = nLum;
254
255
		if( mnLuminance < 40 )
256
			SetLineColor( Color( COL_WHITE ) );
257
		else
258
			SetLineColor( Color( COL_BLACK ) );
259
260
		CreateBitmap();
261
262
		long nX = maPosition.X() + 2;
263
		long nY = maPosition.Y() + 2;
264
265
        if( mpBitmap && ( ( mpReadAccess = mpBitmap->AcquireReadAccess() ) != NULL ) )
266
        {
267
    		// mpBitmap always has a bit count of 24 => use of GetPixel(...) is safe
268
            maColor = mpReadAccess->GetPixel( nY, nX );
269
            mpBitmap->ReleaseAccess( mpReadAccess );
270
            mpReadAccess = NULL;
271
        }
272
273
		Invalidate();
274
	}
275
}
276
277
278
// -----------------------
279
// - ColorPreviewControl -
280
// -----------------------
281
282
283
// -----------------------------------------------------------------------
284
ColorPreviewControl::ColorPreviewControl( Window* pParent, WinBits nStyle ) :
285
	Control		( pParent, nStyle )
286
{
287
	SetFillColor( maColor );
288
	SetLineColor( maColor );
289
}
290
291
// -----------------------------------------------------------------------
292
ColorPreviewControl::ColorPreviewControl( Window* pParent, const ResId& rResId ) :
293
	Control		( pParent, rResId )
294
{
295
	SetFillColor( maColor );
296
	SetLineColor( maColor );
297
}
298
299
300
// -----------------------------------------------------------------------
301
ColorPreviewControl::~ColorPreviewControl()
302
{
303
}
304
305
// -----------------------------------------------------------------------
306
void ColorPreviewControl::Paint( const Rectangle& rRect )
307
{
308
	DrawRect( rRect );
309
}
310
311
// -----------------------------------------------------------------------
312
void ColorPreviewControl::SetColor( const Color& rCol )
313
{
314
	if( rCol != maColor )
315
	{
316
		maColor = rCol;
317
		SetFillColor( maColor );
318
		SetLineColor( maColor );
319
		Invalidate();
320
	}
321
}
322
323
324
// -----------------------
325
// - ColorMixingControl -
326
// -----------------------
327
328
329
// -----------------------------------------------------------------------
330
ColorMixingControl::ColorMixingControl( Window* pParent, WinBits nStyle,
331
										sal_uInt16 nRows, sal_uInt16 nColumns ) :
332
	ValueSet	( pParent, nStyle ),
333
	mnRows		( nRows ),
334
	mnColumns	( nColumns )
335
{
336
	Initialize();
337
}
338
339
// -----------------------------------------------------------------------
340
ColorMixingControl::ColorMixingControl( Window* pParent, const ResId& rResId,
341
										sal_uInt16 nRows, sal_uInt16 nColumns ) :
342
	ValueSet	( pParent, rResId ),
343
	mnRows		( nRows ),
344
	mnColumns	( nColumns )
345
{
346
	Initialize();
347
}
348
349
350
// -----------------------------------------------------------------------
351
ColorMixingControl::~ColorMixingControl()
352
{
353
}
354
355
// -----------------------------------------------------------------------
356
void ColorMixingControl::Initialize()
357
{
358
	SetColCount( mnColumns );
359
360
	Color aColor;
361
	String aStr;
362
	for( sal_uInt16 i = 1; i <= mnRows * mnColumns; i++ )
363
	{
364
		InsertItem( i, aColor, aStr );
365
	}
366
367
	/*maColor[ 0 ] = Color( COL_LIGHTRED );
368
	maColor[ 1 ] = Color( COL_LIGHTGREEN );
369
	maColor[ 2 ] = Color( COL_YELLOW );
370
	maColor[ 3 ] = Color( COL_LIGHTBLUE );*/
371
372
	SetColor( CMC_TOPLEFT, Color( COL_LIGHTRED ) );
373
	SetColor( CMC_BOTTOMRIGHT, Color( COL_LIGHTBLUE ) );
374
375
	SetColor( CMC_TOPRIGHT, Color( COL_LIGHTGREEN ) );
376
	SetColor( CMC_BOTTOMLEFT, Color( COL_YELLOW ) );
377
378
	/*FillColumn( 0 );
379
	FillColumn( mnColumns - 1 );
380
	for( i = 0; i < mnRows; i++ )
381
		FillRow( i );*/
382
}
383
384
// -----------------------------------------------------------------------
385
Color ColorMixingControl::CalcDifferenceColor( sal_uInt16 nCol1, sal_uInt16 nCol2,
386
												sal_uInt16 nSteps )
387
{
388
	// Die Berechnung ist noch etwas ungenau, daher sollte besser mit floats
389
	// gearbeitet werden...  (muss !!!)
390
	Color aColor( GetItemColor( nCol1 ) );
391
	Color aColor2( GetItemColor( nCol2 ) );
392
393
	aColor.SetRed( (sal_uInt8) ( ( aColor2.GetRed() - aColor.GetRed() ) / nSteps ) );
394
	aColor.SetGreen( (sal_uInt8) ( ( aColor2.GetGreen() - aColor.GetGreen() ) / nSteps ) );
395
	aColor.SetBlue( (sal_uInt8) ( ( aColor2.GetBlue() - aColor.GetBlue() ) / nSteps ) );
396
397
	return( aColor );
398
}
399
400
// -----------------------------------------------------------------------
401
void ColorMixingControl::FillRow( sal_uInt16 nRow )
402
{
403
	sal_uInt16 nCol1 = nRow * mnColumns + 1;
404
	sal_uInt16 nCol2 = ( nRow + 1 ) * mnColumns;
405
	Color aColor( GetItemColor( nCol1 ) );
406
	Color aDiffColor( CalcDifferenceColor( nCol1, nCol2, mnColumns - 1 ) );
407
408
	for( sal_uInt16 i = nCol1 + 1; i < nCol2; i++ )
409
	{
410
		aColor.SetRed( aColor.GetRed() + aDiffColor.GetRed() );
411
		aColor.SetGreen( aColor.GetGreen() + aDiffColor.GetGreen() );
412
		aColor.SetBlue( aColor.GetBlue() + aDiffColor.GetBlue() );
413
414
		SetItemColor( i, aColor );
415
		SetItemText( i, GetRGBString( aColor ) );
416
	}
417
}
418
419
// -----------------------------------------------------------------------
420
void ColorMixingControl::FillColumn( sal_uInt16 nColumn )
421
{
422
	sal_uInt16 nCol1 = nColumn + 1;
423
	sal_uInt16 nCol2 = nColumn + ( mnRows - 1 ) * mnColumns + 1;
424
	Color aColor( GetItemColor( nCol1 ) );
425
	Color aDiffColor( CalcDifferenceColor( nCol1, nCol2, mnRows - 1 ) );
426
427
	for( sal_uInt16 i = nCol1 + mnColumns; i < nCol2; i = i + mnColumns )
428
	{
429
		aColor.SetRed( aColor.GetRed() + aDiffColor.GetRed() );
430
		aColor.SetGreen( aColor.GetGreen() + aDiffColor.GetGreen() );
431
		aColor.SetBlue( aColor.GetBlue() + aDiffColor.GetBlue() );
432
433
		SetItemColor( i, aColor );
434
		SetItemText( i, GetRGBString( aColor ) );
435
	}
436
}
437
438
// -----------------------------------------------------------------------
439
void ColorMixingControl::SetRows( sal_uInt16 nRows )
440
{
441
	mnRows = nRows;
442
}
443
444
// -----------------------------------------------------------------------
445
void ColorMixingControl::SetColumns( sal_uInt16 nColumns )
446
{
447
	mnColumns = nColumns;
448
}
449
450
// -----------------------------------------------------------------------
451
void ColorMixingControl::SetColor( CMCPosition ePos, const Color& rCol )
452
{
453
	if( rCol != maColor[ ePos ] )
454
	{
455
		maColor[ ePos ] = rCol;
456
		sal_uInt16 nPos = 0;
457
		sal_uInt16 nColumn = 0;
458
		String aStr( GetRGBString( rCol ) );
459
460
		switch( ePos )
461
		{
462
			case CMC_TOPLEFT:
463
				nPos = 1;
464
				nColumn = 0;
465
			break;
466
467
			case CMC_TOPRIGHT:
468
				nPos = mnColumns;
469
				nColumn = mnColumns - 1;
470
			break;
471
472
			case CMC_BOTTOMLEFT:
473
				nPos = ( mnRows - 1 ) * mnColumns + 1;
474
				nColumn = 0;
475
			break;
476
477
			case CMC_BOTTOMRIGHT:
478
				nPos = mnRows * mnColumns;
479
				nColumn = mnColumns - 1;
480
			break;
481
			case CMC_OTHER:
482
			break;  // -Wall not handled.
483
		}
484
		SetItemColor( nPos, rCol );
485
		SetItemText( nPos, aStr );
486
		FillColumn( nColumn );
487
488
		for( sal_uInt16 i = 0; i < mnRows; i++ )
489
			FillRow( i );
490
	}
491
}
492
493
// -----------------------------------------------------------------------
494
String ColorMixingControl::GetRGBString( const Color& rColor )
495
{
496
	String 	aStr( String::CreateFromInt32(rColor.GetRed()) );
497
			aStr += ' ';
498
			aStr += String::CreateFromInt32(rColor.GetGreen());
499
			aStr += ' ';
500
			aStr += String::CreateFromInt32(rColor.GetBlue());
501
502
	return aStr;
503
}
504
// -----------------------------------------------------------------------
505
CMCPosition	ColorMixingControl::GetCMCPosition() const
506
{
507
	CMCPosition ePos = CMC_OTHER;
508
	sal_uInt16 nPos = GetSelectItemId();
509
510
	if( nPos == 1 )
511
		ePos = CMC_TOPLEFT;
512
	else if( nPos == mnColumns )
513
		ePos = CMC_TOPRIGHT;
514
	else if( nPos == ( mnRows - 1 ) * mnColumns + 1 )
515
		ePos = CMC_BOTTOMLEFT;
516
	else if( nPos == mnRows * mnColumns )
517
		ePos = CMC_BOTTOMRIGHT;
518
519
	return( ePos );
520
}
521
522
523
// ------------
524
// - ColorHSB -
525
// ------------
526
527
// Erste Ansaetze gingen auf die Berechnung von Sven Hannover zurueck
528
// Der jetzige Algorithmus stammt im weitesten Sinne aus dem Foley/VanDam
529
530
531
/**************************************************************************
532
|*
533
|*    ColorHSB::ColorHSB()
534
|*
535
|*    Beschreibung       RGB nach HSB
536
|*    Ersterstellung     SOH 02.10.97
537
|*
538
**************************************************************************/
539
540
ColorHSB::ColorHSB( const Color& rColor )
541
{
542
	sal_uInt8 c[3];
543
	sal_uInt8 cMax, cMin;
544
545
	c[0] = rColor.GetRed();
546
	c[1] = rColor.GetGreen();
547
	c[2] = rColor.GetBlue();
548
549
	cMax = c[0];
550
	if( c[1] > cMax )
551
		cMax = c[1];
552
	if( c[2] > cMax )
553
		cMax = c[2];
554
555
	// Brightness = max(R, G, B);
556
	mnBri = cMax * 100 / 255;
557
558
	cMin = c[0];
559
	if( c[1] < cMin )
560
		cMin = c[1];
561
	if( c[2] < cMin )
562
		cMin = c[2];
563
564
	sal_uInt8 cDelta = cMax - cMin;
565
566
	// Saturation = max - min / max
567
	if( mnBri > 0 )
568
		mnSat = cDelta * 100 / cMax;
569
	else
570
		mnSat = 0;
571
572
	if( mnSat == 0 )
573
		mnHue = 0; // Default = undefined
574
	else
575
	{
576
		double dHue = 0;
577
578
		if( c[0] == cMax )
579
		{
580
			dHue = (double)( c[1] - c[2] ) / (double)cDelta;
581
		}
582
		else if( c[1] == cMax )
583
		{
584
			dHue = 2.0 + (double)( c[2] - c[0] ) / (double)cDelta;
585
		}
586
		else if ( c[2] == cMax )
587
		{
588
			dHue = 4.0 + (double)( c[0] - c[1] ) / (double)cDelta;
589
		}
590
		// else dHue = ???   -Wall   FIXME
591
		dHue *= 60.0;
592
593
		if( dHue < 0.0 )
594
			dHue += 360.0;
595
596
		mnHue = (sal_uInt16) dHue;
597
	}
598
}
599
600
/**************************************************************************
601
|*
602
|*    ColorHSB::GetRGB()
603
|*
604
|*    Beschreibung       HSB nach RGB
605
|*    Ersterstellung     SOH 02.10.97
606
|*
607
**************************************************************************/
608
609
Color ColorHSB::GetRGB() const
610
{
611
	sal_uInt8 cR,cG,cB;
612
	sal_uInt8 nB = (sal_uInt8) ( mnBri * 255 / 100 );
613
614
	if( mnSat == 0 )
615
	{
616
		cR = nB;
617
		cG = nB;
618
		cB = nB;
619
	}
620
	else
621
	{
622
		double dH = mnHue;
623
		double f;
624
		sal_uInt16 n;
625
		if( dH == 360.0 )
626
			dH = 0.0;
627
628
		dH /= 60.0;
629
		n = (sal_uInt16) dH;
630
		f = dH - n;
631
632
        // #107375# Doing the calculation completely in floating
633
        // point, the former optimization gave sometimes negative
634
        // results for c and was pointless anyway
635
		sal_uInt8 a = static_cast<sal_uInt8>( nB * ( 100.0 - mnSat ) / 100.0 );
636
		sal_uInt8 b = static_cast<sal_uInt8>( nB * ( 100.0 - mnSat * f ) / 100.0 );
637
		sal_uInt8 c = static_cast<sal_uInt8>( nB * ( 100.0 - mnSat * ( 1.0 - f ) ) / 100.0 );
638
639
		switch( n )
640
		{
641
			case 0: cR = nB;	cG = c;		cB = a; 	break;
642
			case 1: cR = b;		cG = nB;	cB = a; 	break;
643
			case 2: cR = a;		cG = nB;	cB = c;		break;
644
			case 3: cR = a;		cG = b; 	cB = nB;	break;
645
			case 4: cR = c;		cG = a; 	cB = nB;	break;
646
			case 5: cR = nB; 	cG = a;		cB = b;		break;
647
			default: cR = 0; 	cG = 0;		cB = 0;		break;  // -Wall ????
648
		}
649
	}
650
651
	return( Color( cR, cG, cB ) );
652
}
653
654
// ------------
655
// - ColorCMYK -
656
// ------------
657
658
659
// -----------------------------------------------------------------------
660
ColorCMYK::ColorCMYK( const Color& rColor )
661
{
662
	mnCyan    = 255 - rColor.GetRed();
663
	mnMagenta = 255 - rColor.GetGreen();
664
	mnYellow  = 255 - rColor.GetBlue();
665
666
	mnKey = Min( Min( mnCyan, mnMagenta ), mnYellow );
667
668
	mnCyan    = mnCyan - mnKey;
669
	mnMagenta = mnMagenta - mnKey;
670
	mnYellow  = mnYellow - mnKey;
671
}
672
673
// -----------------------------------------------------------------------
674
Color ColorCMYK::GetRGB() const
675
{
676
	int nTmp = Max( 0, 255 - ( mnCyan + mnKey ) );
677
	sal_uInt8 cR = (sal_uInt8) nTmp;
678
		  nTmp = Max( 0, 255 - ( mnMagenta + mnKey ) );
679
	sal_uInt8 cG = (sal_uInt8) nTmp;
680
		  nTmp = Max( 0, 255 - ( mnYellow + mnKey ) );
681
	sal_uInt8 cB = (sal_uInt8) nTmp;
682
683
	return( Color( cR, cG, cB ) );
684
}
685
686
(-)svtools/source/dialogs/colrdlg.src (-291 lines)
Lines 1-291 Link Here
1
/**************************************************************
2
 * 
3
 * Licensed to the Apache Software Foundation (ASF) under one
4
 * or more contributor license agreements.  See the NOTICE file
5
 * distributed with this work for additional information
6
 * regarding copyright ownership.  The ASF licenses this file
7
 * to you under the Apache License, Version 2.0 (the
8
 * "License"); you may not use this file except in compliance
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
15
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
 * KIND, either express or implied.  See the License for the
17
 * specific language governing permissions and limitations
18
 * under the License.
19
 * 
20
 *************************************************************/
21
22
23
24
#include "colrdlg.hrc"
25
#define DIFF 3
26
ModalDialog DLG_COLOR
27
{
28
    HelpID = "svtools:ModalDialog:DLG_COLOR";
29
	OutputSize = TRUE ;
30
	SVLook = TRUE ;
31
	Size = MAP_APPFONT ( 260 , 165 + DIFF ) ;
32
	Moveable = TRUE ;
33
	Text [ en-US ] = "Color" ;
34
	OKButton BTN_OK
35
	{
36
		Pos = MAP_APPFONT ( 205 , 6 ) ;
37
		Size = MAP_APPFONT ( 50 , 14 ) ;
38
		TabStop = TRUE ;
39
		DefButton = TRUE ;
40
	};
41
	CancelButton BTN_CANCEL
42
	{
43
		Pos = MAP_APPFONT ( 205 , 23 ) ;
44
		Size = MAP_APPFONT ( 50 , 14 ) ;
45
		TabStop = TRUE ;
46
	};
47
	HelpButton BTN_HELP
48
	{
49
		Pos = MAP_APPFONT ( 205 , 43 ) ;
50
		Size = MAP_APPFONT ( 50 , 14 ) ;
51
		TabStop = TRUE ;
52
	};
53
    Control VAL_SET_COLOR
54
	{
55
		Border = TRUE ;
56
		Pos = MAP_APPFONT ( 6 , 6 ) ;
57
		Size = MAP_APPFONT ( 91 , 100 ) ;
58
		TabStop = TRUE ;
59
	};
60
    Control CTL_COLOR
61
	{
62
		Border = TRUE ;
63
		Pos = MAP_APPFONT ( 100 , 6 ) ;
64
		Size = MAP_APPFONT ( 100 , 100 ) ;
65
		TabStop = TRUE ;
66
	};
67
    FixedText FT_CYAN
68
	{
69
		Pos = MAP_APPFONT ( 6 , 110 + DIFF ) ;
70
        Size = MAP_APPFONT ( 34 , 10 ) ;
71
		Text [ en-US ] = "~Cyan" ;
72
	};
73
	FixedText FT_MAGENTA
74
	{
75
		Pos = MAP_APPFONT ( 6 , 123 + DIFF ) ;
76
        Size = MAP_APPFONT ( 34 , 10 ) ;
77
		Text [ en-US ] = "~Magenta" ;
78
	};
79
	FixedText FT_YELLOW
80
	{
81
		Pos = MAP_APPFONT ( 6 , 136 + DIFF ) ;
82
        Size = MAP_APPFONT ( 34 , 10 ) ;
83
		Text [ en-US ] = "~Yellow" ;
84
	};
85
	FixedText FT_KEY
86
	{
87
		Pos = MAP_APPFONT ( 6 , 149 + DIFF ) ;
88
        Size = MAP_APPFONT ( 34 , 10 ) ;
89
		Text [ en-US ] = "~Key" ;
90
	};
91
	MetricField NUM_CYAN
92
	{
93
	    HelpID = "svtools:MetricField:DLG_COLOR:NUM_CYAN";
94
		Border = TRUE ;
95
        Pos = MAP_APPFONT ( 42 , 109 + DIFF ) ;
96
        Size = MAP_APPFONT ( 26 , 12 ) ;
97
		TabStop = TRUE ;
98
		Repeat = TRUE ;
99
		Spin = TRUE ;
100
		Maximum = 100 ;
101
		Last = 100 ;
102
		Unit = FUNIT_CUSTOM ;
103
		CustomUnitText = " %" ;
104
	};
105
	MetricField NUM_MAGENTA
106
	{
107
	    HelpID = "svtools:MetricField:DLG_COLOR:NUM_MAGENTA";
108
		Border = TRUE ;
109
        Pos = MAP_APPFONT ( 42 , 122 + DIFF ) ;
110
        Size = MAP_APPFONT ( 26 , 12 ) ;
111
		TabStop = TRUE ;
112
		Repeat = TRUE ;
113
		Spin = TRUE ;
114
		Maximum = 100 ;
115
		Last = 100 ;
116
		Unit = FUNIT_CUSTOM ;
117
		CustomUnitText = " %" ;
118
	};
119
	MetricField NUM_YELLOW
120
	{
121
	    HelpID = "svtools:MetricField:DLG_COLOR:NUM_YELLOW";
122
		Border = TRUE ;
123
        Pos = MAP_APPFONT ( 42 , 135 + DIFF ) ;
124
        Size = MAP_APPFONT ( 26 , 12 ) ;
125
		TabStop = TRUE ;
126
		Repeat = TRUE ;
127
		Spin = TRUE ;
128
		Maximum = 100 ;
129
		Last = 100 ;
130
		Unit = FUNIT_CUSTOM ;
131
		CustomUnitText = " %" ;
132
	};
133
	MetricField NUM_KEY
134
	{
135
	    HelpID = "svtools:MetricField:DLG_COLOR:NUM_KEY";
136
		Border = TRUE ;
137
        Pos = MAP_APPFONT ( 42 , 148 + DIFF ) ;
138
        Size = MAP_APPFONT ( 26 , 12 ) ;
139
		TabStop = TRUE ;
140
		Repeat = TRUE ;
141
		Spin = TRUE ;
142
		Maximum = 100 ;
143
		Last = 100 ;
144
		Unit = FUNIT_CUSTOM ;
145
		CustomUnitText = " %" ;
146
	};
147
    FixedText FT_RED
148
	{
149
        Pos = MAP_APPFONT ( 72 , 123 + DIFF ) ;
150
        Size = MAP_APPFONT ( 33 , 10 ) ;
151
		Text [ en-US ] = "~Red" ;
152
	};
153
	FixedText FT_GREEN
154
	{
155
        Pos = MAP_APPFONT ( 72 , 136 + DIFF ) ;
156
        Size = MAP_APPFONT ( 33 , 10 ) ;
157
		Text [ en-US ] = "~Green" ;
158
	};
159
	FixedText FT_BLUE
160
	{
161
        Pos = MAP_APPFONT ( 72 , 149 + DIFF ) ;
162
        Size = MAP_APPFONT ( 33 , 10 ) ;
163
		Text [ en-US ] = "~Blue" ;
164
	};
165
	NumericField NUM_RED
166
	{
167
	    HelpID = "svtools:NumericField:DLG_COLOR:NUM_RED";
168
		Border = TRUE ;
169
        Pos = MAP_APPFONT ( 106 , 122 + DIFF ) ;
170
		Size = MAP_APPFONT ( 26 , 12 ) ;
171
		TabStop = TRUE ;
172
		Repeat = TRUE ;
173
		Spin = TRUE ;
174
		Maximum = 255 ;
175
		Last = 255 ;
176
	};
177
	NumericField NUM_GREEN
178
	{
179
	    HelpID = "svtools:NumericField:DLG_COLOR:NUM_GREEN";
180
		Border = TRUE ;
181
        Pos = MAP_APPFONT ( 106 , 135 + DIFF ) ;
182
		Size = MAP_APPFONT ( 26 , 12 ) ;
183
		TabStop = TRUE ;
184
		Repeat = TRUE ;
185
		Spin = TRUE ;
186
		Maximum = 255 ;
187
		Last = 255 ;
188
	};
189
	NumericField NUM_BLUE
190
	{
191
	    HelpID = "svtools:NumericField:DLG_COLOR:NUM_BLUE";
192
		Border = TRUE ;
193
        Pos = MAP_APPFONT ( 106 , 148 + DIFF ) ;
194
		Size = MAP_APPFONT ( 26 , 12 ) ;
195
		TabStop = TRUE ;
196
		Repeat = TRUE ;
197
		Spin = TRUE ;
198
		Maximum = 255 ;
199
		Last = 255 ;
200
	};
201
    FixedText FT_HUE
202
	{
203
        Pos = MAP_APPFONT ( 135 , 123 + DIFF ) ;
204
        Size = MAP_APPFONT ( 34 , 10 ) ;
205
		Text [ en-US ] = "H~ue" ;
206
	};
207
	NumericField NUM_HUE
208
	{
209
	    HelpID = "svtools:NumericField:DLG_COLOR:NUM_HUE";
210
		Border = TRUE ;
211
        Pos = MAP_APPFONT ( 171 , 122 + DIFF ) ;
212
		Size = MAP_APPFONT ( 26 , 12 ) ;
213
		TabStop = TRUE ;
214
		Repeat = TRUE ;
215
		Spin = TRUE ;
216
		Maximum = 359 ;
217
		Last = 359 ;
218
	};
219
	FixedText FT_SATURATION
220
	{
221
        Pos = MAP_APPFONT ( 135 , 136 + DIFF ) ;
222
        Size = MAP_APPFONT ( 34 , 10 ) ;
223
		Text [ en-US ] = "~Saturation" ;
224
	};
225
	NumericField NUM_SATURATION
226
	{
227
	    HelpID = "svtools:NumericField:DLG_COLOR:NUM_SATURATION";
228
		Border = TRUE ;
229
        Pos = MAP_APPFONT ( 171 , 135 + DIFF ) ;
230
		Size = MAP_APPFONT ( 26 , 12 ) ;
231
		TabStop = TRUE ;
232
		Repeat = TRUE ;
233
		Spin = TRUE ;
234
		Maximum = 100 ;
235
		Last = 100 ;
236
	};
237
	FixedText FT_LUMINANCE
238
	{
239
        Pos = MAP_APPFONT ( 135 , 149 + DIFF ) ;
240
        Size = MAP_APPFONT ( 34 , 10 ) ;
241
		Text [ en-US ] = "Bright~ness" ;
242
	};
243
	NumericField NUM_LUMINANCE
244
	{
245
	    HelpID = "svtools:NumericField:DLG_COLOR:NUM_LUMINANCE";
246
		Border = TRUE ;
247
        Pos = MAP_APPFONT ( 171 , 148 + DIFF ) ;
248
		Size = MAP_APPFONT ( 26 , 12 ) ;
249
		TabStop = TRUE ;
250
		Repeat = TRUE ;
251
		Spin = TRUE ;
252
		Maximum = 100 ;
253
		Last = 100 ;
254
	};
255
    PushButton BTN_1
256
	{
257
        HelpID = "svtools:PushButton:DLG_COLOR:BTN_1";
258
		Pos = MAP_APPFONT ( 80 , 109 ) ;
259
		Size = MAP_APPFONT ( 17 , 12 ) ;
260
		Text = "~<--" ;
261
		TabStop = TRUE ;
262
	};
263
	PushButton BTN_2
264
	{
265
	    HelpID = "svtools:PushButton:DLG_COLOR:BTN_2";
266
		Pos = MAP_APPFONT ( 100 , 109 ) ;
267
		Size = MAP_APPFONT ( 17 , 12 ) ;
268
		Text = "--~>" ;
269
		TabStop = TRUE ;
270
	};
271
    Control CTL_PREVIEW_OLD
272
	{
273
		Border = TRUE ;
274
        Pos = MAP_APPFONT ( 200 , 109 ) ;
275
        Size = MAP_APPFONT ( 26 , 51 + DIFF ) ;
276
		TabStop = FALSE ;
277
	};
278
	Control CTL_PREVIEW
279
	{
280
		Border = TRUE ;
281
        Pos = MAP_APPFONT ( 229 , 109 ) ;
282
        Size = MAP_APPFONT ( 26 , 51 + DIFF ) ;
283
		TabStop = FALSE ;
284
	};
285
};
286
287
String STR_COLORDES
288
{
289
	Text [ en-US ] = "RGB(%1, %2, %3) Hue:%4 Saturation:%5 Brightness:%6";
290
};
291
(-)svtools/inc/svtools/colctrl.hxx (-198 lines)
Lines 1-198 Link Here
1
/**************************************************************
2
 * 
3
 * Licensed to the Apache Software Foundation (ASF) under one
4
 * or more contributor license agreements.  See the NOTICE file
5
 * distributed with this work for additional information
6
 * regarding copyright ownership.  The ASF licenses this file
7
 * to you under the Apache License, Version 2.0 (the
8
 * "License"); you may not use this file except in compliance
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
15
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
 * KIND, either express or implied.  See the License for the
17
 * specific language governing permissions and limitations
18
 * under the License.
19
 * 
20
 *************************************************************/
21
22
23
24
#ifndef _SV_COLCTRL_HXX
25
#define _SV_COLCTRL_HXX
26
27
#include <tools/color.hxx>
28
#include <vcl/ctrl.hxx>
29
#include <svtools/valueset.hxx>
30
31
// ----------------
32
// - ColorControl -
33
// ----------------
34
35
class Bitmap;
36
class BitmapReadAccess;
37
class ColorHSB;
38
39
class SvColorControl : public Control
40
{
41
private:
42
	Bitmap*			mpBitmap;
43
	BitmapReadAccess* mpReadAccess;
44
	Color			maColor;
45
	short			mnLuminance;
46
	Point			maPosition;
47
	Link			maModifyHdl;
48
49
	void			Initialize();
50
	void			CreateBitmap();
51
	void			ShowPosition( const Point& aPos );
52
53
public:
54
					SvColorControl( Window* pParent, WinBits nStyle = 0 );
55
					SvColorControl( Window* pParent, const ResId& rResId );
56
					~SvColorControl();
57
58
	virtual void    MouseMove( const MouseEvent& rMEvt );
59
	virtual void    MouseButtonDown( const MouseEvent& rMEvt );
60
	virtual void    MouseButtonUp( const MouseEvent& rMEvt );
61
//    virtual void    KeyInput( const KeyEvent& rKEvent );
62
	virtual void    Paint( const Rectangle& rRect );
63
	virtual void    Resize();
64
//    virtual void    GetFocus();
65
//    virtual void    LoseFocus();
66
67
	virtual void    Modify();
68
69
	Color			GetColor() const { return maColor; };
70
	void 			SetColor( const Color& rCol );
71
	void 			SetColor( const ColorHSB& rCol, sal_Bool bSetColor = sal_True );
72
73
	short			GetLuminance() const { return mnLuminance; };
74
	void 			SetLuminance( short nLum );
75
76
	void            SetModifyHdl( const Link& rLink ) { maModifyHdl = rLink; }
77
	const Link&     GetModifyHdl() const { return maModifyHdl; }
78
79
};
80
81
// -----------------------
82
// - ColorPreviewControl -
83
// -----------------------
84
85
class ColorPreviewControl : public Control
86
{
87
private:
88
	Color			maColor;
89
90
public:
91
					ColorPreviewControl( Window* pParent, WinBits nStyle = 0 );
92
					ColorPreviewControl( Window* pParent, const ResId& rResId );
93
					~ColorPreviewControl();
94
95
	virtual void    Paint( const Rectangle& rRect );
96
97
	Color			GetColor() const { return maColor; };
98
	void 			SetColor( const Color& rCol );
99
};
100
101
// -----------------------
102
// - ColorMixingControl -
103
// -----------------------
104
105
enum CMCPosition { CMC_TOPLEFT, CMC_TOPRIGHT, CMC_BOTTOMLEFT, CMC_BOTTOMRIGHT, CMC_OTHER };
106
107
class ColorMixingControl : public ValueSet
108
{
109
private:
110
	sal_uInt16			mnRows;
111
	sal_uInt16			mnColumns;
112
	Color			maColor[4];
113
114
	void			Initialize();
115
116
	Color			CalcDifferenceColor( sal_uInt16 nCol1, sal_uInt16 nCol2, sal_uInt16 nSteps );
117
	void			FillRow( sal_uInt16 nRow );
118
	void			FillColumn( sal_uInt16 nColumn );
119
120
public:
121
					ColorMixingControl( Window* pParent, WinBits nStyle = 0,
122
										sal_uInt16 nRows = 4, sal_uInt16 nColumns = 4 );
123
					ColorMixingControl( Window* pParent, const ResId& rResId,
124
										sal_uInt16 nRows = 4, sal_uInt16 nColumns = 4 );
125
					~ColorMixingControl();
126
127
	sal_uInt16			GetRows() const { return mnRows; };
128
	void  			SetRows( sal_uInt16 nRows );
129
	sal_uInt16			GetColumns() const { return mnColumns; };
130
	void  			SetColumns( sal_uInt16 nColumns );
131
132
    using ValueSet::GetColor;
133
	Color			GetColor( CMCPosition ePos ) const { return maColor[ ePos ]; };
134
    using ValueSet::SetColor;
135
	void 			SetColor( CMCPosition ePos, const Color& rCol );
136
137
	String			GetRGBString( const Color& rColor );
138
	CMCPosition		GetCMCPosition() const;
139
};
140
141
// ------------
142
// - ColorHSB -
143
// ------------
144
145
class ColorHSB
146
{
147
private:
148
	sal_uInt16      mnHue;   // Farbwinkel, 360 Grad
149
	sal_uInt16      mnSat;   // Saturation, 100 %
150
	sal_uInt16      mnBri;   // Brightness, 100 %
151
152
public:
153
				ColorHSB()
154
					{ mnHue=0; mnSat=0; mnBri=0; }
155
				ColorHSB( sal_uInt16 nH, sal_uInt16 nS, sal_uInt16 nB )
156
					{ mnHue=nH; mnSat=nS; mnBri=nB; }
157
				ColorHSB( const Color& rColor );
158
159
	void        SetHue( sal_uInt16 nH ) { mnHue=nH; }
160
	void        SetSat( sal_uInt16 nS ) { mnSat=nS; }
161
	void        SetBri( sal_uInt16 nB ) { mnBri=nB; }
162
	sal_uInt16      GetHue() const { return mnHue; }
163
	sal_uInt16      GetSat() const { return mnSat; }
164
	sal_uInt16      GetBri() const { return mnBri; }
165
	Color       GetRGB() const;
166
};
167
168
// -------------
169
// - ColorCMYK -
170
// -------------
171
172
class ColorCMYK
173
{
174
private:
175
	sal_uInt16		mnCyan;
176
	sal_uInt16		mnMagenta;
177
	sal_uInt16		mnYellow;
178
	sal_uInt16		mnKey;
179
180
public:
181
				ColorCMYK()
182
					{ mnCyan=0; mnMagenta=0; mnYellow=0; mnKey=100; }
183
				ColorCMYK( sal_uInt16 nC, sal_uInt16 nM, sal_uInt16 nY, sal_uInt16 nK )
184
					{ mnCyan=nC; mnMagenta=nM; mnYellow=nY; mnKey=nK; }
185
				ColorCMYK( const Color& rColor );
186
187
	void        SetCyan( sal_uInt16 nC ) { mnCyan=nC; }
188
	void        SetMagenta( sal_uInt16 nM ) { mnMagenta=nM; }
189
	void        SetYellow( sal_uInt16 nY ) { mnYellow=nY; }
190
	void        SetKey( sal_uInt16 nK ) { mnKey=nK; }
191
	sal_uInt16      GetCyan() const { return mnCyan; }
192
	sal_uInt16      GetMagenta() const { return mnMagenta; }
193
	sal_uInt16      GetYellow() const { return mnYellow; }
194
	sal_uInt16      GetKey() const { return mnKey; }
195
	Color       GetRGB() const;
196
};
197
198
#endif  // _SV_COLCTRL_HXX
(-)svtools/inc/svtools/colrdlg.hxx (-62 / +16 lines)
Lines 19-103 Link Here
19
 * 
19
 * 
20
 *************************************************************/
20
 *************************************************************/
21
21
22
23
24
#ifndef _SV_COLRDLG_HXX
22
#ifndef _SV_COLRDLG_HXX
25
#define _SV_COLRDLG_HXX
23
#define _SV_COLRDLG_HXX
26
24
27
#include "svtools/svtdllapi.h"
25
#include "svtools/svtdllapi.h"
28
#include <vcl/dialog.hxx>
26
#include <tools/color.hxx>
29
#ifndef _SV_BUTTON_HXX //autogen
27
30
#include <vcl/button.hxx>
28
class Window;
31
#endif
32
#include <vcl/fixed.hxx>
33
#include <vcl/field.hxx>
34
#include <svtools/colctrl.hxx>
35
29
36
// ---------------
30
// ---------------
37
// - ColorDialog -
31
// - ColorDialog -
38
// ---------------
32
// ---------------
39
33
40
class SVT_DLLPUBLIC SvColorDialog : public ModalDialog
34
namespace svtools
41
{
35
{
42
private:
36
    // SELECT is the default
43
	ColorMixingControl	maColMixCtrl;
37
    enum ColorPickerMode { ColorPickerMode_SELECT = 0, ColorPickerMode_ADD = 1, ColorPickerMode_MODIFY = 2 };
44
	PushButton		maBtn1;
38
}
45
	PushButton		maBtn2;
46
	//PushButton		maBtn3;
47
	//PushButton		maBtn4;
48
	//FixedText		maFtRGB;
49
	SvColorControl	maCtlColor;
50
39
51
    // CMYK controls.
40
class SVT_DLLPUBLIC SvColorDialog
52
	FixedText		maFtCyan;
41
{
53
	MetricField		maNumCyan;
54
	FixedText		maFtMagenta;
55
	MetricField		maNumMagenta;
56
	FixedText		maFtYellow;
57
	MetricField		maNumYellow;
58
	FixedText		maFtKey;
59
	MetricField		maNumKey;
60
61
    // RGB controls.
62
	FixedText		maFtRed;
63
	NumericField	maNumRed;
64
	FixedText		maFtGreen;
65
	NumericField	maNumGreen;
66
	FixedText		maFtBlue;
67
	NumericField	maNumBlue;
68
69
    // HSL controls.
70
	FixedText		maFtHue;
71
	NumericField	maNumHue;
72
	FixedText		maFtSaturation;
73
	NumericField	maNumSaturation;
74
	FixedText		maFtLuminance;
75
	NumericField	maNumLuminance;
76
77
	ColorPreviewControl	maCtlPreview;
78
	ColorPreviewControl	maCtlPreviewOld;
79
80
	OKButton		maBtnOK;
81
	CancelButton	maBtnCancel;
82
	HelpButton		maBtnHelp;
83
84
	Color			maColor;
85
86
	SVT_DLLPRIVATE void			Initialize();
87
88
	DECL_DLLPRIVATE_LINK( ColorModifyHdl, void * );
89
	DECL_DLLPRIVATE_LINK( ClickBtnHdl, void * );
90
	DECL_DLLPRIVATE_LINK( ClickMixCtrlHdl, void * );
91
	DECL_DLLPRIVATE_LINK( SelectMixCtrlHdl, void * );
92
93
public:
42
public:
94
					SvColorDialog( Window* pParent );
43
    SvColorDialog( ::Window* pParent );
95
					~SvColorDialog();
96
44
97
	void			SetColor( const Color& rColor );
45
	void			SetColor( const Color& rColor );
98
	const Color&	GetColor() const;
46
	const Color&	GetColor() const;
99
47
48
    void            SetMode( sal_Int16 eMode );
100
	virtual short	Execute();
49
	virtual short	Execute();
50
51
private:
52
    Window*         mpParent;
53
    Color           maColor;
54
    sal_Int16       meMode;
101
};
55
};
102
56
103
#endif  // _SV_COLRDLG_HXX
57
#endif  // _SV_COLRDLG_HXX

Return to issue 118828