Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

/home/jeroen/FOX/fox/fox-1.7.33/include/FXVisual.h
00001 /********************************************************************************
00002 *                                                                               *
00003 *                            V i s u a l   C l a s s                            *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1999,2012 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 ********************************************************************************/
00021 #ifndef FXVISUAL_H
00022 #define FXVISUAL_H
00023 
00024 #ifndef FXID_H
00025 #include "FXId.h"
00026 #endif
00027 
00028 namespace FX {
00029 
00030 
00031 class FXWindow;
00032 class FXGLContext;
00033 class FXGLCanvas;
00034 class FXImage;
00035 class FXIcon;
00036 class FXBitmap;
00037 class FXDCWindow;
00038 
00039 
00041 enum {
00042   VISUAL_DEFAULT       = 0,     
00043   VISUAL_MONO          = 1,     
00044   VISUAL_GRAY          = 2,     
00045   VISUAL_INDEX         = 4,     
00046   VISUAL_COLOR         = 8,     
00047   VISUAL_BEST          = 16,    
00048   VISUAL_FORCE         = 32,    
00049   VISUAL_OWN_COLORMAP  = 64,    
00050   VISUAL_DOUBLE_BUFFER = 128,   
00051   VISUAL_STEREO        = 256,   
00052   VISUAL_NO_ACCEL      = 512,   
00053   VISUAL_SWAP_COPY     = 1024   
00054   };
00055 
00056 
00058 class FXAPI FXVisual : public FXId {
00059   FXDECLARE(FXVisual)
00060   friend class FXApp;
00061   friend class FXWindow;
00062   friend class FXImage;
00063   friend class FXIcon;
00064   friend class FXBitmap;
00065   friend class FXDCWindow;
00066   friend class FXGLCanvas;
00067   friend class FXGLContext;
00068 protected:
00069   void         *visual;                 // Application visual/pixel format
00070   FXID          colormap;               // Color map, if any
00071   FXuint        maxcolors;              // Maximum number of colors
00072   FXuint        numcolors;              // Total number of colors
00073   FXuint        numred;                 // Number of reds
00074   FXuint        numgreen;               // Number of greens
00075   FXuint        numblue;                // Number of blues
00076   FXuint        depth;                  // Visual depth, significant bits/pixel
00077   FXuint        flags;                  // Visual flags
00078   FXuint        hint;                   // Hint value
00079   FXuchar       type;                   // Visual type
00080   FXbool        freemap;                // We allocated the map
00081 #ifndef WIN32
00082 protected:
00083   void         *scrollgc;               // Scrolling GC
00084   void         *gc;                     // Drawing GC
00085   FXPixel       rpix[16][256];          // Mapping from red -> pixel
00086   FXPixel       gpix[16][256];          // Mapping from green -> pixel
00087   FXPixel       bpix[16][256];          // Mapping from blue -> pixel
00088   FXPixel       lut[256];               // Color lookup table
00089 protected:
00090   void setuptruecolor();
00091   void setupdirectcolor();
00092   void setuppseudocolor();
00093   void setupstaticcolor();
00094   void setupgrayscale();
00095   void setupstaticgray();
00096   void setuppixmapmono();
00097   void setupcolormap();
00098   void* setupgc(FXbool);
00099 #endif
00100 protected:
00101   FXVisual();
00102 private:
00103   FXVisual(const FXVisual&);
00104   FXVisual &operator=(const FXVisual&);
00105 public:
00106 
00108   enum {
00109     Unknown,    
00110     Mono,       
00111     Gray,       
00112     Index,      
00113     Color       
00114     };
00115 
00116 public:
00117 
00119   FXVisual(FXApp* a,FXuint flgs=VISUAL_DEFAULT,FXuint hnt=32);
00120 
00122   FXuchar getType() const { return type; }
00123 
00125   void* getVisual() const { return visual; }
00126 
00128   virtual void create();
00129 
00131   virtual void detach();
00132 
00134   virtual void destroy();
00135 
00137   void setFlags(FXuint flgs){ flags=flgs; }
00138 
00140   FXuint getFlags() const { return flags; }
00141 
00143   void setHint(FXuint hnt){ hint=hnt; }
00144 
00146   FXuint getHint() const { return hint; }
00147 
00149   FXuint getDepth() const { return depth; }
00150 
00152   FXuint getNumColors() const { return numcolors; }
00153 
00155   FXuint getNumRed() const { return numred; }
00156 
00158   FXuint getNumGreen() const { return numgreen; }
00159 
00161   FXuint getNumBlue() const { return numblue; }
00162 
00164   FXPixel getPixel(FXColor clr);
00165 
00167   FXColor getColor(FXPixel pix);
00168 
00170   void setMaxColors(FXuint maxcols);
00171 
00173   FXuint getMaxColors() const { return maxcolors; }
00174 
00176   virtual void save(FXStream& store) const;
00177 
00179   virtual void load(FXStream& store);
00180 
00182   virtual ~FXVisual();
00183   };
00184 
00185 }
00186 
00187 #endif

Copyright © 1997-2011 Jeroen van der Zijp