Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
00001 /******************************************************************************** 00002 * * 00003 * V i s u a l C l a s s * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1999,2006 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or * 00009 * modify it under the terms of the GNU Lesser General Public * 00010 * License as published by the Free Software Foundation; either * 00011 * version 2.1 of the License, or (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 GNU * 00016 * Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public * 00019 * License along with this library; if not, write to the Free Software * 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * 00021 ********************************************************************************* 00022 * $Id: FXVisual.h,v 1.41 2006/01/22 17:58:12 fox Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXVISUAL_H 00025 #define FXVISUAL_H 00026 00027 #ifndef FXID_H 00028 #include "FXId.h" 00029 #endif 00030 00031 namespace FX { 00032 00033 00034 /// Construction options for FXVisual class 00035 enum FXVisualOptions { 00036 VISUAL_DEFAULT = 0, /// Default visual 00037 VISUAL_MONOCHROME = 1, /// Must be monochrome visual 00038 VISUAL_BEST = 2, /// Best (deepest) visual 00039 VISUAL_INDEXCOLOR = 4, /// Palette visual 00040 VISUAL_GRAYSCALE = 8, /// Gray scale visual 00041 VISUAL_TRUECOLOR = 16, /// Must be true color visual 00042 VISUAL_OWNCOLORMAP = 32, /// Allocate private colormap 00043 VISUAL_DOUBLEBUFFER = 64, /// Double-buffered [FXGLVisual] 00044 VISUAL_STEREO = 128, /// Stereo [FXGLVisual] 00045 VISUAL_NOACCEL = 256, /// No hardware acceleration [for broken h/w] 00046 VISUAL_SWAP_COPY = 512 /// Buffer swap by copying [FXGLVisual] 00047 }; 00048 00049 00050 /// Visual type 00051 enum FXVisualType { 00052 VISUALTYPE_UNKNOWN, /// Undetermined visual type 00053 VISUALTYPE_MONO, /// Visual for drawing into 1-bpp surfaces 00054 VISUALTYPE_TRUE, /// True color 00055 VISUALTYPE_INDEX, /// Index [palette] color 00056 VISUALTYPE_GRAY /// Gray scale 00057 }; 00058 00059 00060 class FXApp; 00061 class FXWindow; 00062 class FXGLContext; 00063 class FXGLCanvas; 00064 class FXImage; 00065 class FXIcon; 00066 class FXBitmap; 00067 class FXDCWindow; 00068 00069 00070 /// Visual describes pixel format of a drawable 00071 class FXAPI FXVisual : public FXId { 00072 FXDECLARE(FXVisual) 00073 friend class FXApp; 00074 friend class FXWindow; 00075 friend class FXImage; 00076 friend class FXIcon; 00077 friend class FXBitmap; 00078 friend class FXDCWindow; 00079 friend class FXGLCanvas; 00080 friend class FXGLContext; 00081 protected: 00082 FXuint flags; // Visual flags 00083 FXuint hint; // Depth Hint 00084 FXuint depth; // Visual depth, significant bits/pixel 00085 FXuint numred; // Number of reds 00086 FXuint numgreen; // Number of greens 00087 FXuint numblue; // Number of blues 00088 FXuint numcolors; // Total number of colors 00089 FXuint maxcolors; // Maximum number of colors 00090 FXVisualType type; // Visual type 00091 void *info; // Opaque data 00092 void *visual; // Application visual/pixel format 00093 FXID colormap; // Color map, if any 00094 FXbool freemap; // We allocated the map 00095 #ifndef WIN32 00096 protected: 00097 void *gc; // Drawing GC 00098 void *scrollgc; // Scrolling GC 00099 FXPixel rpix[16][256]; // Mapping from red -> pixel 00100 FXPixel gpix[16][256]; // Mapping from green -> pixel 00101 FXPixel bpix[16][256]; // Mapping from blue -> pixel 00102 FXPixel lut[256]; // Color lookup table 00103 protected: 00104 void* setupgc(FXbool); 00105 void setuptruecolor(); 00106 void setupdirectcolor(); 00107 void setuppseudocolor(); 00108 void setupstaticcolor(); 00109 void setupgrayscale(); 00110 void setupstaticgray(); 00111 void setuppixmapmono(); 00112 void setupcolormap(); 00113 #endif 00114 protected: 00115 FXVisual(); 00116 private: 00117 FXVisual(const FXVisual&); 00118 FXVisual &operator=(const FXVisual&); 00119 public: 00120 00121 /// Construct default visual 00122 FXVisual(FXApp* a,FXuint flgs,FXuint d=32); 00123 00124 /// Get visual type 00125 FXVisualType getType() const { return type; } 00126 00127 /// Get visual info 00128 void* getInfo() const { return info; } 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 /// Get flags (see FXVisualOptions) 00143 FXuint getFlags() const { return flags; } 00144 00145 /// Get depth, i.e. number of significant bits in color representation 00146 FXuint getDepth() const { return depth; } 00147 00148 /// Get number of colors 00149 FXuint getNumColors() const { return numcolors; } 00150 00151 /// Get number of reds 00152 FXuint getNumRed() const { return numred; } 00153 00154 /// Get number of greens 00155 FXuint getNumGreen() const { return numgreen; } 00156 00157 /// Get number of blues 00158 FXuint getNumBlue() const { return numblue; } 00159 00160 /// Get device pixel value for color 00161 FXPixel getPixel(FXColor clr); 00162 00163 /// Get color value for device pixel value 00164 FXColor getColor(FXPixel pix); 00165 00166 /// Set maximum number of colors to allocate 00167 void setMaxColors(FXuint maxcols); 00168 00169 /// Get maximum number of colors 00170 FXuint getMaxColors() const { return maxcolors; } 00171 00172 /// Save visual information to a stream 00173 virtual void save(FXStream& store) const; 00174 00175 /// Load visual information from a stream 00176 virtual void load(FXStream& store); 00177 00178 /// Destructor 00179 virtual ~FXVisual(); 00180 }; 00181 00182 } 00183 00184 #endif
Copyright © 1997-2005 Jeroen van der Zijp |