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