Source: kpassivepopup.h


Annotated List
Files
Globals
Hierarchy
Index
// -*- c++ -*-

/*
 *   Copyright            : (C) 2001-2002 by Richard Moore
 *   Email                : rich@kde.org
 */

#ifndef KPASSIVEPOPUP_H
#define KPASSIVEPOPUP_H

#include 

class QBoxLayout;
class QTimer;
class QLabel;

/**
 * A dialog-like popup that displays messages without interupting the user. 
 * The simplest uses of KPassivePopup are by using the various @ref message() static
 * methods. The position the popup appears at depends on the type of the parent window:
 *
 * @li Normal Windows: The popup is placed adjacent to the icon of the window.
 * @li System Tray Windows: The popup is placed adjact to the system tray window itself.
 * @li Skip Taskbar Windows: The popup is placed adjact to the window
 *     itself if it is visible, and at the edge of the desktop otherwise.
 *
 * The most basic use of KPassivePopup displays a popup containing a piece of text:
 * 
 *    KPassivePopup::message( "This is the message", this );
 * 
* We can create popups with titles and icons too, as this example shows: *
 *    QPixmap px;
 *    px.load( "lo32-app-logtracker.png" );
 *    KPassivePopup::message( "Some title", "This is the main text", px, this );
 * 
* For more control over the popup, you can use the @ref setView(QWidget *) method * to create a custom popup. *
 *    KPassivePopup *pop = new KPassivePopup( parent );
 *
 *    QVBox *vb = new QVBox( pop );
 *    (void) new QLabel( "<b>Isn't this great?</b>", vb );
 *
 *    QHBox *box = new QHBox( vb );
 *    (void) new QPushButton( "Yes", box );
 *    (void) new QPushButton( "No", box );
 *
 *    pop->setView( vb );
 *    pop->show();
 * 
* * @version $Id: kpassivepopup.h,v 1.2 2002/02/25 22:18:59 rich Exp $ * @author Richard Moore, rich@kde.org */ class KPassivePopup : public QFrame { Q_OBJECT public: /** * Creates a popup for the specified widget. */ KPassivePopup( QWidget *parent=0, const char *name=0 ); /** * Creates a popup for the specified window. */ KPassivePopup( WId parent, const char *name=0 ); /** * Cleans up. */ virtual ~KPassivePopup(); /** * Sets the main view to be the specified widget (which must be a child of the popup). */ void setView( QWidget *child ); /** * Creates a standard view then calls @ref #setView(QWidget*) . */ void setView( const QString &text, const QString &caption = QString::null ); /** * Creates a standard view then calls @ref #setView(QWidget*) . */ virtual void setView( const QString &text, const QString &caption, const QPixmap &icon ); /** * Returns the main view */ QWidget *view() const { return msgView; } /** * Returns the delay before the popup is removed automatically. */ int timeout() const { return hideDelay; } /** * Convenience method that displays popup with the specified message beside the * icon of the specified widget. */ static KPassivePopup *message( const QString &text, QWidget *parent, const char *name=0 ); /** * Convenience method that displays popup with the specified caption and message * beside the icon of the specified widget. */ static KPassivePopup *message( const QString &text, const QString &caption, QWidget *parent, const char *name=0 ); /** * Convenience method that displays popup with the specified icon, caption and * message beside the icon of the specified widget. */ static KPassivePopup *message( const QString &text, const QString &caption, const QPixmap &icon, QWidget *parent, const char *name=0 ); public slots: /** * Sets the delay for the popup is removed automatically. Setting the delay to -1 * disables the timeout, if you're doing this, you may want to connect the * @ref clicked() signal to the hide() slot. */ void setTimeout( int delay ); /** * Reimplemented to reposition the popup. */ virtual void show(); signals: /** * Emitted when the popup is clicked. */ void clicked(); /** * Emitted when the popup is clicked. */ void clicked( QPoint pos ); protected: /** * This method positions the popup. */ virtual void positionSelf(); /** * Moves the popup to be adjacent to the icon of the specified rectangle. */ void moveNear( QRect target ); /** * Reimplemented to detect mouse clicks. */ virtual void mouseReleaseEvent( QMouseEvent *e ); private: QWidget *owner; WId window; QWidget *msgView; QBoxLayout *layout; int hideDelay; QTimer *hideTimer; QLabel *ttlIcon; QLabel *ttl; QLabel *msg; /* @internal */ class Private *d; }; #endif // KPASSIVEPOPUP_H // Local Variables: // c-basic-offset: 4 // End:

Generated by: rich on pegasus on Tue Feb 26 01:28:15 2002, using kdoc 2.0a53.