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

(-)main/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
*
(-)main/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
*
(-)main/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
*
(-)main/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 \
(-)main/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
*
(-)main/cui/source/dialogs/colorpicker.cxx (+1711 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
#include <limits>
52
53
using rtl::OUString;
54
using namespace ::com::sun::star::uno;
55
using namespace ::com::sun::star::lang;
56
using namespace ::com::sun::star::ui::dialogs;
57
using namespace ::com::sun::star::beans;
58
59
namespace cui
60
{
61
const sal_uInt16 COLORMODE_RGB =  0x10;
62
const sal_uInt16 COLORMODE_HSV =  0x20;
63
const sal_uInt16 COLORMODE_CMYK = 0x40;
64
65
const sal_uInt16 COLORCOMP_RED   = 0x10;
66
const sal_uInt16 COLORCOMP_GREEN = 0x11;
67
const sal_uInt16 COLORCOMP_BLUE  = 0x12;
68
69
const sal_uInt16 COLORCOMP_HUE  = 0x20;
70
const sal_uInt16 COLORCOMP_SAT  = 0x21;
71
const sal_uInt16 COLORCOMP_BRI  = 0x22;
72
73
const sal_uInt16 COLORCOMP_CYAN    = 0x40;
74
const sal_uInt16 COLORCOMP_YELLOW  = 0x41;
75
const sal_uInt16 COLORCOMP_MAGENTA = 0x42;
76
const sal_uInt16 COLORCOMP_KEY     = 0x43;
77
78
// -----------------------------------------------------------------------
79
// color space conversion
80
// RGB  = 0 .. 1
81
// H    = 0 .. 360
82
// SV   = 0 .. 1
83
// CMYK = 0 .. 1
84
// -----------------------------------------------------------------------
85
86
static bool equals( double a, double b )
87
{
88
    return (a == b) || (abs(a-b) < std::numeric_limits<double>::epsilon());
89
}
90
91
static void RGBtoHSV( double dR, double dG, double dB, double& dH, double& dS, double& dV )
92
{
93
    // Brightness = max(R, G, B);
94
    dV = std::max( dR, std::max( dG, dB ) );
95
96
    double cDelta = dV - std::min( dR, std::min( dG, dB ) );
97
98
    // Saturation = max - min / max
99
    if( dV > 0 )
100
        dS = cDelta / dV;
101
    else
102
        dS = 0.0;
103
104
    dH = 0.0;
105
106
    if( !equals( dS, 0.0 ) )
107
    {
108
        if( equals( dR, dV ) )
109
        {
110
            dH = ( dG - dB ) / cDelta;
111
        }
112
        else if( equals( dG, dV ) )
113
        {
114
            dH = 2.0 + ( dB - dR ) / cDelta;
115
        }
116
        else if ( equals( dB, dV ) )
117
        {
118
            dH = 4.0 + ( dR - dG ) / cDelta;
119
        }
120
        dH *= 60.0;
121
122
        if( dH < 0.0 )
123
            dH += 360.0;
124
    }
125
}
126
127
static void HSVtoRGB(double dH, double dS, double dV, double& dR, double& dG, double& dB )
128
{
129
    if( equals( dS, 0.0 ) )
130
    {
131
        dR = dV;
132
        dG = dV;
133
        dB = dV;
134
    }
135
    else
136
    {
137
        if( equals( dH, 360.0 ) )
138
            dH = 0.0;
139
        else
140
            dH /= 60.0;
141
142
        sal_uInt16 n = (sal_uInt16) dH;
143
        double f = dH - n;
144
145
        double a = dV * ( 1.0 - dS );
146
        double b = dV * ( 1.0 - ( dS * f ) );
147
        double c = dV * ( 1.0 - ( dS * ( 1.0 - f ) ) );
148
149
        switch( n )
150
        {
151
            case 0: dR = dV; dG = c;  dB = a;  break;
152
            case 1: dR = b;  dG = dV; dB = a;  break;
153
            case 2: dR = a;  dG = dV; dB = c;  break;
154
            case 3: dR = a;  dG = b;  dB = dV; break;
155
            case 4: dR = c;  dG = a;  dB = dV; break;
156
            case 5: dR = dV; dG = a;  dB = b;  break;
157
        }
158
    }
159
}
160
161
// -----------------------------------------------------------------------
162
163
// CMYK values from 0 to 1
164
static void CMYKtoRGB( double fCyan, double fMagenta, double fYellow, double fKey, double& dR, double& dG, double& dB )
165
{
166
    fCyan = (fCyan * ( 1.0 - fKey )) + fKey;
167
    fMagenta = (fMagenta * ( 1.0 - fKey )) + fKey;
168
    fYellow = (fYellow * ( 1.0 - fKey )) + fKey;
169
170
    dR = std::max( std::min( ( 1.0 - fCyan ), 1.0), 0.0 );
171
    dG = std::max( std::min( ( 1.0 - fMagenta ), 1.0), 0.0 );
172
    dB = std::max( std::min( ( 1.0 - fYellow ), 1.0), 0.0 );
173
}
174
175
// -----------------------------------------------------------------------
176
177
// CMY results from 0 to 1
178
static void RGBtoCMYK( double dR, double dG, double dB, double& fCyan, double& fMagenta, double& fYellow, double& fKey )
179
{
180
    fCyan = 1 - dR;
181
    fMagenta = 1 - dG;
182
    fYellow = 1 - dB;
183
184
    //CMYK and CMY values from 0 to 1
185
    fKey = 1.0;
186
    if( fCyan < fKey ) fKey = fCyan;
187
    if( fMagenta < fKey ) fKey = fMagenta;
188
    if( fYellow < fKey ) fKey = fYellow;
189
190
    if( equals( fKey, 1.0 ) )
191
    {
192
        //Black
193
       fCyan = 0.0;
194
       fMagenta = 0.0;
195
       fYellow = 0.0;
196
    }
197
    else
198
    {
199
       fCyan = ( fCyan - fKey ) / ( 1.0 - fKey );
200
       fMagenta = ( fMagenta - fKey ) / ( 1.0 - fKey );
201
       fYellow = ( fYellow - fKey ) / ( 1.0 - fKey );
202
    }
203
}
204
205
// ====================================================================
206
207
class HexColorControl : public Edit
208
{
209
public:
210
    HexColorControl( Window* pParent, const ResId& rResId );
211
212
    virtual long PreNotify( NotifyEvent& rNEvt );
213
    virtual void Paste();
214
215
    void SetColor( sal_Int32 nColor );
216
    sal_Int32 GetColor();
217
218
private:
219
    bool ImplProcessKeyInput( const KeyEvent& rKEv );
220
};
221
222
HexColorControl::HexColorControl( Window* pParent, const ResId& rResId )
223
: Edit( pParent, rResId )
224
{
225
    SetMaxTextLen( 6 );
226
}
227
228
// -----------------------------------------------------------------------
229
230
void HexColorControl::SetColor( sal_Int32 nColor )
231
{
232
    ::rtl::OUStringBuffer aBuffer;
233
    sax::Converter::convertColor( aBuffer, nColor );
234
    SetText( aBuffer.makeStringAndClear().copy(1) );
235
}
236
237
// -----------------------------------------------------------------------
238
239
sal_Int32 HexColorControl::GetColor()
240
{
241
    sal_Int32 nColor = -1;
242
243
    OUString aStr( RTL_CONSTASCII_USTRINGPARAM( "#" ) );
244
    aStr += GetText();
245
    sal_Int32 nLen = aStr.getLength();
246
    if( nLen < 7 )
247
    {
248
        static const sal_Char* pNullStr = "000000";
249
        aStr += OUString::createFromAscii( &pNullStr[nLen-1] );
250
    }
251
252
    sax::Converter::convertColor( nColor, aStr );
253
254
    if( nColor == -1 )
255
        SetControlBackground( Color( COL_RED ) );
256
    else
257
        SetControlBackground();
258
259
    return nColor;
260
}
261
262
// -----------------------------------------------------------------------
263
264
long HexColorControl::PreNotify( NotifyEvent& rNEvt )
265
{
266
    if ( (rNEvt.GetType() == EVENT_KEYINPUT) && !rNEvt.GetKeyEvent()->GetKeyCode().IsMod2() )
267
    {
268
        if ( ImplProcessKeyInput( *rNEvt.GetKeyEvent() ) )
269
            return 1;
270
    }
271
272
    return Edit::PreNotify( rNEvt );
273
}
274
275
// -----------------------------------------------------------------------
276
277
void HexColorControl::Paste()
278
{
279
    ::com::sun::star::uno::Reference<com::sun::star::datatransfer::clipboard::XClipboard> aClipboard(GetClipboard());
280
    if ( aClipboard.is() )
281
    {
282
        ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > xDataObj;
283
284
        const sal_uInt32 nRef = Application::ReleaseSolarMutex();
285
286
        try
287
        {
288
            xDataObj = aClipboard->getContents();
289
        }
290
        catch( const ::com::sun::star::uno::Exception& )
291
        {
292
        }
293
294
        Application::AcquireSolarMutex( nRef );
295
296
        if ( xDataObj.is() )
297
        {
298
            ::com::sun::star::datatransfer::DataFlavor aFlavor;
299
            SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aFlavor );
300
            try
301
            {
302
                ::com::sun::star::uno::Any aData = xDataObj->getTransferData( aFlavor );
303
                ::rtl::OUString aText;
304
                aData >>= aText;
305
306
                if( aText.getLength() && aText.matchAsciiL( "#", 1, 0 ) )
307
                    aText = aText.copy(1);
308
309
                if( aText.getLength() > 6 )
310
                    aText = aText.copy( 0, 6 );
311
312
                SetText( aText );
313
            }
314
            catch( const ::com::sun::star::uno::Exception& )
315
            {
316
            }
317
        }
318
    }
319
}
320
321
// -----------------------------------------------------------------------
322
323
bool HexColorControl::ImplProcessKeyInput( const KeyEvent& rKEv )
324
{
325
    const KeyCode& rKeyCode = rKEv.GetKeyCode();
326
327
    if( rKeyCode.GetGroup() == KEYGROUP_ALPHA && !rKeyCode.IsMod1() && !rKeyCode.IsMod2() )
328
    {
329
        if( (rKeyCode.GetCode() < KEY_A) || (rKeyCode.GetCode() > KEY_F) )
330
        {
331
            Sound::Beep();
332
            return true;
333
        }
334
    }
335
    else if( rKeyCode.GetGroup() == KEYGROUP_NUM )
336
    {
337
        if( rKeyCode.IsShift() )
338
        {
339
            Sound::Beep();
340
            return true;
341
        }
342
    }
343
    return false;
344
}
345
346
// ====================================================================
347
348
class ColorPreviewControl : public Control
349
{
350
public:
351
    ColorPreviewControl( Window* pParent, const ResId& rResId );
352
353
    virtual void        Paint( const Rectangle& rRect );
354
355
    void SetColor( const Color& rColor );
356
private:
357
    Color maColor;
358
};
359
360
// -----------------------------------------------------------------------
361
362
ColorPreviewControl::ColorPreviewControl( Window* pParent, const ResId& rResId )
363
: Control( pParent, rResId )
364
{
365
    SetFillColor( maColor );
366
    SetLineColor( maColor );
367
}
368
369
// -----------------------------------------------------------------------
370
371
void ColorPreviewControl::SetColor( const Color& rCol )
372
{
373
    if( rCol != maColor )
374
    {
375
        maColor = rCol;
376
        SetFillColor( maColor );
377
        SetLineColor( maColor );
378
        Invalidate();
379
    }
380
}
381
382
// -----------------------------------------------------------------------
383
384
void ColorPreviewControl::Paint( const Rectangle& rRect )
385
{
386
    DrawRect( rRect );
387
}
388
389
// ====================================================================
390
391
enum ColorMode { HUE, SATURATION, BRIGHTNESS, RED, GREEN, BLUE };
392
const ColorMode DefaultMode = HUE;
393
394
class ColorFieldControl : public Control
395
{
396
public:
397
    ColorFieldControl( Window* pParent, const ResId& rResId );
398
    ~ColorFieldControl();
399
400
    virtual void        MouseMove( const MouseEvent& rMEvt );
401
    virtual void        MouseButtonDown( const MouseEvent& rMEvt );
402
    virtual void        MouseButtonUp( const MouseEvent& rMEvt );
403
    virtual void        KeyInput( const KeyEvent& rKEvt );
404
    virtual void        Paint( const Rectangle& rRect );
405
    virtual void        Resize();
406
407
    void                UpdateBitmap();
408
    void                ShowPosition( const Point& rPos, bool bUpdate );
409
    void                UpdatePosition();
410
    void                Modify();
411
412
    void                SetValues( Color aColor, ColorMode eMode, double x, double y );
413
    double              GetX();
414
    double              GetY();
415
416
    void                KeyMove( int dx, int dy );
417
418
    void                SetModifyHdl( Link& rLink ) { maModifyHdl = rLink; }
419
420
private:
421
    Link maModifyHdl;
422
    ColorMode meMode;
423
    Color maColor;
424
    double mdX;
425
    double mdY;
426
    Point maPosition;
427
    Bitmap* mpBitmap;
428
    std::vector< sal_uInt8 > maRGB_Horiz;
429
    std::vector< sal_uInt16 > maGrad_Horiz;
430
    std::vector< sal_uInt16 > maPercent_Horiz;
431
    std::vector< sal_uInt8 > maRGB_Vert;
432
    std::vector< sal_uInt16 > maPercent_Vert;
433
    bool mbInit;
434
};
435
436
// -----------------------------------------------------------------------
437
438
ColorFieldControl::ColorFieldControl( Window* pParent, const ResId& rResId )
439
: Control( pParent, rResId )
440
, meMode( DefaultMode )
441
, mdX( -1.0 )
442
, mdY( -1.0 )
443
, mpBitmap( 0 )
444
, mbInit( false )
445
{
446
    SetControlBackground();
447
}
448
449
// -----------------------------------------------------------------------
450
451
ColorFieldControl::~ColorFieldControl()
452
{
453
    delete mpBitmap;
454
}
455
456
// -----------------------------------------------------------------------
457
458
void ColorFieldControl::UpdateBitmap()
459
{
460
    const Size aSize( GetOutputSizePixel() );
461
462
    if( mpBitmap && mpBitmap->GetSizePixel() != aSize )
463
        delete mpBitmap, mpBitmap = NULL;
464
465
    const sal_Int32 nWidth = aSize.Width();
466
    const sal_Int32 nHeight = aSize.Height();
467
468
    if( !mpBitmap )
469
    {
470
        mpBitmap = new Bitmap( aSize, 24 );
471
472
        maRGB_Horiz.resize( nWidth );
473
        maGrad_Horiz.resize( nWidth );
474
        maPercent_Horiz.resize( nWidth );
475
476
        sal_uInt8* pRGB = &(*maRGB_Horiz.begin());
477
        sal_uInt16* pGrad = &(*maGrad_Horiz.begin());
478
        sal_uInt16* pPercent = &(*maPercent_Horiz.begin());
479
480
        for( sal_Int32 x = 0; x < nWidth; x++ )
481
        {
482
            *pRGB++ = static_cast< sal_uInt8 >( (x * 256) / nWidth );
483
            *pGrad++ = static_cast< sal_uInt16 >( (x * 359) / nWidth );
484
            *pPercent++ = static_cast< sal_uInt16 >( (x * 100) / nWidth );
485
        }
486
487
        maRGB_Vert.resize( nHeight );
488
        maPercent_Vert.resize( nHeight );
489
490
        pRGB = &(*maRGB_Vert.begin());
491
        pPercent = &(*maPercent_Vert.begin());
492
493
        sal_Int32 y = nHeight;
494
        while( y-- )
495
        {
496
            *pRGB++ = static_cast< sal_uInt8 >( (y * 256) / nHeight );
497
            *pPercent++ = static_cast< sal_uInt16 >( (y * 100) / nHeight );
498
        }
499
    }
500
501
    sal_uInt8* pRGB_Horiz = &(*maRGB_Horiz.begin());
502
    sal_uInt16* pGrad_Horiz = &(*maGrad_Horiz.begin());
503
    sal_uInt16* pPercent_Horiz = &(*maPercent_Horiz.begin());
504
    sal_uInt8* pRGB_Vert = &(*maRGB_Vert.begin());
505
    sal_uInt16* pPercent_Vert = &(*maPercent_Vert.begin());
506
507
    BitmapWriteAccess* pWriteAccess = mpBitmap->AcquireWriteAccess();
508
    if( pWriteAccess )
509
    {
510
        BitmapColor aBitmapColor( maColor );
511
512
        sal_uInt16 nHue, nSat, nBri;
513
        maColor.RGBtoHSB( nHue, nSat, nBri );
514
515
        // this has been unlooped for performance reason, please do not merge back!
516
517
        sal_uInt16 y = nHeight,x;
518
519
        switch( meMode )
520
        {
521
        case HUE:
522
            while( y-- )
523
            {
524
                nBri = pPercent_Vert[y];
525
                x = nWidth;
526
                while( x-- )
527
                {
528
                    nSat = pPercent_Horiz[x];
529
                    pWriteAccess->SetPixel( y, x, BitmapColor( Color( Color::HSBtoRGB( nHue, nSat, nBri ) ) ) );
530
                }
531
            }
532
            break;
533
        case SATURATION:
534
            while( y-- )
535
            {
536
                nBri = pPercent_Vert[y];
537
                x = nWidth;
538
                while( x-- )
539
                {
540
                    nHue = pGrad_Horiz[x];
541
                    pWriteAccess->SetPixel( y, x, BitmapColor( Color( Color::HSBtoRGB( nHue, nSat, nBri ) ) ) );
542
                }
543
            }
544
            break;
545
        case BRIGHTNESS:
546
            while( y-- )
547
            {
548
                nSat = pPercent_Vert[y];
549
                x = nWidth;
550
                while( x-- )
551
                {
552
                    nHue = pGrad_Horiz[x];
553
                    pWriteAccess->SetPixel( y, x, BitmapColor( Color( Color::HSBtoRGB( nHue, nSat, nBri ) ) ) );
554
                }
555
            }
556
            break;
557
        case RED:
558
            while( y-- )
559
            {
560
                aBitmapColor.SetGreen( pRGB_Vert[y] );
561
                x = nWidth;
562
                while( x-- )
563
                {
564
                    aBitmapColor.SetBlue( pRGB_Horiz[x] );
565
                    pWriteAccess->SetPixel( y, x, aBitmapColor );
566
                }
567
            }
568
            break;
569
        case GREEN:
570
            while( y-- )
571
            {
572
                aBitmapColor.SetRed( pRGB_Vert[y] );
573
                x = nWidth;
574
                while( x-- )
575
                {
576
                    aBitmapColor.SetBlue( pRGB_Horiz[x] );
577
                    pWriteAccess->SetPixel( y, x, aBitmapColor );
578
                }
579
            }
580
            break;
581
        case BLUE:
582
            while( y-- )
583
            {
584
                aBitmapColor.SetGreen( pRGB_Vert[y] );
585
                x = nWidth;
586
                while( x-- )
587
                {
588
                    aBitmapColor.SetRed( pRGB_Horiz[x] );
589
                    pWriteAccess->SetPixel( y, x, aBitmapColor );
590
                }
591
            }
592
            break;
593
        }
594
595
        mpBitmap->ReleaseAccess( pWriteAccess );
596
    }
597
}
598
599
// -----------------------------------------------------------------------
600
601
void ColorFieldControl::ShowPosition( const Point& rPos, bool bUpdate )
602
{
603
    if( !mpBitmap )
604
    {
605
        UpdateBitmap();
606
        Invalidate();
607
    }
608
609
    const Size aSize( mpBitmap->GetSizePixel() );
610
611
    long nX = rPos.X();
612
    long nY = rPos.Y();
613
    if( nX < 0L )
614
        nX = 0L;
615
    else if( nX >= aSize.Width() )
616
        nX = aSize.Width() - 1L;
617
618
    if( nY < 0L )
619
        nY= 0L;
620
    else if( nY >= aSize.Height() )
621
        nY = aSize.Height() - 1L;
622
623
    Point aPos = maPosition;
624
    maPosition.X() = nX - 5;
625
    maPosition.Y() = nY - 5;
626
    Invalidate( Rectangle( aPos, Size( 11, 11) ) );
627
    Invalidate( Rectangle( maPosition, Size( 11, 11) ) );
628
629
    if( bUpdate )
630
    {
631
        mdX = (double)nX / (double)(aSize.Width()-1);
632
        mdY = (double)(aSize.Height()-1-nY) / (double)(aSize.Height()-1);
633
634
        BitmapReadAccess* pReadAccess = mpBitmap->AcquireReadAccess();
635
        if( pReadAccess != NULL )
636
        {
637
            // mpBitmap always has a bit count of 24 => use of GetPixel(...) is safe
638
            maColor = pReadAccess->GetPixel( nY, nX );
639
            mpBitmap->ReleaseAccess( pReadAccess );
640
            pReadAccess = NULL;
641
        }
642
    }
643
}
644
// -----------------------------------------------------------------------
645
646
void ColorFieldControl::MouseMove( const MouseEvent& rMEvt )
647
{
648
    if( rMEvt.IsLeft() )
649
    {
650
        ShowPosition( rMEvt.GetPosPixel(), true );
651
        Modify();
652
    }
653
}
654
655
// -----------------------------------------------------------------------
656
void ColorFieldControl::MouseButtonDown( const MouseEvent& rMEvt )
657
{
658
    if( rMEvt.IsLeft() && !rMEvt.IsShift() )
659
    {
660
        CaptureMouse();
661
        ShowPosition( rMEvt.GetPosPixel(), true );
662
        Modify();
663
    }
664
}
665
666
// -----------------------------------------------------------------------
667
void ColorFieldControl::MouseButtonUp( const MouseEvent& )
668
{
669
    if( IsMouseCaptured() )
670
        ReleaseMouse();
671
}
672
673
// -----------------------------------------------------------------------
674
675
void ColorFieldControl::KeyMove( int dx, int dy )
676
{
677
    Size aSize( GetOutputSizePixel() );
678
    Point aPos( mdX * aSize.Width(), (1.0 - mdY) * aSize.Height() );
679
    aPos.X() += dx;
680
    aPos.Y() += dy;
681
    if( aPos.X() < 0 )
682
        aPos.X() += aSize.Width();
683
    else if( aPos.X() >= aSize.Width() )
684
        aPos.X() -= aSize.Width();
685
686
    if( aPos.Y() < 0 )
687
        aPos.Y() += aSize.Height();
688
    else if( aPos.Y() >= aSize.Height() )
689
        aPos.Y() -= aSize.Height();
690
691
    ShowPosition( aPos, true );
692
    Modify();
693
}
694
695
// -----------------------------------------------------------------------
696
697
void ColorFieldControl::KeyInput( const KeyEvent& rKEvt )
698
{
699
    bool   bShift = rKEvt.GetKeyCode().IsShift();
700
    bool   bCtrl = rKEvt.GetKeyCode().IsMod1();
701
    bool   bAlt = rKEvt.GetKeyCode().IsMod2();
702
703
    if ( !bAlt && !bShift )
704
    {
705
        switch( rKEvt.GetKeyCode().GetCode() )
706
        {
707
        case KEY_DOWN:      KeyMove(  0, bCtrl ?  5  :  1 ); return;
708
        case KEY_UP:        KeyMove(  0, bCtrl ? -5  : -1 ); return;
709
        case KEY_LEFT:      KeyMove( bCtrl ? -5  : -1,  0 ); return;
710
        case KEY_RIGHT:     KeyMove( bCtrl ?  5  :  1,  0 ); return;
711
        }
712
    }
713
    Control::KeyInput( rKEvt );
714
}
715
716
// -----------------------------------------------------------------------
717
718
void ColorFieldControl::Paint( const Rectangle& rRect )
719
{
720
    if( !mpBitmap )
721
        UpdateBitmap();
722
723
    Bitmap aOutputBitmap( *mpBitmap );
724
725
    if( GetBitCount() <= 8 )
726
        aOutputBitmap.Dither();
727
728
    DrawBitmap( rRect.TopLeft(), rRect.GetSize(), rRect.TopLeft(), rRect.GetSize(), aOutputBitmap );
729
730
    // draw circle around current color
731
    if( maColor.IsDark() )
732
        SetLineColor( COL_WHITE );
733
    else
734
        SetLineColor( COL_BLACK );
735
736
    SetFillColor();
737
738
    DrawEllipse( Rectangle( maPosition, Size( 11, 11) ) );
739
}
740
741
// -----------------------------------------------------------------------
742
743
void ColorFieldControl::Resize()
744
{
745
    UpdateBitmap();
746
    Control::Resize();
747
}
748
749
// -----------------------------------------------------------------------
750
751
void ColorFieldControl::Modify()
752
{
753
    maModifyHdl.Call( this );
754
}
755
756
// -----------------------------------------------------------------------
757
758
void ColorFieldControl::SetValues( Color aColor, ColorMode eMode, double x, double y )
759
{
760
    bool bUpdateBitmap = (maColor!= aColor) || (meMode != eMode);
761
    if( bUpdateBitmap || (mdX != x) || (mdY != y) )
762
    {
763
        maColor = aColor;
764
        meMode = eMode;
765
        mdX = x;
766
        mdY = y;
767
768
        if( bUpdateBitmap )
769
            UpdateBitmap();
770
        UpdatePosition();
771
        if( bUpdateBitmap )
772
            Invalidate();
773
    }
774
}
775
776
// -----------------------------------------------------------------------
777
778
double ColorFieldControl::GetX()
779
{
780
    return mdX;
781
}
782
783
// -----------------------------------------------------------------------
784
785
double ColorFieldControl::GetY()
786
{
787
    return mdY;
788
}
789
790
// -----------------------------------------------------------------------
791
792
void ColorFieldControl::UpdatePosition()
793
{
794
    Size aSize( GetOutputSizePixel() );
795
    ShowPosition( Point( mdX * aSize.Width(), (1.0 - mdY) * aSize.Height() ), false );
796
}
797
798
// ====================================================================
799
800
class ColorSliderControl : public Control
801
{
802
public:
803
    ColorSliderControl( Window* pParent, const ResId& rResId );
804
    ~ColorSliderControl();
805
806
    virtual void        MouseMove( const MouseEvent& rMEvt );
807
    virtual void        MouseButtonDown( const MouseEvent& rMEvt );
808
    virtual void        MouseButtonUp( const MouseEvent& rMEvt );
809
    virtual void        KeyInput( const KeyEvent& rKEvt );
810
    virtual void        Paint( const Rectangle& rRect );
811
    virtual void        Resize();
812
813
    void                UpdateBitmap();
814
    void                ChangePosition( long nY );
815
    void                Modify();
816
817
    void SetValue( const Color& rColor, ColorMode eMode, double dValue );
818
    double GetValue() const { return mdValue; }
819
820
    void                KeyMove( int dy );
821
822
    void SetModifyHdl( Link& rLink ) { maModifyHdl = rLink; }
823
824
    sal_Int16 GetLevel() const { return mnLevel; }
825
826
private:
827
    Link maModifyHdl;
828
    Color maColor;
829
    ColorMode meMode;
830
    Bitmap* mpBitmap;
831
    sal_Int16 mnLevel;
832
    double mdValue;
833
};
834
835
// -----------------------------------------------------------------------
836
837
ColorSliderControl::ColorSliderControl( Window* pParent, const ResId& rResId )
838
: Control( pParent, rResId )
839
, meMode( DefaultMode )
840
, mpBitmap( 0 )
841
, mnLevel( 0 )
842
, mdValue( -1.0 )
843
{
844
    SetControlBackground();
845
}
846
847
// -----------------------------------------------------------------------
848
849
ColorSliderControl::~ColorSliderControl()
850
{
851
    delete mpBitmap;
852
}
853
854
// -----------------------------------------------------------------------
855
856
void ColorSliderControl::UpdateBitmap()
857
{
858
    Size aSize( 1, GetOutputSizePixel().Height() );
859
860
    if( mpBitmap && mpBitmap->GetSizePixel() != aSize )
861
        delete mpBitmap, mpBitmap = NULL;
862
863
    if( !mpBitmap )
864
        mpBitmap = new Bitmap( aSize, 24 );
865
866
    BitmapWriteAccess* pWriteAccess = mpBitmap->AcquireWriteAccess();
867
868
    if( pWriteAccess )
869
    {
870
        const long nY = aSize.Height()-1;
871
872
        BitmapColor aBitmapColor( maColor );
873
874
        sal_uInt16 nHue, nSat, nBri;
875
        maColor.RGBtoHSB( nHue, nSat, nBri );
876
877
        // this has been unlooped for performance reason, please do not merge back!
878
879
        switch( meMode )
880
        {
881
        case HUE:
882
            nSat = 100;
883
            nBri = 100;
884
            for( long y = 0; y <= nY; y++ )
885
            {
886
                nHue = static_cast< sal_uInt16 >( (359 * y) / nY );
887
                aBitmapColor = BitmapColor( Color( Color::HSBtoRGB( nHue, nSat, nBri ) ) );
888
                pWriteAccess->SetPixel( nY-y, 0, aBitmapColor );
889
            }
890
            break;
891
892
        case SATURATION:
893
            nBri = std::max( (sal_uInt16)32, nBri );
894
            for( long y = 0; y <= nY; y++ )
895
            {
896
                nSat = static_cast< sal_uInt16 >( (100 * y) / nY );
897
                pWriteAccess->SetPixel( nY-y, 0, BitmapColor( Color( Color::HSBtoRGB( nHue, nSat, nBri ) ) ) );
898
            }
899
            break;
900
901
        case BRIGHTNESS:
902
            for( long y = 0; y <= nY; y++ )
903
            {
904
                nBri = static_cast< sal_uInt16 >( (100 * y) / nY );
905
                pWriteAccess->SetPixel( nY-y, 0, BitmapColor( Color( Color::HSBtoRGB( nHue, nSat, nBri ) ) ) );
906
            }
907
            break;
908
909
        case RED:
910
            for( long y = 0; y <= nY; y++ )
911
            {
912
                aBitmapColor.SetRed( sal_uInt8( ((long)255 * y) / nY ) );
913
                pWriteAccess->SetPixel( nY-y, 0, aBitmapColor );
914
            }
915
            break;
916
917
        case GREEN:
918
            for( long y = 0; y <= nY; y++ )
919
            {
920
                aBitmapColor.SetGreen( sal_uInt8( ((long)255 * y) / nY ) );
921
                pWriteAccess->SetPixel( nY-y, 0, aBitmapColor );
922
            }
923
            break;
924
925
        case BLUE:
926
            for( long y = 0; y <= nY; y++ )
927
            {
928
                aBitmapColor.SetBlue( sal_uInt8( ((long)255 * y) / nY ) );
929
                pWriteAccess->SetPixel( nY-y, 0, aBitmapColor );
930
            }
931
            break;
932
        }
933
934
        mpBitmap->ReleaseAccess( pWriteAccess );
935
    }
936
}
937
938
// -----------------------------------------------------------------------
939
940
void ColorSliderControl::ChangePosition( long nY )
941
{
942
    const long nHeight = GetOutputSizePixel().Height() - 1;
943
944
    if( nY < 0L )
945
        nY = 0;
946
    else if( nY > nHeight )
947
        nY = nHeight;
948
949
    mnLevel = nY;
950
    mdValue = ((double)(nHeight - nY)) / (double)nHeight;
951
}
952
953
// -----------------------------------------------------------------------
954
955
void ColorSliderControl::MouseMove( const MouseEvent& rMEvt )
956
{
957
    if( rMEvt.IsLeft() )
958
    {
959
        ChangePosition( rMEvt.GetPosPixel().Y() );
960
        Modify();
961
    }
962
}
963
964
// -----------------------------------------------------------------------
965
void ColorSliderControl::MouseButtonDown( const MouseEvent& rMEvt )
966
{
967
    if( rMEvt.IsLeft() && !rMEvt.IsShift() )
968
    {
969
        CaptureMouse();
970
        ChangePosition( rMEvt.GetPosPixel().Y() );
971
        Modify();
972
    }
973
}
974
975
// -----------------------------------------------------------------------
976
void ColorSliderControl::MouseButtonUp( const MouseEvent& )
977
{
978
    if( IsMouseCaptured() )
979
        ReleaseMouse();
980
}
981
982
// -----------------------------------------------------------------------
983
984
void ColorSliderControl::KeyMove( int dy )
985
{
986
    ChangePosition( mnLevel + dy );
987
    Modify();
988
}
989
990
// -----------------------------------------------------------------------
991
992
void ColorSliderControl::KeyInput( const KeyEvent& rKEvt )
993
{
994
    if ( !rKEvt.GetKeyCode().IsMod2() && !rKEvt.GetKeyCode().IsShift() )
995
    {
996
        switch( rKEvt.GetKeyCode().GetCode() )
997
        {
998
        case KEY_DOWN:      KeyMove(  rKEvt.GetKeyCode().IsMod1() ?  5 :  1 ); return;
999
        case KEY_UP:        KeyMove(  rKEvt.GetKeyCode().IsMod1() ? -5 : -1 ); return;
1000
        }
1001
    }
1002
1003
    Control::KeyInput( rKEvt );
1004
}
1005
// -----------------------------------------------------------------------
1006
1007
void ColorSliderControl::Paint( const Rectangle& /*rRect*/ )
1008
{
1009
    if( !mpBitmap )
1010
        UpdateBitmap();
1011
1012
    const Size aSize( GetOutputSizePixel() );
1013
1014
    Bitmap aOutputBitmap( *mpBitmap );
1015
1016
    if( GetBitCount() <= 8 )
1017
        aOutputBitmap.Dither();
1018
1019
    Point aPos;
1020
    int x = aSize.Width();
1021
    while( x-- )
1022
    {
1023
        DrawBitmap( aPos, aOutputBitmap );
1024
        aPos.X() += 1;
1025
    }
1026
}
1027
1028
// -----------------------------------------------------------------------
1029
1030
void ColorSliderControl::Resize()
1031
{
1032
    UpdateBitmap();
1033
    Control::Resize();
1034
}
1035
1036
// -----------------------------------------------------------------------
1037
1038
void ColorSliderControl::Modify()
1039
{
1040
    maModifyHdl.Call( this );
1041
}
1042
1043
// -----------------------------------------------------------------------
1044
1045
void ColorSliderControl::SetValue( const Color& rColor, ColorMode eMode, double dValue )
1046
{
1047
    bool bUpdateBitmap = (rColor != maColor) || (eMode != meMode);
1048
    if( bUpdateBitmap || (mdValue != dValue))
1049
    {
1050
        maColor = rColor;
1051
        mdValue = dValue;
1052
        mnLevel = (1.0-dValue) * GetOutputSizePixel().Height();
1053
        meMode = eMode;
1054
        if( bUpdateBitmap )
1055
            UpdateBitmap();
1056
        Invalidate();
1057
    }
1058
}
1059
1060
// ====================================================================
1061
1062
const sal_uInt16 UPDATE_RGB = 0x01;
1063
const sal_uInt16 UPDATE_CMYK = 0x02;
1064
const sal_uInt16 UPDATE_HSB = 0x04;
1065
const sal_uInt16 UPDATE_COLORCHOOSER = 0x08;
1066
const sal_uInt16 UPDATE_COLORSLIDER = 0x10;
1067
const sal_uInt16 UPDATE_HEX = 0x20;
1068
const sal_uInt16 UPDATE_ALL = 0xff;
1069
1070
class ColorPickerDialog : public ModalDialog
1071
{
1072
public:
1073
    ColorPickerDialog( Window* pParent, sal_Int32 nColor, sal_Int16 nMode );
1074
1075
    void update_color( sal_uInt16 n = UPDATE_ALL );
1076
1077
    DECL_LINK( ColorModifyHdl, void * );
1078
    DECL_LINK( ModeModifyHdl, void * );
1079
1080
    sal_Int32 GetColor() const;
1081
1082
    void setColorComponent( sal_uInt16 nComp, double dValue );
1083
1084
private:
1085
    Color maPreviousColor;
1086
    sal_Int16 mnDialogMode;
1087
    ColorMode meMode;
1088
1089
    double mdRed, mdGreen, mdBlue;
1090
    double mdHue, mdSat, mdBri;
1091
    double mdCyan, mdMagenta, mdYellow, mdKey;
1092
1093
private:
1094
    ColorFieldControl  maColorField;
1095
    ColorSliderControl maColorSlider;
1096
    ColorPreviewControl maColorPreview;
1097
    ColorPreviewControl maColorPrevious;
1098
1099
    FixedImage maFISliderLeft;
1100
    FixedImage maFISliderRight;
1101
    Image maSliderImage;
1102
1103
#if 0
1104
    ImageButton maBtnPicker;
1105
#endif
1106
1107
    FixedLine maFLRGB;
1108
1109
    RadioButton maRBRed;
1110
    RadioButton maRBGreen;
1111
    RadioButton maRBBlue;
1112
    RadioButton maRBHue;
1113
    RadioButton maRBSaturation;
1114
    RadioButton maRBBrightness;
1115
1116
    FixedText maFTRed;
1117
    MetricField maMFRed;
1118
    FixedText maFTGreen;
1119
    MetricField maMFGreen;
1120
    FixedText maFTBlue;
1121
    MetricField maMFBlue;
1122
    FixedText maFTHex;
1123
    HexColorControl maEDHex;
1124
1125
    FixedLine maFLHSB;
1126
    FixedText maFTHue;
1127
    MetricField maMFHue;
1128
    FixedText maFTSaturation;
1129
    MetricField maMFSaturation;
1130
    FixedText maFTBrightness;
1131
    MetricField maMFBrightness;
1132
1133
    FixedLine maFLCMYK;
1134
    FixedText maFTCyan;
1135
    MetricField maMFCyan;
1136
    FixedText maFTMagenta;
1137
    MetricField maMFMagenta;
1138
    FixedText maFTYellow;
1139
    MetricField maMFYellow;
1140
    FixedText maFTKey;
1141
    MetricField maMFKey;
1142
1143
    FixedLine maFLBottmLine;
1144
    HelpButton maBTNHelp;
1145
    OKButton maBTNOk;
1146
    CancelButton maBTNCancel;
1147
};
1148
1149
// --------------------------------------------------------------------
1150
1151
ColorPickerDialog::ColorPickerDialog( Window* pParent, sal_Int32 nColor, sal_Int16 nMode )
1152
: ModalDialog( pParent, CUI_RES( RID_CUI_DIALOG_COLORPICKER ) )
1153
, maPreviousColor( nColor )
1154
, mnDialogMode( nMode )
1155
, meMode( DefaultMode )
1156
, maColorField( this, CUI_RES( CT_COLORFIELD ) )
1157
, maColorSlider( this, CUI_RES( CT_COLORSLIDER ) )
1158
, maColorPreview( this, CUI_RES( CT_PREVIEW ) )
1159
, maColorPrevious( this, CUI_RES( CT_PREVIOUS ) )
1160
, maFISliderLeft(  this, CUI_RES( CT_LEFT_SLIDER ) )
1161
, maFISliderRight( this, CUI_RES( CT_RIGHT_SLIDER ) )
1162
, maSliderImage( CUI_RES( CT_SLIDERIMG ) )
1163
#if 0
1164
, maBtnPicker( this, CUI_RES( PB_PICKER ) )
1165
#endif
1166
, maFLRGB( this, CUI_RES( FL_RGB ) )
1167
, maRBRed( this, CUI_RES( CT_RED ) )
1168
, maRBGreen( this, CUI_RES( CT_GREEN ) )
1169
, maRBBlue( this, CUI_RES( CT_BLUE ) )
1170
, maRBHue( this, CUI_RES( CT_HUE ) )
1171
, maRBSaturation( this, CUI_RES( CT_SATURATION ) )
1172
, maRBBrightness( this, CUI_RES( CT_BRIGHTNESS ) )
1173
, maFTRed( this, CUI_RES( CT_RED ) )
1174
, maMFRed( this, CUI_RES( CT_RED ) )
1175
, maFTGreen( this, CUI_RES( CT_GREEN ) )
1176
, maMFGreen( this, CUI_RES( CT_GREEN ) )
1177
, maFTBlue( this, CUI_RES( CT_BLUE ) )
1178
, maMFBlue( this, CUI_RES( CT_BLUE ) )
1179
, maFTHex( this, CUI_RES( CT_HEX ) )
1180
, maEDHex( this, CUI_RES( CT_HEX ) )
1181
, maFLHSB( this, CUI_RES( FL_HSB ) )
1182
, maFTHue( this, CUI_RES( CT_HUE ) )
1183
, maMFHue( this, CUI_RES( CT_HUE ) )
1184
, maFTSaturation( this, CUI_RES( CT_SATURATION ) )
1185
, maMFSaturation( this, CUI_RES( CT_SATURATION ) )
1186
, maFTBrightness( this, CUI_RES( CT_BRIGHTNESS ) )
1187
, maMFBrightness( this, CUI_RES( CT_BRIGHTNESS ) )
1188
, maFLCMYK( this, CUI_RES( FL_CMYK ) )
1189
, maFTCyan( this, CUI_RES( CT_CYAN ) )
1190
, maMFCyan( this, CUI_RES( CT_CYAN ) )
1191
, maFTMagenta( this, CUI_RES( CT_MAGENTA ) )
1192
, maMFMagenta( this, CUI_RES( CT_MAGENTA ) )
1193
, maFTYellow( this, CUI_RES( CT_YELLOW ) )
1194
, maMFYellow( this, CUI_RES( CT_YELLOW ) )
1195
, maFTKey( this, CUI_RES( CT_KEY ) )
1196
, maMFKey( this, CUI_RES( CT_KEY ) )
1197
1198
, maFLBottmLine( this, CUI_RES( FT_BOTTOMLINE ) )
1199
, maBTNHelp( this, CUI_RES( BTN_HELP ) )
1200
, maBTNOk( this, CUI_RES( BTN_OK ) )
1201
, maBTNCancel( this, CUI_RES( BTN_CANCEL ) )
1202
{
1203
    FreeResource();
1204
1205
    String sUnitText;
1206
    sUnitText.Append( ' ' );
1207
    sUnitText.Append( (sal_Unicode) 0xb0 );
1208
1209
    maMFHue.SetCustomUnitText( sUnitText );
1210
1211
    Link aLink( LINK( this, ColorPickerDialog, ColorModifyHdl ) );
1212
    maColorField.SetModifyHdl( aLink );
1213
    maColorSlider.SetModifyHdl( aLink );
1214
1215
    maMFRed.SetModifyHdl( aLink );
1216
    maMFGreen.SetModifyHdl( aLink );
1217
    maMFBlue.SetModifyHdl( aLink );
1218
1219
    maMFCyan.SetModifyHdl( aLink );
1220
    maMFMagenta.SetModifyHdl( aLink );
1221
    maMFYellow.SetModifyHdl( aLink );
1222
    maMFKey.SetModifyHdl( aLink );
1223
1224
    maMFHue.SetModifyHdl( aLink );
1225
    maMFSaturation.SetModifyHdl( aLink );
1226
    maMFBrightness.SetModifyHdl( aLink );
1227
1228
    maEDHex.SetModifyHdl( aLink );
1229
1230
    aLink = LINK( this, ColorPickerDialog, ModeModifyHdl );
1231
    maRBRed.SetToggleHdl( aLink );
1232
    maRBGreen.SetToggleHdl( aLink );
1233
    maRBBlue.SetToggleHdl( aLink );
1234
    maRBHue.SetToggleHdl( aLink );
1235
    maRBSaturation.SetToggleHdl( aLink );
1236
    maRBBrightness.SetToggleHdl( aLink );
1237
1238
    Image aSliderImage( maSliderImage );
1239
1240
    maFISliderLeft.SetImage( aSliderImage );
1241
1242
    BitmapEx aTmpBmp( maSliderImage.GetBitmapEx() );
1243
    aTmpBmp.Mirror( BMP_MIRROR_HORZ );
1244
    maFISliderRight.SetImage( Image( aTmpBmp  ) );
1245
1246
    Size aSize( maSliderImage.GetSizePixel() );
1247
    maFISliderLeft.SetSizePixel( aSize );
1248
    maFISliderRight.SetSizePixel( aSize );
1249
1250
    Point aPos( maColorSlider.GetPosPixel() );
1251
1252
    aPos.X() -= aSize.Width();
1253
    aPos.Y() -= aSize.Height() / 2;
1254
    maFISliderLeft.SetPosPixel( aPos );
1255
1256
    aPos.X() += aSize.Width() + maColorSlider.GetSizePixel().Width();
1257
    maFISliderRight.SetPosPixel( aPos );
1258
1259
    Color aColor( nColor );
1260
1261
    // modify
1262
    if( mnDialogMode == 2 )
1263
    {
1264
        maColorPreview.SetSizePixel( maColorPrevious.GetSizePixel() );
1265
        maColorPrevious.SetColor( aColor );
1266
        maColorPrevious.Show( true );
1267
    }
1268
1269
    mdRed = ((double)aColor.GetRed()) / 255.0;
1270
    mdGreen = ((double)aColor.GetGreen()) / 255.0;
1271
    mdBlue = ((double)aColor.GetBlue()) / 255.0;
1272
1273
    RGBtoHSV( mdRed, mdGreen, mdBlue, mdHue, mdSat, mdBri );
1274
    RGBtoCMYK( mdRed, mdGreen, mdBlue, mdCyan, mdMagenta, mdYellow, mdKey );
1275
1276
    update_color();
1277
}
1278
1279
// --------------------------------------------------------------------
1280
1281
static int toInt( double dValue, double bRange )
1282
{
1283
    return static_cast< int >( std::floor((dValue * bRange) + 0.5 ) );
1284
}
1285
1286
sal_Int32 ColorPickerDialog::GetColor() const
1287
{
1288
    return Color( toInt(mdRed,255.0), toInt(mdGreen,255.0), toInt(mdBlue,255.0) ).GetColor();
1289
}
1290
1291
void ColorPickerDialog::update_color( sal_uInt16 n )
1292
{
1293
    sal_uInt8 nRed = toInt(mdRed,255.0);
1294
    sal_uInt8 nGreen = toInt(mdGreen,255.0);
1295
    sal_uInt8 nBlue = toInt(mdBlue,255.0);
1296
1297
    Color aColor( nRed, nGreen, nBlue );
1298
1299
    if( n & UPDATE_RGB ) // update RGB
1300
    {
1301
        maMFRed.SetValue( nRed );
1302
        maMFGreen.SetValue( nGreen );
1303
        maMFBlue.SetValue( nBlue );
1304
    }
1305
1306
    if( n & UPDATE_CMYK ) // update CMYK
1307
    {
1308
        maMFCyan.SetValue( toInt( mdCyan, 100.0 ) );
1309
        maMFMagenta.SetValue( toInt( mdMagenta, 100.0 ) );
1310
        maMFYellow.SetValue( toInt( mdYellow, 100.0 ) );
1311
        maMFKey.SetValue( toInt( mdKey, 100.0 ) );
1312
    }
1313
1314
    if( n & UPDATE_HSB ) // update HSB
1315
    {
1316
        maMFHue.SetValue( toInt( mdHue, 1.0 ) );
1317
        maMFSaturation.SetValue( toInt( mdSat, 100.0 ) );
1318
        maMFBrightness.SetValue( toInt( mdBri, 100.0 ) );
1319
    }
1320
1321
    if( n & UPDATE_COLORCHOOSER ) // update Color Chooser 1
1322
    {
1323
        switch( meMode )
1324
        {
1325
        case HUE:           maColorField.SetValues( aColor, meMode, mdSat, mdBri ); break;
1326
        case SATURATION:    maColorField.SetValues( aColor, meMode, mdHue / 360.0, mdBri ); break;
1327
        case BRIGHTNESS:    maColorField.SetValues( aColor, meMode, mdHue / 360.0, mdSat ); break;
1328
        case RED:           maColorField.SetValues( aColor, meMode, mdBlue, mdGreen ); break;
1329
        case GREEN:         maColorField.SetValues( aColor, meMode, mdBlue, mdRed ); break;
1330
        case BLUE:          maColorField.SetValues( aColor, meMode, mdRed, mdGreen ); break;
1331
        }
1332
    }
1333
1334
    if( n & UPDATE_COLORSLIDER ) // update Color Chooser 2
1335
    {
1336
        switch( meMode )
1337
        {
1338
        case HUE:           maColorSlider.SetValue( aColor, meMode, mdHue / 360.0 ); break;
1339
        case SATURATION:    maColorSlider.SetValue( aColor, meMode, mdSat ); break;
1340
        case BRIGHTNESS:    maColorSlider.SetValue( aColor, meMode, mdBri ); break;
1341
        case RED:           maColorSlider.SetValue( aColor, meMode, mdRed ); break;
1342
        case GREEN:         maColorSlider.SetValue( aColor, meMode, mdGreen ); break;
1343
        case BLUE:          maColorSlider.SetValue( aColor, meMode, mdBlue ); break;
1344
        }
1345
    }
1346
1347
    if( n & UPDATE_HEX ) // update hex
1348
    {
1349
        maEDHex.SetColor( aColor.GetColor()  );
1350
    }
1351
1352
    {
1353
        Point aPos( 0, maColorSlider.GetLevel() + maColorSlider.GetPosPixel().Y() - 1 );
1354
1355
        aPos.X() = maFISliderLeft.GetPosPixel().X();
1356
        if( aPos != maFISliderLeft.GetPosPixel() )
1357
        {
1358
            maFISliderLeft.SetPosPixel( aPos );
1359
1360
            aPos.X() = maFISliderRight.GetPosPixel().X();
1361
            maFISliderRight.SetPosPixel( aPos );
1362
        }
1363
    }
1364
1365
    maColorPreview.SetColor( aColor );
1366
}
1367
1368
// --------------------------------------------------------------------
1369
1370
IMPL_LINK( ColorPickerDialog, ColorModifyHdl, void *, p )
1371
{
1372
    sal_uInt16 n = 0;
1373
1374
    if( p == &maColorField )
1375
    {
1376
        double x = maColorField.GetX();
1377
        double y = maColorField.GetY();
1378
1379
        switch( meMode )
1380
        {
1381
        case HUE:           mdSat = x; setColorComponent( COLORCOMP_BRI, y ); break;
1382
        case SATURATION:    mdHue = x * 360.0; setColorComponent( COLORCOMP_BRI, y ); break;
1383
        case BRIGHTNESS:    mdHue = x * 360.0; setColorComponent( COLORCOMP_SAT, y ); break;
1384
        case RED:           mdBlue = x; setColorComponent( COLORCOMP_GREEN, y ); break;
1385
        case GREEN:         mdBlue = x; setColorComponent( COLORCOMP_RED, y ); break;
1386
        case BLUE:          mdRed = x; setColorComponent( COLORCOMP_GREEN, y ); break;
1387
        }
1388
1389
        n = UPDATE_ALL&~(UPDATE_COLORCHOOSER);
1390
    }
1391
    else if( p == &maColorSlider )
1392
    {
1393
        double dValue = maColorSlider.GetValue();
1394
        switch( meMode )
1395
        {
1396
        case HUE:           setColorComponent( COLORCOMP_HUE, dValue * 360.0 ); break;
1397
        case SATURATION:    setColorComponent( COLORCOMP_SAT, dValue ); break;
1398
        case BRIGHTNESS:    setColorComponent( COLORCOMP_BRI, dValue ); break;
1399
        case RED:           setColorComponent( COLORCOMP_RED, dValue ); break;
1400
        case GREEN:         setColorComponent( COLORCOMP_GREEN, dValue ); break;
1401
        case BLUE:          setColorComponent( COLORCOMP_BLUE, dValue ); break;
1402
        }
1403
1404
        n = UPDATE_ALL&~(UPDATE_COLORSLIDER);
1405
    }
1406
    else if( p == &maMFRed )
1407
    {
1408
        setColorComponent( COLORCOMP_RED, ((double)maMFRed.GetValue()) / 255.0 );
1409
        n = UPDATE_ALL&~(UPDATE_RGB);
1410
    }
1411
    else if( p == &maMFGreen )
1412
    {
1413
        setColorComponent( COLORCOMP_GREEN, ((double)maMFGreen.GetValue()) / 255.0 );
1414
        n = UPDATE_ALL&~(UPDATE_RGB);
1415
    }
1416
    else if( p == &maMFBlue )
1417
    {
1418
        setColorComponent( COLORCOMP_BLUE, ((double)maMFBlue.GetValue()) / 255.0 );
1419
        n = UPDATE_ALL&~(UPDATE_RGB);
1420
    }
1421
    else if( p == &maMFHue )
1422
    {
1423
        setColorComponent( COLORCOMP_HUE, (double)maMFHue.GetValue() );
1424
        n = UPDATE_ALL&~(UPDATE_HSB);
1425
    }
1426
    else if( p == &maMFSaturation )
1427
    {
1428
        setColorComponent( COLORCOMP_SAT, ((double)maMFSaturation.GetValue()) / 100.0 );
1429
        n = UPDATE_ALL&~(UPDATE_HSB);
1430
    }
1431
    else if( p == &maMFBrightness )
1432
    {
1433
        setColorComponent( COLORCOMP_BRI, ((double)maMFBrightness.GetValue()) / 100.0 );
1434
        n = UPDATE_ALL&~(UPDATE_HSB);
1435
    }
1436
    else if( p == &maMFCyan )
1437
    {
1438
        setColorComponent( COLORCOMP_CYAN, ((double)maMFCyan.GetValue()) / 100.0 );
1439
        n = UPDATE_ALL&~(UPDATE_CMYK);
1440
    }
1441
    else if( p == &maMFMagenta )
1442
    {
1443
        setColorComponent( COLORCOMP_MAGENTA, ((double)maMFMagenta.GetValue()) / 100.0 );
1444
        n = UPDATE_ALL&~(UPDATE_CMYK);
1445
    }
1446
    else if( p == &maMFYellow )
1447
    {
1448
        setColorComponent( COLORCOMP_YELLOW, ((double)maMFYellow.GetValue()) / 100.0 );
1449
        n = UPDATE_ALL&~(UPDATE_CMYK);
1450
    }
1451
    else if( p == &maMFKey )
1452
    {
1453
        setColorComponent( COLORCOMP_KEY, ((double)maMFKey.GetValue()) / 100.0 );
1454
        n = UPDATE_ALL&~(UPDATE_CMYK);
1455
    }
1456
    else if( p == &maEDHex )
1457
    {
1458
        sal_Int32 nColor = maEDHex.GetColor();
1459
1460
        if( nColor != -1 )
1461
        {
1462
            Color aColor( nColor );
1463
1464
            if( aColor != GetColor() )
1465
            {
1466
                mdRed = ((double)aColor.GetRed()) / 255.0;
1467
                mdGreen = ((double)aColor.GetRed()) / 255.0;
1468
                mdBlue = ((double)aColor.GetRed()) / 255.0;
1469
1470
                RGBtoHSV( mdRed, mdGreen, mdBlue, mdHue, mdSat, mdBri );
1471
                RGBtoCMYK( mdRed, mdGreen, mdBlue, mdCyan, mdMagenta, mdYellow, mdKey );
1472
                n = UPDATE_ALL&~(UPDATE_HEX);
1473
            }
1474
        }
1475
    }
1476
1477
    if( n )
1478
        update_color( n );
1479
1480
    return 0;
1481
}
1482
1483
// --------------------------------------------------------------------
1484
1485
IMPL_LINK( ColorPickerDialog, ModeModifyHdl, void *, EMPTYARG )
1486
{
1487
    ColorMode eMode = HUE;
1488
1489
    if( maRBRed.IsChecked() )
1490
    {
1491
        eMode = RED;
1492
    }
1493
    else if( maRBGreen.IsChecked() )
1494
    {
1495
        eMode = GREEN;
1496
    }
1497
    else if( maRBBlue.IsChecked() )
1498
    {
1499
        eMode = BLUE;
1500
    }
1501
    else if( maRBSaturation.IsChecked() )
1502
    {
1503
        eMode = SATURATION;
1504
    }
1505
    else if( maRBBrightness.IsChecked() )
1506
    {
1507
        eMode = BRIGHTNESS;
1508
    }
1509
1510
    if( meMode != eMode )
1511
    {
1512
        meMode = eMode;
1513
        update_color( UPDATE_COLORCHOOSER | UPDATE_COLORSLIDER );
1514
    }
1515
1516
    return 0;
1517
}
1518
1519
// --------------------------------------------------------------------
1520
1521
void ColorPickerDialog::setColorComponent( sal_uInt16 nComp, double dValue )
1522
{
1523
    switch( nComp )
1524
    {
1525
    case COLORCOMP_RED:     mdRed = dValue; break;
1526
    case COLORCOMP_GREEN:   mdGreen = dValue; break;
1527
    case COLORCOMP_BLUE:    mdBlue = dValue; break;
1528
    case COLORCOMP_HUE:     mdHue = dValue; break;
1529
    case COLORCOMP_SAT:     mdSat = dValue; break;
1530
    case COLORCOMP_BRI:     mdBri = dValue; break;
1531
    case COLORCOMP_CYAN:    mdCyan = dValue; break;
1532
    case COLORCOMP_YELLOW:  mdYellow = dValue; break;
1533
    case COLORCOMP_MAGENTA: mdMagenta = dValue; break;
1534
    case COLORCOMP_KEY:     mdKey = dValue; break;
1535
    }
1536
1537
    if( nComp & COLORMODE_RGB )
1538
    {
1539
        RGBtoHSV( mdRed, mdGreen, mdBlue, mdHue, mdSat, mdBri );
1540
        RGBtoCMYK( mdRed, mdGreen, mdBlue, mdCyan, mdMagenta, mdYellow, mdKey );
1541
    }
1542
    else if( nComp & COLORMODE_HSV )
1543
    {
1544
        HSVtoRGB( mdHue, mdSat, mdBri, mdRed, mdGreen, mdBlue );
1545
        RGBtoCMYK( mdRed, mdGreen, mdBlue, mdCyan, mdMagenta, mdYellow, mdKey );
1546
    }
1547
    else
1548
    {
1549
        CMYKtoRGB( mdCyan, mdMagenta, mdYellow, mdKey, mdRed, mdGreen, mdBlue );
1550
        RGBtoHSV( mdRed, mdGreen, mdBlue, mdHue, mdSat, mdBri );
1551
    }
1552
}
1553
1554
// --------------------------------------------------------------------
1555
1556
typedef ::cppu::WeakComponentImplHelper4< XServiceInfo, XExecutableDialog, XInitialization, XPropertyAccess > ColorPickerBase;
1557
1558
class ColorPicker : protected ::comphelper::OBaseMutex,    // Struct for right initalization of mutex member! Must be first of baseclasses.
1559
                    public ColorPickerBase
1560
{
1561
public:
1562
    ColorPicker( Reference< XComponentContext > const & xContext );
1563
1564
    // XInitialization
1565
    virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException);
1566
1567
    // XInitialization
1568
    virtual OUString SAL_CALL getImplementationName(  ) throw (RuntimeException);
1569
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException);
1570
    virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) throw (RuntimeException);
