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 / kscreensaver.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.5 KB  |  139 lines

  1. /* This file is part of the KDE libraries
  2.  
  3.     Copyright (c) 2001  Martin R. Jones <mjones@kde.org>
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.     Boston, MA 02110-1301, USA.
  19. */
  20.  
  21. #ifndef KSCREENSAVER_H
  22. #define KSCREENSAVER_H
  23.  
  24. #include <qwidget.h>
  25.  
  26. #include <kdelibs_export.h>
  27.  
  28. class QTimer;
  29. class KScreenSaverPrivate;
  30. class KBlankEffectPrivate;
  31.  
  32. /**
  33. * Provides a QWidget for a screensaver to draw into.
  34. *
  35. * You should derive from this widget and implement your screensaver's
  36. * functionality.  To use libkss, provide the following constants and
  37. * functions:
  38. *
  39. *   extern "C"
  40. *   {
  41. *       const char *kss_applicationName = "yourappname";
  42. *       const char *kss_description = I18N_NOOP( "Your screensaver" );
  43. *       const char *kss_version = "1.0";
  44. *
  45. *       KScreenSaver *kss_create( WId d )
  46. *       {
  47. *           // return your KScreenSaver derived screensaver
  48. *       }
  49. *
  50. *       QDialog *kss_setup()
  51. *       {
  52. *           // return your modal setup dialog
  53. *       }
  54. *   }
  55. *
  56. * @short Provides a QWidget for a screensaver to draw into.
  57. * @author Martin R. Jones <mjones@kde.org>
  58. */
  59. class KDE_EXPORT KScreenSaver : public QWidget
  60. {
  61.     Q_OBJECT
  62. public:
  63.     /**
  64.      * @param id The winId() of the widget to draw the screensaver into.
  65.      */
  66.     KScreenSaver( WId id=0 );
  67.     ~KScreenSaver();
  68.  
  69. protected:
  70.     /**
  71.      * You cannot create a new widget with this widget as parent, since this
  72.      * widget may not be owned by your application.  In order to create
  73.      * widgets with a KScreenSaver as parent, create the widget with no parent,
  74.      * call embed(), and then show() the widget.
  75.      *
  76.      * @param widget The widget to embed in the screensaver widget.
  77.      */
  78.     void embed( QWidget *widget );
  79.  
  80.     bool eventFilter( QObject *o, QEvent * );
  81.  
  82. private:
  83.     KScreenSaverPrivate *d;
  84. };
  85.  
  86.  
  87. /**
  88. *
  89. * Blanks a widget using various effects.
  90. *
  91. * @short Blanks a widget using various effects.
  92. * @author Martin R. Jones <mjones@kde.org>
  93. */
  94. class KBlankEffect : public QObject
  95. {
  96.     Q_OBJECT
  97. public:
  98.     KBlankEffect( QObject *parent=0 );
  99.     ~KBlankEffect();
  100.  
  101.     enum Effect { Random=-1, Blank=0, SweepRight, SweepDown, Blocks,
  102.                   MaximumEffects };
  103.  
  104.     /**
  105.      * Blank a widget using the specified effect.
  106.      * Some blanking effects take some time, so you should connect to
  107.      * doneBlank() to know when the blanking is complete.
  108.      *
  109.      * @param w The widget to blank.
  110.      * @param effect The type of effect to use.
  111.      */
  112.     void blank( QWidget *w, Effect effect=Random );
  113.  
  114.     typedef void (KBlankEffect::*BlankEffect)();
  115.  
  116. signals:
  117.     /**
  118.      * emitted when a blanking effect has completed.
  119.      */
  120.     void doneBlank();
  121.  
  122. protected slots:
  123.     void timeout();
  124.  
  125. protected:
  126.     void finished();
  127.  
  128.     void blankNormal();
  129.     void blankSweepRight();
  130.     void blankSweepDown();
  131.     void blankBlocks();
  132.  
  133. protected:
  134.     static BlankEffect effects[];
  135.     KBlankEffectPrivate *d;
  136. };
  137. #endif
  138.  
  139.