home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qlineedit.h < prev    next >
C/C++ Source or Header  |  2001-10-11  |  7KB  |  220 lines

  1. /**********************************************************************
  2. ** $Id:  qt/qlineedit.h   3.0.0   edited Sep 21 17:17 $
  3. **
  4. ** Definition of QLineEdit widget class
  5. **
  6. ** Created : 941011
  7. **
  8. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  9. **
  10. ** This file is part of the widgets module of the Qt GUI Toolkit.
  11. **
  12. ** This file may be distributed under the terms of the Q Public License
  13. ** as defined by Trolltech AS of Norway and appearing in the file
  14. ** LICENSE.QPL included in the packaging of this file.
  15. **
  16. ** This file may be distributed and/or modified under the terms of the
  17. ** GNU General Public License version 2 as published by the Free Software
  18. ** Foundation and appearing in the file LICENSE.GPL included in the
  19. ** packaging of this file.
  20. **
  21. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  22. ** licenses may use this file in accordance with the Qt Commercial License
  23. ** Agreement provided with the Software.
  24. **
  25. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  26. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27. **
  28. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  29. **   information about Qt Commercial License Agreements.
  30. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  31. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  32. **
  33. ** Contact info@trolltech.com if any conditions of this licensing are
  34. ** not clear to you.
  35. **
  36. **********************************************************************/
  37.  
  38. #ifndef QLINEEDIT_H
  39. #define QLINEEDIT_H
  40.  
  41. struct QLineEditPrivate;
  42.  
  43. class QValidator;
  44. class QPopupMenu;
  45.  
  46. #ifndef QT_H
  47. #include "qframe.h"
  48. #include "qstring.h"
  49. #endif // QT_H
  50.  
  51. #ifndef QT_NO_LINEEDIT
  52.  
  53. class Q_EXPORT QLineEdit : public QFrame
  54. {
  55.     Q_OBJECT
  56.     Q_ENUMS( EchoMode )
  57.     Q_PROPERTY( QString text READ text WRITE setText )
  58.     Q_PROPERTY( int maxLength READ maxLength WRITE setMaxLength )
  59.     Q_PROPERTY( bool frame READ frame WRITE setFrame )
  60.     Q_PROPERTY( EchoMode echoMode READ echoMode WRITE setEchoMode )
  61.     Q_PROPERTY( QString displayText READ displayText )
  62.     Q_PROPERTY( int cursorPosition READ cursorPosition WRITE setCursorPosition )
  63.     Q_PROPERTY( Alignment alignment READ alignment WRITE setAlignment )
  64.     Q_PROPERTY( bool edited READ edited WRITE setEdited )
  65.     Q_PROPERTY( bool hasMarkedText READ hasMarkedText DESIGNABLE false )
  66.     Q_PROPERTY( bool hasSelectedText READ hasSelectedText )
  67.     Q_PROPERTY( QString markedText READ markedText DESIGNABLE false )
  68.     Q_PROPERTY( QString selectedText READ selectedText )
  69.     Q_PROPERTY( bool dragEnabled READ dragEnabled WRITE setDragEnabled )
  70.     Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
  71.     Q_PROPERTY( bool undoAvailable READ isUndoAvailable )
  72.     Q_PROPERTY( bool redoAvailable READ isRedoAvailable )
  73.  
  74. public:
  75.     QLineEdit( QWidget* parent, const char* name=0 );
  76.     QLineEdit( const QString &, QWidget* parent, const char* name=0 );
  77.     ~QLineEdit();
  78.  
  79.     QString text() const;
  80.  
  81.     QString displayText() const;
  82.  
  83.     int maxLength() const;
  84.  
  85.     bool frame() const;
  86.  
  87.     enum EchoMode { Normal, NoEcho, Password };
  88.     EchoMode echoMode() const;
  89.  
  90.     bool isReadOnly() const;
  91.  
  92.     const QValidator * validator() const;
  93.  
  94.     QSize sizeHint() const;
  95.     QSize minimumSizeHint() const;
  96.  
  97.     int cursorPosition() const;
  98.     bool validateAndSet( const QString &, int, int, int );
  99.  
  100.     int alignment() const;
  101.  
  102. #ifndef QT_NO_COMPAT
  103.     void cursorLeft( bool mark, int steps = 1 ) { cursorForward( mark, -steps ); }
  104.     void cursorRight( bool mark, int steps = 1 ) { cursorForward( mark, steps ); }
  105. #endif
  106.     void cursorForward( bool mark, int steps = 1 );
  107.     void cursorBackward( bool mark, int steps = 1 );
  108.     void cursorWordForward( bool mark );
  109.     void cursorWordBackward( bool mark );
  110.     void backspace();
  111.     void del();
  112.     void home( bool mark );
  113.     void end( bool mark );
  114.  
  115.     void setEdited( bool );
  116.     bool edited() const;
  117.  
  118.     bool hasSelectedText() const;
  119.     QString selectedText() const;
  120.     bool getSelection( int *start, int *end );
  121.     bool isUndoAvailable() const;
  122.     bool isRedoAvailable() const;
  123.  
  124. #ifndef QT_NO_COMPAT
  125.     bool hasMarkedText() const { return hasSelectedText(); }
  126.     QString markedText() const { return selectedText(); }
  127. #endif
  128.     bool dragEnabled() const;
  129.     int characterAt( int xpos, QChar *chr ) const;
  130.  
  131. public slots:
  132.     virtual void setText( const QString &);
  133.     virtual void selectAll();
  134.     virtual void deselect();
  135.     virtual void clearValidator();
  136.     virtual void insert( const QString &);
  137.     virtual void clear();
  138.     virtual void undo();
  139.     virtual void redo();
  140.     virtual void setMaxLength( int );
  141.     virtual void setFrame( bool );
  142.     virtual void setEchoMode( EchoMode );
  143.     virtual void setReadOnly( bool );
  144.     virtual void setValidator( const QValidator * );
  145.     virtual void setFont( const QFont & );
  146.     virtual void setPalette( const QPalette & );
  147.     virtual void setSelection( int, int );
  148.     virtual void setCursorPosition( int );
  149.     virtual void setAlignment( int flag );
  150. #ifndef QT_NO_CLIPBOARD
  151.     virtual void cut();
  152.     virtual void copy() const;
  153.     virtual void paste();
  154. #endif
  155.     virtual void setDragEnabled( bool b );
  156.  
  157. signals:
  158.     void textChanged( const QString &);
  159.     void returnPressed();
  160.     void selectionChanged();
  161.  
  162. protected:
  163.     bool event( QEvent * );
  164.     void mousePressEvent( QMouseEvent * );
  165.     void mouseMoveEvent( QMouseEvent * );
  166.     void mouseReleaseEvent( QMouseEvent * );
  167.     void mouseDoubleClickEvent( QMouseEvent * );
  168.     void keyPressEvent( QKeyEvent * );
  169.     void imStartEvent( QIMEvent * );
  170.     void imComposeEvent( QIMEvent * );
  171.     void imEndEvent( QIMEvent * );
  172.     void focusInEvent( QFocusEvent * );
  173.     void focusOutEvent( QFocusEvent * );
  174.     void drawContents( QPainter *painter );
  175.     void resizeEvent( QResizeEvent * );
  176. #ifndef QT_NO_DRAGANDDROP
  177.     void dragEnterEvent( QDragEnterEvent * );
  178.     void dragMoveEvent( QDragMoveEvent *e );
  179.     void dragLeaveEvent( QDragLeaveEvent *e );
  180.     void dropEvent( QDropEvent * );
  181. #endif
  182.     void contextMenuEvent( QContextMenuEvent * );
  183.  
  184. #ifndef QT_NO_COMPAT
  185.     void repaintArea( int, int ) { update(); }
  186. #endif
  187.  
  188.     virtual QPopupMenu *createPopupMenu();
  189.     void windowActivationChange( bool );
  190.  
  191. private slots:
  192.     void clipboardChanged();
  193.     void blinkSlot();
  194. #ifndef QT_NO_DRAGANDDROP
  195.     void doDrag();
  196. #endif
  197.     void dragSlot();
  198.     void popupActivated( int r );
  199.  
  200. private:
  201.     void init();
  202.     void blinkOn();
  203.     void updateOffset();
  204.     void updateSelection();
  205.     void removeSelectedText();
  206.  
  207.     QLineEditPrivate * d;
  208.  
  209. private:    // Disabled copy constructor and operator=
  210. #if defined(Q_DISABLE_COPY)
  211.     QLineEdit( const QLineEdit & );
  212.     QLineEdit &operator=( const QLineEdit & );
  213. #endif
  214. };
  215.  
  216.  
  217. #endif // QT_NO_LINEEDIT
  218.  
  219. #endif // QLINEEDIT_H
  220.