![]() |
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,2002 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.23 2002/01/18 22:42:55 jeroen Exp $ * 00023 ********************************************************************************/ 00024 #ifndef FXVISUAL_H 00025 #define FXVISUAL_H 00026 00027 #ifndef FXID_H 00028 #include "FXId.h" 00029 #endif 00030 00031 00032 00033 /// Construction options for FXVisual class 00034 enum FXVisualOptions { 00035 VISUAL_DEFAULT = 0, /// Default visual 00036 VISUAL_MONOCHROME = 1, /// Must be monochrome visual 00037 VISUAL_BEST = 2, /// Best (deepest) visual 00038 VISUAL_INDEXCOLOR = 4, /// Palette visual 00039 VISUAL_GRAYSCALE = 8, /// Gray scale visual 00040 VISUAL_TRUECOLOR = 16, /// Must be true color visual 00041 VISUAL_OWNCOLORMAP = 32, /// Allocate private colormap 00042 VISUAL_DOUBLEBUFFER = 64, /// Double-buffered [FXGLVisual] 00043 VISUAL_STEREO = 128, /// Stereo [FXGLVisual] 00044 VISUAL_NOACCEL = 256 /// No hardware acceleration [for broken h/w] 00045 }; 00046 00047 00048 /// Visual type 00049 enum FXVisualType { 00050 VISUALTYPE_UNKNOWN, /// Undetermined visual type 00051 VISUALTYPE_MONO, /// Visual for drawing into 1-bpp surfaces 00052 VISUALTYPE_TRUE, /// True color 00053 VISUALTYPE_INDEX, /// Index [palette] color 00054 VISUALTYPE_GRAY /// Gray scale 00055 }; 00056 00057 00058 class FXApp; 00059 class FXWindow; 00060 class FXGLContext; 00061 class FXGLCanvas; 00062 class FXImage; 00063 class FXIcon; 00064 class FXBitmap; 00065 class FXDCWindow; 00066 00067 00068 /// Visual describes pixel format of a drawable 00069 class FXAPI FXVisual : public FXId { 00070 FXDECLARE(FXVisual) 00071 friend class FXApp; 00072 friend class FXWindow; 00073 friend class FXGLContext; 00074 friend class FXGLCanvas; 00075 friend class FXImage; 00076 friend class FXIcon; 00077 friend class FXBitmap; 00078 friend class FXDCWindow; 00079 protected: 00080 FXuint flags; // Visual flags 00081 FXuint hint; // Depth Hint 00082 FXuint depth; // Visual depth, bits/pixel 00083 FXuint numred; // Number of reds 00084 FXuint numgreen; // Number of greens 00085 FXuint numblue; // Number of blues 00086 FXuint numcolors; // Total number of colors 00087 FXuint maxcolors; // Maximum number of colors 00088 FXVisualType type; // Visual type 00089 #ifndef WIN32 00090 protected: 00091 void *visual; // Application visual [Visual] 00092 void *info; // XVisualInfo, if any 00093 FXID colormap; // Color map, if any 00094 void* gc; // Drawing GC 00095 void* scrollgc; // Scrolling GC 00096 FXPixel rpix[16][256]; // Mapping from red -> pixel 00097 FXPixel gpix[16][256]; // Mapping from green -> pixel 00098 FXPixel bpix[16][256]; // Mapping from blue -> pixel 00099 FXPixel lut[256]; // Color lookup table 00100 FXbool freemap; // We allocated the map 00101 protected: 00102 void* makegc(FXbool gex); 00103 void setuptruecolor(); 00104 void setupdirectcolor(); 00105 void setuppseudocolor(); 00106 void setupstaticcolor(); 00107 void setupgrayscale(); 00108 void setupstaticgray(); 00109 void setuppixmapmono(); 00110 void setupcolormap(); 00111 #else 00112 protected: 00113 FXID hPalette; // Palette, if any 00114 void *info; // PIXELFORMATDESCRIPTOR, if any 00115 int pixelformat; // PIXELFORMAT number 00116 protected: 00117 FXID createAllPurposePalette(); 00118 #endif 00119 protected: 00120 FXVisual(); 00121 public: 00122 00123 /// Construct default visual 00124 FXVisual(FXApp* a,FXuint flgs,FXuint d=32); 00125 00126 /// Create visual 00127 virtual void create(); 00128 00129 /// Detach visual 00130 virtual void detach(); 00131 00132 /// Destroy visual 00133 virtual void destroy(); 00134 00135 /// Get flags (see FXVisualOptions) 00136 FXuint getFlags() const { return flags; } 00137 00138 /// Get depth 00139 FXuint getDepth() const { return depth; } 00140 00141 /// Get number of colors 00142 FXuint getNumColors() const { return numcolors; } 00143 00144 /// Get number of reds 00145 FXuint getNumRed() const { return numred; } 00146 00147 /// Get number of greens 00148 FXuint getNumGreen() const { return numred; } 00149 00150 /// Get number of blues 00151 FXuint getNumBlue() const { return numred; } 00152 00153 /// Get device pixel value for color 00154 FXPixel getPixel(FXColor clr); 00155 00156 /// Get color value for device pixel value 00157 FXColor getColor(FXPixel pix); 00158 00159 /// Set maximum number of colors to allocate 00160 void setMaxColors(FXuint maxcols); 00161 00162 /// Get maximum number of colors 00163 FXuint getMaxColors() const { return maxcolors; } 00164 00165 /// Get visual type 00166 FXVisualType getType() const { return type; } 00167 00168 /// Save visual information to a stream 00169 virtual void save(FXStream& store) const; 00170 00171 /// Load visual information from a stream 00172 virtual void load(FXStream& store); 00173 00174 /// Destructor 00175 virtual ~FXVisual(); 00176 }; 00177 00178 00179 #endif