00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TGX11
00013 #define ROOT_TGX11
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef ROOT_TVirtualX
00026 #include "TVirtualX.h"
00027 #endif
00028
00029 #if !defined(__CINT__)
00030
00031 #include <X11/Xlib.h>
00032 #include <X11/Xutil.h>
00033 #include <X11/Xatom.h>
00034 #include <X11/cursorfont.h>
00035 #include <X11/keysym.h>
00036 #include <X11/xpm.h>
00037
00038 #else
00039
00040 typedef unsigned long XID;
00041 typedef XID Drawable;
00042 typedef XID Cursor;
00043 typedef XID Colormap;
00044 typedef XID Window;
00045
00046 struct GC;
00047 struct Display;
00048 struct Visual;
00049 struct XVisualInfo;
00050 struct XGCValues;
00051 struct XSetWindowAttributes;
00052 struct XColor;
00053 struct XEvent;
00054 struct XImage;
00055 struct XPoint;
00056 struct XpmAttributes;
00057
00058 #endif
00059
00060
00061 struct XWindow_t {
00062 Int_t fOpen;
00063 Int_t fDoubleBuffer;
00064 Int_t fIsPixmap;
00065 Drawable fDrawing;
00066 Drawable fWindow;
00067 Drawable fBuffer;
00068 UInt_t fWidth;
00069 UInt_t fHeight;
00070 Int_t fClip;
00071 Int_t fXclip;
00072 Int_t fYclip;
00073 UInt_t fWclip;
00074 UInt_t fHclip;
00075 ULong_t *fNewColors;
00076 Int_t fNcolors;
00077 Bool_t fShared;
00078 };
00079
00080 struct XColor_t {
00081 ULong_t fPixel;
00082 UShort_t fRed;
00083 UShort_t fGreen;
00084 UShort_t fBlue;
00085 Bool_t fDefined;
00086 XColor_t() { fPixel = 0; fRed = fGreen = fBlue = 0; fDefined = kFALSE; }
00087 };
00088
00089 class TExMap;
00090
00091
00092 class TGX11 : public TVirtualX {
00093
00094 private:
00095 Int_t fMaxNumberOfWindows;
00096 XWindow_t *fWindows;
00097 TExMap *fColors;
00098 Cursor fCursors[kNumCursors];
00099 XEvent *fXEvent;
00100
00101 void CloseWindow1();
00102 void ClearPixmap(Drawable *pix);
00103 void CopyWindowtoPixmap(Drawable *pix, Int_t xpos, Int_t ypos);
00104 void FindBestVisual();
00105 void FindUsableVisual(XVisualInfo *vlist, Int_t nitems);
00106 void PutImage(Int_t offset, Int_t itran, Int_t x0, Int_t y0, Int_t nx,
00107 Int_t ny, Int_t xmin, Int_t ymin, Int_t xmax, Int_t ymax,
00108 UChar_t *image, Drawable_t id);
00109 void RemovePixmap(Drawable *pix);
00110 void SetColor(GC gc, Int_t ci);
00111 void SetFillStyleIndex(Int_t style, Int_t fasi);
00112 void SetInput(Int_t inp);
00113 void SetMarkerType(Int_t type, Int_t n, XPoint *xy);
00114 void CollectImageColors(ULong_t pixel, ULong_t *&orgcolors, Int_t &ncolors,
00115 Int_t &maxcolors);
00116 void MakeOpaqueColors(Int_t percent, ULong_t *orgcolors, Int_t ncolors);
00117 Int_t FindColor(ULong_t pixel, ULong_t *orgcolors, Int_t ncolors);
00118 void ImgPickPalette(XImage *image, Int_t &ncol, Int_t *&R, Int_t *&G, Int_t *&B);
00119
00120
00121 void MapGCValues(GCValues_t &gval, ULong_t &xmask, XGCValues &xgval, Bool_t tox = kTRUE);
00122 void MapSetWindowAttributes(SetWindowAttributes_t *attr,
00123 ULong_t &xmask, XSetWindowAttributes &xattr);
00124 void MapCursor(ECursor cursor, Int_t &xcursor);
00125 void MapColorStruct(ColorStruct_t *color, XColor &xcolor);
00126 void MapPictureAttributes(PictureAttributes_t &attr, XpmAttributes &xpmattr,
00127 Bool_t toxpm = kTRUE);
00128 void MapModifierState(UInt_t &state, UInt_t &xstate, Bool_t tox = kTRUE);
00129 void MapEvent(Event_t &ev, XEvent &xev, Bool_t tox = kTRUE);
00130 void MapEventMask(UInt_t &emask, UInt_t &xemask, Bool_t tox = kTRUE);
00131 void MapKeySym(UInt_t &keysym, UInt_t &xkeysym, Bool_t tox = kTRUE);
00132
00133 protected:
00134 Display *fDisplay;
00135 Visual *fVisual;
00136 Drawable fRootWin;
00137 Drawable fVisRootWin;
00138 Colormap fColormap;
00139 ULong_t fBlackPixel;
00140 ULong_t fWhitePixel;
00141 Int_t fScreenNumber;
00142 Int_t fTextAlignH;
00143 Int_t fTextAlignV;
00144 Int_t fTextAlign;
00145 Float_t fCharacterUpX;
00146 Float_t fCharacterUpY;
00147 Float_t fTextMagnitude;
00148 Int_t fDepth;
00149 Int_t fRedDiv;
00150 Int_t fGreenDiv;
00151 Int_t fBlueDiv;
00152 Int_t fRedShift;
00153 Int_t fGreenShift;
00154 Int_t fBlueShift;
00155 Bool_t fHasTTFonts;
00156
00157
00158 Bool_t AllocColor(Colormap cmap, XColor *color);
00159 void QueryColors(Colormap cmap, XColor *colors, Int_t ncolors);
00160 GC *GetGC(Int_t which) const;
00161 XColor_t &GetColor(Int_t cid);
00162
00163 public:
00164 TGX11();
00165 TGX11(const TGX11 &org);
00166 TGX11(const char *name, const char *title);
00167 virtual ~TGX11();
00168
00169 Bool_t Init(void *display);
00170 void ClearWindow();
00171 void ClosePixmap();
00172 void CloseWindow();
00173 void CopyPixmap(Int_t wid, Int_t xpos, Int_t ypos);
00174 void DrawBox(Int_t x1, Int_t y1, Int_t x2, Int_t y2, EBoxMode mode);
00175 void DrawCellArray(Int_t x1, Int_t y1, Int_t x2, Int_t y2, Int_t nx, Int_t ny, Int_t *ic);
00176 void DrawFillArea(Int_t n, TPoint *xy);
00177 void DrawLine(Int_t x1, Int_t y1, Int_t x2, Int_t y2);
00178 void DrawPolyLine(Int_t n, TPoint *xy);
00179 void DrawPolyMarker(Int_t n, TPoint *xy);
00180 virtual void DrawText(Int_t x, Int_t y, Float_t angle, Float_t mgn, const char *text, ETextMode mode);
00181 void GetCharacterUp(Float_t &chupx, Float_t &chupy);
00182 Int_t GetDoubleBuffer(Int_t wid);
00183 void GetGeometry(Int_t wid, Int_t &x, Int_t &y, UInt_t &w, UInt_t &h);
00184 const char *DisplayName(const char *dpyName = 0);
00185 Handle_t GetNativeEvent() const { return (Handle_t) fXEvent; }
00186 ULong_t GetPixel(Color_t cindex);
00187 void GetPlanes(Int_t &nplanes);
00188 void GetRGB(Int_t index, Float_t &r, Float_t &g, Float_t &b);
00189 virtual void GetTextExtent(UInt_t &w, UInt_t &h, char *mess);
00190 Float_t GetTextMagnitude() { return fTextMagnitude; }
00191 Window_t GetWindowID(Int_t wid);
00192 Bool_t HasTTFonts() const { return fHasTTFonts; }
00193 Int_t InitWindow(ULong_t window);
00194 Int_t AddWindow(ULong_t qwid, UInt_t w, UInt_t h);
00195 Int_t AddPixmap(ULong_t pixid, UInt_t w, UInt_t h);
00196 void RemoveWindow(ULong_t qwid);
00197 void MoveWindow(Int_t wid, Int_t x, Int_t y);
00198 Int_t OpenDisplay(Display *display);
00199 Int_t OpenPixmap(UInt_t w, UInt_t h);
00200 void QueryPointer(Int_t &ix, Int_t &iy);
00201 Pixmap_t ReadGIF(Int_t x0, Int_t y0, const char *file, Window_t id=0);
00202 Int_t RequestLocator(Int_t mode, Int_t ctyp, Int_t &x, Int_t &y);
00203 Int_t RequestString(Int_t x, Int_t y, char *text);
00204 void RescaleWindow(Int_t wid, UInt_t w, UInt_t h);
00205 Int_t ResizePixmap(Int_t wid, UInt_t w, UInt_t h);
00206 void ResizeWindow(Int_t wid);
00207 void SelectWindow(Int_t wid);
00208 void SetCharacterUp(Float_t chupx, Float_t chupy);
00209 void SetClipOFF(Int_t wid);
00210 void SetClipRegion(Int_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h);
00211 void SetCursor(Int_t win, ECursor cursor);
00212 void SetDoubleBuffer(Int_t wid, Int_t mode);
00213 void SetDoubleBufferOFF();
00214 void SetDoubleBufferON();
00215 void SetDrawMode(EDrawMode mode);
00216 void SetFillColor(Color_t cindex);
00217 void SetFillStyle(Style_t style);
00218 void SetLineColor(Color_t cindex);
00219 void SetLineType(Int_t n, Int_t *dash);
00220 void SetLineStyle(Style_t linestyle);
00221 void SetLineWidth(Width_t width);
00222 void SetMarkerColor(Color_t cindex);
00223 void SetMarkerSize(Float_t markersize);
00224 void SetMarkerStyle(Style_t markerstyle);
00225 void SetOpacity(Int_t percent);
00226 void SetRGB(Int_t cindex, Float_t r, Float_t g, Float_t b);
00227 void SetTextAlign(Short_t talign=11);
00228 void SetTextColor(Color_t cindex);
00229 virtual Int_t SetTextFont(char *fontname, ETextSetMode mode);
00230 virtual void SetTextFont(Font_t fontnumber);
00231 void SetTextMagnitude(Float_t mgn=1) { fTextMagnitude = mgn;}
00232 virtual void SetTextSize(Float_t textsize);
00233 void Sync(Int_t mode);
00234 void UpdateWindow(Int_t mode);
00235 void Warp(Int_t ix, Int_t iy, Window_t id = 0);
00236 Int_t WriteGIF(char *name);
00237 void WritePixmap(Int_t wid, UInt_t w, UInt_t h, char *pxname);
00238 Window_t GetCurrentWindow() const;
00239 Int_t SupportsExtension(const char *ext) const;
00240
00241
00242 void GetWindowAttributes(Window_t id, WindowAttributes_t &attr);
00243 void MapWindow(Window_t id);
00244 void MapSubwindows(Window_t id);
00245 void MapRaised(Window_t id);
00246 void UnmapWindow(Window_t id);
00247 void DestroyWindow(Window_t id);
00248 void DestroySubwindows(Window_t id);
00249 void RaiseWindow(Window_t id);
00250 void LowerWindow(Window_t id);
00251 void MoveWindow(Window_t id, Int_t x, Int_t y);
00252 void MoveResizeWindow(Window_t id, Int_t x, Int_t y, UInt_t w, UInt_t h);
00253 void ResizeWindow(Window_t id, UInt_t w, UInt_t h);
00254 void IconifyWindow(Window_t id);
00255 void ReparentWindow(Window_t id, Window_t pid, Int_t x, Int_t y);
00256 void SetWindowBackground(Window_t id, ULong_t color);
00257 void SetWindowBackgroundPixmap(Window_t id, Pixmap_t pxm);
00258 Window_t CreateWindow(Window_t parent, Int_t x, Int_t y,
00259 UInt_t w, UInt_t h, UInt_t border,
00260 Int_t depth, UInt_t clss,
00261 void *visual, SetWindowAttributes_t *attr,
00262 UInt_t wtype);
00263 Int_t OpenDisplay(const char *dpyName);
00264 void CloseDisplay();
00265 Display_t GetDisplay() const;
00266 Visual_t GetVisual() const;
00267 Int_t GetScreen() const;
00268 Int_t GetDepth() const;
00269 Colormap_t GetColormap() const;
00270 Atom_t InternAtom(const char *atom_name, Bool_t only_if_exist);
00271 Window_t GetDefaultRootWindow() const;
00272 Window_t GetParent(Window_t id) const;
00273 FontStruct_t LoadQueryFont(const char *font_name);
00274 FontH_t GetFontHandle(FontStruct_t fs);
00275 void DeleteFont(FontStruct_t fs);
00276 GContext_t CreateGC(Drawable_t id, GCValues_t *gval);
00277 void ChangeGC(GContext_t gc, GCValues_t *gval);
00278 void CopyGC(GContext_t org, GContext_t dest, Mask_t mask);
00279 void DeleteGC(GContext_t gc);
00280 Cursor_t CreateCursor(ECursor cursor);
00281 void SetCursor(Window_t id, Cursor_t curid);
00282 Pixmap_t CreatePixmap(Drawable_t id, UInt_t w, UInt_t h);
00283 Pixmap_t CreatePixmap(Drawable_t id, const char *bitmap, UInt_t width,
00284 UInt_t height, ULong_t forecolor, ULong_t backcolor,
00285 Int_t depth);
00286 unsigned char *GetColorBits(Drawable_t wid, Int_t x = 0, Int_t y = 0, UInt_t w = 0, UInt_t h = 0);
00287 Pixmap_t CreatePixmapFromData(unsigned char *bits, UInt_t width, UInt_t height);
00288 Pixmap_t CreateBitmap(Drawable_t id, const char *bitmap,
00289 UInt_t width, UInt_t height);
00290 void DeletePixmap(Pixmap_t pmap);
00291 Bool_t CreatePictureFromFile(Drawable_t id, const char *filename,
00292 Pixmap_t &pict, Pixmap_t &pict_mask,
00293 PictureAttributes_t &attr);
00294 Bool_t CreatePictureFromData(Drawable_t id, char **data,
00295 Pixmap_t &pict, Pixmap_t &pict_mask,
00296 PictureAttributes_t &attr);
00297 Bool_t ReadPictureDataFromFile(const char *filename, char ***ret_data);
00298 void DeletePictureData(void *data);
00299 void SetDashes(GContext_t gc, Int_t offset, const char *dash_list, Int_t n);
00300 Bool_t ParseColor(Colormap_t cmap, const char *cname, ColorStruct_t &color);
00301 Bool_t AllocColor(Colormap_t cmap, ColorStruct_t &color);
00302 void QueryColor(Colormap_t cmap, ColorStruct_t &color);
00303 void FreeColor(Colormap_t cmap, ULong_t pixel);
00304 Int_t EventsPending();
00305 void NextEvent(Event_t &event);
00306 void Bell(Int_t percent);
00307 void CopyArea(Drawable_t src, Drawable_t dest, GContext_t gc,
00308 Int_t src_x, Int_t src_y, UInt_t width, UInt_t height,
00309 Int_t dest_x, Int_t dest_y);
00310 void ChangeWindowAttributes(Window_t id, SetWindowAttributes_t *attr);
00311 void ChangeProperty(Window_t id, Atom_t property, Atom_t type,
00312 UChar_t *data, Int_t len);
00313 void DrawLine(Drawable_t id, GContext_t gc, Int_t x1, Int_t y1, Int_t x2, Int_t y2);
00314 void ClearArea(Window_t id, Int_t x, Int_t y, UInt_t w, UInt_t h);
00315 Bool_t CheckEvent(Window_t id, EGEventType type, Event_t &ev);
00316 void SendEvent(Window_t id, Event_t *ev);
00317 void WMDeleteNotify(Window_t id);
00318 void SetKeyAutoRepeat(Bool_t on = kTRUE);
00319 void GrabKey(Window_t id, Int_t keycode, UInt_t modifier, Bool_t grab = kTRUE);
00320 void GrabButton(Window_t id, EMouseButton button, UInt_t modifier,
00321 UInt_t evmask, Window_t confine, Cursor_t cursor,
00322 Bool_t grab = kTRUE);
00323 void GrabPointer(Window_t id, UInt_t evmask, Window_t confine,
00324 Cursor_t cursor, Bool_t grab = kTRUE,
00325 Bool_t owner_events = kTRUE);
00326 void SetWindowName(Window_t id, char *name);
00327 void SetIconName(Window_t id, char *name);
00328 void SetIconPixmap(Window_t id, Pixmap_t pic);
00329 void SetClassHints(Window_t id, char *className, char *resourceName);
00330 void SetMWMHints(Window_t id, UInt_t value, UInt_t funcs, UInt_t input);
00331 void SetWMPosition(Window_t id, Int_t x, Int_t y);
00332 void SetWMSize(Window_t id, UInt_t w, UInt_t h);
00333 void SetWMSizeHints(Window_t id, UInt_t wmin, UInt_t hmin,
00334 UInt_t wmax, UInt_t hmax, UInt_t winc, UInt_t hinc);
00335 void SetWMState(Window_t id, EInitialState state);
00336 void SetWMTransientHint(Window_t id, Window_t main_id);
00337 void DrawString(Drawable_t id, GContext_t gc, Int_t x, Int_t y,
00338 const char *s, Int_t len);
00339 Int_t TextWidth(FontStruct_t font, const char *s, Int_t len);
00340 void GetFontProperties(FontStruct_t font, Int_t &max_ascent, Int_t &max_descent);
00341 void GetGCValues(GContext_t gc, GCValues_t &gval);
00342 FontStruct_t GetFontStruct(FontH_t fh);
00343 void FreeFontStruct(FontStruct_t fs);
00344 void ClearWindow(Window_t id);
00345 Int_t KeysymToKeycode(UInt_t keysym);
00346 void FillRectangle(Drawable_t id, GContext_t gc, Int_t x, Int_t y,
00347 UInt_t w, UInt_t h);
00348 void DrawRectangle(Drawable_t id, GContext_t gc, Int_t x, Int_t y,
00349 UInt_t w, UInt_t h);
00350 void DrawSegments(Drawable_t id, GContext_t gc, Segment_t *seg, Int_t nseg);
00351 void SelectInput(Window_t id, UInt_t evmask);
00352 Window_t GetInputFocus();
00353 void SetInputFocus(Window_t id);
00354 Window_t GetPrimarySelectionOwner();
00355 void SetPrimarySelectionOwner(Window_t id);
00356 void ConvertPrimarySelection(Window_t id, Atom_t clipboard, Time_t when);
00357 void LookupString(Event_t *event, char *buf, Int_t buflen, UInt_t &keysym);
00358 void GetPasteBuffer(Window_t id, Atom_t atom, TString &text,
00359 Int_t &nchar, Bool_t del);
00360 void TranslateCoordinates(Window_t src, Window_t dest, Int_t src_x,
00361 Int_t src_y, Int_t &dest_x, Int_t &dest_y, Window_t &child);
00362 void GetWindowSize(Drawable_t id, Int_t &x, Int_t &y, UInt_t &w, UInt_t &h);
00363 void FillPolygon(Window_t id, GContext_t gc, Point_t *points, Int_t npnt);
00364 void QueryPointer(Window_t id, Window_t &rootw, Window_t &childw,
00365 Int_t &root_x, Int_t &root_y, Int_t &win_x,
00366 Int_t &win_y, UInt_t &mask);
00367 void SetForeground(GContext_t gc, ULong_t foreground);
00368 void SetClipRectangles(GContext_t gc, Int_t x, Int_t y, Rectangle_t *recs, Int_t n);
00369 void Update(Int_t mode = 0);
00370 Region_t CreateRegion();
00371 void DestroyRegion(Region_t reg);
00372 void UnionRectWithRegion(Rectangle_t *rect, Region_t src, Region_t dest);
00373 Region_t PolygonRegion(Point_t *points, Int_t np, Bool_t winding);
00374 void UnionRegion(Region_t rega, Region_t regb, Region_t result);
00375 void IntersectRegion(Region_t rega, Region_t regb, Region_t result);
00376 void SubtractRegion(Region_t rega, Region_t regb, Region_t result);
00377 void XorRegion(Region_t rega, Region_t regb, Region_t result);
00378 Bool_t EmptyRegion(Region_t reg);
00379 Bool_t PointInRegion(Int_t x, Int_t y, Region_t reg);
00380 Bool_t EqualRegion(Region_t rega, Region_t regb);
00381 void GetRegionBox(Region_t reg, Rectangle_t *);
00382 char **ListFonts(const char *fontname, Int_t max, Int_t &count);
00383 void FreeFontNames(char **fontlist);
00384 Drawable_t CreateImage(UInt_t width, UInt_t height);
00385 void GetImageSize(Drawable_t id, UInt_t &width, UInt_t &height);
00386 void PutPixel(Drawable_t id, Int_t x, Int_t y, ULong_t pixel);
00387 void PutImage(Drawable_t id, GContext_t gc, Drawable_t img,
00388 Int_t dx, Int_t dy, Int_t x, Int_t y,
00389 UInt_t w, UInt_t h);
00390 void DeleteImage(Drawable_t img);
00391 void ShapeCombineMask(Window_t id, Int_t x, Int_t y, Pixmap_t mask);
00392 UInt_t ScreenWidthMM() const;
00393
00394 void DeleteProperty(Window_t, Atom_t&);
00395 Int_t GetProperty(Window_t, Atom_t, Long_t, Long_t, Bool_t, Atom_t,
00396 Atom_t*, Int_t*, ULong_t*, ULong_t*, unsigned char**);
00397 void ChangeActivePointerGrab(Window_t, UInt_t, Cursor_t);
00398 void ConvertSelection(Window_t, Atom_t&, Atom_t&, Atom_t&, Time_t&);
00399 Bool_t SetSelectionOwner(Window_t, Atom_t&);
00400 void ChangeProperties(Window_t id, Atom_t property, Atom_t type,
00401 Int_t format, UChar_t *data, Int_t len);
00402 void SetDNDAware(Window_t, Atom_t *);
00403 void SetTypeList(Window_t win, Atom_t prop, Atom_t *typelist);
00404 Window_t FindRWindow(Window_t win, Window_t dragwin, Window_t input, int x, int y, int maxd);
00405 Bool_t IsDNDAware(Window_t win, Atom_t *typelist);
00406
00407 ClassDef(TGX11,0)
00408 };
00409
00410 #endif