Source Code (Use browser search to find items of interest.)

Class Index

kdelibs'KApplet (./kdelibs/kdeui/kapplet.h:35)

class KApplet : public QWidget, DCOPObject
{
    Q_OBJECT
public:
    /**
     * Sizes to which your applet may be streched when
     * laying out the toolbar.
     **/
    enum Stretch{Fixed=0, Small, Medium, Large, Huge};
    
    /**
     * Construct a KApplet widget just like any other widget.
     **/
    KApplet( QWidget* parent = 0, const char* name = 0 );


    /**
     * Destructor
     **/
    ~KApplet();

    /**
     * Initialize the applet according to the passed command line
     * parameters
     *
     * Evalutate some command line arguments, dock into the
     * respective applet container and eventually call
     * @ref setupGeometry().
     **/
    void init( int& argc, char ** argv );

    /**
     * Set up the applet's geometry. This function needs to be
     * reimplemented by subclasses.
     *
     * @param orientation The applet's orientation, either @p Qt::Horizontal
     * or @p Qt::Vertical.
     * @param width Width of the applet.
     * @param height Height of the applet.
     *
     * The size parameter is meant as a hint in case an applet
     * supports different look&feels depending on the target size. Of
     * course, an applet could do these things in @ref resizeEvent(), but
     * this way it's more convenient.
     *
     * The applet container that will embed this applet will resize itself
     * to the standard size of its applets. If your applet needs more
     * space, ensure to set a proper minimum size with
     * @ref QWidget::setMinimumWidth() or @ref QWidget::setMinimumHeight()
     * depending on the applets orientation.
     *
     * Keep in mind that @ref setupGeometry() may be called several times
     * during a life-cycle of your applet, for example when the applet
     * container is resized, moved or changes orientation.
     **/
    virtual void setupGeometry( Orientation orientation, int width, int height );

    /**
     * Set the applet to be fixed size or stretchable (and to what size).
     **/
    void setStretch(Stretch size);
    /**
     * @returns Integer of type @p Stretch indicating whether the applet is fixed size or stretchable (and to what size).
     **/
    Stretch stretch(){return s;}
    
    /**
     * @return A suggested size for the applet.
     **/
    QSize sizeHint() const;

    


    /**
       Returns  the current orientation set by the last KApplet::init() call.
    */
    Orientation orientation() const;



    // dcop internal
    bool process(const QCString &fun, const QByteArray &data,
		 QCString& replyType, QByteArray &replyData);

public slots:

    /*!
      Tells the applet container that the applet wants to be
      removed. Subclasses should provide a context menu with a
      "Remove" item connected to this slot.
     */
    void removeRequest();

    /*!
      Tells the applet container that the applet wants to be
      moved around. Subclasses should provide a context menu with a
      "Move" item connected to this slot.
     */
    void moveRequest();



private:
    KAppletData* d;
    Stretch s;
};


kdelibs'KApplet::KApplet() (./kdelibs/kdeui/kapplet.cpp:43)

KApplet::KApplet( QWidget* parent, const char* name  )
    : QWidget( parent, name), DCOPObject()
{
    QXEmbed::initialize();
    d = new KAppletData;
    s = Fixed;
}


kdelibs'KApplet::~KApplet() (./kdelibs/kdeui/kapplet.cpp:51)

KApplet::~KApplet()
{
    delete d;
}


kdelibs'KApplet::init() (./kdelibs/kdeui/kapplet.cpp:56)

void KApplet::init( int& /*argc*/, char ** /*argv*/ )
{
    int ideal_width = 42;
    int ideal_height = 42;

    DCOPClient* dcop = kapp->dcopClient();

    if (!dcop->isAttached() ) {
	if ( !dcop->attach() )
	    goto error;
    }

    // tell kicker that we are here and want be docked
    {
	QCString replyType;
	QByteArray data, replyData;
	QDataStream dataStream( data, IO_WriteOnly );
	dataStream << objId();

	// we use "call" to know whether it was really sucessful
	if ( !dcop->call("kicker", "appletArea", "dockMe(QCString)", data, replyType, replyData ) )
	    goto error;
    }

    return;

error:
    // do something, at least
    setupGeometry ( orientation(), ideal_width, ideal_height );
    show();
}



kdelibs'KApplet::removeRequest() (./kdelibs/kdeui/kapplet.cpp:89)

void KApplet::removeRequest()
{
    QByteArray data;
    QDataStream dataStream( data, IO_WriteOnly );
    dataStream << objId();
    kapp->dcopClient()->send("kicker", "appletArea", "removeMe(QCString)", data);
}


kdelibs'KApplet::moveRequest() (./kdelibs/kdeui/kapplet.cpp:97)

void KApplet::moveRequest()
{
    QByteArray data;
    QDataStream dataStream( data, IO_WriteOnly );
    dataStream << objId();
    kapp->dcopClient()->send("kicker", "appletArea", "moveMe(QCString)", data);
}


kdelibs'KApplet::setStretch() (./kdelibs/kdeui/kapplet.cpp:105)

void KApplet::setStretch(Stretch size)
{
    s = size;
    QByteArray data;
    QDataStream dataStream( data, IO_WriteOnly );
    dataStream << objId();
    dataStream << (int)s;
    kapp->dcopClient()->send("kicker", "appletArea",
                             "setStretch(QCString,int)", data);
}



kdelibs'KApplet::process() (./kdelibs/kdeui/kapplet.cpp:117)

bool KApplet::process(const QCString &fun, const QByteArray &data,
	     QCString& replyType, QByteArray &replyData)
{
    if ( fun == "setupGeometry(int,int,int)" ) {
	QDataStream dataStream( data, IO_ReadOnly );
	int orient;
	int width, height;
	dataStream >> orient  >> width >> height;
	setupGeometry( Orientation(orient), width, height );
	return TRUE;
    } else if ( fun == "winId()" ) {
	QDataStream reply( replyData, IO_WriteOnly );
	reply << winId();
	replyType = "WId";
	return TRUE;
    } else if ( fun == "restartCommand()" ) {
	QDataStream reply( replyData, IO_WriteOnly );
	reply << QCString( kapp->argv()[0] );
	replyType = "QCString";
	return TRUE;
    }
    return FALSE;
}


kdelibs'KApplet::setupGeometry() (./kdelibs/kdeui/kapplet.cpp:141)

void KApplet::setupGeometry( Orientation orientation , int width, int height  )
{
    QApplication::flushX();
    d->orientation = orientation;
    resize(width, height );
    updateGeometry();
}



kdelibs'KApplet::sizeHint() (./kdelibs/kdeui/kapplet.cpp:150)

QSize KApplet::sizeHint() const
{
    return size();
}

Qt::Orientation KApplet::orientation() const
{
    return d->orientation;
}

#include "kapplet.moc"

// $Log: kapplet.cpp,v $
// Revision 1.12  2000/03/19 19:25:37  ettrich
// new iteration of QXEmbed
//
// Revision 1.11  1999/11/15 11:03:45  mosfet
// Added stretch methods for layouts. Will add docu when done.
//
// Revision 1.10  1999/11/14 05:53:32  ettrich
//
// Added KDockWindow, a simpler and more comfortable way of doing panel docking.
//
// Removed obsolete KWMModuleApplicaton as announced some time ago.
//