LibreOffice Module cui (master)  1
colorpicker.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <com/sun/star/uno/XComponentContext.hpp>
21 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
22 #include <com/sun/star/beans/XPropertyAccess.hpp>
23 #include <com/sun/star/lang/XInitialization.hpp>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
25 #include <com/sun/star/awt/XWindow.hpp>
26 #include <cppuhelper/compbase.hxx>
28 #include <cppuhelper/basemutex.hxx>
29 #include <vcl/customweld.hxx>
30 #include <vcl/event.hxx>
31 #include <vcl/svapp.hxx>
32 #include <vcl/virdev.hxx>
33 #include <vcl/weld.hxx>
34 #include <svx/hexcolorcontrol.hxx>
36 #include <colorpicker.hxx>
37 #include <cmath>
38 #include <o3tl/typed_flags_set.hxx>
39 
40 using namespace ::com::sun::star::uno;
41 using namespace ::com::sun::star::lang;
42 using namespace ::com::sun::star::ui::dialogs;
43 using namespace ::com::sun::star::beans;
44 using namespace ::basegfx;
45 
46 namespace {
47 
48 enum class UpdateFlags
49 {
50  NONE = 0x00,
51  RGB = 0x01,
52  CMYK = 0x02,
53  HSB = 0x04,
54  ColorChooser = 0x08,
55  ColorSlider = 0x10,
56  Hex = 0x20,
57  All = 0x3f,
58 };
59 
60 }
61 
62 namespace o3tl {
63  template<> struct typed_flags<UpdateFlags> : is_typed_flags<UpdateFlags, 0x3f> {};
64 }
65 
66 
67 namespace cui
68 {
69 
70 namespace {
71 
72 enum class ColorComponent {
73  Red,
74  Green,
75  Blue,
76  Hue,
77  Saturation,
78  Brightness,
79  Cyan,
80  Yellow,
81  Magenta,
82  Key,
83 };
84 
85 }
86 
87 // color space conversion helpers
88 
89 static void RGBtoHSV( double dR, double dG, double dB, double& dH, double& dS, double& dV )
90 {
91  BColor result = basegfx::utils::rgb2hsv( BColor( dR, dG, dB ) );
92 
93  dH = result.getX();
94  dS = result.getY();
95  dV = result.getZ();
96 }
97 
98 static void HSVtoRGB(double dH, double dS, double dV, double& dR, double& dG, double& dB )
99 {
100  BColor result = basegfx::utils::hsv2rgb( BColor( dH, dS, dV ) );
101 
102  dR = result.getRed();
103  dG = result.getGreen();
104  dB = result.getBlue();
105 }
106 
107 // CMYK values from 0 to 1
108 static void CMYKtoRGB( double fCyan, double fMagenta, double fYellow, double fKey, double& dR, double& dG, double& dB )
109 {
110  fCyan = (fCyan * ( 1.0 - fKey )) + fKey;
111  fMagenta = (fMagenta * ( 1.0 - fKey )) + fKey;
112  fYellow = (fYellow * ( 1.0 - fKey )) + fKey;
113 
114  dR = std::max( std::min( ( 1.0 - fCyan ), 1.0), 0.0 );
115  dG = std::max( std::min( ( 1.0 - fMagenta ), 1.0), 0.0 );
116  dB = std::max( std::min( ( 1.0 - fYellow ), 1.0), 0.0 );
117 }
118 
119 // CMY results from 0 to 1
120 static void RGBtoCMYK( double dR, double dG, double dB, double& fCyan, double& fMagenta, double& fYellow, double& fKey )
121 {
122  fCyan = 1 - dR;
123  fMagenta = 1 - dG;
124  fYellow = 1 - dB;
125 
126  //CMYK and CMY values from 0 to 1
127  fKey = 1.0;
128  if( fCyan < fKey ) fKey = fCyan;
129  if( fMagenta < fKey ) fKey = fMagenta;
130  if( fYellow < fKey ) fKey = fYellow;
131 
132  if( fKey >= 1.0 )
133  {
134  //Black
135  fCyan = 0.0;
136  fMagenta = 0.0;
137  fYellow = 0.0;
138  }
139  else
140  {
141  fCyan = ( fCyan - fKey ) / ( 1.0 - fKey );
142  fMagenta = ( fMagenta - fKey ) / ( 1.0 - fKey );
143  fYellow = ( fYellow - fKey ) / ( 1.0 - fKey );
144  }
145 }
146 
147 namespace {
148 
149 class ColorPreviewControl : public weld::CustomWidgetController
150 {
151 private:
153 
154  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
155 public:
156  ColorPreviewControl()
157  {
158  }
159 
160  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
161  {
162  CustomWidgetController::SetDrawingArea(pDrawingArea);
163  pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 10,
164  pDrawingArea->get_text_height() * 2);
165  }
166 
167  void SetColor(const Color& rCol)
168  {
169  if (rCol != m_aColor)
170  {
171  m_aColor = rCol;
172  Invalidate();
173  }
174  }
175 };
176 
177 }
178 
179 void ColorPreviewControl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
180 {
181  rRenderContext.SetFillColor(m_aColor);
182  rRenderContext.SetLineColor(m_aColor);
183  rRenderContext.DrawRect(tools::Rectangle(Point(0, 0), GetOutputSizePixel()));
184 }
185 
186 namespace {
187 
188 enum ColorMode { HUE, SATURATION, BRIGHTNESS, RED, GREEN, BLUE };
189 
190 }
191 
192 const ColorMode DefaultMode = HUE;
193 
194 namespace {
195 
196 class ColorFieldControl : public weld::CustomWidgetController
197 {
198 public:
199  ColorFieldControl()
200  : meMode( DefaultMode )
201  , mdX( -1.0 )
202  , mdY( -1.0 )
203  , mbMouseCaptured(false)
204  {
205  }
206 
207  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
208  {
209  CustomWidgetController::SetDrawingArea(pDrawingArea);
210  pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 40,
211  pDrawingArea->get_text_height() * 10);
212  }
213 
214  virtual ~ColorFieldControl() override
215  {
217  }
218 
219  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
220  virtual void Resize() override;
221  virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
222  virtual bool MouseMove(const MouseEvent& rMEvt) override;
223  virtual bool MouseButtonUp(const MouseEvent& rMEvt) override;
224 
225  void UpdateBitmap();
226  void ShowPosition( const Point& rPos, bool bUpdate );
227  void UpdatePosition();
228  void Modify();
229 
230  void SetValues(Color aColor, ColorMode eMode, double x, double y);
231  double GetX() const { return mdX;}
232  double GetY() const { return mdY;}
233 
234  void SetModifyHdl(const Link<ColorFieldControl&,void>& rLink) { maModifyHdl = rLink; }
235 
236 private:
237  ColorMode meMode;
239  double mdX;
240  double mdY;
245  std::vector<sal_uInt8> maRGB_Horiz;
246  std::vector<sal_uInt16> maGrad_Horiz;
247  std::vector<sal_uInt16> maPercent_Horiz;
248  std::vector<sal_uInt8> maRGB_Vert;
249  std::vector<sal_uInt16> maPercent_Vert;
250 };
251 
252 }
253 
254 void ColorFieldControl::UpdateBitmap()
255 {
256  const Size aSize(GetOutputSizePixel());
257 
258  if (mxBitmap && mxBitmap->GetOutputSizePixel() != aSize)
260 
261  const sal_Int32 nWidth = aSize.Width();
262  const sal_Int32 nHeight = aSize.Height();
263 
264  if (nWidth == 0 || nHeight == 0)
265  return;
266 
267  if (!mxBitmap)
268  {
271 
272  maRGB_Horiz.resize( nWidth );
273  maGrad_Horiz.resize( nWidth );
274  maPercent_Horiz.resize( nWidth );
275 
276  sal_uInt8* pRGB = maRGB_Horiz.data();
277  sal_uInt16* pGrad = maGrad_Horiz.data();
278  sal_uInt16* pPercent = maPercent_Horiz.data();
279 
280  for( sal_Int32 x = 0; x < nWidth; x++ )
281  {
282  *pRGB++ = static_cast<sal_uInt8>((x * 256) / nWidth);
283  *pGrad++ = static_cast<sal_uInt16>((x * 359) / nWidth);
284  *pPercent++ = static_cast<sal_uInt16>((x * 100) / nWidth);
285  }
286 
287  maRGB_Vert.resize(nHeight);
288  maPercent_Vert.resize(nHeight);
289 
290  pRGB = maRGB_Vert.data();
291  pPercent = maPercent_Vert.data();
292 
293  sal_Int32 y = nHeight;
294  while (y--)
295  {
296  *pRGB++ = static_cast<sal_uInt8>((y * 256) / nHeight);
297  *pPercent++ = static_cast<sal_uInt16>((y * 100) / nHeight);
298  }
299  }
300 
301  sal_uInt8* pRGB_Horiz = maRGB_Horiz.data();
302  sal_uInt16* pGrad_Horiz = maGrad_Horiz.data();
303  sal_uInt16* pPercent_Horiz = maPercent_Horiz.data();
304  sal_uInt8* pRGB_Vert = maRGB_Vert.data();
305  sal_uInt16* pPercent_Vert = maPercent_Vert.data();
306 
307  Color aBitmapColor(maColor);
308 
309  sal_uInt16 nHue, nSat, nBri;
310  maColor.RGBtoHSB(nHue, nSat, nBri);
311 
312  // this has been unlooped for performance reason, please do not merge back!
313 
314  sal_uInt16 y = nHeight,x;
315 
316  switch(meMode)
317  {
318  case HUE:
319  while (y--)
320  {
321  nBri = pPercent_Vert[y];
322  x = nWidth;
323  while (x--)
324  {
325  nSat = pPercent_Horiz[x];
326  mxBitmap->DrawPixel(Point(x,y), Color::HSBtoRGB(nHue, nSat, nBri));
327  }
328  }
329  break;
330  case SATURATION:
331  while (y--)
332  {
333  nBri = pPercent_Vert[y];
334  x = nWidth;
335  while (x--)
336  {
337  nHue = pGrad_Horiz[x];
338  mxBitmap->DrawPixel(Point(x,y), Color::HSBtoRGB(nHue, nSat, nBri));
339  }
340  }
341  break;
342  case BRIGHTNESS:
343  while (y--)
344  {
345  nSat = pPercent_Vert[y];
346  x = nWidth;
347  while (x--)
348  {
349  nHue = pGrad_Horiz[x];
350  mxBitmap->DrawPixel(Point(x,y), Color::HSBtoRGB(nHue, nSat, nBri));
351  }
352  }
353  break;
354  case RED:
355  while (y--)
356  {
357  aBitmapColor.SetGreen(pRGB_Vert[y]);
358  x = nWidth;
359  while (x--)
360  {
361  aBitmapColor.SetBlue(pRGB_Horiz[x]);
362  mxBitmap->DrawPixel(Point(x,y), aBitmapColor);
363  }
364  }
365  break;
366  case GREEN:
367  while (y--)
368  {
369  aBitmapColor.SetRed(pRGB_Vert[y]);
370  x = nWidth;
371  while (x--)
372  {
373  aBitmapColor.SetBlue(pRGB_Horiz[x]);
374  mxBitmap->DrawPixel(Point(x,y), aBitmapColor);
375  }
376  }
377  break;
378  case BLUE:
379  while (y--)
380  {
381  aBitmapColor.SetGreen(pRGB_Vert[y]);
382  x = nWidth;
383  while (x--)
384  {
385  aBitmapColor.SetRed(pRGB_Horiz[x]);
386  mxBitmap->DrawPixel(Point(x,y), aBitmapColor);
387  }
388  }
389  break;
390  }
391 }
392 
393 void ColorFieldControl::ShowPosition( const Point& rPos, bool bUpdate )
394 {
395  if (!mxBitmap)
396  {
397  UpdateBitmap();
398  Invalidate();
399  }
400 
401  if (!mxBitmap)
402  return;
403 
404  const Size aSize(mxBitmap->GetOutputSizePixel());
405 
406  long nX = rPos.X();
407  long nY = rPos.Y();
408  if (nX < 0)
409  nX = 0;
410  else if (nX >= aSize.Width())
411  nX = aSize.Width() - 1;
412 
413  if (nY < 0)
414  nY = 0;
415  else if (nY >= aSize.Height())
416  nY = aSize.Height() - 1;
417 
418  Point aPos = maPosition;
419  maPosition.setX( nX - 5 );
420  maPosition.setY( nY - 5 );
421  Invalidate(tools::Rectangle(aPos, Size(11, 11)));
422  Invalidate(tools::Rectangle(maPosition, Size(11, 11)));
423 
424  if (bUpdate)
425  {
426  mdX = double(nX) / double(aSize.Width() - 1.0);
427  mdY = double(aSize.Height() - 1.0 - nY) / double(aSize.Height() - 1.0);
428 
429  maColor = mxBitmap->GetPixel(Point(nX, nY));
430  }
431 }
432 
433 bool ColorFieldControl::MouseButtonDown(const MouseEvent& rMEvt)
434 {
435  CaptureMouse();
436  mbMouseCaptured = true;
437  ShowPosition(rMEvt.GetPosPixel(), true);
438  Modify();
439  return true;
440 }
441 
442 bool ColorFieldControl::MouseMove(const MouseEvent& rMEvt)
443 {
444  if (mbMouseCaptured)
445  {
446  ShowPosition(rMEvt.GetPosPixel(), true);
447  Modify();
448  }
449  return true;
450 }
451 
452 bool ColorFieldControl::MouseButtonUp(const MouseEvent&)
453 {
454  ReleaseMouse();
455  mbMouseCaptured = false;
456  return true;
457 }
458 
459 void ColorFieldControl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
460 {
461  if (!mxBitmap)
462  UpdateBitmap();
463 
464  if (mxBitmap)
465  {
466  Size aSize(GetOutputSizePixel());
467  rRenderContext.DrawOutDev(Point(0, 0), aSize, Point(0, 0), aSize, *mxBitmap);
468  }
469 
470  // draw circle around current color
471  if (maColor.IsDark())
472  rRenderContext.SetLineColor( COL_WHITE );
473  else
474  rRenderContext.SetLineColor( COL_BLACK );
475 
476  rRenderContext.SetFillColor();
477 
478  rRenderContext.DrawEllipse(::tools::Rectangle(maPosition, Size(11, 11)));
479 }
480 
481 void ColorFieldControl::Resize()
482 {
483  CustomWidgetController::Resize();
484  UpdateBitmap();
485  UpdatePosition();
486 }
487 
488 void ColorFieldControl::Modify()
489 {
490  maModifyHdl.Call( *this );
491 }
492 
493 void ColorFieldControl::SetValues( Color aColor, ColorMode eMode, double x, double y )
494 {
495  bool bUpdateBitmap = (maColor!= aColor) || (meMode != eMode);
496  if( bUpdateBitmap || (mdX != x) || (mdY != y) )
497  {
498  maColor = aColor;
499  meMode = eMode;
500  mdX = x;
501  mdY = y;
502 
503  if (bUpdateBitmap)
504  UpdateBitmap();
505  UpdatePosition();
506  if (bUpdateBitmap)
507  Invalidate();
508  }
509 }
510 
511 void ColorFieldControl::UpdatePosition()
512 {
513  Size aSize(GetOutputSizePixel());
514  ShowPosition(Point(static_cast<long>(mdX * aSize.Width()), static_cast<long>((1.0 - mdY) * aSize.Height())), false);
515 }
516 
517 namespace {
518 
519 class ColorSliderControl : public weld::CustomWidgetController
520 {
521 public:
522  ColorSliderControl();
523  virtual ~ColorSliderControl() override;
524 
525  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
526 
527  virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
528  virtual bool MouseMove(const MouseEvent& rMEvt) override;
529  virtual bool MouseButtonUp(const MouseEvent& rMEvt) override;
530  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
531  virtual void Resize() override;
532 
533  void UpdateBitmap();
534  void ChangePosition( long nY );
535  void Modify();
536 
537  void SetValue( const Color& rColor, ColorMode eMode, double dValue );
538  double GetValue() const { return mdValue; }
539 
540  void SetModifyHdl( const Link<ColorSliderControl&,void>& rLink ) { maModifyHdl = rLink; }
541 
542  sal_Int16 GetLevel() const { return mnLevel; }
543 
544 private:
546  Color maColor;
547  ColorMode meMode;
549  sal_Int16 mnLevel;
550  double mdValue;
551 };
552 
553 }
554 
555 ColorSliderControl::ColorSliderControl()
556  : meMode( DefaultMode )
557  , mnLevel( 0 )
558  , mdValue( -1.0 )
559 {
560 }
561 
562 void ColorSliderControl::SetDrawingArea(weld::DrawingArea* pDrawingArea)
563 {
564  CustomWidgetController::SetDrawingArea(pDrawingArea);
565  pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 3, -1);
566 }
567 
568 ColorSliderControl::~ColorSliderControl()
569 {
571 }
572 
573 void ColorSliderControl::UpdateBitmap()
574 {
575  Size aSize(1, GetOutputSizePixel().Height());
576 
577  if (mxBitmap && mxBitmap->GetOutputSizePixel() != aSize)
579 
580  if (!mxBitmap)
581  {
584  }
585 
586  const long nY = aSize.Height() - 1;
587 
588  Color aBitmapColor(maColor);
589 
590  sal_uInt16 nHue, nSat, nBri;
591  maColor.RGBtoHSB(nHue, nSat, nBri);
592 
593  // this has been unlooped for performance reason, please do not merge back!
594 
595  switch (meMode)
596  {
597  case HUE:
598  nSat = 100;
599  nBri = 100;
600  for (long y = 0; y <= nY; y++)
601  {
602  nHue = static_cast<sal_uInt16>((359 * y) / nY);
603  mxBitmap->DrawPixel(Point(0, nY - y), Color::HSBtoRGB(nHue, nSat, nBri));
604  }
605  break;
606 
607  case SATURATION:
608  nBri = std::max(sal_uInt16(32), nBri);
609  for (long y = 0; y <= nY; y++)
610  {
611  nSat = static_cast<sal_uInt16>((100 * y) / nY);
612  mxBitmap->DrawPixel(Point(0, nY - y), Color::HSBtoRGB(nHue, nSat, nBri));
613  }
614  break;
615 
616  case BRIGHTNESS:
617  for (long y = 0; y <= nY; y++)
618  {
619  nBri = static_cast<sal_uInt16>((100 * y) / nY);
620  mxBitmap->DrawPixel(Point(0, nY - y), Color::HSBtoRGB(nHue, nSat, nBri));
621  }
622  break;
623 
624  case RED:
625  for (long y = 0; y <= nY; y++)
626  {
627  aBitmapColor.SetRed(sal_uInt8((long(255) * y) / nY));
628  mxBitmap->DrawPixel(Point(0, nY - y), aBitmapColor);
629  }
630  break;
631 
632  case GREEN:
633  for (long y = 0; y <= nY; y++)
634  {
635  aBitmapColor.SetGreen(sal_uInt8((long(255) * y) / nY));
636  mxBitmap->DrawPixel(Point(0, nY - y), aBitmapColor);
637  }
638  break;
639 
640  case BLUE:
641  for (long y = 0; y <= nY; y++)
642  {
643  aBitmapColor.SetBlue(sal_uInt8((long(255) * y) / nY));
644  mxBitmap->DrawPixel(Point(0, nY - y), aBitmapColor);
645  }
646  break;
647  }
648 }
649 
650 void ColorSliderControl::ChangePosition(long nY)
651 {
652  const long nHeight = GetOutputSizePixel().Height() - 1;
653 
654  if (nY < 0)
655  nY = 0;
656  else if (nY > nHeight)
657  nY = nHeight;
658 
659  mnLevel = nY;
660  mdValue = double(nHeight - nY) / double(nHeight);
661 }
662 
663 bool ColorSliderControl::MouseButtonDown(const MouseEvent& rMEvt)
664 {
665  CaptureMouse();
666  ChangePosition(rMEvt.GetPosPixel().Y());
667  Modify();
668  return true;
669 }
670 
671 bool ColorSliderControl::MouseMove(const MouseEvent& rMEvt)
672 {
673  if (IsMouseCaptured())
674  {
675  ChangePosition(rMEvt.GetPosPixel().Y());
676  Modify();
677  }
678  return true;
679 }
680 
681 bool ColorSliderControl::MouseButtonUp(const MouseEvent&)
682 {
683  ReleaseMouse();
684  return true;
685 }
686 
687 void ColorSliderControl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
688 {
689  if (!mxBitmap)
690  UpdateBitmap();
691 
692  const Size aSize(GetOutputSizePixel());
693 
694  Point aPos;
695  int x = aSize.Width();
696  while (x--)
697  {
698  rRenderContext.DrawOutDev(aPos, aSize, Point(0,0), aSize, *mxBitmap);
699  aPos.AdjustX(1);
700  }
701 }
702 
703 void ColorSliderControl::Resize()
704 {
705  CustomWidgetController::Resize();
706  UpdateBitmap();
707 }
708 
709 void ColorSliderControl::Modify()
710 {
711  maModifyHdl.Call(*this);
712 }
713 
714 void ColorSliderControl::SetValue(const Color& rColor, ColorMode eMode, double dValue)
715 {
716  bool bUpdateBitmap = (rColor != maColor) || (eMode != meMode);
717  if( bUpdateBitmap || (mdValue != dValue))
718  {
719  maColor = rColor;
720  mdValue = dValue;
721  mnLevel = static_cast<sal_Int16>((1.0-dValue) * GetOutputSizePixel().Height());
722  meMode = eMode;
723  if (bUpdateBitmap)
724  UpdateBitmap();
725  Invalidate();
726  }
727 }
728 
729 namespace {
730 
731 class ColorPickerDialog : public weld::GenericDialogController
732 {
733 private:
734  ColorFieldControl m_aColorField;
735  ColorSliderControl m_aColorSlider;
736  ColorPreviewControl m_aColorPreview;
737  ColorPreviewControl m_aColorPrevious;
738 
739  std::unique_ptr<weld::CustomWeld> m_xColorField;
740  std::unique_ptr<weld::CustomWeld> m_xColorSlider;
741  std::unique_ptr<weld::CustomWeld> m_xColorPreview;
742  std::unique_ptr<weld::CustomWeld> m_xColorPrevious;
743 
744  std::unique_ptr<weld::Widget> m_xFISliderLeft;
745  std::unique_ptr<weld::Widget> m_xFISliderRight;
746  std::unique_ptr<weld::RadioButton> m_xRBRed;
747  std::unique_ptr<weld::RadioButton> m_xRBGreen;
748  std::unique_ptr<weld::RadioButton> m_xRBBlue;
749  std::unique_ptr<weld::RadioButton> m_xRBHue;
750  std::unique_ptr<weld::RadioButton> m_xRBSaturation;
751  std::unique_ptr<weld::RadioButton> m_xRBBrightness;
752 
753  std::unique_ptr<weld::SpinButton> m_xMFRed;
754  std::unique_ptr<weld::SpinButton> m_xMFGreen;
755  std::unique_ptr<weld::SpinButton> m_xMFBlue;
756  std::unique_ptr<weld::HexColorControl> m_xEDHex;
757 
758  std::unique_ptr<weld::MetricSpinButton> m_xMFHue;
759  std::unique_ptr<weld::MetricSpinButton> m_xMFSaturation;
760  std::unique_ptr<weld::MetricSpinButton> m_xMFBrightness;
761 
762  std::unique_ptr<weld::MetricSpinButton> m_xMFCyan;
763  std::unique_ptr<weld::MetricSpinButton> m_xMFMagenta;
764  std::unique_ptr<weld::MetricSpinButton> m_xMFYellow;
765  std::unique_ptr<weld::MetricSpinButton> m_xMFKey;
766 
767 public:
768  ColorPickerDialog(weld::Window* pParent, Color nColor, sal_Int16 nMode);
769 
770  void update_color(UpdateFlags n = UpdateFlags::All);
771 
772  DECL_LINK(ColorFieldControlModifydl, ColorFieldControl&, void);
773  DECL_LINK(ColorSliderControlModifyHdl, ColorSliderControl&, void);
774  DECL_LINK(ColorModifyMetricHdl, weld::MetricSpinButton&, void);
775  DECL_LINK(ColorModifySpinHdl, weld::SpinButton&, void);
776  DECL_LINK(ColorModifyEditHdl, weld::Entry&, void);
777  DECL_LINK(ModeModifyHdl, weld::ToggleButton&, void);
778 
779  Color GetColor() const;
780 
781  void setColorComponent(ColorComponent nComp, double dValue);
782 
783 private:
784  ColorMode meMode;
785 
786  double mdRed, mdGreen, mdBlue;
787  double mdHue, mdSat, mdBri;
789 };
790 
791 }
792 
793 ColorPickerDialog::ColorPickerDialog(weld::Window* pParent, Color nColor, sal_Int16 nDialogMode)
794  : GenericDialogController(pParent, "cui/ui/colorpickerdialog.ui", "ColorPicker")
795  , m_xColorField(new weld::CustomWeld(*m_xBuilder, "colorField", m_aColorField))
796  , m_xColorSlider(new weld::CustomWeld(*m_xBuilder, "colorSlider", m_aColorSlider))
797  , m_xColorPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aColorPreview))
798  , m_xColorPrevious(new weld::CustomWeld(*m_xBuilder, "previous", m_aColorPrevious))
799  , m_xFISliderLeft(m_xBuilder->weld_widget("leftImage"))
800  , m_xFISliderRight(m_xBuilder->weld_widget("rightImage"))
801  , m_xRBRed(m_xBuilder->weld_radio_button("redRadiobutton"))
802  , m_xRBGreen(m_xBuilder->weld_radio_button("greenRadiobutton"))
803  , m_xRBBlue(m_xBuilder->weld_radio_button("blueRadiobutton"))
804  , m_xRBHue(m_xBuilder->weld_radio_button("hueRadiobutton"))
805  , m_xRBSaturation(m_xBuilder->weld_radio_button("satRadiobutton"))
806  , m_xRBBrightness(m_xBuilder->weld_radio_button("brightRadiobutton"))
807  , m_xMFRed(m_xBuilder->weld_spin_button("redSpinbutton"))
808  , m_xMFGreen(m_xBuilder->weld_spin_button("greenSpinbutton"))
809  , m_xMFBlue(m_xBuilder->weld_spin_button("blueSpinbutton"))
810  , m_xEDHex(new weld::HexColorControl(m_xBuilder->weld_entry("hexEntry")))
811  , m_xMFHue(m_xBuilder->weld_metric_spin_button("hueSpinbutton", FieldUnit::DEGREE))
812  , m_xMFSaturation(m_xBuilder->weld_metric_spin_button("satSpinbutton", FieldUnit::PERCENT))
813  , m_xMFBrightness(m_xBuilder->weld_metric_spin_button("brightSpinbutton", FieldUnit::PERCENT))
814  , m_xMFCyan(m_xBuilder->weld_metric_spin_button("cyanSpinbutton", FieldUnit::PERCENT))
815  , m_xMFMagenta(m_xBuilder->weld_metric_spin_button("magSpinbutton", FieldUnit::PERCENT))
816  , m_xMFYellow(m_xBuilder->weld_metric_spin_button("yellowSpinbutton", FieldUnit::PERCENT))
817  , m_xMFKey(m_xBuilder->weld_metric_spin_button("keySpinbutton", FieldUnit::PERCENT))
818  , meMode( DefaultMode )
819 {
820  m_aColorField.SetModifyHdl( LINK( this, ColorPickerDialog, ColorFieldControlModifydl ) );
821  m_aColorSlider.SetModifyHdl( LINK( this, ColorPickerDialog, ColorSliderControlModifyHdl ) );
822 
823  int nMargin = (m_xFISliderLeft->get_preferred_size().Height() + 1) / 2;
824  m_xColorSlider->set_margin_top(nMargin);
825  m_xColorSlider->set_margin_bottom(nMargin);
826 
827  Link<weld::MetricSpinButton&,void> aLink3( LINK( this, ColorPickerDialog, ColorModifyMetricHdl ) );
828  m_xMFCyan->connect_value_changed( aLink3 );
829  m_xMFMagenta->connect_value_changed( aLink3 );
830  m_xMFYellow->connect_value_changed( aLink3 );
831  m_xMFKey->connect_value_changed( aLink3 );
832 
833  m_xMFHue->connect_value_changed( aLink3 );
834  m_xMFSaturation->connect_value_changed( aLink3 );
835  m_xMFBrightness->connect_value_changed( aLink3 );
836 
837  Link<weld::SpinButton&,void> aLink4(LINK(this, ColorPickerDialog, ColorModifySpinHdl));
838  m_xMFRed->connect_value_changed(aLink4);
839  m_xMFGreen->connect_value_changed(aLink4);
840  m_xMFBlue->connect_value_changed(aLink4);
841 
842  m_xEDHex->connect_changed(LINK(this, ColorPickerDialog, ColorModifyEditHdl));
843 
844  Link<weld::ToggleButton&,void> aLink2 = LINK( this, ColorPickerDialog, ModeModifyHdl );
845  m_xRBRed->connect_toggled( aLink2 );
846  m_xRBGreen->connect_toggled( aLink2 );
847  m_xRBBlue->connect_toggled( aLink2 );
848  m_xRBHue->connect_toggled( aLink2 );
849  m_xRBSaturation->connect_toggled( aLink2 );
850  m_xRBBrightness->connect_toggled( aLink2 );
851 
852  Color aColor(nColor);
853 
854  // modify
855  if (nDialogMode == 2)
856  {
857  m_aColorPrevious.SetColor(aColor);
858  m_xColorPrevious->show();
859  }
860 
861  mdRed = static_cast<double>(aColor.GetRed()) / 255.0;
862  mdGreen = static_cast<double>(aColor.GetGreen()) / 255.0;
863  mdBlue = static_cast<double>(aColor.GetBlue()) / 255.0;
864 
867 
868  update_color();
869 }
870 
871 static int toInt( double dValue, double dRange )
872 {
873  return static_cast< int >( std::floor((dValue * dRange) + 0.5 ) );
874 }
875 
876 Color ColorPickerDialog::GetColor() const
877 {
878  return Color( toInt(mdRed,255.0), toInt(mdGreen,255.0), toInt(mdBlue,255.0) );
879 }
880 
881 void ColorPickerDialog::update_color( UpdateFlags n )
882 {
883  sal_uInt8 nRed = toInt(mdRed,255.0);
884  sal_uInt8 nGreen = toInt(mdGreen,255.0);
885  sal_uInt8 nBlue = toInt(mdBlue,255.0);
886 
887  Color aColor(nRed, nGreen, nBlue);
888 
889  if (n & UpdateFlags::RGB) // update RGB
890  {
891  m_xMFRed->set_value(nRed);
892  m_xMFGreen->set_value(nGreen);
893  m_xMFBlue->set_value(nBlue);
894  }
895 
896  if (n & UpdateFlags::CMYK) // update CMYK
897  {
898  m_xMFCyan->set_value(toInt(mdCyan, 100.0), FieldUnit::PERCENT);
899  m_xMFMagenta->set_value(toInt(mdMagenta, 100.0), FieldUnit::PERCENT);
900  m_xMFYellow->set_value(toInt(mdYellow, 100.0), FieldUnit::PERCENT);
901  m_xMFKey->set_value(toInt(mdKey, 100.0), FieldUnit::PERCENT);
902  }
903 
904  if (n & UpdateFlags::HSB ) // update HSB
905  {
906  m_xMFHue->set_value(toInt(mdHue, 1.0), FieldUnit::DEGREE);
907  m_xMFSaturation->set_value(toInt( mdSat, 100.0), FieldUnit::PERCENT);
908  m_xMFBrightness->set_value(toInt( mdBri, 100.0), FieldUnit::PERCENT);
909  }
910 
911  if (n & UpdateFlags::ColorChooser ) // update Color Chooser 1
912  {
913  switch( meMode )
914  {
915  case HUE:
916  m_aColorField.SetValues(aColor, meMode, mdSat, mdBri);
917  break;
918  case SATURATION:
919  m_aColorField.SetValues(aColor, meMode, mdHue / 360.0, mdBri);
920  break;
921  case BRIGHTNESS:
922  m_aColorField.SetValues(aColor, meMode, mdHue / 360.0, mdSat);
923  break;
924  case RED:
925  m_aColorField.SetValues(aColor, meMode, mdBlue, mdGreen);
926  break;
927  case GREEN:
928  m_aColorField.SetValues(aColor, meMode, mdBlue, mdRed);
929  break;
930  case BLUE:
931  m_aColorField.SetValues(aColor, meMode, mdRed, mdGreen);
932  break;
933  }
934  }
935 
936  if (n & UpdateFlags::ColorSlider) // update Color Chooser 2
937  {
938  switch (meMode)
939  {
940  case HUE:
941  m_aColorSlider.SetValue(aColor, meMode, mdHue / 360.0);
942  break;
943  case SATURATION:
944  m_aColorSlider.SetValue(aColor, meMode, mdSat);
945  break;
946  case BRIGHTNESS:
947  m_aColorSlider.SetValue(aColor, meMode, mdBri);
948  break;
949  case RED:
950  m_aColorSlider.SetValue(aColor, meMode, mdRed);
951  break;
952  case GREEN:
953  m_aColorSlider.SetValue(aColor, meMode, mdGreen);
954  break;
955  case BLUE:
956  m_aColorSlider.SetValue(aColor, meMode, mdBlue);
957  break;
958  }
959  }
960 
961  if (n & UpdateFlags::Hex) // update hex
962  {
963  m_xFISliderLeft->set_margin_top(m_aColorSlider.GetLevel());
964  m_xFISliderRight->set_margin_top(m_aColorSlider.GetLevel());
965  m_xEDHex->SetColor(aColor);
966  }
967  m_aColorPreview.SetColor(aColor);
968 }
969 
970 IMPL_LINK_NOARG(ColorPickerDialog, ColorFieldControlModifydl, ColorFieldControl&, void)
971 {
972  double x = m_aColorField.GetX();
973  double y = m_aColorField.GetY();
974 
975  switch( meMode )
976  {
977  case HUE:
978  mdSat = x;
979  setColorComponent( ColorComponent::Brightness, y );
980  break;
981  case SATURATION:
982  mdHue = x * 360.0;
983  setColorComponent( ColorComponent::Brightness, y );
984  break;
985  case BRIGHTNESS:
986  mdHue = x * 360.0;
987  setColorComponent( ColorComponent::Saturation, y );
988  break;
989  case RED:
990  mdBlue = x;
991  setColorComponent( ColorComponent::Green, y );
992  break;
993  case GREEN:
994  mdBlue = x;
995  setColorComponent( ColorComponent::Red, y );
996  break;
997  case BLUE:
998  mdRed = x;
999  setColorComponent( ColorComponent::Green, y );
1000  break;
1001  }
1002 
1003  update_color(UpdateFlags::All & ~UpdateFlags::ColorChooser);
1004 }
1005 
1006 IMPL_LINK_NOARG(ColorPickerDialog, ColorSliderControlModifyHdl, ColorSliderControl&, void)
1007 {
1008  double dValue = m_aColorSlider.GetValue();
1009  switch (meMode)
1010  {
1011  case HUE:
1012  setColorComponent( ColorComponent::Hue, dValue * 360.0 );
1013  break;
1014  case SATURATION:
1015  setColorComponent( ColorComponent::Saturation, dValue );
1016  break;
1017  case BRIGHTNESS:
1018  setColorComponent( ColorComponent::Brightness, dValue );
1019  break;
1020  case RED:
1021  setColorComponent( ColorComponent::Red, dValue );
1022  break;
1023  case GREEN:
1024  setColorComponent( ColorComponent::Green, dValue );
1025  break;
1026  case BLUE:
1027  setColorComponent( ColorComponent::Blue, dValue );
1028  break;
1029  }
1030 
1031  update_color(UpdateFlags::All & ~UpdateFlags::ColorSlider);
1032 }
1033 
1034 IMPL_LINK(ColorPickerDialog, ColorModifyMetricHdl, weld::MetricSpinButton&, rEdit, void)
1035 {
1036  UpdateFlags n = UpdateFlags::NONE;
1037 
1038  if (&rEdit == m_xMFHue.get())
1039  {
1040  setColorComponent( ColorComponent::Hue, static_cast<double>(m_xMFHue->get_value(FieldUnit::DEGREE)) );
1041  n = UpdateFlags::All & ~UpdateFlags::HSB;
1042  }
1043  else if (&rEdit == m_xMFSaturation.get())
1044  {
1045  setColorComponent( ColorComponent::Saturation, static_cast<double>(m_xMFSaturation->get_value(FieldUnit::PERCENT)) / 100.0 );
1046  n = UpdateFlags::All & ~UpdateFlags::HSB;
1047  }
1048  else if (&rEdit == m_xMFBrightness.get())
1049  {
1050  setColorComponent( ColorComponent::Brightness, static_cast<double>(m_xMFBrightness->get_value(FieldUnit::PERCENT)) / 100.0 );
1051  n = UpdateFlags::All & ~UpdateFlags::HSB;
1052  }
1053  else if (&rEdit == m_xMFCyan.get())
1054  {
1055  setColorComponent( ColorComponent::Cyan, static_cast<double>(m_xMFCyan->get_value(FieldUnit::PERCENT)) / 100.0 );
1056  n = UpdateFlags::All & ~UpdateFlags::CMYK;
1057  }
1058  else if (&rEdit == m_xMFMagenta.get())
1059  {
1060  setColorComponent( ColorComponent::Magenta, static_cast<double>(m_xMFMagenta->get_value(FieldUnit::PERCENT)) / 100.0 );
1061  n = UpdateFlags::All & ~UpdateFlags::CMYK;
1062  }
1063  else if (&rEdit == m_xMFYellow.get())
1064  {
1065  setColorComponent( ColorComponent::Yellow, static_cast<double>(m_xMFYellow->get_value(FieldUnit::PERCENT)) / 100.0 );
1066  n = UpdateFlags::All & ~UpdateFlags::CMYK;
1067  }
1068  else if (&rEdit == m_xMFKey.get())
1069  {
1070  setColorComponent( ColorComponent::Key, static_cast<double>(m_xMFKey->get_value(FieldUnit::PERCENT)) / 100.0 );
1071  n = UpdateFlags::All & ~UpdateFlags::CMYK;
1072  }
1073 
1074  if (n != UpdateFlags::NONE)
1075  update_color(n);
1076 }
1077 
1078 IMPL_LINK_NOARG(ColorPickerDialog, ColorModifyEditHdl, weld::Entry&, void)
1079 {
1080  UpdateFlags n = UpdateFlags::NONE;
1081 
1082  Color aColor = m_xEDHex->GetColor();
1083 
1084  if (aColor != Color(0xffffffff) && aColor != GetColor())
1085  {
1086  mdRed = static_cast<double>(aColor.GetRed()) / 255.0;
1087  mdGreen = static_cast<double>(aColor.GetGreen()) / 255.0;
1088  mdBlue = static_cast<double>(aColor.GetBlue()) / 255.0;
1089 
1092  n = UpdateFlags::All & ~UpdateFlags::Hex;
1093  }
1094 
1095  if (n != UpdateFlags::NONE)
1096  update_color(n);
1097 }
1098 
1099 IMPL_LINK(ColorPickerDialog, ColorModifySpinHdl, weld::SpinButton&, rEdit, void)
1100 {
1101  UpdateFlags n = UpdateFlags::NONE;
1102 
1103  if (&rEdit == m_xMFRed.get())
1104  {
1105  setColorComponent( ColorComponent::Red, static_cast<double>(m_xMFRed->get_value()) / 255.0 );
1106  n = UpdateFlags::All & ~UpdateFlags::RGB;
1107  }
1108  else if (&rEdit == m_xMFGreen.get())
1109  {
1110  setColorComponent( ColorComponent::Green, static_cast<double>(m_xMFGreen->get_value()) / 255.0 );
1111  n = UpdateFlags::All & ~UpdateFlags::RGB;
1112  }
1113  else if (&rEdit == m_xMFBlue.get())
1114  {
1115  setColorComponent( ColorComponent::Blue, static_cast<double>(m_xMFBlue->get_value()) / 255.0 );
1116  n = UpdateFlags::All & ~UpdateFlags::RGB;
1117  }
1118 
1119  if (n != UpdateFlags::NONE)
1120  update_color(n);
1121 }
1122 
1123 
1124 IMPL_LINK_NOARG(ColorPickerDialog, ModeModifyHdl, weld::ToggleButton&, void)
1125 {
1126  ColorMode eMode = HUE;
1127 
1128  if (m_xRBRed->get_active())
1129  {
1130  eMode = RED;
1131  }
1132  else if (m_xRBGreen->get_active())
1133  {
1134  eMode = GREEN;
1135  }
1136  else if (m_xRBBlue->get_active())
1137  {
1138  eMode = BLUE;
1139  }
1140  else if (m_xRBSaturation->get_active())
1141  {
1142  eMode = SATURATION;
1143  }
1144  else if (m_xRBBrightness->get_active())
1145  {
1146  eMode = BRIGHTNESS;
1147  }
1148 
1149  if (meMode != eMode)
1150  {
1151  meMode = eMode;
1152  update_color(UpdateFlags::ColorChooser | UpdateFlags::ColorSlider);
1153  }
1154 }
1155 
1156 void ColorPickerDialog::setColorComponent( ColorComponent nComp, double dValue )
1157 {
1158  switch( nComp )
1159  {
1160  case ColorComponent::Red:
1161  mdRed = dValue;
1162  break;
1163  case ColorComponent::Green:
1164  mdGreen = dValue;
1165  break;
1166  case ColorComponent::Blue:
1167  mdBlue = dValue;
1168  break;
1169  case ColorComponent::Hue:
1170  mdHue = dValue;
1171  break;
1172  case ColorComponent::Saturation:
1173  mdSat = dValue;
1174  break;
1175  case ColorComponent::Brightness:
1176  mdBri = dValue;
1177  break;
1178  case ColorComponent::Cyan:
1179  mdCyan = dValue;
1180  break;
1181  case ColorComponent::Yellow:
1182  mdYellow = dValue;
1183  break;
1184  case ColorComponent::Magenta:
1185  mdMagenta = dValue;
1186  break;
1187  case ColorComponent::Key:
1188  mdKey = dValue;
1189  break;
1190  }
1191 
1192  if (nComp == ColorComponent::Red || nComp == ColorComponent::Green || nComp == ColorComponent::Blue)
1193  {
1196  }
1197  else if (nComp == ColorComponent::Hue || nComp == ColorComponent::Saturation || nComp == ColorComponent::Brightness)
1198  {
1201  }
1202  else
1203  {
1206  }
1207 }
1208 
1209 typedef ::cppu::WeakComponentImplHelper< XServiceInfo, XExecutableDialog, XInitialization, XPropertyAccess > ColorPickerBase;
1210 
1211 namespace {
1212 
1213 class ColorPicker : protected ::cppu::BaseMutex, // Struct for right initialization of mutex member! Must be first of baseclasses.
1214  public ColorPickerBase
1215 {
1216 public:
1217  explicit ColorPicker();
1218 
1219  // XInitialization
1220  virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) override;
1221 
1222  // XInitialization
1223  virtual OUString SAL_CALL getImplementationName( ) override;
1224  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
1225  virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
1226 
1227  // XPropertyAccess
1228  virtual Sequence< PropertyValue > SAL_CALL getPropertyValues( ) override;
1229  virtual void SAL_CALL setPropertyValues( const Sequence< PropertyValue >& aProps ) override;
1230 
1231  // XExecutableDialog
1232  virtual void SAL_CALL setTitle( const OUString& aTitle ) override;
1233  virtual sal_Int16 SAL_CALL execute( ) override;
1234 
1235 private:
1237  sal_Int16 mnMode;
1238  Reference<css::awt::XWindow> mxParent;
1239 };
1240 
1241 }
1242 
1244 {
1245  return "com.sun.star.cui.ColorPicker";
1246 }
1247 
1249 {
1250  return static_cast<XWeak*>( new ColorPicker );
1251 }
1252 
1254 {
1255  Sequence< OUString > seq { "com.sun.star.ui.dialogs.ColorPicker" };
1256  return seq;
1257 }
1258 
1259 static const OUStringLiteral gsColorKey( "Color" );
1260 static const OUStringLiteral gsModeKey( "Mode" );
1261 
1262 ColorPicker::ColorPicker()
1263  : ColorPickerBase( m_aMutex )
1264  , mnColor( 0 )
1265  , mnMode( 0 )
1266 {
1267 }
1268 
1269 // XInitialization
1270 void SAL_CALL ColorPicker::initialize( const Sequence< Any >& aArguments )
1271 {
1272  if( aArguments.getLength() == 1 )
1273  {
1274  aArguments[0] >>= mxParent;
1275  }
1276 }
1277 
1278 // XInitialization
1279 OUString SAL_CALL ColorPicker::getImplementationName( )
1280 {
1282 }
1283 
1284 sal_Bool SAL_CALL ColorPicker::supportsService( const OUString& sServiceName )
1285 {
1286  return cppu::supportsService(this, sServiceName);
1287 }
1288 
1289 Sequence< OUString > SAL_CALL ColorPicker::getSupportedServiceNames( )
1290 {
1292 }
1293 
1294 // XPropertyAccess
1295 Sequence< PropertyValue > SAL_CALL ColorPicker::getPropertyValues( )
1296 {
1297  Sequence< PropertyValue > props(1);
1298  props[0].Name = gsColorKey;
1299  props[0].Value <<= mnColor;
1300  return props;
1301 }
1302 
1303 void SAL_CALL ColorPicker::setPropertyValues( const Sequence< PropertyValue >& aProps )
1304 {
1305  for( sal_Int32 n = 0; n < aProps.getLength(); n++ )
1306  {
1307  if( aProps[n].Name == gsColorKey )
1308  {
1309  aProps[n].Value >>= mnColor;
1310  }
1311  else if( aProps[n].Name == gsModeKey )
1312  {
1313  aProps[n].Value >>= mnMode;
1314  }
1315  }
1316 }
1317 
1318 // XExecutableDialog
1319 void SAL_CALL ColorPicker::setTitle( const OUString& )
1320 {
1321 }
1322 
1323 sal_Int16 SAL_CALL ColorPicker::execute()
1324 {
1325  std::unique_ptr<ColorPickerDialog> xDlg(new ColorPickerDialog(Application::GetFrameWeld(mxParent), mnColor, mnMode));
1326  sal_Int16 ret = xDlg->run();
1327  if (ret)
1328  mnColor = xDlg->GetColor();
1329  return ret;
1330 }
1331 
1332 }
1333 
1334 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::MetricSpinButton > m_xMFCyan
std::vector< sal_uInt16 > maPercent_Vert
long Width() const
ColorPreviewControl m_aColorPrevious
double mdBlue
static int toInt(double dValue, double dRange)
ColorPreviewControl m_aColorPreview
std::unique_ptr< weld::HexColorControl > m_xEDHex
FieldUnit
std::unique_ptr< weld::RadioButton > m_xRBSaturation
std::unique_ptr< weld::SpinButton > m_xMFGreen
std::unique_ptr< weld::CustomWeld > m_xColorField
sal_uInt8 GetRed() const
osl::Mutex m_aMutex
long AdjustX(long nHorzMove)
std::string GetValue
sal_Int16 mnLevel
long Height() const
double mdX
ColorSliderControl m_aColorSlider
std::unique_ptr< weld::RadioButton > m_xRBBlue
double mdKey
Color m_aColor
std::unique_ptr< weld::RadioButton > m_xRBRed
std::unique_ptr< weld::CustomWeld > m_xColorPreview
std::unique_ptr< weld::MetricSpinButton > m_xMFSaturation
OUString getImplementationName()
UpdateFlags
const ColorMode DefaultMode
IMPL_LINK(ColorPickerDialog, ColorModifySpinHdl, weld::SpinButton &, rEdit, void)
static const OUStringLiteral gsColorKey("Color")
double mdValue
std::unique_ptr< weld::MetricSpinButton > m_xMFHue
float x
std::vector< sal_uInt8 > maRGB_Horiz
std::unique_ptr< weld::CustomWeld > m_xColorPrevious
NONE
bool mbMouseCaptured
Sequence< PropertyValue > aArguments
void setX(long nX)
Point maPosition
static void HSVtoRGB(double dH, double dS, double dV, double &dR, double &dG, double &dB)
Definition: colorpicker.cxx:98
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
Mode eMode
Reference< css::awt::XWindow > mxParent
void setY(long nY)
static Color HSBtoRGB(sal_uInt16 nHue, sal_uInt16 nSaturation, sal_uInt16 nBrightness)
sal_uInt8 GetBlue() const
ColorMode meMode
void DrawRect(const tools::Rectangle &rRect)
double mdRed
double mdYellow
float y
double mdHue
void SetLineColor()
static const OUStringLiteral gsModeKey("Mode")
double mdSat
std::unique_ptr< weld::SpinButton > m_xMFRed
double mdBri
css::uno::Sequence< OUString > getSupportedServiceNames()
static void RGBtoCMYK(double dR, double dG, double dB, double &fCyan, double &fMagenta, double &fYellow, double &fKey)
::cppu::WeakComponentImplHelper< XServiceInfo, XExecutableDialog, XInitialization, XPropertyAccess > ColorPickerBase
bool IsDark() const
std::unique_ptr< weld::RadioButton > m_xRBGreen
Link< ColorFieldControl &, void > maModifyHdl
bool SetOutputSizePixel(const Size &rNewSize, bool bErase=true)
BColor hsv2rgb(const BColor &rHSVColor)
std::unique_ptr< weld::CustomWeld > m_xColorSlider
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
void SetFillColor()
static void RGBtoHSV(double dR, double dG, double dB, double &dH, double &dS, double &dV)
Definition: colorpicker.cxx:89
std::vector< sal_uInt16 > maPercent_Horiz
unsigned char sal_Bool
VclPtr< VirtualDevice > mxBitmap
Size GetOutputSizePixel() const
std::unique_ptr< weld::MetricSpinButton > m_xMFKey
std::unique_ptr< weld::MetricSpinButton > m_xMFYellow
void DrawPixel(const Point &rPt)
long X() const
sal_uInt8 GetGreen() const
IMPL_LINK_NOARG(ColorPickerDialog, ModeModifyHdl, weld::ToggleButton &, void)
weld::Entry & rEdit
Color maColor
unsigned char sal_uInt8
static void CMYKtoRGB(double fCyan, double fMagenta, double fYellow, double fKey, double &dR, double &dG, double &dB)
std::vector< sal_uInt8 > maRGB_Vert
std::unique_ptr< weld::MetricSpinButton > m_xMFBrightness
std::unique_ptr< weld::RadioButton > m_xRBBrightness
virtual int get_text_height() const =0
static VclPtr< reference_type > Create(Arg &&...arg)
const OUString PERCENT("Percent")
const Point & GetPosPixel() const
BColor rgb2hsv(const BColor &rRGBColor)
std::vector< sal_uInt16 > maGrad_Horiz
void DrawEllipse(const tools::Rectangle &rRect)
double mdY
double mdGreen
Any result
struct _ADOKey Key
std::unique_ptr< weld::Widget > m_xFISliderRight
void RGBtoHSB(sal_uInt16 &nHue, sal_uInt16 &nSaturation, sal_uInt16 &nBrightness) const
Sequence< OUString > ColorPicker_getSupportedServiceNames()
Reference< XInterface > ColorPicker_createInstance(Reference< XComponentContext > const &)
std::unique_ptr< weld::MetricSpinButton > m_xMFMagenta
std::unique_ptr< weld::SpinButton > m_xMFBlue
Color mnColor
Color GetPixel(const Point &rPt) const
std::unique_ptr< weld::RadioButton > m_xRBHue
double mdCyan
virtual void set_size_request(int nWidth, int nHeight)=0
std::unique_ptr< weld::Widget > m_xFISliderLeft
ColorFieldControl m_aColorField
double mdMagenta
virtual float get_approximate_digit_width() const =0
OUString ColorPicker_getImplementationName()
sal_Int16 mnMode
SAL_DLLPRIVATE void DrawOutDev(const Point &, const Size &, const Point &, const Size &, const Printer &)=delete
long Y() const