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

FXVisual.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * V i s u a l C l a s s *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1999,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXVisual.h,v 1.41 2006/01/22 17:58:12 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXVISUAL_H
25 #define FXVISUAL_H
26 
27 #ifndef FXID_H
28 #include "FXId.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// Construction options for FXVisual class
35 enum FXVisualOptions {
36  VISUAL_DEFAULT = 0, /// Default visual
37  VISUAL_MONOCHROME = 1, /// Must be monochrome visual
38  VISUAL_BEST = 2, /// Best (deepest) visual
39  VISUAL_INDEXCOLOR = 4, /// Palette visual
40  VISUAL_GRAYSCALE = 8, /// Gray scale visual
41  VISUAL_TRUECOLOR = 16, /// Must be true color visual
42  VISUAL_OWNCOLORMAP = 32, /// Allocate private colormap
43  VISUAL_DOUBLEBUFFER = 64, /// Double-buffered [FXGLVisual]
44  VISUAL_STEREO = 128, /// Stereo [FXGLVisual]
45  VISUAL_NOACCEL = 256, /// No hardware acceleration [for broken h/w]
46  VISUAL_SWAP_COPY = 512 /// Buffer swap by copying [FXGLVisual]
47  };
48 
49 
50 /// Visual type
51 enum FXVisualType {
52  VISUALTYPE_UNKNOWN, /// Undetermined visual type
53  VISUALTYPE_MONO, /// Visual for drawing into 1-bpp surfaces
54  VISUALTYPE_TRUE, /// True color
55  VISUALTYPE_INDEX, /// Index [palette] color
56  VISUALTYPE_GRAY /// Gray scale
57  };
58 
59 
60 class FXApp;
61 class FXWindow;
63 class FXGLCanvas;
64 class FXImage;
65 class FXIcon;
66 class FXBitmap;
67 class FXDCWindow;
68 
69 
70 /// Visual describes pixel format of a drawable
71 class FXAPI FXVisual : public FXId {
73  friend class FXApp;
74  friend class FXWindow;
75  friend class FXImage;
76  friend class FXIcon;
77  friend class FXBitmap;
78  friend class FXDCWindow;
79  friend class FXGLCanvas;
80  friend class FXGLContext;
81 protected:
82  FXuint flags; // Visual flags
83  FXuint hint; // Depth Hint
84  FXuint depth; // Visual depth, significant bits/pixel
85  FXuint numred; // Number of reds
86  FXuint numgreen; // Number of greens
87  FXuint numblue; // Number of blues
88  FXuint numcolors; // Total number of colors
89  FXuint maxcolors; // Maximum number of colors
90  FXVisualType type; // Visual type
91  void *info; // Opaque data
92  void *visual; // Application visual/pixel format
93  FXID colormap; // Color map, if any
94  FXbool freemap; // We allocated the map
95 #ifndef WIN32
96 protected:
97  void *gc; // Drawing GC
98  void *scrollgc; // Scrolling GC
99  FXPixel rpix[16][256]; // Mapping from red -> pixel
100  FXPixel gpix[16][256]; // Mapping from green -> pixel
101  FXPixel bpix[16][256]; // Mapping from blue -> pixel
102  FXPixel lut[256]; // Color lookup table
103 protected:
104  void* setupgc(FXbool);
105  void setuptruecolor();
106  void setupdirectcolor();
107  void setuppseudocolor();
108  void setupstaticcolor();
109  void setupgrayscale();
110  void setupstaticgray();
111  void setuppixmapmono();
112  void setupcolormap();
113 #endif
114 protected:
115  FXVisual();
116 private:
117  FXVisual(const FXVisual&);
118  FXVisual &operator=(const FXVisual&);
119 public:
120 
121  /// Construct default visual
122  FXVisual(FXApp* a,FXuint flgs,FXuint d=32);
123 
124  /// Get visual type
125  FXVisualType getType() const { return type; }
126 
127  /// Get visual info
128  void* getInfo() const { return info; }
129 
130  /// Get visual or pixel format
131  void* getVisual() const { return visual; }
132 
133  /// Create visual
134  virtual void create();
135 
136  /// Detach visual
137  virtual void detach();
138 
139  /// Destroy visual
140  virtual void destroy();
141 
142  /// Get flags (see FXVisualOptions)
143  FXuint getFlags() const { return flags; }
144 
145  /// Get depth, i.e. number of significant bits in color representation
146  FXuint getDepth() const { return depth; }
147 
148  /// Get number of colors
149  FXuint getNumColors() const { return numcolors; }
150 
151  /// Get number of reds
152  FXuint getNumRed() const { return numred; }
153 
154  /// Get number of greens
155  FXuint getNumGreen() const { return numgreen; }
156 
157  /// Get number of blues
158  FXuint getNumBlue() const { return numblue; }
159 
160  /// Get device pixel value for color
161  FXPixel getPixel(FXColor clr);
162 
163  /// Get color value for device pixel value
164  FXColor getColor(FXPixel pix);
165 
166  /// Set maximum number of colors to allocate
167  void setMaxColors(FXuint maxcols);
168 
169  /// Get maximum number of colors
170  FXuint getMaxColors() const { return maxcolors; }
171 
172  /// Save visual information to a stream
173  virtual void save(FXStream& store) const;
174 
175  /// Load visual information from a stream
176  virtual void load(FXStream& store);
177 
178  /// Destructor
179  virtual ~FXVisual();
180  };
181 
182 }
183 
184 #endif
unsigned long FXID
Definition: fxdefs.h:442
A Bitmap is a rectangular array of pixels.
Definition: FXBitmap.h:64
unsigned long FXPixel
Definition: fxdefs.h:451
Base class for all windows.
Definition: FXWindow.h:115
Buffer swap by copying [FXGLVisual].
Definition: FXVisual.h:49
unsigned int FXuint
Definition: fxdefs.h:396
Gray scale visual.
Definition: FXVisual.h:43
Stereo [FXGLVisual].
Definition: FXVisual.h:47
#define FXAPI
Definition: fxdefs.h:122
FXuchar FXbool
Definition: fxdefs.h:393
Index [palette] color.
Definition: FXVisual.h:62
Application Object.
Definition: FXApp.h:158
No hardware acceleration [for broken h/w].
Definition: FXVisual.h:48
Must be true color visual.
Definition: FXVisual.h:44
FXuint FXColor
Definition: fxdefs.h:454
Must be monochrome visual.
Definition: FXVisual.h:40
Best (deepest) visual.
Definition: FXVisual.h:41
Undetermined visual type.
Definition: FXVisual.h:59
Encapsulates server side resource.
Definition: FXId.h:37
Definition: FX4Splitter.h:31
An Icon is an image with two additional server-side resources: a shape bitmap, which is used to mask ...
Definition: FXIcon.h:45
FXVisualType
Visual type.
Definition: FXVisual.h:58
A GL context is an object representing the OpenGL state information.
Definition: FXGLContext.h:46
GLCanvas, an area drawn by another object.
Definition: FXGLCanvas.h:38
FXVisualOptions
Construction options for FXVisual class.
Definition: FXVisual.h:38
Visual describes pixel format of a drawable.
Definition: FXVisual.h:84
Visual for drawing into 1-bpp surfaces.
Definition: FXVisual.h:60
Gray scale.
Definition: FXVisual.h:63
Allocate private colormap.
Definition: FXVisual.h:45
Window Device Context.
Definition: FXDCWindow.h:52
An Image is a rectangular array of pixels.
Definition: FXImage.h:67
Double-buffered [FXGLVisual].
Definition: FXVisual.h:46
True color.
Definition: FXVisual.h:61
Palette visual.
Definition: FXVisual.h:42
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
Default visual.
Definition: FXVisual.h:39

Copyright © 1997-2005 Jeroen van der Zijp