keditcl.h
00001 /* This file is part of the KDE libraries 00002 00003 Copyright (C) 1996 Bernd Johannes Wuebben <wuebben@math.cornell.edu> 00004 Copyright (C) 2000 Waldo Bastian <bastian@kde.org> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 #ifndef __KEDITCL_H__ 00022 #define __KEDITCL_H__ 00023 00024 #include <tqmultilineedit.h> 00025 #include <tqstring.h> 00026 #include <kdialogbase.h> 00027 00028 class TQDropEvent; 00029 class TQPushButton; 00030 class TQCheckBox; 00031 class TQRadioButton; 00032 class TQTextStream; 00033 class KHistoryCombo; 00034 class KIntNumInput; 00035 class TQVButtonGroup; 00036 00037 class KDEUI_EXPORT KEdGotoLine : public KDialogBase 00038 { 00039 Q_OBJECT 00040 00041 public: 00042 KEdGotoLine( TQWidget *parent=0, const char *name=0, bool modal=true ); 00043 int getLineNumber(); 00044 00045 public slots: 00046 void selected( int ); 00047 00048 private: 00049 KIntNumInput *lineNum; 00050 00051 protected: 00052 virtual void virtual_hook( int id, void* data ); 00053 private: 00054 class KEdGotoLinePrivate; 00055 KEdGotoLinePrivate *d; 00056 }; 00057 00059 class KDEUI_EXPORT KEdFind : public KDialogBase 00060 { 00061 Q_OBJECT 00062 Q_PROPERTY( TQString text READ getText WRITE setText ) 00063 Q_PROPERTY( bool caseSensitivity READ case_sensitive WRITE setCaseSensitive ) 00064 Q_PROPERTY( bool direction READ get_direction WRITE setDirection ) 00065 public: 00066 00067 KEdFind( TQWidget *parent = 0, const char *name=0, bool modal=true); 00068 ~KEdFind(); 00069 00070 TQString getText() const; 00071 void setText(TQString string); 00072 void setCaseSensitive( bool b ); 00073 bool case_sensitive() const; 00074 void setDirection( bool b ); 00075 bool get_direction() const; 00076 00081 KHistoryCombo *searchCombo() const; 00082 00083 protected slots: 00084 void slotCancel( void ); 00085 void slotUser1( void ); 00086 void textSearchChanged ( const TQString & ); 00087 00088 protected: 00089 TQVButtonGroup* group; 00090 00091 private: 00092 TQCheckBox *sensitive; 00093 TQCheckBox *direction; 00094 00095 virtual void done(int i ) { KDialogBase::done(i); } 00096 00097 signals: 00098 00099 void search(); 00100 void done(); 00101 protected: 00102 virtual void virtual_hook( int id, void* data ); 00103 private: 00104 class KEdFindPrivate; 00105 KEdFindPrivate *d; 00106 }; 00107 00109 class KDEUI_EXPORT KEdReplace : public KDialogBase 00110 { 00111 Q_OBJECT 00112 00113 public: 00114 00115 KEdReplace ( TQWidget *parent = 0, const char *name=0, bool modal=true ); 00116 ~KEdReplace(); 00117 00118 TQString getText(); 00119 TQString getReplaceText(); 00120 void setText(TQString); 00121 00126 KHistoryCombo *searchCombo() const; 00127 00132 KHistoryCombo *replaceCombo() const; 00133 00134 bool case_sensitive(); 00135 bool get_direction(); 00136 00137 protected slots: 00138 void slotCancel( void ); 00139 void slotClose( void ); 00140 void slotUser1( void ); 00141 void slotUser2( void ); 00142 void slotUser3( void ); 00143 void textSearchChanged ( const TQString & ); 00144 00145 private: 00146 TQCheckBox *sensitive; 00147 TQCheckBox *direction; 00148 00149 virtual void done(int i ) { KDialogBase::done(i); } 00150 00151 signals: 00152 void replace(); 00153 void find(); 00154 void replaceAll(); 00155 void done(); 00156 protected: 00157 virtual void virtual_hook( int id, void* data ); 00158 private: 00159 class KEdReplacePrivate; 00160 KEdReplacePrivate *d; 00161 }; 00162 00163 00171 class KDEUI_EXPORT_DEPRECATED KEdit : public TQMultiLineEdit 00172 { 00173 Q_OBJECT 00174 00175 public: 00179 KEdit (TQWidget *_parent=NULL, const char *name=NULL); 00180 00181 ~KEdit(); 00182 00187 enum { NONE, 00188 FORWARD, 00189 BACKWARD }; 00193 void insertText(TQTextStream *); 00194 00201 void saveText(TQTextStream *, bool softWrap); 00202 void saveText(TQTextStream *); // KDE 4.0: remove 00203 00208 void selectFont(); 00209 00213 void search(); 00214 00223 bool repeatSearch(); 00224 00228 void replace(); 00229 00233 void doGotoLine(); 00234 00238 void cleanWhiteSpace(); 00239 00245 void installRBPopup( TQPopupMenu* ); 00246 00252 int currentLine(); 00253 00263 int currentColumn(); 00264 00265 00269 void spellcheck_start(); 00270 00274 void spellcheck_stop(); 00275 00282 void setOverwriteEnabled(bool b); 00283 00284 TQString selectWordUnderCursor(); 00285 00287 TQPopupMenu *createPopupMenu( const TQPoint& pos ); 00288 00289 void setAutoUpdate(bool b); 00290 00291 signals: 00298 void gotUrlDrop(TQDropEvent* e); 00299 00305 void CursorPositionChanged(); 00306 00316 void toggle_overwrite_signal(); 00317 00318 public slots: 00322 void corrected (const TQString &originalword, const TQString &newword, unsigned int pos); 00326 void misspelling (const TQString &word, const TQStringList &, unsigned int pos); 00327 private slots: 00328 00333 void search_slot(); 00334 00338 void searchdone_slot(); 00339 00343 void replace_slot(); 00344 00348 void replace_all_slot(); 00349 00353 void replace_search_slot(); 00354 00358 void replacedone_slot(); 00359 00363 void slotCursorPositionChanged(); 00364 00365 protected: 00366 void computePosition(); 00367 int doSearch(TQString s_pattern, bool case_sensitive, 00368 bool regex, bool forward,int line, int col); 00369 00370 int doReplace(TQString s_pattern, bool case_sensitive, 00371 bool regex, bool forward,int line, int col,bool replace); 00372 00376 void posToRowCol(unsigned int pos, unsigned int &line, unsigned int &col); 00377 00381 virtual void create( WId = 0, bool initializeWindow = true, 00382 bool destroyOldWindow = true ); 00383 00387 virtual void ensureCursorVisible(); 00388 virtual void setCursor( const TQCursor & ); 00389 virtual void viewportPaintEvent( TQPaintEvent* ); 00390 00391 protected: 00392 00393 void keyPressEvent ( TQKeyEvent * ); 00394 00395 // DnD interface 00396 void dragMoveEvent(TQDragMoveEvent* e); 00397 void dragEnterEvent(TQDragEnterEvent* e); 00398 void dropEvent(TQDropEvent* e); 00399 void contentsDragMoveEvent(TQDragMoveEvent* e); 00400 void contentsDragEnterEvent(TQDragEnterEvent* e); 00401 void contentsDropEvent(TQDropEvent* e); 00402 00403 private: 00404 TQTimer* repaintTimer; 00405 00406 QString killbufferstring; 00407 TQWidget *parent; 00408 KEdFind *srchdialog; 00409 KEdReplace *replace_dialog; 00410 KEdGotoLine *gotodialog; 00411 00412 TQString pattern; 00413 00414 bool can_replace; 00415 bool killing; 00416 bool killtrue; 00417 bool lastwasanewline; 00418 bool saved_readonlystate; 00419 int last_search; 00420 int last_replace; 00421 int replace_all_line; 00422 int replace_all_col; 00423 00424 int line_pos, col_pos; 00425 bool fill_column_is_set; 00426 bool word_wrap_is_set; 00427 int fill_column_value; 00428 00429 protected: 00430 virtual void virtual_hook( int id, void* data ); 00431 private: 00432 class KEditPrivate; 00433 KEditPrivate *d; 00434 }; 00435 00436 #endif