Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:15

0001 /* @(#)root/base:$Id$ */
0002 
0003 /*************************************************************************
0004  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0005  * All rights reserved.                                                  *
0006  *                                                                       *
0007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0009  *************************************************************************/
0010 
0011 #ifndef ROOT_GuiTypes
0012 #define ROOT_GuiTypes
0013 
0014 //////////////////////////////////////////////////////////////////////////
0015 //                                                                      //
0016 // GuiTypes                                                             //
0017 //                                                                      //
0018 // Types used by the GUI classes.                                       //
0019 //                                                                      //
0020 //////////////////////////////////////////////////////////////////////////
0021 
0022 #include "Rtypes.h"
0023 #include <climits>
0024 
0025 // Basic GUI types
0026 typedef ULongptr_t         Handle_t;     ///< Generic resource handle
0027 typedef Handle_t           Display_t;    ///< Display handle
0028 typedef Handle_t           Visual_t;     ///< Visual handle
0029 typedef Handle_t           Window_t;     ///< Window handle
0030 typedef Handle_t           Pixmap_t;     ///< Pixmap handle
0031 typedef Handle_t           Drawable_t;   ///< Drawable handle
0032 typedef Handle_t           Region_t;     ///< Region handle
0033 typedef Handle_t           Colormap_t;   ///< Colormap handle
0034 typedef Handle_t           Cursor_t;     ///< Cursor handle
0035 typedef Handle_t           FontH_t;      ///< Font handle (as opposed to Font_t which is an index)
0036 typedef Handle_t           KeySym_t;     ///< Key symbol handle
0037 typedef Handle_t           Atom_t;       ///< WM token
0038 typedef Handle_t           GContext_t;   ///< Graphics context handle
0039 typedef Handle_t           FontStruct_t; ///< Pointer to font structure
0040 typedef ULong_t            Pixel_t;      ///< Pixel value
0041 typedef UInt_t             Mask_t;       ///< Structure mask type
0042 typedef ULong_t            Time_t;       ///< Event time
0043 
0044 enum EGuiConstants {
0045    kNotUseful = 0, kWhenMapped = 1, kAlways = 2,
0046    kIsUnmapped = 0, kIsUnviewable = 1, kIsViewable = 2,
0047    kInputOutput = 1, kInputOnly = 2,
0048    kLineSolid = 0, kLineOnOffDash = 1, kLineDoubleDash = 2,
0049    kCapNotLast = 0, kCapButt = 1, kCapRound = 2, kCapProjecting = 3,
0050    kJoinMiter = 0, kJoinRound = 1, kJoinBevel = 2,
0051    kFillSolid = 0, kFillTiled = 1, kFillStippled = 2, kFillOpaqueStippled = 3,
0052    kEvenOddRule = 0, kWindingRule = 1,
0053    kClipByChildren = 0, kIncludeInferiors = 1,
0054    kArcChord = 0, kArcPieSlice = 1
0055 };
0056 
0057 // GUI event types. Later merge with EEventType in Button.h and rename to
0058 // EEventTypes. Also rename in that case kGKeyPress to kKeyPress.
0059 enum EGEventType {
0060    kGKeyPress, kKeyRelease, kButtonPress, kButtonRelease,
0061    kMotionNotify, kEnterNotify, kLeaveNotify, kFocusIn, kFocusOut,
0062    kExpose, kConfigureNotify, kMapNotify, kUnmapNotify, kDestroyNotify,
0063    kClientMessage, kSelectionClear, kSelectionRequest, kSelectionNotify,
0064    kColormapNotify, kButtonDoubleClick, kOtherEvent
0065 };
0066 
0067 enum EGraphicsFunction {
0068    kGXclear = 0,               ///< 0
0069    kGXand,                     ///< src AND dst
0070    kGXandReverse,              ///< src AND NOT dst
0071    kGXcopy,                    ///< src
0072    kGXandInverted,             ///< NOT src AND dst
0073    kGXnoop,                    ///< dst
0074    kGXxor,                     ///< src XOR dst
0075    kGXor,                      ///< src OR dst
0076    kGXnor,                     ///< NOT src AND NOT dst
0077    kGXequiv,                   ///< NOT src XOR dst
0078    kGXinvert,                  ///< NOT dst
0079    kGXorReverse,               ///< src OR NOT dst
0080    kGXcopyInverted,            ///< NOT src
0081    kGXorInverted,              ///< NOT src OR dst
0082    kGXnand,                    ///< NOT src OR NOT dst
0083    kGXset                      ///< 1
0084 };
0085 
0086 enum { kDefaultScrollBarWidth = 16 };
0087 
0088 const Handle_t kNone = 0;
0089 const Handle_t kCopyFromParent = 0;
0090 const Handle_t kParentRelative = 1;
0091 
0092 /// Attributes that can be used when creating or changing a window
0093 struct SetWindowAttributes_t {
0094    Pixmap_t   fBackgroundPixmap;     ///< background or kNone or kParentRelative
0095    ULong_t    fBackgroundPixel;      ///< background pixel
0096    Pixmap_t   fBorderPixmap;         ///< border of the window
0097    ULong_t    fBorderPixel;          ///< border pixel value
0098    UInt_t     fBorderWidth;          ///< border width in pixels
0099    Int_t      fBitGravity;           ///< one of bit gravity values
0100    Int_t      fWinGravity;           ///< one of the window gravity values
0101    Int_t      fBackingStore;         ///< kNotUseful, kWhenMapped, kAlways
0102    ULong_t    fBackingPlanes;        ///< planes to be preserved if possible
0103    ULong_t    fBackingPixel;         ///< value to use in restoring planes
0104    Bool_t     fSaveUnder;            ///< should bits under be saved (popups)?
0105    Long_t     fEventMask;            ///< set of events that should be saved
0106    Long_t     fDoNotPropagateMask;   ///< set of events that should not propagate
0107    Bool_t     fOverrideRedirect;     ///< boolean value for override-redirect
0108    Colormap_t fColormap;             ///< color map to be associated with window
0109    Cursor_t   fCursor;               ///< cursor to be displayed (or kNone)
0110    Mask_t     fMask;                 ///< bit mask specifying which fields are valid
0111 };
0112 
0113 /// Window attributes that can be inquired
0114 struct WindowAttributes_t {
0115    Int_t      fX, fY;                 ///< location of window
0116    Int_t      fWidth, fHeight;        ///< width and height of window
0117    Int_t      fBorderWidth;           ///< border width of window
0118    Int_t      fDepth;                 ///< depth of window
0119    void      *fVisual;                ///< the associated visual structure
0120    Window_t   fRoot;                  ///< root of screen containing window
0121    Int_t      fClass;                 ///< kInputOutput, kInputOnly
0122    Int_t      fBitGravity;            ///< one of bit gravity values
0123    Int_t      fWinGravity;            ///< one of the window gravity values
0124    Int_t      fBackingStore;          ///< kNotUseful, kWhenMapped, kAlways
0125    ULong_t    fBackingPlanes;         ///< planes to be preserved if possible
0126    ULong_t    fBackingPixel;          ///< value to be used when restoring planes
0127    Bool_t     fSaveUnder;             ///< boolean, should bits under be saved?
0128    Colormap_t fColormap;              ///< color map to be associated with window
0129    Bool_t     fMapInstalled;          ///< boolean, is color map currently installed
0130    Int_t      fMapState;              ///< kIsUnmapped, kIsUnviewable, kIsViewable
0131    Long_t     fAllEventMasks;         ///< set of events all people have interest in
0132    Long_t     fYourEventMask;         ///< my event mask
0133    Long_t     fDoNotPropagateMask;    ///< set of events that should not propagate
0134    Bool_t     fOverrideRedirect;      ///< boolean value for override-redirect
0135    void      *fScreen;                ///< back pointer to correct screen
0136 };
0137 
0138 // Bits telling which SetWindowAttributes_t fields are valid
0139 const Mask_t kWABackPixmap       = BIT(0);
0140 const Mask_t kWABackPixel        = BIT(1);
0141 const Mask_t kWABorderPixmap     = BIT(2);
0142 const Mask_t kWABorderPixel      = BIT(3);
0143 const Mask_t kWABorderWidth      = BIT(4);
0144 const Mask_t kWABitGravity       = BIT(5);
0145 const Mask_t kWAWinGravity       = BIT(6);
0146 const Mask_t kWABackingStore     = BIT(7);
0147 const Mask_t kWABackingPlanes    = BIT(8);
0148 const Mask_t kWABackingPixel     = BIT(9);
0149 const Mask_t kWAOverrideRedirect = BIT(10);
0150 const Mask_t kWASaveUnder        = BIT(11);
0151 const Mask_t kWAEventMask        = BIT(12);
0152 const Mask_t kWADontPropagate    = BIT(13);
0153 const Mask_t kWAColormap         = BIT(14);
0154 const Mask_t kWACursor           = BIT(15);
0155 
0156 // Input event masks, used to set SetWindowAttributes_t::fEventMask
0157 // and to be passed to TVirtualX::SelectInput()
0158 const Mask_t kNoEventMask         = 0;
0159 const Mask_t kKeyPressMask        = BIT(0);
0160 const Mask_t kKeyReleaseMask      = BIT(1);
0161 const Mask_t kButtonPressMask     = BIT(2);
0162 const Mask_t kButtonReleaseMask   = BIT(3);
0163 const Mask_t kPointerMotionMask   = BIT(4);
0164 const Mask_t kButtonMotionMask    = BIT(5);
0165 const Mask_t kExposureMask        = BIT(6);
0166 const Mask_t kStructureNotifyMask = BIT(7);
0167 const Mask_t kEnterWindowMask     = BIT(8);
0168 const Mask_t kLeaveWindowMask     = BIT(9);
0169 const Mask_t kFocusChangeMask     = BIT(10);
0170 const Mask_t kOwnerGrabButtonMask = BIT(11);
0171 const Mask_t kColormapChangeMask  = BIT(12);
0172 
0173 /// Event structure
0174 struct Event_t {
0175    EGEventType fType;              ///< of event (see EGEventType)
0176    Window_t    fWindow;            ///< window reported event is relative to
0177    Time_t      fTime;              ///< time event event occurred in ms
0178    Int_t       fX, fY;             ///< pointer x, y coordinates in event window
0179    Int_t       fXRoot, fYRoot;     ///< coordinates relative to root
0180    UInt_t      fCode;              ///< key or button code
0181    UInt_t      fState;             ///< key or button mask
0182    UInt_t      fWidth, fHeight;    ///< width and height of exposed area
0183    Int_t       fCount;             ///< if non-zero, at least this many more exposes
0184    Bool_t      fSendEvent;         ///< true if event came from SendEvent
0185    Handle_t    fHandle;            ///< general resource handle (used for atoms or windows)
0186    Int_t       fFormat;            ///< Next fields only used by kClientMessageEvent
0187    Longptr_t   fUser[5];           ///< 5 longs can be used by client message events
0188                                    ///< NOTE: only [0], [1] and [2] may be used.
0189                                    ///< [1] and [2] may contain >32 bit quantities
0190                                    ///< (i.e. pointers on 64 bit machines)
0191 };
0192 
0193 // Key masks, used as modifiers to GrabButton and GrabKey and
0194 // in Event_t::fState in various key-, mouse-, and button-related events
0195 const Mask_t kKeyShiftMask   = BIT(0);
0196 const Mask_t kKeyLockMask    = BIT(1);
0197 const Mask_t kKeyControlMask = BIT(2);
0198 const Mask_t kKeyMod1Mask    = BIT(3);   ///< typically the Alt key
0199 const Mask_t kKeyMod2Mask    = BIT(4);   ///< typically mod on numeric keys
0200 const Mask_t kKeyMod3Mask    = BIT(5);
0201 const Mask_t kKeyMod4Mask    = BIT(6);
0202 const Mask_t kKeyMod5Mask    = BIT(7);
0203 const Mask_t kButton1Mask    = BIT(8);
0204 const Mask_t kButton2Mask    = BIT(9);
0205 const Mask_t kButton3Mask    = BIT(10);
0206 const Mask_t kButton4Mask    = BIT(11);
0207 const Mask_t kButton5Mask    = BIT(12);
0208 const Mask_t kButton6Mask    = BIT(13);
0209 const Mask_t kButton7Mask    = BIT(14);
0210 const Mask_t kAnyModifier    = BIT(15);
0211 
0212 /// Button names. Used as arguments to GrabButton and as Event_t::fCode
0213 /// for button events. Maps to the X11 values.
0214 enum EMouseButton { kAnyButton, kButton1, kButton2, kButton3,
0215                     kButton4, kButton5, kButton6, kButton7 };
0216 
0217 /// Some magic X notify modes used in TGTextEntry widget.
0218 /// Values must match the ones in /usr/include/X11/X.h. Check when porting.
0219 enum EXMagic { kNotifyNormal = 0, kNotifyGrab = 1, kNotifyUngrab = 2,
0220                kNotifyPointer = 5, kColormapUninstalled = 0,
0221                kColormapInstalled = 1 };
0222 
0223 /// Graphics context structure
0224 struct GCValues_t {
0225    EGraphicsFunction fFunction;  ///< logical operation
0226    ULong_t  fPlaneMask;          ///< plane mask
0227    ULong_t  fForeground;         ///< foreground pixel
0228    ULong_t  fBackground;         ///< background pixel
0229    Int_t    fLineWidth;          ///< line width
0230    Int_t    fLineStyle;          ///< kLineSolid, kLineOnOffDash, kLineDoubleDash
0231    Int_t    fCapStyle;           ///< kCapNotLast, kCapButt,
0232                                  ///< kCapRound, kCapProjecting
0233    Int_t    fJoinStyle;          ///< kJoinMiter, kJoinRound, kJoinBevel
0234    Int_t    fFillStyle;          ///< kFillSolid, kFillTiled,
0235                                  ///< kFillStippled, kFillOpaeueStippled
0236    Int_t    fFillRule;           ///< kEvenOddRule, kWindingRule
0237    Int_t    fArcMode;            ///< kArcChord, kArcPieSlice
0238    Pixmap_t fTile;               ///< tile pixmap for tiling operations
0239    Pixmap_t fStipple;            ///< stipple 1 plane pixmap for stippling
0240    Int_t    fTsXOrigin;          ///< offset for tile or stipple operations
0241    Int_t    fTsYOrigin;
0242    FontH_t  fFont;               ///< default text font for text operations
0243    Int_t    fSubwindowMode;      ///< kClipByChildren, kIncludeInferiors
0244    Bool_t   fGraphicsExposures;  ///< boolean, should exposures be generated
0245    Int_t    fClipXOrigin;        ///< origin for clipping
0246    Int_t    fClipYOrigin;
0247    Pixmap_t fClipMask;           ///< bitmap clipping; other calls for rects
0248    Int_t    fDashOffset;         ///< patterned/dashed line information
0249    Char_t   fDashes[8];          ///< dash pattern list (dash length per byte)
0250    Int_t    fDashLen;            ///< number of dashes in fDashes
0251    Mask_t   fMask;               ///< bit mask specifying which fields are valid
0252 
0253    GCValues_t() : // default constructor
0254       fFunction  (kGXcopy),
0255       fPlaneMask  (0),
0256       fForeground  (0),
0257       fBackground  (1),
0258       fLineWidth  (0),
0259       fLineStyle  (kLineSolid),
0260       fCapStyle  (kCapButt),
0261       fJoinStyle  (kJoinMiter),
0262       fFillStyle  (kFillSolid),
0263       fFillRule  (kEvenOddRule),
0264       fArcMode  (kArcPieSlice),
0265       fTile  (0),
0266       fStipple  (0),
0267       fTsXOrigin  (0),
0268       fTsYOrigin  (0),
0269       fFont  (0),
0270       fSubwindowMode  (kClipByChildren),
0271       fGraphicsExposures  (kTRUE),
0272       fClipXOrigin  (0),
0273       fClipYOrigin  (0),
0274       fClipMask  (0),
0275       fDashOffset  (0),
0276       fDashLen  (2),
0277       fMask  (0)
0278    {
0279       for (int i = 2; i < 8; i++) fDashes[i] = 0;
0280       fDashes[0] = 5; // dashed
0281       fDashes[1] = 5;
0282    }
0283 };
0284 
0285 // Bits telling which GCValues_t fields are valid
0286 const Mask_t kGCFunction          = BIT(0);
0287 const Mask_t kGCPlaneMask         = BIT(1);
0288 const Mask_t kGCForeground        = BIT(2);
0289 const Mask_t kGCBackground        = BIT(3);
0290 const Mask_t kGCLineWidth         = BIT(4);
0291 const Mask_t kGCLineStyle         = BIT(5);
0292 const Mask_t kGCCapStyle          = BIT(6);
0293 const Mask_t kGCJoinStyle         = BIT(7);
0294 const Mask_t kGCFillStyle         = BIT(8);
0295 const Mask_t kGCFillRule          = BIT(9);
0296 const Mask_t kGCTile              = BIT(10);
0297 const Mask_t kGCStipple           = BIT(11);
0298 const Mask_t kGCTileStipXOrigin   = BIT(12);
0299 const Mask_t kGCTileStipYOrigin   = BIT(13);
0300 const Mask_t kGCFont              = BIT(14);
0301 const Mask_t kGCSubwindowMode     = BIT(15);
0302 const Mask_t kGCGraphicsExposures = BIT(16);
0303 const Mask_t kGCClipXOrigin       = BIT(17);
0304 const Mask_t kGCClipYOrigin       = BIT(18);
0305 const Mask_t kGCClipMask          = BIT(19);
0306 const Mask_t kGCDashOffset        = BIT(20);
0307 const Mask_t kGCDashList          = BIT(21);
0308 const Mask_t kGCArcMode           = BIT(22);
0309 
0310 struct ColorStruct_t {
0311    ULong_t   fPixel;    ///< color pixel value (index in color table)
0312    UShort_t  fRed;      ///< red component (0..65535)
0313    UShort_t  fGreen;    ///< green component (0..65535)
0314    UShort_t  fBlue;     ///< blue component (0..65535)
0315    UShort_t  fMask;     ///< mask telling which color components are valid
0316 };
0317 
0318 // Bits telling which ColorStruct_t fields are valid
0319 const Mask_t kDoRed   = BIT(0);
0320 const Mask_t kDoGreen = BIT(1);
0321 const Mask_t kDoBlue  = BIT(2);
0322 
0323 struct PictureAttributes_t {
0324    Colormap_t   fColormap;   ///< colormap to use
0325    Int_t        fDepth;      ///< depth of window
0326    UInt_t       fWidth;      ///< width of picture
0327    UInt_t       fHeight;     ///< height of picture
0328    UInt_t       fXHotspot;   ///< picture x hotspot coordinate
0329    UInt_t       fYHotspot;   ///< picture y hotspot coordinate
0330    ULong_t     *fPixels;     ///< list of used color pixels (if set use delete[])
0331    UInt_t       fNpixels;    ///< number of used color pixels
0332    UInt_t       fCloseness;  ///< allowable RGB deviation
0333    Mask_t       fMask;       ///< mask specifying which attributes are defined
0334 };
0335 
0336 // PictureAttributes_t masks bits
0337 const Mask_t kPAColormap     = BIT(0);
0338 const Mask_t kPADepth        = BIT(1);
0339 const Mask_t kPASize         = BIT(2);   ///< width and height
0340 const Mask_t kPAHotspot      = BIT(3);   ///< x and y hotspot
0341 const Mask_t kPAReturnPixels = BIT(4);
0342 const Mask_t kPACloseness    = BIT(5);
0343 
0344 /// Initial window mapping state
0345 enum EInitialState {
0346    kNormalState = BIT(0),
0347    kIconicState = BIT(1)
0348 };
0349 
0350 /// Used for drawing line segments (maps to the X11 XSegments structure)
0351 struct Segment_t {
0352    Short_t fX1, fY1, fX2, fY2;
0353 };
0354 
0355 /// Point structure (maps to the X11 XPoint structure)
0356 struct Point_t {
0357    Short_t fX, fY;
0358 };
0359 
0360 /// Rectangle structure (maps to the X11 XRectangle structure)
0361 struct Rectangle_t {
0362    Short_t  fX, fY;
0363    UShort_t fWidth, fHeight;
0364 };
0365 
0366 // Atoms used for text cut and paste between windows
0367 const Atom_t kPrimarySelection = 1;       ///< magic values, must match the ones
0368 const Atom_t kCutBuffer        = 9;       ///< in /usr/include/X11/Xatom.h
0369 const Int_t  kMaxPixel         = INT_MAX; ///< Max value for an int
0370 
0371 const int kNumCursors = 19;
0372 enum ECursor { kBottomLeft, kBottomRight, kTopLeft, kTopRight,
0373                kBottomSide, kLeftSide, kTopSide, kRightSide,
0374                kMove, kCross, kArrowHor, kArrowVer, kHand, kRotate,
0375                kPointer, kArrowRight, kCaret, kWatch, kNoDrop };
0376 
0377 /// types of frames (and borders), moved from TGFrame.h
0378 enum EFrameType {
0379    kChildFrame      = 0,
0380    kMainFrame       = BIT(0),
0381    kVerticalFrame   = BIT(1),
0382    kHorizontalFrame = BIT(2),
0383    kSunkenFrame     = BIT(3),
0384    kRaisedFrame     = BIT(4),
0385    kDoubleBorder    = BIT(5),
0386    kFitWidth        = BIT(6),
0387    kFixedWidth      = BIT(7),
0388    kFitHeight       = BIT(8),
0389    kFixedHeight     = BIT(9),
0390    kFixedSize       = (kFixedWidth | kFixedHeight),
0391    kOwnBackground   = BIT(10),
0392    kTransientFrame  = BIT(11),
0393    kTempFrame       = BIT(12),
0394    kMdiMainFrame    = BIT(13),
0395    kMdiFrame        = BIT(14)
0396 };
0397 
0398 
0399 #endif