TDE base libraries and programs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

184 lines
4.6 KiB

  1. /* vi: ts=8 sts=4 sw=4
  2. * kate: space-indent on; tab-width 8; indent-width 4; indent-mode cstyle;
  3. *
  4. * This file is part of the KDE project, module kdesktop.
  5. * Copyright (C) 1999 Geert Jansen <g.t.jansen@stud.tue.nl>
  6. *
  7. * You can Freely distribute this program under the GNU Library General
  8. * Public License. See the file "COPYING.LIB" for the exact licensing terms.
  9. */
  10. #ifndef BGRender_h_Included
  11. #define BGRender_h_Included
  12. #include <tqobject.h>
  13. #include <tqptrvector.h>
  14. #include <tqimage.h>
  15. #include <tqpixmap.h>
  16. #include "bgsettings.h"
  17. class TQSize;
  18. class TQRect;
  19. class TQString;
  20. class TQTimer;
  21. class TDEConfig;
  22. class TDEProcess;
  23. class KTempFile;
  24. class KShellProcess;
  25. class TDEStandardDirs;
  26. class KCrossBGRender;
  27. /**
  28. * This class renders a desktop background to a TQImage. The operation is
  29. * asynchronous: connect to the signal imageDone() to find out when the
  30. * rendering is finished. It also has support for preview images, like
  31. * the monitor in kcmdisplay.
  32. */
  33. class KBackgroundRenderer:
  34. public TQObject,
  35. public KBackgroundSettings
  36. {
  37. Q_OBJECT
  38. public:
  39. KBackgroundRenderer(int desk, int screen, bool drawBackgroundPerScreen, TDEConfig *config=0);
  40. ~KBackgroundRenderer();
  41. void load(int desk, int screen, bool drawBackgroundPerScreen, bool reparseConfig=true);
  42. void setPreview(const TQSize &size);
  43. void setSize(const TQSize &size);
  44. TQPixmap pixmap();
  45. TQImage image();
  46. bool isActive() { return m_State & Rendering; }
  47. void cleanup();
  48. void saveCacheFile();
  49. void enableTiling( bool enable ) { m_TilingEnabled = enable; }
  50. public slots:
  51. void start(bool enableBusyCursor = false);
  52. void stop();
  53. void desktopResized();
  54. signals:
  55. void imageDone(int desk, int screen);
  56. void programFailure(int desk, int exitstatus); //Guaranteed either programFailure or
  57. void programSuccess(int desk); //programSuccess is emitted after imageDone
  58. private slots:
  59. void slotBackgroundDone(TDEProcess *);
  60. void render();
  61. void done();
  62. private:
  63. enum { Error, Wait, WaitUpdate, Done };
  64. enum { Rendering = 1, InitCheck = 2,
  65. BackgroundStarted = 4, BackgroundDone = 8,
  66. WallpaperStarted = 0x10, WallpaperDone = 0x20,
  67. AllDone = 0x40 };
  68. TQString buildCommand();
  69. void createTempFile();
  70. void tile(TQImage& dst, TQRect rect, const TQImage& src);
  71. void blend(TQImage& dst, TQRect dr, const TQImage& src, TQPoint soffs = TQPoint(0, 0), int blendFactor=100);
  72. void wallpaperBlend();
  73. void fastWallpaperBlend();
  74. void fullWallpaperBlend();
  75. int doBackground(bool quit=false);
  76. int doWallpaper(bool quit=false);
  77. void setBusyCursor(bool isBusy);
  78. TQString cacheFileName();
  79. bool useCacheFile() const;
  80. bool canTile() const;
  81. bool m_isBusyCursor;
  82. bool m_enableBusyCursor;
  83. bool m_bPreview;
  84. int m_State;
  85. bool m_Cached;
  86. bool m_TilingEnabled;
  87. KTempFile* m_Tempfile;
  88. TQSize m_Size, m_rSize;
  89. TQRect m_WallpaperRect;
  90. TQImage m_Image, m_Background, m_Wallpaper;
  91. TQPixmap m_Pixmap;
  92. TQTimer *m_pTimer;
  93. TDEStandardDirs *m_pDirs;
  94. KShellProcess *m_pProc;
  95. };
  96. /**
  97. * In xinerama mode, each screen is rendered seperately by KBackgroundRenderer.
  98. * This class controls a set of renderers for a desktop, and coallates the
  99. * images. Usage is similar to KBackgroundRenderer: connect to the imageDone
  100. * signal.
  101. */
  102. class KVirtualBGRenderer : public QObject
  103. {
  104. Q_OBJECT
  105. public:
  106. KVirtualBGRenderer(int desk, TDEConfig *config=0l);
  107. ~KVirtualBGRenderer();
  108. KCrossBGRender * renderer(unsigned screen);
  109. unsigned numRenderers() const { return m_numRenderers; }
  110. TQPixmap pixmap();
  111. void setPreview(const TQSize & size);
  112. bool needProgramUpdate();
  113. void programUpdate();
  114. bool needWallpaperChange();
  115. void changeWallpaper();
  116. int hash();
  117. bool isActive();
  118. void setEnabled( bool enable );
  119. void desktopResized();
  120. void load(int desk, bool reparseConfig=true);
  121. void start();
  122. void stop();
  123. void cleanup();
  124. void saveCacheFile();
  125. void enableTiling( bool enable );
  126. signals:
  127. void imageDone(int desk);
  128. private slots:
  129. void screenDone(int desk, int screen);
  130. private:
  131. TQSize renderSize(int screen); // the size the renderer should be
  132. void initRenderers();
  133. TDEConfig *m_pConfig;
  134. float m_scaleX;
  135. float m_scaleY;
  136. int m_desk;
  137. unsigned m_numRenderers;
  138. bool m_bDrawBackgroundPerScreen;
  139. bool m_bCommonScreen;
  140. bool m_bDeleteConfig;
  141. TQSize m_size;
  142. TQMemArray<bool> m_bFinished;
  143. TQPtrVector<KCrossBGRender> m_renderer;
  144. TQPixmap *m_pPixmap;
  145. };
  146. #endif // BGRender_h_Included