~ubuntu-branches/ubuntu/edgy/koffice/edgy-updates

« back to all changes in this revision

Viewing changes to lib/kofficeui/koCharSelectDia.cc

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20040509113300-xi5t1z4yxe7n03x7
Tags: upstream-1.3.1
ImportĀ upstreamĀ versionĀ 1.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
 
3
 
 
4
   This library is free software; you can redistribute it and/or
 
5
   modify it under the terms of the GNU Library General Public
 
6
   License as published by the Free Software Foundation; either
 
7
   version 2 of the License, or (at your option) any later version.
 
8
 
 
9
   This library is distributed in the hope that it will be useful,
 
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
   Library General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU Library General Public License
 
15
   along with this library; see the file COPYING.LIB.  If not, write to
 
16
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
   Boston, MA 02111-1307, USA.
 
18
*/
 
19
 
 
20
#include "koCharSelectDia.h"
 
21
#include "koCharSelectDia.moc"
 
22
 
 
23
#include <qlayout.h>
 
24
 
 
25
#include <klocale.h>
 
26
#include <kcharselect.h>
 
27
#include <kdebug.h>
 
28
/******************************************************************/
 
29
/* class KoCharSelectDia                                           */
 
30
/******************************************************************/
 
31
 
 
32
KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QChar &_chr, const QString &_font, bool _enableFont , bool _modal)
 
33
    : KDialogBase( Plain, i18n("Select Character"), Ok | Cancel, Ok , parent, name, _modal )
 
34
{
 
35
    initDialog(_chr,_font,_enableFont);
 
36
 
 
37
    setButtonOKText(i18n("&Insert"),
 
38
                      i18n("Insert the selected character in the text"));
 
39
 
 
40
}
 
41
 
 
42
KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QString &_font, const QChar &_chr, bool _modal )
 
43
    : KDialogBase( Plain, i18n("Select Character"), User1 | Close, User1 , parent, name, _modal )
 
44
{
 
45
    initDialog(_chr,_font,true);
 
46
 
 
47
    setButtonText( User1, i18n("&Insert") );
 
48
    setButtonTip( User1, i18n("Insert the selected character in the text") );
 
49
 
 
50
}
 
51
 
 
52
void KoCharSelectDia::initDialog(const QChar &_chr, const QString &_font, bool /*_enableFont*/)
 
53
{
 
54
   QWidget *page = plainPage();
 
55
 
 
56
    grid = new QGridLayout( page, 1, 1, KDialog::marginHint(), KDialog::spacingHint() );
 
57
 
 
58
    charSelect = new KCharSelect( page, "", _font, _chr );
 
59
    connect(charSelect, SIGNAL(doubleClicked()),this, SLOT(slotDoubleClicked()));
 
60
    charSelect->resize( charSelect->sizeHint() );
 
61
    charSelect->enableFontCombo( true );
 
62
    grid->addWidget( charSelect, 0, 0 );
 
63
 
 
64
    grid->addColSpacing( 0, charSelect->width() );
 
65
    grid->addRowSpacing( 0, charSelect->height() );
 
66
    grid->setRowStretch( 0, 0 );
 
67
    charSelect->setFocus();
 
68
}
 
69
 
 
70
KoCharSelectDia::~KoCharSelectDia()
 
71
{
 
72
}
 
73
 
 
74
void KoCharSelectDia::closeDialog()
 
75
{
 
76
    KDialogBase::close();
 
77
}
 
78
 
 
79
bool KoCharSelectDia::selectChar( QString &_font, QChar &_chr, bool _enableFont )
 
80
{
 
81
    bool res = false;
 
82
 
 
83
    KoCharSelectDia *dlg = new KoCharSelectDia( 0L, "Select Character", _chr, _font, _enableFont );
 
84
    dlg->setFocus();
 
85
    if ( dlg->exec() == Accepted )
 
86
    {
 
87
 
 
88
        _font = dlg->font();
 
89
        _chr = dlg->chr();
 
90
        res = true;
 
91
    }
 
92
 
 
93
    delete dlg;
 
94
 
 
95
    return res;
 
96
}
 
97
 
 
98
QChar KoCharSelectDia::chr()
 
99
{
 
100
    return charSelect->chr();
 
101
}
 
102
 
 
103
QString KoCharSelectDia::font()
 
104
{
 
105
    return charSelect->font();
 
106
}
 
107
 
 
108
void KoCharSelectDia::slotUser1()
 
109
{
 
110
    emit insertChar(chr(),font());
 
111
}
 
112
 
 
113
void KoCharSelectDia::slotDoubleClicked()
 
114
{
 
115
    emit insertChar(chr(),font());
 
116
}