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 
148 {
149 private:
151 
152  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
153 public:
155  {
156  }
157 
158  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
159  {
160  CustomWidgetController::SetDrawingArea(pDrawingArea);
161  pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 10,
162  pDrawingArea->get_text_height() * 2);
163  }
164 
165  void SetColor(const Color& rCol)
166  {
167  if (rCol != m_aColor)
168  {
169  m_aColor = rCol;
170  Invalidate();
171  }
172  }
173 };
174 
176 {
177  rRenderContext.SetFillColor(m_aColor);
178  rRenderContext.SetLineColor(m_aColor);
179  rRenderContext.DrawRect(tools::Rectangle(Point(0, 0), GetOutputSizePixel()));
180 }
181 
182 namespace {
183 
184 enum ColorMode { HUE, SATURATION, BRIGHTNESS, RED, GREEN, BLUE };
185 
186 }
187 
188 const ColorMode DefaultMode = HUE;
189 
191 {
192 public:
194  : meMode( DefaultMode )
195  , mdX( -1.0 )
196  , mdY( -1.0 )
197  , mbMouseCaptured(false)
198  {
199  }
200 
201  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override
202  {
203  CustomWidgetController::SetDrawingArea(pDrawingArea);
204  pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 40,
205  pDrawingArea->get_text_height() * 10);
206  }
207 
208  virtual ~ColorFieldControl() override
209  {
211  }
212 
213  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
214  virtual void Resize() override;
215  virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
216  virtual bool MouseMove(const MouseEvent& rMEvt) override;
217  virtual bool MouseButtonUp(const MouseEvent& rMEvt) override;
218 
219  void UpdateBitmap();
220  void ShowPosition( const Point& rPos, bool bUpdate );
221  void UpdatePosition();
222  void Modify();
223 
224  void SetValues(Color aColor, ColorMode eMode, double x, double y);
225  double GetX() const { return mdX;}
226  double GetY() const { return mdY;}
227 
229 
230 private:
231  ColorMode meMode;
233  double mdX;
234  double mdY;
239  std::vector<sal_uInt8> maRGB_Horiz;
240  std::vector<sal_uInt16> maGrad_Horiz;
241  std::vector<sal_uInt16> maPercent_Horiz;
242  std::vector<sal_uInt8> maRGB_Vert;
243  std::vector<sal_uInt16> maPercent_Vert;
244 };
245 
247 {
248  const Size aSize(GetOutputSizePixel());
249 
250  if (mxBitmap && mxBitmap->GetOutputSizePixel() != aSize)
252 
253  const sal_Int32 nWidth = aSize.Width();
254  const sal_Int32 nHeight = aSize.Height();
255 
256  if (nWidth == 0 || nHeight == 0)
257  return;
258 
259  if (!mxBitmap)
260  {
263 
264  maRGB_Horiz.resize( nWidth );
265  maGrad_Horiz.resize( nWidth );
266  maPercent_Horiz.resize( nWidth );
267 
268  sal_uInt8* pRGB = maRGB_Horiz.data();
269  sal_uInt16* pGrad = maGrad_Horiz.data();
270  sal_uInt16* pPercent = maPercent_Horiz.data();
271 
272  for( sal_Int32 x = 0; x < nWidth; x++ )
273  {
274  *pRGB++ = static_cast<sal_uInt8>((x * 256) / nWidth);
275  *pGrad++ = static_cast<sal_uInt16>((x * 359) / nWidth);
276  *pPercent++ = static_cast<sal_uInt16>((x * 100) / nWidth);
277  }
278 
279  maRGB_Vert.resize(nHeight);
280  maPercent_Vert.resize(nHeight);
281 
282  pRGB = maRGB_Vert.data();
283  pPercent = maPercent_Vert.data();
284 
285  sal_Int32 y = nHeight;
286  while (y--)
287  {
288  *pRGB++ = static_cast<sal_uInt8>((y * 256) / nHeight);
289  *pPercent++ = static_cast<sal_uInt16>((y * 100) / nHeight);
290  }
291  }
292 
293  sal_uInt8* pRGB_Horiz = maRGB_Horiz.data();
294  sal_uInt16* pGrad_Horiz = maGrad_Horiz.data();
295  sal_uInt16* pPercent_Horiz = maPercent_Horiz.data();
296  sal_uInt8* pRGB_Vert = maRGB_Vert.data();
297  sal_uInt16* pPercent_Vert = maPercent_Vert.data();
298 
299  Color aBitmapColor(maColor);
300 
301  sal_uInt16 nHue, nSat, nBri;
302  maColor.RGBtoHSB(nHue, nSat, nBri);
303 
304  // this has been unlooped for performance reason, please do not merge back!
305 
306  sal_uInt16 y = nHeight,x;
307 
308  switch(meMode)
309  {
310  case HUE:
311  while (y--)
312  {
313  nBri = pPercent_Vert[y];
314  x = nWidth;
315  while (x--)
316  {
317  nSat = pPercent_Horiz[x];
318  mxBitmap->DrawPixel(Point(x,y), Color::HSBtoRGB(nHue, nSat, nBri));
319  }
320  }
321  break;
322  case SATURATION:
323  while (y--)
324  {
325  nBri = pPercent_Vert[y];
326  x = nWidth;
327  while (x--)
328  {
329  nHue = pGrad_Horiz[x];
330  mxBitmap->DrawPixel(Point(x,y), Color::HSBtoRGB(nHue, nSat, nBri));
331  }
332  }
333  break;
334  case BRIGHTNESS:
335  while (y--)
336  {
337  nSat = pPercent_Vert[y];
338  x = nWidth;
339  while (x--)
340  {
341  nHue = pGrad_Horiz[x];
342  mxBitmap->DrawPixel(Point(x,y), Color::HSBtoRGB(nHue, nSat, nBri));
343  }
344  }
345  break;
346  case RED:
347  while (y--)
348  {
349  aBitmapColor.SetGreen(pRGB_Vert[y]);
350  x = nWidth;
351  while (x--)
352  {
353  aBitmapColor.SetBlue(pRGB_Horiz[x]);
354  mxBitmap->DrawPixel(Point(x,y), aBitmapColor);
355  }
356  }
357  break;
358  case GREEN:
359  while (y--)
360  {
361  aBitmapColor.SetRed(pRGB_Vert[y]);
362  x = nWidth;
363  while (x--)
364  {
365  aBitmapColor.SetBlue(pRGB_Horiz[x]);
366  mxBitmap->DrawPixel(Point(x,y), aBitmapColor);
367  }
368  }
369  break;
370  case BLUE:
371  while (y--)
372  {
373  aBitmapColor.SetGreen(pRGB_Vert[y]);
374  x = nWidth;
375  while (x--)
376  {
377  aBitmapColor.SetRed(pRGB_Horiz[x]);
378  mxBitmap->DrawPixel(Point(x,y), aBitmapColor);
379  }
380  }
381  break;
382  }
383 }
384 
385 void ColorFieldControl::ShowPosition( const Point& rPos, bool bUpdate )
386 {
387  if (!mxBitmap)
388  {
389  UpdateBitmap();
390  Invalidate();
391  }
392 
393  if (!mxBitmap)
394  return;
395 
396  const Size aSize(mxBitmap->GetOutputSizePixel());
397 
398  long nX = rPos.X();
399  long nY = rPos.Y();
400  if (nX < 0)
401  nX = 0;
402  else if (nX >= aSize.Width())
403  nX = aSize.Width() - 1;
404 
405  if (nY < 0)
406  nY = 0;
407  else if (nY >= aSize.Height())
408  nY = aSize.Height() - 1;
409 
410  Point aPos = maPosition;
411  maPosition.setX( nX - 5 );
412  maPosition.setY( nY - 5 );
413  Invalidate(tools::Rectangle(aPos, Size(11, 11)));
415 
416  if (bUpdate)
417  {
418  mdX = double(nX) / double(aSize.Width() - 1.0);
419  mdY = double(aSize.Height() - 1.0 - nY) / double(aSize.Height() - 1.0);
420 
421  maColor = mxBitmap->GetPixel(Point(nX, nY));
422  }
423 }
424 
426 {
427  CaptureMouse();
428  mbMouseCaptured = true;
429  ShowPosition(rMEvt.GetPosPixel(), true);
430  Modify();
431  return true;
432 }
433 
435 {
436  if (mbMouseCaptured)
437  {
438  ShowPosition(rMEvt.GetPosPixel(), true);
439  Modify();
440  }
441  return true;
442 }
443 
445 {
446  ReleaseMouse();
447  mbMouseCaptured = false;
448  return true;
449 }
450 
452 {
453  if (!mxBitmap)
454  UpdateBitmap();
455 
456  if (mxBitmap)
457  {
458  Size aSize(GetOutputSizePixel());
459  rRenderContext.DrawOutDev(Point(0, 0), aSize, Point(0, 0), aSize, *mxBitmap);
460  }
461 
462  // draw circle around current color
463  if (maColor.IsDark())
464  rRenderContext.SetLineColor( COL_WHITE );
465  else
466  rRenderContext.SetLineColor( COL_BLACK );
467 
468  rRenderContext.SetFillColor();
469 
470  rRenderContext.DrawEllipse(::tools::Rectangle(maPosition, Size(11, 11)));
471 }
472 
474 {
475  CustomWidgetController::Resize();
476  UpdateBitmap();
477  UpdatePosition();
478 }
479 
481 {
482  maModifyHdl.Call( *this );
483 }
484 
485 void ColorFieldControl::SetValues( Color aColor, ColorMode eMode, double x, double y )
486 {
487  bool bUpdateBitmap = (maColor!= aColor) || (meMode != eMode);
488  if( bUpdateBitmap || (mdX != x) || (mdY != y) )
489  {
490  maColor = aColor;
491  meMode = eMode;
492  mdX = x;
493  mdY = y;
494 
495  if (bUpdateBitmap)
496  UpdateBitmap();
497  UpdatePosition();
498  if (bUpdateBitmap)
499  Invalidate();
500  }
501 }
502 
504 {
505  Size aSize(GetOutputSizePixel());
506  ShowPosition(Point(static_cast<long>(mdX * aSize.Width()), static_cast<long>((1.0 - mdY) * aSize.Height())), false);
507 }
508 
510 {
511 public:
513  virtual ~ColorSliderControl() override;
514 
515  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
516 
517  virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
518  virtual bool MouseMove(const MouseEvent& rMEvt) override;
519  virtual bool MouseButtonUp(const MouseEvent& rMEvt) override;
520  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
521  virtual void Resize() override;
522 
523  void UpdateBitmap();
524  void ChangePosition( long nY );
525  void Modify();
526 
527  void SetValue( const Color& rColor, ColorMode eMode, double dValue );
528  double GetValue() const { return mdValue; }
529 
530  void SetModifyHdl( const Link<ColorSliderControl&,void>& rLink ) { maModifyHdl = rLink; }
531 
532  sal_Int16 GetLevel() const { return mnLevel; }
533 
534 private:
537  ColorMode meMode;
539  sal_Int16 mnLevel;
540  double mdValue;
541 };
542 
544  : meMode( DefaultMode )
545  , mnLevel( 0 )
546  , mdValue( -1.0 )
547 {
548 }
549 
551 {
552  CustomWidgetController::SetDrawingArea(pDrawingArea);
553  pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 3, -1);
554 }
555 
557 {
559 }
560 
562 {
563  Size aSize(1, GetOutputSizePixel().Height());
564 
565  if (mxBitmap && mxBitmap->GetOutputSizePixel() != aSize)
567 
568  if (!mxBitmap)
569  {
572  }
573 
574  const long nY = aSize.Height() - 1;
575 
576  Color aBitmapColor(maColor);
577 
578  sal_uInt16 nHue, nSat, nBri;
579  maColor.RGBtoHSB(nHue, nSat, nBri);
580 
581  // this has been unlooped for performance reason, please do not merge back!
582 
583  switch (meMode)
584  {
585  case HUE:
586  nSat = 100;
587  nBri = 100;
588  for (long y = 0; y <= nY; y++)
589  {
590  nHue = static_cast<sal_uInt16>((359 * y) / nY);
591  mxBitmap->DrawPixel(Point(0, nY - y), Color::HSBtoRGB(nHue, nSat, nBri));
592  }
593  break;
594 
595  case SATURATION:
596  nBri = std::max(sal_uInt16(32), nBri);
597  for (long y = 0; y <= nY; y++)
598  {
599  nSat = static_cast<sal_uInt16>((100 * y) / nY);
600  mxBitmap->DrawPixel(Point(0, nY - y), Color::HSBtoRGB(nHue, nSat, nBri));
601  }
602  break;
603 
604  case BRIGHTNESS:
605  for (long y = 0; y <= nY; y++)
606  {
607  nBri = static_cast<sal_uInt16>((100 * y) / nY);
608  mxBitmap->DrawPixel(Point(0, nY - y), Color::HSBtoRGB(nHue, nSat, nBri));
609  }
610  break;
611 
612  case RED:
613  for (long y = 0; y <= nY; y++)
614  {
615  aBitmapColor.SetRed(sal_uInt8((long(255) * y) / nY));
616  mxBitmap->DrawPixel(Point(0, nY - y), aBitmapColor);
617  }
618  break;
619 
620  case GREEN:
621  for (long y = 0; y <= nY; y++)
622  {
623  aBitmapColor.SetGreen(sal_uInt8((long(255) * y) / nY));
624  mxBitmap->DrawPixel(Point(0, nY - y), aBitmapColor);
625  }
626  break;
627 
628  case BLUE:
629  for (long y = 0; y <= nY; y++)
630  {
631  aBitmapColor.SetBlue(sal_uInt8((long(255) * y) / nY));
632  mxBitmap->DrawPixel(Point(0, nY - y), aBitmapColor);
633  }
634  break;
635  }
636 }
637 
639 {
640  const long nHeight = GetOutputSizePixel().Height() - 1;
641 
642  if (nY < 0)
643  nY = 0;
644  else if (nY > nHeight)
645  nY = nHeight;
646 
647  mnLevel = nY;
648  mdValue = double(nHeight - nY) / double(nHeight);
649 }
650 
652 {
653  CaptureMouse();
654  ChangePosition(rMEvt.GetPosPixel().Y());
655  Modify();
656  return true;
657 }
658 
660 {
661  if (IsMouseCaptured())
662  {
663  ChangePosition(rMEvt.GetPosPixel().Y());
664  Modify();
665  }
666  return true;
667 }
668 
670 {
671  ReleaseMouse();
672  return true;
673 }
674 
676 {
677  if (!mxBitmap)
678  UpdateBitmap();
679 
680  const Size aSize(GetOutputSizePixel());
681 
682  Point aPos;
683  int x = aSize.Width();
684  while (x--)
685  {
686  rRenderContext.DrawOutDev(aPos, aSize, Point(0,0), aSize, *mxBitmap);
687  aPos.AdjustX(1);
688  }
689 }
690 
692 {
693  CustomWidgetController::Resize();
694  UpdateBitmap();
695 }
696 
698 {
699  maModifyHdl.Call(*this);
700 }
701 
702 void ColorSliderControl::SetValue(const Color& rColor, ColorMode eMode, double dValue)
703 {
704  bool bUpdateBitmap = (rColor != maColor) || (eMode != meMode);
705  if( bUpdateBitmap || (mdValue != dValue))
706  {
707  maColor = rColor;
708  mdValue = dValue;
709  mnLevel = static_cast<sal_Int16>((1.0-dValue) * GetOutputSizePixel().Height());
710  meMode = eMode;
711  if (bUpdateBitmap)
712  UpdateBitmap();
713  Invalidate();
714  }
715 }
716 
718 {
719 private:
724 
725  std::unique_ptr<weld::CustomWeld> m_xColorField;
726  std::unique_ptr<weld::CustomWeld> m_xColorSlider;
727  std::unique_ptr<weld::CustomWeld> m_xColorPreview;
728  std::unique_ptr<weld::CustomWeld> m_xColorPrevious;
729 
730  std::unique_ptr<weld::Widget> m_xFISliderLeft;
731  std::unique_ptr<weld::Widget> m_xFISliderRight;
732  std::unique_ptr<weld::RadioButton> m_xRBRed;
733  std::unique_ptr<weld::RadioButton> m_xRBGreen;
734  std::unique_ptr<weld::RadioButton> m_xRBBlue;
735  std::unique_ptr<weld::RadioButton> m_xRBHue;
736  std::unique_ptr<weld::RadioButton> m_xRBSaturation;
737  std::unique_ptr<weld::RadioButton> m_xRBBrightness;
738 
739  std::unique_ptr<weld::SpinButton> m_xMFRed;
740  std::unique_ptr<weld::SpinButton> m_xMFGreen;
741  std::unique_ptr<weld::SpinButton> m_xMFBlue;
742  std::unique_ptr<weld::HexColorControl> m_xEDHex;
743 
744  std::unique_ptr<weld::MetricSpinButton> m_xMFHue;
745  std::unique_ptr<weld::MetricSpinButton> m_xMFSaturation;
746  std::unique_ptr<weld::MetricSpinButton> m_xMFBrightness;
747 
748  std::unique_ptr<weld::MetricSpinButton> m_xMFCyan;
749  std::unique_ptr<weld::MetricSpinButton> m_xMFMagenta;
750  std::unique_ptr<weld::MetricSpinButton> m_xMFYellow;
751  std::unique_ptr<weld::MetricSpinButton> m_xMFKey;
752 
753 public:
754  ColorPickerDialog(weld::Window* pParent, Color nColor, sal_Int16 nMode);
755 
756  void update_color(UpdateFlags n = UpdateFlags::All);
757 
758  DECL_LINK(ColorFieldControlModifydl, ColorFieldControl&, void);
759  DECL_LINK(ColorSliderControlModifyHdl, ColorSliderControl&, void);
760  DECL_LINK(ColorModifyMetricHdl, weld::MetricSpinButton&, void);
761  DECL_LINK(ColorModifySpinHdl, weld::SpinButton&, void);
762  DECL_LINK(ColorModifyEditHdl, weld::Entry&, void);
763  DECL_LINK(ModeModifyHdl, weld::ToggleButton&, void);
764 
765  Color GetColor() const;
766 
767  void setColorComponent(ColorComponent nComp, double dValue);
768 
769 private:
770  ColorMode meMode;
771 
772  double mdRed, mdGreen, mdBlue;
773  double mdHue, mdSat, mdBri;
775 };
776 
777 ColorPickerDialog::ColorPickerDialog(weld::Window* pParent, Color nColor, sal_Int16 nDialogMode)
778  : GenericDialogController(pParent, "cui/ui/colorpickerdialog.ui", "ColorPicker")
779  , m_xColorField(new weld::CustomWeld(*m_xBuilder, "colorField", m_aColorField))
780  , m_xColorSlider(new weld::CustomWeld(*m_xBuilder, "colorSlider", m_aColorSlider))
781  , m_xColorPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aColorPreview))
782  , m_xColorPrevious(new weld::CustomWeld(*m_xBuilder, "previous", m_aColorPrevious))
783  , m_xFISliderLeft(m_xBuilder->weld_widget("leftImage"))
784  , m_xFISliderRight(m_xBuilder->weld_widget("rightImage"))
785  , m_xRBRed(m_xBuilder->weld_radio_button("redRadiobutton"))
786  , m_xRBGreen(m_xBuilder->weld_radio_button("greenRadiobutton"))
787  , m_xRBBlue(m_xBuilder->weld_radio_button("blueRadiobutton"))
788  , m_xRBHue(m_xBuilder->weld_radio_button("hueRadiobutton"))
789  , m_xRBSaturation(m_xBuilder->weld_radio_button("satRadiobutton"))
790  , m_xRBBrightness(m_xBuilder->weld_radio_button("brightRadiobutton"))
791  , m_xMFRed(m_xBuilder->weld_spin_button("redSpinbutton"))
792  , m_xMFGreen(m_xBuilder->weld_spin_button("greenSpinbutton"))
793  , m_xMFBlue(m_xBuilder->weld_spin_button("blueSpinbutton"))
794  , m_xEDHex(new weld::HexColorControl(m_xBuilder->weld_entry("hexEntry")))
795  , m_xMFHue(m_xBuilder->weld_metric_spin_button("hueSpinbutton", FieldUnit::DEGREE))
796  , m_xMFSaturation(m_xBuilder->weld_metric_spin_button("satSpinbutton", FieldUnit::PERCENT))
797  , m_xMFBrightness(m_xBuilder->weld_metric_spin_button("brightSpinbutton", FieldUnit::PERCENT))
798  , m_xMFCyan(m_xBuilder->weld_metric_spin_button("cyanSpinbutton", FieldUnit::PERCENT))
799  , m_xMFMagenta(m_xBuilder->weld_metric_spin_button("magSpinbutton", FieldUnit::PERCENT))
800  , m_xMFYellow(m_xBuilder->weld_metric_spin_button("yellowSpinbutton", FieldUnit::PERCENT))
801  , m_xMFKey(m_xBuilder->weld_metric_spin_button("keySpinbutton", FieldUnit::PERCENT))
802  , meMode( DefaultMode )
803 {
804  m_aColorField.SetModifyHdl( LINK( this, ColorPickerDialog, ColorFieldControlModifydl ) );
805  m_aColorSlider.SetModifyHdl( LINK( this, ColorPickerDialog, ColorSliderControlModifyHdl ) );
806 
807  int nMargin = (m_xFISliderLeft->get_preferred_size().Height() + 1) / 2;
808  m_xColorSlider->set_margin_top(nMargin);
809  m_xColorSlider->set_margin_bottom(nMargin);
810 
811  Link<weld::MetricSpinButton&,void> aLink3( LINK( this, ColorPickerDialog, ColorModifyMetricHdl ) );
812  m_xMFCyan->connect_value_changed( aLink3 );
813  m_xMFMagenta->connect_value_changed( aLink3 );
814  m_xMFYellow->connect_value_changed( aLink3 );
815  m_xMFKey->connect_value_changed( aLink3 );
816 
817  m_xMFHue->connect_value_changed( aLink3 );
818  m_xMFSaturation->connect_value_changed( aLink3 );
819  m_xMFBrightness->connect_value_changed( aLink3 );
820 
821  Link<weld::SpinButton&,void> aLink4(LINK(this, ColorPickerDialog, ColorModifySpinHdl));
822  m_xMFRed->connect_value_changed(aLink4);
823  m_xMFGreen->connect_value_changed(aLink4);
824  m_xMFBlue->connect_value_changed(aLink4);
825 
826  m_xEDHex->connect_changed(LINK(this, ColorPickerDialog, ColorModifyEditHdl));
827 
828  Link<weld::ToggleButton&,void> aLink2 = LINK( this, ColorPickerDialog, ModeModifyHdl );
829  m_xRBRed->connect_toggled( aLink2 );
830  m_xRBGreen->connect_toggled( aLink2 );
831  m_xRBBlue->connect_toggled( aLink2 );
832  m_xRBHue->connect_toggled( aLink2 );
833  m_xRBSaturation->connect_toggled( aLink2 );
834  m_xRBBrightness->connect_toggled( aLink2 );
835 
836  Color aColor(nColor);
837 
838  // modify
839  if (nDialogMode == 2)
840  {
841  m_aColorPrevious.SetColor(aColor);
842  m_xColorPrevious->show();
843  }
844 
845  mdRed = static_cast<double>(aColor.GetRed()) / 255.0;
846  mdGreen = static_cast<double>(aColor.GetGreen()) / 255.0;
847  mdBlue = static_cast<double>(aColor.GetBlue()) / 255.0;
848 
851 
852  update_color();
853 }
854 
855 static int toInt( double dValue, double dRange )
856 {
857  return static_cast< int >( std::floor((dValue * dRange) + 0.5 ) );
858 }
859 
861 {
862  return Color( toInt(mdRed,255.0), toInt(mdGreen,255.0), toInt(mdBlue,255.0) );
863 }
864 
866 {
867  sal_uInt8 nRed = toInt(mdRed,255.0);
868  sal_uInt8 nGreen = toInt(mdGreen,255.0);
869  sal_uInt8 nBlue = toInt(mdBlue,255.0);
870 
871  Color aColor(nRed, nGreen, nBlue);
872 
873  if (n & UpdateFlags::RGB) // update RGB
874  {
875  m_xMFRed->set_value(nRed);
876  m_xMFGreen->set_value(nGreen);
877  m_xMFBlue->set_value(nBlue);
878  }
879 
880  if (n & UpdateFlags::CMYK) // update CMYK
881  {
882  m_xMFCyan->set_value(toInt(mdCyan, 100.0), FieldUnit::PERCENT);
883  m_xMFMagenta->set_value(toInt(mdMagenta, 100.0), FieldUnit::PERCENT);
884  m_xMFYellow->set_value(toInt(mdYellow, 100.0), FieldUnit::PERCENT);
885  m_xMFKey->set_value(toInt(mdKey, 100.0), FieldUnit::PERCENT);
886  }
887 
888  if (n & UpdateFlags::HSB ) // update HSB
889  {
890  m_xMFHue->set_value(toInt(mdHue, 1.0), FieldUnit::DEGREE);
891  m_xMFSaturation->set_value(toInt( mdSat, 100.0), FieldUnit::PERCENT);
892  m_xMFBrightness->set_value(toInt( mdBri, 100.0), FieldUnit::PERCENT);
893  }
894 
895  if (n & UpdateFlags::ColorChooser ) // update Color Chooser 1
896  {
897  switch( meMode )
898  {
899  case HUE:
901  break;
902  case SATURATION:
903  m_aColorField.SetValues(aColor, meMode, mdHue / 360.0, mdBri);
904  break;
905  case BRIGHTNESS:
906  m_aColorField.SetValues(aColor, meMode, mdHue / 360.0, mdSat);
907  break;
908  case RED:
910  break;
911  case GREEN:
913  break;
914  case BLUE:
916  break;
917  }
918  }
919 
920  if (n & UpdateFlags::ColorSlider) // update Color Chooser 2
921  {
922  switch (meMode)
923  {
924  case HUE:
925  m_aColorSlider.SetValue(aColor, meMode, mdHue / 360.0);
926  break;
927  case SATURATION:
929  break;
930  case BRIGHTNESS:
932  break;
933  case RED:
935  break;
936  case GREEN:
938  break;
939  case BLUE:
941  break;
942  }
943  }
944 
945  if (n & UpdateFlags::Hex) // update hex
946  {
947  m_xFISliderLeft->set_margin_top(m_aColorSlider.GetLevel());
948  m_xFISliderRight->set_margin_top(m_aColorSlider.GetLevel());
949  m_xEDHex->SetColor(aColor);
950  }
951  m_aColorPreview.SetColor(aColor);
952 }
953 
954 IMPL_LINK_NOARG(ColorPickerDialog, ColorFieldControlModifydl, ColorFieldControl&, void)
955 {
956  double x = m_aColorField.GetX();
957  double y = m_aColorField.GetY();
958 
959  switch( meMode )
960  {
961  case HUE:
962  mdSat = x;
963  setColorComponent( ColorComponent::Brightness, y );
964  break;
965  case SATURATION:
966  mdHue = x * 360.0;
967  setColorComponent( ColorComponent::Brightness, y );
968  break;
969  case BRIGHTNESS:
970  mdHue = x * 360.0;
971  setColorComponent( ColorComponent::Saturation, y );
972  break;
973  case RED:
974  mdBlue = x;
975  setColorComponent( ColorComponent::Green, y );
976  break;
977  case GREEN:
978  mdBlue = x;
979  setColorComponent( ColorComponent::Red, y );
980  break;
981  case BLUE:
982  mdRed = x;
983  setColorComponent( ColorComponent::Green, y );
984  break;
985  }
986 
987  update_color(UpdateFlags::All & ~UpdateFlags::ColorChooser);
988 }
989 
990 IMPL_LINK_NOARG(ColorPickerDialog, ColorSliderControlModifyHdl, ColorSliderControl&, void)
991 {
992  double dValue = m_aColorSlider.GetValue();
993  switch (meMode)
994  {
995  case HUE:
996  setColorComponent( ColorComponent::Hue, dValue * 360.0 );
997  break;
998  case SATURATION:
999  setColorComponent( ColorComponent::Saturation, dValue );
1000  break;
1001  case BRIGHTNESS:
1002  setColorComponent( ColorComponent::Brightness, dValue );
1003  break;
1004  case RED:
1005  setColorComponent( ColorComponent::Red, dValue );
1006  break;
1007  case GREEN:
1008  setColorComponent( ColorComponent::Green, dValue );
1009  break;
1010  case BLUE:
1011  setColorComponent( ColorComponent::Blue, dValue );
1012  break;
1013  }
1014 
1015  update_color(UpdateFlags::All & ~UpdateFlags::ColorSlider);
1016 }
1017 
1018 IMPL_LINK(ColorPickerDialog, ColorModifyMetricHdl, weld::MetricSpinButton&, rEdit, void)
1019 {
1020  UpdateFlags n = UpdateFlags::NONE;
1021 
1022  if (&rEdit == m_xMFHue.get())
1023  {
1024  setColorComponent( ColorComponent::Hue, static_cast<double>(m_xMFHue->get_value(FieldUnit::DEGREE)) );
1025  n = UpdateFlags::All & ~UpdateFlags::HSB;
1026  }
1027  else if (&rEdit == m_xMFSaturation.get())
1028  {
1029  setColorComponent( ColorComponent::Saturation, static_cast<double>(m_xMFSaturation->get_value(FieldUnit::PERCENT)) / 100.0 );
1030  n = UpdateFlags::All & ~UpdateFlags::HSB;
1031  }
1032  else if (&rEdit == m_xMFBrightness.get())
1033  {
1034  setColorComponent( ColorComponent::Brightness, static_cast<double>(m_xMFBrightness->get_value(FieldUnit::PERCENT)) / 100.0 );
1035  n = UpdateFlags::All & ~UpdateFlags::HSB;
1036  }
1037  else if (&rEdit == m_xMFCyan.get())
1038  {
1039  setColorComponent( ColorComponent::Cyan, static_cast<double>(m_xMFCyan->get_value(FieldUnit::PERCENT)) / 100.0 );
1040  n = UpdateFlags::All & ~UpdateFlags::CMYK;
1041  }
1042  else if (&rEdit == m_xMFMagenta.get())
1043  {
1044  setColorComponent( ColorComponent::Magenta, static_cast<double>(m_xMFMagenta->get_value(FieldUnit::PERCENT)) / 100.0 );
1045  n = UpdateFlags::All & ~UpdateFlags::CMYK;
1046  }
1047  else if (&rEdit == m_xMFYellow.get())
1048  {
1049  setColorComponent( ColorComponent::Yellow, static_cast<double>(m_xMFYellow->get_value(FieldUnit::PERCENT)) / 100.0 );
1050  n = UpdateFlags::All & ~UpdateFlags::CMYK;
1051  }
1052  else if (&rEdit == m_xMFKey.get())
1053  {
1054  setColorComponent( ColorComponent::Key, static_cast<double>(m_xMFKey->get_value(FieldUnit::PERCENT)) / 100.0 );
1055  n = UpdateFlags::All & ~UpdateFlags::CMYK;
1056  }
1057 
1058  if (n != UpdateFlags::NONE)
1059  update_color(n);
1060 }
1061 
1062 IMPL_LINK_NOARG(ColorPickerDialog, ColorModifyEditHdl, weld::Entry&, void)
1063 {
1064  UpdateFlags n = UpdateFlags::NONE;
1065 
1066  Color aColor = m_xEDHex->GetColor();
1067 
1068  if (aColor != Color(0xffffffff) && aColor != GetColor())
1069  {
1070  mdRed = static_cast<double>(aColor.GetRed()) / 255.0;
1071  mdGreen = static_cast<double>(aColor.GetGreen()) / 255.0;
1072  mdBlue = static_cast<double>(aColor.GetBlue()) / 255.0;
1073 
1074  RGBtoHSV( mdRed, mdGreen, mdBlue, mdHue, mdSat, mdBri );
1075  RGBtoCMYK( mdRed, mdGreen, mdBlue, mdCyan, mdMagenta, mdYellow, mdKey );
1076  n = UpdateFlags::All & ~UpdateFlags::Hex;
1077  }
1078 
1079  if (n != UpdateFlags::NONE)
1080  update_color(n);
1081 }
1082 
1083 IMPL_LINK(ColorPickerDialog, ColorModifySpinHdl, weld::SpinButton&, rEdit, void)
1084 {
1085  UpdateFlags n = UpdateFlags::NONE;
1086 
1087  if (&rEdit == m_xMFRed.get())
1088  {
1089  setColorComponent( ColorComponent::Red, static_cast<double>(m_xMFRed->get_value()) / 255.0 );
1090  n = UpdateFlags::All & ~UpdateFlags::RGB;
1091  }
1092  else if (&rEdit == m_xMFGreen.get())
1093  {
1094  setColorComponent( ColorComponent::Green, static_cast<double>(m_xMFGreen->get_value()) / 255.0 );
1095  n = UpdateFlags::All & ~UpdateFlags::RGB;
1096  }
1097  else if (&rEdit == m_xMFBlue.get())
1098  {
1099  setColorComponent( ColorComponent::Blue, static_cast<double>(m_xMFBlue->get_value()) / 255.0 );
1100  n = UpdateFlags::All & ~UpdateFlags::RGB;
1101  }
1102 
1103  if (n != UpdateFlags::NONE)
1104  update_color(n);
1105 }
1106 
1107 
1109 {
1110  ColorMode eMode = HUE;
1111 
1112  if (m_xRBRed->get_active())
1113  {
1114  eMode = RED;
1115  }
1116  else if (m_xRBGreen->get_active())
1117  {
1118  eMode = GREEN;
1119  }
1120  else if (m_xRBBlue->get_active())
1121  {
1122  eMode = BLUE;
1123  }
1124  else if (m_xRBSaturation->get_active())
1125  {
1126  eMode = SATURATION;
1127  }
1128  else if (m_xRBBrightness->get_active())
1129  {
1130  eMode = BRIGHTNESS;
1131  }
1132 
1133  if (meMode != eMode)
1134  {
1135  meMode = eMode;
1136  update_color(UpdateFlags::ColorChooser | UpdateFlags::ColorSlider);
1137  }
1138 }
1139 
1140 void ColorPickerDialog::setColorComponent( ColorComponent nComp, double dValue )
1141 {
1142  switch( nComp )
1143  {
1144  case ColorComponent::Red:
1145  mdRed = dValue;
1146  break;
1147  case ColorComponent::Green:
1148  mdGreen = dValue;
1149  break;
1150  case ColorComponent::Blue:
1151  mdBlue = dValue;
1152  break;
1153  case ColorComponent::Hue:
1154  mdHue = dValue;
1155  break;
1156  case ColorComponent::Saturation:
1157  mdSat = dValue;
1158  break;
1159  case ColorComponent::Brightness:
1160  mdBri = dValue;
1161  break;
1162  case ColorComponent::Cyan:
1163  mdCyan = dValue;
1164  break;
1165  case ColorComponent::Yellow:
1166  mdYellow = dValue;
1167  break;
1168  case ColorComponent::Magenta:
1169  mdMagenta = dValue;
1170  break;
1171  case ColorComponent::Key:
1172  mdKey = dValue;
1173  break;
1174  }
1175 
1176  if (nComp == ColorComponent::Red || nComp == ColorComponent::Green || nComp == ColorComponent::Blue)
1177  {
1180  }
1181  else if (nComp == ColorComponent::Hue || nComp == ColorComponent::Saturation || nComp == ColorComponent::Brightness)
1182  {
1185  }
1186  else
1187  {
1190  }
1191 }
1192 
1193 typedef ::cppu::WeakComponentImplHelper< XServiceInfo, XExecutableDialog, XInitialization, XPropertyAccess > ColorPickerBase;
1194 
1195 class ColorPicker : protected ::cppu::BaseMutex, // Struct for right initialization of mutex member! Must be first of baseclasses.
1196  public ColorPickerBase
1197 {
1198 public:
1199  explicit ColorPicker();
1200 
1201  // XInitialization
1202  virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) override;
1203 
1204  // XInitialization
1205  virtual OUString SAL_CALL getImplementationName( ) override;
1206  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
1207  virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
1208 
1209  // XPropertyAccess
1210  virtual Sequence< PropertyValue > SAL_CALL getPropertyValues( ) override;
1211  virtual void SAL_CALL setPropertyValues( const Sequence< PropertyValue >& aProps ) override;
1212 
1213  // XExecutableDialog
1214  virtual void SAL_CALL setTitle( const OUString& aTitle ) override;
1215  virtual sal_Int16 SAL_CALL execute( ) override;
1216 
1217 private:
1219  sal_Int16 mnMode;
1220  Reference<css::awt::XWindow> mxParent;
1221 };
1222 
1224 {
1225  return "com.sun.star.cui.ColorPicker";
1226 }
1227 
1229 {
1230  return static_cast<XWeak*>( new ColorPicker );
1231 }
1232 
1234 {
1235  Sequence< OUString > seq { "com.sun.star.ui.dialogs.ColorPicker" };
1236  return seq;
1237 }
1238 
1239 static const OUStringLiteral gsColorKey( "Color" );
1240 static const OUStringLiteral gsModeKey( "Mode" );
1241 
1243  : ColorPickerBase( m_aMutex )
1244  , mnColor( 0 )
1245  , mnMode( 0 )
1246 {
1247 }
1248 
1249 // XInitialization
1250 void SAL_CALL ColorPicker::initialize( const Sequence< Any >& aArguments )
1251 {
1252  if( aArguments.getLength() == 1 )
1253  {
1254  aArguments[0] >>= mxParent;
1255  }
1256 }
1257 
1258 // XInitialization
1260 {
1262 }
1263 
1264 sal_Bool SAL_CALL ColorPicker::supportsService( const OUString& sServiceName )
1265 {
1266  return cppu::supportsService(this, sServiceName);
1267 }
1268 
1270 {
1272 }
1273 
1274 // XPropertyAccess
1276 {
1277  Sequence< PropertyValue > props(1);
1278  props[0].Name = gsColorKey;
1279  props[0].Value <<= mnColor;
1280  return props;
1281 }
1282 
1284 {
1285  for( sal_Int32 n = 0; n < aProps.getLength(); n++ )
1286  {
1287  if( aProps[n].Name == gsColorKey )
1288  {
1289  aProps[n].Value >>= mnColor;
1290  }
1291  else if( aProps[n].Name == gsModeKey )
1292  {
1293  aProps[n].Value >>= mnMode;
1294  }
1295  }
1296 }
1297 
1298 // XExecutableDialog
1299 void SAL_CALL ColorPicker::setTitle( const OUString& )
1300 {
1301 }
1302 
1303 sal_Int16 SAL_CALL ColorPicker::execute()
1304 {
1305  std::unique_ptr<ColorPickerDialog> xDlg(new ColorPickerDialog(Application::GetFrameWeld(mxParent), mnColor, mnMode));
1306  sal_Int16 ret = xDlg->run();
1307  if (ret)
1308  mnColor = xDlg->GetColor();
1309  return ret;
1310 }
1311 
1312 }
1313 
1314 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetColor(const Color &rCol)
long Width() const
static int toInt(double dValue, double dRange)
std::unique_ptr< weld::SpinButton > m_xMFBlue
virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual bool MouseMove(const MouseEvent &rMEvt) override
FieldUnit
::osl::Mutex m_aMutex
std::unique_ptr< weld::RadioButton > m_xRBGreen
constexpr::Color COL_BLACK(0x00, 0x00, 0x00)
sal_uInt8 GetRed() const
ColorPreviewControl m_aColorPrevious
void SetBlue(sal_uInt8 nBlue)
std::unique_ptr< weld::RadioButton > m_xRBRed
double GetValue() const
long AdjustX(long nHorzMove)
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
IMPL_LINK(ColorPickerDialog, ColorModifyMetricHdl, weld::MetricSpinButton &, rEdit, void)
IMPL_LINK_NOARG(ColorPickerDialog, ColorFieldControlModifydl, ColorFieldControl &, void)
std::unique_ptr< weld::CustomWeld > m_xColorPreview
long Height() const
void ShowPosition(const Point &rPos, bool bUpdate)
std::unique_ptr< weld::MetricSpinButton > m_xMFMagenta
DECL_LINK(ColorFieldControlModifydl, ColorFieldControl &, void)
UpdateFlags
const ColorMode DefaultMode
static const OUStringLiteral gsColorKey("Color")
OUString Name
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
float x
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
std::unique_ptr< weld::RadioButton > m_xRBBlue
double GetY() const
Size const & GetOutputSizePixel() const
VclPtr< VirtualDevice > mxBitmap
NONE
std::unique_ptr< weld::CustomWeld > m_xColorPrevious
ColorFieldControl m_aColorField
std::unique_ptr< weld::MetricSpinButton > m_xMFHue
std::unique_ptr< weld::MetricSpinButton > m_xMFKey
virtual sal_Int16 SAL_CALL execute() override
void SetModifyHdl(const Link< ColorSliderControl &, void > &rLink)
Color GetColor() const
void setX(long nX)
std::unique_ptr< weld::CustomWeld > m_xColorSlider
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)
virtual ~ColorFieldControl() override
Link< ColorFieldControl &, void > maModifyHdl
void setY(long nY)
static Color HSBtoRGB(sal_uInt16 nHue, sal_uInt16 nSaturation, sal_uInt16 nBrightness)
sal_uInt8 GetBlue() const
virtual OUString SAL_CALL getImplementationName() override
void DrawRect(const tools::Rectangle &rRect)
std::unique_ptr< weld::MetricSpinButton > m_xMFYellow
float y
std::unique_ptr< weld::Widget > m_xFISliderLeft
void SetModifyHdl(const Link< ColorFieldControl &, void > &rLink)
virtual void SAL_CALL setPropertyValues(const Sequence< PropertyValue > &aProps) override
std::vector< sal_uInt16 > maPercent_Horiz
void SetLineColor()
static const OUStringLiteral gsModeKey("Mode")
static void RGBtoCMYK(double dR, double dG, double dB, double &fCyan, double &fMagenta, double &fYellow, double &fKey)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
::cppu::WeakComponentImplHelper< XServiceInfo, XExecutableDialog, XInitialization, XPropertyAccess > ColorPickerBase
bool IsDark() const
std::vector< sal_uInt16 > maPercent_Vert
bool SetOutputSizePixel(const Size &rNewSize, bool bErase=true)
BColor hsv2rgb(const BColor &rHSVColor)
MetadataImporterPluginType * result
void ChangePosition(long nY)
static weld::Window * GetFrameWeld(const css::uno::Reference< css::awt::XWindow > &rWindow)
virtual void SAL_CALL initialize(const Sequence< Any > &aArguments) override
VclPtr< VirtualDevice > mxBitmap
void SetFillColor()
static void RGBtoHSV(double dR, double dG, double dB, double &dH, double &dS, double &dV)
Definition: colorpicker.cxx:89
void SetRed(sal_uInt8 nRed)
unsigned char sal_Bool
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
void SetValue(const Color &rColor, ColorMode eMode, double dValue)
std::unique_ptr< weld::HexColorControl > m_xEDHex
ColorPreviewControl m_aColorPreview
Size GetOutputSizePixel() const
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
ColorPickerDialog(weld::Window *pParent, Color nColor, sal_Int16 nMode)
void DrawPixel(const Point &rPt)
long X() const
std::unique_ptr< weld::MetricSpinButton > m_xMFCyan
virtual Sequence< PropertyValue > SAL_CALL getPropertyValues() override
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
std::vector< sal_uInt8 > maRGB_Horiz
sal_uInt8 GetGreen() const
void update_color(UpdateFlags n=UpdateFlags::All)
std::unique_ptr< weld::MetricSpinButton > m_xMFBrightness
void SetValues(Color aColor, ColorMode eMode, double x, double y)
virtual void Resize() override
weld::Entry & rEdit
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
std::unique_ptr< weld::RadioButton > m_xRBSaturation
std::vector< sal_uInt16 > maGrad_Horiz
unsigned char sal_uInt8
static void CMYKtoRGB(double fCyan, double fMagenta, double fYellow, double fKey, double &dR, double &dG, double &dB)
std::unique_ptr< weld::RadioButton > m_xRBBrightness
std::unique_ptr< weld::RadioButton > m_xRBHue
double GetX() const
void SetGreen(sal_uInt8 nGreen)
virtual int get_text_height() const =0
static VclPtr< reference_type > Create(Arg &&...arg)
std::unique_ptr< weld::CustomWeld > m_xColorField
void setColorComponent(ColorComponent nComp, double dValue)
const OUString PERCENT("Percent")
Link< ColorSliderControl &, void > maModifyHdl
const Point & GetPosPixel() const
constexpr::Color COL_WHITE(0xFF, 0xFF, 0xFF)
BColor rgb2hsv(const BColor &rRGBColor)
virtual void Resize() override
void DrawEllipse(const tools::Rectangle &rRect)
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
std::unique_ptr< weld::MetricSpinButton > m_xMFSaturation
std::vector< sal_uInt8 > maRGB_Vert
sal_Int16 GetLevel() const
virtual void SAL_CALL setTitle(const OUString &aTitle) override
struct _ADOKey Key
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::SpinButton > m_xMFRed
Color GetPixel(const Point &rPt) const
virtual void set_size_request(int nWidth, int nHeight)=0
Reference< css::awt::XWindow > mxParent
std::unique_ptr< weld::SpinButton > m_xMFGreen
virtual bool MouseButtonUp(const MouseEvent &rMEvt) override
ColorSliderControl m_aColorSlider
virtual float get_approximate_digit_width() const =0
virtual bool MouseMove(const MouseEvent &rMEvt) override
OUString ColorPicker_getImplementationName()
std::unique_ptr< weld::Widget > m_xFISliderRight
SAL_DLLPRIVATE void DrawOutDev(const Point &, const Size &, const Point &, const Size &, const Printer &)=delete
long Y() const
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
virtual ~ColorSliderControl() override