21 #if !defined(__CINT__)
25 #include "gdk/win32/gdkwin32.h"
29 typedef ULong_t LPCRITICAL_SECTION;
30 typedef unsigned long DWORD;
33 typedef unsigned long XID;
34 typedef XID GdkDrawable;
35 typedef XID GdkCursor;
36 typedef XID GdkColormap;
37 typedef XID GdkWindow;
38 typedef XID GdkVisual;
53 typedef unsigned long KeySym;
62 XColor_t() { color.pixel = 0; color.red = color.green = color.blue = 0; fDefined = kFALSE; }
67 class TGWin32 :
public TVirtualX {
70 enum EAlign { kNone, kTLeft, kTCenter, kTRight, kMLeft, kMCenter, kMRight,
71 kBLeft, kBCenter, kBRight };
76 void DrawImage(FT_Bitmap *source, ULong_t fore, ULong_t back, GdkImage *xim,
78 Bool_t IsVisible(Int_t x, Int_t y, UInt_t w, UInt_t h);
79 GdkImage *GetBackground(Int_t x, Int_t y, UInt_t w, UInt_t h);
80 void RenderString(Int_t x, Int_t y, ETextMode mode);
82 Int_t fMaxNumberOfWindows;
85 GdkCursor *fCursors[kNumCursors];
88 void PutImage(Int_t offset, Int_t itran, Int_t x0, Int_t y0, Int_t nx,
89 Int_t ny, Int_t xmin, Int_t ymin, Int_t xmax, Int_t ymax,
90 UChar_t *image, Drawable_t
id);
91 void RemovePixmap(GdkDrawable *pix);
92 void SetColor(GdkGC *gc, Int_t ci);
93 void SetInput(Int_t inp);
94 void SetMarkerType(Int_t type, Int_t n, GdkPoint *xy);
95 void MakeOpaqueColors(Int_t percent, ULong_t *orgcolors, Int_t ncolors);
96 Int_t FindColor(ULong_t pixel, ULong_t *orgcolors, Int_t ncolors);
97 void ImgPickPalette(GdkImage *image, Int_t &ncol, Int_t *&R, Int_t *&G, Int_t *&B);
100 void MapGCValues(GCValues_t &gval, ULong_t &xmask, GdkGCValues &xgval, Bool_t tox = kTRUE);
101 void MapSetWindowAttributes(SetWindowAttributes_t *attr,
102 ULong_t &xmask, GdkWindowAttr &xattr);
103 void MapCursor(ECursor cursor, Int_t &xcursor);
104 void MapColorStruct(ColorStruct_t *color, GdkColor &xcolor);
105 void MapModifierState(UInt_t &state, UInt_t &xstate, Bool_t tox = kTRUE);
106 void MapEvent(Event_t &ev, GdkEvent &xev, Bool_t tox = kTRUE);
107 void MapEventMask(UInt_t &emask, UInt_t &xemask, Bool_t tox = kTRUE);
108 void MapKeySym(UInt_t &keysym, UInt_t &xkeysym, Bool_t tox = kTRUE);
112 GdkColormap *fColormap;
115 Bool_t fUseSysPointers;
119 Float_t fCharacterUpX;
120 Float_t fCharacterUpY;
121 Float_t fTextMagnitude;
130 TObject* fRefreshTimer;
132 Bool_t fFillColorModified;
133 Bool_t fFillStyleModified;
134 Bool_t fLineColorModified;
136 Bool_t fMarkerStyleModified;
137 Bool_t fMarkerColorModified;
139 void UpdateFillColor();
140 void UpdateFillStyle();
141 void UpdateLineColor();
142 void UpdateMarkerStyle();
143 void UpdateMarkerColor();
144 void UpdateLineStyle();
147 Bool_t AllocColor(GdkColormap *cmap, GdkColor *color);
148 void QueryColors(GdkColormap *cmap, GdkColor *colors, Int_t ncolors);
149 GdkGC *GetGC(Int_t which)
const;
150 XColor_t &GetColor(Int_t cid);
154 TGWin32(
const char *name,
const char *title);
157 void DrawText(Int_t x, Int_t y, Float_t angle, Float_t mgn,
158 const char *text, ETextMode mode);
159 void DrawText(Int_t x, Int_t y, Float_t angle, Float_t mgn,
160 const wchar_t *text, ETextMode mode);
161 void SetTextFont(Font_t fontnumber);
162 Int_t SetTextFont(
char *fontname, ETextSetMode mode);
163 void SetTextSize(Float_t textsize);
165 Bool_t Init(
void *display=0);
170 void CopyPixmap(Int_t wid, Int_t xpos, Int_t ypos);
171 void DrawBox(Int_t x1, Int_t y1, Int_t x2, Int_t y2, EBoxMode mode);
172 void DrawCellArray(Int_t x1, Int_t y1, Int_t x2, Int_t y2, Int_t nx, Int_t ny, Int_t *ic);
173 void DrawFillArea(Int_t n, TPoint *xy);
174 void DrawLine(Int_t x1, Int_t y1, Int_t x2, Int_t y2);
175 void DrawPolyLine(Int_t n, TPoint *xy);
176 void DrawPolyMarker(Int_t n, TPoint *xy);
177 void GetCharacterUp(Float_t &chupx, Float_t &chupy);
178 Int_t GetDoubleBuffer(Int_t wid);
179 void GetGeometry(Int_t wid, Int_t &x, Int_t &y, UInt_t &w, UInt_t &h);
180 const char *DisplayName(
const char *dpyName = 0);
181 ULong_t GetPixel(Color_t cindex);
182 void GetPlanes(Int_t &nplanes);
183 void GetRGB(Int_t index, Float_t &r, Float_t &g, Float_t &b);
184 virtual void GetTextExtent(UInt_t &w, UInt_t &h,
char *mess);
185 virtual void GetTextExtent(UInt_t &, UInt_t &,
wchar_t *){}
186 Float_t GetTextMagnitude() {
return fTextMagnitude;}
187 Window_t GetWindowID(Int_t wid);
188 Bool_t HasTTFonts()
const {
return fHasTTFonts; }
189 Int_t InitWindow(ULong_t window);
190 Int_t AddPixmap(ULong_t pix, UInt_t w, UInt_t h);
191 void MoveWindow(Int_t wid, Int_t x, Int_t y);
192 Int_t OpenPixmap(UInt_t w, UInt_t h);
193 void QueryPointer(Int_t &ix, Int_t &iy);
194 Pixmap_t ReadGIF(Int_t x0, Int_t y0,
const char *file, Window_t
id=0);
195 Int_t RequestLocator(Int_t mode, Int_t ctyp, Int_t &x, Int_t &y);
196 Int_t RequestString(Int_t x, Int_t y,
char *text);
197 void RescaleWindow(Int_t wid, UInt_t w, UInt_t h);
198 Int_t ResizePixmap(Int_t wid, UInt_t w, UInt_t h);
199 void ResizeWindow(Int_t wid);
200 void SelectWindow(Int_t wid);
201 void SetCharacterUp(Float_t chupx, Float_t chupy);
202 void SetClipOFF(Int_t wid);
203 void SetClipRegion(Int_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h);
204 void SetCursor(Int_t win, ECursor cursor);
205 void SetDoubleBuffer(Int_t wid, Int_t mode);
206 void SetDoubleBufferOFF();
207 void SetDoubleBufferON();
208 void SetDrawMode(EDrawMode mode);
209 void SetFillColor(Color_t cindex);
210 void SetFillStyle(Style_t style);
211 void SetLineColor(Color_t cindex);
212 void SetLineType(Int_t n, Int_t *dash);
213 void SetLineStyle(Style_t linestyle);
214 void SetLineWidth(Width_t width);
215 void SetMarkerColor(Color_t cindex);
216 void SetMarkerSize(Float_t markersize);
217 void SetMarkerStyle(Style_t markerstyle);
218 void SetOpacity(Int_t percent);
219 void SetRGB(Int_t cindex, Float_t r, Float_t g, Float_t b);
220 void SetTextAlign(Short_t talign=11);
221 void SetTextColor(Color_t cindex);
222 void SetTextMagnitude(Float_t mgn=1) { fTextMagnitude = mgn;}
223 void Sync(Int_t mode);
224 void UpdateWindow(Int_t mode);
225 void Warp(Int_t ix, Int_t iy, Window_t
id = 0);
226 Int_t WriteGIF(
char *name);
227 void WritePixmap(Int_t wid, UInt_t w, UInt_t h,
char *pxname);
228 Window_t GetCurrentWindow()
const;
231 void GetWindowAttributes(Window_t
id, WindowAttributes_t &attr);
232 void MapWindow(Window_t
id);
233 void MapSubwindows(Window_t
id);
234 void MapRaised(Window_t
id);
235 void UnmapWindow(Window_t
id);
236 void DestroyWindow(Window_t
id);
237 void DestroySubwindows(Window_t
id);
238 void RaiseWindow(Window_t
id);
239 void LowerWindow(Window_t
id);
240 void MoveWindow(Window_t
id, Int_t x, Int_t y);
241 void MoveResizeWindow(Window_t
id, Int_t x, Int_t y, UInt_t w, UInt_t h);
242 void ResizeWindow(Window_t
id, UInt_t w, UInt_t h);
243 void IconifyWindow(Window_t
id);
244 void ReparentWindow(Window_t
id, Window_t pid, Int_t x, Int_t y);
245 void SetWindowBackground(Window_t
id, ULong_t color);
246 void SetWindowBackgroundPixmap(Window_t
id, Pixmap_t pxm);
247 Window_t CreateWindow(Window_t parent, Int_t x, Int_t y,
248 UInt_t w, UInt_t h, UInt_t border,
249 Int_t depth, UInt_t clss,
250 void *visual, SetWindowAttributes_t *attr,
252 Int_t OpenDisplay(
const char *dpyName=0);
254 Display_t GetDisplay()
const;
255 Visual_t GetVisual()
const {
return 0; }
256 Int_t GetScreen()
const {
return 0; }
257 Int_t GetDepth()
const;
258 Colormap_t GetColormap()
const {
return (Colormap_t) fColormap; }
259 Atom_t InternAtom(
const char *atom_name, Bool_t only_if_exist);
260 Window_t GetDefaultRootWindow()
const;
261 Window_t GetParent(Window_t
id)
const;
262 FontStruct_t LoadQueryFont(
const char *font_name);
263 FontH_t GetFontHandle(FontStruct_t fs);
264 void DeleteFont(FontStruct_t fs);
265 GContext_t CreateGC(Drawable_t
id, GCValues_t *gval);
266 void ChangeGC(GContext_t gc, GCValues_t *gval);
267 void CopyGC(GContext_t org, GContext_t dest, Mask_t mask);
268 void DeleteGC(GContext_t gc);
269 Cursor_t CreateCursor(ECursor cursor);
270 void SetCursor(Window_t
id, Cursor_t curid);
271 Pixmap_t CreatePixmap(Drawable_t
id, UInt_t w, UInt_t h);
272 Pixmap_t CreatePixmap(Drawable_t
id,
const char *bitmap, UInt_t width,
273 UInt_t height, ULong_t forecolor, ULong_t backcolor,
275 Pixmap_t CreatePixmapFromData(
unsigned char *bits, UInt_t width, UInt_t height);
276 Pixmap_t CreateBitmap(Drawable_t
id,
const char *bitmap,
277 UInt_t width, UInt_t height);
278 void DeletePixmap(Pixmap_t pmap);
279 Bool_t CreatePictureFromFile(Drawable_t
id,
const char *filename,
280 Pixmap_t &pict, Pixmap_t &pict_mask,
281 PictureAttributes_t &attr);
282 Bool_t CreatePictureFromData(Drawable_t
id,
char **data,
283 Pixmap_t &pict, Pixmap_t &pict_mask,
284 PictureAttributes_t &attr);
285 Bool_t ReadPictureDataFromFile(
const char *filename,
char ***ret_data);
286 void DeletePictureData(
void *data);
287 void SetDashes(GContext_t gc, Int_t offset,
const char *dash_list, Int_t n);
288 Bool_t ParseColor(Colormap_t cmap,
const char *cname, ColorStruct_t &color);
289 Bool_t AllocColor(Colormap_t cmap, ColorStruct_t &color);
290 void QueryColor(Colormap_t cmap, ColorStruct_t &color);
291 void FreeColor(Colormap_t cmap, ULong_t pixel);
292 Int_t EventsPending();
293 void NextEvent(Event_t &event);
294 void Bell(Int_t percent);
295 void CopyArea(Drawable_t src, Drawable_t dest, GContext_t gc,
296 Int_t src_x, Int_t src_y, UInt_t width, UInt_t height,
297 Int_t dest_x, Int_t dest_y);
298 void ChangeWindowAttributes(Window_t
id, SetWindowAttributes_t *attr);
299 void ChangeProperty(Window_t
id, Atom_t property, Atom_t type,
300 UChar_t *data, Int_t len);
301 void DrawLine(Drawable_t
id, GContext_t gc, Int_t x1, Int_t y1, Int_t x2, Int_t y2);
302 void ClearArea(Window_t
id, Int_t x, Int_t y, UInt_t w, UInt_t h);
303 Bool_t CheckEvent(Window_t
id, EGEventType type, Event_t &ev);
304 void SendEvent(Window_t
id, Event_t *ev);
305 void WMDeleteNotify(Window_t
id);
306 void SetKeyAutoRepeat(Bool_t on = kTRUE);
307 void GrabKey(Window_t
id, Int_t keycode, UInt_t modifier, Bool_t grab = kTRUE);
308 void GrabButton(Window_t
id, EMouseButton button, UInt_t modifier,
309 UInt_t evmask, Window_t confine, Cursor_t cursor,
310 Bool_t grab = kTRUE);
311 void GrabPointer(Window_t
id, UInt_t evmask, Window_t confine,
312 Cursor_t cursor, Bool_t grab = kTRUE,
313 Bool_t owner_events = kTRUE);
314 void SetWindowName(Window_t
id,
char *name);
315 void SetIconName(Window_t
id,
char *name);
316 void SetIconPixmap(Window_t
id, Pixmap_t pic);
317 void SetClassHints(Window_t
id,
char *className,
char *resourceName);
318 void SetMWMHints(Window_t
id, UInt_t value, UInt_t funcs, UInt_t input);
319 void SetWMPosition(Window_t
id, Int_t x, Int_t y);
320 void SetWMSize(Window_t
id, UInt_t w, UInt_t h);
321 void SetWMSizeHints(Window_t
id, UInt_t wmin, UInt_t hmin,
322 UInt_t wmax, UInt_t hmax, UInt_t winc, UInt_t hinc);
323 void SetWMState(Window_t
id, EInitialState state);
324 void SetWMTransientHint(Window_t
id, Window_t main_id);
325 void DrawString(Drawable_t
id, GContext_t gc, Int_t x, Int_t y,
326 const char *s, Int_t len);
327 Int_t TextWidth(FontStruct_t font,
const char *s, Int_t len);
328 void GetFontProperties(FontStruct_t font, Int_t &max_ascent, Int_t &max_descent);
329 void GetGCValues(GContext_t gc, GCValues_t &gval);
330 FontStruct_t GetFontStruct(FontH_t fh);
331 void FreeFontStruct(FontStruct_t fs);
332 void ClearWindow(Window_t
id);
333 Int_t KeysymToKeycode(UInt_t keysym);
334 void FillRectangle(Drawable_t
id, GContext_t gc, Int_t x, Int_t y,
336 void DrawRectangle(Drawable_t
id, GContext_t gc, Int_t x, Int_t y,
338 void DrawSegments(Drawable_t
id, GContext_t gc, Segment_t *seg, Int_t nseg);
339 void SelectInput(Window_t
id, UInt_t evmask);
340 Window_t GetInputFocus();
341 void SetInputFocus(Window_t
id);
342 Window_t GetPrimarySelectionOwner();
343 void SetPrimarySelectionOwner(Window_t
id);
344 void ConvertPrimarySelection(Window_t
id, Atom_t clipboard, Time_t when);
345 void LookupString(Event_t *event,
char *buf, Int_t buflen, UInt_t &keysym);
346 void GetPasteBuffer(Window_t
id, Atom_t atom, TString &text,
347 Int_t &nchar, Bool_t del);
348 void TranslateCoordinates(Window_t src, Window_t dest, Int_t src_x,
349 Int_t src_y, Int_t &dest_x, Int_t &dest_y, Window_t &child);
350 void GetWindowSize(Drawable_t
id, Int_t &x, Int_t &y, UInt_t &w, UInt_t &h);
351 void FillPolygon(Window_t
id, GContext_t gc, Point_t *points, Int_t npnt);
352 void QueryPointer(Window_t
id, Window_t &rootw, Window_t &childw,
353 Int_t &root_x, Int_t &root_y, Int_t &win_x,
354 Int_t &win_y, UInt_t &mask);
355 void SetForeground(GContext_t gc, ULong_t foreground);
356 void SetClipRectangles(GContext_t gc, Int_t x, Int_t y, Rectangle_t *recs, Int_t n);
357 void Update(Int_t mode = 0);
358 Region_t CreateRegion();
359 void DestroyRegion(Region_t reg);
360 void UnionRectWithRegion(Rectangle_t *rect, Region_t src, Region_t dest);
361 Region_t PolygonRegion(Point_t *points, Int_t np, Bool_t winding);
362 void UnionRegion(Region_t rega, Region_t regb, Region_t result);
363 void IntersectRegion(Region_t rega, Region_t regb, Region_t result);
364 void SubtractRegion(Region_t rega, Region_t regb, Region_t result);
365 void XorRegion(Region_t rega, Region_t regb, Region_t result);
366 Bool_t EmptyRegion(Region_t reg);
367 Bool_t PointInRegion(Int_t x, Int_t y, Region_t reg);
368 Bool_t EqualRegion(Region_t rega, Region_t regb);
369 void GetRegionBox(Region_t reg, Rectangle_t *);
370 char **ListFonts(
const char *fontname, Int_t max, Int_t &count);
371 void FreeFontNames(
char **fontlist);
372 Drawable_t CreateImage(UInt_t width, UInt_t height);
373 void GetImageSize(Drawable_t
id, UInt_t &width, UInt_t &height);
374 void PutPixel(Drawable_t
id, Int_t x, Int_t y, ULong_t pixel);
375 void PutImage(Drawable_t
id, GContext_t gc, Drawable_t img,
376 Int_t dx, Int_t dy, Int_t x, Int_t y,
378 void DeleteImage(Drawable_t img);
379 unsigned char *GetColorBits(Drawable_t wid, Int_t x, Int_t y, UInt_t width, UInt_t height);
380 Int_t AddWindow(ULong_t qwid, UInt_t w, UInt_t h);
381 void RemoveWindow(ULong_t qwid);
382 void ShapeCombineMask(Window_t
id, Int_t x, Int_t y, Pixmap_t mask);
383 UInt_t ScreenWidthMM()
const;
385 void DeleteProperty(Window_t, Atom_t&);
386 Int_t GetProperty(Window_t, Atom_t, Long_t, Long_t, Bool_t, Atom_t,
387 Atom_t*, Int_t*, ULong_t*, ULong_t*,
unsigned char**);
388 void ChangeActivePointerGrab(Window_t, UInt_t, Cursor_t);
389 void ConvertSelection(Window_t, Atom_t&, Atom_t&, Atom_t&, Time_t&);
390 Bool_t SetSelectionOwner(Window_t, Atom_t&);
391 void ChangeProperties(Window_t
id, Atom_t property, Atom_t type,
392 Int_t format, UChar_t *data, Int_t len);
393 void SetDNDAware(Window_t win, Atom_t *typelist);
394 void SetTypeList(Window_t win, Atom_t prop, Atom_t *typelist);
395 Window_t FindRWindow(Window_t win, Window_t dragwin, Window_t input,
int x,
int y,
int maxd);
396 Bool_t IsDNDAware(Window_t win, Atom_t *typelist);
398 Bool_t GUIThreadMessageFunc(MSG* msg);
399 Bool_t IsCmdThread()
const;
400 void SetUserThreadId(ULong_t
id);
403 static void Unlock();