summaryrefslogtreecommitdiffstats
path: root/lib/kopainter/ko_gray_widget.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2021-05-23 20:48:35 +0900
committerMichele Calgaro <[email protected]>2021-05-29 15:16:28 +0900
commit8b78a8791bc539bcffe7159f9d9714d577cb3d7d (patch)
tree1328291f966f19a22d7b13657d3f01a588eb1083 /lib/kopainter/ko_gray_widget.cpp
parent95834e2bdc5e01ae1bd21ac0dfa4fa1d2417fae9 (diff)
downloadkoffice-8b78a8791bc539bcffe7159f9d9714d577cb3d7d.tar.gz
koffice-8b78a8791bc539bcffe7159f9d9714d577cb3d7d.zip
Renaming of files in preparation for code style tools.
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'lib/kopainter/ko_gray_widget.cpp')
-rw-r--r--lib/kopainter/ko_gray_widget.cpp157
1 files changed, 157 insertions, 0 deletions
diff --git a/lib/kopainter/ko_gray_widget.cpp b/lib/kopainter/ko_gray_widget.cpp
new file mode 100644
index 00000000..af09dfa0
--- /dev/null
+++ b/lib/kopainter/ko_gray_widget.cpp
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 1999 Matthias Elter ([email protected])
+ * Copyright (c) 2001-2002 Igor Jansen ([email protected])
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#include "ko_gray_widget.h"
+
+#include <tqlayout.h>
+#include <tqhbox.h>
+#include <tqlabel.h>
+#include <tqspinbox.h>
+#include <tqcolor.h>
+
+#include <kdebug.h>
+
+#include <koFrameButton.h>
+#include <koColorSlider.h>
+#include <kcolordialog.h>
+
+KoGrayWidget::KoGrayWidget(TQWidget *parent, const char *name) : super(parent, name)
+{
+ m_ColorButton = new KDualColorButton(this);
+ TQ_CHECK_PTR(m_ColorButton);
+
+ m_ColorButton -> setFixedSize(m_ColorButton->sizeHint());
+ TQGridLayout *mGrid = new TQGridLayout(this, 3, 5, 5, 2);
+
+ /* setup color sliders */
+ mSlider = new KoColorSlider(this);
+ mSlider->setFocusPolicy( TQ_ClickFocus );
+ mSlider->setMaximumHeight(20);
+ mSlider->slotSetRange(0, 255);
+ mSlider->slotSetColor1(TQColor(255, 255, 255));
+ mSlider->slotSetColor2(TQColor(0, 0, 0));
+
+ /* setup slider labels */
+ mLabel = new TQLabel("K:", this);
+ mLabel->setFixedWidth(12);
+ mLabel->setFixedHeight(20);
+
+ /* setup spin box */
+ mIn = new TQSpinBox(0, 255, 1, this);
+ mIn->setFixedWidth(50);
+ mIn->setFixedHeight(20);
+ mIn->setFocusPolicy( TQ_ClickFocus );
+
+ mGrid->addMultiCellWidget(m_ColorButton, 0, 3, 0, 0, TQt::AlignTop);
+ mGrid->addWidget(mLabel, 0, 1);
+ mGrid->addMultiCellWidget(mSlider, 0, 0, 2, 3);
+ mGrid->addWidget(mIn, 0, 4);
+
+ connect(m_ColorButton, TQT_SIGNAL(fgChanged(const TQColor &)), this, TQT_SLOT(slotFGColorSelected(const TQColor &)));
+ connect(m_ColorButton, TQT_SIGNAL(bgChanged(const TQColor &)), this, TQT_SLOT(slotBGColorSelected(const TQColor &)));
+
+ /* connect color slider */
+ connect(mSlider, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotChanged(int)));
+
+ /* connect spin box */
+ connect(mIn, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotChanged(int)));
+}
+
+void KoGrayWidget::slotChanged(int v)
+{
+ v = 255 - v;
+
+ if (m_ColorButton->current() == KDualColorButton::Foreground){
+ slotFGColorSelected( TQColor( v, v, v));
+ }
+ else{
+ slotBGColorSelected( TQColor( v, v, v));
+ }
+}
+
+void KoGrayWidget::setFgColor(const TQColor & c)
+{
+ blockSignals(true);
+ slotFGColorSelected(c);
+ blockSignals(false);
+}
+
+void KoGrayWidget::setBgColor(const TQColor & c)
+{
+ blockSignals(true);
+ slotBGColorSelected(c);
+ blockSignals(false);
+}
+
+void KoGrayWidget::update(const TQColor & fgColor, const TQColor & bgColor)
+{
+
+ m_fgColor = fgColor;
+ m_bgColor = bgColor;
+
+ TQColor color = (m_ColorButton->current() == KDualColorButton::Foreground)? m_fgColor : m_bgColor;
+
+ disconnect(mSlider, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotChanged(int)));
+ disconnect(mIn, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotChanged(int)));
+
+ mIn->blockSignals(true);
+ mSlider->blockSignals(true);
+ double v = color.red() + color.green() + color.blue();
+ v /= 3.0;
+ v = 255.0 - v;
+ mIn->setValue(static_cast<int>(v));
+ mSlider->slotSetValue(static_cast<int>(v));
+ mIn->blockSignals(false);
+ mSlider->blockSignals(false);
+
+ connect(mSlider, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotChanged(int)));
+ connect(mIn, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotChanged(int)));
+}
+
+void KoGrayWidget::slotFGColorSelected(const TQColor& c)
+{
+ m_fgColor = c;
+
+ disconnect(m_ColorButton, TQT_SIGNAL(fgChanged(const TQColor &)), this, TQT_SLOT(slotFGColorSelected(const TQColor &)));
+ m_ColorButton->setForeground( m_fgColor );
+ connect(m_ColorButton, TQT_SIGNAL(fgChanged(const TQColor &)), this, TQT_SLOT(slotFGColorSelected(const TQColor &)));
+
+ emit sigFgColorChanged(m_fgColor);
+}
+
+void KoGrayWidget::slotBGColorSelected(const TQColor& c)
+{
+ m_bgColor = c;
+
+ disconnect(m_ColorButton, TQT_SIGNAL(bgChanged(const TQColor &)), this, TQT_SLOT(slotBGColorSelected(const TQColor &)));
+ m_ColorButton->setBackground( m_bgColor );
+ connect(m_ColorButton, TQT_SIGNAL(bgChanged(const TQColor &)), this, TQT_SLOT(slotBGColorSelected(const TQColor &)));
+
+ emit sigBgColorChanged(m_bgColor);
+}
+
+void KoGrayWidget::currentChanged(KDualColorButton::DualColor s)
+{
+ if(s == KDualColorButton::Foreground)
+ slotFGColorSelected(m_ColorButton->currentColor());
+ else
+ slotBGColorSelected(m_ColorButton->currentColor());
+}
+
+#include "ko_gray_widget.moc"