File indexing completed on 2025-01-18 10:12:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGX11
0013 #define ROOT_TGX11
0014
0015 #include "TVirtualX.h"
0016
0017 #ifdef Status
0018
0019 typedef Status X11Status_t;
0020 #undef Status
0021 typedef X11Status_t Status;
0022 #endif
0023
0024 #ifdef None
0025
0026 static const unsigned long gX11None = None;
0027 #undef None
0028 static const unsigned long None = gX11None;
0029 #endif
0030
0031
0032 typedef unsigned long XID;
0033 typedef XID Drawable;
0034 typedef XID Cursor;
0035 typedef XID Colormap;
0036 typedef XID Window;
0037
0038 struct RXGCValues;
0039 struct RXColor;
0040 struct RXImage;
0041 struct RXPoint;
0042 struct RXpmAttributes;
0043 struct RXSetWindowAttributes;
0044 struct RXVisualInfo;
0045 struct RVisual;
0046
0047
0048 struct XWindow_t {
0049 Int_t fOpen;
0050 Int_t fDoubleBuffer;
0051 Int_t fIsPixmap;
0052 Drawable fDrawing;
0053 Drawable fWindow;
0054 Drawable fBuffer;
0055 UInt_t fWidth;
0056 UInt_t fHeight;
0057 Int_t fClip;
0058 Int_t fXclip;
0059 Int_t fYclip;
0060 UInt_t fWclip;
0061 UInt_t fHclip;
0062 ULong_t *fNewColors;
0063 Int_t fNcolors;
0064 Bool_t fShared;
0065 };
0066
0067
0068 struct XColor_t {
0069 ULong_t fPixel;
0070 UShort_t fRed;
0071 UShort_t fGreen;
0072 UShort_t fBlue;
0073 Bool_t fDefined;
0074 XColor_t() { fPixel = 0; fRed = fGreen = fBlue = 0; fDefined = kFALSE; }
0075 };
0076
0077 class TExMap;
0078
0079
0080 class TGX11 : public TVirtualX {
0081
0082 private:
0083 Int_t fMaxNumberOfWindows;
0084 XWindow_t *fWindows;
0085 TExMap *fColors;
0086 Cursor fCursors[kNumCursors];
0087 void *fXEvent;
0088
0089 void CloseWindow1();
0090 void ClearPixmap(Drawable *pix);
0091 void CopyWindowtoPixmap(Drawable *pix, Int_t xpos, Int_t ypos);
0092 void FindBestVisual();
0093 void FindUsableVisual(RXVisualInfo *vlist, Int_t nitems);
0094 void PutImage(Int_t offset, Int_t itran, Int_t x0, Int_t y0, Int_t nx,
0095 Int_t ny, Int_t xmin, Int_t ymin, Int_t xmax, Int_t ymax,
0096 UChar_t *image, Drawable_t id);
0097 void RemovePixmap(Drawable *pix);
0098 void SetColor(void *gc, Int_t ci);
0099 void SetFillStyleIndex(Int_t style, Int_t fasi);
0100 void SetInput(Int_t inp);
0101 void SetMarkerType(Int_t type, Int_t n, RXPoint *xy);
0102 void CollectImageColors(ULong_t pixel, ULong_t *&orgcolors, Int_t &ncolors,
0103 Int_t &maxcolors);
0104 void MakeOpaqueColors(Int_t percent, ULong_t *orgcolors, Int_t ncolors);
0105 Int_t FindColor(ULong_t pixel, ULong_t *orgcolors, Int_t ncolors);
0106 void ImgPickPalette(RXImage *image, Int_t &ncol, Int_t *&R, Int_t *&G, Int_t *&B);
0107
0108
0109 void MapGCValues(GCValues_t &gval, ULong_t &xmask, RXGCValues &xgval, Bool_t tox = kTRUE);
0110 void MapSetWindowAttributes(SetWindowAttributes_t *attr,
0111 ULong_t &xmask, RXSetWindowAttributes &xattr);
0112 void MapCursor(ECursor cursor, Int_t &xcursor);
0113 void MapColorStruct(ColorStruct_t *color, RXColor &xcolor);
0114 void MapPictureAttributes(PictureAttributes_t &attr, RXpmAttributes &xpmattr,
0115 Bool_t toxpm = kTRUE);
0116 void MapModifierState(UInt_t &state, UInt_t &xstate, Bool_t tox = kTRUE);
0117
0118
0119 void MapEvent(Event_t &ev, void *xev, Bool_t tox = kTRUE);
0120
0121 void MapEventMask(UInt_t &emask, UInt_t &xemask, Bool_t tox = kTRUE);
0122 void MapKeySym(UInt_t &keysym, UInt_t &xkeysym, Bool_t tox = kTRUE);
0123
0124 protected:
0125 void *fDisplay;
0126 RVisual *fVisual;
0127 Drawable fRootWin;
0128 Drawable fVisRootWin;
0129 Colormap fColormap;
0130 ULong_t fBlackPixel;
0131 ULong_t fWhitePixel;
0132 Int_t fScreenNumber;
0133 Int_t fTextAlignH;
0134 Int_t fTextAlignV;
0135 Int_t fTextAlign;
0136 Float_t fCharacterUpX;
0137 Float_t fCharacterUpY;
0138 Float_t fTextMagnitude;
0139 Int_t fDepth;
0140 Int_t fRedDiv;
0141 Int_t fGreenDiv;
0142 Int_t fBlueDiv;
0143 Int_t fRedShift;
0144 Int_t fGreenShift;
0145 Int_t fBlueShift;
0146 Bool_t fHasTTFonts;
0147 Bool_t fHasXft;
0148
0149
0150 Bool_t AllocColor(Colormap cmap, RXColor *color);
0151 void QueryColors(Colormap cmap, RXColor *colors, Int_t ncolors);
0152 void *GetGC(Int_t which) const;
0153 XColor_t &GetColor(Int_t cid);
0154
0155 public:
0156 TGX11();
0157 TGX11(const TGX11 &org);
0158 TGX11(const char *name, const char *title);
0159 ~TGX11() override;
0160
0161 Bool_t Init(void *display) override;
0162 void ClearWindow() override;
0163 void ClosePixmap() override;
0164 void CloseWindow() override;
0165 void CopyPixmap(Int_t wid, Int_t xpos, Int_t ypos) override;
0166 void DrawBox(Int_t x1, Int_t y1, Int_t x2, Int_t y2, EBoxMode mode) override;
0167 void DrawCellArray(Int_t x1, Int_t y1, Int_t x2, Int_t y2, Int_t nx, Int_t ny, Int_t *ic) override;
0168 void DrawFillArea(Int_t n, TPoint *xy) override;
0169 void DrawLine(Int_t x1, Int_t y1, Int_t x2, Int_t y2) override;
0170 void DrawPolyLine(Int_t n, TPoint *xy) override;
0171 void DrawPolyMarker(Int_t n, TPoint *xy) override;
0172 void DrawText(Int_t x, Int_t y, Float_t angle, Float_t mgn, const char *text, ETextMode mode) override;
0173 void DrawText(Int_t, Int_t, Float_t, Float_t, const wchar_t *, ETextMode) override {}
0174 void GetCharacterUp(Float_t &chupx, Float_t &chupy) override;
0175 Int_t GetDoubleBuffer(Int_t wid) override;
0176 void GetGeometry(Int_t wid, Int_t &x, Int_t &y, UInt_t &w, UInt_t &h) override;
0177 const char *DisplayName(const char *dpyName = nullptr) override;
0178 Handle_t GetNativeEvent() const override { return (Handle_t) fXEvent; }
0179 ULong_t GetPixel(Color_t cindex) override;
0180 void GetPlanes(Int_t &nplanes) override;
0181 void GetRGB(Int_t index, Float_t &r, Float_t &g, Float_t &b) override;
0182 void GetTextExtent(UInt_t &w, UInt_t &h, char *mess) override;
0183 void GetTextExtent(UInt_t &, UInt_t &, wchar_t *) override {}
0184 Float_t GetTextMagnitude() override { return fTextMagnitude; }
0185 Window_t GetWindowID(Int_t wid) override;
0186 Bool_t HasTTFonts() const override { return fHasTTFonts; }
0187 Int_t InitWindow(ULong_t window) override;
0188 Int_t AddWindow(ULong_t qwid, UInt_t w, UInt_t h) override;
0189 Int_t AddPixmap(ULong_t pixid, UInt_t w, UInt_t h) override;
0190 void RemoveWindow(ULong_t qwid) override;
0191 void MoveWindow(Int_t wid, Int_t x, Int_t y) override;
0192 Int_t OpenDisplay(void *display);
0193 Int_t OpenPixmap(UInt_t w, UInt_t h) override;
0194 void QueryPointer(Int_t &ix, Int_t &iy) override;
0195 Pixmap_t ReadGIF(Int_t x0, Int_t y0, const char *file, Window_t id = 0) override;
0196 Int_t RequestLocator(Int_t mode, Int_t ctyp, Int_t &x, Int_t &y) override;
0197 Int_t RequestString(Int_t x, Int_t y, char *text) override;
0198 void RescaleWindow(Int_t wid, UInt_t w, UInt_t h) override;
0199 Int_t ResizePixmap(Int_t wid, UInt_t w, UInt_t h) override;
0200 void ResizeWindow(Int_t wid) override;
0201 void SelectWindow(Int_t wid) override;
0202 void SetCharacterUp(Float_t chupx, Float_t chupy) override;
0203 void SetClipOFF(Int_t wid) override;
0204 void SetClipRegion(Int_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h) override;
0205 void SetCursor(Int_t win, ECursor cursor) override;
0206 void SetDoubleBuffer(Int_t wid, Int_t mode) override;
0207 void SetDoubleBufferOFF() override;
0208 void SetDoubleBufferON() override;
0209 void SetDrawMode(EDrawMode mode) override;
0210 void SetFillColor(Color_t cindex) override;
0211 void SetFillStyle(Style_t style) override;
0212 void SetLineColor(Color_t cindex) override;
0213 void SetLineType(Int_t n, Int_t *dash) override;
0214 void SetLineStyle(Style_t linestyle) override;
0215 void SetLineWidth(Width_t width) override;
0216 void SetMarkerColor(Color_t cindex) override;
0217 void SetMarkerSize(Float_t markersize) override;
0218 void SetMarkerStyle(Style_t markerstyle) override;
0219 void SetOpacity(Int_t percent) override;
0220 void SetRGB(Int_t cindex, Float_t r, Float_t g, Float_t b) override;
0221 void SetTextAlign(Short_t talign=11) override;
0222 void SetTextColor(Color_t cindex) override;
0223 Int_t SetTextFont(char *fontname, ETextSetMode mode) override;
0224 void SetTextFont(Font_t fontnumber) override;
0225 void SetTextMagnitude(Float_t mgn=1) override { fTextMagnitude = mgn;}
0226 void SetTextSize(Float_t textsize) override;
0227 void Sync(Int_t mode) override;
0228 void UpdateWindow(Int_t mode) override;
0229 void Warp(Int_t ix, Int_t iy, Window_t id = 0) override;
0230 Int_t WriteGIF(char *name) override;
0231 void WritePixmap(Int_t wid, UInt_t w, UInt_t h, char *pxname) override;
0232 Window_t GetCurrentWindow() const override;
0233 Int_t SupportsExtension(const char *ext) const override;
0234
0235
0236 void GetWindowAttributes(Window_t id, WindowAttributes_t &attr) override;
0237 void MapWindow(Window_t id) override;
0238 void MapSubwindows(Window_t id) override;
0239 void MapRaised(Window_t id) override;
0240 void UnmapWindow(Window_t id) override;
0241 void DestroyWindow(Window_t id) override;
0242 void DestroySubwindows(Window_t id) override;
0243 void RaiseWindow(Window_t id) override;
0244 void LowerWindow(Window_t id) override;
0245 void MoveWindow(Window_t id, Int_t x, Int_t y) override;
0246 void MoveResizeWindow(Window_t id, Int_t x, Int_t y, UInt_t w, UInt_t h) override;
0247 void ResizeWindow(Window_t id, UInt_t w, UInt_t h) override;
0248 void IconifyWindow(Window_t id) override;
0249 void ReparentWindow(Window_t id, Window_t pid, Int_t x, Int_t y) override;
0250 void SetWindowBackground(Window_t id, ULong_t color) override;
0251 void SetWindowBackgroundPixmap(Window_t id, Pixmap_t pxm) override;
0252 Window_t CreateWindow(Window_t parent, Int_t x, Int_t y,
0253 UInt_t w, UInt_t h, UInt_t border,
0254 Int_t depth, UInt_t clss,
0255 void *visual, SetWindowAttributes_t *attr,
0256 UInt_t wtype) override;
0257 Int_t OpenDisplay(const char *dpyName) override;
0258 void CloseDisplay() override;
0259 Display_t GetDisplay() const override;
0260 Visual_t GetVisual() const override;
0261 Int_t GetScreen() const override;
0262 Int_t GetDepth() const override;
0263 Colormap_t GetColormap() const override;
0264 Atom_t InternAtom(const char *atom_name, Bool_t only_if_exist) override;
0265 Window_t GetDefaultRootWindow() const override;
0266 Window_t GetParent(Window_t id) const override;
0267 FontStruct_t LoadQueryFont(const char *font_name) override;
0268 FontH_t GetFontHandle(FontStruct_t fs) override;
0269 void DeleteFont(FontStruct_t fs) override;
0270 GContext_t CreateGC(Drawable_t id, GCValues_t *gval) override;
0271 void ChangeGC(GContext_t gc, GCValues_t *gval) override;
0272 void CopyGC(GContext_t org, GContext_t dest, Mask_t mask) override;
0273 void DeleteGC(GContext_t gc) override;
0274 Cursor_t CreateCursor(ECursor cursor) override;
0275 void SetCursor(Window_t id, Cursor_t curid) override;
0276 Pixmap_t CreatePixmap(Drawable_t id, UInt_t w, UInt_t h) override;
0277 Pixmap_t CreatePixmap(Drawable_t id, const char *bitmap, UInt_t width,
0278 UInt_t height, ULong_t forecolor, ULong_t backcolor,
0279 Int_t depth) override;
0280 unsigned char *GetColorBits(Drawable_t wid, Int_t x = 0, Int_t y = 0, UInt_t w = 0, UInt_t h = 0) override;
0281 Pixmap_t CreatePixmapFromData(unsigned char *bits, UInt_t width, UInt_t height) override;
0282 Pixmap_t CreateBitmap(Drawable_t id, const char *bitmap,
0283 UInt_t width, UInt_t height) override;
0284 void DeletePixmap(Pixmap_t pmap) override;
0285 Bool_t CreatePictureFromFile(Drawable_t id, const char *filename,
0286 Pixmap_t &pict, Pixmap_t &pict_mask,
0287 PictureAttributes_t &attr) override;
0288 Bool_t CreatePictureFromData(Drawable_t id, char **data,
0289 Pixmap_t &pict, Pixmap_t &pict_mask,
0290 PictureAttributes_t &attr) override;
0291 Bool_t ReadPictureDataFromFile(const char *filename, char ***ret_data) override;
0292 void DeletePictureData(void *data) override;
0293 void SetDashes(GContext_t gc, Int_t offset, const char *dash_list, Int_t n) override;
0294 Bool_t ParseColor(Colormap_t cmap, const char *cname, ColorStruct_t &color) override;
0295 Bool_t AllocColor(Colormap_t cmap, ColorStruct_t &color) override;
0296 void QueryColor(Colormap_t cmap, ColorStruct_t &color) override;
0297 void FreeColor(Colormap_t cmap, ULong_t pixel) override;
0298 Int_t EventsPending() override;
0299 void NextEvent(Event_t &event) override;
0300 void Bell(Int_t percent) override;
0301 void CopyArea(Drawable_t src, Drawable_t dest, GContext_t gc,
0302 Int_t src_x, Int_t src_y, UInt_t width, UInt_t height,
0303 Int_t dest_x, Int_t dest_y) override;
0304 void ChangeWindowAttributes(Window_t id, SetWindowAttributes_t *attr) override;
0305 void ChangeProperty(Window_t id, Atom_t property, Atom_t type,
0306 UChar_t *data, Int_t len) override;
0307 void DrawLine(Drawable_t id, GContext_t gc, Int_t x1, Int_t y1, Int_t x2, Int_t y2) override;
0308 void ClearArea(Window_t id, Int_t x, Int_t y, UInt_t w, UInt_t h) override;
0309 Bool_t CheckEvent(Window_t id, EGEventType type, Event_t &ev) override;
0310 void SendEvent(Window_t id, Event_t *ev) override;
0311 void WMDeleteNotify(Window_t id) override;
0312 void SetKeyAutoRepeat(Bool_t on = kTRUE) override;
0313 void GrabKey(Window_t id, Int_t keycode, UInt_t modifier, Bool_t grab = kTRUE) override;
0314 void GrabButton(Window_t id, EMouseButton button, UInt_t modifier,
0315 UInt_t evmask, Window_t confine, Cursor_t cursor,
0316 Bool_t grab = kTRUE) override;
0317 void GrabPointer(Window_t id, UInt_t evmask, Window_t confine,
0318 Cursor_t cursor, Bool_t grab = kTRUE,
0319 Bool_t owner_events = kTRUE) override;
0320 void SetWindowName(Window_t id, char *name) override;
0321 void SetIconName(Window_t id, char *name) override;
0322 void SetIconPixmap(Window_t id, Pixmap_t pic) override;
0323 void SetClassHints(Window_t id, char *className, char *resourceName) override;
0324 void SetMWMHints(Window_t id, UInt_t value, UInt_t funcs, UInt_t input) override;
0325 void SetWMPosition(Window_t id, Int_t x, Int_t y) override;
0326 void SetWMSize(Window_t id, UInt_t w, UInt_t h) override;
0327 void SetWMSizeHints(Window_t id, UInt_t wmin, UInt_t hmin,
0328 UInt_t wmax, UInt_t hmax, UInt_t winc, UInt_t hinc) override;
0329 void SetWMState(Window_t id, EInitialState state) override;
0330 void SetWMTransientHint(Window_t id, Window_t main_id) override;
0331 void DrawString(Drawable_t id, GContext_t gc, Int_t x, Int_t y,
0332 const char *s, Int_t len) override;
0333 Int_t TextWidth(FontStruct_t font, const char *s, Int_t len) override;
0334 void GetFontProperties(FontStruct_t font, Int_t &max_ascent, Int_t &max_descent) override;
0335 void GetGCValues(GContext_t gc, GCValues_t &gval) override;
0336 FontStruct_t GetFontStruct(FontH_t fh) override;
0337 void FreeFontStruct(FontStruct_t fs) override;
0338 void ClearWindow(Window_t id) override;
0339 Int_t KeysymToKeycode(UInt_t keysym) override;
0340 void FillRectangle(Drawable_t id, GContext_t gc, Int_t x, Int_t y,
0341 UInt_t w, UInt_t h) override;
0342 void DrawRectangle(Drawable_t id, GContext_t gc, Int_t x, Int_t y,
0343 UInt_t w, UInt_t h) override;
0344 void DrawSegments(Drawable_t id, GContext_t gc, Segment_t *seg, Int_t nseg) override;
0345 void SelectInput(Window_t id, UInt_t evmask) override;
0346 Window_t GetInputFocus() override;
0347 void SetInputFocus(Window_t id) override;
0348 Window_t GetPrimarySelectionOwner() override;
0349 void SetPrimarySelectionOwner(Window_t id) override;
0350 void ConvertPrimarySelection(Window_t id, Atom_t clipboard, Time_t when) override;
0351 void LookupString(Event_t *event, char *buf, Int_t buflen, UInt_t &keysym) override;
0352 void GetPasteBuffer(Window_t id, Atom_t atom, TString &text,
0353 Int_t &nchar, Bool_t del) override;
0354 void TranslateCoordinates(Window_t src, Window_t dest, Int_t src_x,
0355 Int_t src_y, Int_t &dest_x, Int_t &dest_y, Window_t &child) override;
0356 void GetWindowSize(Drawable_t id, Int_t &x, Int_t &y, UInt_t &w, UInt_t &h) override;
0357 void FillPolygon(Window_t id, GContext_t gc, Point_t *points, Int_t npnt) override;
0358 void QueryPointer(Window_t id, Window_t &rootw, Window_t &childw,
0359 Int_t &root_x, Int_t &root_y, Int_t &win_x,
0360 Int_t &win_y, UInt_t &mask) override;
0361 void SetForeground(GContext_t gc, ULong_t foreground) override;
0362 void SetClipRectangles(GContext_t gc, Int_t x, Int_t y, Rectangle_t *recs, Int_t n) override;
0363 void Update(Int_t mode = 0) override;
0364 Region_t CreateRegion() override;
0365 void DestroyRegion(Region_t reg) override;
0366 void UnionRectWithRegion(Rectangle_t *rect, Region_t src, Region_t dest) override;
0367 Region_t PolygonRegion(Point_t *points, Int_t np, Bool_t winding) override;
0368 void UnionRegion(Region_t rega, Region_t regb, Region_t result) override;
0369 void IntersectRegion(Region_t rega, Region_t regb, Region_t result) override;
0370 void SubtractRegion(Region_t rega, Region_t regb, Region_t result) override;
0371 void XorRegion(Region_t rega, Region_t regb, Region_t result) override;
0372 Bool_t EmptyRegion(Region_t reg) override;
0373 Bool_t PointInRegion(Int_t x, Int_t y, Region_t reg) override;
0374 Bool_t EqualRegion(Region_t rega, Region_t regb) override;
0375 void GetRegionBox(Region_t reg, Rectangle_t *) override;
0376 char **ListFonts(const char *fontname, Int_t max, Int_t &count) override;
0377 void FreeFontNames(char **fontlist) override;
0378 Drawable_t CreateImage(UInt_t width, UInt_t height) override;
0379 void GetImageSize(Drawable_t id, UInt_t &width, UInt_t &height) override;
0380 void PutPixel(Drawable_t id, Int_t x, Int_t y, ULong_t pixel) override;
0381 void PutImage(Drawable_t id, GContext_t gc, Drawable_t img,
0382 Int_t dx, Int_t dy, Int_t x, Int_t y,
0383 UInt_t w, UInt_t h) override;
0384 void DeleteImage(Drawable_t img) override;
0385 void ShapeCombineMask(Window_t id, Int_t x, Int_t y, Pixmap_t mask) override;
0386 UInt_t ScreenWidthMM() const override;
0387
0388 void DeleteProperty(Window_t, Atom_t&) override;
0389 Int_t GetProperty(Window_t, Atom_t, Long_t, Long_t, Bool_t, Atom_t,
0390 Atom_t*, Int_t*, ULong_t*, ULong_t*, unsigned char**) override;
0391 void ChangeActivePointerGrab(Window_t, UInt_t, Cursor_t) override;
0392 void ConvertSelection(Window_t, Atom_t&, Atom_t&, Atom_t&, Time_t&) override;
0393 Bool_t SetSelectionOwner(Window_t, Atom_t&) override;
0394 void ChangeProperties(Window_t id, Atom_t property, Atom_t type,
0395 Int_t format, UChar_t *data, Int_t len) override;
0396 void SetDNDAware(Window_t, Atom_t *) override;
0397 void SetTypeList(Window_t win, Atom_t prop, Atom_t *typelist) override;
0398 Window_t FindRWindow(Window_t win, Window_t dragwin, Window_t input, int x, int y, int maxd) override;
0399 Bool_t IsDNDAware(Window_t win, Atom_t *typelist) override;
0400
0401 ClassDefOverride(TGX11,0)
0402 };
0403
0404 #endif