lib Library API Documentation

koCharSelectDia.cc

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, USA.
00018 */
00019 
00020 #include "koCharSelectDia.h"
00021 #include "koCharSelectDia.moc"
00022 
00023 #include <qlayout.h>
00024 
00025 #include <klocale.h>
00026 #include <kcharselect.h>
00027 #include <kdebug.h>
00028 /******************************************************************/
00029 /* class KoCharSelectDia                                           */
00030 /******************************************************************/
00031 
00032 KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QChar &_chr, const QString &_font, bool _enableFont , bool _modal)
00033     : KDialogBase( Plain, i18n("Select Character"), Ok | Cancel, Ok , parent, name, _modal )
00034 {
00035     initDialog(_chr,_font,_enableFont);
00036 
00037     setButtonOKText(i18n("&Insert"),
00038                       i18n("Insert the selected character in the text"));
00039 
00040 }
00041 
00042 KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QString &_font, const QChar &_chr, bool _modal )
00043     : KDialogBase( Plain, i18n("Select Character"), User1 | Close, User1 , parent, name, _modal )
00044 {
00045     initDialog(_chr,_font,true);
00046 
00047     setButtonText( User1, i18n("&Insert") );
00048     setButtonTip( User1, i18n("Insert the selected character in the text") );
00049 
00050 }
00051 
00052 void KoCharSelectDia::initDialog(const QChar &_chr, const QString &_font, bool /*_enableFont*/)
00053 {
00054    QWidget *page = plainPage();
00055 
00056     grid = new QGridLayout( page, 1, 1, KDialog::marginHint(), KDialog::spacingHint() );
00057 
00058     charSelect = new KCharSelect( page, "", _font, _chr );
00059     connect(charSelect, SIGNAL(doubleClicked()),this, SLOT(slotDoubleClicked()));
00060     charSelect->resize( charSelect->sizeHint() );
00061     charSelect->enableFontCombo( true );
00062     grid->addWidget( charSelect, 0, 0 );
00063 
00064     grid->addColSpacing( 0, charSelect->width() );
00065     grid->addRowSpacing( 0, charSelect->height() );
00066     grid->setRowStretch( 0, 0 );
00067     charSelect->setFocus();
00068 }
00069 
00070 KoCharSelectDia::~KoCharSelectDia()
00071 {
00072 }
00073 
00074 void KoCharSelectDia::closeDialog()
00075 {
00076     KDialogBase::close();
00077 }
00078 
00079 bool KoCharSelectDia::selectChar( QString &_font, QChar &_chr, bool _enableFont )
00080 {
00081     bool res = false;
00082 
00083     KoCharSelectDia *dlg = new KoCharSelectDia( 0L, "Select Character", _chr, _font, _enableFont );
00084     dlg->setFocus();
00085     if ( dlg->exec() == Accepted )
00086     {
00087 
00088         _font = dlg->font();
00089         _chr = dlg->chr();
00090         res = true;
00091     }
00092 
00093     delete dlg;
00094 
00095     return res;
00096 }
00097 
00098 QChar KoCharSelectDia::chr()
00099 {
00100     return charSelect->chr();
00101 }
00102 
00103 QString KoCharSelectDia::font()
00104 {
00105     return charSelect->font();
00106 }
00107 
00108 void KoCharSelectDia::slotUser1()
00109 {
00110     emit insertChar(chr(),font());
00111 }
00112 
00113 void KoCharSelectDia::slotDoubleClicked()
00114 {
00115     emit insertChar(chr(),font());
00116 }
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Mar 11 11:47:40 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003