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

FXVisual.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                            V i s u a l   C l a s s                            *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1999,2009 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 * $Id: FXVisual.h,v 1.62 2009/01/06 13:07:29 fox Exp $                          *
00022 ********************************************************************************/
00023 #ifndef FXVISUAL_H
00024 #define FXVISUAL_H
00025 
00026 #ifndef FXID_H
00027 #include "FXId.h"
00028 #endif
00029 
00030 namespace FX {
00031 
00032 
00033 class FXWindow;
00034 class FXGLContext;
00035 class FXGLCanvas;
00036 class FXImage;
00037 class FXIcon;
00038 class FXBitmap;
00039 class FXDCWindow;
00040 
00041 
00042 /// Construction options for FXVisual class
00043 enum {
00044   VISUAL_DEFAULT       = 0,     /// Default visual
00045   VISUAL_MONO          = 1,     /// Must be monochrome visual
00046   VISUAL_GRAY          = 2,     /// Gray scale visual
00047   VISUAL_INDEX         = 4,     /// Palette visual
00048   VISUAL_COLOR         = 8,     /// Must be true color visual
00049   VISUAL_BEST          = 16,    /// Best (deepest) visual
00050   VISUAL_FORCE         = 32,    /// Force given visual id (X11)
00051   VISUAL_OWN_COLORMAP  = 64,    /// Allocate private colormap
00052   VISUAL_WINDOW        = 128,   /// Draw to window [GL Visual]
00053   VISUAL_IMAGE         = 256,   /// Draw to image [GL Visual]
00054   VISUAL_BUFFER        = 512,   /// Draw to buffer [GL Visual]
00055   VISUAL_DOUBLE_BUFFER = 1024,  /// Double buffered [GL Visual]
00056   VISUAL_STEREO        = 2048,  /// Stereo buffered [GL Visual]
00057   VISUAL_NO_ACCEL      = 4096,  /// No hardware acceleration [GL Visual]
00058   VISUAL_SWAP_COPY     = 8192,  /// Buffer swap by copying [GL Visual]
00059   VISUAL_FLOAT         = 16384  /// Floating point buffers [GL Visual]
00060   };
00061 
00062 
00063 /// Visual describes pixel format of a drawable
00064 class FXAPI FXVisual : public FXId {
00065   FXDECLARE(FXVisual)
00066   friend class FXApp;
00067   friend class FXWindow;
00068   friend class FXImage;
00069   friend class FXIcon;
00070   friend class FXBitmap;
00071   friend class FXDCWindow;
00072   friend class FXGLCanvas;
00073   friend class FXGLContext;
00074 protected:
00075   void         *visual;                 // Application visual/pixel format
00076   FXID          colormap;               // Color map, if any
00077   FXuint        maxcolors;              // Maximum number of colors
00078   FXuint        numcolors;              // Total number of colors
00079   FXuint        numred;                 // Number of reds
00080   FXuint        numgreen;               // Number of greens
00081   FXuint        numblue;                // Number of blues
00082   FXuint        depth;                  // Visual depth, significant bits/pixel
00083   FXuint        flags;                  // Visual flags
00084   FXuint        hint;                   // Hint value
00085   FXuchar       type;                   // Visual type
00086   FXbool        freemap;                // We allocated the map
00087 #ifndef WIN32
00088 protected:
00089   void         *scrollgc;               // Scrolling GC
00090   void         *gc;                     // Drawing GC
00091   FXPixel       rpix[16][256];          // Mapping from red -> pixel
00092   FXPixel       gpix[16][256];          // Mapping from green -> pixel
00093   FXPixel       bpix[16][256];          // Mapping from blue -> pixel
00094   FXPixel       lut[256];               // Color lookup table
00095 protected:
00096   void setuptruecolor();
00097   void setupdirectcolor();
00098   void setuppseudocolor();
00099   void setupstaticcolor();
00100   void setupgrayscale();
00101   void setupstaticgray();
00102   void setuppixmapmono();
00103   void setupcolormap();
00104   void* setupgc(FXbool);
00105 #endif
00106 protected:
00107   FXVisual();
00108 private:
00109   FXVisual(const FXVisual&);
00110   FXVisual &operator=(const FXVisual&);
00111 public:
00112 
00113   /// Visual types
00114   enum {
00115     Unknown,    /// Undetermined visual type
00116     Mono,       /// Monochrome 1 bit/pixel
00117     Gray,       /// Gray scale color
00118     Index,      /// Index color
00119     Color       /// True color
00120     };
00121 
00122 public:
00123 
00124   /// Construct visual
00125   FXVisual(FXApp* a,FXuint flgs=VISUAL_DEFAULT,FXuint hnt=32);
00126 
00127   /// Get visual type
00128   FXuchar getType() const { return type; }
00129 
00130   /// Get visual or pixel format
00131   void* getVisual() const { return visual; }
00132 
00133   /// Create visual
00134   virtual void create();
00135 
00136   /// Detach visual
00137   virtual void detach();
00138 
00139   /// Destroy visual
00140   virtual void destroy();
00141 
00142   /// Change option flags
00143   void setFlags(FXuint flgs){ flags=flgs; }
00144 
00145   /// Get option flags
00146   FXuint getFlags() const { return flags; }
00147 
00148   /// Change hints
00149   void setHint(FXuint hnt){ hint=hnt; }
00150 
00151   /// Get hints
00152   FXuint getHint() const { return hint; }
00153 
00154   /// Get depth, i.e. number of significant bits in color representation
00155   FXuint getDepth() const { return depth; }
00156 
00157   /// Get number of colors
00158   FXuint getNumColors() const { return numcolors; }
00159 
00160   /// Get number of reds
00161   FXuint getNumRed() const { return numred; }
00162 
00163   /// Get number of greens
00164   FXuint getNumGreen() const { return numgreen; }
00165 
00166   /// Get number of blues
00167   FXuint getNumBlue() const { return numblue; }
00168 
00169   /// Get device pixel value for color
00170   FXPixel getPixel(FXColor clr);
00171 
00172   /// Get color value for device pixel value
00173   FXColor getColor(FXPixel pix);
00174 
00175   /// Set maximum number of colors to allocate
00176   void setMaxColors(FXuint maxcols);
00177 
00178   /// Get maximum number of colors
00179   FXuint getMaxColors() const { return maxcolors; }
00180 
00181   /// Save visual information to a stream
00182   virtual void save(FXStream& store) const;
00183 
00184   /// Load visual information from a stream
00185   virtual void load(FXStream& store);
00186 
00187   /// Destructor
00188   virtual ~FXVisual();
00189   };
00190 
00191 }
00192 
00193 #endif

Copyright © 1997-2009 Jeroen van der Zijp