news download themes documentation links










ImageControl.hh

00001 // ImageControl.hh for FbTk - Fluxbox Toolkit
00002 // Copyright (c) 2001 - 2003 Henrik Kinnunen (fluxbox at users.sourceforge.net)
00003 //
00004 // from Image.hh for Blackbox - an X11 Window manager
00005 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net)
00006 //
00007 // Permission is hereby granted, free of charge, to any person obtaining a
00008 // copy of this software and associated documentation files (the "Software"),
00009 // to deal in the Software without restriction, including without limitation
00010 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
00011 // and/or sell copies of the Software, and to permit persons to whom the
00012 // Software is furnished to do so, subject to the following conditions:
00013 //
00014 // The above copyright notice and this permission notice shall be included in
00015 // all copies or substantial portions of the Software.
00016 //
00017 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00020 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00021 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00022 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00023 // DEALINGS IN THE SOFTWARE.
00024 
00025 // $Id: ImageControl.hh,v 1.9 2004/01/11 12:40:47 fluxgen Exp $
00026 
00027 #ifndef  FBTK_IMAGECONTROL_HH
00028 #define  FBTK_IMAGECONTROL_HH
00029 
00030 #include "Texture.hh"
00031 #include "Timer.hh"
00032 #include "NotCopyable.hh"
00033 
00034 #include <X11/Xlib.h>
00035 #include <X11/Xutil.h>
00036 #include <list>
00037 #include <set>
00038 
00039 namespace FbTk {
00040 
00042 class ImageControl: private NotCopyable {
00043 public:
00044     ImageControl(int screen_num, bool dither = false, int colors_per_channel = 4,
00045                   unsigned long cache_timeout = 300000l, unsigned long cache_max = 200l);
00046     virtual ~ImageControl();
00047 
00048     inline bool doDither() const { return m_dither; }
00049     inline int bitsPerPixel() const { return bits_per_pixel; }
00050     inline int depth() const { return m_screen_depth; }
00051     inline int colorsPerChannel() const { return m_colors_per_channel; }
00052     int screenNum() const { return m_screen_num; }
00053     Visual *visual() const { return m_visual; }
00054     unsigned long getSqrt(unsigned int val) const;
00055 
00063     Pixmap renderImage(unsigned int width, unsigned int height,
00064                        const FbTk::Texture &src_texture);
00065 
00066     void installRootColormap();
00067     void removeImage(Pixmap thepix);
00068     void colorTables(const unsigned char **, const unsigned char **, const unsigned char **,
00069                      int *, int *, int *, int *, int *, int *) const;
00070     void getXColorTable(XColor **, int *);
00071     void getGradientBuffers(unsigned int, unsigned int,
00072                             unsigned int **, unsigned int **);
00073     void setDither(bool d) { m_dither = d; }
00074     void setColorsPerChannel(int cpc);
00075 
00076     void cleanCache();
00077 private:
00082     Pixmap searchCache(unsigned int width, unsigned int height, const Texture &text) const;
00083 
00084     void createColorTable();
00085     bool m_dither;
00086     Timer m_timer;
00087 
00088     Colormap m_colormap;
00089 
00090     Window m_root_window;
00091 
00092     XColor *m_colors; 
00093     unsigned int m_num_colors; 
00094 
00095     Visual *m_visual;
00096 
00097     int bits_per_pixel, red_offset, green_offset, blue_offset,
00098         red_bits, green_bits, blue_bits;
00099     int m_colors_per_channel; 
00100     int m_screen_depth; 
00101     int m_screen_num;  
00102     unsigned char red_color_table[256], green_color_table[256],
00103         blue_color_table[256];
00104     unsigned int *grad_xbuffer, *grad_ybuffer, grad_buffer_width,
00105         grad_buffer_height;
00106 
00107     static unsigned long *sqrt_table; 
00108 
00109     typedef struct Cache {
00110         Pixmap pixmap;
00111         Pixmap texture_pixmap;
00112         unsigned int count, width, height;
00113         unsigned long pixel1, pixel2, texture;
00114     } Cache;
00115 
00116     struct ltCacheEntry {
00117         bool operator()(const Cache* s1, const Cache* s2) const {
00118             return (s1->width  < s2->width  || s1->width == s2->width && 
00119                     (s1->height < s2->height || s1->height == s2->height &&
00120                      (s1->texture < s2->texture || s1->texture == s2->texture &&
00121                       s1->pixel1 < s2->pixel1 || s1->pixel1 == s2->pixel1 &&
00122                       (s1->texture & FbTk::Texture::GRADIENT) &&
00123                        s1->pixel2 < s2->pixel2)
00124                         ));
00125         }
00126     };
00127 
00128     
00129     unsigned long cache_max;
00130     typedef std::list<Cache *> CacheList;
00131 
00132     mutable CacheList cache;
00133     static bool s_timed_cache;
00134 };
00135 
00136 } // end namespace FbTk
00137 
00138 #endif // FBTK_IMAGECONTROL_HH
00139 

Fluxbox CVS-Jan-2003




      



Got comments about the page? Send them to webmaster.
If you have general Fluxbox related questions ask them on our irc channel or mailing lists.

Show Source








Designed by aLEczapKA