summaryrefslogtreecommitdiffstats
path: root/tdeui/tests/kdualcolortest.cpp
blob: ea749cd6e449d60adca95cfbaee30b97745836a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "kdualcolortest.h"
#include <kdualcolorbutton.h>
#include <kapplication.h>
#include <klocale.h>
#include <tqlayout.h>
#include <tqpalette.h>

KDualColorWidget::KDualColorWidget(TQWidget *parent, const char *name)
    : TQWidget(parent, name)
{
    lbl = new TQLabel("Testing, testing, 1, 2, 3...", this);
    KDualColorButton *colorBtn =
        new KDualColorButton(lbl->colorGroup().text(),
                             lbl->colorGroup().background(), this);
    connect(colorBtn, TQT_SIGNAL(fgChanged(const TQColor &)),
            TQT_SLOT(slotFgChanged(const TQColor &)));
    connect(colorBtn, TQT_SIGNAL(bgChanged(const TQColor &)),
            TQT_SLOT(slotBgChanged(const TQColor &)));
    connect(colorBtn, TQT_SIGNAL(currentChanged(KDualColorButton::DualColor)),
            TQT_SLOT(slotCurrentChanged(KDualColorButton::DualColor)));
    
    TQHBoxLayout *layout = new TQHBoxLayout(this, 5);
    layout->addWidget(colorBtn, 0);
    layout->addWidget(lbl, 1);
    layout->activate();
    resize(sizeHint());
}

void KDualColorWidget::slotFgChanged(const TQColor &c)
{
    TQPalette p = lbl->palette();
    p.setColor(TQColorGroup::Text, c);
    lbl->setPalette(p);
}

void KDualColorWidget::slotBgChanged(const TQColor &c)
{
    TQPalette p = lbl->palette();
    TQBrush b(c, SolidPattern);
    p.setBrush(TQColorGroup::Background, b);
    setPalette(p);
}

void KDualColorWidget::slotCurrentChanged(KDualColorButton::DualColor current)
{
    if(current == KDualColorButton::Foreground)
        tqDebug("Foreground Button Selected.");
    else
        tqDebug("Background Button Selected.");
}

int main(int argc, char **argv)
{
    TDEApplication *app = new TDEApplication(argc, argv, "KDualColorTest");
    KDualColorWidget w;
    app->setMainWidget(&w);
    w.show();
    return(app->exec());
}

#include "kdualcolortest.moc"