home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / ktextbrowser.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.6 KB  |  134 lines

  1. /*  This file is part of the KDE Libraries
  2.  *  Copyright (C) 1999 Espen Sand (espensa@online.no)
  3.  *
  4.  *  This library is free software; you can redistribute it and/or
  5.  *  modify it under the terms of the GNU Library General Public
  6.  *  License as published by the Free Software Foundation; either
  7.  *  version 2 of the License, or (at your option) any later version.
  8.  *
  9.  *  This library is distributed in the hope that it will be useful,
  10.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.  *  Library General Public License for more details.
  13.  *
  14.  *  You should have received a copy of the GNU Library General Public License
  15.  *  along with this library; see the file COPYING.LIB.  If not, write to
  16.  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.  *  Boston, MA 02110-1301, USA.
  18.  */
  19.  
  20. #ifndef _KTEXT_BROWSER_H_
  21. #define _KTEXT_BROWSER_H_
  22.  
  23. #include <qtextbrowser.h>
  24.  
  25. #include <kdelibs_export.h>
  26.  
  27. /**
  28.  * @short Extended QTextBrowser.
  29.  *
  30.  * An extended QTextBrowser.
  31.  *
  32.  * By default it will
  33.  * invoke the system mailer or the system browser when a link is
  34.  * activated, or it can emit the signal urlClick() or mailClick()
  35.  * when a link is activated.
  36.  *
  37.  * \image html ktextbrowser.png "KDE Text Browser"
  38.  *
  39.  * @author Espen Sand (espensa@online.no)
  40.  */
  41.  
  42. class KDEUI_EXPORT KTextBrowser : public QTextBrowser
  43. {
  44.   Q_OBJECT
  45.   Q_PROPERTY( bool notifyClick READ isNotifyClick WRITE setNotifyClick )
  46.  
  47.   public:
  48.     /**
  49.      * Constructor.
  50.      *
  51.      * @param parent Parent of the widget.
  52.      * @param name Widget name.
  53.      * @param notifyClick @p true causes signals to be emitted.
  54.      */
  55.     KTextBrowser( QWidget *parent=0, const char *name=0,
  56.           bool notifyClick=false );
  57.  
  58.     /**
  59.      * Destructor.
  60.      */
  61.     ~KTextBrowser( void );
  62.  
  63.     /**
  64.      * Decide whether a click on a link should be handled internally
  65.      * or if a signal should be emitted.
  66.      *
  67.      * @param notifyClick @p true causes signals to be emitted.
  68.      */
  69.     void setNotifyClick( bool notifyClick );
  70.     /**
  71.      * Returns whether a click on a link should be handled internally
  72.      * or if a signal should be emitted.
  73.      */
  74.     bool isNotifyClick() const;
  75.  
  76.   protected:
  77.     /**
  78.        Reimplemented to NOT set the source but to do the special handling.
  79.        Do not call.
  80.      */
  81.     void setSource(const QString& name);
  82.  
  83.     /**
  84.      * Makes sure Key_Escape is ignored
  85.      */
  86.     virtual void keyPressEvent(QKeyEvent *e);
  87.  
  88.     /**
  89.      * Make sure we use our own hand cursor
  90.      */
  91.     virtual void viewportMouseMoveEvent( QMouseEvent* e);
  92.  
  93.     /**
  94.      * Reimplemented to support Qt2 behavior (Ctrl-Wheel = fast scroll)
  95.      */
  96.     virtual void contentsWheelEvent( QWheelEvent *e );
  97.  
  98.     /**
  99.     * Re-implemented for internal reasons.  API not affected.
  100.     *
  101.     * See QLineEdit::createPopupMenu().
  102.     */
  103.     virtual QPopupMenu *createPopupMenu( const QPoint &pos );
  104.  
  105.   signals:
  106.     /**
  107.      * Emitted when a mail link has been activated and the widget has
  108.      * been configured to emit the signal.
  109.      *
  110.      * @param name The destination name. It is QString::null at the moment.
  111.      * @param address The destination address.
  112.      */
  113.     void mailClick( const QString &name, const QString &address );
  114.  
  115.     /**
  116.      * Emitted if mailClick() is not emitted and the widget has been
  117.      * configured to emit the signal.
  118.      *
  119.      * @param url The destination address.
  120.      */
  121.     void urlClick( const QString &url );
  122.  
  123.   private:
  124.     bool    mNotifyClick;
  125.  
  126.   protected:
  127.     virtual void virtual_hook( int id, void* data );
  128.   private:
  129.     class KTextBrowserPrivate;
  130.     KTextBrowserPrivate *d;
  131. };
  132.  
  133. #endif
  134.