Source Code (Use browser search to find items of interest.)
Class Index
kdelibs'KPanelApplet (./kdelibs/kdeui/kpanelapplet.h:38)
class KPanelApplet : public QWidget, DCOPObject
{
Q_OBJECT;
public:
enum Position { Left = 0, Right, Top, Bottom };
/**
* Construct a KApplet widget just like any other widget.
**/
KPanelApplet( QWidget* parent = 0, const char* name = 0 );
/**
* Destructor
**/
virtual ~KPanelApplet();
/**
* Initialize the applet according to the passed command line
* parameters. Call this function after instantiating the applet
* widget in your main() function.
*
* Evalutate some command line arguments and get docked by the panel.
**/
void init( int& argc, char ** argv );
/**
* Set the applet to be fixed size or stretchable.
*
* Most applets might want to have a fixed size.
* Applets like a taskbar however can set the stretch flag to get
* all space available on the panel between the two surrounding applets
* and/or the panel borders.
**/
void setStretch(bool s);
/**
* @returns Bool indicating whether the applet is fixed size or stretchable.
**/
bool stretch() { return _stretch; }
/**
* @returns A suggested width for a given height.
*
* Applets should reimplement this function.
*
* Depending on the panel orientation the height (horizontal panel) or the
* width (vertical panel) of the applets is fixed.
* The exact values of the fixed size component depend on the panel size.
*
* On a horizontal panel the applet height is fixed, the panel will
* call widthForHeight(int height) with height == 'the fixed applet height'
* when layouting the applets.
*
* The applet can now choose the other size component (width)
* based on the given height.
*
* The width you return is guaranteed.
**/
virtual int widthForHeight(int height);
/**
* @returns A suggested height for a given width.
*
* Applets should reimplement this function.
*
* Depending on the panel orientation the height (horizontal panel) or the
* width (vertical panel) of the applets is fixed.
* The exact values of the fixed size component depend on the panel size.
*
* On a vertical panel the applet width is fixed, the panel will
* call heightForWidth(int width) with width == 'the fixed applet width'
* when layouting the applets.
*
* The applet can now choose the other size component (height)
* based on the given width.
*
* The height you return is guaranteed.
**/
virtual int heightForWidth(int width);
/**
* Is called when the applet is removed from the panel.
*
* The default implementation will simply call "kapp->quit()".
* If the KPanelApplet widget is only a part of a bigger application
* you might want to reimplement this to avoid the app shutdown and do
* something else like simply deleting the applet widget instead.
**/
virtual void removedFromPanel();
/**
* Notify the panel about a new applet layout.
*
* Call this to make the panel relayout all applets, when
* you want to change your width (horizontal panel) or
* height (vertical panel).
*
* The panel is going to relayout all applets based on their
* widthForHeight(int height) (horizontal panel) or
* heightForWidth(int width) (vertical panel).
*
* Please note that the panel may change the applets location
* if the new widthForHeight(int height) (horizontal panel) or
* heightForWidth(int width) (vertical panel) does not fit into the
* current panel layout.
**/
void updateLayout();
/**
* @returns The panel orientation. You may need this if you want to popup menus at the
* right position.
**/
Orientation orientation() const { return _orient; }
/**
* @returns The panel position. You may need this if you want to popup menus at the
* right position.
**/
Position position() const { return _pos; }
// dcop internal
bool process(const QCString &fun, const QByteArray &data,
QCString& replyType, QByteArray &replyData);
private:
KPanelAppletData *d;
bool _stretch;
Orientation _orient;
Position _pos;
};
kdelibs'KPanelApplet::KPanelApplet() (./kdelibs/kdeui/kpanelapplet.cpp:33)
KPanelApplet::KPanelApplet( QWidget* parent, const char* name )
: QWidget( parent, name)
, DCOPObject()
, _stretch (false)
{
QXEmbed::initialize();
}
kdelibs'KPanelApplet::~KPanelApplet() (./kdelibs/kdeui/kpanelapplet.cpp:41)
KPanelApplet::~KPanelApplet() {}
kdelibs'KPanelApplet::init() (./kdelibs/kdeui/kpanelapplet.cpp:43)
void KPanelApplet::init( int& /*argc*/, char ** /*argv*/ )
{
DCOPClient* dcop = kapp->dcopClient();
if (!dcop->isAttached())
if (!dcop->attach())
{
qDebug("Error: Failed to attach to DCOP server.");
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 ) )
{
qDebug("Error: Failed to dock into Kicker.");
goto error;
}
}
return;
error:
// do something, at least
resize(48,heightForWidth(48));
show();
}
kdelibs'KPanelApplet::setStretch() (./kdelibs/kdeui/kpanelapplet.cpp:76)
void KPanelApplet::setStretch(bool s)
{
_stretch = s;
QByteArray data;
QDataStream dataStream( data, IO_WriteOnly );
dataStream << objId();
dataStream << static_cast<int>(_stretch);
kapp->dcopClient()->send("kicker", "appletArea",
"setStretch(QCString,int)", data);
}
kdelibs'KPanelApplet::updateLayout() (./kdelibs/kdeui/kpanelapplet.cpp:88)
void KPanelApplet::updateLayout()
{
QByteArray data;
kapp->dcopClient()->send("kicker", "appletArea", "updateLayout()", data);
}
kdelibs'KPanelApplet::process() (./kdelibs/kdeui/kpanelapplet.cpp:94)
bool KPanelApplet::process(const QCString &fun, const QByteArray &data,
QCString& replyType, QByteArray &replyData)
{
if ( fun == "winId()" )
{
QDataStream reply( replyData, IO_WriteOnly );
reply << winId();
replyType = "WId";
return true;
}
else if ( fun == "widthForHeight(int)" )
{
QDataStream dataStream( data, IO_ReadOnly );
int height;
dataStream >> height;
QDataStream reply( replyData, IO_WriteOnly );
reply << widthForHeight(height);
replyType = "int";
return true;
}
else if ( fun == "heightForWidth(int)" )
{
QDataStream dataStream( data, IO_ReadOnly );
int width;
dataStream >> width;
QDataStream reply( replyData, IO_WriteOnly );
reply << heightForWidth(width);
replyType = "int";
return true;
}
else if ( fun == "setPosition(int)" )
{
QDataStream dataStream( data, IO_ReadOnly );
int pos;
dataStream >> pos;
_pos = static_cast<Position>(pos);
resizeEvent(0);
return true;
}
else if ( fun == "setOrientation(int)" )
{
QDataStream dataStream( data, IO_ReadOnly );
int orient;
dataStream >> orient;
_orient = static_cast<Qt::Orientation>(orient);
resizeEvent(0);
return true;
}
else if ( fun == "removedFromPanel()" )
{
removedFromPanel();
return true;
}
else if ( fun == "restartCommand()" )
{
QDataStream reply( replyData, IO_WriteOnly );
reply << QCString( kapp->argv()[0] );
replyType = "QCString";
return true;
}
return false;
}
kdelibs'KPanelApplet::heightForWidth() (./kdelibs/kdeui/kpanelapplet.cpp:157)
int KPanelApplet::heightForWidth(int width)
{
// default to a quadratic shape
return width;
}
kdelibs'KPanelApplet::widthForHeight() (./kdelibs/kdeui/kpanelapplet.cpp:163)
int KPanelApplet::widthForHeight(int height)
{
// default to a quadratic shape
return height;
}
kdelibs'KPanelApplet::removedFromPanel() (./kdelibs/kdeui/kpanelapplet.cpp:169)
void KPanelApplet::removedFromPanel()
{
kapp->quit();
}