1 /* This file is part of the KDE libraries
3 Copyright (c) 2001 Martin R. Jones <mjones@kde.org>
4 Copyright 2006 David Faure <faure@kde.org>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
22 #ifndef KSCREENSAVER_H
23 #define KSCREENSAVER_H
25 #include <QtGui/QWidget>
27 #include <kdemacros.h>
28 #include <kaboutdata.h> // needed by all users of this header, so no point in a forward declaration
30 class KScreenSaverPrivate
;
31 class KBlankEffectPrivate
;
34 * Provides a QWidget for a screensaver to draw into.
36 * You should derive from this widget and implement your screensaver's
39 * @see KScreenSaverInterface
41 * @short Provides a QWidget for a screensaver to draw into.
42 * @author Martin R. Jones <mjones@kde.org>
44 class KDE_EXPORT KScreenSaver
: public QWidget
49 * @param id The winId() of the widget to draw the screensaver into.
51 KScreenSaver( WId id
=0 );
56 * You cannot create a new widget with this widget as parent, since this
57 * widget may not be owned by your application. In order to create
58 * widgets with a KScreenSaver as parent, create the widget with no parent,
59 * call embed(), and then show() the widget.
61 * @param widget The widget to embed in the screensaver widget.
63 void embed( QWidget
*widget
);
64 bool event( QEvent
* event
);
67 KScreenSaverPrivate
*d
;
72 * To use libkscreensaver, derive from KScreenSaverInterface and reimplement
73 * its virtual methods. Then write
75 * int main( int argc, char *argv[] )
77 * MyKScreenSaverInterface kssi;
78 * return kScreenSaverMain( argc, argv, kssi );
82 * In order to convert a KDE-3 screensaver (which used to export kss_* symbols and had no main function)
83 * to KDE-4, you can use the following python script
84 * kdebase/workspace/kscreensaver/libkscreensaver/kscreensaver-kde3to4-porting.py
86 class KDE_EXPORT KScreenSaverInterface
92 virtual ~KScreenSaverInterface();
94 * Reimplement this method to return the KAboutData instance describing your screensaver
96 virtual KAboutData
*aboutData() = 0;
98 * Reimplement this method to return your KScreenSaver-derived screensaver
100 virtual KScreenSaver
* create( WId id
) = 0;
102 * Reimplement this method to return your modal setup dialog
104 virtual QDialog
* setup();
108 * The entry point for the program's main()
109 * @see KScreenSaverInterface
111 KDE_EXPORT
int kScreenSaverMain( int argc
, char** argv
, KScreenSaverInterface
& screenSaverInterface
);
115 * Blanks a widget using various effects.
117 * @short Blanks a widget using various effects.
118 * @author Martin R. Jones <mjones@kde.org>
120 class KBlankEffect
: public QObject
124 KBlankEffect( QObject
*parent
=0 );
127 enum Effect
{ Random
=-1, Blank
=0, SweepRight
, SweepDown
, Blocks
,
131 * Blank a widget using the specified effect.
132 * Some blanking effects take some time, so you should connect to
133 * doneBlank() to know when the blanking is complete.
135 * @param w The widget to blank.
136 * @param effect The type of effect to use.
138 void blank( QWidget
*w
, Effect effect
=Random
);
140 typedef void (KBlankEffect::*BlankEffect
)();
144 * emitted when a blanking effect has completed.
155 void blankSweepRight();
156 void blankSweepDown();
160 static BlankEffect effects
[];
161 KBlankEffectPrivate
*d
;