F:/KPlato/koffice/libs/kofficeui/KoCharSelectDia.cpp

Aller à la documentation de ce fichier.
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., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "KoCharSelectDia.h"
00021 #include "KoCharSelectDia.moc"
00022 
00023 #include <QLayout>
00024 #include <QGridLayout>
00025 
00026 #include <klocale.h>
00027 #include <kcharselect.h>
00028 #include <kdebug.h>
00029 #include <kstdguiitem.h>
00030 
00031 /******************************************************************/
00032 /* class KoCharSelectDia                                           */
00033 /******************************************************************/
00034 
00035 KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QChar &_chr, const QString &_font, bool _enableFont , bool _modal)
00036     : KDialog( parent )
00037 {
00038     setCaption( i18n("Select Character") );
00039     setModal( _modal );
00040     setButtons( Ok | Cancel );
00041     setDefaultButton( Ok );
00042     setObjectName( name );
00043 
00044     initDialog(_chr,_font,_enableFont);
00045 
00046     KGuiItem okItem = KStdGuiItem::ok(); // start from std item to keep the OK icon...
00047     okItem.setText( i18n("&Insert") );
00048     okItem.setWhatsThis( i18n("Insert the selected character in the text") );
00049     setButtonGuiItem( KDialog::Ok, okItem );
00050 }
00051 
00052 KoCharSelectDia::KoCharSelectDia( QWidget *parent, const char *name, const QString &_font, const QChar &_chr, bool _modal )
00053     : KDialog( parent )
00054 {
00055     setCaption( i18n("Select Character") );
00056     setModal( _modal );
00057     setButtons( User1 | Close );
00058     setDefaultButton( User1 );
00059     setObjectName( name );
00060 
00061     initDialog(_chr,_font,true);
00062 
00063     setButtonText( User1, i18n("&Insert") );
00064     setButtonToolTip( User1, i18n("Insert the selected character in the text") );
00065 
00066 }
00067 
00068 void KoCharSelectDia::initDialog(const QChar &_chr, const QString &_font, bool /*_enableFont*/)
00069 {
00070     QWidget *page = mainWidget()/*plainPage()*/;
00071 
00072     grid = new QGridLayout( page );
00073     grid->setMargin(0);
00074     grid->setSpacing(KDialog::spacingHint());
00075 
00076     charSelect = new KCharSelect( page,  _font, _chr );
00077     connect(charSelect, SIGNAL(doubleClicked()),this, SLOT(slotDoubleClicked()));
00078     charSelect->resize( charSelect->sizeHint() );
00079     charSelect->enableFontCombo( true );
00080     grid->addWidget( charSelect, 0, 0 );
00081 
00082     grid->addItem( new QSpacerItem( charSelect->width(), 0 ), 0, 0 );
00083     grid->addItem( new QSpacerItem( 0, charSelect->height() ), 0, 0 );
00084     grid->setRowStretch( 0, 0 );
00085     charSelect->setFocus();
00086 }
00087 
00088 KoCharSelectDia::~KoCharSelectDia()
00089 {
00090 }
00091 
00092 void KoCharSelectDia::closeDialog()
00093 {
00094     KDialog::close();
00095 }
00096 
00097 bool KoCharSelectDia::selectChar( QString &_font, QChar &_chr, bool _enableFont, QWidget* parent, const char* name )
00098 {
00099     bool res = false;
00100 
00101     KoCharSelectDia *dlg = new KoCharSelectDia( parent, name, _chr, _font, _enableFont );
00102     dlg->setFocus();
00103     if ( dlg->exec() == Accepted )
00104     {
00105         _font = dlg->font();
00106         _chr = dlg->chr();
00107         res = true;
00108     }
00109 
00110     delete dlg;
00111 
00112     return res;
00113 }
00114 
00115 QChar KoCharSelectDia::chr() const
00116 {
00117     return charSelect->chr();
00118 }
00119 
00120 QString KoCharSelectDia::font() const
00121 {
00122     return charSelect->font();
00123 }
00124 
00125 void KoCharSelectDia::slotUser1()
00126 {
00127     emit insertChar(chr(),font());
00128 }
00129 
00130 void KoCharSelectDia::slotDoubleClicked()
00131 {
00132     emit insertChar(chr(),font());
00133 }

Généré le Wed Nov 22 23:41:04 2006 pour KPlato par  doxygen 1.5.1-p1