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.

377 lines
10 KiB

  1. /* vi: ts=8 sts=4 sw=4
  2. * kate: space-indent on; 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 __BGSETTINGS_H__
  11. #define __BGSETTINGS_H__
  12. #include <tqstringlist.h>
  13. #include <tqcolor.h>
  14. #include <tqvaluevector.h>
  15. template <class TQString, class T> class TQMap;
  16. class TDEStandardDirs;
  17. class KSimpleConfig;
  18. class TDEConfig;
  19. class TQString;
  20. class TQImage;
  21. /**
  22. * A class to manipulate/read/write/list KDE desktop patterns.
  23. *
  24. * A pattern is a raster image. An entry for earch pattern is
  25. * stored as a .desktop file in $(datadir)/kdesktop/patterns.
  26. */
  27. class KBackgroundPattern
  28. {
  29. public:
  30. KBackgroundPattern(TQString name=TQString::null);
  31. ~KBackgroundPattern();
  32. void copyConfig(const KBackgroundPattern*);
  33. TQString name() const { return m_Name; }
  34. void load(TQString name);
  35. void setComment(const TQString &comment);
  36. TQString comment() const {return m_Comment; }
  37. void setPattern(TQString file);
  38. TQString pattern() const { return m_Pattern; }
  39. void readSettings();
  40. void writeSettings();
  41. bool isAvailable();
  42. bool isGlobal()const { return m_bReadOnly; }
  43. bool remove();
  44. int hash();
  45. static TQStringList list();
  46. private:
  47. void init(bool force_rw=false);
  48. TQString fingerprint();
  49. bool dirty, hashdirty;
  50. bool m_bReadOnly;
  51. int m_Hash;
  52. TQString m_Name, m_Comment;
  53. TQString m_Pattern, m_File;
  54. TDEStandardDirs *m_pDirs;
  55. KSimpleConfig *m_pConfig;
  56. };
  57. /**
  58. * A class to manipulate/read/write/list KDE desktop programs (a la xearth).
  59. *
  60. * A program is described by a string like:
  61. *
  62. * a_program -xres %x -yres %y -outfile %f
  63. *
  64. * Possible escape sequences:
  65. *
  66. * %x Horizontal resolution in pixels.
  67. * %y Vertical resulution in pixels.
  68. * %f Filename to dump to.
  69. *
  70. * An entry for each program is stored as a .desktop file in
  71. * $(datadir)/kdesktop/programs.
  72. */
  73. class KBackgroundProgram
  74. {
  75. public:
  76. KBackgroundProgram(TQString name=TQString::null);
  77. ~KBackgroundProgram();
  78. void copyConfig(const KBackgroundProgram*);
  79. TQString name()const { return m_Name; }
  80. void load(const TQString & name);
  81. void setComment(const TQString &comment);
  82. TQString comment()const { return m_Comment; }
  83. void setCommand(const TQString &command);
  84. TQString command()const { return m_Command; }
  85. void setPreviewCommand(const TQString &command);
  86. TQString previewCommand()const { return m_PreviewCommand; }
  87. void setRefresh(int refresh);
  88. int refresh()const { return m_Refresh; }
  89. void setExecutable(const TQString &executable);
  90. TQString executable()const { return m_Executable; }
  91. void readSettings();
  92. void writeSettings();
  93. void update();
  94. bool needUpdate();
  95. int hash();
  96. bool isAvailable();
  97. bool isGlobal()const { return m_bReadOnly; }
  98. bool remove();
  99. static TQStringList list();
  100. private:
  101. void init(bool force_rw=false);
  102. TQString fingerprint();
  103. bool dirty, hashdirty;
  104. bool m_bReadOnly;
  105. int m_Refresh, m_Hash, m_LastChange;
  106. TQString m_Name, m_Command;
  107. TQString m_PreviewCommand, m_Comment;
  108. TQString m_Executable, m_File;
  109. TDEStandardDirs *m_pDirs;
  110. KSimpleConfig *m_pConfig;
  111. };
  112. /**
  113. * KBackgroundSettings: A class to read/write/manipulate
  114. * KDE desktop settings.
  115. */
  116. class KBackgroundSettings
  117. : public KBackgroundPattern,
  118. public KBackgroundProgram
  119. {
  120. public:
  121. /**
  122. * @param drawBackgroundPerScreen if false, then all screens (in xinerama
  123. * mode) will be treated as one big display, and the "screen" paramater
  124. * will be ignored.
  125. */
  126. KBackgroundSettings(int desk, int screen, bool drawBackgroundPerScreen, TDEConfig *config);
  127. ~KBackgroundSettings();
  128. void copyConfig(const KBackgroundSettings*);
  129. bool drawBackgroundPerScreen() const { return m_bDrawBackgroundPerScreen; }
  130. void setDrawBackgroundPerScreen(bool draw);
  131. int desk() const { return m_Desk; }
  132. int screen() const { return m_Screen; }
  133. // void load(int desk, int screen, bool drawBackgroundPerScreen, bool reparseConfig=true);
  134. void load(int desk, int screen, bool drawBackgroundPerScreen, bool reparseConfig);
  135. void setColorA(const TQColor &color);
  136. TQColor colorA() const { return m_ColorA; }
  137. void setColorB(const TQColor &color);
  138. TQColor colorB() const { return m_ColorB; }
  139. void setProgram(TQString program);
  140. void setPatternName(TQString pattern);
  141. enum BackgroundMode {
  142. Flat, Pattern, Program,
  143. HorizontalGradient, VerticalGradient, PyramidGradient,
  144. PipeCrossGradient, EllipticGradient, lastBackgroundMode
  145. };
  146. void setBackgroundMode(int mode);
  147. int backgroundMode() const { return m_BackgroundMode; }
  148. enum BlendMode {
  149. NoBlending, FlatBlending,
  150. HorizontalBlending, VerticalBlending, PyramidBlending,
  151. PipeCrossBlending, EllipticBlending,
  152. IntensityBlending, SaturateBlending, ContrastBlending,
  153. HueShiftBlending, lastBlendMode
  154. };
  155. void setBlendMode(int mode);
  156. int blendMode() const { return m_BlendMode; }
  157. void setReverseBlending(bool value);
  158. bool reverseBlending() const { return m_ReverseBlending; }
  159. void setCrossFadeBg(bool value);
  160. bool crossFadeBg() const { return m_CrossFadeBg; }
  161. void setBlendBalance(int value);
  162. int blendBalance() const { return m_BlendBalance; }
  163. void setWallpaper(TQString name);
  164. TQString wallpaper() const { return m_Wallpaper; }
  165. enum WallpaperMode {
  166. NoWallpaper, Centred, Tiled, CenterTiled, CentredMaxpect, TiledMaxpect,
  167. Scaled, CentredAutoFit, ScaleAndCrop, lastWallpaperMode
  168. };
  169. void setWallpaperMode(int mode);
  170. int wallpaperMode() const { return m_WallpaperMode; }
  171. void setWallpaperList(TQStringList);
  172. TQStringList wallpaperList() const;
  173. TQStringList wallpaperFiles() const;
  174. void setWallpaperChangeInterval(int);
  175. int wallpaperChangeInterval() const { return m_Interval; }
  176. enum MultiMode {
  177. NoMulti, InOrder, Random, NoMultiRandom
  178. };
  179. void setMultiWallpaperMode(int mode);
  180. int multiWallpaperMode() const { return m_MultiMode; }
  181. enum MinOptDepth {
  182. AlwaysOpt, Opt16bpp, Opt15bpp, NeverOpt };
  183. void setMinOptimizationDepth( int mode );
  184. int minOptimizationDepth() const { return m_MinOptimizationDepth; }
  185. bool optimize() const;
  186. void setUseShm( bool use );
  187. bool useShm() const { return m_bShm; }
  188. void changeWallpaper(bool init=false);
  189. void updateWallpaperFiles();
  190. void randomizeWallpaperFiles();
  191. TQString currentWallpaper() const;
  192. /**
  193. * @return true if the currentWallpaper has changed
  194. */
  195. bool discardCurrentWallpaper();
  196. int lastWallpaperChange() const { return m_LastChange; }
  197. bool needWallpaperChange();
  198. void readSettings(bool reparse=false);
  199. void writeSettings();
  200. TQString configGroupName() const;
  201. int hash();
  202. TQString fingerprint();
  203. void setEnabled( const bool enable );
  204. bool enabled() const { return m_bEnabled; }
  205. private:
  206. void updateHash();
  207. bool dirty;
  208. bool hashdirty;
  209. int m_Screen, m_Desk, m_Hash;
  210. TQColor m_ColorA, defColorA;
  211. TQColor m_ColorB, defColorB;
  212. TQString m_Wallpaper;
  213. TQStringList m_WallpaperList, m_WallpaperFiles;
  214. int m_BackgroundMode, defBackgroundMode;
  215. int m_WallpaperMode, defWallpaperMode;
  216. int m_BlendMode, defBlendMode;
  217. int m_BlendBalance, defBlendBalance;
  218. bool m_ReverseBlending, defReverseBlending;
  219. bool m_CrossFadeBg, defCrossFadeBg;
  220. int m_MinOptimizationDepth;
  221. bool m_bShm;
  222. bool m_bDrawBackgroundPerScreen;
  223. int m_MultiMode, defMultiMode;
  224. int m_Interval, m_LastChange;
  225. int m_CurrentWallpaper;
  226. TQString m_CurrentWallpaperName;
  227. TDEConfig *m_pConfig;
  228. TDEStandardDirs *m_pDirs;
  229. bool m_bDeleteConfig;
  230. bool m_bEnabled;
  231. public:
  232. TQMap<TQString,int> m_BMMap;
  233. TQMap<TQString,int> m_WMMap;
  234. TQMap<TQString,int> m_MMMap;
  235. TQMap<TQString,int> m_BlMMap;
  236. char *m_BMRevMap[16];
  237. char *m_WMRevMap[16];
  238. char *m_MMRevMap[16];
  239. char *m_BlMRevMap[16];
  240. };
  241. /**
  242. * A class to read/modify the global desktop background settings.
  243. */
  244. class TDEGlobalBackgroundSettings
  245. {
  246. public:
  247. TDEGlobalBackgroundSettings(TDEConfig *config);
  248. TQString deskName(int desk);
  249. //void setDeskName(int desk, TQString name);
  250. int cacheSize() { return m_CacheSize; }
  251. void setCacheSize(int size);
  252. bool drawBackgroundPerScreen(int desk) const;
  253. void setDrawBackgroundPerScreen(int desk, bool perScreen);
  254. bool limitCache() { return m_bLimitCache; }
  255. void setLimitCache(bool limit);
  256. bool commonScreenBackground() { return m_bCommonScreen; }
  257. void setCommonScreenBackground(bool common);
  258. bool commonDeskBackground() { return m_bCommonDesk; }
  259. void setCommonDeskBackground(bool common);
  260. bool dockPanel() { return m_bDock; }
  261. void setDockPanel(bool dock);
  262. bool exportBackground() {return m_bExport; }
  263. void setExportBackground(bool _export);
  264. void setTextColor(TQColor _color);
  265. TQColor textColor() const { return m_TextColor; }
  266. void setTextBackgroundColor(TQColor _color);
  267. TQColor textBackgroundColor() const { return m_TextBackgroundColor; }
  268. void setShadowEnabled(bool enabled);
  269. bool shadowEnabled() const { return m_shadowEnabled; }
  270. void setTextLines(int lines);
  271. int textLines() const { return m_textLines; }
  272. void setTextWidth(int width);
  273. int textWidth() const { return m_textWidth; }
  274. void readSettings();
  275. void writeSettings();
  276. TDEConfig* getConfig() { return m_pConfig; }
  277. private:
  278. bool dirty;
  279. bool m_bCommonDesk;
  280. bool m_bCommonScreen;
  281. bool m_bDock;
  282. bool m_bLimitCache, m_bExport;
  283. int m_CacheSize;
  284. TQStringList m_Names;
  285. TQColor m_TextColor;
  286. TQColor m_TextBackgroundColor;
  287. bool m_shadowEnabled;
  288. int m_textLines;
  289. int m_textWidth;
  290. TDEConfig *m_pConfig;
  291. bool m_bDeleteConfig;
  292. TQValueVector<bool> m_bDrawBackgroundPerScreen; // m_bDrawBackgroundPerScreen[desk]
  293. };
  294. #endif // __BGSETTINGS_H__