kcharselect.h
00001 /* This file is part of the KDE libraries 00002 00003 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef kcharselect_h 00022 #define kcharselect_h 00023 00024 #include <tqgridview.h> 00025 #include <tqvbox.h> 00026 #include <tqcombobox.h> 00027 #include <tqspinbox.h> 00028 #include <tqstring.h> 00029 #include <tqpoint.h> 00030 #include <tqstringlist.h> 00031 00032 #include <kdelibs_export.h> 00033 00034 class TQFont; 00035 class TQFontDatabase; 00036 class TQMouseEvent; 00037 class TQSpinBox; 00038 class KCharSelectTablePrivate; 00039 class KCharSelectPrivate; 00040 00051 class KDEUI_EXPORT KCharSelectTable : public TQGridView 00052 { 00053 Q_OBJECT 00054 00055 public: 00056 KCharSelectTable( TQWidget *parent, const char *name, const TQString &_font, 00057 const TQChar &_chr, int _tableNum ); 00058 00059 virtual TQSize sizeHint() const; 00060 virtual void resizeEvent( TQResizeEvent * ); 00061 00062 virtual void setFont( const TQString &_font ); 00063 virtual void setChar( const TQChar &_chr ); 00064 virtual void setTableNum( int _tableNum ); 00065 00066 virtual TQChar chr() { return vChr; } 00067 00068 protected: 00069 virtual void paintCell( class TQPainter *p, int row, int col ); 00070 00071 virtual void mousePressEvent( TQMouseEvent *e ) { mouseMoveEvent( e ); } 00072 virtual void mouseDoubleClickEvent ( TQMouseEvent *e ){ mouseMoveEvent( e ); emit doubleClicked();} 00073 virtual void mouseReleaseEvent( TQMouseEvent *e ) { mouseMoveEvent( e ); emit activated( chr() ); emit activated(); } 00074 virtual void mouseMoveEvent( TQMouseEvent *e ); 00075 00076 virtual void keyPressEvent( TQKeyEvent *e ); 00077 00078 void gotoLeft(); 00079 void gotoRight(); 00080 void gotoUp(); 00081 void gotoDown(); 00082 00083 TQString vFont; 00084 TQChar vChr; 00085 int vTableNum; 00086 TQPoint vPos; 00087 TQChar focusItem; 00088 TQPoint focusPos; 00089 int temp; 00090 00091 signals: 00092 void highlighted( const TQChar &c ); 00093 void highlighted(); 00094 void activated( const TQChar &c ); 00095 void activated(); 00096 void focusItemChanged(); 00097 void focusItemChanged( const TQChar &c ); 00098 void tableUp(); 00099 void tableDown(); 00100 void doubleClicked(); 00101 00102 private: 00103 virtual void setFont(const TQFont &f) { TQGridView::setFont(f); } 00104 void setToolTips(); 00105 protected: 00106 virtual void virtual_hook( int id, void* data ); 00107 private: 00108 KCharSelectTablePrivate* const d; 00109 }; 00110 00140 class KDEUI_EXPORT KCharSelect : public TQVBox 00141 { 00142 Q_OBJECT 00143 Q_PROPERTY( TQString fontFamily READ font WRITE setFont ) 00144 Q_PROPERTY( int tableNum READ tableNum WRITE setTableNum ) 00145 Q_PROPERTY( bool fontComboEnabled READ isFontComboEnabled WRITE enableFontCombo ) 00146 Q_PROPERTY( bool tableSpinBoxEnabled READ isTableSpinBoxEnabled WRITE enableTableSpinBox ) 00147 00148 public: 00154 KCharSelect( TQWidget *parent, const char *name, 00155 const TQString &font = TQString::null, const TQChar &chr = ' ', int tableNum = 0 ); 00156 ~KCharSelect(); 00160 virtual TQSize sizeHint() const; 00161 00165 virtual void setFont( const TQString &font ); 00166 00170 virtual void setChar( const TQChar &chr ); 00171 00175 virtual void setTableNum( int tableNum ); 00176 00180 virtual TQChar chr() const { return charTable->chr(); } 00181 00185 virtual TQString font() const { return fontCombo->currentText(); } 00186 00190 virtual int tableNum() const { return tableSpinBox->value(); } 00191 00197 virtual void enableFontCombo( bool e ) { fontCombo->setEnabled( e ); } 00198 00205 virtual void enableTableSpinBox( bool e ) { tableSpinBox->setEnabled( e ); } 00206 00213 virtual bool isFontComboEnabled() const { return fontCombo->isEnabled(); } 00214 00221 virtual bool isTableSpinBoxEnabled() const { return tableSpinBox->isEnabled(); } 00222 00223 protected: 00224 virtual void fillFontCombo(); 00225 static void cleanupFontDatabase(); 00226 00227 TQComboBox *fontCombo; 00228 TQSpinBox *tableSpinBox; 00229 KCharSelectTable *charTable; 00230 TQStringList fontList; 00231 static TQFontDatabase * fontDataBase; 00232 00233 protected slots: 00234 void fontSelected( const TQString &_font ); 00235 void tableChanged( int _value ); 00236 void charHighlighted( const TQChar &c ) { emit highlighted( c ); } 00237 void charHighlighted() { emit highlighted(); } 00238 void charActivated( const TQChar &c ) { emit activated( c ); } 00239 void charActivated() { emit activated(); } 00240 void charFocusItemChanged() { emit focusItemChanged(); } 00241 void charFocusItemChanged( const TQChar &c ) { emit focusItemChanged( c ); } 00242 void charTableUp() { if ( tableNum() < 255 ) setTableNum( tableNum() + 1 ); } 00243 void charTableDown() { if ( tableNum() > 0 ) setTableNum( tableNum() - 1 ); } 00244 void slotDoubleClicked() { emit doubleClicked(); } 00245 void slotUnicodeEntered(); 00246 void slotUpdateUnicode( const TQChar &c ); 00247 signals: 00248 void highlighted( const TQChar &c ); 00249 void highlighted(); 00250 void activated( const TQChar &c ); 00251 void activated(); 00252 void fontChanged( const TQString &_font ); 00253 void focusItemChanged(); 00254 void focusItemChanged( const TQChar &c ); 00255 void doubleClicked(); 00256 00257 private: 00258 virtual void setFont(const TQFont &f) { TQVBox::setFont(f); } 00259 protected: 00260 virtual void virtual_hook( int id, void* data ); 00261 private: 00262 class KCharSelectPrivate; 00263 KCharSelectPrivate* const d; 00264 }; 00265 00266 #endif