1571
1572
    // XPropertyAccess
1573
    virtual Sequence< PropertyValue > SAL_CALL getPropertyValues(  ) throw (RuntimeException);
1574
    virtual void SAL_CALL setPropertyValues( const Sequence< PropertyValue >& aProps ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException);
1575
1576
    // XExecutableDialog
1577
    virtual void SAL_CALL setTitle( const OUString& aTitle ) throw (RuntimeException);
1578
    virtual sal_Int16 SAL_CALL execute(  ) throw (RuntimeException);
1579
1580
private:
1581
    Reference< XComponentContext > mxContext;
1582
    OUString msTitle;
1583
    const OUString msColorKey;
1584
    const OUString msModeKey;
1585
    sal_Int32 mnColor;
1586
    sal_Int16 mnMode;
1587
    Reference< ::com::sun::star::awt::XWindow > mxParent;
1588
};
1589
1590
// --------------------------------------------------------------------
1591
1592
OUString SAL_CALL ColorPicker_getImplementationName()
1593
{
1594
    return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.cui.ColorPicker" ) );
1595
}
1596
1597
// --------------------------------------------------------------------
1598
1599
Reference< XInterface > SAL_CALL ColorPicker_createInstance( Reference< XComponentContext > const & xContext ) SAL_THROW( (Exception) )
1600
{
1601
    return static_cast<XWeak*>( new ColorPicker( xContext ) );
1602
}
1603
1604
// --------------------------------------------------------------------
1605
1606
Sequence< OUString > SAL_CALL ColorPicker_getSupportedServiceNames() throw( RuntimeException )
1607
{
1608
    Sequence< OUString > seq(1);
1609
    seq[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.ColorPicker" ) );
1610
    return seq;
1611
}
1612
1613
// --------------------------------------------------------------------
1614
1615
ColorPicker::ColorPicker( Reference< XComponentContext > const & xContext )
1616
: ColorPickerBase( m_aMutex )
1617
, mxContext( xContext )
1618
, msColorKey( RTL_CONSTASCII_USTRINGPARAM( "Color" ) )
1619
, msModeKey( RTL_CONSTASCII_USTRINGPARAM( "Mode" ) )
1620
, mnColor( 0 )
1621
, mnMode( 0 )
1622
{
1623
}
1624
1625
// --------------------------------------------------------------------
1626
1627
// XInitialization
1628
void SAL_CALL ColorPicker::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException)
1629
{
1630
    if( aArguments.getLength() == 1 )
1631
    {
1632
        aArguments[0] >>= mxParent;
1633
    }
1634
}
1635
1636
// --------------------------------------------------------------------
1637
1638
// XInitialization
1639
OUString SAL_CALL ColorPicker::getImplementationName(  ) throw (RuntimeException)
1640
{
1641
    return ColorPicker_getImplementationName();
1642
}
1643
1644
// --------------------------------------------------------------------
1645
1646
sal_Bool SAL_CALL ColorPicker::supportsService( const OUString& sServiceName ) throw (RuntimeException)
1647
{
1648
    return sServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.ui.dialogs.ColorPicker" ) );
1649
}
1650
1651
// --------------------------------------------------------------------
1652
1653
Sequence< OUString > SAL_CALL ColorPicker::getSupportedServiceNames(  ) throw (RuntimeException)
1654
{
1655
    return ColorPicker_getSupportedServiceNames();
1656
}
1657
1658
// --------------------------------------------------------------------
1659
1660
// XPropertyAccess
1661
Sequence< PropertyValue > SAL_CALL ColorPicker::getPropertyValues(  ) throw (RuntimeException)
1662
{
1663
    Sequence< PropertyValue > props(1);
1664
    props[0].Name = msColorKey;
1665
    props[0].Value <<= mnColor;
1666
    return props;
1667
}
1668
1669
// --------------------------------------------------------------------
1670
1671
void SAL_CALL ColorPicker::setPropertyValues( const Sequence< PropertyValue >& aProps ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
1672
{
1673
    for( sal_Int32 n = 0; n < aProps.getLength(); n++ )
1674
    {
1675
        if( aProps[n].Name.equals( msColorKey ) )
1676
        {
1677
            aProps[n].Value >>= mnColor;
1678
        }
1679
        else if( aProps[n].Name.equals( msModeKey ) )
1680
        {
1681
            aProps[n].Value >>= mnMode;
1682
        }
1683
    }
1684
}
1685
1686
// --------------------------------------------------------------------
1687
1688
// XExecutableDialog
1689
void SAL_CALL ColorPicker::setTitle( const OUString& sTitle ) throw (RuntimeException)
1690
{
1691
    msTitle = sTitle;
1692
}
1693
1694
// --------------------------------------------------------------------
1695
1696
sal_Int16 SAL_CALL ColorPicker::execute(  ) throw (RuntimeException)
1697
{
1698
    ColorPickerDialog aDlg( VCLUnoHelper::GetWindow( mxParent ), mnColor, mnMode );
1699
    sal_Int16 ret = aDlg.Execute();
1700
    if( ret )
1701
        mnColor = aDlg.GetColor();
1702
1703
    return ret;
1704
}
1705
1706
// --------------------------------------------------------------------
1707
1708
}
1709
1710
// eof
1711
*
(-)main/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
	{
(-)main/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
(-)main/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
(-)main/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
(-)main/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
(-)main/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
};
(-)main/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 )
(-)main/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 );
(-)main/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 \
(-)main/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))
(-)main/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 \
(-)main/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 \
(-)main/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
(-)main/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
(-)main/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
(-)main/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
(-)main/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
(-)main/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