summaryrefslogtreecommitdiffstats
path: root/ksirc/charSelector.cpp
blob: 49f5a364c6078aed23ceb562af207e97eeb9ca2f (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* ascii table for ksirc - Robbie Ward <linuxphreak@gmx.co.uk>*/

#include "charSelector.h"
#include "charSelector.moc"

#include <tqlayout.h>
#include <tqpushbutton.h>

#include <klocale.h>

charSelector::charSelector(TQWidget *tqparent, const char* name)
           : KDialog(tqparent, name, false)
{
  testLayout = new TQVBoxLayout(this);
  testLayout->setSpacing( spacingHint() );
  testLayout->setMargin( marginHint() );

  charSelect = new KCharSelect(this, TQCString(name) + "_kcharselector", "", 0);
  testLayout->addWidget(charSelect);
  charSelect->installEventFilter(this);

  connect(charSelect, TQT_SIGNAL(doubleClicked()), TQT_SLOT(insertText()));

  TQHBoxLayout *buttonLayout = new TQHBoxLayout;
  buttonLayout->setSpacing( spacingHint() );

  insertButton = new TQPushButton(i18n("&Insert Char"), this);
  connect(insertButton, TQT_SIGNAL(clicked()), TQT_SLOT(insertText()));
  buttonLayout->addWidget(insertButton);

  TQSpacerItem *spacer = new TQSpacerItem(50, 20, TQSizePolicy::Expanding, TQSizePolicy::Expanding);
  buttonLayout->addItem(spacer);

  testLayout->addLayout(buttonLayout);
}

charSelector::~charSelector()
{
    delete charSelect;
    charSelect = 0x0;
}

void charSelector::insertText()
{
  emit clicked();
}

void charSelector::setFont( const TQString &font )
{
    charSelect->setFont(font);
}

void charSelector::reject()
{
    KDialog::reject();
    close();
}

void charSelector::keyPressEvent(TQKeyEvent *e)
{
    KDialog::keyPressEvent(e);
}

bool charSelector::eventFilter ( TQObject *, TQEvent * e )
{
    if ( e->type() == TQEvent::AccelOverride ) {
	// special processing for key press
	TQKeyEvent *k = (TQKeyEvent *)e;
	if(k->key() == Key_Escape){
            keyPressEvent(k);
	    return TRUE; // eat event
	}
    }
    // standard event processing
    return FALSE;
}