Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
GuiTypes.h
Go to the documentation of this file.
1 /* @(#)root/base:$Id$ */
2 
3 /*************************************************************************
4  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 #ifndef ROOT_GuiTypes
12 #define ROOT_GuiTypes
13 
14 //////////////////////////////////////////////////////////////////////////
15 // //
16 // GuiTypes //
17 // //
18 // Types used by the GUI classes. //
19 // //
20 //////////////////////////////////////////////////////////////////////////
21 
22 #include "Rtypes.h"
23 
24 // Basic GUI types
25 typedef ULong_t Handle_t; //Generic resource handle
26 typedef Handle_t Display_t; //Display handle
27 typedef Handle_t Visual_t; //Visual handle
28 typedef Handle_t Window_t; //Window handle
29 typedef Handle_t Pixmap_t; //Pixmap handle
30 typedef Handle_t Drawable_t; //Drawable handle
31 typedef Handle_t Region_t; //Region handle
32 typedef Handle_t Colormap_t; //Colormap handle
33 typedef Handle_t Cursor_t; //Cursor handle
34 typedef Handle_t FontH_t; //Font handle (as opposed to Font_t which is an index)
35 typedef Handle_t KeySym_t; //Key symbol handle
36 typedef Handle_t Atom_t; //WM token
37 typedef Handle_t GContext_t; //Graphics context handle
38 typedef Handle_t FontStruct_t; //Pointer to font structure
39 typedef ULong_t Pixel_t; //Pixel value
40 typedef UInt_t Mask_t; //Structure mask type
41 typedef ULong_t Time_t; //Event time
42 
43 enum EGuiConstants {
44  kNotUseful = 0, kWhenMapped = 1, kAlways = 2,
45  kIsUnmapped = 0, kIsUnviewable = 1, kIsViewable = 2,
46  kInputOutput = 1, kInputOnly = 2,
47  kLineSolid = 0, kLineOnOffDash = 1, kLineDoubleDash = 2,
48  kCapNotLast = 0, kCapButt = 1, kCapRound = 2, kCapProjecting = 3,
49  kJoinMiter = 0, kJoinRound = 1, kJoinBevel = 2,
50  kFillSolid = 0, kFillTiled = 1, kFillStippled = 2, kFillOpaqueStippled = 3,
51  kEvenOddRule = 0, kWindingRule = 1,
52  kClipByChildren = 0, kIncludeInferiors = 1,
53  kArcChord = 0, kArcPieSlice = 1
54 };
55 
56 // GUI event types. Later merge with EEventType in Button.h and rename to
57 // EEventTypes. Also rename in that case kGKeyPress to kKeyPress.
58 enum EGEventType {
59  kGKeyPress, kKeyRelease, kButtonPress, kButtonRelease,
60  kMotionNotify, kEnterNotify, kLeaveNotify, kFocusIn, kFocusOut,
61  kExpose, kConfigureNotify, kMapNotify, kUnmapNotify, kDestroyNotify,
62  kClientMessage, kSelectionClear, kSelectionRequest, kSelectionNotify,
63  kColormapNotify, kButtonDoubleClick, kOtherEvent
64 };
65 
66 enum EGraphicsFunction {
67  kGXclear = 0, // 0
68  kGXand, // src AND dst
69  kGXandReverse, // src AND NOT dst
70  kGXcopy, // src
71  kGXandInverted, // NOT src AND dst
72  kGXnoop, // dst
73  kGXxor, // src XOR dst
74  kGXor, // src OR dst
75  kGXnor, // NOT src AND NOT dst
76  kGXequiv, // NOT src XOR dst
77  kGXinvert, // NOT dst
78  kGXorReverse, // src OR NOT dst
79  kGXcopyInverted, // NOT src
80  kGXorInverted, // NOT src OR dst
81  kGXnand, // NOT src OR NOT dst
82  kGXset // 1
83 };
84 
85 enum { kDefaultScrollBarWidth = 16 };
86 
87 const Handle_t kNone = 0;
88 const Handle_t kCopyFromParent = 0;
89 const Handle_t kParentRelative = 1;
90 
91 // Attributes that can be used when creating or changing a window
92 struct SetWindowAttributes_t {
93  Pixmap_t fBackgroundPixmap; // background or kNone or kParentRelative
94  ULong_t fBackgroundPixel; // background pixel
95  Pixmap_t fBorderPixmap; // border of the window
96  ULong_t fBorderPixel; // border pixel value
97  UInt_t fBorderWidth; // border width in pixels
98  Int_t fBitGravity; // one of bit gravity values
99  Int_t fWinGravity; // one of the window gravity values
100  Int_t fBackingStore; // kNotUseful, kWhenMapped, kAlways
101  ULong_t fBackingPlanes; // planes to be preseved if possible
102  ULong_t fBackingPixel; // value to use in restoring planes
103  Bool_t fSaveUnder; // should bits under be saved (popups)?
104  Long_t fEventMask; // set of events that should be saved
105  Long_t fDoNotPropagateMask; // set of events that should not propagate
106  Bool_t fOverrideRedirect; // boolean value for override-redirect
107  Colormap_t fColormap; // color map to be associated with window
108  Cursor_t fCursor; // cursor to be displayed (or kNone)
109  Mask_t fMask; // bit mask specifying which fields are valid
110 };
111 
112 // Window attributes that can be inquired
113 struct WindowAttributes_t {
114  Int_t fX, fY; // location of window
115  Int_t fWidth, fHeight; // width and height of window
116  Int_t fBorderWidth; // border width of window
117  Int_t fDepth; // depth of window
118  void *fVisual; // the associated visual structure
119  Window_t fRoot; // root of screen containing window
120  Int_t fClass; // kInputOutput, kInputOnly
121  Int_t fBitGravity; // one of bit gravity values
122  Int_t fWinGravity; // one of the window gravity values
123  Int_t fBackingStore; // kNotUseful, kWhenMapped, kAlways
124  ULong_t fBackingPlanes; // planes to be preserved if possible
125  ULong_t fBackingPixel; // value to be used when restoring planes
126  Bool_t fSaveUnder; // boolean, should bits under be saved?
127  Colormap_t fColormap; // color map to be associated with window
128  Bool_t fMapInstalled; // boolean, is color map currently installed
129  Int_t fMapState; // kIsUnmapped, kIsUnviewable, kIsViewable
130  Long_t fAllEventMasks; // set of events all people have interest in
131  Long_t fYourEventMask; // my event mask
132  Long_t fDoNotPropagateMask; // set of events that should not propagate
133  Bool_t fOverrideRedirect; // boolean value for override-redirect
134  void *fScreen; // back pointer to correct screen
135 };
136 
137 // Bits telling which SetWindowAttributes_t fields are valid
138 const Mask_t kWABackPixmap = BIT(0);
139 const Mask_t kWABackPixel = BIT(1);
140 const Mask_t kWABorderPixmap = BIT(2);
141 const Mask_t kWABorderPixel = BIT(3);
142 const Mask_t kWABorderWidth = BIT(4);
143 const Mask_t kWABitGravity = BIT(5);
144 const Mask_t kWAWinGravity = BIT(6);
145 const Mask_t kWABackingStore = BIT(7);
146 const Mask_t kWABackingPlanes = BIT(8);
147 const Mask_t kWABackingPixel = BIT(9);
148 const Mask_t kWAOverrideRedirect = BIT(10);
149 const Mask_t kWASaveUnder = BIT(11);
150 const Mask_t kWAEventMask = BIT(12);
151 const Mask_t kWADontPropagate = BIT(13);
152 const Mask_t kWAColormap = BIT(14);
153 const Mask_t kWACursor = BIT(15);
154 
155 // Input event masks, used to set SetWindowAttributes_t::fEventMask
156 // and to be passed to TVirtualX::SelectInput()
157 const Mask_t kNoEventMask = 0;
158 const Mask_t kKeyPressMask = BIT(0);
159 const Mask_t kKeyReleaseMask = BIT(1);
160 const Mask_t kButtonPressMask = BIT(2);
161 const Mask_t kButtonReleaseMask = BIT(3);
162 const Mask_t kPointerMotionMask = BIT(4);
163 const Mask_t kButtonMotionMask = BIT(5);
164 const Mask_t kExposureMask = BIT(6);
165 const Mask_t kStructureNotifyMask = BIT(7);
166 const Mask_t kEnterWindowMask = BIT(8);
167 const Mask_t kLeaveWindowMask = BIT(9);
168 const Mask_t kFocusChangeMask = BIT(10);
169 const Mask_t kOwnerGrabButtonMask = BIT(11);
170 const Mask_t kColormapChangeMask = BIT(12);
171 
172 // Event structure
173 struct Event_t {
174  EGEventType fType; // of event (see EGEventType)
175  Window_t fWindow; // window reported event is relative to
176  Time_t fTime; // time event event occured in ms
177  Int_t fX, fY; // pointer x, y coordinates in event window
178  Int_t fXRoot, fYRoot; // coordinates relative to root
179  UInt_t fCode; // key or button code
180  UInt_t fState; // key or button mask
181  UInt_t fWidth, fHeight; // width and height of exposed area
182  Int_t fCount; // if non-zero, at least this many more exposes
183  Bool_t fSendEvent; // true if event came from SendEvent
184  Handle_t fHandle; // general resource handle (used for atoms or windows)
185  Int_t fFormat; // Next fields only used by kClientMessageEvent
186  Long_t fUser[5]; // 5 longs can be used by client message events
187  // NOTE: only [0], [1] and [2] may be used.
188  // [1] and [2] may contain >32 bit quantities
189  // (i.e. pointers on 64 bit machines)
190 };
191 
192 // Key masks, used as modifiers to GrabButton and GrabKey and
193 // in Event_t::fState in various key-, mouse-, and button-related events
194 const Mask_t kKeyShiftMask = BIT(0);
195 const Mask_t kKeyLockMask = BIT(1);
196 const Mask_t kKeyControlMask = BIT(2);
197 const Mask_t kKeyMod1Mask = BIT(3); // typically the Alt key
198 const Mask_t kKeyMod2Mask = BIT(4); // typically mod on numeric keys
199 const Mask_t kKeyMod3Mask = BIT(5);
200 const Mask_t kKeyMod4Mask = BIT(6);
201 const Mask_t kKeyMod5Mask = BIT(7);
202 const Mask_t kButton1Mask = BIT(8);
203 const Mask_t kButton2Mask = BIT(9);
204 const Mask_t kButton3Mask = BIT(10);
205 const Mask_t kButton4Mask = BIT(11);
206 const Mask_t kButton5Mask = BIT(12);
207 const Mask_t kButton6Mask = BIT(13);
208 const Mask_t kButton7Mask = BIT(14);
209 const Mask_t kAnyModifier = BIT(15);
210 
211 // Button names. Used as arguments to GrabButton and as Event_t::fCode
212 // for button events. Maps to the X11 values.
213 enum EMouseButton { kAnyButton, kButton1, kButton2, kButton3,
214  kButton4, kButton5, kButton6, kButton7 };
215 
216 // Some magic X notify modes used in TGTextEntry widget.
217 // Values must match the ones in /usr/include/X11/X.h. Check when porting.
218 enum EXMagic { kNotifyNormal = 0, kNotifyGrab = 1, kNotifyUngrab = 2,
219  kNotifyPointer = 5, kColormapUninstalled = 0,
220  kColormapInstalled = 1 };
221 
222 // Graphics context structure
223 struct GCValues_t {
224  EGraphicsFunction fFunction; // logical operation
225  ULong_t fPlaneMask; // plane mask
226  ULong_t fForeground; // foreground pixel
227  ULong_t fBackground; // background pixel
228  Int_t fLineWidth; // line width
229  Int_t fLineStyle; // kLineSolid, kLineOnOffDash, kLineDoubleDash
230  Int_t fCapStyle; // kCapNotLast, kCapButt,
231  // kCapRound, kCapProjecting
232  Int_t fJoinStyle; // kJoinMiter, kJoinRound, kJoinBevel
233  Int_t fFillStyle; // kFillSolid, kFillTiled,
234  // kFillStippled, kFillOpaeueStippled
235  Int_t fFillRule; // kEvenOddRule, kWindingRule
236  Int_t fArcMode; // kArcChord, kArcPieSlice
237  Pixmap_t fTile; // tile pixmap for tiling operations
238  Pixmap_t fStipple; // stipple 1 plane pixmap for stipping
239  Int_t fTsXOrigin; // offset for tile or stipple operations
240  Int_t fTsYOrigin;
241  FontH_t fFont; // default text font for text operations
242  Int_t fSubwindowMode; // kClipByChildren, kIncludeInferiors
243  Bool_t fGraphicsExposures; // boolean, should exposures be generated
244  Int_t fClipXOrigin; // origin for clipping
245  Int_t fClipYOrigin;
246  Pixmap_t fClipMask; // bitmap clipping; other calls for rects
247  Int_t fDashOffset; // patterned/dashed line information
248  Char_t fDashes[8]; // dash pattern list (dash length per byte)
249  Int_t fDashLen; // number of dashes in fDashes
250  Mask_t fMask; // bit mask specifying which fields are valid
251 
252  GCValues_t() : // default constructor
253  fFunction (kGXcopy),
254  fPlaneMask (0),
255  fForeground (0),
256  fBackground (1),
257  fLineWidth (0),
258  fLineStyle (kLineSolid),
259  fCapStyle (kCapButt),
260  fJoinStyle (kJoinMiter),
261  fFillStyle (kFillSolid),
262  fFillRule (kEvenOddRule),
263  fArcMode (kArcPieSlice),
264  fTile (0),
265  fStipple (0),
266  fTsXOrigin (0),
267  fTsYOrigin (0),
268  fFont (0),
269  fSubwindowMode (kClipByChildren),
270  fGraphicsExposures (kTRUE),
271  fClipXOrigin (0),
272  fClipYOrigin (0),
273  fClipMask (0),
274  fDashOffset (0),
275  fDashLen (2),
276  fMask (0)
277  {
278  for (int i = 2; i < 8; i++) fDashes[i] = 0;
279  fDashes[0] = 5; // dashed
280  fDashes[1] = 5;
281  }
282 };
283 
284 // Bits telling which GCValues_t fields are valid
285 const Mask_t kGCFunction = BIT(0);
286 const Mask_t kGCPlaneMask = BIT(1);
287 const Mask_t kGCForeground = BIT(2);
288 const Mask_t kGCBackground = BIT(3);
289 const Mask_t kGCLineWidth = BIT(4);
290 const Mask_t kGCLineStyle = BIT(5);
291 const Mask_t kGCCapStyle = BIT(6);
292 const Mask_t kGCJoinStyle = BIT(7);
293 const Mask_t kGCFillStyle = BIT(8);
294 const Mask_t kGCFillRule = BIT(9);
295 const Mask_t kGCTile = BIT(10);
296 const Mask_t kGCStipple = BIT(11);
297 const Mask_t kGCTileStipXOrigin = BIT(12);
298 const Mask_t kGCTileStipYOrigin = BIT(13);
299 const Mask_t kGCFont = BIT(14);
300 const Mask_t kGCSubwindowMode = BIT(15);
301 const Mask_t kGCGraphicsExposures = BIT(16);
302 const Mask_t kGCClipXOrigin = BIT(17);
303 const Mask_t kGCClipYOrigin = BIT(18);
304 const Mask_t kGCClipMask = BIT(19);
305 const Mask_t kGCDashOffset = BIT(20);
306 const Mask_t kGCDashList = BIT(21);
307 const Mask_t kGCArcMode = BIT(22);
308 
309 struct ColorStruct_t {
310  ULong_t fPixel; // color pixel value (index in color table)
311  UShort_t fRed; // red component (0..65535)
312  UShort_t fGreen; // green component (0..65535)
313  UShort_t fBlue; // blue component (0..65535)
314  UShort_t fMask; // mask telling which color components are valid
315 };
316 
317 // Bits telling which ColorStruct_t fields are valid
318 const Mask_t kDoRed = BIT(0);
319 const Mask_t kDoGreen = BIT(1);
320 const Mask_t kDoBlue = BIT(2);
321 
322 struct PictureAttributes_t {
323  Colormap_t fColormap; // colormap to use
324  Int_t fDepth; // depth of window
325  UInt_t fWidth; // width of picture
326  UInt_t fHeight; // height of picture
327  UInt_t fXHotspot; // picture x hotspot coordinate
328  UInt_t fYHotspot; // picture y hotspot coordinate
329  ULong_t *fPixels; // list of used color pixels (if set use delete[])
330  UInt_t fNpixels; // number of used color pixels
331  UInt_t fCloseness; // allowable RGB deviation
332  Mask_t fMask; // mask specifying which attributes are defined
333 };
334 
335 // PictureAttributes_t masks bits
336 const Mask_t kPAColormap = BIT(0);
337 const Mask_t kPADepth = BIT(1);
338 const Mask_t kPASize = BIT(2); // width and height
339 const Mask_t kPAHotspot = BIT(3); // x and y hotspot
340 const Mask_t kPAReturnPixels = BIT(4);
341 const Mask_t kPACloseness = BIT(5);
342 
343 // Initial window mapping state
344 enum EInitialState {
345  kNormalState = BIT(0),
346  kIconicState = BIT(1)
347 };
348 
349 // Used for drawing line segments (maps to the X11 XSegments structure)
350 struct Segment_t {
351  Short_t fX1, fY1, fX2, fY2;
352 };
353 
354 // Point structure (maps to the X11 XPoint structure)
355 struct Point_t {
356  Short_t fX, fY;
357 };
358 
359 // Rectangle structure (maps to the X11 XRectangle structure)
360 struct Rectangle_t {
361  Short_t fX, fY;
362  UShort_t fWidth, fHeight;
363 };
364 
365 // Atoms used for text cut and paste between windows
366 const Atom_t kPrimarySelection = 1; // magic values, must match the ones
367 const Atom_t kCutBuffer = 9; // in /usr/include/X11/Xatom.h
368 const Int_t kMaxPixel = 32000;
369 
370 #endif