Logo ROOT   6.16/01
Reference Guide
TGWin32.cxx
Go to the documentation of this file.
1// @(#)root/win32gdk:$Id$
2// Author: Rene Brun, Olivier Couet, Fons Rademakers, Valeri Onuchin, Bertrand Bellenot 27/11/01
3
4/*************************************************************************
5 * Copyright (C) 1995-2001, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/// \defgroup win32 Win32 backend
13/// \brief Interface to Windows graphics.
14/// \ingroup GraphicsBackends
15
16/** \class TGWin32
17\ingroup win32
18This class is the basic interface to the Win32 graphics system.
19It is an implementation of the abstract TVirtualX class.
20
21This code was initially developed in the context of HIGZ and PAW
22by Olivier Couet (package X11INT).
23*/
24
25#include <ft2build.h>
26#include FT_FREETYPE_H
27#include FT_GLYPH_H
28#include "TGWin32.h"
29#include <stdio.h>
30#include <string.h>
31#include <stdlib.h>
32#include <ctype.h>
33#include <limits.h>
34#include <process.h>
35#include <wchar.h>
36#include "gdk/gdkkeysyms.h"
37#include "xatom.h"
38#include <winuser.h>
39
40#include "TROOT.h"
41#include "TApplication.h"
42#include "TColor.h"
43#include "TPoint.h"
44#include "TMath.h"
45#include "TStorage.h"
46#include "TStyle.h"
47#include "TSystem.h"
48#include "TGFrame.h"
49#include "TError.h"
50#include "TException.h"
51#include "TClassTable.h"
52#include "KeySymbols.h"
53#include "TWinNTSystem.h"
56#include "TWin32SplashThread.h"
57#include "TString.h"
58#include "TObjString.h"
59#include "TObjArray.h"
60#include "TExMap.h"
61#include "TEnv.h"
62#include "RStipples.h"
63#include "TEnv.h"
64
65// DND protocol version
66#define XDND_PROTOCOL_VERSION 5
67#ifndef IDC_HAND
68#define IDC_HAND MAKEINTRESOURCE(32649)
69#endif
70
71extern "C" {
72void gdk_win32_draw_rectangle (GdkDrawable *drawable,
73 GdkGC *gc,
74 gint filled,
75 gint x,
76 gint y,
77 gint width,
78 gint height);
79void gdk_win32_draw_arc (GdkDrawable *drawable,
80 GdkGC *gc,
81 gint filled,
82 gint x,
83 gint y,
84 gint width,
85 gint height,
86 gint angle1,
87 gint angle2);
88void gdk_win32_draw_polygon (GdkDrawable *drawable,
89 GdkGC *gc,
90 gint filled,
91 GdkPoint *points,
92 gint npoints);
93void gdk_win32_draw_text (GdkDrawable *drawable,
94 GdkFont *font,
95 GdkGC *gc,
96 gint x,
97 gint y,
98 const gchar *text,
99 gint text_length);
100void gdk_win32_draw_points (GdkDrawable *drawable,
101 GdkGC *gc,
102 GdkPoint *points,
103 gint npoints);
104void gdk_win32_draw_segments (GdkDrawable *drawable,
105 GdkGC *gc,
106 GdkSegment *segs,
107 gint nsegs);
108void gdk_win32_draw_lines (GdkDrawable *drawable,
109 GdkGC *gc,
110 GdkPoint *points,
111 gint npoints);
112
113};
114
115//////////// internal classes & structures (very private) ////////////////
116
117struct XWindow_t {
118 Int_t open; // 1 if the window is open, 0 if not
119 Int_t double_buffer; // 1 if the double buffer is on, 0 if not
120 Int_t ispixmap; // 1 if pixmap, 0 if not
121 GdkDrawable *drawing; // drawing area, equal to window or buffer
122 GdkDrawable *window; // win32 window
123 GdkDrawable *buffer; // pixmap used for double buffer
124 UInt_t width; // width of the window
125 UInt_t height; // height of the window
126 Int_t clip; // 1 if the clipping is on
127 Int_t xclip; // x coordinate of the clipping rectangle
128 Int_t yclip; // y coordinate of the clipping rectangle
129 UInt_t wclip; // width of the clipping rectangle
130 UInt_t hclip; // height of the clipping rectangle
131 ULong_t *new_colors; // new image colors (after processing)
132 Int_t ncolors; // number of different colors
133};
134
135
136/////////////////////////////////// globals //////////////////////////////////
138
139namespace {
140/////////////////////////////////// globals //////////////////////////////////
141
142GdkAtom gClipboardAtom = GDK_NONE;
143static XWindow_t *gCws; // gCws: pointer to the current window
144static XWindow_t *gTws; // gTws: temporary pointer
145
146//
147// gColors[0] : background also used for b/w screen
148// gColors[1] : foreground also used for b/w screen
149// gColors[2..kMAXCOL-1]: colors which can be set by SetColor
150//
151const Int_t kBIGGEST_RGB_VALUE = 65535;
152//const Int_t kMAXCOL = 1000;
153//static struct {
154// Int_t defined;
155// GdkColor color;
156//} gColors[kMAXCOL];
157
158//
159// Primitives Graphic Contexts global for all windows
160//
161const int kMAXGC = 7;
162static GdkGC *gGClist[kMAXGC];
163static GdkGC *gGCline; // = gGClist[0]; // PolyLines
164static GdkGC *gGCmark; // = gGClist[1]; // PolyMarker
165static GdkGC *gGCfill; // = gGClist[2]; // Fill areas
166static GdkGC *gGCtext; // = gGClist[3]; // Text
167static GdkGC *gGCinvt; // = gGClist[4]; // Inverse text
168static GdkGC *gGCdash; // = gGClist[5]; // Dashed lines
169static GdkGC *gGCpxmp; // = gGClist[6]; // Pixmap management
170
171static GdkGC *gGCecho; // Input echo
172
173static Int_t gFillHollow; // Flag if fill style is hollow
174static GdkPixmap *gFillPattern; // Fill pattern
175
176//
177// Text management
178//
179static char *gTextFont = "arial.ttf"; // Current font
180
181//
182// Markers
183//
184const Int_t kMAXMK = 100;
185static struct {
186 int type;
187 int n;
188 GdkPoint xy[kMAXMK];
189} gMarker; // Point list to draw marker
190
191//
192// Keep style values for line GdkGC
193//
194static int gLineWidth = 0;
195static int gLineStyle = GDK_LINE_SOLID;
196static int gCapStyle = GDK_CAP_BUTT;
197static int gJoinStyle = GDK_JOIN_MITER;
198static char gDashList[10];
199static int gDashLength = 0;
200static int gDashOffset = 0;
201static int gDashSize = 0;
202
203//
204// Event masks
205//
206static ULong_t gMouseMask =
207 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK
208 | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK
209 | GDK_KEY_RELEASE_MASK;
210static ULong_t gKeybdMask =
211 GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK |
212 GDK_LEAVE_NOTIFY_MASK;
213
214//
215// Data to create an invisible cursor
216//
217const char null_cursor_bits[] = {
218 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
219 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
220 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
221};
222static GdkCursor *gNullCursor;
223
224static bool gdk_initialized = false;
225
226//---- MWM Hints stuff
227
228struct MWMHintsProperty_t {
229 Handle_t fFlags;
230 Handle_t fFunctions;
231 Handle_t fDecorations;
232 Int_t fInputMode;
233};
234
235//---- hints
236
240
243
244
245//---- Key symbol mapping
246
247struct KeySymbolMap_t {
248 KeySym fXKeySym;
249 EKeySym fKeySym;
250};
251
252static char *keyCodeToString[] = {
253 "", /* 0x000 */
254 "", /* 0x001, VK_LBUTTON */
255 "", /* 0x002, VK_RBUTTON */
256 "", /* 0x003, VK_CANCEL */
257 "", /* 0x004, VK_MBUTTON */
258 "", /* 0x005 */
259 "", /* 0x006 */
260 "", /* 0x007 */
261 "\015", /* 0x008, VK_BACK */
262 "\t", /* 0x009, VK_TAB */
263 "", /* 0x00A */
264 "", /* 0x00B */
265 "", /* 0x00C, VK_CLEAR */
266 "\r", /* 0x00D, VK_RETURN */
267 "", /* 0x00E */
268 "", /* 0x00F */
269 "", /* 0x010, VK_SHIFT */
270 "", /* 0x011, VK_CONTROL */
271 "", /* 0x012, VK_MENU */
272 "", /* 0x013, VK_PAUSE */
273 "", /* 0x014, VK_CAPITAL */
274 "", /* 0x015, VK_KANA */
275 "", /* 0x016 */
276 "", /* 0x017 */
277 "", /* 0x018 */
278 "", /* 0x019, VK_KANJI */
279 "", /* 0x01A */
280 "", /* 0x01B, VK_ESCAPE */
281 "", /* 0x01C, VK_CONVERT */
282 "", /* 0x01D, VK_NONCONVERT */
283 "", /* 0x01E */
284 "", /* 0x01F */
285 " ", /* 0x020, VK_SPACE */
286 "", /* 0x021, VK_PRIOR */
287 "", /* 0x022, VK_NEXT */
288 "", /* 0x023, VK_END */
289 "", /* 0x024, VK_HOME */
290 "", /* 0x025, VK_LEFT */
291 "", /* 0x026, VK_UP */
292 "", /* 0x027, VK_RIGHT */
293 "", /* 0x028, VK_DOWN */
294 "", /* 0x029, VK_SELECT */
295 "", /* 0x02A, VK_PRINT */
296 "", /* 0x02B, VK_EXECUTE */
297 "", /* 0x02C, VK_SNAPSHOT */
298 "", /* 0x02D, VK_INSERT */
299 "\037", /* 0x02E, VK_DELETE */
300 "", /* 0x02F, VK_HELP */
301};
302
303//---- Mapping table of all non-trivial mappings (the ASCII keys map
304//---- one to one so are not included)
305
306static KeySymbolMap_t gKeyMap[] = {
307 {GDK_Escape, kKey_Escape},
308 {GDK_Tab, kKey_Tab},
309#ifndef GDK_ISO_Left_Tab
310 {0xFE20, kKey_Backtab},
311#else
312 {GDK_ISO_Left_Tab, kKey_Backtab},
313#endif
314 {GDK_BackSpace, kKey_Backspace},
315 {GDK_Return, kKey_Return},
316 {GDK_Insert, kKey_Insert},
317 {GDK_Delete, kKey_Delete},
318 {GDK_Clear, kKey_Delete},
319 {GDK_Pause, kKey_Pause},
320 {GDK_Print, kKey_Print},
321 {0x1005FF60, kKey_SysReq}, // hardcoded Sun SysReq
322 {0x1007ff00, kKey_SysReq}, // hardcoded X386 SysReq
323 {GDK_Home, kKey_Home}, // cursor movement
324 {GDK_End, kKey_End},
325 {GDK_Left, kKey_Left},
326 {GDK_Up, kKey_Up},
327 {GDK_Right, kKey_Right},
328 {GDK_Down, kKey_Down},
329 {GDK_Prior, kKey_Prior},
330 {GDK_Next, kKey_Next},
331 {GDK_Shift_L, kKey_Shift}, // modifiers
332 {GDK_Shift_R, kKey_Shift},
333 {GDK_Shift_Lock, kKey_Shift},
334 {GDK_Control_L, kKey_Control},
335 {GDK_Control_R, kKey_Control},
336 {GDK_Meta_L, kKey_Meta},
337 {GDK_Meta_R, kKey_Meta},
338 {GDK_Alt_L, kKey_Alt},
339 {GDK_Alt_R, kKey_Alt},
340 {GDK_Caps_Lock, kKey_CapsLock},
341 {GDK_Num_Lock, kKey_NumLock},
342 {GDK_Scroll_Lock, kKey_ScrollLock},
343 {GDK_KP_Space, kKey_Space}, // numeric keypad
344 {GDK_KP_Tab, kKey_Tab},
345 {GDK_KP_Enter, kKey_Enter},
346 {GDK_KP_Equal, kKey_Equal},
347 {GDK_KP_Multiply, kKey_Asterisk},
348 {GDK_KP_Add, kKey_Plus},
349 {GDK_KP_Separator, kKey_Comma},
350 {GDK_KP_Subtract, kKey_Minus},
351 {GDK_KP_Decimal, kKey_Period},
352 {GDK_KP_Divide, kKey_Slash},
353 {0, (EKeySym) 0}
354};
355
356
357/////////////////////static auxilary functions /////////////////////////////////
358////////////////////////////////////////////////////////////////////////////////
359
360static Int_t _lookup_string(Event_t * event, char *buf, Int_t buflen)
361{
362 int i;
363 int n = event->fUser[1];
364 if (n > 0) {
365 for (i = 0; i < n; i++) {
366 buf[i] = event->fUser[2 + i];
367 }
368 buf[n] = 0;
369 } else {
370 buf[0] = 0;
371 }
372 if (event->fCode <= 0x20) {
373 strncpy(buf, keyCodeToString[event->fCode], buflen - 1);
374 }
375 return n;
376}
377
378////////////////////////////////////////////////////////////////////////////////
379
380inline void SplitLong(Long_t ll, Long_t & i1, Long_t & i2)
381{
382 union {
383 Long_t l;
384 Int_t i[2];
385 } conv;
386
387 conv.l = 0L;
388 conv.i[0] = 0;
389 conv.i[1] = 0;
390
391 conv.l = ll;
392 i1 = conv.i[0];
393 i2 = conv.i[1];
394}
395
396////////////////////////////////////////////////////////////////////////////////
397
398inline void AsmLong(Long_t i1, Long_t i2, Long_t & ll)
399{
400 union {
401 Long_t l;
402 Int_t i[2];
403 } conv;
404
405 conv.i[0] = (Int_t) i1;
406 conv.i[1] = (Int_t) i2;
407 ll = conv.l;
408}
409
410////////////////////////////////////////////////////////////////////////////////
411/// Make sure the child window is visible.
412
413static BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam)
414{
415 ::ShowWindow(hwndChild, SW_SHOWNORMAL);
416 GdkWindow *child = gdk_window_lookup(hwndChild);
417 if (child)
418 ((GdkWindowPrivate *) child)->mapped = TRUE;
419 return TRUE;
420}
421
422////////////////////////////////////////////////////////////////////////////////
423
424static void _ChangeProperty(HWND w, char *np, char *dp, int n, Atom_t type)
425{
426 HGLOBAL hMem;
427 char *p;
428
429 hMem = ::GetProp(w, np);
430 if (hMem != NULL) {
431 ::GlobalFree(hMem);
432 }
433 hMem = ::GlobalAlloc(GHND, n + sizeof(Atom_t));
434 p = (char *) ::GlobalLock(hMem);
435 memcpy(p, &type, sizeof(Atom_t));
436 memcpy(p + sizeof(Atom_t), dp, n);
437 ::GlobalUnlock(hMem);
438 ::SetProp(w, np, hMem);
439 ::GlobalFree(hMem);
440}
441
442////////////////////////////////////////////////////////////////////////////////
443///
444
445static void W32ChangeProperty(HWND w, Atom_t property, Atom_t type,
446 int format, int mode, const unsigned char *data,
447 int nelements)
448{
449 char *atomName;
450 char buffer[256];
451 int len;
452 char propName[32];
453
454 if (mode == GDK_PROP_MODE_REPLACE || mode == GDK_PROP_MODE_PREPEND) {
455 len = (int) ::GlobalGetAtomName(property, buffer, sizeof(buffer));
456 if ((atomName = (char *) malloc(len + 1)) == NULL) {
457 return;
458 } else {
459 strcpy(atomName, buffer);
460 }
461 sprintf(propName, "#0x%0.4x", atomName);
462 _ChangeProperty(w, propName, (char *) data, nelements, type);
463 free(atomName);
464 }
465}
466
467////////////////////////////////////////////////////////////////////////////////
468///
469
470static int _GetWindowProperty(GdkWindow * id, Atom_t property, Long_t long_offset,
471 Long_t long_length, Bool_t delete_it, Atom_t req_type,
472 Atom_t * actual_type_return,
473 Int_t * actual_format_return, ULong_t * nitems_return,
474 ULong_t * bytes_after_return, UChar_t ** prop_return)
475{
476 if (!id) return 0;
477
478 char *data, *destPtr;
479 char propName[32];
480 HGLOBAL handle;
481 HWND w;
482
483 w = (HWND) GDK_DRAWABLE_XID(id);
484
485 if (::IsClipboardFormatAvailable(CF_TEXT) && ::OpenClipboard(NULL)) {
486 handle = ::GetClipboardData(CF_TEXT);
487 if (handle != NULL) {
488 data = (char *) ::GlobalLock(handle);
489 *nitems_return = strlen(data);
490 *prop_return = (UChar_t *) malloc(*nitems_return + 1);
491 destPtr = (char *) *prop_return;
492 while (*data != '\0') {
493 if (*data != '\r') {
494 *destPtr = *data;
495 destPtr++;
496 }
497 data++;
498 }
499 *destPtr = '\0';
500 ::GlobalUnlock(handle);
501 *actual_type_return = XA_STRING;
502 *bytes_after_return = 0;
503 }
504 ::CloseClipboard();
505 return 1;
506 }
507 if (delete_it) {
508 ::RemoveProp(w, propName);
509 }
510 return 1;
511}
512
513////////////////////////////////////////////////////////////////////////////////
514///
515
516static ULong_t GetPixelImage(Drawable_t id, Int_t x, Int_t y)
517{
518 if (!id) return 0;
519
520 GdkImage *image = (GdkImage *)id;
521 ULong_t pixel;
522
523 if (image->depth == 1) {
524 pixel = (((char *) image->mem)[y * image->bpl + (x >> 3)] & (1 << (7 - (x & 0x7)))) != 0;
525 } else {
526 UChar_t *pixelp = (UChar_t *) image->mem + y * image->bpl + x * image->bpp;
527 switch (image->bpp) {
528 case 1:
529 pixel = *pixelp;
530 break;
531 // Windows is always LSB, no need to check image->byte_order.
532 case 2:
533 pixel = pixelp[0] | (pixelp[1] << 8);
534 break;
535 case 3:
536 pixel = pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16);
537 break;
538 case 4:
539 pixel = pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16);
540 break;
541 }
542 }
543 return pixel;
544}
545
546////////////////////////////////////////////////////////////////////////////////
547/// Collect in orgcolors all different original image colors.
548
549static void CollectImageColors(ULong_t pixel, ULong_t * &orgcolors,
550 Int_t & ncolors, Int_t & maxcolors)
551{
552 if (maxcolors == 0) {
553 ncolors = 0;
554 maxcolors = 100;
555 orgcolors = (ULong_t*) ::operator new(maxcolors*sizeof(ULong_t));
556 }
557
558 for (int i = 0; i < ncolors; i++) {
559 if (pixel == orgcolors[i]) return;
560 }
561 if (ncolors >= maxcolors) {
562 orgcolors = (ULong_t *) TStorage::ReAlloc(orgcolors,
563 maxcolors * 2 *
564 sizeof(ULong_t),
565 maxcolors *
566 sizeof(ULong_t));
567 maxcolors *= 2;
568 }
569 orgcolors[ncolors++] = pixel;
570}
571
572////////////////////////////////////////////////////////////////////////////////
573/// debug function for printing event mask
574
575static char *EventMask2String(UInt_t evmask)
576{
577 static char bfr[500];
578 char *p = bfr;
579
580 *p = '\0';
581#define BITmask(x) \
582 if (evmask & k##x##Mask) \
583 p += sprintf (p, "%s" #x, (p > bfr ? " " : ""))
584 BITmask(Exposure);
585 BITmask(PointerMotion);
586 BITmask(ButtonMotion);
587 BITmask(ButtonPress);
588 BITmask(ButtonRelease);
589 BITmask(KeyPress);
590 BITmask(KeyRelease);
591 BITmask(EnterWindow);
592 BITmask(LeaveWindow);
593 BITmask(FocusChange);
594 BITmask(StructureNotify);
595#undef BITmask
596
597 return bfr;
598}
599
600///////////////////////////////////////////////////////////////////////////////
601class TGWin32MainThread {
602
603public:
604 void *fHandle; // handle of server (aka command) thread
605 DWORD fId; // id of server (aka command) thread
606 static LPCRITICAL_SECTION fCritSec; // general mutex
607 static LPCRITICAL_SECTION fMessageMutex; // message queue mutex
608
609 TGWin32MainThread();
610 ~TGWin32MainThread();
611 static void LockMSG();
612 static void UnlockMSG();
613};
614
615TGWin32MainThread *gMainThread = 0;
616LPCRITICAL_SECTION TGWin32MainThread::fCritSec = 0;
617LPCRITICAL_SECTION TGWin32MainThread::fMessageMutex = 0;
618
619
620////////////////////////////////////////////////////////////////////////////////
621/// dtor
622
623TGWin32MainThread::~TGWin32MainThread()
624{
625 if (fCritSec) {
626 ::LeaveCriticalSection(fCritSec);
627 ::DeleteCriticalSection(fCritSec);
628 delete fCritSec;
629 }
630 fCritSec = 0;
631
632 if (fMessageMutex) {
633 ::LeaveCriticalSection(fMessageMutex);
634 ::DeleteCriticalSection(fMessageMutex);
635 delete fMessageMutex;
636 }
637 fMessageMutex = 0;
638
639 if(fHandle) {
640 ::PostThreadMessage(fId, WM_QUIT, 0, 0);
641 ::CloseHandle(fHandle);
642 }
643 fHandle = 0;
644}
645
646////////////////////////////////////////////////////////////////////////////////
647/// lock message queue
648
649void TGWin32MainThread::LockMSG()
650{
651 if (fMessageMutex) ::EnterCriticalSection(fMessageMutex);
652}
653
654////////////////////////////////////////////////////////////////////////////////
655/// unlock message queue
656
657void TGWin32MainThread::UnlockMSG()
658{
659 if (fMessageMutex) ::LeaveCriticalSection(fMessageMutex);
660}
661
662///////////////////////////////////////////////////////////////////////////////
663class TGWin32RefreshTimer : public TTimer {
664
665public:
666 TGWin32RefreshTimer() : TTimer(10, kTRUE) { if (gSystem) gSystem->AddTimer(this); }
667 ~TGWin32RefreshTimer() { if (gSystem) gSystem->RemoveTimer(this); }
668 Bool_t Notify()
669 {
670 Reset();
671 MSG msg;
672
673 while (::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE)) {
674 ::PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE);
675 if (!gVirtualX)
676 Sleep(200); // avoid start-up race
677 if (gVirtualX)
678 ((TGWin32*)gVirtualX)->GUIThreadMessageFunc(&msg);
679 }
680 return kFALSE;
681 }
682};
683/*
684////////////////////////////////////////////////////////////////////////////////
685/// thread for processing windows messages (aka Main/Server thread)
686
687static DWORD WINAPI MessageProcessingLoop(void *p)
688{
689 MSG msg;
690 Int_t erret;
691 Bool_t endLoop = kFALSE;
692 TGWin32RefreshTimer *refersh = 0;
693
694 // force to create message queue
695 ::PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
696
697 // periodically we refresh windows
698 // Don't create refresh timer if the application has been created inside PVSS
699 if (gApplication) {
700 TString arg = gSystem->BaseName(gApplication->Argv(0));
701 if (!arg.Contains("PVSS"))
702 refersh = new TGWin32RefreshTimer();
703 }
704
705 while (!endLoop) {
706 erret = ::GetMessage(&msg, NULL, NULL, NULL);
707 if (erret <= 0) endLoop = kTRUE;
708 endLoop = MessageProcessingFunc(&msg);
709 }
710
711 TGWin32::Instance()->CloseDisplay();
712 if (refersh)
713 delete refersh;
714
715 // exit thread
716 if (erret == -1) {
717 erret = ::GetLastError();
718 Error("MsgLoop", "Error in GetMessage");
719 ::ExitThread(-1);
720 } else {
721 ::ExitThread(0);
722 }
723 return 0;
724}
725*/
726
727Bool_t GUIThreadMessageWrapper(MSG* msg)
728{
729 // Static wrapper for handling GUI messages.
730 // Forwards from TWinNTSystem's GUIThreadMessageProcessingLoop()
731 // to TGWin32::GUIThreadMessageFunc()
732
733 return ((TGWin32*)gVirtualX)->GUIThreadMessageFunc(msg);
734}
735
736////////////////////////////////////////////////////////////////////////////////
737/// constructor
738
739TGWin32MainThread::TGWin32MainThread()
740{
741 fCritSec = new CRITICAL_SECTION;
742 ::InitializeCriticalSection(fCritSec);
743 fMessageMutex = new CRITICAL_SECTION;
744 ::InitializeCriticalSection(fMessageMutex);
745 fHandle = ((TWinNTSystem*)gSystem)->GetGUIThreadHandle();
746 fId = ((TWinNTSystem*)gSystem)->GetGUIThreadId();
747 ((TWinNTSystem*)gSystem)->SetGUIThreadMsgHandler(GUIThreadMessageWrapper);
748}
749
750} // unnamed namespace
751
752///////////////////////// TGWin32 implementation ///////////////////////////////
754
755////////////////////////////////////////////////////////////////////////////////
756/// Default constructor.
757
758TGWin32::TGWin32(): fRefreshTimer(0)
759{
760 fScreenNumber = 0;
761 fWindows = 0;
762 fColors = 0;
763}
764
765////////////////////////////////////////////////////////////////////////////////
766/// Normal Constructor.
767
768TGWin32::TGWin32(const char *name, const char *title) : TVirtualX(name,title), fRefreshTimer(0)
769{
770 fScreenNumber = 0;
773 fTextAlignH = 1;
774 fTextAlignV = 1;
775 fTextAlign = 7;
776 fTextMagnitude = 1;
777 fCharacterUpX = 1;
778 fCharacterUpY = 1;
780 fWindows = 0;
782 fXEvent = 0;
789
790 fWindows = (XWindow_t*) TStorage::Alloc(fMaxNumberOfWindows*sizeof(XWindow_t));
791 for (int i = 0; i < fMaxNumberOfWindows; i++) fWindows[i].open = 0;
792
793 fColors = new TExMap;
794
795 if (gApplication) {
797 if (!arg.Contains("PVSS"))
798 fRefreshTimer = new TGWin32RefreshTimer();
799 } else {
800 fRefreshTimer = new TGWin32RefreshTimer();
801 }
802
803 // initialize GUI thread and proxy objects
804 if (!gROOT->IsBatch() && !gMainThread) {
805 gMainThread = new TGWin32MainThread();
806 TGWin32ProxyBase::fgMainThreadId = ::GetCurrentThreadId(); // gMainThread->fId;
809#ifdef OLD_THREAD_IMPLEMENTATION
810 gPtr2Interpreter = &TGWin32InterpreterProxy::ProxyObject;
811#endif
812 }
813}
814
815////////////////////////////////////////////////////////////////////////////////
816/// destructor.
817
819{
820 CloseDisplay();
821 if (fRefreshTimer)
822 delete fRefreshTimer;
823 if (!fColors) return;
824 Long64_t key, value;
826 while (it.Next(key, value)) {
827 XColor_t *col = (XColor_t *) value;
828 delete col;
829 }
830 delete fColors;
831}
832
833////////////////////////////////////////////////////////////////////////////////
834/// Windows timer handling events while moving/resizing windows
835
836VOID CALLBACK MyTimerProc(HWND hwnd, UINT message, UINT idTimer, DWORD dwTime)
837{
839 //gVirtualX->UpdateWindow(1); // cause problems with OpenGL in pad...
840}
841
842////////////////////////////////////////////////////////////////////////////////
843/// Message processing function for the GUI thread.
844/// Kicks in once TGWin32 becomes active, and "replaces" the dummy one
845/// in TWinNTSystem; see TWinNTSystem.cxx's GUIThreadMessageProcessingLoop().
846
848{
849 Bool_t ret = kFALSE;
850 static Int_t m_timer = 0;
851
852 if ( (msg->message == WM_NCLBUTTONDOWN) ) {
853 if (m_timer == 0)
854 m_timer = SetTimer(NULL, 1, 20, (TIMERPROC) MyTimerProc);
855 }
856 else if (msg->message == WM_NCMOUSELEAVE ) {
857 if (m_timer) {
858 KillTimer(NULL, m_timer);
859 }
860 m_timer = 0;
861 }
862
863 if (msg->message == TGWin32ProxyBase::fgPostMessageId) {
864 if (msg->wParam) {
865 TGWin32ProxyBase *proxy = (TGWin32ProxyBase*)msg->wParam;
866 proxy->ExecuteCallBack(kTRUE);
867 } else {
868 ret = kTRUE;
869 }
870 } else if (msg->message == TGWin32ProxyBase::fgPingMessageId) {
872 } else {
873 //if ( (msg->message >= WM_NCMOUSEMOVE) &&
874 // (msg->message <= WM_NCMBUTTONDBLCLK) ) {
875 // TGWin32ProxyBase::GlobalLock();
876 //}
877 TGWin32MainThread::LockMSG();
878 TranslateMessage(msg);
879 DispatchMessage(msg);
880 TGWin32MainThread::UnlockMSG();
881 }
882 return ret;
883}
884
885////////////////////////////////////////////////////////////////////////////////
886/// returns kTRUE if we are inside cmd/server thread
887
889{
890#ifdef OLD_THREAD_IMPLEMENTATION
891 return ((::GetCurrentThreadId() == TGWin32ProxyBase::fgMainThreadId) ||
892 (::GetCurrentThreadId() == TGWin32ProxyBase::fgUserThreadId));
893#else
894 return kTRUE;
895#endif
896}
897
898////////////////////////////////////////////////////////////////////////////////
899/// close display (terminate server/gMainThread thread)
900
902{
903 // disable any processing while exiting
905
906 // terminate server thread
907 gPtr2VirtualX = 0;
908#if ROOT_VERSION_CODE < ROOT_VERSION(6,00,00)
910#endif
912 // Following the change in revision 47611,
913 // gInterpreter is a read-only variable but its value
914 // is overridden by gPtr2Interpreter when it is not null.
915 // gInterpreter = TGWin32InterpreterProxy::RealObject();
916
917 // The lock above does not work, so at least
918 // minimize the risk
919 TGWin32MainThread *delThread = gMainThread;
920 if (gMainThread) {
921 gMainThread = 0;
922 delete delThread;
923 }
924
926
927 // terminate ROOT logo splash thread
928 TWin32SplashThread *delSplash = gSplash;
929 if (gSplash) {
930 gSplash = 0;
931 delete delSplash;
932 }
933
935 fWindows = 0;
936
937 if (fXEvent) gdk_event_free((GdkEvent*)fXEvent);
938
940
941 gROOT->SetBatch(kTRUE); // no GUI is possible
942}
943
944////////////////////////////////////////////////////////////////////////////////
945///
946
948{
949 if (gMainThread && gMainThread->fCritSec) ::EnterCriticalSection(gMainThread->fCritSec);
950}
951
952////////////////////////////////////////////////////////////////////////////////
953///
954
956{
957 if (gMainThread && gMainThread->fCritSec) ::LeaveCriticalSection(gMainThread->fCritSec);
958}
959
960////////////////////////////////////////////////////////////////////////////////
961/// Initialize Win32 system. Returns kFALSE in case of failure.
962
963Bool_t TGWin32::Init(void *display)
964{
965 if (!gdk_initialized) {
966 if (!gdk_init_check(NULL, NULL)) return kFALSE;
967 gdk_initialized = true;
968 }
969
970 if (!gClipboardAtom) {
971 gClipboardAtom = gdk_atom_intern("CLIPBOARD", kFALSE);
972 }
973
974 return kTRUE;
975}
976
977////////////////////////////////////////////////////////////////////////////////
978/// Open the display. Return -1 if the opening fails, 0 when ok.
979
980Int_t TGWin32::OpenDisplay(const char *dpyName)
981{
982 GdkPixmap *pixmp1, *pixmp2;
983 GdkColor fore, back;
984 GdkColor color;
985 GdkGCValues gcvals;
986 int i;
987
988 if (!Init((void*)dpyName)) {
989 return -1;
990 }
991
992 if (gDebug <= 4) {
994 } else {
995 gdk_debug_level = 0;
996 }
997
998 fore.red = fore.green = fore.blue = 0;
999 back.red = back.green = back.blue = 0;
1000 color.red = color.green = color.blue = 0;
1001
1002 fScreenNumber = 0; //DefaultScreen(fDisplay);
1003 fVisual = gdk_visual_get_best();
1004 fColormap = gdk_colormap_get_system();
1005 fDepth = gdk_visual_get_best_depth();
1006
1007 GetColor(1).fDefined = kTRUE; // default foreground
1008 gdk_color_black((GdkColormap *)fColormap, &GetColor(1).color);
1009
1010 GetColor(0).fDefined = kTRUE; // default background
1011 gdk_color_white((GdkColormap *)fColormap, &GetColor(0).color);
1012
1013 // Create primitives graphic contexts
1014 for (i = 0; i < kMAXGC; i++) {
1015 gGClist[i] = gdk_gc_new(GDK_ROOT_PARENT());
1016 gdk_gc_set_foreground(gGClist[i], &GetColor(1).color);
1017 gdk_gc_set_background(gGClist[i], &GetColor(0).color);
1018 }
1019
1020 gGCline = gGClist[0]; // PolyLines
1021 gGCmark = gGClist[1]; // PolyMarker
1022 gGCfill = gGClist[2]; // Fill areas
1023 gGCtext = gGClist[3]; // Text
1024 gGCinvt = gGClist[4]; // Inverse text
1025 gGCdash = gGClist[5]; // Dashed lines
1026 gGCpxmp = gGClist[6]; // Pixmap management
1027
1028 gdk_gc_get_values(gGCtext, &gcvals);
1029 gdk_gc_set_foreground(gGCinvt, &gcvals.background);
1030 gdk_gc_set_background(gGCinvt, &gcvals.foreground);
1031
1032 // Create input echo graphic context
1033 GdkGCValues echov;
1034 gdk_color_black(fColormap, &echov.foreground); // = BlackPixel(fDisplay, fScreenNumber);
1035 gdk_color_white(fColormap, &echov.background); // = WhitePixel(fDisplay, fScreenNumber);
1036 echov.function = GDK_INVERT;
1037 echov.subwindow_mode = GDK_CLIP_BY_CHILDREN;
1038 gGCecho =
1039 gdk_gc_new_with_values((GdkWindow *) GDK_ROOT_PARENT(), &echov,
1040 (GdkGCValuesMask) (GDK_GC_FOREGROUND |
1041 GDK_GC_BACKGROUND |
1042 GDK_GC_FUNCTION |
1043 GDK_GC_SUBWINDOW));
1044 // Create a null cursor
1045 pixmp1 = gdk_bitmap_create_from_data(GDK_ROOT_PARENT(),
1046 (const char *)null_cursor_bits, 16,16);
1047
1048 pixmp2 = gdk_bitmap_create_from_data(GDK_ROOT_PARENT(),
1049 (const char *)null_cursor_bits, 16, 16);
1050
1051 gNullCursor = gdk_cursor_new_from_pixmap((GdkDrawable *)pixmp1, (GdkDrawable *)pixmp2,
1052 &fore, &back, 0, 0);
1053 // Create cursors
1054 if (gEnv->GetValue("Win32.UseSysPointers", 0)) {
1056 fCursors[kBottomLeft] = gdk_syscursor_new((ULong_t)IDC_SIZENESW);
1057 fCursors[kBottomRight] = gdk_syscursor_new((ULong_t)IDC_SIZENWSE);
1058 fCursors[kTopLeft] = gdk_syscursor_new((ULong_t)IDC_SIZENWSE);
1059 fCursors[kTopRight] = gdk_syscursor_new((ULong_t)IDC_SIZENESW);
1060 fCursors[kBottomSide] = gdk_syscursor_new((ULong_t)IDC_SIZENS);
1061 fCursors[kLeftSide] = gdk_syscursor_new((ULong_t)IDC_SIZEWE);
1062 fCursors[kTopSide] = gdk_syscursor_new((ULong_t)IDC_SIZENS);
1063 fCursors[kRightSide] = gdk_syscursor_new((ULong_t)IDC_SIZEWE);
1064 fCursors[kMove] = gdk_syscursor_new((ULong_t)IDC_SIZEALL);
1065 fCursors[kCross] =gdk_syscursor_new((ULong_t)IDC_CROSS);
1066 fCursors[kArrowHor] = gdk_syscursor_new((ULong_t)IDC_SIZEWE);
1067 fCursors[kArrowVer] = gdk_syscursor_new((ULong_t)IDC_SIZENS);
1068 fCursors[kHand] = gdk_syscursor_new((ULong_t)IDC_HAND);
1069 fCursors[kPointer] = gdk_syscursor_new((ULong_t)IDC_ARROW);
1070 fCursors[kCaret] = gdk_syscursor_new((ULong_t)IDC_IBEAM);
1071 fCursors[kWatch] = gdk_syscursor_new((ULong_t)IDC_WAIT);
1072 fCursors[kNoDrop] = gdk_syscursor_new((ULong_t)IDC_NO);
1073 }
1074 else {
1076 fCursors[kBottomLeft] = gdk_cursor_new(GDK_BOTTOM_LEFT_CORNER);
1077 fCursors[kBottomRight] = gdk_cursor_new(GDK_BOTTOM_RIGHT_CORNER);
1078 fCursors[kTopLeft] = gdk_cursor_new(GDK_TOP_LEFT_CORNER);
1079 fCursors[kTopRight] = gdk_cursor_new(GDK_TOP_RIGHT_CORNER);
1080 fCursors[kBottomSide] = gdk_cursor_new(GDK_BOTTOM_SIDE);
1081 fCursors[kLeftSide] = gdk_cursor_new(GDK_LEFT_SIDE);
1082 fCursors[kTopSide] = gdk_cursor_new(GDK_TOP_SIDE);
1083 fCursors[kRightSide] = gdk_cursor_new(GDK_RIGHT_SIDE);
1084 fCursors[kMove] = gdk_cursor_new(GDK_FLEUR);
1085 fCursors[kCross] =gdk_cursor_new(GDK_CROSSHAIR);
1086 fCursors[kArrowHor] = gdk_cursor_new(GDK_SB_H_DOUBLE_ARROW);
1087 fCursors[kArrowVer] = gdk_cursor_new(GDK_SB_V_DOUBLE_ARROW);
1088 fCursors[kHand] = gdk_cursor_new(GDK_HAND2);
1089 fCursors[kPointer] = gdk_cursor_new(GDK_LEFT_PTR);
1090 fCursors[kCaret] = gdk_cursor_new(GDK_XTERM);
1091 //fCursors[kWatch] = gdk_cursor_new(GDK_WATCH);
1092 fCursors[kWatch] = gdk_cursor_new(GDK_BUSY);
1093 fCursors[kNoDrop] = gdk_cursor_new(GDK_PIRATE);
1094 }
1095 fCursors[kRotate] = gdk_cursor_new(GDK_EXCHANGE);
1096 fCursors[kArrowRight] = gdk_cursor_new(GDK_ARROW);
1097
1098 // Setup color information
1100
1101 if ( gdk_visual_get_best_type() == GDK_VISUAL_TRUE_COLOR) {
1102 int i;
1103 for (i = 0; i < int(sizeof(fVisual->blue_mask)*kBitsPerByte); i++) {
1104 if (fBlueShift == -1 && ((fVisual->blue_mask >> i) & 1)) {
1105 fBlueShift = i;
1106 }
1107 if ((fVisual->blue_mask >> i) == 1) {
1108 fBlueDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fBlueShift;
1109 break;
1110 }
1111 }
1112 for (i = 0; i < int(sizeof(fVisual->green_mask)*kBitsPerByte); i++) {
1113 if (fGreenShift == -1 && ((fVisual->green_mask >> i) & 1)) {
1114 fGreenShift = i;
1115 }
1116 if ((fVisual->green_mask >> i) == 1) {
1117 fGreenDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fGreenShift;
1118 break;
1119 }
1120 }
1121 for (i = 0; i < int(sizeof(fVisual->red_mask)*kBitsPerByte); i++) {
1122 if (fRedShift == -1 && ((fVisual->red_mask >> i) & 1)) {
1123 fRedShift = i;
1124 }
1125 if ((fVisual->red_mask >> i) == 1) {
1126 fRedDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fRedShift;
1127 break;
1128 }
1129 }
1130 }
1131
1132 SetName("Win32TTF");
1133 SetTitle("ROOT interface to Win32 with TrueType fonts");
1134
1135 if (!TTF::IsInitialized()) TTF::Init();
1136
1137 if (fDepth > 8) {
1139 } else {
1141 }
1142
1145 return 0;
1146}
1147
1148////////////////////////////////////////////////////////////////////////////////
1149/// Allocate color in colormap. If we are on an <= 8 plane machine
1150/// we will use XAllocColor. If we are on a >= 15 (15, 16 or 24) plane
1151/// true color machine we will calculate the pixel value using:
1152/// for 15 and 16 bit true colors have 6 bits precision per color however
1153/// only the 5 most significant bits are used in the color index.
1154/// Except for 16 bits where green uses all 6 bits. I.e.:
1155/// 15 bits = rrrrrgggggbbbbb
1156/// 16 bits = rrrrrggggggbbbbb
1157/// for 24 bits each r, g and b are represented by 8 bits.
1158///
1159/// Since all colors are set with a max of 65535 (16 bits) per r, g, b
1160/// we just right shift them by 10, 11 and 10 bits for 16 planes, and
1161/// (10, 10, 10 for 15 planes) and by 8 bits for 24 planes.
1162/// Returns kFALSE in case color allocation failed.
1163
1164Bool_t TGWin32::AllocColor(GdkColormap *cmap, GdkColor *color)
1165{
1166 if (fRedDiv == -1) {
1167 if ( gdk_color_alloc((GdkColormap *)cmap, (GdkColor *)color) ) return kTRUE;
1168 } else {
1169 color->pixel = (color->red >> fRedDiv) << fRedShift |
1170 (color->green >> fGreenDiv) << fGreenShift |
1171 (color->blue >> fBlueDiv) << fBlueShift;
1172 return kTRUE;
1173 }
1174
1175 return kFALSE;
1176}
1177
1178////////////////////////////////////////////////////////////////////////////////
1179/// Returns the current RGB value for the pixel in the XColor structure.
1180
1181void TGWin32::QueryColors(GdkColormap *cmap, GdkColor *color, Int_t ncolors)
1182{
1183 ULong_t r, g, b;
1184
1185 if (fRedDiv == -1) {
1186 GdkColorContext *cc = gdk_color_context_new(gdk_visual_get_system(), cmap);
1187 gdk_color_context_query_colors(cc, color, ncolors);
1188 gdk_color_context_free(cc);
1189 } else {
1190 for (Int_t i = 0; i < ncolors; i++) {
1191 r = (color[i].pixel & fVisual->red_mask) >> fRedShift;
1192 color[i].red = UShort_t(r*kBIGGEST_RGB_VALUE/(fVisual->red_mask >> fRedShift));
1193
1194 g = (color[i].pixel & fVisual->green_mask) >> fGreenShift;
1195 color[i].green = UShort_t(g*kBIGGEST_RGB_VALUE/(fVisual->green_mask >> fGreenShift));
1196
1197 b = (color[i].pixel & fVisual->blue_mask) >> fBlueShift;
1198 color[i].blue = UShort_t(b*kBIGGEST_RGB_VALUE/(fVisual->blue_mask >> fBlueShift));
1199 }
1200 }
1201}
1202
1203////////////////////////////////////////////////////////////////////////////////
1204/// Compute alignment variables. The alignment is done on the horizontal string
1205/// then the rotation is applied on the alignment variables.
1206/// SetRotation and LayoutGlyphs should have been called before.
1207
1209{
1210 EAlign align = (EAlign) fTextAlign;
1211
1212 // vertical alignment
1213 if (align == kTLeft || align == kTCenter || align == kTRight) {
1214 fAlign.y = TTF::GetAscent();
1215 } else if (align == kMLeft || align == kMCenter || align == kMRight) {
1216 fAlign.y = TTF::GetAscent()/2;
1217 } else {
1218 fAlign.y = 0;
1219 }
1220 // horizontal alignment
1221 if (align == kTRight || align == kMRight || align == kBRight) {
1222 fAlign.x = TTF::GetWidth();
1223 } else if (align == kTCenter || align == kMCenter || align == kBCenter) {
1224 fAlign.x = TTF::GetWidth()/2;
1225 } else {
1226 fAlign.x = 0;
1227 }
1228
1229 FT_Vector_Transform(&fAlign, TTF::GetRotMatrix());
1230 fAlign.x = fAlign.x >> 6;
1231 fAlign.y = fAlign.y >> 6;
1232}
1233
1234////////////////////////////////////////////////////////////////////////////////
1235/// Draw FT_Bitmap bitmap to xim image at position bx,by using specified
1236/// foreground color.
1237
1238void TGWin32::DrawImage(FT_Bitmap *source, ULong_t fore, ULong_t back,
1239 GdkImage *xim, Int_t bx, Int_t by)
1240{
1241 UChar_t d = 0, *s = source->buffer;
1242
1243 if (TTF::GetSmoothing()) {
1244
1245 static GdkColor col[5];
1246 GdkColor *bcol = 0, *bc;
1247 Int_t x, y;
1248
1249 // background kClear, i.e. transparent, we take as background color
1250 // the average of the rgb values of all pixels covered by this character
1251 if (back == (ULong_t) -1 && (UInt_t)source->width) {
1252 ULong_t r, g, b;
1253 Int_t dots, dotcnt;
1254 const Int_t maxdots = 50000;
1255
1256 dots = Int_t(source->width * source->rows);
1257 dots = dots > maxdots ? maxdots : dots;
1258 bcol = new GdkColor[dots];
1259 if (!bcol) return;
1260
1261 bc = bcol;
1262 dotcnt = 0;
1263 for (y = 0; y < (int) source->rows; y++) {
1264 for (x = 0; x < (int) source->width; x++, bc++) {
1265 bc->pixel = GetPixelImage((Drawable_t)xim, bx + x, by + y);
1266 if (++dotcnt >= maxdots) break;
1267 }
1268 }
1269 QueryColors(fColormap, bcol, dots);
1270 r = g = b = 0;
1271 bc = bcol;
1272 dotcnt = 0;
1273 for (y = 0; y < (int) source->rows; y++) {
1274 for (x = 0; x < (int) source->width; x++, bc++) {
1275 r += bc->red;
1276 g += bc->green;
1277 b += bc->blue;
1278 if (++dotcnt >= maxdots) break;
1279 }
1280 }
1281 if (dots != 0) {
1282 r /= dots;
1283 g /= dots;
1284 b /= dots;
1285 }
1286 bc = &col[0];
1287 if (bc->red == r && bc->green == g && bc->blue == b) {
1288 bc->pixel = back;
1289 } else {
1290 bc->pixel = ~back;
1291 bc->red = (UShort_t) r;
1292 bc->green = (UShort_t) g;
1293 bc->blue = (UShort_t) b;
1294 }
1295 }
1296 delete [] bcol;
1297
1298 // if fore or background have changed from previous character
1299 // recalculate the 3 smooting colors (interpolation between fore-
1300 // and background colors)
1301 if (fore != col[4].pixel || back != col[0].pixel) {
1302 col[4].pixel = fore;
1303 if (back != (ULong_t) -1) {
1304 col[3].pixel = back;
1305 QueryColors(fColormap, &col[3], 2);
1306 col[0] = col[3];
1307 } else {
1308 QueryColors(fColormap, &col[4], 1);
1309 }
1310
1311 // interpolate between fore and backgound colors
1312 for (x = 3; x > 0; x--) {
1313 col[x].red = (col[4].red *x + col[0].red *(4-x)) /4;
1314 col[x].green = (col[4].green*x + col[0].green*(4-x)) /4;
1315 col[x].blue = (col[4].blue *x + col[0].blue *(4-x)) /4;
1316 if (!AllocColor(fColormap, &col[x])) {
1317 Warning("DrawImage", "cannot allocate smoothing color");
1318 col[x].pixel = col[x+1].pixel;
1319 }
1320 }
1321 }
1322
1323 // put smoothed character, character pixmap values are an index
1324 // into the 5 colors used for aliasing (4 = foreground, 0 = background)
1325 for (y = 0; y < (int) source->rows; y++) {
1326 for (x = 0; x < (int) source->width; x++) {
1327 d = *s++ & 0xff;
1328 d = ((d + 10) * 5) / 256;
1329 if (d > 4) d = 4;
1330 if (d && x < (int) source->width) {
1331 ULong_t p = col[d].pixel;
1332 PutPixel((Drawable_t)xim, bx + x, by + y, p);
1333 }
1334 }
1335 }
1336 } else {
1337 // no smoothing, just put character using foreground color
1338 UChar_t* row=s;
1339 for (int y = 0; y < (int) source->rows; y++) {
1340 int n = 0;
1341 s = row;
1342 for (int x = 0; x < (int) source->width; x++) {
1343 if (n == 0) d = *s++;
1344 if (TESTBIT(d,7-n)) {
1345 PutPixel((Drawable_t)xim, bx + x, by + y, fore);
1346 }
1347 if (++n == (int) kBitsPerByte) n = 0;
1348 }
1349 row += source->pitch;
1350 }
1351 }
1352}
1353
1354////////////////////////////////////////////////////////////////////////////////
1355/// Draw text using TrueType fonts. If TrueType fonts are not available the
1356/// text is drawn with TGWin32::DrawText.
1357
1359 const char *text, ETextMode mode)
1360{
1361 if (!TTF::IsInitialized()) TTF::Init();
1365 Align();
1366 RenderString(x, y, mode);
1367}
1368
1369////////////////////////////////////////////////////////////////////////////////
1370/// Draw text using TrueType fonts. If TrueType fonts are not available the
1371/// text is drawn with TGWin32::DrawText.
1372
1374 const wchar_t *text, ETextMode mode)
1375{
1376 if (!TTF::IsInitialized()) TTF::Init();
1380 Align();
1381 RenderString(x, y, mode);
1382}
1383
1384////////////////////////////////////////////////////////////////////////////////
1385/// Get the background of the current window in an XImage.
1386
1388{
1389 Window_t cws = GetCurrentWindow();
1390 UInt_t width;
1391 UInt_t height;
1392 Int_t xy;
1393 gVirtualX->GetWindowSize(cws, xy, xy, width, height);
1394
1395 if (x < 0) {
1396 w += x;
1397 x = 0;
1398 }
1399 if (y < 0) {
1400 h += y;
1401 y = 0;
1402 }
1403
1404 if (x+w > width) w = width - x;
1405 if (y+h > height) h = height - y;
1406
1407 return gdk_image_get((GdkDrawable*)cws, x, y, w, h);
1408}
1409
1410////////////////////////////////////////////////////////////////////////////////
1411/// Test if there is really something to render
1412
1414{
1415 Window_t cws = GetCurrentWindow();
1416 UInt_t width;
1417 UInt_t height;
1418 Int_t xy;
1419 gVirtualX->GetWindowSize(cws, xy, xy, width, height);
1420
1421 // If w or h is 0, very likely the string is only blank characters
1422 if ((int)w == 0 || (int)h == 0) return kFALSE;
1423
1424 // If string falls outside window, there is probably no need to draw it.
1425 if (x + (int)w <= 0 || x >= (int)width) return kFALSE;
1426 if (y + (int)h <= 0 || y >= (int)height) return kFALSE;
1427
1428 return kTRUE;
1429}
1430
1431////////////////////////////////////////////////////////////////////////////////
1432/// Perform the string rendering in the pad.
1433/// LayoutGlyphs should have been called before.
1434
1436{
1437 TTF::TTGlyph* glyph = TTF::GetGlyphs();
1438 GdkGCValues gcvals;
1439
1440 // compute the size and position of the XImage that will contain the text
1441 Int_t Xoff = 0; if (TTF::GetBox().xMin < 0) Xoff = -TTF::GetBox().xMin;
1442 Int_t Yoff = 0; if (TTF::GetBox().yMin < 0) Yoff = -TTF::GetBox().yMin;
1443 Int_t w = TTF::GetBox().xMax + Xoff;
1444 Int_t h = TTF::GetBox().yMax + Yoff;
1445 Int_t x1 = x-Xoff-fAlign.x;
1446 Int_t y1 = y+Yoff+fAlign.y-h;
1447
1448 if (!IsVisible(x1, y1, w, h)) {
1449 return;
1450 }
1451
1452 // create the XImage that will contain the text
1453 UInt_t depth = fDepth;
1454 GdkImage *xim = gdk_image_new(GDK_IMAGE_SHARED, gdk_visual_get_best(), w, h);
1455
1456 // use malloc since Xlib will use free() in XDestroyImage
1457// xim->data = (char *) malloc(xim->bytes_per_line * h);
1458// memset(xim->data, 0, xim->bytes_per_line * h);
1459
1460 ULong_t pixel;
1461 ULong_t bg;
1462
1463 gdk_gc_get_values((GdkGC*)GetGC(3), &gcvals);
1464
1465 // get the background
1466 if (mode == kClear) {
1467 // if mode == kClear we need to get an image of the background
1468 GdkImage *bim = GetBackground(x1, y1, w, h);
1469 if (!bim) {
1470 Error("DrawText", "error getting background image");
1471 return;
1472 }
1473
1474 // and copy it into the text image
1475 Int_t xo = 0, yo = 0;
1476 if (x1 < 0) xo = -x1;
1477 if (y1 < 0) yo = -y1;
1478
1479 for (int yp = 0; yp < (int) bim->height; yp++) {
1480 for (int xp = 0; xp < (int) bim->width; xp++) {
1481 pixel = GetPixelImage((Drawable_t)bim, xp, yp);
1482 PutPixel((Drawable_t)xim, xo+xp, yo+yp, pixel);
1483 }
1484 }
1485
1486 gdk_image_unref((GdkImage *)bim);
1487
1488 bg = (ULong_t) -1;
1489 } else {
1490 // if mode == kOpaque its simple, we just draw the background
1491
1492 GdkImage *bim = GetBackground(x1, y1, w, h);
1493 if (!bim) {
1494 pixel = gcvals.background.pixel;
1495 } else {
1496 pixel = GetPixelImage((Drawable_t)bim, 0, 0);
1497 }
1498 Int_t xo = 0, yo = 0;
1499 if (x1 < 0) xo = -x1;
1500 if (y1 < 0) yo = -y1;
1501
1502 for (int yp = 0; yp < h; yp++) {
1503 for (int xp = 0; xp < (int) w; xp++) {
1504 PutPixel((Drawable_t)xim, xo+xp, yo+yp, pixel);
1505 }
1506 }
1507 if (bim) {
1508 gdk_image_unref((GdkImage *)bim);
1509 bg = (ULong_t) -1;
1510 } else {
1511 bg = pixel;
1512 }
1513 }
1514
1515 // paint the glyphs in the XImage
1516 glyph = TTF::GetGlyphs();
1517 for (int n = 0; n < TTF::GetNumGlyphs(); n++, glyph++) {
1518 if (FT_Glyph_To_Bitmap(&glyph->fImage,
1519 TTF::GetSmoothing() ? ft_render_mode_normal
1520 : ft_render_mode_mono,
1521 0, 1 )) continue;
1522 FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph->fImage;
1523 FT_Bitmap* source = &bitmap->bitmap;
1524 Int_t bx, by;
1525
1526 bx = bitmap->left+Xoff;
1527 by = h - bitmap->top-Yoff;
1528 DrawImage(source, gcvals.foreground.pixel, bg, xim, bx, by);
1529 }
1530
1531 // put the Ximage on the screen
1532 Window_t cws = GetCurrentWindow();
1533 gdk_draw_image((GdkDrawable *)cws, GetGC(6), xim, 0, 0, x1, y1, w, h);
1534
1535 gdk_image_unref(xim);
1536}
1537
1538////////////////////////////////////////////////////////////////////////////////
1539/// Set specified font.
1540
1542{
1543 fTextFont = fontnumber;
1544 TTF::SetTextFont(fontnumber);
1545}
1546
1547////////////////////////////////////////////////////////////////////////////////
1548/// Set text font to specified name.
1549/// mode : loading flag
1550/// mode=0 : search if the font exist (kCheck)
1551/// mode=1 : search the font and load it if it exists (kLoad)
1552/// font : font name
1553///
1554/// Set text font to specified name. This function returns 0 if
1555/// the specified font is found, 1 if not.
1556
1558{
1559 return TTF::SetTextFont(fontname);
1560}
1561
1562////////////////////////////////////////////////////////////////////////////////
1563/// Set current text size.
1564
1566{
1567 fTextSize = textsize;
1568 TTF::SetTextSize(textsize);
1569}
1570
1571////////////////////////////////////////////////////////////////////////////////
1572/// Clear current window.
1573
1575{
1576 if (!fWindows) return;
1577
1578 if (!gCws->ispixmap && !gCws->double_buffer) {
1579 gdk_window_set_background(gCws->drawing, (GdkColor *) & GetColor(0).color);
1580 gdk_window_clear(gCws->drawing);
1581 GdiFlush();
1582 } else {
1583 SetColor(gGCpxmp, 0);
1585 0, 0, gCws->width, gCws->height);
1586 SetColor(gGCpxmp, 1);
1587 }
1588}
1589
1590////////////////////////////////////////////////////////////////////////////////
1591/// Delete current pixmap.
1592
1594{
1595 CloseWindow1();
1596}
1597
1598////////////////////////////////////////////////////////////////////////////////
1599/// Delete current window.
1600
1602{
1603 CloseWindow1();
1604}
1605
1606////////////////////////////////////////////////////////////////////////////////
1607/// Delete current window.
1608
1610{
1611 int wid;
1612
1613 if (gCws->ispixmap) {
1614 gdk_pixmap_unref(gCws->window);
1615 } else {
1616 gdk_window_destroy(gCws->window, kTRUE);
1617 }
1618
1619 if (gCws->buffer) {
1620 gdk_pixmap_unref(gCws->buffer);
1621 }
1622 if (gCws->new_colors) {
1623 gdk_colormap_free_colors((GdkColormap *) fColormap,
1624 (GdkColor *)gCws->new_colors, gCws->ncolors);
1625
1626 delete [] gCws->new_colors;
1627 gCws->new_colors = 0;
1628 }
1629
1630 GdiFlush();
1631 gCws->open = 0;
1632
1633 if (!fWindows) return;
1634
1635 // make first window in list the current window
1636 for (wid = 0; wid < fMaxNumberOfWindows; wid++) {
1637 if (fWindows[wid].open) {
1638 gCws = &fWindows[wid];
1639 return;
1640 }
1641 }
1642 gCws = 0;
1643}
1644
1645////////////////////////////////////////////////////////////////////////////////
1646/// Copy the pixmap wid at the position xpos, ypos in the current window.
1647
1648void TGWin32::CopyPixmap(int wid, int xpos, int ypos)
1649{
1650 if (!fWindows) return;
1651
1652 gTws = &fWindows[wid];
1653 gdk_window_copy_area(gCws->drawing, gGCpxmp, xpos, ypos, gTws->drawing,
1654 0, 0, gTws->width, gTws->height);
1655 GdiFlush();
1656}
1657
1658////////////////////////////////////////////////////////////////////////////////
1659/// Draw a box.
1660/// mode=0 hollow (kHollow)
1661/// mode=1 solid (kSolid)
1662
1663void TGWin32::DrawBox(int x1, int y1, int x2, int y2, EBoxMode mode)
1664{
1665 if (!fWindows) return;
1666
1667 Int_t x = TMath::Min(x1, x2);
1668 Int_t y = TMath::Min(y1, y2);
1669 Int_t w = TMath::Abs(x2 - x1);
1670 Int_t h = TMath::Abs(y2 - y1);
1671
1672 switch (mode) {
1673
1674 case kHollow:
1677 gdk_win32_draw_rectangle(gCws->drawing, gGCline, 0, x, y, w, h);
1678 break;
1679
1680 case kFilled:
1683 gdk_win32_draw_rectangle(gCws->drawing, gGCfill, 1, x, y, w, h);
1684 break;
1685
1686 default:
1687 break;
1688 }
1689}
1690
1691////////////////////////////////////////////////////////////////////////////////
1692/// Draw a cell array.
1693/// x1,y1 : left down corner
1694/// x2,y2 : right up corner
1695/// nx,ny : array size
1696/// ic : array
1697///
1698/// Draw a cell array. The drawing is done with the pixel presicion
1699/// if (X2-X1)/NX (or Y) is not a exact pixel number the position of
1700/// the top rigth corner may be wrong.
1701
1703 Int_t nx, Int_t ny, Int_t *ic)
1704{
1705 int i, j, icol, ix, iy, w, h, current_icol;
1706
1707 if (!fWindows) return;
1708
1709 current_icol = -1;
1710 w = TMath::Max((x2 - x1) / (nx), 1);
1711 h = TMath::Max((y1 - y2) / (ny), 1);
1712 ix = x1;
1713
1716
1717 for (i = 0; i < nx; i++) {
1718 iy = y1 - h;
1719 for (j = 0; j < ny; j++) {
1720 icol = ic[i + (nx * j)];
1721 if (icol != current_icol) {
1722 gdk_gc_set_foreground(gGCfill, (GdkColor *) & GetColor(icol).color);
1723 current_icol = icol;
1724 }
1725
1726 gdk_win32_draw_rectangle(gCws->drawing, gGCfill, kTRUE, ix, iy, w, h);
1727 iy = iy - h;
1728 }
1729 ix = ix + w;
1730 }
1731}
1732
1733////////////////////////////////////////////////////////////////////////////////
1734/// Fill area described by polygon.
1735/// n : number of points
1736/// xy(2,n) : list of points
1737
1739{
1740 int i;
1741 static int lastn = 0;
1742 static GdkPoint *xy = 0;
1743
1744 if (!fWindows) return;
1745
1748
1749 if (lastn!=n) {
1750 delete [] (GdkPoint *)xy;
1751 xy = new GdkPoint[n];
1752 lastn = n;
1753 }
1754 for (i = 0; i < n; i++) {
1755 xy[i].x = xyt[i].fX;
1756 xy[i].y = xyt[i].fY;
1757 }
1758
1759 if (gFillHollow) {
1760 gdk_win32_draw_lines(gCws->drawing, gGCfill, xy, n);
1761 } else {
1762 gdk_win32_draw_polygon(gCws->drawing, gGCfill, 1, xy, n);
1763 }
1764}
1765
1766////////////////////////////////////////////////////////////////////////////////
1767/// Draw a line.
1768/// x1,y1 : begin of line
1769/// x2,y2 : end of line
1770
1771void TGWin32::DrawLine(int x1, int y1, int x2, int y2)
1772{
1773 if (!fWindows) return;
1774
1777
1778 if (gLineStyle == GDK_LINE_SOLID) {
1779 gdk_draw_line(gCws->drawing, gGCline, x1, y1, x2, y2);
1780 } else {
1781 int i;
1782 gint8 dashes[32];
1783 for (i = 0; i < gDashSize; i++) {
1784 dashes[i] = (gint8) gDashList[i];
1785 }
1786 for (i = gDashSize; i < 32; i++) {
1787 dashes[i] = (gint8) 0;
1788 }
1789 gdk_gc_set_dashes(gGCdash, gDashOffset, dashes, gDashSize);
1790 gdk_draw_line(gCws->drawing, gGCdash, x1, y1, x2, y2);
1791 }
1792}
1793
1794////////////////////////////////////////////////////////////////////////////////
1795/// Draw a line through all points.
1796/// n : number of points
1797/// xy : list of points
1798
1800{
1801 int i;
1802
1803 if (!fWindows) return;
1804
1805 Point_t *xy = new Point_t[n];
1806
1807 for (i = 0; i < n; i++) {
1808 xy[i].fX = xyt[i].fX;
1809 xy[i].fY = xyt[i].fY;
1810 }
1811
1814
1815 if (n > 1) {
1816 if (gLineStyle == GDK_LINE_SOLID) {
1817 gdk_win32_draw_lines(gCws->drawing, gGCline, (GdkPoint *)xy, n);
1818 } else {
1819 int i;
1820 gint8 dashes[32];
1821
1822 for (i = 0; i < gDashSize; i++) {
1823 dashes[i] = (gint8) gDashList[i];
1824 }
1825 for (i = gDashSize; i < 32; i++) {
1826 dashes[i] = (gint8) 0;
1827 }
1828
1829 gdk_gc_set_dashes(gGCdash, gDashOffset, dashes, gDashSize);
1830 gdk_win32_draw_lines(gCws->drawing, (GdkGC*)gGCdash, (GdkPoint *)xy, n);
1831
1832 // calculate length of line to update dash offset
1833 for (i = 1; i < n; i++) {
1834 int dx = xy[i].fX - xy[i - 1].fX;
1835 int dy = xy[i].fY - xy[i - 1].fY;
1836
1837 if (dx < 0) dx = -dx;
1838 if (dy < 0) dy = -dy;
1839 gDashOffset += dx > dy ? dx : dy;
1840 }
1842 }
1843 } else {
1844 gdk_win32_draw_points( gCws->drawing, gLineStyle == GDK_LINE_SOLID ?
1845 gGCline : gGCdash, (GdkPoint *)xy,1);
1846 }
1847 delete [] xy;
1848}
1849
1850////////////////////////////////////////////////////////////////////////////////
1851/// Draw n markers with the current attributes at position x, y.
1852/// n : number of markers to draw
1853/// xy : x,y coordinates of markers
1854
1856{
1857 int i;
1858 static int lastn = 0;
1859 static GdkPoint *xy = 0;
1860
1861 if (!fWindows) return;
1862
1865
1866 if (lastn!=n) {
1867 delete [] (GdkPoint *)xy;
1868 xy = new GdkPoint[n];
1869 lastn = n;
1870 }
1871
1872 for (i = 0; i < n; i++) {
1873 xy[i].x = xyt[i].fX;
1874 xy[i].y = xyt[i].fY;
1875 }
1876
1877 if (gMarker.n <= 0) {
1878 gdk_win32_draw_points(gCws->drawing, gGCmark, xy, n);
1879 } else {
1880 int r = gMarker.n / 2;
1881 int m;
1882
1883 for (m = 0; m < n; m++) {
1884 int hollow = 0;
1885 switch (gMarker.type) {
1886 int i;
1887
1888 case 0: // hollow circle
1889 gdk_win32_draw_arc(gCws->drawing, gGCmark, kFALSE, xy[m].x-r, xy[m].y-r,
1890 gMarker.n, gMarker.n, 0, 23040);
1891 break;
1892
1893 case 1: // filled circle
1894 gdk_win32_draw_arc(gCws->drawing, gGCmark, kTRUE, xy[m].x-r, xy[m].y-r,
1895 gMarker.n, gMarker.n, 0, 23040);
1896 break;
1897
1898 case 2: // hollow polygon
1899 hollow = 1;
1900 case 3: // filled polygon
1901 for (i = 0; i < gMarker.n; i++) {
1902 gMarker.xy[i].x += xy[m].x;
1903 gMarker.xy[i].y += xy[m].y;
1904 }
1905 if (hollow) {
1906 gdk_win32_draw_lines(gCws->drawing, gGCmark, (GdkPoint *)gMarker.xy, gMarker.n);
1907 } else {
1908 gdk_win32_draw_polygon(gCws->drawing, gGCmark, 1, (GdkPoint *)gMarker.xy, gMarker.n);
1909 }
1910 for (i = 0; i < gMarker.n; i++) {
1911 gMarker.xy[i].x -= xy[m].x;
1912 gMarker.xy[i].y -= xy[m].y;
1913 }
1914 break;
1915
1916 case 4: // segmented line
1917 for (i = 0; i < gMarker.n; i += 2) {
1918 gdk_draw_line(gCws->drawing, gGCmark,
1919 xy[m].x + gMarker.xy[i].x,
1920 xy[m].y + gMarker.xy[i].y,
1921 xy[m].x + gMarker.xy[i + 1].x,
1922 xy[m].y + gMarker.xy[i + 1].y);
1923 }
1924 break;
1925 }
1926 }
1927 }
1928}
1929
1930////////////////////////////////////////////////////////////////////////////////
1931/// Return character up vector.
1932
1934{
1935 chupx = fCharacterUpX;
1936 chupy = fCharacterUpY;
1937}
1938
1939////////////////////////////////////////////////////////////////////////////////
1940/// Return reference to internal color structure associated
1941/// to color index cid.
1942
1944{
1945 XColor_t *col = (XColor_t*) fColors->GetValue(cid);
1946 if (!col) {
1947 col = new XColor_t;
1948 fColors->Add(cid, (Long_t) col);
1949 }
1950 return *col;
1951}
1952
1953////////////////////////////////////////////////////////////////////////////////
1954/// Return current window pointer. Protected method used by TGWin32TTF.
1955
1957{
1958 return (Window_t)(gCws ? gCws->drawing : 0);
1959}
1960
1961////////////////////////////////////////////////////////////////////////////////
1962/// Return desired Graphics Context ("which" maps directly on gGCList[]).
1963/// Protected method used by TGWin32TTF.
1964
1965GdkGC *TGWin32::GetGC(Int_t which) const
1966{
1967 if (which >= kMAXGC || which < 0) {
1968 Error("GetGC", "trying to get illegal GdkGC (which = %d)", which);
1969 return 0;
1970 }
1971
1972 return gGClist[which];
1973}
1974
1975////////////////////////////////////////////////////////////////////////////////
1976/// Query the double buffer value for the window wid.
1977
1979{
1980 if (!fWindows) return 0;
1981
1982 gTws = &fWindows[wid];
1983
1984 if (!gTws->open) {
1985 return -1;
1986 } else {
1987 return gTws->double_buffer;
1988 }
1989}
1990
1991////////////////////////////////////////////////////////////////////////////////
1992/// Return position and size of window wid.
1993/// wid : window identifier
1994/// x,y : window position (output)
1995/// w,h : window size (output)
1996/// if wid < 0 the size of the display is returned
1997
1998void TGWin32::GetGeometry(int wid, int &x, int &y, unsigned int &w,
1999 unsigned int &h)
2000{
2001 if (!fWindows) return;
2002
2003 if (wid < 0) {
2004 x = 0;
2005 y = 0;
2006
2007 w = gdk_screen_width();
2008 h = gdk_screen_height();
2009 } else {
2010 int depth;
2011 int width, height;
2012
2013 gTws = &fWindows[wid];
2014 gdk_window_get_geometry((GdkDrawable *) gTws->window, &x, &y,
2015 &width, &height, &depth);
2016
2017 gdk_window_get_deskrelative_origin((GdkDrawable *) gTws->window, &x, &y);
2018
2019 if (width > 0 && height > 0) {
2020 gTws->width = width;
2021 gTws->height = height;
2022 }
2023 w = gTws->width;
2024 h = gTws->height;
2025 }
2026}
2027
2028////////////////////////////////////////////////////////////////////////////////
2029/// Return hostname on which the display is opened.
2030
2031const char *TGWin32::DisplayName(const char *dpyName)
2032{
2033 return "localhost"; //return gdk_get_display();
2034}
2035
2036////////////////////////////////////////////////////////////////////////////////
2037/// Get maximum number of planes.
2038
2039void TGWin32::GetPlanes(int &nplanes)
2040{
2041 nplanes = gdk_visual_get_best_depth();
2042}
2043
2044////////////////////////////////////////////////////////////////////////////////
2045/// Get rgb values for color "index".
2046
2047void TGWin32::GetRGB(int index, float &r, float &g, float &b)
2048{
2049 if (index == 0) {
2050 r = g = b = 1.0;
2051 } else if (index == 1) {
2052 r = g = b = 0.0;
2053 } else {
2054 XColor_t &col = GetColor(index);
2055 r = ((float) col.color.red) / ((float) kBIGGEST_RGB_VALUE);
2056 g = ((float) col.color.green) / ((float) kBIGGEST_RGB_VALUE);
2057 b = ((float) col.color.blue) / ((float) kBIGGEST_RGB_VALUE);
2058 }
2059}
2060
2061////////////////////////////////////////////////////////////////////////////////
2062/// Return the size of a character string.
2063/// iw : text width
2064/// ih : text height
2065/// mess : message
2066
2067void TGWin32::GetTextExtent(unsigned int &w, unsigned int &h, char *mess)
2068{
2071 TTF::GetTextExtent(w, h, mess);
2072}
2073
2074////////////////////////////////////////////////////////////////////////////////
2075/// Return the X11 window identifier.
2076/// wid : Workstation identifier (input)
2077
2079{
2080 if (!fWindows) return 0;
2081 return (Window_t) fWindows[wid].window;
2082}
2083
2084////////////////////////////////////////////////////////////////////////////////
2085/// Move the window wid.
2086/// wid : GdkWindow identifier.
2087/// x : x new window position
2088/// y : y new window position
2089
2090void TGWin32::MoveWindow(int wid, int x, int y)
2091{
2092 if (!fWindows) return;
2093
2094 gTws = &fWindows[wid];
2095 if (!gTws->open) return;
2096
2097 gdk_window_move((GdkDrawable *) gTws->window, x, y);
2098}
2099
2100////////////////////////////////////////////////////////////////////////////////
2101/// Open a new pixmap.
2102/// w,h : Width and height of the pixmap.
2103
2104Int_t TGWin32::OpenPixmap(unsigned int w, unsigned int h)
2105{
2106 int wval, hval;
2107 int i, wid;
2108 int ww, hh, depth;
2109 wval = w;
2110 hval = h;
2111
2112 // Select next free window number
2113 again:
2114 for (wid = 0; wid < fMaxNumberOfWindows; wid++) {
2115 if (!fWindows[wid].open) {
2116 fWindows[wid].open = 1;
2117 gCws = &fWindows[wid];
2118 break;
2119 }
2120 }
2121 if (wid == fMaxNumberOfWindows) {
2122 int newsize = fMaxNumberOfWindows + 10;
2123 fWindows = (XWindow_t *) TStorage::ReAlloc(fWindows,
2124 newsize * sizeof(XWindow_t),
2126 sizeof(XWindow_t));
2127
2128 for (i = fMaxNumberOfWindows; i < newsize; i++) fWindows[i].open = 0;
2129 fMaxNumberOfWindows = newsize;
2130 goto again;
2131 }
2132
2133 depth =gdk_visual_get_best_depth();
2134 gCws->window = (GdkPixmap *) gdk_pixmap_new(GDK_ROOT_PARENT(),wval,hval,depth);
2135 gdk_drawable_get_size((GdkDrawable *) gCws->window, &ww, &hh);
2136
2137 for (i = 0; i < kMAXGC; i++) {
2138 gdk_gc_set_clip_mask((GdkGC *) gGClist[i], (GdkDrawable *)None);
2139 }
2140
2141 SetColor(gGCpxmp, 0);
2142 gdk_win32_draw_rectangle(gCws->window,(GdkGC *)gGCpxmp, kTRUE,
2143 0, 0, ww, hh);
2144 SetColor(gGCpxmp, 1);
2145
2146 // Initialise the window structure
2147 gCws->drawing = gCws->window;
2148 gCws->buffer = 0;
2149 gCws->double_buffer = 0;
2150 gCws->ispixmap = 1;
2151 gCws->clip = 0;
2152 gCws->width = wval;
2153 gCws->height = hval;
2154 gCws->new_colors = 0;
2155
2156 return wid;
2157}
2158
2159////////////////////////////////////////////////////////////////////////////////
2160/// Open window and return window number.
2161/// Return -1 if window initialization fails.
2162
2164{
2165 GdkWindowAttr attributes;
2166 unsigned long attr_mask = 0;
2167 int wid;
2168 int xval, yval;
2169 int wval, hval, depth;
2170
2171 GdkWindow *wind = (GdkWindow *) win;
2172
2173 gdk_window_get_geometry(wind, &xval, &yval, &wval, &hval, &depth);
2174
2175 // Select next free window number
2176
2177 again:
2178 for (wid = 0; wid < fMaxNumberOfWindows; wid++) {
2179 if (!fWindows[wid].open) {
2180 fWindows[wid].open = 1;
2181 fWindows[wid].double_buffer = 0;
2182 gCws = &fWindows[wid];
2183 break;
2184 }
2185 }
2186
2187 if (wid == fMaxNumberOfWindows) {
2188 int newsize = fMaxNumberOfWindows + 10;
2189 fWindows =
2190 (XWindow_t *) TStorage::ReAlloc(fWindows,
2191 newsize * sizeof(XWindow_t),
2193 sizeof(XWindow_t));
2194
2195 for (int i = fMaxNumberOfWindows; i < newsize; i++) {
2196 fWindows[i].open = 0;
2197 }
2198
2199 fMaxNumberOfWindows = newsize;
2200 goto again;
2201 }
2202 // Create window
2203 attributes.wclass = GDK_INPUT_OUTPUT;
2204 attributes.event_mask = 0L; //GDK_ALL_EVENTS_MASK;
2205 attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK |
2206 GDK_PROPERTY_CHANGE_MASK;
2207// GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK;
2208 if (xval >= 0) {
2209 attributes.x = xval;
2210 } else {
2211 attributes.x = -1.0 * xval;
2212 }
2213
2214 if (yval >= 0) {
2215 attributes.y = yval;
2216 } else {
2217 attributes.y = -1.0 * yval;
2218 }
2219 attributes.width = wval;
2220 attributes.height = hval;
2221 attributes.colormap = gdk_colormap_get_system();
2222 attributes.visual = gdk_window_get_visual(wind);
2223 attributes.override_redirect = TRUE;
2224
2225 if ((attributes.y > 0) && (attributes.x > 0)) {
2226 attr_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_COLORMAP |
2227 GDK_WA_WMCLASS | GDK_WA_NOREDIR;
2228 } else {
2229 attr_mask = GDK_WA_COLORMAP | GDK_WA_WMCLASS | GDK_WA_NOREDIR;
2230 }
2231
2232 if (attributes.visual != NULL) {
2233 attr_mask |= GDK_WA_VISUAL;
2234 }
2235 attributes.window_type = GDK_WINDOW_CHILD;
2236 gCws->window = gdk_window_new(wind, &attributes, attr_mask);
2237 HWND window = (HWND)GDK_DRAWABLE_XID((GdkWindow *)gCws->window);
2238 ::ShowWindow(window, SW_SHOWNORMAL);
2239 ::ShowWindow(window, SW_RESTORE);
2240 ::BringWindowToTop(window);
2241
2242 if (!fUseSysPointers) {
2243 ::SetClassLong(window, GCL_HCURSOR,
2244 (LONG)GDK_CURSOR_XID(fCursors[kPointer]));
2245 }
2246
2247 // Initialise the window structure
2248
2249 gCws->drawing = gCws->window;
2250 gCws->buffer = 0;
2251 gCws->double_buffer = 0;
2252 gCws->ispixmap = 0;
2253 gCws->clip = 0;
2254 gCws->width = wval;
2255 gCws->height = hval;
2256 gCws->new_colors = 0;
2257
2258 return wid;
2259}
2260
2261////////////////////////////////////////////////////////////////////////////////
2262/// Query pointer position.
2263/// ix : X coordinate of pointer
2264/// iy : Y coordinate of pointer
2265/// (both coordinates are relative to the origin of the root window)
2266
2267void TGWin32::QueryPointer(int &ix, int &iy)
2268{
2269 //GdkModifierType mask;
2270 //GdkWindow *retw = gdk_window_get_pointer((GdkWindow *) gCws->window,
2271 // &ix, &iy, &mask);
2272 POINT cpt;
2273 GetCursorPos(&cpt);
2274 ix = cpt.x;
2275 iy = cpt.y;
2276}
2277
2278////////////////////////////////////////////////////////////////////////////////
2279/// Remove the pixmap pix.
2280
2281void TGWin32::RemovePixmap(GdkDrawable *pix)
2282{
2283 gdk_pixmap_unref((GdkPixmap *)pix);
2284}
2285
2286////////////////////////////////////////////////////////////////////////////////
2287/// Request Locator position.
2288/// x,y : cursor position at moment of button press (output)
2289/// ctyp : cursor type (input)
2290/// ctyp=1 tracking cross
2291/// ctyp=2 cross-hair
2292/// ctyp=3 rubber circle
2293/// ctyp=4 rubber band
2294/// ctyp=5 rubber rectangle
2295///
2296/// mode : input mode
2297/// mode=0 request
2298/// mode=1 sample
2299///
2300/// Request locator:
2301/// return button number 1 = left is pressed
2302/// 2 = middle is pressed
2303/// 3 = right is pressed
2304/// in sample mode:
2305/// 11 = left is released
2306/// 12 = middle is released
2307/// 13 = right is released
2308/// -1 = nothing is pressed or released
2309/// -2 = leave the window
2310/// else = keycode (keyboard is pressed)
2311
2313{
2314 static int xloc = 0;
2315 static int yloc = 0;
2316 static int xlocp = 0;
2317 static int ylocp = 0;
2318 static GdkCursor *cursor = NULL;
2319 Int_t xtmp, ytmp;
2320
2321 GdkEvent *event;
2322 int button_press;
2323 int radius;
2324
2325 // Change the cursor shape
2326 if (cursor == NULL) {
2327 if (ctyp > 1) {
2328 gdk_window_set_cursor((GdkWindow *)gCws->window, (GdkCursor *)gNullCursor);
2329 gdk_gc_set_foreground((GdkGC *) gGCecho, &GetColor(0).color);
2330 } else {
2331 if (fUseSysPointers)
2332 cursor = gdk_syscursor_new((ULong_t)IDC_CROSS);
2333 else
2334 cursor = gdk_cursor_new((GdkCursorType)GDK_CROSSHAIR);
2335 gdk_window_set_cursor((GdkWindow *)gCws->window, (GdkCursor *)cursor);
2336 }
2337 }
2338
2339 // Event loop
2340 button_press = 0;
2341
2342 // Set max response time to 2 minutes to avoid timeout
2343 // in TGWin32ProxyBase::ForwardCallBack during RequestLocator
2345 while (button_press == 0) {
2346 event = gdk_event_get();
2347
2348 switch (ctyp) {
2349
2350 case 1:
2351 break;
2352
2353 case 2:
2354 gdk_draw_line(gCws->window, gGCecho, xloc, 0, xloc, gCws->height);
2355 gdk_draw_line(gCws->window, gGCecho, 0, yloc, gCws->width, yloc);
2356 break;
2357
2358 case 3:
2359 radius = (int) TMath::Sqrt((double)((xloc - xlocp) * (xloc - xlocp) +
2360 (yloc - ylocp) * (yloc - ylocp)));
2361
2363 xlocp - radius, ylocp - radius,
2364 2 * radius, 2 * radius, 0, 23040);
2365 break;
2366
2367 case 4:
2368 gdk_draw_line(gCws->window, gGCecho, xlocp, ylocp, xloc, yloc);
2369 break;
2370
2371 case 5:
2373 TMath::Min(xlocp, xloc), TMath::Min(ylocp, yloc),
2374 TMath::Abs(xloc - xlocp), TMath::Abs(yloc - ylocp));
2375 break;
2376
2377 default:
2378 break;
2379 }
2380
2381 xloc = event->button.x;
2382 yloc = event->button.y;
2383
2384 switch (event->type) {
2385
2386 case GDK_LEAVE_NOTIFY:
2387 if (mode == 0) {
2388 while (1) {
2389 event = gdk_event_get();
2390
2391 if (event->type == GDK_ENTER_NOTIFY) {
2392 gdk_event_free(event);
2393 break;
2394 }
2395 gdk_event_free(event);
2396 }
2397 } else {
2398 button_press = -2;
2399 }
2400 break;
2401
2402 case GDK_BUTTON_PRESS:
2403 button_press = event->button.button;
2404 xlocp = event->button.x;
2405 ylocp = event->button.y;
2406 gdk_cursor_unref(cursor);
2407 cursor = 0;
2408 break;
2409
2410 case GDK_BUTTON_RELEASE:
2411 if (mode == 1) {
2412 button_press = 10 + event->button.button;
2413 xlocp = event->button.x;
2414 ylocp = event->button.y;
2415 }
2416 break;
2417
2418 case GDK_KEY_PRESS:
2419 if (mode == 1) {
2420 button_press = event->key.keyval;
2421 xlocp = event->button.x;
2422 ylocp = event->button.y;
2423 }
2424 break;
2425
2426 case GDK_KEY_RELEASE:
2427 if (mode == 1) {
2428 button_press = -1 * (int)(event->key.keyval);
2429 xlocp = event->button.x;
2430 ylocp = event->button.y;
2431 }
2432 break;
2433
2434 default:
2435 break;
2436 }
2437
2438 xtmp = event->button.x;
2439 ytmp = event->button.y;
2440
2441 gdk_event_free(event);
2442
2443 if (mode == 1) {
2444 if (button_press == 0) {
2445 button_press = -1;
2446 }
2447 break;
2448 }
2449 }
2451
2452 x = xtmp;
2453 y = ytmp;
2454
2455 return button_press;
2456}
2457
2458////////////////////////////////////////////////////////////////////////////////
2459/// Request a string.
2460/// x,y : position where text is displayed
2461/// text : text displayed (input), edited text (output)
2462///
2463/// Request string:
2464/// text is displayed and can be edited with Emacs-like keybinding
2465/// return termination code (0 for ESC, 1 for RETURN)
2466
2468{
2469 static GdkCursor *cursor = NULL;
2470 static int percent = 0; // bell volume
2471 static GdkWindow *CurWnd;
2472 HWND focuswindow;
2473 GdkEvent *event;
2474 KeySym keysym;
2475 int key = -1;
2476 int len_text = strlen(text);
2477 int nt; // defined length of text
2478 int pt; // cursor position in text
2479
2480 CurWnd = (GdkWindow *)gCws->window;
2481 // change the cursor shape
2482 if (cursor == NULL) {
2483 if (fUseSysPointers)
2484 cursor = gdk_syscursor_new((ULong_t)IDC_HELP);
2485 else
2486 cursor = gdk_cursor_new((GdkCursorType)GDK_QUESTION_ARROW);
2487 }
2488 if (cursor != 0) {
2489 gdk_window_set_cursor(CurWnd, cursor);
2490 }
2491 for (nt = len_text; nt > 0 && text[nt - 1] == ' '; nt--);
2492
2493 pt = nt;
2494 focuswindow = ::SetFocus((HWND)GDK_DRAWABLE_XID(CurWnd));
2495
2496 // Set max response time to 2 minutes to avoid timeout
2497 // in TGWin32ProxyBase::ForwardCallBack during RequestString
2501 do {
2502 char tmp[2];
2503 char keybuf[8];
2504 char nbytes;
2505 UInt_t dx, ddx, h;
2506 int i;
2507
2508 if (EventsPending()) {
2509 event = gdk_event_get();
2510 } else {
2512 ::SleepEx(10, kTRUE);
2513 continue;
2514 }
2515
2516 DrawText(x, y, 0.0, 1.0, text, kOpaque);
2518 DrawText(x+dx, y, 0.0, 1.0, " ", kOpaque);
2519
2520 if (pt == 0) {
2521 dx = 0;
2522 } else {
2523 char *stmp = new char[pt+1];
2524 strncpy(stmp, text, pt);
2525 stmp[pt] = '\0';
2526 TTF::GetTextExtent(ddx, h, stmp);
2527 dx = ddx;
2528 delete[] stmp;
2529 }
2530
2531 if (pt < len_text) {
2532 tmp[0] = text[pt];
2533 tmp[1] = '\0';
2534 DrawText(x+dx, y, 0.0, 1.0, tmp, kOpaque);
2535 } else {
2536 DrawText(x+dx, y, 0.0, 1.0, " ", kOpaque);
2537 }
2538
2539 if (event != NULL) {
2540 switch (event->type) {
2541 case GDK_BUTTON_PRESS:
2542 case GDK_ENTER_NOTIFY:
2543 focuswindow = ::SetFocus((HWND)GDK_DRAWABLE_XID(CurWnd));
2544 break;
2545
2546 case GDK_LEAVE_NOTIFY:
2547 ::SetFocus(focuswindow);
2548 break;
2549 case GDK_KEY_PRESS:
2550 nbytes = event->key.length;
2551 for (i = 0; i < nbytes; i++) {
2552 keybuf[i] = event->key.string[i];
2553 }
2554 keysym = event->key.keyval;
2555 switch (keysym) { // map cursor keys
2556 case GDK_BackSpace:
2557 keybuf[0] = 0x08; // backspace
2558 nbytes = 1;
2559 break;
2560 case GDK_Return:
2561 keybuf[0] = 0x0d; // return
2562 nbytes = 1;
2563 break;
2564 case GDK_Delete:
2565 keybuf[0] = 0x7f; // del
2566 nbytes = 1;
2567 break;
2568 case GDK_Escape:
2569 keybuf[0] = 0x1b; // esc
2570 nbytes = 1;
2571 break;
2572 case GDK_Home:
2573 keybuf[0] = 0x01; // home
2574 nbytes = 1;
2575 break;
2576 case GDK_Left:
2577 keybuf[0] = 0x02; // backward
2578 nbytes = 1;
2579 break;
2580 case GDK_Right:
2581 keybuf[0] = 0x06; // forward
2582 nbytes = 1;
2583 break;
2584 case GDK_End:
2585 keybuf[0] = 0x05; // end
2586 nbytes = 1;
2587 break;
2588 }
2589 if (nbytes == 1) {
2590 if (isascii(keybuf[0]) && isprint(keybuf[0])) {
2591 // insert character
2592 if (nt < len_text) {
2593 nt++;
2594 }
2595 for (i = nt - 1; i > pt; i--) {
2596 text[i] = text[i - 1];
2597 }
2598 if (pt < len_text) {
2599 text[pt] = keybuf[0];
2600 pt++;
2601 }
2602 } else {
2603 switch (keybuf[0]) {
2604 // Emacs-like editing keys
2605
2606 case 0x08: //'\010': // backspace
2607 case 0x7f: //'\177': // delete
2608 // delete backward
2609 if (pt > 0) {
2610 for (i = pt; i < nt; i++) {
2611 text[i - 1] = text[i];
2612 }
2613 text[nt - 1] = ' ';
2614 nt--;
2615 pt--;
2616 }
2617 break;
2618 case 0x01: //'\001': // ^A
2619 // beginning of line
2620 pt = 0;
2621 break;
2622 case 0x02: //'\002': // ^B
2623 // move backward
2624 if (pt > 0) {
2625 pt--;
2626 }
2627 break;
2628 case 0x04: //'\004': // ^D
2629 // delete forward
2630 if (pt > 0) {
2631 for (i = pt; i < nt; i++) {
2632 text[i - 1] = text[i];
2633 }
2634 text[nt - 1] = ' ';
2635 pt--;
2636 }
2637 break;
2638 case 0x05: //'\005': // ^E
2639 // end of line
2640 pt = nt;
2641 break;
2642
2643 case 0x06: //'\006': // ^F
2644 // move forward
2645 if (pt < nt) {
2646 pt++;
2647 }
2648 break;
2649 case 0x0b: //'\013': // ^K
2650 // delete to end of line
2651 for (i = pt; i < nt; i++)
2652 text[i] = ' ';
2653 nt = pt;
2654 break;
2655 case 0x14: //'\024': // ^T
2656 // transpose
2657 if (pt > 0) {
2658 char c = text[pt];
2659 text[pt] = text[pt - 1];
2660 text[pt - 1] = c;
2661 }
2662 break;
2663 case 0x0A: //'\012': // newline
2664 case 0x0D: //'\015': // return
2665 key = 1;
2666 break;
2667 case 0x1B: //'\033': // escape
2668 key = 0;
2669 break;
2670
2671 default:
2672 gSystem->Beep();
2673 break;
2674 }
2675 }
2676 }
2677 default:
2678 SetInputFocus((Window_t)gCws->window);
2679 break;
2680 }
2681 gdk_event_free(event);
2682 }
2683 } while (key < 0);
2685 ::SetFocus(focuswindow);
2686 SetInputFocus((Window_t)CurWnd);
2687
2688 gdk_window_set_cursor(CurWnd, (GdkCursor *)fCursors[kPointer]);
2689 if (cursor != 0) {
2690 gdk_cursor_unref(cursor);
2691 cursor = 0;
2692 }
2693
2694 return key;
2695}
2696
2697////////////////////////////////////////////////////////////////////////////////
2698/// Rescale the window wid.
2699/// wid : GdkWindow identifier
2700/// w : Width
2701/// h : Heigth
2702
2703void TGWin32::RescaleWindow(int wid, unsigned int w, unsigned int h)
2704{
2705 int i;
2706
2707 if (!fWindows) return;
2708
2709 gTws = &fWindows[wid];
2710 if (!gTws->open)
2711 return;
2712
2713 // don't do anything when size did not change
2714 if (gTws->width == w && gTws->height == h)
2715 return;
2716
2717 gdk_window_resize((GdkWindow *) gTws->window, w, h);
2718
2719 if (gTws->buffer) {
2720 // don't free and recreate pixmap when new pixmap is smaller
2721 if (gTws->width < w || gTws->height < h) {
2722 gdk_pixmap_unref(gTws->buffer);
2723 gTws->buffer = gdk_pixmap_new(GDK_ROOT_PARENT(), // NULL,
2724 w, h, gdk_visual_get_best_depth());
2725 }
2726 for (i = 0; i < kMAXGC; i++) {
2727 gdk_gc_set_clip_mask(gGClist[i], None);
2728 }
2729 SetColor(gGCpxmp, 0);
2730 gdk_win32_draw_rectangle(gTws->buffer, gGCpxmp, 1, 0, 0, w, h);
2731 SetColor(gGCpxmp, 1);
2732
2733 if (gTws->double_buffer) gTws->drawing = gTws->buffer;
2734 }
2735 gTws->width = w;
2736 gTws->height = h;
2737}
2738
2739////////////////////////////////////////////////////////////////////////////////
2740/// Resize a pixmap.
2741/// wid : pixmap to be resized
2742/// w,h : Width and height of the pixmap
2743
2744int TGWin32::ResizePixmap(int wid, unsigned int w, unsigned int h)
2745{
2746 int wval, hval;
2747 int i;
2748 int ww, hh, depth;
2749 wval = w;
2750 hval = h;
2751
2752 if (!fWindows) return 0;
2753
2754 gTws = &fWindows[wid];
2755
2756 // don't do anything when size did not change
2757 // if (gTws->width == wval && gTws->height == hval) return 0;
2758
2759 // due to round-off errors in TPad::Resize() we might get +/- 1 pixel
2760 // change, in those cases don't resize pixmap
2761 if (gTws->width >= wval - 1 && gTws->width <= wval + 1 &&
2762 gTws->height >= hval - 1 && gTws->height <= hval + 1)
2763 return 0;
2764
2765 // don't free and recreate pixmap when new pixmap is smaller
2766 if (gTws->width < wval || gTws->height < hval) {
2767 gdk_pixmap_unref((GdkPixmap *)gTws->window);
2768 depth = gdk_visual_get_best_depth();
2769 gTws->window = gdk_pixmap_new(GDK_ROOT_PARENT(), wval, hval, depth);
2770 }
2771
2772 gdk_drawable_get_size(gTws->window, &ww, &hh);
2773
2774 for (i = 0; i < kMAXGC; i++) {
2775 gdk_gc_set_clip_mask((GdkGC *) gGClist[i], (GdkDrawable *)None);
2776 }
2777
2778 SetColor(gGCpxmp, 0);
2779 gdk_win32_draw_rectangle(gTws->window,(GdkGC *)gGCpxmp, kTRUE, 0, 0, ww, hh);
2780 SetColor(gGCpxmp, 1);
2781
2782 // Initialise the window structure
2783 gTws->drawing = gTws->window;
2784 gTws->width = wval;
2785 gTws->height = hval;
2786 return 1;
2787}
2788
2789////////////////////////////////////////////////////////////////////////////////
2790/// Resize the current window if necessary.
2791
2793{
2794 int i;
2795 int xval = 0, yval = 0;
2796 GdkWindow *win, *root = NULL;
2797 int wval = 0, hval = 0, depth = 0;
2798
2799 if (!fWindows) return;
2800
2801 gTws = &fWindows[wid];
2802
2803 win = (GdkWindow *) gTws->window;
2804 gdk_window_get_geometry(win, &xval, &yval,
2805 &wval, &hval, &depth);
2806
2807 // don't do anything when size did not change
2808 if (gTws->width == wval && gTws->height == hval) {
2809 return;
2810 }
2811
2812 gdk_window_resize((GdkWindow *) gTws->window, wval, hval);
2813
2814 if (gTws->buffer) {
2815 if (gTws->width < wval || gTws->height < hval) {
2816 gdk_pixmap_unref((GdkPixmap *)gTws->buffer);
2817 depth = gdk_visual_get_best_depth();
2818 gTws->buffer = (GdkPixmap *) gdk_pixmap_new(GDK_ROOT_PARENT(),
2819 wval, hval, depth);
2820 }
2821
2822 for (i = 0; i < kMAXGC; i++) {
2823 gdk_gc_set_clip_mask((GdkGC *) gGClist[i], (GdkDrawable *)None);
2824 }
2825
2826 SetColor(gGCpxmp, 0);
2827 gdk_win32_draw_rectangle(gTws->buffer,(GdkGC *)gGCpxmp, kTRUE, 0, 0, wval, hval);
2828
2829 SetColor(gGCpxmp, 1);
2830
2831 if (gTws->double_buffer) gTws->drawing = gTws->buffer;
2832 }
2833
2834 gTws->width = wval;
2835 gTws->height = hval;
2836}
2837
2838////////////////////////////////////////////////////////////////////////////////
2839/// Select window to which subsequent output is directed.
2840
2842{
2843 int i;
2844 GdkRectangle rect;
2845
2846 if (!fWindows || wid < 0 || wid >= fMaxNumberOfWindows || !fWindows[wid].open) {
2847 return;
2848 }
2849
2850 gCws = &fWindows[wid];
2851
2852 if (gCws->clip && !gCws->ispixmap && !gCws->double_buffer) {
2853 rect.x = gCws->xclip;
2854 rect.y = gCws->yclip;
2855 rect.width = gCws->wclip;
2856 rect.height = gCws->hclip;
2857
2858 for (i = 0; i < kMAXGC; i++) {
2859 gdk_gc_set_clip_rectangle((GdkGC *) gGClist[i], &rect);
2860 }
2861 } else {
2862 for (i = 0; i < kMAXGC; i++) {
2863 gdk_gc_set_clip_mask((GdkGC *) gGClist[i], (GdkDrawable *)None);
2864 }
2865 }
2866}
2867
2868////////////////////////////////////////////////////////////////////////////////
2869/// Set character up vector.
2870
2872{
2873 if (chupx == fCharacterUpX && chupy == fCharacterUpY) return;
2874
2875 if (chupx == 0 && chupy == 0) {
2876 fTextAngle = 0;
2877 } else if (chupx == 0 && chupy == 1) {
2878 fTextAngle = 0;
2879 } else if (chupx == -1 && chupy == 0) {
2880 fTextAngle = 90;
2881 } else if (chupx == 0 && chupy == -1) {
2882 fTextAngle = 180;
2883 } else if (chupx == 1 && chupy == 0) {
2884 fTextAngle = 270;
2885 } else {
2886 fTextAngle =
2887 ((TMath::
2888 ACos(chupx / TMath::Sqrt(chupx * chupx + chupy * chupy)) *
2889 180.) / 3.14159) - 90;
2890 if (chupy < 0) fTextAngle = 180 - fTextAngle;
2891 if (TMath::Abs(fTextAngle) <= 0.01) fTextAngle = 0;
2892 }
2893 fCharacterUpX = chupx;
2894 fCharacterUpY = chupy;
2895}
2896
2897////////////////////////////////////////////////////////////////////////////////
2898/// Turn off the clipping for the window wid.
2899
2901{
2902 if (!fWindows) return;
2903
2904 gTws = &fWindows[wid];
2905 gTws->clip = 0;
2906
2907 for (int i = 0; i < kMAXGC; i++) {
2908 gdk_gc_set_clip_mask((GdkGC *) gGClist[i], (GdkDrawable *)None);
2909 }
2910}
2911
2912////////////////////////////////////////////////////////////////////////////////
2913/// Set clipping region for the window wid.
2914/// wid : GdkWindow indentifier
2915/// x,y : origin of clipping rectangle
2916/// w,h : size of clipping rectangle;
2917
2918void TGWin32::SetClipRegion(int wid, int x, int y, unsigned int w,
2919 unsigned int h)
2920{
2921 if (!fWindows) return;
2922
2923 gTws = &fWindows[wid];
2924 gTws->xclip = x;
2925 gTws->yclip = y;
2926 gTws->wclip = w;
2927 gTws->hclip = h;
2928 gTws->clip = 1;
2929 GdkRectangle rect;
2930
2931 if (gTws->clip && !gTws->ispixmap && !gTws->double_buffer) {
2932 rect.x = gTws->xclip;
2933 rect.y = gTws->yclip;
2934 rect.width = gTws->wclip;
2935 rect.height = gTws->hclip;
2936
2937 for (int i = 0; i < kMAXGC; i++) {
2938 gdk_gc_set_clip_rectangle((GdkGC *)gGClist[i], &rect);
2939 }
2940 }
2941}
2942
2943////////////////////////////////////////////////////////////////////////////////
2944/// Return pixel value associated to specified ROOT color number.
2945
2947{
2948 TColor *color = gROOT->GetColor(ci);
2949 if (color)
2950 SetRGB(ci, color->GetRed(), color->GetGreen(), color->GetBlue());
2951 XColor_t &col = GetColor(ci);
2952 return col.color.pixel;
2953}
2954
2955////////////////////////////////////////////////////////////////////////////////
2956/// Set the foreground color in GdkGC.
2957
2958void TGWin32::SetColor(GdkGC *gc, int ci)
2959{
2960 GdkGCValues gcvals;
2961 GdkColor color;
2962
2963 if (ci<=0) ci = 10; //white
2964
2965 TColor *clr = gROOT->GetColor(ci);
2966 if (clr)
2967 SetRGB(ci, clr->GetRed(), clr->GetGreen(), clr->GetBlue());
2968
2969 XColor_t &col = GetColor(ci);
2970 if (fColormap && !col.fDefined) {
2971 col = GetColor(0);
2972 } else if (!fColormap && (ci < 0 || ci > 1)) {
2973 col = GetColor(0);
2974 }
2975
2976 if (fDrawMode == kXor) {
2977 gdk_gc_get_values(gc, &gcvals);
2978
2979 color.pixel = col.color.pixel ^ gcvals.background.pixel;
2980 color.red = GetRValue(color.pixel);
2981 color.green = GetGValue(color.pixel);
2982 color.blue = GetBValue(color.pixel);
2983 gdk_gc_set_foreground(gc, &color);
2984
2985 } else {
2986 gdk_gc_set_foreground(gc, &col.color);
2987
2988 // make sure that foreground and background are different
2989 gdk_gc_get_values(gc, &gcvals);
2990
2991 if (gcvals.foreground.pixel != gcvals.background.pixel) {
2992 gdk_gc_set_background(gc, &GetColor(!ci).color);
2993 }
2994 }
2995}
2996
2997////////////////////////////////////////////////////////////////////////////////
2998/// Set the cursor.
2999
3000void TGWin32::SetCursor(int wid, ECursor cursor)
3001{
3002 if (!fWindows) return;
3003
3004 gTws = &fWindows[wid];
3005 gdk_window_set_cursor((GdkWindow *)gTws->window, (GdkCursor *)fCursors[cursor]);
3006}
3007
3008////////////////////////////////////////////////////////////////////////////////
3009/// Set the specified cursor.
3010
3012{
3013 if (!id) return;
3014
3015 static GdkWindow *lid = 0;
3016 static GdkCursor *lcur = 0;
3017
3018 if ((lid == (GdkWindow *)id) && (lcur==(GdkCursor *)curid)) return;
3019 lid = (GdkWindow *)id;
3020 lcur = (GdkCursor *)curid;
3021
3022 gdk_window_set_cursor((GdkWindow *) id, (GdkCursor *)curid);
3023}
3024
3025////////////////////////////////////////////////////////////////////////////////
3026/// Set the double buffer on/off on window wid.
3027/// wid : GdkWindow identifier.
3028/// 999 means all the opened windows.
3029/// mode : 1 double buffer is on
3030/// 0 double buffer is off
3031
3032void TGWin32::SetDoubleBuffer(int wid, int mode)
3033{
3034 if (!fWindows) return;
3035
3036 if (wid == 999) {
3037 for (int i = 0; i < fMaxNumberOfWindows; i++) {
3038 gTws = &fWindows[i];
3039 if (gTws->open) {
3040 switch (mode) {
3041 case 1:
3043 break;
3044 default:
3046 break;
3047 }
3048 }
3049 }
3050 } else {
3051 gTws = &fWindows[wid];
3052 if (!gTws->open) return;
3053
3054 switch (mode) {
3055 case 1:
3057 return;
3058 default:
3060 return;
3061 }
3062 }
3063}
3064
3065////////////////////////////////////////////////////////////////////////////////
3066/// Turn double buffer mode off.
3067
3069{
3070 if (!gTws->double_buffer) return;
3071 gTws->double_buffer = 0;
3072 gTws->drawing = gTws->window;
3073}
3074
3075////////////////////////////////////////////////////////////////////////////////
3076/// Turn double buffer mode on.
3077
3079{
3080 if (!fWindows || gTws->double_buffer || gTws->ispixmap) return;
3081
3082 if (!gTws->buffer) {
3083 gTws->buffer = gdk_pixmap_new(GDK_ROOT_PARENT(), //NULL,
3084 gTws->width, gTws->height,
3085 gdk_visual_get_best_depth());
3086 SetColor(gGCpxmp, 0);
3087 gdk_win32_draw_rectangle(gTws->buffer, gGCpxmp, 1, 0, 0, gTws->width,
3088 gTws->height);
3089 SetColor(gGCpxmp, 1);
3090 }
3091 for (int i = 0; i < kMAXGC; i++) {
3092 gdk_gc_set_clip_mask(gGClist[i], None);
3093 }
3094 gTws->double_buffer = 1;
3095 gTws->drawing = gTws->buffer;
3096}
3097
3098////////////////////////////////////////////////////////////////////////////////
3099/// Set the drawing mode.
3100/// mode : drawing mode
3101/// mode=1 copy
3102/// mode=2 xor
3103/// mode=3 invert
3104/// mode=4 set the suitable mode for cursor echo according to
3105/// the vendor
3106
3108{
3109 int i;
3110
3111 switch (mode) {
3112 case kCopy:
3113 for (i = 0; i < kMAXGC; i++) {
3114 gdk_gc_set_function(gGClist[i], GDK_COPY);
3115 }
3116 break;
3117
3118 case kXor:
3119 for (i = 0; i < kMAXGC; i++) {
3120 gdk_gc_set_function(gGClist[i], GDK_XOR);
3121 }
3122 break;
3123
3124 case kInvert:
3125 for (i = 0; i < kMAXGC; i++) {
3126 gdk_gc_set_function(gGClist[i], GDK_INVERT);
3127 }
3128 break;
3129 }
3130 fDrawMode = mode;
3131}
3132
3133////////////////////////////////////////////////////////////////////////////////
3134/// Set color index for fill areas.
3135
3137{
3138 Int_t indx = Int_t(cindex);
3139
3140 if (!gStyle->GetFillColor() && cindex > 1) {
3141 indx = 0;
3142 }
3143
3144 fFillColor = indx;
3146}
3147
3148////////////////////////////////////////////////////////////////////////////////
3149///
3150
3152{
3153 if (fFillColor >= 0) {
3155 }
3156
3157 // invalidate fill pattern
3158 if (gFillPattern != NULL) {
3159 gdk_pixmap_unref(gFillPattern);
3160 gFillPattern = NULL;
3161 }
3163}
3164
3165////////////////////////////////////////////////////////////////////////////////
3166/// Set fill area style.
3167/// fstyle : compound fill area interior style
3168/// fstyle = 1000*interiorstyle + styleindex
3169
3171{
3172 if (fFillStyle==fstyle) return;
3173
3174 fFillStyle = fstyle;
3176}
3177
3178////////////////////////////////////////////////////////////////////////////////
3179/// Set fill area style index.
3180
3182{
3183 static int current_fasi = 0;
3184
3185 Int_t style = fFillStyle / 1000;
3186 Int_t fasi = fFillStyle % 1000;
3187
3188 switch (style) {
3189
3190 case 1: // solid
3191 gFillHollow = 0;
3192 gdk_gc_set_fill(gGCfill, GDK_SOLID);
3193 break;
3194
3195 case 2: // pattern
3196 gFillHollow = 1;
3197 break;
3198
3199 case 3: // hatch
3200 gFillHollow = 0;
3201 gdk_gc_set_fill(gGCfill, GDK_STIPPLED);
3202
3203 if (fasi != current_fasi) {
3204 if (gFillPattern != NULL) {
3205 gdk_pixmap_unref(gFillPattern);
3206 gFillPattern = NULL;
3207 }
3208 int stn = (fasi >= 1 && fasi <=25) ? fasi : 2;
3209 gFillPattern = gdk_bitmap_create_from_data(GDK_ROOT_PARENT(),
3210 (const char *)gStipples[stn], 16, 16);
3211 gdk_gc_set_stipple(gGCfill, gFillPattern);
3212 current_fasi = fasi;
3213 }
3214 break;
3215
3216 default:
3217 gFillHollow = 1;
3218 }
3219
3221}
3222
3223////////////////////////////////////////////////////////////////////////////////
3224/// Set input on or off.
3225
3227{
3228 EnableWindow((HWND) GDK_DRAWABLE_XID(gCws->window), inp);
3229}
3230
3231////////////////////////////////////////////////////////////////////////////////
3232/// Set color index for lines.
3233
3235{
3236 if ((cindex < 0) || (cindex==fLineColor)) return;
3237
3238 fLineColor = cindex;
3240}
3241
3242////////////////////////////////////////////////////////////////////////////////
3243///
3244
3246{
3250}
3251
3252////////////////////////////////////////////////////////////////////////////////
3253/// Set line type.
3254/// n : length of dash list
3255/// dash(n) : dash segment lengths
3256///
3257/// if n <= 0 use solid lines
3258/// if n > 0 use dashed lines described by DASH(N)
3259/// e.g. N=4,DASH=(6,3,1,3) gives a dashed-dotted line with dash length 6
3260/// and a gap of 7 between dashes
3261
3262void TGWin32::SetLineType(int n, int *dash)
3263{
3264 if (n <= 0) {
3265 gLineStyle = GDK_LINE_SOLID;
3266 gdk_gc_set_line_attributes(gGCline, gLineWidth,
3267 (GdkLineStyle)gLineStyle,
3268 (GdkCapStyle) gCapStyle,
3269 (GdkJoinStyle) gJoinStyle);
3270 } else {
3271 int i;
3272 gDashSize = TMath::Min((int)sizeof(gDashList),n);
3273 gDashLength = 0;
3274 for (i = 0; i < gDashSize; i++) {
3275 gDashList[i] = dash[i];
3276 gDashLength += gDashList[i];
3277 }
3278 gDashOffset = 0;
3279 gLineStyle = GDK_LINE_ON_OFF_DASH;
3280 if (gLineWidth == 0) gLineWidth =1;
3281 gdk_gc_set_line_attributes(gGCdash, gLineWidth,
3282 (GdkLineStyle) gLineStyle,
3283 (GdkCapStyle) gCapStyle,
3284 (GdkJoinStyle) gJoinStyle);
3285 }
3287}
3288
3289////////////////////////////////////////////////////////////////////////////////
3290/// Set line style.
3291
3293{
3294 if (fLineStyle == lstyle) return;
3295
3296 fLineStyle = lstyle;
3298}
3299
3300////////////////////////////////////////////////////////////////////////////////
3301/// Update line style
3302
3304{
3305 static Int_t dashed[2] = { 3, 3 };
3306 static Int_t dotted[2] = { 1, 2 };
3307 static Int_t dasheddotted[4] = { 3, 4, 1, 4 };
3308
3309 if (fLineStyle <= 1) {
3310 SetLineType(0, 0);
3311 } else if (fLineStyle == 2) {
3312 SetLineType(2, dashed);
3313 } else if (fLineStyle == 3) {
3314 SetLineType(2, dotted);
3315 } else if (fLineStyle == 4) {
3316 SetLineType(4, dasheddotted);
3317 } else {
3319 TObjArray *tokens = st.Tokenize(" ");
3320 Int_t nt;
3321 nt = tokens->GetEntries();
3322 Int_t *linestyle = new Int_t[nt];
3323 for (Int_t j = 0; j<nt; j++) {
3324 Int_t it;
3325 sscanf(((TObjString*)tokens->At(j))->GetName(), "%d", &it);
3326 linestyle[j] = (Int_t)(it/4);
3327 }
3328 SetLineType(nt,linestyle);
3329 delete [] linestyle;
3330 delete tokens;
3331 }
3333}
3334
3335////////////////////////////////////////////////////////////////////////////////
3336/// Set line width.
3337/// width : line width in pixels
3338
3340{
3341 if (fLineWidth == width) return;
3342 fLineWidth = width;
3343
3344 if (width == 1 && gLineStyle == GDK_LINE_SOLID) gLineWidth = 0;
3345 else gLineWidth = width;
3346
3348}
3349
3350////////////////////////////////////////////////////////////////////////////////
3351/// Set color index for markers.
3352
3354{
3355 if ((cindex<0) || (cindex==fMarkerColor)) return;
3356 fMarkerColor = cindex;
3358}
3359
3360////////////////////////////////////////////////////////////////////////////////
3361///
3362
3364{
3367}
3368
3369////////////////////////////////////////////////////////////////////////////////
3370/// Set marker size index.
3371/// msize : marker scale factor
3372
3374{
3375 if ((msize==fMarkerSize) || (msize<0)) return;
3376
3377 fMarkerSize = msize;
3379}
3380
3381////////////////////////////////////////////////////////////////////////////////
3382/// Set marker type.
3383/// type : marker type
3384/// n : length of marker description
3385/// xy : list of points describing marker shape
3386///
3387/// if n == 0 marker is a single point
3388/// if TYPE == 0 marker is hollow circle of diameter N
3389/// if TYPE == 1 marker is filled circle of diameter N
3390/// if TYPE == 2 marker is a hollow polygon describe by line XY
3391/// if TYPE == 3 marker is a filled polygon describe by line XY
3392/// if TYPE == 4 marker is described by segmented line XY
3393/// e.g. TYPE=4,N=4,XY=(-3,0,3,0,0,-3,0,3) sets a plus shape of 7x7 pixels
3394
3395void TGWin32::SetMarkerType(int type, int n, GdkPoint * xy)
3396{
3397 gMarker.type = type;
3398 gMarker.n = n < kMAXMK ? n : kMAXMK;
3399 if (gMarker.type >= 2) {
3400 for (int i = 0; i < gMarker.n; i++) {
3401 gMarker.xy[i] = xy[i];
3402 }
3403 }
3404}
3405
3406////////////////////////////////////////////////////////////////////////////////
3407/// Set marker style.
3408
3410{
3411 if ((fMarkerStyle == markerstyle) || (markerstyle >= 50)) return;
3412 fMarkerStyle = TMath::Abs(markerstyle);
3414}
3415
3416////////////////////////////////////////////////////////////////////////////////
3417///
3418
3420{
3421 static GdkPoint shape[30];
3422
3423 Int_t im = Int_t(4 * fMarkerSize + 0.5);
3424
3425 if (fMarkerStyle == 2) {
3426 // + shaped marker
3427 shape[0].x = -im;
3428 shape[0].y = 0;
3429 shape[1].x = im;
3430 shape[1].y = 0;
3431 shape[2].x = 0;
3432 shape[2].y = -im;
3433 shape[3].x = 0;
3434 shape[3].y = im;
3435 SetMarkerType(4, 4, shape);
3436 } else if (fMarkerStyle == 3 || fMarkerStyle == 31) {
3437 // * shaped marker
3438 shape[0].x = -im;
3439 shape[0].y = 0;
3440 shape[1].x = im;
3441 shape[1].y = 0;
3442 shape[2].x = 0;
3443 shape[2].y = -im;
3444 shape[3].x = 0;
3445 shape[3].y = im;
3446 im = Int_t(0.707 * Float_t(im) + 0.5);
3447 shape[4].x = -im;
3448 shape[4].y = -im;
3449 shape[5].x = im;
3450 shape[5].y = im;
3451 shape[6].x = -im;
3452 shape[6].y = im;
3453 shape[7].x = im;
3454 shape[7].y = -im;
3455 SetMarkerType(4, 8, shape);
3456 } else if (fMarkerStyle == 4 || fMarkerStyle == 24) {
3457 // O shaped marker
3458 SetMarkerType(0, im * 2, shape);
3459 } else if (fMarkerStyle == 5) {
3460 // X shaped marker
3461 im = Int_t(0.707 * Float_t(im) + 0.5);
3462 shape[0].x = -im;
3463 shape[0].y = -im;
3464 shape[1].x = im;
3465 shape[1].y = im;
3466 shape[2].x = -im;
3467 shape[2].y = im;
3468 shape[3].x = im;
3469 shape[3].y = -im;
3470 SetMarkerType(4, 4, shape);
3471 } else if (fMarkerStyle == 6) {
3472 // + shaped marker (with 1 pixel)
3473 shape[0].x = -1;
3474 shape[0].y = 0;
3475 shape[1].x = 1;
3476 shape[1].y = 0;
3477 shape[2].x = 0;
3478 shape[2].y = -1;
3479 shape[3].x = 0;
3480 shape[3].y = 1;
3481 SetMarkerType(4, 4, shape);
3482 } else if (fMarkerStyle == 7) {
3483 // . shaped marker (with 9 pixel)
3484 shape[0].x = -1;
3485 shape[0].y = 1;
3486 shape[1].x = 1;
3487 shape[1].y = 1;
3488 shape[2].x = -1;
3489 shape[2].y = 0;
3490 shape[3].x = 1;
3491 shape[3].y = 0;
3492 shape[4].x = -1;
3493 shape[4].y = -1;
3494 shape[5].x = 1;
3495 shape[5].y = -1;
3496 SetMarkerType(4, 6, shape);
3497 } else if (fMarkerStyle == 8 || fMarkerStyle == 20) {
3498 // O shaped marker (filled)
3499 SetMarkerType(1, im * 2, shape);
3500 } else if (fMarkerStyle == 21) {
3501 // full square
3502 shape[0].x = -im;
3503 shape[0].y = -im;
3504 shape[1].x = im;
3505 shape[1].y = -im;
3506 shape[2].x = im;
3507 shape[2].y = im;
3508 shape[3].x = -im;
3509 shape[3].y = im;
3510 shape[4].x = -im;
3511 shape[4].y = -im;
3512 SetMarkerType(3, 5, shape);
3513 } else if (fMarkerStyle == 22) {
3514 // full triangle up
3515 shape[0].x = -im;
3516 shape[0].y = im;
3517 shape[1].x = im;
3518 shape[1].y = im;
3519 shape[2].x = 0;
3520 shape[2].y = -im;
3521 shape[3].x = -im;
3522 shape[3].y = im;
3523 SetMarkerType(3, 4, shape);
3524 } else if (fMarkerStyle == 23) {
3525 // full triangle down
3526 shape[0].x = 0;
3527 shape[0].y = im;
3528 shape[1].x = im;
3529 shape[1].y = -im;
3530 shape[2].x = -im;
3531 shape[2].y = -im;
3532 shape[3].x = 0;
3533 shape[3].y = im;
3534 SetMarkerType(3, 4, shape);
3535 } else if (fMarkerStyle == 25) {
3536 // open square
3537 shape[0].x = -im;
3538 shape[0].y = -im;
3539 shape[1].x = im;
3540 shape[1].y = -im;
3541 shape[2].x = im;
3542 shape[2].y = im;
3543 shape[3].x = -im;
3544 shape[3].y = im;
3545 shape[4].x = -im;
3546 shape[4].y = -im;
3547 SetMarkerType(2, 5, shape);
3548 } else if (fMarkerStyle == 26) {
3549 // open triangle up
3550 shape[0].x = -im;
3551 shape[0].y = im;
3552 shape[1].x = im;
3553 shape[1].y = im;
3554 shape[2].x = 0;
3555 shape[2].y = -im;
3556 shape[3].x = -im;
3557 shape[3].y = im;
3558 SetMarkerType(2, 4, shape);
3559 } else if (fMarkerStyle == 27) {
3560 // open losange
3561 Int_t imx = Int_t(2.66 * fMarkerSize + 0.5);
3562 shape[0].x = -imx;
3563 shape[0].y = 0;
3564 shape[1].x = 0;
3565 shape[1].y = -im;
3566 shape[2].x = imx;
3567 shape[2].y = 0;
3568 shape[3].x = 0;
3569 shape[3].y = im;
3570 shape[4].x = -imx;
3571 shape[4].y = 0;
3572 SetMarkerType(2, 5, shape);
3573 } else if (fMarkerStyle == 28) {
3574 // open cross
3575 Int_t imx = Int_t(1.33 * fMarkerSize + 0.5);
3576 shape[0].x = -im;
3577 shape[0].y = -imx;
3578 shape[1].x = -imx;
3579 shape[1].y = -imx;
3580 shape[2].x = -imx;
3581 shape[2].y = -im;
3582 shape[3].x = imx;
3583 shape[3].y = -im;
3584 shape[4].x = imx;
3585 shape[4].y = -imx;
3586 shape[5].x = im;
3587 shape[5].y = -imx;
3588 shape[6].x = im;
3589 shape[6].y = imx;
3590 shape[7].x = imx;
3591 shape[7].y = imx;
3592 shape[8].x = imx;
3593 shape[8].y = im;
3594 shape[9].x = -imx;
3595 shape[9].y = im;
3596 shape[10].x = -imx;
3597 shape[10].y = imx;
3598 shape[11].x = -im;
3599 shape[11].y = imx;
3600 shape[12].x = -im;
3601 shape[12].y = -imx;
3602 SetMarkerType(2, 13, shape);
3603 } else if (fMarkerStyle == 29) {
3604 // full star pentagone
3605 Int_t im1 = Int_t(0.66 * fMarkerSize + 0.5);
3606 Int_t im2 = Int_t(2.00 * fMarkerSize + 0.5);
3607 Int_t im3 = Int_t(2.66 * fMarkerSize + 0.5);
3608 Int_t im4 = Int_t(1.33 * fMarkerSize + 0.5);
3609 shape[0].x = -im;
3610 shape[0].y = im4;
3611 shape[1].x = -im2;
3612 shape[1].y = -im1;
3613 shape[2].x = -im3;
3614 shape[2].y = -im;
3615 shape[3].x = 0;
3616 shape[3].y = -im2;
3617 shape[4].x = im3;
3618 shape[4].y = -im;
3619 shape[5].x = im2;
3620 shape[5].y = -im1;
3621 shape[6].x = im;
3622 shape[6].y = im4;
3623 shape[7].x = im4;
3624 shape[7].y = im4;
3625 shape[8].x = 0;
3626 shape[8].y = im;
3627 shape[9].x = -im4;
3628 shape[9].y = im4;
3629 shape[10].x = -im;
3630 shape[10].y = im4;
3631 SetMarkerType(3, 11, shape);
3632 } else if (fMarkerStyle == 30) {
3633 // open star pentagone
3634 Int_t im1 = Int_t(0.66 * fMarkerSize + 0.5);
3635 Int_t im2 = Int_t(2.00 * fMarkerSize + 0.5);
3636 Int_t im3 = Int_t(2.66 * fMarkerSize + 0.5);
3637 Int_t im4 = Int_t(1.33 * fMarkerSize + 0.5);
3638 shape[0].x = -im;
3639 shape[0].y = im4;
3640 shape[1].x = -im2;
3641 shape[1].y = -im1;
3642 shape[2].x = -im3;
3643 shape[2].y = -im;
3644 shape[3].x = 0;
3645 shape[3].y = -im2;
3646 shape[4].x = im3;
3647 shape[4].y = -im;
3648 shape[5].x = im2;
3649 shape[5].y = -im1;
3650 shape[6].x = im;
3651 shape[6].y = im4;
3652 shape[7].x = im4;
3653 shape[7].y = im4;
3654 shape[8].x = 0;
3655 shape[8].y = im;
3656 shape[9].x = -im4;
3657 shape[9].y = im4;
3658 shape[10].x = -im;
3659 shape[10].y = im4;
3660 SetMarkerType(2, 11, shape);
3661 } else if (fMarkerStyle == 32) {
3662 // open triangle down
3663 shape[0].x = 0; shape[0].y = im;
3664 shape[1].x = im; shape[1].y = -im;
3665 shape[2].x = -im; shape[2].y = -im;
3666 shape[3].x = 0; shape[3].y = im;
3667 SetMarkerType(2,4,shape);
3668 } else if (fMarkerStyle == 33) {
3669 // full losange
3670 Int_t imx = Int_t(2.66*fMarkerSize + 0.5);
3671 shape[0].x =-imx; shape[0].y = 0;
3672 shape[1].x = 0; shape[1].y = -im;
3673 shape[2].x = imx; shape[2].y = 0;
3674 shape[3].x = 0; shape[3].y = im;
3675 shape[4].x =-imx; shape[4].y = 0;
3676 SetMarkerType(3,5,shape);
3677 } else if (fMarkerStyle == 34) {
3678 // full cross
3679 Int_t imx = Int_t(1.33*fMarkerSize + 0.5);
3680 shape[0].x = -im; shape[0].y =-imx;
3681 shape[1].x =-imx; shape[1].y =-imx;
3682 shape[2].x =-imx; shape[2].y = -im;
3683 shape[3].x = imx; shape[3].y = -im;
3684 shape[4].x = imx; shape[4].y =-imx;
3685 shape[5].x = im; shape[5].y =-imx;
3686 shape[6].x = im; shape[6].y = imx;
3687 shape[7].x = imx; shape[7].y = imx;
3688 shape[8].x = imx; shape[8].y = im;
3689 shape[9].x =-imx; shape[9].y = im;
3690 shape[10].x=-imx; shape[10].y= imx;
3691 shape[11].x= -im; shape[11].y= imx;
3692 shape[12].x= -im; shape[12].y=-imx;
3693 SetMarkerType(3,13,shape);
3694 } else if (fMarkerStyle == 35) {
3695 // square with diagonal cross
3696 shape[0].x = -im; shape[0].y = -im;
3697 shape[1].x = im; shape[1].y = -im;
3698 shape[2].x = im; shape[2].y = im;
3699 shape[3].x = -im; shape[3].y = im;
3700 shape[4].x = -im; shape[4].y = -im;
3701 shape[5].x = im; shape[5].y = im;
3702 shape[6].x = -im; shape[6].y = im;
3703 shape[7].x = im; shape[7].y = -im;
3704 SetMarkerType(2,8,shape);
3705 } else if (fMarkerStyle == 36) {
3706 // diamond with cross
3707 shape[0].x =-im; shape[0].y = 0;
3708 shape[1].x = 0; shape[1].y = -im;
3709 shape[2].x = im; shape[2].y = 0;
3710 shape[3].x = 0; shape[3].y = im;
3711 shape[4].x =-im; shape[4].y = 0;
3712 shape[5].x = im; shape[5].y = 0;
3713 shape[6].x = 0; shape[6].y = im;
3714 shape[7].x = 0; shape[7].y =-im;
3715 SetMarkerType(2,8,shape);
3716 } else if (fMarkerStyle == 37) {
3717 // open three triangles
3718 Int_t im2 = Int_t(2.0*fMarkerSize + 0.5);
3719 shape[0].x = 0; shape[0].y = 0;
3720 shape[1].x =-im2; shape[1].y = im;
3721 shape[2].x = -im; shape[2].y = 0;
3722 shape[3].x = 0; shape[3].y = 0;
3723 shape[4].x =-im2; shape[4].y = -im;
3724 shape[5].x = im2; shape[5].y = -im;
3725 shape[6].x = 0; shape[6].y = 0;
3726 shape[7].x = im; shape[7].y = 0;
3727 shape[8].x = im2; shape[8].y = im;
3728 shape[9].x = 0; shape[9].y = 0;
3729 SetMarkerType(2,10,shape);
3730 } else if (fMarkerStyle == 38) {
3731 // + shaped marker with octagon
3732 Int_t im2 = Int_t(2.0*fMarkerSize + 0.5);
3733 shape[0].x = -im; shape[0].y = 0;
3734 shape[1].x = -im; shape[1].y =-im2;
3735 shape[2].x =-im2; shape[2].y =-im;
3736 shape[3].x = im2; shape[3].y = -im;
3737 shape[4].x = im; shape[4].y =-im2;
3738 shape[5].x = im; shape[5].y = im2;
3739 shape[6].x = im2; shape[6].y = im;
3740 shape[7].x =-im2; shape[7].y = im;
3741 shape[8].x = -im; shape[8].y = im2;
3742 shape[9].x = -im; shape[9].y = 0;
3743 shape[10].x = im; shape[10].y = 0;
3744 shape[11].x = 0; shape[11].y = 0;
3745 shape[12].x = 0; shape[12].y = -im;
3746 shape[13].x = 0; shape[13].y = im;
3747 shape[14].x = 0; shape[14].y = 0;
3748 SetMarkerType(2,15,shape);
3749 } else if (fMarkerStyle == 39) {
3750 // filled three triangles
3751 Int_t im2 = Int_t(2.0*fMarkerSize + 0.5);
3752 shape[0].x = 0; shape[0].y = 0;
3753 shape[1].x =-im2; shape[1].y = im;
3754 shape[2].x = -im; shape[2].y = 0;
3755 shape[3].x = 0; shape[3].y = 0;
3756 shape[4].x =-im2; shape[4].y = -im;
3757 shape[5].x = im2; shape[5].y = -im;
3758 shape[6].x = 0; shape[6].y = 0;
3759 shape[7].x = im; shape[7].y = 0;
3760 shape[8].x = im2; shape[8].y = im;
3761 SetMarkerType(3,9,shape);
3762 } else if (fMarkerStyle == 40) {
3763 // four open triangles X
3764 Int_t im2 = Int_t(2.0*fMarkerSize + 0.5);
3765 shape[0].x = 0; shape[0].y = 0;
3766 shape[1].x = im2; shape[1].y = im;
3767 shape[2].x = im; shape[2].y = im2;
3768 shape[3].x = 0; shape[3].y = 0;
3769 shape[4].x = im; shape[4].y = -im2;
3770 shape[5].x = im2; shape[5].y = -im;
3771 shape[6].x = 0; shape[6].y = 0;
3772 shape[7].x = -im2; shape[7].y = -im;
3773 shape[8].x = -im; shape[8].y = -im2;
3774 shape[9].x = 0; shape[9].y = 0;
3775 shape[10].x = -im; shape[10].y = im2;
3776 shape[11].x = -im2; shape[11].y = im;
3777 shape[12].x = 0; shape[12].y = 0;
3778 SetMarkerType(2,13,shape);
3779 } else if (fMarkerStyle == 41) {
3780 // four filled triangles X
3781 Int_t im2 = Int_t(2.0*fMarkerSize + 0.5);
3782 shape[0].x = 0; shape[0].y = 0;
3783 shape[1].x = im2; shape[1].y = im;
3784 shape[2].x = im; shape[2].y = im2;
3785 shape[3].x = 0; shape[3].y = 0;
3786 shape[4].x = im; shape[4].y = -im2;
3787 shape[5].x = im2; shape[5].y = -im;
3788 shape[6].x = 0; shape[6].y = 0;
3789 shape[7].x = -im2; shape[7].y = -im;
3790 shape[8].x = -im; shape[8].y = -im2;
3791 shape[9].x = 0; shape[9].y = 0;
3792 shape[10].x = -im; shape[10].y = im2;
3793 shape[11].x = -im2; shape[11].y = im;
3794 shape[12].x = 0; shape[12].y = 0;
3795 SetMarkerType(3,13,shape);
3796 } else if (fMarkerStyle == 42) {
3797 // open double diamonds
3798 Int_t imx = Int_t(fMarkerSize + 0.5);
3799 shape[0].x= 0; shape[0].y= im;
3800 shape[1].x= -imx; shape[1].y= imx;
3801 shape[2].x = -im; shape[2].y = 0;
3802 shape[3].x = -imx; shape[3].y = -imx;
3803 shape[4].x = 0; shape[4].y = -im;
3804 shape[5].x = imx; shape[5].y = -imx;
3805 shape[6].x = im; shape[6].y = 0;
3806 shape[7].x= imx; shape[7].y= imx;
3807 shape[8].x= 0; shape[8].y= im;
3808 SetMarkerType(2,9,shape);
3809 } else if (fMarkerStyle == 43) {
3810 // filled double diamonds
3811 Int_t imx = Int_t(fMarkerSize + 0.5);
3812 shape[0].x = 0; shape[0].y = im;
3813 shape[1].x = -imx; shape[1].y = imx;
3814 shape[2].x = -im; shape[2].y = 0;
3815 shape[3].x = -imx; shape[3].y = -imx;
3816 shape[4].x = 0; shape[4].y = -im;
3817 shape[5].x = imx; shape[5].y = -imx;
3818 shape[6].x = im; shape[6].y = 0;
3819 shape[7].x = imx; shape[7].y = imx;
3820 shape[8].x = 0; shape[8].y = im;
3821 SetMarkerType(3,9,shape);
3822 } else if (fMarkerStyle == 44) {
3823 // open four triangles plus
3824 Int_t im2 = Int_t(2.0*fMarkerSize + 0.5);
3825 shape[0].x = 0; shape[0].y = 0;
3826 shape[1].x = im2; shape[1].y = im;
3827 shape[2].x = -im2; shape[2].y = im;
3828 shape[3].x = im2; shape[3].y = -im;
3829 shape[4].x = -im2; shape[4].y = -im;
3830 shape[5].x = 0; shape[5].y = 0;
3831 shape[6].x = im; shape[6].y = im2;
3832 shape[7].x = im; shape[7].y = -im2;
3833 shape[8].x = -im; shape[8].y = im2;
3834 shape[9].x = -im; shape[9].y = -im2;
3835 shape[10].x = 0; shape[10].y = 0;
3836 SetMarkerType(2,11,shape);
3837 } else if (fMarkerStyle == 45) {
3838 // filled four triangles plus
3839 Int_t im0 = Int_t(0.4*fMarkerSize + 0.5);
3840 Int_t im2 = Int_t(2.0*fMarkerSize + 0.5);
3841 shape[0].x = im0; shape[0].y = im0;
3842 shape[1].x = im2; shape[1].y = im;
3843 shape[2].x = -im2; shape[2].y = im;
3844 shape[3].x = -im0; shape[3].y = im0;
3845 shape[4].x = -im; shape[4].y = im2;
3846 shape[5].x = -im; shape[5].y = -im2;
3847 shape[6].x = -im0; shape[6].y = -im0;
3848 shape[7].x = -im2; shape[7].y = -im;
3849 shape[8].x = im2; shape[8].y = -im;
3850 shape[9].x = im0; shape[9].y = -im0;
3851 shape[10].x = im; shape[10].y = -im2;
3852 shape[11].x = im; shape[11].y = im2;
3853 shape[12].x = im0; shape[12].y = im0;
3854 SetMarkerType(3,13,shape);
3855 } else if (fMarkerStyle == 46) {
3856 // open four triangles X
3857 Int_t im2 = Int_t(2.0*fMarkerSize + 0.5);
3858 shape[0].x = 0; shape[0].y = im2;
3859 shape[1].x = -im2; shape[1].y = im;
3860 shape[2].x = -im; shape[2].y = im2;
3861 shape[3].x = -im2; shape[3].y = 0;
3862 shape[4].x = -im; shape[4].y = -im2;
3863 shape[5].x = -im2; shape[5].y = -im;
3864 shape[6].x = 0; shape[6].y = -im2;
3865 shape[7].x = im2; shape[7].y = -im;
3866 shape[8].x = im; shape[8].y = -im2;
3867 shape[9].x = im2; shape[9].y = 0;
3868 shape[10].x = im; shape[10].y = im2;
3869 shape[11].x = im2; shape[11].y = im;
3870 shape[12].x = 0; shape[12].y = im2;
3871 SetMarkerType(2,13,shape);
3872 } else if (fMarkerStyle == 47) {
3873 // filled four triangles X
3874 Int_t im2 = Int_t(2.0*fMarkerSize + 0.5);
3875 shape[0].x = 0; shape[0].y = im2;
3876 shape[1].x = -im2; shape[1].y = im;
3877 shape[2].x = -im; shape[2].y = im2;
3878 shape[3].x = -im2; shape[3].y = 0;
3879 shape[4].x = -im; shape[4].y = -im2;
3880 shape[5].x = -im2; shape[5].y = -im;
3881 shape[6].x = 0; shape[6].y = -im2;
3882 shape[7].x = im2; shape[7].y = -im;
3883 shape[8].x = im; shape[8].y = -im2;
3884 shape[9].x = im2; shape[9].y = 0;
3885 shape[10].x = im; shape[10].y = im2;
3886 shape[11].x = im2; shape[11].y = im;
3887 shape[12].x = 0; shape[12].y = im2;
3888 SetMarkerType(3,13,shape);
3889 } else if (fMarkerStyle == 48) {
3890 // four filled squares X
3891 Int_t im2 = Int_t(2.0*fMarkerSize + 0.5);
3892 shape[0].x = 0; shape[0].y = im2*1.005;
3893 shape[1].x = -im2; shape[1].y = im;
3894 shape[2].x = -im; shape[2].y = im2;
3895 shape[3].x = -im2; shape[3].y = 0;
3896 shape[4].x = -im; shape[4].y = -im2;
3897 shape[5].x = -im2; shape[5].y = -im;
3898 shape[6].x = 0; shape[6].y = -im2;
3899 shape[7].x = im2; shape[7].y = -im;
3900 shape[8].x = im; shape[8].y = -im2;
3901 shape[9].x = im2; shape[9].y = 0;
3902 shape[10].x = im; shape[10].y = im2;
3903 shape[11].x = im2; shape[11].y = im;
3904 shape[12].x = 0; shape[12].y = im2*0.995;
3905 shape[13].x = im2*0.995; shape[13].y = 0;
3906 shape[14].x = 0; shape[14].y = -im2*0.995;
3907 shape[15].x = -im2*0.995; shape[15].y = 0;
3908 shape[16].x = 0; shape[16].y = im2*0.995;
3909 SetMarkerType(3,16,shape);
3910 } else if (fMarkerStyle == 49) {
3911 // four filled squares plus
3912 Int_t imx = Int_t(1.33*fMarkerSize + 0.5);
3913 shape[0].x =-imx; shape[0].y =-imx*1.005;
3914 shape[1].x =-imx; shape[1].y = -im;
3915 shape[2].x = imx; shape[2].y = -im;
3916 shape[3].x = imx; shape[3].y =-imx;
3917 shape[4].x = im; shape[4].y =-imx;
3918 shape[5].x = im; shape[5].y = imx;
3919 shape[6].x = imx; shape[6].y = imx;
3920 shape[7].x = imx; shape[7].y = im;
3921 shape[8].x =-imx; shape[8].y = im;
3922 shape[9].x =-imx; shape[9].y = imx;
3923 shape[10].x = -im; shape[10].y = imx;
3924 shape[11].x = -im; shape[11].y =-imx;
3925 shape[12].x =-imx; shape[12].y =-imx*0.995;
3926 shape[13].x =-imx; shape[13].y = imx;
3927 shape[14].x = imx; shape[14].y = imx;
3928 shape[15].x = imx; shape[15].y =-imx;
3929 shape[16].x =-imx; shape[16].y =-imx*1.005;
3930 SetMarkerType(3,17,shape);
3931 } else {
3932 // single dot
3933 SetMarkerType(0, 0, shape);
3934 }
3936}
3937
3938////////////////////////////////////////////////////////////////////////////////
3939/// Set opacity of a window. This image manipulation routine works
3940/// by adding to a percent amount of neutral to each pixels RGB.
3941/// Since it requires quite some additional color map entries is it
3942/// only supported on displays with more than > 8 color planes (> 256
3943/// colors)
3944
3946{
3947 Int_t depth = gdk_visual_get_best_depth();
3948
3949 if (depth <= 8) return;
3950 if (percent == 0) return;
3951
3952 // if 100 percent then just make white
3953 ULong_t *orgcolors = 0, *tmpc = 0;
3954 Int_t maxcolors = 0, ncolors, ntmpc = 0;
3955
3956 // save previous allocated colors, delete at end when not used anymore
3957 if (gCws->new_colors) {
3958 tmpc = gCws->new_colors;
3959 ntmpc = gCws->ncolors;
3960 }
3961 // get pixmap from server as image
3962 GdkImage *image = gdk_image_get((GdkDrawable*)gCws->drawing, 0, 0,
3963 gCws->width, gCws->height);
3964
3965 // collect different image colors
3966 int x, y;
3967 for (y = 0; y < (int) gCws->height; y++) {
3968 for (x = 0; x < (int) gCws->width; x++) {
3969 ULong_t pixel = GetPixelImage((Drawable_t)image, x, y);
3970 CollectImageColors(pixel, orgcolors, ncolors, maxcolors);
3971 }
3972 }
3973 if (ncolors == 0) {
3974 gdk_image_unref(image);
3975 ::operator delete(orgcolors);
3976 return;
3977 }
3978 // create opaque counter parts
3979 MakeOpaqueColors(percent, orgcolors, ncolors);
3980
3981 // put opaque colors in image
3982 for (y = 0; y < (int) gCws->height; y++) {
3983 for (x = 0; x < (int) gCws->width; x++) {
3984 ULong_t pixel = GetPixelImage((Drawable_t)image, x, y);
3985 Int_t idx = FindColor(pixel, orgcolors, ncolors);
3986 PutPixel((Drawable_t)image, x, y, gCws->new_colors[idx]);
3987 }
3988 }
3989
3990 // put image back in pixmap on server
3991 gdk_draw_image(gCws->drawing, gGCpxmp, (GdkImage *)image,
3992 0, 0, 0, 0, gCws->width, gCws->height);
3993 GdiFlush();
3994
3995 // clean up
3996 if (tmpc) {
3997 gdk_colors_free((GdkColormap *)fColormap, tmpc, ntmpc, 0);
3998 delete[]tmpc;
3999 }
4000 gdk_image_unref(image);
4001 ::operator delete(orgcolors);
4002}
4003
4004////////////////////////////////////////////////////////////////////////////////
4005/// Get RGB values for orgcolors, add percent neutral to the RGB and
4006/// allocate new_colors.
4007
4008void TGWin32::MakeOpaqueColors(Int_t percent, ULong_t *orgcolors, Int_t ncolors)
4009{
4010 Int_t ret;
4011 if (ncolors <= 0) return;
4012 GdkColor *xcol = new GdkColor[ncolors];
4013
4014 int i;
4015 for (i = 0; i < ncolors; i++) {
4016 xcol[i].pixel = orgcolors[i];
4017 xcol[i].red = xcol[i].green = xcol[i].blue = 0;
4018 }
4019
4020 GdkColorContext *cc;
4021 cc = gdk_color_context_new(gdk_visual_get_system(), (GdkColormap *)fColormap);
4022 gdk_color_context_query_colors(cc, xcol, ncolors);
4023 gdk_color_context_free(cc);
4024
4025 UShort_t add = percent * kBIGGEST_RGB_VALUE / 100;
4026
4027 Int_t val;
4028 for (i = 0; i < ncolors; i++) {
4029 val = xcol[i].red + add;
4030 if (val > kBIGGEST_RGB_VALUE) {
4031 val = kBIGGEST_RGB_VALUE;
4032 }
4033 xcol[i].red = (UShort_t) val;
4034 val = xcol[i].green + add;
4035 if (val > kBIGGEST_RGB_VALUE) {
4036 val = kBIGGEST_RGB_VALUE;
4037 }
4038 xcol[i].green = (UShort_t) val;
4039 val = xcol[i].blue + add;
4040 if (val > kBIGGEST_RGB_VALUE) {
4041 val = kBIGGEST_RGB_VALUE;
4042 }
4043 xcol[i].blue = (UShort_t) val;
4044
4045 ret = gdk_color_alloc((GdkColormap *)fColormap, &xcol[i]);
4046
4047 if (!ret) {
4048 Warning("MakeOpaqueColors",
4049 "failed to allocate color %hd, %hd, %hd", xcol[i].red,
4050 xcol[i].green, xcol[i].blue);
4051 // assumes that in case of failure xcol[i].pixel is not changed
4052 }
4053 }
4054
4055 gCws->new_colors = new ULong_t[ncolors];
4056 gCws->ncolors = ncolors;
4057
4058 for (i = 0; i < ncolors; i++) {
4059 gCws->new_colors[i] = xcol[i].pixel;
4060 }
4061
4062 delete []xcol;
4063}
4064
4065////////////////////////////////////////////////////////////////////////////////
4066/// Returns index in orgcolors (and new_colors) for pixel.
4067
4068Int_t TGWin32::FindColor(ULong_t pixel, ULong_t * orgcolors, Int_t ncolors)
4069{
4070 for (int i = 0; i < ncolors; i++) {
4071 if (pixel == orgcolors[i]) return i;
4072 }
4073 Error("FindColor", "did not find color, should never happen!");
4074
4075 return 0;
4076}
4077
4078////////////////////////////////////////////////////////////////////////////////
4079/// Set color intensities for given color index.
4080/// cindex : color index
4081/// r,g,b : red, green, blue intensities between 0.0 and 1.0
4082
4083void TGWin32::SetRGB(int cindex, float r, float g, float b)
4084{
4085 GdkColor xcol;
4086
4087 if (fColormap && cindex >= 0) {
4088 xcol.red = (unsigned short) (r * kBIGGEST_RGB_VALUE);
4089 xcol.green = (unsigned short) (g * kBIGGEST_RGB_VALUE);
4090 xcol.blue = (unsigned short) (b * kBIGGEST_RGB_VALUE);
4091 xcol.pixel = RGB(xcol.red, xcol.green, xcol.blue);
4092
4093 XColor_t &col = GetColor(cindex);
4094 if (col.fDefined) {
4095 // if color is already defined with same rgb just return
4096 if (col.color.red == xcol.red && col.color.green == xcol.green &&
4097 col.color.blue == xcol.blue)
4098 return;
4099 col.fDefined = kFALSE;
4100 gdk_colormap_free_colors((GdkColormap *) fColormap,
4101 (GdkColor *)&col, 1);
4102 }
4103
4104 Int_t ret = gdk_colormap_alloc_color(fColormap, &xcol, 1, 1);
4105 if (ret != 0) {
4106 col.fDefined = kTRUE;
4107 col.color.pixel = xcol.pixel;
4108 col.color.red = xcol.red;
4109 col.color.green = xcol.green;
4110 col.color.blue = xcol.blue;
4111 }
4112 }
4113}
4114
4115////////////////////////////////////////////////////////////////////////////////
4116/// Set text alignment.
4117/// txalh : horizontal text alignment
4118/// txalv : vertical text alignment
4119
4121{
4122 static Short_t current = 0;
4123 if (talign==current) return;
4124 current = talign;
4125
4126 Int_t txalh = talign / 10;
4127 Int_t txalv = talign % 10;
4128 fTextAlignH = txalh;
4129 fTextAlignV = txalv;
4130
4131 switch (txalh) {
4132
4133 case 0:
4134 case 1:
4135 switch (txalv) { //left
4136 case 1:
4137 fTextAlign = 7; //bottom
4138 break;
4139 case 2:
4140 fTextAlign = 4; //center
4141 break;
4142 case 3:
4143 fTextAlign = 1; //top
4144 break;
4145 }
4146 break;
4147 case 2:
4148 switch (txalv) { //center
4149 case 1:
4150 fTextAlign = 8; //bottom
4151 break;
4152 case 2:
4153 fTextAlign = 5; //center
4154 break;
4155 case 3:
4156 fTextAlign = 2; //top
4157 break;
4158 }
4159 break;
4160 case 3:
4161 switch (txalv) { //right
4162 case 1:
4163 fTextAlign = 9; //bottom
4164 break;
4165 case 2:
4166 fTextAlign = 6; //center
4167 break;
4168 case 3:
4169 fTextAlign = 3; //top
4170 break;
4171 }
4172 break;
4173 }
4175}
4176
4177////////////////////////////////////////////////////////////////////////////////
4178/// Set color index for text.
4179
4181{
4182 static Int_t current = 0;
4183 GdkGCValues values;
4184 if ((cindex < 0) || (Int_t(cindex)==current)) return;
4185
4186 TAttText::SetTextColor(cindex);
4187
4188 SetColor(gGCtext, Int_t(cindex));
4189 gdk_gc_get_values(gGCtext, &values);
4190 gdk_gc_set_foreground(gGCinvt, &values.background);
4191 gdk_gc_set_background(gGCinvt, &values.foreground);
4192 gdk_gc_set_background(gGCtext, (GdkColor *) & GetColor(0).color);
4193 current = Int_t(cindex);
4194}
4195
4196////////////////////////////////////////////////////////////////////////////////
4197
4198void TGWin32::Sync(int mode)
4199{
4200}
4201
4202////////////////////////////////////////////////////////////////////////////////
4203/// Update display.
4204/// mode : (1) update
4205/// (0) sync
4206///
4207/// Synchronise client and server once (not permanent).
4208/// Copy the pixmap gCws->drawing on the window gCws->window
4209/// if the double buffer is on.
4210
4212{
4213 if (gCws && gCws->double_buffer) {
4214 gdk_window_copy_area(gCws->window, gGCpxmp, 0, 0,
4215 gCws->drawing, 0, 0, gCws->width, gCws->height);
4216 }
4217 Update(mode);
4218}
4219
4220////////////////////////////////////////////////////////////////////////////////
4221/// Set pointer position.
4222/// ix : New X coordinate of pointer
4223/// iy : New Y coordinate of pointer
4224/// Coordinates are relative to the origin of the window id
4225/// or to the origin of the current window if id == 0.
4226
4227void TGWin32::Warp(int ix, int iy, Window_t id)
4228{
4229 if (!id) return;
4230
4231 POINT cpt, tmp;
4232 HWND dw;
4233 if (!id)
4234 dw = (HWND) GDK_DRAWABLE_XID((GdkWindow *)gCws->window);
4235 else
4236 dw = (HWND) GDK_DRAWABLE_XID((GdkWindow *)id);
4237 GetCursorPos(&cpt);
4238 tmp.x = ix > 0 ? ix : cpt.x;
4239 tmp.y = iy > 0 ? iy : cpt.y;
4240 ClientToScreen(dw, &tmp);
4241 SetCursorPos(tmp.x, tmp.y);
4242}
4243
4244////////////////////////////////////////////////////////////////////////////////
4245/// Write the pixmap wid in the bitmap file pxname.
4246/// wid : Pixmap address
4247/// w,h : Width and height of the pixmap.
4248/// lenname : pixmap name length
4249/// pxname : pixmap name
4250
4251void TGWin32::WritePixmap(int wid, unsigned int w, unsigned int h,
4252 char *pxname)
4253{
4254 int wval, hval;
4255 wval = w;
4256 hval = h;
4257
4258 if (!fWindows) return;
4259 gTws = &fWindows[wid];
4260// XWriteBitmapFile(fDisplay,pxname,(Pixmap)gTws->drawing,wval,hval,-1,-1);
4261}
4262
4263
4264//
4265// Functions for GIFencode()
4266//
4267
4268static FILE *gGifFile; // output unit used WriteGIF and PutByte
4269static GdkImage *gGifImage = 0; // image used in WriteGIF and GetPixel
4270
4271extern "C" {
4272 int GIFquantize(UInt_t width, UInt_t height, Int_t * ncol, Byte_t * red,
4273 Byte_t * green, Byte_t * blue, Byte_t * outputBuf,
4274 Byte_t * outputCmap);
4275 long GIFencode(int Width, int Height, Int_t Ncol, Byte_t R[],
4276 Byte_t G[], Byte_t B[], Byte_t ScLine[],
4277 void (*get_scline) (int, int, Byte_t *),
4278 void (*pb) (Byte_t));
4279 int GIFdecode(Byte_t * GIFarr, Byte_t * PIXarr, int *Width, int *Height,
4280 int *Ncols, Byte_t * R, Byte_t * G, Byte_t * B);
4281 int GIFinfo(Byte_t * GIFarr, int *Width, int *Height, int *Ncols);
4282}
4283
4284
4285////////////////////////////////////////////////////////////////////////////////
4286/// Get pixels in line y and put in array scline.
4287
4288static void GetPixel(int y, int width, Byte_t * scline)
4289{
4290 for (int i = 0; i < width; i++) {
4291 scline[i] = Byte_t(GetPixelImage((Drawable_t)gGifImage, i, y));
4292 }
4293}
4294
4295////////////////////////////////////////////////////////////////////////////////
4296/// Put byte b in output stream.
4297
4298static void PutByte(Byte_t b)
4299{
4300 if (ferror(gGifFile) == 0) fputc(b, gGifFile);
4301}
4302
4303////////////////////////////////////////////////////////////////////////////////
4304/// Returns in R G B the ncol colors of the palette used by the image.
4305/// The image pixels are changed to index values in these R G B arrays.
4306/// This produces a colormap with only the used colors (so even on displays
4307/// with more than 8 planes we will be able to create GIF's when the image
4308/// contains no more than 256 different colors). If it does contain more
4309/// colors we will have to use GIFquantize to reduce the number of colors.
4310/// The R G B arrays must be deleted by the caller.
4311
4312void TGWin32::ImgPickPalette(GdkImage * image, Int_t & ncol, Int_t * &R,
4313 Int_t * &G, Int_t * &B)
4314{
4315 ULong_t *orgcolors = 0;
4316 Int_t maxcolors = 0, ncolors;
4317
4318 // collect different image colors
4319 int x, y;
4320 for (x = 0; x < (int) gCws->width; x++) {
4321 for (y = 0; y < (int) gCws->height; y++) {
4322 ULong_t pixel = GetPixelImage((Drawable_t)image, x, y);
4323 CollectImageColors(pixel, orgcolors, ncolors, maxcolors);
4324 }
4325 }
4326
4327 // get RGB values belonging to pixels
4328 GdkColor *xcol = new GdkColor[ncolors];
4329
4330 int i;
4331 for (i = 0; i < ncolors; i++) {
4332 xcol[i].pixel = orgcolors[i];
4333// xcol[i].red = xcol[i].green = xcol[i].blue = 0;
4334 xcol[i].red = GetRValue(xcol[i].pixel);
4335 xcol[i].green = GetGValue(xcol[i].pixel);
4336 xcol[i].blue = GetBValue(xcol[i].pixel);
4337 }
4338
4339 GdkColorContext *cc;
4340 cc = gdk_color_context_new(gdk_visual_get_system(), (GdkColormap *)fColormap);
4341 gdk_color_context_query_colors(cc, xcol, ncolors);
4342 gdk_color_context_free(cc);
4343
4344 // create RGB arrays and store RGB's for each color and set number of colors
4345 // (space must be delete by caller)
4346 R = new Int_t[ncolors];
4347 G = new Int_t[ncolors];
4348 B = new Int_t[ncolors];
4349
4350 for (i = 0; i < ncolors; i++) {
4351 R[i] = xcol[i].red;
4352 G[i] = xcol[i].green;
4353 B[i] = xcol[i].blue;
4354 }
4355 ncol = ncolors;
4356
4357 // update image with indices (pixels) into the new RGB colormap
4358 for (x = 0; x < (int) gCws->width; x++) {
4359 for (y = 0; y < (int) gCws->height; y++) {
4360 ULong_t pixel = GetPixelImage((Drawable_t)image, x, y);
4361 Int_t idx = FindColor(pixel, orgcolors, ncolors);
4362 PutPixel((Drawable_t)image, x, y, idx);
4363 }
4364 }
4365
4366 // cleanup
4367 delete[]xcol;
4368 ::operator delete(orgcolors);
4369}
4370
4371////////////////////////////////////////////////////////////////////////////////
4372/// Writes the current window into GIF file.
4373
4375{
4376 Byte_t scline[2000], r[256], b[256], g[256];
4377 Int_t *R, *G, *B;
4378 Int_t ncol, maxcol, i;
4379
4380 if (gGifImage) {
4381 gdk_image_unref((GdkImage *)gGifImage);
4382 }
4383
4384 gGifImage = gdk_image_get((GdkDrawable*)gCws->drawing, 0, 0,
4385 gCws->width, gCws->height);
4386
4387 ImgPickPalette(gGifImage, ncol, R, G, B);
4388
4389 if (ncol > 256) {
4390 //GIFquantize(...);
4391 Error("WriteGIF",
4392 "can not create GIF of image containing more than 256 colors");
4393 delete[]R;
4394 delete[]G;
4395 delete[]B;
4396 return 0;
4397 }
4398
4399 maxcol = 0;
4400 for (i = 0; i < ncol; i++) {
4401 if (maxcol < R[i]) maxcol = R[i];
4402 if (maxcol < G[i]) maxcol = G[i];
4403 if (maxcol < B[i]) maxcol = B[i];
4404 r[i] = 0;
4405 g[i] = 0;
4406 b[i] = 0;
4407 }
4408 if (maxcol != 0) {
4409 for (i = 0; i < ncol; i++) {
4410 r[i] = R[i] * 255 / maxcol;
4411 g[i] = G[i] * 255 / maxcol;
4412 b[i] = B[i] * 255 / maxcol;
4413 }
4414 }
4415
4416 gGifFile = fopen(name, "wb");
4417
4418 if (gGifFile) {
4419 GIFencode(gCws->width, gCws->height,
4420 ncol, r, g, b, scline, ::GetPixel, PutByte);
4421 fclose(gGifFile);
4422 i = 1;
4423 } else {
4424 Error("WriteGIF","cannot write file: %s",name);
4425 i = 0;
4426 }
4427 delete[]R;
4428 delete[]G;
4429 delete[]B;
4430
4431 return i;
4432}
4433
4434////////////////////////////////////////////////////////////////////////////////
4435/// Draw image.
4436
4437void TGWin32::PutImage(int offset, int itran, int x0, int y0, int nx,
4438 int ny, int xmin, int ymin, int xmax, int ymax,
4439 unsigned char *image, Drawable_t wid)
4440{
4441 const int MAX_SEGMENT = 20;
4442 int i, n, x, y, xcur, x1, x2, y1, y2;
4443 unsigned char *jimg, *jbase, icol;
4444 int nlines[256];
4445 GdkSegment lines[256][MAX_SEGMENT];
4446 GdkDrawable *id;
4447
4448 if (wid) {
4449 id = (GdkDrawable*)wid;
4450 } else {
4451 id = gCws->drawing;
4452 }
4453
4454 for (i = 0; i < 256; i++) nlines[i] = 0;
4455
4456 x1 = x0 + xmin;
4457 y1 = y0 + ny - ymax - 1;
4458 x2 = x0 + xmax;
4459 y2 = y0 + ny - ymin - 1;
4460 jbase = image + (ymin - 1) * nx + xmin;
4461
4462 for (y = y2; y >= y1; y--) {
4463 xcur = x1;
4464 jbase += nx;
4465 for (jimg = jbase, icol = *jimg++, x = x1 + 1; x <= x2; jimg++, x++) {
4466 if (icol != *jimg) {
4467 if (icol != itran) {
4468 n = nlines[icol]++;
4469 lines[icol][n].x1 = xcur;
4470 lines[icol][n].y1 = y;
4471 lines[icol][n].x2 = x - 1;
4472 lines[icol][n].y2 = y;
4473 if (nlines[icol] == MAX_SEGMENT) {
4474 SetColor(gGCline, (int) icol + offset);
4475 gdk_win32_draw_segments(id, (GdkGC *) gGCline,
4476 (GdkSegment *) &lines[icol][0], MAX_SEGMENT);
4477 nlines[icol] = 0;
4478 }
4479 }
4480 icol = *jimg;
4481 xcur = x;
4482 }
4483 }
4484 if (icol != itran) {
4485 n = nlines[icol]++;
4486 lines[icol][n].x1 = xcur;
4487 lines[icol][n].y1 = y;
4488 lines[icol][n].x2 = x - 1;
4489 lines[icol][n].y2 = y;
4490 if (nlines[icol] == MAX_SEGMENT) {
4491 SetColor(gGCline, (int) icol + offset);
4492 gdk_win32_draw_segments(id, (GdkGC *) gGCline,
4493 (GdkSegment *)&lines[icol][0], MAX_SEGMENT);
4494 nlines[icol] = 0;
4495 }
4496 }
4497 }
4498
4499 for (i = 0; i < 256; i++) {
4500 if (nlines[i] != 0) {
4501 SetColor(gGCline, i + offset);
4502 gdk_win32_draw_segments(id, (GdkGC *) gGCline,
4503 (GdkSegment *)&lines[icol][0], nlines[i]);
4504 }
4505 }
4506}
4507
4508////////////////////////////////////////////////////////////////////////////////
4509/// If id is NULL - loads the specified gif file at position [x0,y0] in the
4510/// current window. Otherwise creates pixmap from gif file
4511
4512Pixmap_t TGWin32::ReadGIF(int x0, int y0, const char *file, Window_t id)
4513{
4514 FILE *fd;
4515 Seek_t filesize;
4516 unsigned char *GIFarr, *PIXarr, R[256], G[256], B[256], *j1, *j2, icol;
4517 int i, j, k, width, height, ncolor, irep, offset;
4518 float rr, gg, bb;
4519 Pixmap_t pic = 0;
4520
4521 fd = fopen(file, "r+b");
4522 if (!fd) {
4523 Error("ReadGIF", "unable to open GIF file");
4524 return pic;
4525 }
4526
4527 fseek(fd, 0L, 2);
4528 filesize = Seek_t(ftell(fd));
4529 fseek(fd, 0L, 0);
4530
4531 if (!(GIFarr = (unsigned char *) calloc(filesize + 256, 1))) {
4532 fclose(fd);
4533 Error("ReadGIF", "unable to allocate array for gif");
4534 return pic;
4535 }
4536
4537 if (fread(GIFarr, filesize, 1, fd) != 1) {
4538 fclose(fd);
4539 Error("ReadGIF", "GIF file read failed");
4540 free(GIFarr);
4541 return pic;
4542 }
4543 fclose(fd);
4544
4545 irep = GIFinfo(GIFarr, &width, &height, &ncolor);
4546 if (irep != 0) {
4547 return pic;
4548 }
4549
4550 if (!(PIXarr = (unsigned char *) calloc((width * height), 1))) {
4551 Error("ReadGIF", "unable to allocate array for image");
4552 return pic;
4553 }
4554
4555 irep = GIFdecode(GIFarr, PIXarr, &width, &height, &ncolor, R, G, B);
4556 if (irep != 0) {
4557 return pic;
4558 }
4559 // S E T P A L E T T E
4560
4561 offset = 8;
4562
4563 for (i = 0; i < ncolor; i++) {
4564 rr = R[i] / 255.;
4565 gg = G[i] / 255.;
4566 bb = B[i] / 255.;
4567 j = i + offset;
4568 SetRGB(j, rr, gg, bb);
4569 }
4570
4571 // O U T P U T I M A G E
4572
4573 for (i = 1; i <= height / 2; i++) {
4574 j1 = PIXarr + (i - 1) * width;
4575 j2 = PIXarr + (height - i) * width;
4576 for (k = 0; k < width; k++) {
4577 icol = *j1;
4578 *j1++ = *j2;
4579 *j2++ = icol;
4580 }
4581 }
4582
4583 if (id) pic = CreatePixmap(id, width, height);
4584 PutImage(offset, -1, x0, y0, width, height, 0, 0, width-1, height-1, PIXarr, pic);
4585
4586 if (pic) return pic;
4587 else if (gCws->drawing) return (Pixmap_t)gCws->drawing;
4588 else return 0;
4589}
4590
4591//////////////////////////// GWin32Gui //////////////////////////////////////////
4592////////////////////////////////////////////////////////////////////////////////
4593/// Map window on screen.
4594
4596{
4597 if (!id) return;
4598
4599 gdk_window_show((GdkWindow *)id);
4600 if ((GDK_DRAWABLE_TYPE((GdkWindow *)id) != GDK_WINDOW_TEMP) &&
4601 (GetParent(id) == GetDefaultRootWindow())) {
4602 HWND window = (HWND)GDK_DRAWABLE_XID((GdkWindow *)id);
4603 ::SetForegroundWindow(window);
4604 }
4605}
4606
4607////////////////////////////////////////////////////////////////////////////////
4608///
4609
4611{
4612 if (!id) return;
4613
4614 EnumChildWindows((HWND)GDK_DRAWABLE_XID((GdkWindow *)id),
4615 EnumChildProc, (LPARAM) NULL);
4616}
4617
4618////////////////////////////////////////////////////////////////////////////////
4619/// Map window on screen and put on top of all windows.
4620
4622{
4623 if (!id) return;
4624
4625 HWND hwnd = ::GetForegroundWindow();
4626 HWND window = (HWND)GDK_DRAWABLE_XID((GdkWindow *)id);
4627 gdk_window_show((GdkWindow *)id);
4628 if (GDK_DRAWABLE_TYPE((GdkWindow *)id) != GDK_WINDOW_TEMP) {
4629 ::BringWindowToTop(window);
4630 if (GDK_DRAWABLE_TYPE((GdkWindow *)id) != GDK_WINDOW_CHILD)
4631 ::SetForegroundWindow(window);
4632 }
4633
4634 if (gConsoleWindow && (hwnd == (HWND)gConsoleWindow)) {
4635 RECT r1, r2, r3;
4636 ::GetWindowRect((HWND)gConsoleWindow, &r1);
4637 HWND fore = ::GetForegroundWindow();
4638 ::GetWindowRect(fore, &r2);
4639 if (!::IntersectRect(&r3, &r2, &r1)) {
4640 ::SetForegroundWindow((HWND)gConsoleWindow);
4641 }
4642 }
4643}
4644
4645////////////////////////////////////////////////////////////////////////////////
4646/// Unmap window from screen.
4647
4649{
4650 if (!id) return;
4651
4652 gdk_window_hide((GdkWindow *) id);
4653}
4654
4655////////////////////////////////////////////////////////////////////////////////
4656/// Destroy window.
4657
4659{
4660 if (!id) return;
4661
4662 // we need to unmap the window before to destroy it, in order to properly
4663 // receive kUnmapNotify needed by gClient->WaitForUnmap()...
4664 gdk_window_hide((GdkWindow *) id);
4665 gdk_window_destroy((GdkDrawable *) id, kTRUE);
4666}
4667
4668////////////////////////////////////////////////////////////////////////////////
4669/// Destroy all internal subwindows
4670
4672{
4673 if (!id) return;
4674
4675 gdk_window_destroy((GdkDrawable *) id, kFALSE);
4676}
4677
4678////////////////////////////////////////////////////////////////////////////////
4679/// Put window on top of window stack.
4680
4682{
4683 if (!id) return;
4684
4685 HWND window = (HWND)GDK_DRAWABLE_XID((GdkWindow *)id);
4686 if (GDK_DRAWABLE_TYPE((GdkWindow *)id) == GDK_WINDOW_TEMP) {
4687 ::SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0,
4688 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
4689 }
4690 else {
4691 ::BringWindowToTop(window);
4692 if (GDK_DRAWABLE_TYPE((GdkWindow *)id) != GDK_WINDOW_CHILD)
4693 ::SetForegroundWindow(window);
4694 }
4695}
4696
4697////////////////////////////////////////////////////////////////////////////////
4698/// Lower window so it lays below all its siblings.
4699
4701{
4702 if (!id) return;
4703
4704 HWND window = (HWND)GDK_DRAWABLE_XID((GdkWindow *)id);
4705 ::SetWindowPos(window, HWND_BOTTOM, 0, 0, 0, 0,
4706 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
4707}
4708
4709////////////////////////////////////////////////////////////////////////////////
4710/// Move a window.
4711
4713{
4714 if (!id) return;
4715
4716 gdk_window_move((GdkDrawable *) id, x, y);
4717}
4718
4719////////////////////////////////////////////////////////////////////////////////
4720/// Move and resize a window.
4721
4723 UInt_t h)
4724{
4725 if (!id) return;
4726
4727 gdk_window_move_resize((GdkWindow *) id, x, y, w, h);
4728}
4729
4730////////////////////////////////////////////////////////////////////////////////
4731/// Resize the window.
4732
4734{
4735 if (!id) return;
4736
4737 // protect against potential negative values
4738 if (w >= (UInt_t)INT_MAX || h >= (UInt_t)INT_MAX)
4739 return;
4740 gdk_window_resize((GdkWindow *) id, w, h);
4741}
4742
4743////////////////////////////////////////////////////////////////////////////////
4744/// Iconify the window.
4745
4747{
4748 if (!id) return;
4749
4750 gdk_window_lower((GdkWindow *) id);
4751 ::CloseWindow((HWND)GDK_DRAWABLE_XID((GdkWindow *)id));
4752}
4753
4754////////////////////////////////////////////////////////////////////////////////
4755/// Reparent window, make pid the new parent and position the window at
4756/// position (x,y) in new parent.
4757
4759{
4760 if (!id) return;
4761
4762 gdk_window_reparent((GdkWindow *)id, (GdkWindow *)pid, x, y);
4763}
4764
4765////////////////////////////////////////////////////////////////////////////////
4766/// Set the window background color.
4767
4769{
4770 if (!id) return;
4771
4772 GdkColor back;
4773 back.pixel = color;
4774 back.red = GetRValue(color);
4775 back.green = GetGValue(color);
4776 back.blue = GetBValue(color);
4777
4778 gdk_window_set_background((GdkWindow *) id, &back);
4779}
4780
4781////////////////////////////////////////////////////////////////////////////////
4782/// Set pixmap as window background.
4783
4785{
4786 if (!id) return;
4787
4788 gdk_window_set_back_pixmap((GdkWindow *) id, (GdkPixmap *) pxm, 0);
4789}
4790
4791////////////////////////////////////////////////////////////////////////////////
4792/// Return handle to newly created gdk window.
4793
4795 UInt_t w, UInt_t h, UInt_t border,
4796 Int_t depth, UInt_t clss,
4797 void *visual, SetWindowAttributes_t * attr,
4798 UInt_t wtype)
4799{
4800 GdkWindowAttr xattr;
4801 GdkWindow *newWin;
4802 GdkColor background_color;
4803 ULong_t xmask = 0;
4804
4805 if (attr) {
4806 MapSetWindowAttributes(attr, xmask, xattr);
4807 xattr.window_type = GDK_WINDOW_CHILD;
4808 if (wtype & kMainFrame) {
4809 xattr.window_type = GDK_WINDOW_TOPLEVEL;
4810 }
4811 if (wtype & kTransientFrame) {
4812 xattr.window_type = GDK_WINDOW_DIALOG;
4813 }
4814 if (wtype & kTempFrame) {
4815 xattr.window_type = GDK_WINDOW_TEMP;
4816 }
4817 newWin = gdk_window_new((GdkWindow *) parent, &xattr, xmask);
4818 } else {
4819 xattr.width = w;
4820 xattr.height = h;
4821 xattr.wclass = GDK_INPUT_OUTPUT;
4822 xattr.event_mask = 0L; //GDK_ALL_EVENTS_MASK;
4823 xattr.event_mask |= GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK |
4824 GDK_PROPERTY_CHANGE_MASK;
4825// GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK;
4826 if (x >= 0) {
4827 xattr.x = x;
4828 } else {
4829 xattr.x = -1.0 * x;
4830 }
4831 if (y >= 0) {
4832 xattr.y = y;
4833 } else {
4834 xattr.y = -1.0 * y;
4835 }
4836 xattr.colormap = gdk_colormap_get_system();
4837 xattr.cursor = NULL;
4838 xattr.override_redirect = TRUE;
4839 if ((xattr.y > 0) && (xattr.x > 0)) {
4840 xmask = GDK_WA_X | GDK_WA_Y | GDK_WA_COLORMAP |
4841 GDK_WA_WMCLASS | GDK_WA_NOREDIR;
4842 } else {
4843 xmask = GDK_WA_COLORMAP | GDK_WA_WMCLASS | GDK_WA_NOREDIR;
4844 }
4845 if (visual != NULL) {
4846 xattr.visual = (GdkVisual *) visual;
4847 xmask |= GDK_WA_VISUAL;
4848 } else {
4849 xattr.visual = gdk_visual_get_system();
4850 xmask |= GDK_WA_VISUAL;
4851 }
4852 xattr.window_type = GDK_WINDOW_CHILD;
4853 if (wtype & kMainFrame) {
4854 xattr.window_type = GDK_WINDOW_TOPLEVEL;
4855 }
4856 if (wtype & kTransientFrame) {
4857 xattr.window_type = GDK_WINDOW_DIALOG;
4858 }
4859 if (wtype & kTempFrame) {
4860 xattr.window_type = GDK_WINDOW_TEMP;
4861 }
4862 newWin = gdk_window_new((GdkWindow *) parent, &xattr, xmask);
4863 gdk_window_set_events(newWin, (GdkEventMask) 0L);
4864 }
4865 if (border > 0) {
4866 gdk_window_set_decorations(newWin,
4867 (GdkWMDecoration) GDK_DECOR_BORDER);
4868 }
4869 if (attr) {
4870 if ((attr->fMask & kWABackPixmap)) {
4871 if (attr->fBackgroundPixmap == kNone) {
4872 gdk_window_set_back_pixmap(newWin, (GdkPixmap *) GDK_NONE, 0);
4873 } else if (attr->fBackgroundPixmap == kParentRelative) {
4874 gdk_window_set_back_pixmap(newWin, (GdkPixmap *) GDK_NONE, 1);
4875 } else {
4876 gdk_window_set_back_pixmap(newWin,
4877 (GdkPixmap *) attr->
4878 fBackgroundPixmap, 0);
4879 }
4880 }
4881 if ((attr->fMask & kWABackPixel)) {
4882 background_color.pixel = attr->fBackgroundPixel;
4883 background_color.red = GetRValue(attr->fBackgroundPixel);
4884 background_color.green = GetGValue(attr->fBackgroundPixel);
4885 background_color.blue = GetBValue(attr->fBackgroundPixel);
4886 gdk_window_set_background(newWin, &background_color);
4887 }
4888 }
4889 if (!fUseSysPointers) {
4890 ::SetClassLong((HWND)GDK_DRAWABLE_XID(newWin), GCL_HCURSOR,
4891 (LONG)GDK_CURSOR_XID(fCursors[kPointer]));
4892 }
4893 return (Window_t) newWin;
4894}
4895
4896////////////////////////////////////////////////////////////////////////////////
4897/// Map event mask to or from gdk.
4898
4899void TGWin32::MapEventMask(UInt_t & emask, UInt_t & xemask, Bool_t tox)
4900{
4901 if (tox) {
4902 Long_t lxemask = 0L;
4903 if ((emask & kKeyPressMask)) {
4904 lxemask |= GDK_KEY_PRESS_MASK;
4905 }
4906 if ((emask & kKeyReleaseMask)) {
4907 lxemask |= GDK_KEY_RELEASE_MASK;
4908 }
4909 if ((emask & kButtonPressMask)) {
4910 lxemask |= GDK_BUTTON_PRESS_MASK;
4911 }
4912 if ((emask & kButtonReleaseMask)) {
4913 lxemask |= GDK_BUTTON_RELEASE_MASK;
4914 }
4915 if ((emask & kPointerMotionMask)) {
4916 lxemask |= GDK_POINTER_MOTION_MASK;
4917 }
4918 if ((emask & kButtonMotionMask)) {
4919 lxemask |= GDK_BUTTON_MOTION_MASK;
4920 }
4921 if ((emask & kExposureMask)) {
4922 lxemask |= GDK_EXPOSURE_MASK;
4923 }
4924 if ((emask & kStructureNotifyMask)) {
4925 lxemask |= GDK_STRUCTURE_MASK;
4926 }
4927 if ((emask & kEnterWindowMask)) {
4928 lxemask |= GDK_ENTER_NOTIFY_MASK;
4929 }
4930 if ((emask & kLeaveWindowMask)) {
4931 lxemask |= GDK_LEAVE_NOTIFY_MASK;
4932 }
4933 if ((emask & kFocusChangeMask)) {
4934 lxemask |= GDK_FOCUS_CHANGE_MASK;
4935 }
4936 xemask = (UInt_t) lxemask;
4937 } else {
4938 emask = 0;
4939 if ((xemask & GDK_KEY_PRESS_MASK)) {
4940 emask |= kKeyPressMask;
4941 }
4942 if ((xemask & GDK_KEY_RELEASE_MASK)) {
4943 emask |= kKeyReleaseMask;
4944 }
4945 if ((xemask & GDK_BUTTON_PRESS_MASK)) {
4946 emask |= kButtonPressMask;
4947 }
4948 if ((xemask & GDK_BUTTON_RELEASE_MASK)) {
4949 emask |= kButtonReleaseMask;
4950 }
4951 if ((xemask & GDK_POINTER_MOTION_MASK)) {
4952 emask |= kPointerMotionMask;
4953 }
4954 if ((xemask & GDK_BUTTON_MOTION_MASK)) {
4955 emask |= kButtonMotionMask;
4956 }
4957 if ((xemask & GDK_EXPOSURE_MASK)) {
4958 emask |= kExposureMask;
4959 }
4960 if ((xemask & GDK_STRUCTURE_MASK)) {
4961 emask |= kStructureNotifyMask;
4962 }
4963 if ((xemask & GDK_ENTER_NOTIFY_MASK)) {
4964 emask |= kEnterWindowMask;
4965 }
4966 if ((xemask & GDK_LEAVE_NOTIFY_MASK)) {
4967 emask |= kLeaveWindowMask;
4968 }
4969 if ((xemask & GDK_FOCUS_CHANGE_MASK)) {
4970 emask |= kFocusChangeMask;
4971 }
4972 }
4973}
4974
4975////////////////////////////////////////////////////////////////////////////////
4976/// Map a SetWindowAttributes_t to a GdkWindowAttr structure.
4977
4979 ULong_t & xmask,
4980 GdkWindowAttr & xattr)
4981{
4982 Mask_t mask = attr->fMask;
4983 xmask = 0;
4984
4985 if ((mask & kWAOverrideRedirect)) {
4986 xmask |= GDK_WA_NOREDIR;
4987 xattr.override_redirect = attr->fOverrideRedirect;
4988 }
4989 if ((mask & kWAEventMask)) {
4990 UInt_t xmsk, msk = (UInt_t) attr->fEventMask;
4991 MapEventMask(msk, xmsk, kTRUE);
4992 xattr.event_mask = xmsk;
4993 }
4994 if ((mask & kWAColormap)) {
4995 xmask |= GDK_WA_COLORMAP;
4996 xattr.colormap = (GdkColormap *) attr->fColormap;
4997 }
4998 if ((mask & kWACursor)) {
4999 xmask |= GDK_WA_CURSOR;
5000 if (attr->fCursor != kNone) {
5001 xattr.cursor = (GdkCursor *) attr->fCursor;
5002 }
5003 }
5004 xattr.wclass = GDK_INPUT_OUTPUT;
5005}
5006
5007////////////////////////////////////////////////////////////////////////////////
5008/// Map a GCValues_t to a XCGValues structure if tox is true. Map
5009/// the other way in case tox is false.
5010
5012 ULong_t & xmask, GdkGCValues & xgval, Bool_t tox)
5013{
5014 if (tox) {
5015 // map GCValues_t to XGCValues
5016 Mask_t mask = gval.fMask;
5017 xmask = 0;
5018
5019 if ((mask & kGCFunction)) {
5020 xmask |= GDK_GC_FUNCTION;
5021 switch (gval.fFunction) {
5022 case kGXclear:
5023 xgval.function = GDK_CLEAR;
5024 break;
5025 case kGXand:
5026 xgval.function = GDK_AND;
5027 break;
5028 case kGXandReverse:
5029 xgval.function = GDK_AND_REVERSE;
5030 break;
5031 case kGXcopy:
5032 xgval.function = GDK_COPY;
5033 break;
5034 case kGXandInverted:
5035 xgval.function = GDK_AND_INVERT;
5036 break;
5037 case kGXnoop:
5038 xgval.function = GDK_NOOP;
5039 break;
5040 case kGXxor:
5041 xgval.function = GDK_XOR;
5042 break;
5043 case kGXor:
5044 xgval.function = GDK_OR;
5045 break;
5046 case kGXequiv:
5047 xgval.function = GDK_EQUIV;
5048 break;
5049 case kGXinvert:
5050 xgval.function = GDK_INVERT;
5051 break;
5052 case kGXorReverse:
5053 xgval.function = GDK_OR_REVERSE;
5054 break;
5055 case kGXcopyInverted:
5056 xgval.function = GDK_COPY_INVERT;
5057 break;
5058 case kGXorInverted:
5059 xgval.function = GDK_OR_INVERT;
5060 break;
5061 case kGXnand:
5062 xgval.function = GDK_NAND;
5063 break;
5064 case kGXset:
5065 xgval.function = GDK_SET;
5066 break;
5067 }
5068 }
5069 if (mask & kGCSubwindowMode) {
5070 xmask |= GDK_GC_SUBWINDOW;
5071 if (gval.fSubwindowMode == kIncludeInferiors) {
5072 xgval.subwindow_mode = GDK_INCLUDE_INFERIORS;
5073 } else {
5074 xgval.subwindow_mode = GDK_CLIP_BY_CHILDREN;
5075 }
5076 }
5077 if (mask & kGCForeground) {
5078 xmask |= GDK_GC_FOREGROUND;
5079 xgval.foreground.pixel = gval.fForeground;
5080 xgval.foreground.red = GetRValue(gval.fForeground);
5081 xgval.foreground.green = GetGValue(gval.fForeground);
5082 xgval.foreground.blue = GetBValue(gval.fForeground);
5083 }
5084 if (mask & kGCBackground) {
5085 xmask |= GDK_GC_BACKGROUND;
5086 xgval.background.pixel = gval.fBackground;
5087 xgval.background.red = GetRValue(gval.fBackground);
5088 xgval.background.green = GetGValue(gval.fBackground);
5089 xgval.background.blue = GetBValue(gval.fBackground);
5090 }
5091 if (mask & kGCLineWidth) {
5092 xmask |= GDK_GC_LINE_WIDTH;
5093 xgval.line_width = gval.fLineWidth;
5094 }
5095 if (mask & kGCLineStyle) {
5096 xmask |= GDK_GC_LINE_STYLE;
5097 xgval.line_style = (GdkLineStyle) gval.fLineStyle; // ident mapping
5098 }
5099 if (mask & kGCCapStyle) {
5100 xmask |= GDK_GC_CAP_STYLE;
5101 xgval.cap_style = (GdkCapStyle) gval.fCapStyle; // ident mapping
5102 }
5103 if (mask & kGCJoinStyle) {
5104 xmask |= GDK_GC_JOIN_STYLE;
5105 xgval.join_style = (GdkJoinStyle) gval.fJoinStyle; // ident mapping
5106 }
5107 if ((mask & kGCFillStyle)) {
5108 xmask |= GDK_GC_FILL;
5109 xgval.fill = (GdkFill) gval.fFillStyle; // ident mapping
5110 }
5111 if ((mask & kGCTile)) {
5112 xmask |= GDK_GC_TILE;
5113 xgval.tile = (GdkPixmap *) gval.fTile;
5114 }
5115 if ((mask & kGCStipple)) {
5116 xmask |= GDK_GC_STIPPLE;
5117 xgval.stipple = (GdkPixmap *) gval.fStipple;
5118 }
5119 if ((mask & kGCTileStipXOrigin)) {
5120 xmask |= GDK_GC_TS_X_ORIGIN;
5121 xgval.ts_x_origin = gval.fTsXOrigin;
5122 }
5123 if ((mask & kGCTileStipYOrigin)) {
5124 xmask |= GDK_GC_TS_Y_ORIGIN;
5125 xgval.ts_y_origin = gval.fTsYOrigin;
5126 }
5127 if ((mask & kGCFont)) {
5128 xmask |= GDK_GC_FONT;
5129 xgval.font = (GdkFont *) gval.fFont;
5130 }
5131 if ((mask & kGCGraphicsExposures)) {
5132 xmask |= GDK_GC_EXPOSURES;
5133 xgval.graphics_exposures = gval.fGraphicsExposures;
5134 }
5135 if ((mask & kGCClipXOrigin)) {
5136 xmask |= GDK_GC_CLIP_X_ORIGIN;
5137 xgval.clip_x_origin = gval.fClipXOrigin;
5138 }
5139 if ((mask & kGCClipYOrigin)) {
5140 xmask |= GDK_GC_CLIP_Y_ORIGIN;
5141 xgval.clip_y_origin = gval.fClipYOrigin;
5142 }
5143 if ((mask & kGCClipMask)) {
5144 xmask |= GDK_GC_CLIP_MASK;
5145 xgval.clip_mask = (GdkPixmap *) gval.fClipMask;
5146 }
5147 } else {
5148 // map XValues to GCValues_t
5149 Mask_t mask = 0;
5150
5151 if ((xmask & GDK_GC_FUNCTION)) {
5152 mask |= kGCFunction;
5153 gval.fFunction = (EGraphicsFunction) xgval.function; // ident mapping
5154 switch (xgval.function) {
5155 case GDK_CLEAR:
5156 gval.fFunction = kGXclear;
5157 break;
5158 case GDK_AND:
5159 gval.fFunction = kGXand;
5160 break;
5161 case GDK_AND_REVERSE:
5162 gval.fFunction = kGXandReverse;
5163 break;
5164 case GDK_COPY:
5165 gval.fFunction = kGXcopy;
5166 break;
5167 case GDK_AND_INVERT:
5169 break;
5170 case GDK_NOOP:
5171 gval.fFunction = kGXnoop;
5172 break;
5173 case GDK_XOR:
5174 gval.fFunction = kGXxor;
5175 break;
5176 case GDK_OR:
5177 gval.fFunction = kGXor;
5178 break;
5179 case GDK_EQUIV:
5180 gval.fFunction = kGXequiv;
5181 break;
5182 case GDK_INVERT:
5183 gval.fFunction = kGXinvert;
5184 break;
5185 case GDK_OR_REVERSE:
5186 gval.fFunction = kGXorReverse;
5187 break;
5188 case GDK_COPY_INVERT:
5190 break;
5191 case GDK_OR_INVERT:
5192 gval.fFunction = kGXorInverted;
5193 break;
5194 case GDK_NAND:
5195 gval.fFunction = kGXnand;
5196 break;
5197 case GDK_SET:
5198 gval.fFunction = kGXset;
5199 break;
5200 }
5201 }
5202 if (xmask & GDK_GC_SUBWINDOW) {
5203 mask |= kGCSubwindowMode;
5204 if (xgval.subwindow_mode == GDK_INCLUDE_INFERIORS)
5206 else
5208 }
5209 if ((xmask & GDK_GC_FOREGROUND)) {
5210 mask |= kGCForeground;
5211 gval.fForeground = xgval.foreground.pixel;
5212 }
5213 if ((xmask & GDK_GC_BACKGROUND)) {
5214 mask |= kGCBackground;
5215 gval.fBackground = xgval.background.pixel;
5216 }
5217 if ((xmask & GDK_GC_LINE_WIDTH)) {
5218 mask |= kGCLineWidth;
5219 gval.fLineWidth = xgval.line_width;
5220 }
5221 if ((xmask & GDK_GC_LINE_STYLE)) {
5222 mask |= kGCLineStyle;
5223 gval.fLineStyle = xgval.line_style; // ident mapping
5224 }
5225 if ((xmask & GDK_GC_CAP_STYLE)) {
5226 mask |= kGCCapStyle;
5227 gval.fCapStyle = xgval.cap_style; // ident mapping
5228 }
5229 if ((xmask & GDK_GC_JOIN_STYLE)) {
5230 mask |= kGCJoinStyle;
5231 gval.fJoinStyle = xgval.join_style; // ident mapping
5232 }
5233 if ((xmask & GDK_GC_FILL)) {
5234 mask |= kGCFillStyle;
5235 gval.fFillStyle = xgval.fill; // ident mapping
5236 }
5237 if ((xmask & GDK_GC_TILE)) {
5238 mask |= kGCTile;
5239 gval.fTile = (Pixmap_t) xgval.tile;
5240 }
5241 if ((xmask & GDK_GC_STIPPLE)) {
5242 mask |= kGCStipple;
5243 gval.fStipple = (Pixmap_t) xgval.stipple;
5244 }
5245 if ((xmask & GDK_GC_TS_X_ORIGIN)) {
5246 mask |= kGCTileStipXOrigin;
5247 gval.fTsXOrigin = xgval.ts_x_origin;
5248 }
5249 if ((xmask & GDK_GC_TS_Y_ORIGIN)) {
5250 mask |= kGCTileStipYOrigin;
5251 gval.fTsYOrigin = xgval.ts_y_origin;
5252 }
5253 if ((xmask & GDK_GC_FONT)) {
5254 mask |= kGCFont;
5255 gval.fFont = (FontH_t) xgval.font;
5256 }
5257 if ((xmask & GDK_GC_EXPOSURES)) {
5258 mask |= kGCGraphicsExposures;
5259 gval.fGraphicsExposures = (Bool_t) xgval.graphics_exposures;
5260 }
5261 if ((xmask & GDK_GC_CLIP_X_ORIGIN)) {
5262 mask |= kGCClipXOrigin;
5263 gval.fClipXOrigin = xgval.clip_x_origin;
5264 }
5265 if ((xmask & GDK_GC_CLIP_Y_ORIGIN)) {
5266 mask |= kGCClipYOrigin;
5267 gval.fClipYOrigin = xgval.clip_y_origin;
5268 }
5269 if ((xmask & GDK_GC_CLIP_MASK)) {
5270 mask |= kGCClipMask;
5271 gval.fClipMask = (Pixmap_t) xgval.clip_mask;
5272 }
5273 gval.fMask = mask;
5274 }
5275}
5276
5277////////////////////////////////////////////////////////////////////////////////
5278/// Get window attributes and return filled in attributes structure.
5279
5281{
5282 if (!id) return;
5283
5284 RECT rcClient, rcWind;
5285 ::GetClientRect((HWND)GDK_DRAWABLE_XID((GdkWindow *) id), &rcClient);
5286 ::GetWindowRect((HWND)GDK_DRAWABLE_XID((GdkWindow *) id), &rcWind);
5287
5288 gdk_window_get_geometry((GdkWindow *) id, &attr.fX, &attr.fY,
5289 &attr.fWidth, &attr.fHeight, &attr.fDepth);
5290 attr.fX = ((rcWind.right - rcWind.left) - rcClient.right) / 2;
5291 attr.fY = ((rcWind.bottom - rcWind.top) - rcClient.bottom) - attr.fX;
5292
5293 attr.fRoot = (Window_t) GDK_ROOT_PARENT();
5294 attr.fColormap = (Colormap_t) gdk_window_get_colormap((GdkWindow *) id);
5295 attr.fBorderWidth = 0;
5296 attr.fVisual = gdk_window_get_visual((GdkWindow *) id);
5297 attr.fClass = kInputOutput;
5299 attr.fSaveUnder = kFALSE;
5300 attr.fMapInstalled = kTRUE;
5301 attr.fOverrideRedirect = kFALSE; // boolean value for override-redirect
5302
5303 if (!gdk_window_is_visible((GdkWindow *) id)) {
5304 attr.fMapState = kIsUnmapped;
5305 } else if (!gdk_window_is_viewable((GdkWindow *) id)) {
5306 attr.fMapState = kIsUnviewable;
5307 } else {
5308 attr.fMapState = kIsViewable;
5309 }
5310
5311 UInt_t tmp_mask = (UInt_t)gdk_window_get_events((GdkWindow *) id);
5312 UInt_t evmask;
5313 MapEventMask(evmask, tmp_mask, kFALSE);
5314
5315 attr.fYourEventMask = evmask;
5316}
5317
5318////////////////////////////////////////////////////////////////////////////////
5319///
5320
5322{
5323 return 0;
5324}
5325
5326////////////////////////////////////////////////////////////////////////////////
5327/// Get maximum number of planes.
5328
5330{
5331 return gdk_visual_get_best_depth();
5332}
5333
5334////////////////////////////////////////////////////////////////////////////////
5335/// Return atom handle for atom_name. If it does not exist
5336/// create it if only_if_exist is false. Atoms are used to communicate
5337/// between different programs (i.e. window manager) via the X server.
5338
5339Atom_t TGWin32::InternAtom(const char *atom_name, Bool_t only_if_exist)
5340{
5341 GdkAtom a = gdk_atom_intern((const gchar *) atom_name, only_if_exist);
5342
5343 if (a == None) return kNone;
5344 return (Atom_t) a;
5345}
5346
5347////////////////////////////////////////////////////////////////////////////////
5348/// Return handle to the default root window created when calling
5349/// XOpenDisplay().
5350
5352{
5353 return (Window_t) GDK_ROOT_PARENT();
5354}
5355
5356////////////////////////////////////////////////////////////////////////////////
5357/// Return the parent of the window.
5358
5360{
5361 if (!id) return (Window_t)0;
5362
5363 return (Window_t)gdk_window_get_parent((GdkWindow *) id);
5364}
5365
5366////////////////////////////////////////////////////////////////////////////////
5367/// Load font and query font. If font is not found 0 is returned,
5368/// otherwise an opaque pointer to the FontStruct_t.
5369/// Free the loaded font using DeleteFont().
5370
5372{
5373 char family[100], weight[32], slant[32], fontname[256];
5374 Int_t n1, pixel, numfields;
5375
5376 numfields = sscanf(font_name, "%s -%d%n", family, &pixel, &n1);
5377 if (numfields == 2) {
5378 sprintf(weight,"medium");
5379 if (strstr(font_name, "bold"))
5380 sprintf(weight,"bold");
5381 sprintf(slant,"r");
5382 if (strstr(font_name, "italic"))
5383 sprintf(slant,"i");
5384 sprintf(fontname, "-*-%s-%s-%s-*-*-%d-*-*-*-*-*-iso8859-1",
5385 family, weight, slant, pixel);
5386 }
5387 else
5388 sprintf(fontname, "%s", font_name);
5389 return (FontStruct_t) gdk_font_load(fontname);
5390}
5391
5392////////////////////////////////////////////////////////////////////////////////
5393/// Return handle to font described by font structure.
5394
5396{
5397 if (fs) {
5398 return (FontH_t)gdk_font_ref((GdkFont *) fs);
5399 }
5400 return 0;
5401}
5402
5403////////////////////////////////////////////////////////////////////////////////
5404/// Explicitely delete font structure obtained with LoadQueryFont().
5405
5407{
5408 gdk_font_unref((GdkFont *) fs);
5409}
5410
5411////////////////////////////////////////////////////////////////////////////////
5412/// Create a graphics context using the values set in gval (but only for
5413/// those entries that are in the mask).
5414
5416{
5417 if (!id) return (GContext_t)0;
5418
5419 GdkGCValues xgval;
5420 ULong_t xmask = 0;
5421
5422 if (gval) MapGCValues(*gval, xmask, xgval, kTRUE);
5423
5424 xgval.subwindow_mode = GDK_CLIP_BY_CHILDREN; // GDK_INCLUDE_INFERIORS;
5425
5426 GdkGC *gc = gdk_gc_new_with_values((GdkDrawable *) id,
5427 &xgval, (GdkGCValuesMask)xmask);
5428 return (GContext_t) gc;
5429}
5430
5431////////////////////////////////////////////////////////////////////////////////
5432/// Change entries in an existing graphics context, gc, by values from gval.
5433
5435{
5436 GdkGCValues xgval;
5437 ULong_t xmask = 0;
5438 Mask_t mask = 0;
5439
5440 if (gval) {
5441 mask = gval->fMask;
5442 MapGCValues(*gval, xmask, xgval, kTRUE);
5443 }
5444 if (mask & kGCForeground) {
5445 gdk_gc_set_foreground((GdkGC *) gc, &xgval.foreground);
5446 }
5447 if (mask & kGCBackground) {
5448 gdk_gc_set_background((GdkGC *) gc, &xgval.background);
5449 }
5450 if (mask & kGCFont) {
5451 gdk_gc_set_font((GdkGC *) gc, xgval.font);
5452 }
5453 if (mask & kGCFunction) {
5454 gdk_gc_set_function((GdkGC *) gc, xgval.function);
5455 }
5456 if (mask & kGCFillStyle) {
5457 gdk_gc_set_fill((GdkGC *) gc, xgval.fill);
5458 }
5459 if (mask & kGCTile) {
5460 gdk_gc_set_tile((GdkGC *) gc, xgval.tile);
5461 }
5462 if (mask & kGCStipple) {
5463 gdk_gc_set_stipple((GdkGC *) gc, xgval.stipple);
5464 }
5465 if ((mask & kGCTileStipXOrigin) || (mask & kGCTileStipYOrigin)) {
5466 gdk_gc_set_ts_origin((GdkGC *) gc, xgval.ts_x_origin,
5467 xgval.ts_y_origin);
5468 }
5469 if ((mask & kGCClipXOrigin) || (mask & kGCClipYOrigin)) {
5470 gdk_gc_set_clip_origin((GdkGC *) gc, xgval.clip_x_origin,
5471 xgval.clip_y_origin);
5472 }
5473 if (mask & kGCClipMask) {
5474 gdk_gc_set_clip_mask((GdkGC *) gc, xgval.clip_mask);
5475 }
5476 if (mask & kGCGraphicsExposures) {
5477 gdk_gc_set_exposures((GdkGC *) gc, xgval.graphics_exposures);
5478 }
5479 if (mask & kGCLineWidth) {
5480 gdk_gc_set_values((GdkGC *) gc, &xgval, GDK_GC_LINE_WIDTH);
5481 }
5482 if (mask & kGCLineStyle) {
5483 gdk_gc_set_values((GdkGC *) gc, &xgval, GDK_GC_LINE_STYLE);
5484 }
5485 if (mask & kGCCapStyle) {
5486 gdk_gc_set_values((GdkGC *) gc, &xgval, GDK_GC_CAP_STYLE);
5487 }
5488 if (mask & kGCJoinStyle) {
5489 gdk_gc_set_values((GdkGC *) gc, &xgval, GDK_GC_JOIN_STYLE);
5490 }
5491 if (mask & kGCSubwindowMode) {
5492 gdk_gc_set_subwindow((GdkGC *) gc, xgval.subwindow_mode);
5493 }
5494}
5495
5496////////////////////////////////////////////////////////////////////////////////
5497/// Copies graphics context from org to dest. Only the values specified
5498/// in mask are copied. Both org and dest must exist.
5499
5501{
5502 GCValues_t gval;
5503 GdkGCValues xgval;
5504 ULong_t xmask;
5505
5506 if (!mask) {
5507 // in this case copy all fields
5508 mask = (Mask_t) - 1;
5509 }
5510
5511 gval.fMask = mask; // only set fMask used to convert to xmask
5512 MapGCValues(gval, xmask, xgval, kTRUE);
5513
5514 gdk_gc_copy((GdkGC *) dest, (GdkGC *) org);
5515}
5516
5517////////////////////////////////////////////////////////////////////////////////
5518/// Explicitely delete a graphics context.
5519
5521{
5522 gdk_gc_unref((GdkGC *) gc);
5523}
5524
5525////////////////////////////////////////////////////////////////////////////////
5526/// Create cursor handle (just return cursor from cursor pool fCursors).
5527
5529{
5530 return (Cursor_t) fCursors[cursor];
5531}
5532
5533////////////////////////////////////////////////////////////////////////////////
5534/// Creates a pixmap of the width and height you specified
5535/// and returns a pixmap ID that identifies it.
5536
5538{
5539 GdkWindow *wid = (GdkWindow *)id;
5540 if (!id) wid = GDK_ROOT_PARENT();
5541
5542 return (Pixmap_t) gdk_pixmap_new(wid, w, h, gdk_visual_get_best_depth());
5543}
5544
5545////////////////////////////////////////////////////////////////////////////////
5546/// Create a pixmap from bitmap data. Ones will get foreground color and
5547/// zeroes background color.
5548
5550 UInt_t width, UInt_t height,
5551 ULong_t forecolor, ULong_t backcolor,
5552 Int_t depth)
5553{
5554 GdkColor fore, back;
5555 fore.pixel = forecolor;
5556 fore.red = GetRValue(forecolor);
5557 fore.green = GetGValue(forecolor);
5558 fore.blue = GetBValue(forecolor);
5559
5560 back.pixel = backcolor;
5561 back.red = GetRValue(backcolor);
5562 back.green = GetGValue(backcolor);
5563 back.blue = GetBValue(backcolor);
5564
5565 GdkWindow *wid = (GdkWindow *)id;
5566 if (!id) wid = GDK_ROOT_PARENT();
5567
5568 return (Pixmap_t) gdk_pixmap_create_from_data(wid, (char *) bitmap, width,
5569 height, depth, &fore, &back);
5570}
5571
5572////////////////////////////////////////////////////////////////////////////////
5573/// Create a bitmap (i.e. pixmap with depth 1) from the bitmap data.
5574
5576 UInt_t width, UInt_t height)
5577{
5578 GdkWindow *wid = (GdkWindow *)id;
5579 if (!id) wid = GDK_ROOT_PARENT();
5580
5581 Pixmap_t ret = (Pixmap_t) gdk_bitmap_create_from_data(wid,
5582 (char *)bitmap, width, height);
5583 return ret;
5584}
5585
5586////////////////////////////////////////////////////////////////////////////////
5587/// Explicitely delete pixmap resource.
5588
5590{
5591 gdk_pixmap_unref((GdkPixmap *) pmap);
5592}
5593
5594////////////////////////////////////////////////////////////////////////////////
5595/// Create a picture pixmap from data on file. The picture attributes
5596/// are used for input and output. Returns kTRUE in case of success,
5597/// kFALSE otherwise. If mask does not exist it is set to kNone.
5598
5600 Pixmap_t & pict,
5601 Pixmap_t & pict_mask,
5602 PictureAttributes_t & attr)
5603{
5604 GdkBitmap *gdk_pixmap_mask;
5605 if (strstr(filename, ".xpm") || strstr(filename, ".XPM")) {
5606 GdkWindow *wid = (GdkWindow *)id;
5607 if (!id) wid = GDK_ROOT_PARENT();
5608
5609 pict = (Pixmap_t) gdk_pixmap_create_from_xpm(wid, &gdk_pixmap_mask, 0,
5610 filename);
5611 pict_mask = (Pixmap_t) gdk_pixmap_mask;
5612 } else if (strstr(filename, ".gif") || strstr(filename, ".GIF")) {
5613 pict = ReadGIF(0, 0, filename, id);
5614 pict_mask = kNone;
5615 }
5616
5617 gdk_drawable_get_size((GdkPixmap *) pict, (int *) &attr.fWidth,
5618 (int *) &attr.fHeight);
5619 if (pict) {
5620 return kTRUE;
5621 }
5622 if (pict_mask) {
5623 pict_mask = kNone;
5624 }
5625 return kFALSE;
5626}
5627
5628////////////////////////////////////////////////////////////////////////////////
5629/// Create a pixture pixmap from data. The picture attributes
5630/// are used for input and output. Returns kTRUE in case of success,
5631/// kFALSE otherwise. If mask does not exist it is set to kNone.
5632
5634 Pixmap_t & pict,
5635 Pixmap_t & pict_mask,
5636 PictureAttributes_t & attr)
5637{
5638 GdkBitmap *gdk_pixmap_mask;
5639 GdkWindow *wid = (GdkWindow *)id;
5640 if (!id) wid = GDK_ROOT_PARENT();
5641
5642 pict = (Pixmap_t) gdk_pixmap_create_from_xpm_d(wid, &gdk_pixmap_mask, 0,
5643 data);
5644 pict_mask = (Pixmap_t) gdk_pixmap_mask;
5645
5646 if (pict) {
5647 return kTRUE;
5648 }
5649 if (pict_mask) {
5650 pict_mask = kNone;
5651 }
5652 return kFALSE;
5653}
5654
5655////////////////////////////////////////////////////////////////////////////////
5656/// Read picture data from file and store in ret_data. Returns kTRUE in
5657/// case of success, kFALSE otherwise.
5658
5659Bool_t TGWin32::ReadPictureDataFromFile(const char *filename, char ***ret_data)
5660{
5661 Bool_t ret = kFALSE;
5662 GdkPixmap *pxm = gdk_pixmap_create_from_xpm(NULL, NULL, NULL, filename);
5663 ret_data = 0;
5664
5665 if (pxm==NULL) return kFALSE;
5666
5667 HBITMAP hbm = (HBITMAP)GDK_DRAWABLE_XID(pxm);
5668 BITMAP bitmap;
5669
5670 ret = ::GetObject(hbm, sizeof(HBITMAP), (LPVOID)&bitmap);
5671 ret_data = (char ***)&bitmap.bmBits;
5672 gdk_pixmap_unref(pxm);
5673 return ret;
5674}
5675
5676////////////////////////////////////////////////////////////////////////////////
5677/// Delete picture data created by the function ReadPictureDataFromFile.
5678
5680{
5681 free(data);
5682}
5683
5684////////////////////////////////////////////////////////////////////////////////
5685/// Specify a dash pattertn. Offset defines the phase of the pattern.
5686/// Each element in the dash_list array specifies the length (in pixels)
5687/// of a segment of the pattern. N defines the length of the list.
5688
5689void TGWin32::SetDashes(GContext_t gc, Int_t offset, const char *dash_list,
5690 Int_t n)
5691{
5692 int i;
5693 gint8 dashes[32];
5694 for (i = 0; i < n; i++) {
5695 dashes[i] = (gint8) dash_list[i];
5696 }
5697 for (i = n; i < 32; i++) {
5698 dashes[i] = (gint8) 0;
5699 }
5700
5701 gdk_gc_set_dashes((GdkGC *) gc, offset, dashes, n);
5702}
5703
5704////////////////////////////////////////////////////////////////////////////////
5705/// Map a ColorStruct_t to a XColor structure.
5706
5707void TGWin32::MapColorStruct(ColorStruct_t * color, GdkColor & xcolor)
5708{
5709 xcolor.pixel = color->fPixel;
5710 xcolor.red = color->fRed;
5711 xcolor.green = color->fGreen;
5712 xcolor.blue = color->fBlue;
5713}
5714
5715////////////////////////////////////////////////////////////////////////////////
5716/// Parse string cname containing color name, like "green" or "#00FF00".
5717/// It returns a filled in ColorStruct_t. Returns kFALSE in case parsing
5718/// failed, kTRUE in case of success. On success, the ColorStruct_t
5719/// fRed, fGreen and fBlue fields are all filled in and the mask is set
5720/// for all three colors, but fPixel is not set.
5721
5722Bool_t TGWin32::ParseColor(Colormap_t cmap, const char *cname,
5723 ColorStruct_t & color)
5724{
5725 GdkColor xc;
5726
5727 if (gdk_color_parse((char *)cname, &xc)) {
5728 color.fPixel = xc.pixel = RGB(xc.red, xc.green, xc.blue);
5729 color.fRed = xc.red;
5730 color.fGreen = xc.green;
5731 color.fBlue = xc.blue;
5732 return kTRUE;
5733 }
5734 return kFALSE;
5735}
5736
5737////////////////////////////////////////////////////////////////////////////////
5738/// Find and allocate a color cell according to the color values specified
5739/// in the ColorStruct_t. If no cell could be allocated it returns kFALSE,
5740/// otherwise kTRUE.
5741
5743{
5744 int status;
5745 GdkColor xc;
5746
5747 xc.red = color.fRed;
5748 xc.green = color.fGreen;
5749 xc.blue = color.fBlue;
5750
5751 status = gdk_colormap_alloc_color((GdkColormap *) cmap, &xc, FALSE, TRUE);
5752 color.fPixel = xc.pixel;
5753
5754 return kTRUE; // status != 0 ? kTRUE : kFALSE;
5755}
5756
5757////////////////////////////////////////////////////////////////////////////////
5758/// Fill in the primary color components for a specific pixel value.
5759/// On input fPixel should be set on return the fRed, fGreen and
5760/// fBlue components will be set.
5761
5763{
5764 GdkColor xc;
5765 xc.pixel = color.fPixel;
5766
5767 GdkColorContext *cc = gdk_color_context_new(gdk_visual_get_system(), fColormap);
5768 gdk_color_context_query_color(cc, &xc);
5769 gdk_color_context_free(cc);
5770
5771 color.fPixel = xc.pixel;
5772 color.fRed = xc.red;
5773 color.fGreen = xc.green;
5774 color.fBlue = xc.blue;
5775}
5776
5777////////////////////////////////////////////////////////////////////////////////
5778/// Free color cell with specified pixel value.
5779
5781{
5782 // FIXME: to be implemented.
5783}
5784
5785////////////////////////////////////////////////////////////////////////////////
5786/// Check if there is for window "id" an event of type "type". If there
5787/// is fill in the event structure and return true. If no such event
5788/// return false.
5789
5791{
5792 if (!id) return kFALSE;
5793
5794 Event_t tev;
5795 GdkEvent xev;
5796
5797 tev.fType = type;
5798 tev.fWindow = (Window_t) id;
5799 tev.fTime = 0;
5800 tev.fX = tev.fY = 0;
5801 tev.fXRoot = tev.fYRoot = 0;
5802 tev.fCode = 0;
5803 tev.fState = 0;
5804 tev.fWidth = tev.fHeight = 0;
5805 tev.fCount = 0;
5806 tev.fSendEvent = kFALSE;
5807 tev.fHandle = 0;
5808 tev.fFormat = 0;
5809 tev.fUser[0] = tev.fUser[1] = tev.fUser[2] = tev.fUser[3] = tev.fUser[4] = 0L;
5810
5811 TGWin32MainThread::LockMSG();
5812 MapEvent(tev, xev, kTRUE);
5813 Bool_t r = gdk_check_typed_window_event((GdkWindow *) id, xev.type, &xev);
5814
5815 if (r) MapEvent(ev, xev, kFALSE);
5816 TGWin32MainThread::UnlockMSG();
5817
5818 return r ? kTRUE : kFALSE;
5819}
5820
5821////////////////////////////////////////////////////////////////////////////////
5822/// Send event ev to window id.
5823
5825{
5826 if (!ev || !id) return;
5827
5828 TGWin32MainThread::LockMSG();
5829 GdkEvent xev;
5830 MapEvent(*ev, xev, kTRUE);
5831 gdk_event_put(&xev);
5832 TGWin32MainThread::UnlockMSG();
5833}
5834
5835////////////////////////////////////////////////////////////////////////////////
5836/// Returns number of pending events.
5837
5839{
5840 Int_t ret;
5841
5842 TGWin32MainThread::LockMSG();
5843 ret = (Int_t)gdk_event_queue_find_first();
5844 TGWin32MainThread::UnlockMSG();
5845
5846 return ret;
5847}
5848
5849////////////////////////////////////////////////////////////////////////////////
5850/// Copies first pending event from event queue to Event_t structure
5851/// and removes event from queue. Not all of the event fields are valid
5852/// for each event type, except fType and fWindow.
5853
5855{
5856 TGWin32MainThread::LockMSG();
5857 GdkEvent *xev = gdk_event_unqueue();
5858
5859 // fill in Event_t
5860 event.fType = kOtherEvent; // bb add
5861 if (xev == NULL) {
5862 TGWin32MainThread::UnlockMSG();
5863 return;
5864 }
5865 MapEvent(event, *xev, kFALSE);
5866 gdk_event_free (xev);
5867 TGWin32MainThread::UnlockMSG();
5868}
5869
5870////////////////////////////////////////////////////////////////////////////////
5871/// Map modifier key state to or from X.
5872
5873void TGWin32::MapModifierState(UInt_t & state, UInt_t & xstate, Bool_t tox)
5874{
5875 if (tox) {
5876 xstate = state;
5877 if (state & kAnyModifier) {
5878 xstate = GDK_MODIFIER_MASK;
5879 }
5880 } else {
5881 state = xstate;
5882 }
5883}
5884
5885static void _set_event_time(GdkEvent &event, UInt_t time)
5886{
5887 // set gdk event time
5888
5889 switch (event.type) {
5890 case GDK_MOTION_NOTIFY:
5891 event.motion.time = time;
5892 case GDK_BUTTON_PRESS:
5893 case GDK_2BUTTON_PRESS:
5894 case GDK_3BUTTON_PRESS:
5895 case GDK_BUTTON_RELEASE:
5896 case GDK_SCROLL:
5897 event.button.time = time;
5898 case GDK_KEY_PRESS:
5899 case GDK_KEY_RELEASE:
5900 event.key.time = time;
5901 case GDK_ENTER_NOTIFY:
5902 case GDK_LEAVE_NOTIFY:
5903 event.crossing.time = time;
5904 case GDK_PROPERTY_NOTIFY:
5905 event.property.time = time;
5906 case GDK_SELECTION_CLEAR:
5907 case GDK_SELECTION_REQUEST:
5908 case GDK_SELECTION_NOTIFY:
5909 event.selection.time = time;
5910 case GDK_PROXIMITY_IN:
5911 case GDK_PROXIMITY_OUT:
5912 event.proximity.time = time;
5913 case GDK_DRAG_ENTER:
5914 case GDK_DRAG_LEAVE:
5915 case GDK_DRAG_MOTION:
5916 case GDK_DRAG_STATUS:
5917 case GDK_DROP_START:
5918 case GDK_DROP_FINISHED:
5919 event.dnd.time = time;
5920 default: /* use current time */
5921 break;
5922 }
5923}
5924
5925////////////////////////////////////////////////////////////////////////////////
5926/// Map Event_t structure to gdk_event structure. If tox is false
5927/// map the other way.
5928
5929void TGWin32::MapEvent(Event_t & ev, GdkEvent & xev, Bool_t tox)
5930{
5931 if (tox) {
5932 // map from Event_t to gdk_event
5933 xev.type = GDK_NOTHING;
5934 if (ev.fType == kGKeyPress)
5935 xev.type = GDK_KEY_PRESS;
5936 if (ev.fType == kKeyRelease)
5937 xev.type = GDK_KEY_RELEASE;
5938 if (ev.fType == kButtonPress)
5939 xev.type = GDK_BUTTON_PRESS;
5940 if (ev.fType == kButtonRelease)
5941 xev.type = GDK_BUTTON_RELEASE;
5942 if (ev.fType == kMotionNotify)
5943 xev.type = GDK_MOTION_NOTIFY;
5944 if (ev.fType == kEnterNotify)
5945 xev.type = GDK_ENTER_NOTIFY;
5946 if (ev.fType == kLeaveNotify)
5947 xev.type = GDK_LEAVE_NOTIFY;
5948 if (ev.fType == kExpose)
5949 xev.type = GDK_EXPOSE;
5950 if (ev.fType == kConfigureNotify)
5951 xev.type = GDK_CONFIGURE;
5952 if (ev.fType == kMapNotify)
5953 xev.type = GDK_MAP;
5954 if (ev.fType == kUnmapNotify)
5955 xev.type = GDK_UNMAP;
5956 if (ev.fType == kDestroyNotify)
5957 xev.type = GDK_DESTROY;
5958 if (ev.fType == kClientMessage)
5959 xev.type = GDK_CLIENT_EVENT;
5960 if (ev.fType == kSelectionClear)
5961 xev.type = GDK_SELECTION_CLEAR;
5962 if (ev.fType == kSelectionRequest)
5963 xev.type = GDK_SELECTION_REQUEST;
5964 if (ev.fType == kSelectionNotify)
5965 xev.type = GDK_SELECTION_NOTIFY;
5966
5967 xev.any.type = xev.type;
5968 xev.any.send_event = ev.fSendEvent;
5969 if (ev.fType == kDestroyNotify) {
5970 xev.any.window = (GdkWindow *) ev.fWindow;
5971 }
5972 if (ev.fType == kFocusIn) {
5973 xev.type = GDK_FOCUS_CHANGE;
5974 xev.focus_change.type = xev.type;
5975 xev.focus_change.window = (GdkWindow *) ev.fWindow;
5976 xev.focus_change.in = TRUE;
5977 }
5978 if (ev.fType == kFocusOut) {
5979 xev.type = GDK_FOCUS_CHANGE;
5980 xev.focus_change.type = xev.type;
5981 xev.focus_change.window = (GdkWindow *) ev.fWindow;
5982 xev.focus_change.in = FALSE;
5983 }
5984 if (ev.fType == kGKeyPress || ev.fType == kKeyRelease) {
5985 xev.key.window = (GdkWindow *) ev.fWindow;
5986 xev.key.type = xev.type;
5987 MapModifierState(ev.fState, xev.key.state, kTRUE); // key mask
5988 xev.key.keyval = ev.fCode; // key code
5989 }
5990 if (ev.fType == kButtonPress || ev.fType == kButtonRelease) {
5991 xev.button.window = (GdkWindow *) ev.fWindow;
5992 xev.button.type = xev.type;
5993 xev.button.x = ev.fX;
5994 xev.button.y = ev.fY;
5995 xev.button.x_root = ev.fXRoot;
5996 xev.button.y_root = ev.fYRoot;
5997 MapModifierState(ev.fState, xev.button.state, kTRUE); // button mask
5998 xev.button.button = ev.fCode; // button code
5999 }
6000 if (ev.fType == kSelectionNotify) {
6001 xev.selection.window = (GdkWindow *) ev.fUser[0];
6002 xev.selection.requestor = (guint32) ev.fUser[0];
6003 xev.selection.selection = (GdkAtom) ev.fUser[1];
6004 xev.selection.target = (GdkAtom) ev.fUser[2];
6005 xev.selection.property = (GdkAtom) ev.fUser[3];
6006 xev.selection.type = xev.type;
6007 }
6008 if (ev.fType == kClientMessage) {
6009 if ((ev.fFormat == 32) && (ev.fHandle == gWM_DELETE_WINDOW)) {
6010 xev.type = GDK_DELETE;
6011 xev.any.type = xev.type;
6012 xev.any.window = (GdkWindow *) ev.fWindow;
6013 } else {
6014 xev.client.window = (GdkWindow *) ev.fWindow;
6015 xev.client.type = xev.type;
6016 xev.client.message_type = (GdkAtom) ev.fHandle;
6017 xev.client.data_format = ev.fFormat;
6018 xev.client.data.l[0] = ev.fUser[0];
6019 if (sizeof(ev.fUser[0]) > 4) {
6020 SplitLong(ev.fUser[1], xev.client.data.l[1],
6021 xev.client.data.l[3]);
6022 SplitLong(ev.fUser[2], xev.client.data.l[2],
6023 xev.client.data.l[4]);
6024 } else {
6025 xev.client.data.l[1] = ev.fUser[1];
6026 xev.client.data.l[2] = ev.fUser[2];
6027 xev.client.data.l[3] = ev.fUser[3];
6028 xev.client.data.l[4] = ev.fUser[4];
6029 }
6030 }
6031 }
6032 if (ev.fType == kMotionNotify) {
6033 xev.motion.window = (GdkWindow *) ev.fWindow;
6034 xev.motion.type = xev.type;
6035 xev.motion.x = ev.fX;
6036 xev.motion.y = ev.fY;
6037 xev.motion.x_root = ev.fXRoot;
6038 xev.motion.y_root = ev.fYRoot;
6039 }
6040 if ((ev.fType == kEnterNotify) || (ev.fType == kLeaveNotify)) {
6041 xev.crossing.window = (GdkWindow *) ev.fWindow;
6042 xev.crossing.type = xev.type;
6043 xev.crossing.x = ev.fX;
6044 xev.crossing.y = ev.fY;
6045 xev.crossing.x_root = ev.fXRoot;
6046 xev.crossing.y_root = ev.fYRoot;
6047 xev.crossing.mode = (GdkCrossingMode) ev.fCode; // NotifyNormal, NotifyGrab, NotifyUngrab
6048 MapModifierState(ev.fState, xev.crossing.state, kTRUE); // key or button mask
6049 }
6050 if (ev.fType == kExpose) {
6051 xev.expose.window = (GdkWindow *) ev.fWindow;
6052 xev.expose.type = xev.type;
6053 xev.expose.area.x = ev.fX;
6054 xev.expose.area.y = ev.fY;
6055 xev.expose.area.width = ev.fWidth; // width and
6056 xev.expose.area.height = ev.fHeight; // height of exposed area
6057 xev.expose.count = ev.fCount; // number of expose events still to come
6058 }
6059 if (ev.fType == kConfigureNotify) {
6060 xev.configure.window = (GdkWindow *) ev.fWindow;
6061 xev.configure.type = xev.type;
6062 xev.configure.x = ev.fX;
6063 xev.configure.y = ev.fY;
6064 xev.configure.width = ev.fWidth;
6065 xev.configure.height = ev.fHeight;
6066 }
6067 if (ev.fType == kSelectionClear) {
6068 xev.selection.window = (GdkWindow *) ev.fWindow;
6069 xev.selection.type = xev.type;
6070 xev.selection.selection = ev.fUser[0];
6071 }
6072 if (ev.fType == kSelectionRequest) {
6073 xev.selection.window = (GdkWindow *) ev.fUser[0];
6074 xev.selection.type = xev.type;
6075 xev.selection.selection = ev.fUser[1];
6076 xev.selection.target = ev.fUser[2];
6077 xev.selection.property = ev.fUser[3];
6078 }
6079 if ((ev.fType == kMapNotify) || (ev.fType == kUnmapNotify)) {
6080 xev.any.window = (GdkWindow *) ev.fWindow;
6081 }
6082 if (xev.type != GDK_CLIENT_EVENT)
6083 _set_event_time(xev, ev.fTime);
6084 } else {
6085 // map from gdk_event to Event_t
6086 ev.fType = kOtherEvent;
6087 if (xev.type == GDK_KEY_PRESS)
6088 ev.fType = kGKeyPress;
6089 if (xev.type == GDK_KEY_RELEASE)
6090 ev.fType = kKeyRelease;
6091 if (xev.type == GDK_BUTTON_PRESS)
6092 ev.fType = kButtonPress;
6093 if (xev.type == GDK_BUTTON_RELEASE)
6094 ev.fType = kButtonRelease;
6095 if (xev.type == GDK_MOTION_NOTIFY)
6096 ev.fType = kMotionNotify;
6097 if (xev.type == GDK_ENTER_NOTIFY)
6098 ev.fType = kEnterNotify;
6099 if (xev.type == GDK_LEAVE_NOTIFY)
6100 ev.fType = kLeaveNotify;
6101 if (xev.type == GDK_EXPOSE)
6102 ev.fType = kExpose;
6103 if (xev.type == GDK_CONFIGURE)
6105 if (xev.type == GDK_MAP)
6106 ev.fType = kMapNotify;
6107 if (xev.type == GDK_UNMAP)
6108 ev.fType = kUnmapNotify;
6109 if (xev.type == GDK_DESTROY)
6110 ev.fType = kDestroyNotify;
6111 if (xev.type == GDK_SELECTION_CLEAR)
6113 if (xev.type == GDK_SELECTION_REQUEST)
6115 if (xev.type == GDK_SELECTION_NOTIFY)
6117
6118 ev.fSendEvent = kFALSE; //xev.any.send_event ? kTRUE : kFALSE;
6119 ev.fTime = gdk_event_get_time((GdkEvent *)&xev);
6120 ev.fWindow = (Window_t) xev.any.window;
6121
6122 if ((xev.type == GDK_MAP) || (xev.type == GDK_UNMAP)) {
6123 ev.fWindow = (Window_t) xev.any.window;
6124 }
6125 if (xev.type == GDK_DELETE) {
6126 ev.fWindow = (Window_t) xev.any.window;
6127 ev.fType = kClientMessage;
6128 ev.fFormat = 32;
6130 ev.fUser[0] = (Long_t) gWM_DELETE_WINDOW;
6131 if (sizeof(ev.fUser[0]) > 4) {
6132 AsmLong(xev.client.data.l[1], xev.client.data.l[3],
6133 ev.fUser[1]);
6134 AsmLong(xev.client.data.l[2], xev.client.data.l[4],
6135 ev.fUser[2]);
6136 } else {
6137 ev.fUser[1] = 0; //xev.client.data.l[1];
6138 ev.fUser[2] = 0; //xev.client.data.l[2];
6139 ev.fUser[3] = 0; //xev.client.data.l[3];
6140 ev.fUser[4] = 0; //xev.client.data.l[4];
6141 }
6142 }
6143 if (xev.type == GDK_DESTROY) {
6144 ev.fType = kDestroyNotify;
6145 ev.fHandle = (Window_t) xev.any.window; // window to be destroyed
6146 ev.fWindow = (Window_t) xev.any.window;
6147 }
6148 if (xev.type == GDK_FOCUS_CHANGE) {
6149 ev.fWindow = (Window_t) xev.focus_change.window;
6150 ev.fCode = kNotifyNormal;
6151 ev.fState = 0;
6152 if (xev.focus_change.in == TRUE) {
6153 ev.fType = kFocusIn;
6154 } else {
6155 ev.fType = kFocusOut;
6156 }
6157 }
6158 if (ev.fType == kGKeyPress || ev.fType == kKeyRelease) {
6159 ev.fWindow = (Window_t) xev.key.window;
6160 MapModifierState(ev.fState, xev.key.state, kFALSE); // key mask
6161 ev.fCode = xev.key.keyval; // key code
6162 ev.fUser[1] = xev.key.length;
6163 if (xev.key.length > 0) ev.fUser[2] = xev.key.string[0];
6164 if (xev.key.length > 1) ev.fUser[3] = xev.key.string[1];
6165 if (xev.key.length > 2) ev.fUser[4] = xev.key.string[2];
6166 HWND tmpwin = (HWND) GetWindow((HWND) GDK_DRAWABLE_XID((GdkWindow *)xev.key.window), GW_CHILD);
6167 if (tmpwin) {
6168 ev.fUser[0] = (ULong_t) gdk_xid_table_lookup((HANDLE)tmpwin);
6169 } else {
6170 ev.fUser[0] = (ULong_t) xev.key.window;
6171 }
6172 }
6173 if (ev.fType == kButtonPress || ev.fType == kButtonRelease) {
6174 ev.fWindow = (Window_t) xev.button.window;
6175 ev.fX = xev.button.x;
6176 ev.fY = xev.button.y;
6177 ev.fXRoot = xev.button.x_root;
6178 ev.fYRoot = xev.button.y_root;
6179 MapModifierState(ev.fState, xev.button.state, kFALSE); // button mask
6180 ev.fCode = xev.button.button; // button code
6181 POINT tpoint;
6182 tpoint.x = xev.button.x;
6183 tpoint.y = xev.button.y;
6184 HWND tmpwin = ChildWindowFromPoint((HWND) GDK_DRAWABLE_XID((GdkWindow *)xev.button.window), tpoint);
6185 if (tmpwin) {
6186 ev.fUser[0] = (ULong_t) gdk_xid_table_lookup((HANDLE)tmpwin);
6187 } else {
6188 ev.fUser[0] = (ULong_t) 0;
6189 }
6190 }
6191 if (ev.fType == kMotionNotify) {
6192 ev.fWindow = (Window_t) xev.motion.window;
6193 ev.fX = xev.motion.x;
6194 ev.fY = xev.motion.y;
6195 ev.fXRoot = xev.motion.x_root;
6196 ev.fYRoot = xev.motion.y_root;
6197 MapModifierState(ev.fState, xev.motion.state, kFALSE); // key or button mask
6198
6199 POINT tpoint;
6200 tpoint.x = xev.button.x;
6201 tpoint.y = xev.button.y;
6202 HWND tmpwin = ChildWindowFromPoint((HWND) GDK_DRAWABLE_XID((GdkWindow *)xev.motion.window), tpoint);
6203 if (tmpwin) {
6204 ev.fUser[0] = (ULong_t)gdk_xid_table_lookup((HANDLE)tmpwin);
6205 } else {
6206 ev.fUser[0] = (ULong_t) xev.motion.window;
6207 }
6208 }
6209 if (ev.fType == kEnterNotify || ev.fType == kLeaveNotify) {
6210 ev.fWindow = (Window_t) xev.crossing.window;
6211 ev.fX = xev.crossing.x;
6212 ev.fY = xev.crossing.y;
6213 ev.fXRoot = xev.crossing.x_root;
6214 ev.fYRoot = xev.crossing.y_root;
6215 ev.fCode = xev.crossing.mode; // NotifyNormal, NotifyGrab, NotifyUngrab
6216 MapModifierState(ev.fState, xev.crossing.state, kFALSE); // key or button mask
6217 }
6218 if (ev.fType == kExpose) {
6219 ev.fWindow = (Window_t) xev.expose.window;
6220 ev.fX = xev.expose.area.x;
6221 ev.fY = xev.expose.area.y;
6222 ev.fWidth = xev.expose.area.width; // width and
6223 ev.fHeight = xev.expose.area.height; // height of exposed area
6224 ev.fCount = xev.expose.count; // number of expose events still to come
6225 }
6226 if (ev.fType == kConfigureNotify) {
6227 ev.fWindow = (Window_t) xev.configure.window;
6228 ev.fX = xev.configure.x;
6229 ev.fY = xev.configure.y;
6230 ev.fWidth = xev.configure.width;
6231 ev.fHeight = xev.configure.height;
6232 }
6233 if (xev.type == GDK_CLIENT_EVENT) {
6234 ev.fWindow = (Window_t) xev.client.window;
6235 ev.fType = kClientMessage;
6236 ev.fHandle = xev.client.message_type;
6237 ev.fFormat = xev.client.data_format;
6238 ev.fUser[0] = xev.client.data.l[0];
6239 if (sizeof(ev.fUser[0]) > 4) {
6240 AsmLong(xev.client.data.l[1], xev.client.data.l[3],
6241 ev.fUser[1]);
6242 AsmLong(xev.client.data.l[2], xev.client.data.l[4],
6243 ev.fUser[2]);
6244 } else {
6245 ev.fUser[1] = xev.client.data.l[1];
6246 ev.fUser[2] = xev.client.data.l[2];
6247 ev.fUser[3] = xev.client.data.l[3];
6248 ev.fUser[4] = xev.client.data.l[4];
6249 }
6250 }
6251 if (ev.fType == kSelectionClear) {
6252 ev.fWindow = (Window_t) xev.selection.window;
6253 ev.fUser[0] = xev.selection.selection;
6254 }
6255 if (ev.fType == kSelectionRequest) {
6256 ev.fWindow = (Window_t) xev.selection.window;
6257 ev.fUser[0] = (ULong_t) xev.selection.window;
6258 ev.fUser[1] = xev.selection.selection;
6259 ev.fUser[2] = xev.selection.target;
6260 ev.fUser[3] = xev.selection.property;
6261 }
6262 if (ev.fType == kSelectionNotify) {
6263 ev.fWindow = (Window_t) xev.selection.window;
6264 ev.fUser[0] = (ULong_t) xev.selection.window;
6265 ev.fUser[1] = xev.selection.selection;
6266 ev.fUser[2] = xev.selection.target;
6267 ev.fUser[3] = xev.selection.property;
6268 }
6269 if (xev.type == GDK_SCROLL) {
6270 ev.fType = kButtonRelease;
6271 if (xev.scroll.direction == GDK_SCROLL_UP) {
6272 ev.fCode = kButton4;
6273 } else if (xev.scroll.direction == GDK_SCROLL_DOWN) {
6274 ev.fCode = kButton5;
6275 }
6276 ev.fWindow = (Window_t) xev.scroll.window;
6277 ev.fX = xev.scroll.x;
6278 ev.fY = xev.scroll.y;
6279 ev.fXRoot = xev.scroll.x_root;
6280 ev.fYRoot = xev.scroll.y_root;
6281 POINT tpoint;
6282 tpoint.x = xev.scroll.x;
6283 tpoint.y = xev.scroll.y;
6284 HWND tmpwin = ChildWindowFromPoint((HWND) GDK_DRAWABLE_XID((GdkWindow *)xev.scroll.window), tpoint);
6285 if (tmpwin) {
6286 ev.fUser[0] = (ULong_t)gdk_xid_table_lookup((HANDLE)tmpwin);
6287 } else {
6288 ev.fUser[0] = (ULong_t) 0;
6289 }
6290 }
6291 }
6292}
6293
6294////////////////////////////////////////////////////////////////////////////////
6295///
6296
6298{
6299 gSystem->Beep();
6300}
6301
6302////////////////////////////////////////////////////////////////////////////////
6303/// Copy a drawable (i.e. pixmap) to another drawable (pixmap, window).
6304/// The graphics context gc will be used and the source will be copied
6305/// from src_x,src_y,src_x+width,src_y+height to dest_x,dest_y.
6306
6308 Int_t src_x, Int_t src_y, UInt_t width,
6309 UInt_t height, Int_t dest_x, Int_t dest_y)
6310{
6311 if (!src || !dest) return;
6312
6313 gdk_window_copy_area((GdkDrawable *) dest, (GdkGC *) gc, dest_x, dest_y,
6314 (GdkDrawable *) src, src_x, src_y, width, height);
6315}
6316
6317////////////////////////////////////////////////////////////////////////////////
6318/// Change window attributes.
6319
6321{
6322 if (!id) return;
6323
6324 GdkColor color;
6325 UInt_t xevmask;
6326 Mask_t evmask;
6327
6328 if (attr && (attr->fMask & kWAEventMask)) {
6329 evmask = (Mask_t) attr->fEventMask;
6330 MapEventMask(evmask, xevmask);
6331 gdk_window_set_events((GdkWindow *) id, (GdkEventMask) xevmask);
6332 }
6333 if (attr && (attr->fMask & kWABackPixel)) {
6334 color.pixel = attr->fBackgroundPixel;
6335 color.red = GetRValue(attr->fBackgroundPixel);
6336 color.green = GetGValue(attr->fBackgroundPixel);
6337 color.blue = GetBValue(attr->fBackgroundPixel);
6338 gdk_window_set_background((GdkWindow *) id, &color);
6339 }
6340// if (attr && (attr->fMask & kWAOverrideRedirect))
6341// gdk_window_set_override_redirect ((GdkWindow *) id, attr->fOverrideRedirect);
6342 if (attr && (attr->fMask & kWABackPixmap)) {
6343 gdk_window_set_back_pixmap((GdkWindow *) id,
6344 (GdkPixmap *) attr->fBackgroundPixmap, 0);
6345 }
6346 if (attr && (attr->fMask & kWACursor)) {
6347 gdk_window_set_cursor((GdkWindow *) id, (GdkCursor *) attr->fCursor);
6348 }
6349 if (attr && (attr->fMask & kWAColormap)) {
6350 gdk_window_set_colormap((GdkWindow *) id,(GdkColormap *) attr->fColormap);
6351 }
6352 if (attr && (attr->fMask & kWABorderWidth)) {
6353 if (attr->fBorderWidth > 0) {
6354 gdk_window_set_decorations((GdkWindow *) id,
6355 (GdkWMDecoration) GDK_DECOR_BORDER);
6356 }
6357 }
6358}
6359
6360////////////////////////////////////////////////////////////////////////////////
6361/// This function alters the property for the specified window and
6362/// causes the X server to generate a PropertyNotify event on that
6363/// window.
6364
6366 UChar_t * data, Int_t len)
6367{
6368 if (!id) return;
6369
6370 gdk_property_change((GdkWindow *) id, (GdkAtom) property,
6371 (GdkAtom) type, 8, GDK_PROP_MODE_REPLACE, data,len);
6372}
6373
6374////////////////////////////////////////////////////////////////////////////////
6375/// Draw a line.
6376
6378 Int_t x2, Int_t y2)
6379{
6380 if (!id) return;
6381
6382 gdk_draw_line((GdkDrawable *) id, (GdkGC *) gc, x1, y1, x2, y2);
6383}
6384
6385////////////////////////////////////////////////////////////////////////////////
6386/// Clear a window area to the bakcground color.
6387
6389{
6390 if (!id) return;
6391
6392 gdk_window_clear_area((GdkWindow *) id, x, y, w, h);
6393}
6394
6395////////////////////////////////////////////////////////////////////////////////
6396/// Tell WM to send message when window is closed via WM.
6397
6399{
6400 if (!id) return;
6401
6402 Atom prop;
6403 prop = (Atom_t) gdk_atom_intern("WM_DELETE_WINDOW", FALSE);
6404
6405 W32ChangeProperty((HWND) GDK_DRAWABLE_XID((GdkWindow *) id),
6406 prop, XA_ATOM, 32, GDK_PROP_MODE_REPLACE,
6407 (unsigned char *) &gWM_DELETE_WINDOW, 1);
6408}
6409
6410////////////////////////////////////////////////////////////////////////////////
6411/// Turn key auto repeat on or off.
6412
6414{
6415 if (on) {
6416 gdk_key_repeat_restore();
6417 } else {
6418 gdk_key_repeat_disable();
6419 }
6420}
6421
6422////////////////////////////////////////////////////////////////////////////////
6423/// Establish passive grab on a certain key. That is, when a certain key
6424/// keycode is hit while certain modifier's (Shift, Control, Meta, Alt)
6425/// are active then the keyboard will be grabed for window id.
6426/// When grab is false, ungrab the keyboard for this key and modifier.
6427
6428void TGWin32::GrabKey(Window_t id, Int_t keycode, UInt_t modifier, Bool_t grab)
6429{
6430 UInt_t xmod;
6431
6432 MapModifierState(modifier, xmod);
6433
6434 if (grab) {
6435 gdk_key_grab(keycode, (GdkEventMask)xmod, (GdkWindow *)id);
6436 } else {
6437 gdk_key_ungrab(keycode, (GdkEventMask)xmod, (GdkWindow *)id);
6438 }
6439}
6440
6441////////////////////////////////////////////////////////////////////////////////
6442/// Establish passive grab on a certain mouse button. That is, when a
6443/// certain mouse button is hit while certain modifier's (Shift, Control,
6444/// Meta, Alt) are active then the mouse will be grabed for window id.
6445/// When grab is false, ungrab the mouse button for this button and modifier.
6446
6448 UInt_t evmask, Window_t confine, Cursor_t cursor,
6449 Bool_t grab)
6450{
6451 UInt_t xevmask;
6452 UInt_t xmod;
6453
6454 if (!id) return;
6455
6456 MapModifierState(modifier, xmod);
6457
6458 if (grab) {
6459 MapEventMask(evmask, xevmask);
6460 gdk_button_grab(button, xmod, ( GdkWindow *)id, 1, (GdkEventMask)xevmask,
6461 (GdkWindow*)confine, (GdkCursor*)cursor);
6462 } else {
6463 gdk_button_ungrab(button, xmod, ( GdkWindow *)id);
6464 }
6465}
6466
6467////////////////////////////////////////////////////////////////////////////////
6468/// Establish an active pointer grab. While an active pointer grab is in
6469/// effect, further pointer events are only reported to the grabbing
6470/// client window.
6471
6473 Cursor_t cursor, Bool_t grab, Bool_t owner_events)
6474{
6475 UInt_t xevmask;
6476 MapEventMask(evmask, xevmask);
6477
6478 if (grab) {
6479 if(!::IsWindowVisible((HWND)GDK_DRAWABLE_XID(id))) return;
6480 gdk_pointer_grab((GdkWindow *) id, owner_events, (GdkEventMask) xevmask,
6481 (GdkWindow *) confine, (GdkCursor *) cursor,
6482 GDK_CURRENT_TIME);
6483 } else {
6484 gdk_pointer_ungrab(GDK_CURRENT_TIME);
6485 ::SetCursor((HCURSOR)GDK_CURSOR_XID(fCursors[kPointer]));
6486 }
6487}
6488
6489////////////////////////////////////////////////////////////////////////////////
6490/// Set window name.
6491
6493{
6494 if (!id) return;
6495
6496 gdk_window_set_title((GdkWindow *) id, name);
6497}
6498
6499////////////////////////////////////////////////////////////////////////////////
6500/// Set window icon name.
6501
6503{
6504 if (!id) return;
6505
6506 gdk_window_set_icon_name((GdkWindow *) id, name);
6507}
6508
6509////////////////////////////////////////////////////////////////////////////////
6510/// Set pixmap the WM can use when the window is iconized.
6511
6513{
6514 if (!id) return;
6515
6516 gdk_window_set_icon((GdkWindow *)id, NULL, (GdkPixmap *)pic, (GdkPixmap *)pic);
6517}
6518
6519#define safestrlen(s) ((s) ? strlen(s) : 0)
6520
6521////////////////////////////////////////////////////////////////////////////////
6522/// Set the windows class and resource name.
6523
6524void TGWin32::SetClassHints(Window_t id, char *className, char *resourceName)
6525{
6526 if (!id) return;
6527
6528 char *class_string;
6529 char *s;
6530 int len_nm, len_cl;
6531 GdkAtom prop;
6532
6533 prop = gdk_atom_intern("WM_CLASS", kFALSE);
6534
6535 len_nm = safestrlen(resourceName);
6536 len_cl = safestrlen(className);
6537
6538 if ((class_string = s =
6539 (char *) malloc((unsigned) (len_nm + len_cl + 2)))) {
6540 if (len_nm) {
6541 strcpy(s, resourceName);
6542 s += len_nm + 1;
6543 } else
6544 *s++ = '\0';
6545 if (len_cl) {
6546 strcpy(s, className);
6547 } else {
6548 *s = '\0';
6549 }
6550
6551 W32ChangeProperty((HWND) GDK_DRAWABLE_XID((GdkWindow *) id),
6553 GDK_PROP_MODE_REPLACE,
6554 (unsigned char *) class_string,
6555 len_nm + len_cl + 2);
6556 free(class_string);
6557 }
6558}
6559
6560////////////////////////////////////////////////////////////////////////////////
6561/// Set decoration style for MWM-compatible wm (mwm, ncdwm, fvwm?).
6562
6564 UInt_t input)
6565{
6566 if (!id) return;
6567
6568 gdk_window_set_decorations((GdkDrawable *) id, (GdkWMDecoration) value);
6569 gdk_window_set_functions((GdkDrawable *) id, (GdkWMFunction) funcs);
6570}
6571
6572////////////////////////////////////////////////////////////////////////////////
6573///
6574
6576{
6577 if (!id) return;
6578
6579 gdk_window_move((GdkDrawable *) id, x, y);
6580}
6581
6582////////////////////////////////////////////////////////////////////////////////
6583///
6584
6586{
6587 if (!id) return;
6588
6589 gdk_window_resize((GdkWindow *) id, w, h);
6590}
6591
6592////////////////////////////////////////////////////////////////////////////////
6593/// Give the window manager minimum and maximum size hints. Also
6594/// specify via winc and hinc the resize increments.
6595
6597 UInt_t wmax, UInt_t hmax,
6598 UInt_t winc, UInt_t hinc)
6599{
6600 if (!id) return;
6601
6602 GdkGeometry hints;
6603 GdkWindowHints flags;
6604
6605 flags = (GdkWindowHints) (GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE |
6606 GDK_HINT_RESIZE_INC);
6607 hints.min_width = (Int_t) wmin;
6608 hints.max_width = (Int_t) wmax;
6609 hints.min_height = (Int_t) hmin;
6610 hints.max_height = (Int_t) hmax;
6611 hints.width_inc = (Int_t) winc;
6612 hints.height_inc = (Int_t) hinc;
6613
6614 gdk_window_set_geometry_hints((GdkWindow *) id, (GdkGeometry *) &hints,
6615 (GdkWindowHints) flags);
6616}
6617
6618////////////////////////////////////////////////////////////////////////////////
6619/// Set the initial state of the window. Either kNormalState or kIconicState.
6620
6622{
6623 if (!id) return;
6624
6625#if 0
6626 XWMHints hints;
6627 Int_t xstate = NormalState;
6628
6629 if (state == kNormalState)
6630 xstate = NormalState;
6631 if (state == kIconicState)
6632 xstate = IconicState;
6633
6634 hints.flags = StateHint;
6635 hints.initial_state = xstate;
6636
6637 XSetWMHints((GdkWindow *) id, &hints);
6638#endif
6639}
6640
6641////////////////////////////////////////////////////////////////////////////////
6642/// Tell window manager that window is a transient window of gdk_parent_root.
6643
6645{
6646 if (!id) return;
6647
6648 gdk_window_set_transient_for((GdkWindow *) id, (GdkWindow *) main_id);
6649}
6650
6651////////////////////////////////////////////////////////////////////////////////
6652/// Draw a string using a specific graphics context in position (x,y).
6653
6655 const char *s, Int_t len)
6656{
6657 if (!id) return;
6658
6659 GdkGCValues values;
6660 gdk_gc_get_values((GdkGC *) gc, &values);
6661 gdk_win32_draw_text((GdkDrawable *) id, (GdkFont *) values.font,
6662 (GdkGC *) gc, x, y, (const gchar *)s, len);
6663}
6664
6665////////////////////////////////////////////////////////////////////////////////
6666/// Return length of string in pixels. Size depends on font.
6667
6669{
6670 return gdk_text_width((GdkFont *)font, s, len);
6671}
6672
6673////////////////////////////////////////////////////////////////////////////////
6674/// Return some font properties.
6675
6677 Int_t & max_descent)
6678{
6679 GdkFont *f = (GdkFont *) font;
6680 max_ascent = f->ascent;
6681 max_descent = f->descent;
6682}
6683
6684////////////////////////////////////////////////////////////////////////////////
6685/// Get current values from graphics context gc. Which values of the
6686/// context to get is encoded in the GCValues::fMask member.
6687
6689{
6690 GdkGCValues xgval;
6691 ULong_t xmask;
6692
6693 MapGCValues(gval, xmask, xgval, kTRUE);
6694 gdk_gc_get_values((GdkGC *) gc, &xgval);
6695 MapGCValues(gval, xmask, xgval, kFALSE);
6696}
6697
6698////////////////////////////////////////////////////////////////////////////////
6699/// Retrieve associated font structure once we have the font handle.
6700/// Free returned FontStruct_t using FreeFontStruct().
6701
6703{
6704 return (FontStruct_t) gdk_font_ref((GdkFont *) fh);
6705}
6706
6707////////////////////////////////////////////////////////////////////////////////
6708/// Free font structure returned by GetFontStruct().
6709
6711{
6712 gdk_font_unref((GdkFont *) fs);
6713}
6714
6715////////////////////////////////////////////////////////////////////////////////
6716/// Clear window.
6717
6719{
6720 if (!id) return;
6721
6722 gdk_window_clear((GdkDrawable *) id);
6723}
6724
6725////////////////////////////////////////////////////////////////////////////////
6726/// Convert a keysym to the appropriate keycode. For example keysym is
6727/// a letter and keycode is the matching keyboard key (which is dependend
6728/// on the current keyboard mapping).
6729
6731{
6732 UInt_t xkeysym;
6733 MapKeySym(keysym, xkeysym);
6734 return xkeysym;
6735}
6736
6737////////////////////////////////////////////////////////////////////////////////
6738/// Draw a filled rectangle. Filling is done according to the gc.
6739
6741 UInt_t w, UInt_t h)
6742{
6743 if (!id) return;
6744
6745 gdk_win32_draw_rectangle((GdkDrawable *) id, (GdkGC *) gc, kTRUE, x, y, w, h);
6746}
6747
6748////////////////////////////////////////////////////////////////////////////////
6749/// Draw a rectangle outline.
6750
6752 UInt_t w, UInt_t h)
6753{
6754 if (!id) return;
6755
6756 gdk_win32_draw_rectangle((GdkDrawable *) id, (GdkGC *) gc, kFALSE, x, y, w, h);
6757}
6758
6759////////////////////////////////////////////////////////////////////////////////
6760/// Draws multiple line segments. Each line is specified by a pair of points.
6761
6763 Int_t nseg)
6764{
6765 if (!id) return;
6766
6767 gdk_win32_draw_segments((GdkDrawable *) id, (GdkGC *) gc, (GdkSegment *)seg, nseg);
6768}
6769
6770////////////////////////////////////////////////////////////////////////////////
6771/// Defines which input events the window is interested in. By default
6772/// events are propageted up the window stack. This mask can also be
6773/// set at window creation time via the SetWindowAttributes_t::fEventMask
6774/// attribute.
6775
6777{
6778 if (!id) return;
6779
6780 UInt_t xevmask;
6781 MapEventMask(evmask, xevmask, kTRUE);
6782 gdk_window_set_events((GdkWindow *) id, (GdkEventMask)xevmask);
6783}
6784
6785////////////////////////////////////////////////////////////////////////////////
6786/// Returns the window id of the window having the input focus.
6787
6789{
6790 HWND hwnd = ::GetFocus();
6791 return (Window_t) gdk_xid_table_lookup(hwnd);
6792}
6793
6794////////////////////////////////////////////////////////////////////////////////
6795/// Set keyboard input focus to window id.
6796
6798{
6799 if (!id) return;
6800
6801 HWND hwnd = (HWND)GDK_DRAWABLE_XID((GdkWindow *)id);
6802 ::SetFocus(hwnd);
6803}
6804
6805////////////////////////////////////////////////////////////////////////////////
6806/// Returns the window id of the current owner of the primary selection.
6807/// That is the window in which, for example some text is selected.
6808
6810{
6811 return (Window_t)gdk_selection_owner_get(gClipboardAtom);
6812}
6813
6814////////////////////////////////////////////////////////////////////////////////
6815/// Makes the window id the current owner of the primary selection.
6816/// That is the window in which, for example some text is selected.
6817
6819{
6820 if (!id) return;
6821
6822 gdk_selection_owner_set((GdkWindow *) id, gClipboardAtom, GDK_CURRENT_TIME, 0);
6823}
6824
6825////////////////////////////////////////////////////////////////////////////////
6826/// XConvertSelection() causes a SelectionRequest event to be sent to the
6827/// current primary selection owner. This event specifies the selection
6828/// property (primary selection), the format into which to convert that
6829/// data before storing it (target = XA_STRING), the property in which
6830/// the owner will place the information (sel_property), the window that
6831/// wants the information (id), and the time of the conversion request
6832/// (when).
6833/// The selection owner responds by sending a SelectionNotify event, which
6834/// confirms the selected atom and type.
6835
6837{
6838 if (!id) return;
6839
6840 gdk_selection_convert((GdkWindow *) id, clipboard,
6841 gdk_atom_intern("GDK_TARGET_STRING", 0), when);
6842}
6843
6844////////////////////////////////////////////////////////////////////////////////
6845/// Convert the keycode from the event structure to a key symbol (according
6846/// to the modifiers specified in the event structure and the current
6847/// keyboard mapping). In buf a null terminated ASCII string is returned
6848/// representing the string that is currently mapped to the key code.
6849
6850void TGWin32::LookupString(Event_t * event, char *buf, Int_t buflen,
6851 UInt_t & keysym)
6852{
6853 _lookup_string(event, buf, buflen);
6854 UInt_t ks, xks = (UInt_t) event->fCode;
6855 MapKeySym(ks, xks, kFALSE);
6856 keysym = (Int_t) ks;
6857}
6858
6859////////////////////////////////////////////////////////////////////////////////
6860/// Map to and from X key symbols. Keysym are the values returned by
6861/// XLookUpString.
6862
6863void TGWin32::MapKeySym(UInt_t & keysym, UInt_t & xkeysym, Bool_t tox)
6864{
6865 if (tox) {
6866 xkeysym = GDK_VoidSymbol;
6867 if (keysym < 127) {
6868 xkeysym = keysym;
6869 } else if (keysym >= kKey_F1 && keysym <= kKey_F35) {
6870 xkeysym = GDK_F1 + (keysym - (UInt_t) kKey_F1); // function keys
6871 } else {
6872 for (int i = 0; gKeyMap[i].fKeySym; i++) { // any other keys
6873 if (keysym == (UInt_t) gKeyMap[i].fKeySym) {
6874 xkeysym = (UInt_t) gKeyMap[i].fXKeySym;
6875 break;
6876 }
6877 }
6878 }
6879 } else {
6880 keysym = kKey_Unknown;
6881 // commentary in X11/keysymdef says that X codes match ASCII
6882 if (xkeysym < 127) {
6883 keysym = xkeysym;
6884 } else if (xkeysym >= GDK_F1 && xkeysym <= GDK_F35) {
6885 keysym = kKey_F1 + (xkeysym - GDK_F1); // function keys
6886 } else if (xkeysym >= GDK_KP_0 && xkeysym <= GDK_KP_9) {
6887 keysym = kKey_0 + (xkeysym - GDK_KP_0); // numeric keypad keys
6888 } else {
6889 for (int i = 0; gKeyMap[i].fXKeySym; i++) { // any other keys
6890 if (xkeysym == gKeyMap[i].fXKeySym) {
6891 keysym = (UInt_t) gKeyMap[i].fKeySym;
6892 break;
6893 }
6894 }
6895 }
6896 }
6897}
6898
6899////////////////////////////////////////////////////////////////////////////////
6900/// Get contents of paste buffer atom into string. If del is true delete
6901/// the paste buffer afterwards.
6902
6904 Int_t & nchar, Bool_t del)
6905{
6906 if (!id) return;
6907
6908 char *data;
6909 int nread, actual_format;
6910
6911 nread = gdk_selection_property_get((GdkWindow *) id,
6912 (unsigned char **) &data,
6913 (GdkAtom *) & atom, &actual_format);
6914
6915 if ((nread == 0) || (data == NULL)) {
6916 nchar = 0;
6917 return;
6918 }
6919
6920 text.Insert(0, (const char *) data);
6921 nchar = 1; //strlen(data);
6922 g_free(data);
6923
6924 // if (del)
6925 gdk_property_delete((GdkWindow *) id,
6926 gdk_atom_intern("GDK_SELECTION", FALSE));
6927}
6928
6929////////////////////////////////////////////////////////////////////////////////
6930/// TranslateCoordinates translates coordinates from the frame of
6931/// reference of one window to another. If the point is contained
6932/// in a mapped child of the destination, the id of that child is
6933/// returned as well.
6934
6936 Int_t src_x, Int_t src_y,
6937 Int_t &dest_x, Int_t &dest_y,
6938 Window_t &child)
6939{
6940 if (!src || !dest) return;
6941
6942 HWND sw, dw, ch = NULL;
6943 POINT point;
6944 sw = (HWND)GDK_DRAWABLE_XID((GdkWindow *)src);
6945 dw = (HWND)GDK_DRAWABLE_XID((GdkWindow *)dest);
6946 point.x = src_x;
6947 point.y = src_y;
6948 ::MapWindowPoints(sw, // handle of window to be mapped from
6949 dw, // handle to window to be mapped to
6950 &point, // pointer to array with points to map
6951 1); // number of structures in array
6952 ch = ::ChildWindowFromPointEx(dw, point, CWP_SKIPDISABLED | CWP_SKIPINVISIBLE);
6953 child = (Window_t)gdk_xid_table_lookup(ch);
6954
6955 if (child == src) {
6956 child = (Window_t) 0;
6957 }
6958 dest_x = point.x;
6959 dest_y = point.y;
6960}
6961
6962////////////////////////////////////////////////////////////////////////////////
6963/// Return geometry of window (should be called GetGeometry but signature
6964/// already used).
6965
6967 UInt_t & w, UInt_t & h)
6968{
6969 if (!id) return;
6970
6971 Int_t ddum;
6972 if (GDK_DRAWABLE_TYPE(id) == GDK_DRAWABLE_PIXMAP) {
6973 x = y = 0;
6974 gdk_drawable_get_size((GdkDrawable *)id, (int*)&w, (int*)&h);
6975 }
6976 else {
6977 gdk_window_get_geometry((GdkDrawable *) id, &x, &y, (int*)&w,
6978 (int*)&h, &ddum);
6979 }
6980}
6981
6982////////////////////////////////////////////////////////////////////////////////
6983/// FillPolygon fills the region closed by the specified path.
6984/// The path is closed automatically if the last point in the list does
6985/// not coincide with the first point. All point coordinates are
6986/// treated as relative to the origin. For every pair of points
6987/// inside the polygon, the line segment connecting them does not
6988/// intersect the path.
6989
6991 Int_t npnt)
6992{
6993 if (!id) return;
6994
6995 gdk_win32_draw_polygon((GdkWindow *) id, (GdkGC *) gc, 1, (GdkPoint *) points, npnt);
6996}
6997
6998////////////////////////////////////////////////////////////////////////////////
6999/// Returns the root window the pointer is logically on and the pointer
7000/// coordinates relative to the root window's origin.
7001/// The pointer coordinates returned to win_x and win_y are relative to
7002/// the origin of the specified window. In this case, QueryPointer returns
7003/// the child that contains the pointer, if any, or else kNone to
7004/// childw. QueryPointer returns the current logical state of the
7005/// keyboard buttons and the modifier keys in mask.
7006
7008 Window_t &childw, Int_t &root_x,
7009 Int_t &root_y, Int_t &win_x, Int_t &win_y,
7010 UInt_t &mask)
7011{
7012 if (!id) return;
7013
7014 POINT currPt;
7015 HWND chw, window;
7016 UInt_t umask = 0;
7017 BYTE kbd[256];
7018
7019 window = (HWND)GDK_DRAWABLE_XID((GdkWindow *)id);
7020 rootw = (Window_t)GDK_ROOT_PARENT();
7021 ::GetCursorPos(&currPt);
7022 chw = ::WindowFromPoint(currPt);
7023 childw = (Window_t)gdk_xid_table_lookup(chw);
7024 root_x = currPt.x;
7025 root_y = currPt.y;
7026
7027 ::ScreenToClient(window, &currPt);
7028 win_x = currPt.x;
7029 win_y = currPt.y;
7030
7031 ::GetKeyboardState (kbd);
7032
7033 if (kbd[VK_SHIFT] & 0x80) {
7034 umask |= GDK_SHIFT_MASK;
7035 }
7036 if (kbd[VK_CAPITAL] & 0x80) {
7037 umask |= GDK_LOCK_MASK;
7038 }
7039 if (kbd[VK_CONTROL] & 0x80) {
7040 umask |= GDK_CONTROL_MASK;
7041 }
7042 if (kbd[VK_MENU] & 0x80) {
7043 umask |= GDK_MOD1_MASK;
7044 }
7045 if (kbd[VK_LBUTTON] & 0x80) {
7046 umask |= GDK_BUTTON1_MASK;
7047 }
7048 if (kbd[VK_MBUTTON] & 0x80) {
7049 umask |= GDK_BUTTON2_MASK;
7050 }
7051 if (kbd[VK_RBUTTON] & 0x80) {
7052 umask |= GDK_BUTTON3_MASK;
7053 }
7054
7055 MapModifierState(mask, umask, kFALSE);
7056}
7057
7058////////////////////////////////////////////////////////////////////////////////
7059/// Set foreground color in graphics context (shortcut for ChangeGC with
7060/// only foreground mask set).
7061
7063{
7064 GdkColor fore;
7065 fore.pixel = foreground;
7066 fore.red = GetRValue(foreground);
7067 fore.green = GetGValue(foreground);
7068 fore.blue = GetBValue(foreground);
7069 gdk_gc_set_foreground((GdkGC *) gc, &fore);
7070}
7071
7072////////////////////////////////////////////////////////////////////////////////
7073/// Set clipping rectangles in graphics context. X, Y specify the origin
7074/// of the rectangles. Recs specifies an array of rectangles that define
7075/// the clipping mask and n is the number of rectangles.
7076
7078 Rectangle_t * recs, Int_t n)
7079{
7080 Int_t i;
7081 GdkRectangle *grects = new GdkRectangle[n];
7082
7083 for (i = 0; i < n; i++) {
7084 grects[i].x = x+recs[i].fX;
7085 grects[i].y = y+recs[i].fY;
7086 grects[i].width = recs[i].fWidth;
7087 grects[i].height = recs[i].fHeight;
7088 }
7089
7090 for (i = 0; i < n; i++) {
7091 gdk_gc_set_clip_rectangle((GdkGC *)gc, (GdkRectangle*)recs);
7092 }
7093 delete [] grects;
7094}
7095
7096////////////////////////////////////////////////////////////////////////////////
7097/// Flush (mode = 0, default) or synchronize (mode = 1) X output buffer.
7098/// Flush flushes output buffer. Sync flushes buffer and waits till all
7099/// requests have been processed by X server.
7100
7102{
7103 GdiFlush();
7104}
7105
7106////////////////////////////////////////////////////////////////////////////////
7107/// Create a new empty region.
7108
7110{
7111 return (Region_t) gdk_region_new();
7112}
7113
7114////////////////////////////////////////////////////////////////////////////////
7115/// Destroy region.
7116
7118{
7119 gdk_region_destroy((GdkRegion *) reg);
7120}
7121
7122////////////////////////////////////////////////////////////////////////////////
7123/// Union of rectangle with a region.
7124
7126{
7127 GdkRectangle r;
7128 r.x = rect->fX;
7129 r.y = rect->fY;
7130 r.width = rect->fWidth;
7131 r.height = rect->fHeight;
7132 dest = (Region_t) gdk_region_union_with_rect((GdkRegion *) src, &r);
7133}
7134
7135////////////////////////////////////////////////////////////////////////////////
7136/// Create region for the polygon defined by the points array.
7137/// If winding is true use WindingRule else EvenOddRule as fill rule.
7138
7140{
7141 return (Region_t) gdk_region_polygon((GdkPoint*)points, np,
7142 winding ? GDK_WINDING_RULE : GDK_EVEN_ODD_RULE);
7143}
7144
7145////////////////////////////////////////////////////////////////////////////////
7146/// Compute the union of rega and regb and return result region.
7147/// The output region may be the same result region.
7148
7150{
7151 result = (Region_t) gdk_regions_union((GdkRegion *) rega, (GdkRegion *) regb);
7152}
7153
7154////////////////////////////////////////////////////////////////////////////////
7155/// Compute the intersection of rega and regb and return result region.
7156/// The output region may be the same as the result region.
7157
7159 Region_t result)
7160{
7161 result = (Region_t) gdk_regions_intersect((GdkRegion *) rega,(GdkRegion *) regb);
7162}
7163
7164////////////////////////////////////////////////////////////////////////////////
7165/// Subtract rega from regb.
7166
7168{
7169 result = (Region_t)gdk_regions_subtract((GdkRegion *) rega,(GdkRegion *) regb);
7170}
7171
7172////////////////////////////////////////////////////////////////////////////////
7173/// Calculate the difference between the union and intersection of
7174/// two regions.
7175
7177{
7178 result = (Region_t) gdk_regions_xor((GdkRegion *) rega, (GdkRegion *) regb);
7179}
7180
7181////////////////////////////////////////////////////////////////////////////////
7182/// Return true if the region is empty.
7183
7185{
7186 return (Bool_t) gdk_region_empty((GdkRegion *) reg);
7187}
7188
7189////////////////////////////////////////////////////////////////////////////////
7190/// Returns true if the point x,y is in the region.
7191
7193{
7194 return (Bool_t) gdk_region_point_in((GdkRegion *) reg, x, y);
7195}
7196
7197////////////////////////////////////////////////////////////////////////////////
7198/// Returns true if two regions are equal.
7199
7201{
7202 return (Bool_t) gdk_region_equal((GdkRegion *) rega, (GdkRegion *) regb);
7203}
7204
7205////////////////////////////////////////////////////////////////////////////////
7206/// Return smallest enclosing rectangle.
7207
7209{
7210 GdkRectangle r;
7211 gdk_region_get_clipbox((GdkRegion *) reg, &r);
7212 rect->fX = r.x;
7213 rect->fY = r.y;
7214 rect->fWidth = r.width;
7215 rect->fHeight = r.height;
7216}
7217
7218////////////////////////////////////////////////////////////////////////////////
7219/// Return list of font names matching "fontname".
7220
7221char **TGWin32::ListFonts(const char *fontname, Int_t /*max*/, Int_t &count)
7222{
7223 char foundry[32], family[100], weight[32], slant[32], font_name[256];
7224 char **fontlist;
7225 Int_t n1, fontcount = 0;
7226
7227 sscanf(fontname, "-%30[^-]-%100[^-]-%30[^-]-%30[^-]-%n",
7228 foundry, family, weight, slant, &n1);
7229 // replace "medium" by "normal"
7230 if(!stricmp(weight,"medium")) {
7231 sprintf(weight,"normal");
7232 }
7233 // since all sizes are allowed with TTF, just forget it...
7234 sprintf(font_name, "-%s-%s-%s-%s-*", foundry, family, weight, slant);
7235 fontlist = gdk_font_list_new(font_name, &fontcount);
7236 count = fontcount;
7237
7238 if (fontcount > 0) return fontlist;
7239 return 0;
7240}
7241
7242////////////////////////////////////////////////////////////////////////////////
7243///
7244
7245void TGWin32::FreeFontNames(char **fontlist)
7246{
7247 gdk_font_list_free(fontlist);
7248}
7249
7250////////////////////////////////////////////////////////////////////////////////
7251///
7252
7254{
7255 return (Drawable_t) gdk_image_new(GDK_IMAGE_SHARED, gdk_visual_get_best(),
7256 width, height);
7257}
7258
7259////////////////////////////////////////////////////////////////////////////////
7260///
7261
7263{
7264 width = ((GdkImage*)id)->width;
7265 height = ((GdkImage*)id)->height;
7266}
7267
7268////////////////////////////////////////////////////////////////////////////////
7269///
7270
7272{
7273 if (!id) return;
7274
7275 GdkImage *image = (GdkImage *)id;
7276 if (image->depth == 1) {
7277 if (pixel & 1) {
7278 ((UChar_t *) image->mem)[y * image->bpl + (x >> 3)] |= (1 << (7 - (x & 0x7)));
7279 } else {
7280 ((UChar_t *) image->mem)[y * image->bpl + (x >> 3)] &= ~(1 << (7 - (x & 0x7)));
7281 }
7282 } else {
7283 UChar_t *pixelp = (UChar_t *) image->mem + y * image->bpl + x * image->bpp;
7284 // Windows is always LSB, no need to check image->byte_order.
7285 switch (image->bpp) {
7286 case 4:
7287 pixelp[3] = 0;
7288 case 3:
7289 pixelp[2] = ((pixel >> 16) & 0xFF);
7290 case 2:
7291 pixelp[1] = ((pixel >> 8) & 0xFF);
7292 case 1:
7293 pixelp[0] = (pixel & 0xFF);
7294 }
7295 }
7296}
7297
7298////////////////////////////////////////////////////////////////////////////////
7299///
7300
7302 Int_t dy, Int_t x, Int_t y, UInt_t w, UInt_t h)
7303{
7304 if (!id) return;
7305
7306 gdk_draw_image((GdkDrawable *) id, (GdkGC *)gc, (GdkImage *)img,
7307 x, y, dx, dy, w, h);
7308 ::GdiFlush();
7309}
7310
7311////////////////////////////////////////////////////////////////////////////////
7312///
7313
7315{
7316 gdk_image_unref((GdkImage *)img);
7317}
7318
7319////////////////////////////////////////////////////////////////////////////////
7320/// Gets DIB bits
7321/// x, y, width, height - position of bitmap
7322/// returns a pointer on bitmap bits array
7323/// in format:
7324/// b1, g1, r1, 0, b2, g2, r2, 0 ... bn, gn, rn, 0 ..
7325///
7326/// Pixels are numbered from left to right and from top to bottom.
7327/// By default all pixels from the whole drawable are returned.
7328
7330 UInt_t width, UInt_t height)
7331{
7332 HDC hdc, memdc;
7333 BITMAPINFO bmi;
7334 HGDIOBJ oldbitmap1, oldbitmap2;
7335 BITMAP bm;
7336 HBITMAP ximage = 0;
7337 VOID *bmbits = 0;
7338 unsigned char *ret = 0;
7339
7340 if (GDK_DRAWABLE_TYPE(wid) == GDK_DRAWABLE_PIXMAP) {
7341 hdc = ::CreateCompatibleDC(NULL);
7342 oldbitmap1 = ::SelectObject(hdc, GDK_DRAWABLE_XID(wid));
7343 ::GetObject(GDK_DRAWABLE_XID(wid), sizeof(BITMAP), &bm);
7344 } else {
7345 hdc = ::GetDC((HWND)GDK_DRAWABLE_XID(wid));
7346 }
7347 memdc = ::CreateCompatibleDC(hdc);
7348
7349 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
7350 bmi.bmiHeader.biWidth = width;
7351 bmi.bmiHeader.biHeight = -1 * (int)(height);
7352 bmi.bmiHeader.biPlanes = 1;
7353 bmi.bmiHeader.biBitCount = 32;
7354 bmi.bmiHeader.biCompression = BI_RGB;
7355 bmi.bmiHeader.biSizeImage = 0;
7356 bmi.bmiHeader.biXPelsPerMeter = bmi.bmiHeader.biYPelsPerMeter = 0;
7357 bmi.bmiHeader.biClrUsed = 0;
7358 bmi.bmiHeader.biClrImportant = 0;
7359
7360 ximage = ::CreateDIBSection(hdc, (BITMAPINFO *) &bmi, DIB_RGB_COLORS, &bmbits, NULL, 0);
7361
7362 if (ximage && bmbits) {
7363 oldbitmap2 = ::SelectObject(memdc, ximage);
7364 ::BitBlt(memdc, x, y, width, height, hdc, 0, 0, SRCCOPY);
7365 ::SelectObject(memdc, oldbitmap2);
7366 }
7367 ::DeleteDC(memdc);
7368 if (GDK_DRAWABLE_TYPE(wid) == GDK_DRAWABLE_PIXMAP) {
7369 ::SelectObject(hdc, oldbitmap1);
7370 ::DeleteDC(hdc);
7371 } else {
7372 ::ReleaseDC((HWND)GDK_DRAWABLE_XID(wid), hdc);
7373 }
7374 if (ximage && bmbits) {
7375 ULong_t sz = width*height*4;
7376 ret = new unsigned char[sz];
7377 memcpy(ret, bmbits, sz);
7378 ::DeleteObject(ximage);
7379 }
7380 return ret;
7381}
7382
7383////////////////////////////////////////////////////////////////////////////////
7384/// create an image from RGB data. RGB data is in format :
7385/// b1, g1, r1, 0, b2, g2, r2, 0 ... bn, gn, rn, 0 ..
7386///
7387/// Pixels are numbered from left to right and from top to bottom.
7388/// Note that data must be 32-bit aligned
7389
7391{
7392 BITMAPINFO bmp_info;
7393 bmp_info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
7394 bmp_info.bmiHeader.biWidth = width;
7395 bmp_info.bmiHeader.biHeight = -1 * (int)(height);
7396 bmp_info.bmiHeader.biPlanes = 1;
7397 bmp_info.bmiHeader.biBitCount = 32;
7398 bmp_info.bmiHeader.biCompression = BI_RGB;
7399 bmp_info.bmiHeader.biSizeImage = 0;
7400 bmp_info.bmiHeader.biClrUsed = 0;
7401 bmp_info.bmiHeader.biXPelsPerMeter = 0L;
7402 bmp_info.bmiHeader.biYPelsPerMeter = 0L;
7403 bmp_info.bmiHeader.biClrImportant = 0;
7404 bmp_info.bmiColors[0].rgbRed = 0;
7405 bmp_info.bmiColors[0].rgbGreen = 0;
7406 bmp_info.bmiColors[0].rgbBlue = 0;
7407 bmp_info.bmiColors[0].rgbReserved = 0;
7408
7409 HDC hdc = ::GetDC(NULL);
7410 HBITMAP hbitmap = ::CreateDIBitmap(hdc, &bmp_info.bmiHeader, CBM_INIT,
7411 (void *)bits, &bmp_info, DIB_RGB_COLORS);
7412 ::ReleaseDC(NULL, hdc);
7413
7414 SIZE size;
7415 // For an obscure reason, we have to set the size of the
7416 // bitmap this way before to call gdk_pixmap_foreign_new
7417 // otherwise, it fails...
7418 ::SetBitmapDimensionEx(hbitmap,width, height, &size);
7419
7420 return (Pixmap_t)gdk_pixmap_foreign_new((guint32)hbitmap);
7421}
7422
7423////////////////////////////////////////////////////////////////////////////////
7424///register pixmap created by TGWin32GLManager
7425
7427{
7428 HBITMAP hBmp = reinterpret_cast<HBITMAP>(pix);
7429 SIZE sz = SIZE();
7430
7431 SetBitmapDimensionEx(hBmp, w, h, &sz);
7432 GdkPixmap *newPix = gdk_pixmap_foreign_new(reinterpret_cast<guint32>(hBmp));
7433
7434 Int_t wid = 0;
7435 for(; wid < fMaxNumberOfWindows; ++wid)
7436 if (!fWindows[wid].open)
7437 break;
7438
7439 if (wid == fMaxNumberOfWindows) {
7440 Int_t newSize = fMaxNumberOfWindows + 10;
7441
7442 fWindows = (XWindow_t *)TStorage::ReAlloc(fWindows, newSize * sizeof(XWindow_t),
7443 fMaxNumberOfWindows * sizeof(XWindow_t));
7444
7445 for (Int_t i = fMaxNumberOfWindows; i < newSize; ++i)
7446 fWindows[i].open = 0;
7447
7448 fMaxNumberOfWindows = newSize;
7449 }
7450
7451 fWindows[wid].open = 1;
7452 gCws = fWindows + wid;
7453 gCws->window = newPix;
7454 gCws->drawing = gCws->window;
7455 gCws->buffer = 0;
7456 gCws->double_buffer = 0;
7457 gCws->ispixmap = 1;
7458 gCws->clip = 0;
7459 gCws->width = w;
7460 gCws->height = h;
7461 gCws->new_colors = 0;
7462
7463 return wid;
7464}
7465
7466////////////////////////////////////////////////////////////////////////////////
7467/// Register a window created by Qt as a ROOT window (like InitWindow()).
7468
7470{
7471 Int_t wid;
7472 // Select next free window number
7473
7474 again:
7475 for (wid = 0; wid < fMaxNumberOfWindows; wid++) {
7476 if (!fWindows[wid].open) {
7477 fWindows[wid].open = 1;
7478 fWindows[wid].double_buffer = 0;
7479 gCws = &fWindows[wid];
7480 break;
7481 }
7482 }
7483
7484 if (wid == fMaxNumberOfWindows) {
7485 int newsize = fMaxNumberOfWindows + 10;
7486 fWindows =
7487 (XWindow_t *) TStorage::ReAlloc(fWindows,
7488 newsize * sizeof(XWindow_t),
7490 sizeof(XWindow_t));
7491
7492 for (int i = fMaxNumberOfWindows; i < newsize; i++) {
7493 fWindows[i].open = 0;
7494 }
7495
7496 fMaxNumberOfWindows = newsize;
7497 goto again;
7498 }
7499
7500 gCws->window = gdk_window_foreign_new((guint32)qwid);
7501
7502 gCws->drawing = gCws->window;
7503 gCws->buffer = 0;
7504 gCws->double_buffer = 0;
7505 gCws->ispixmap = 0;
7506 gCws->clip = 0;
7507 gCws->width = w;
7508 gCws->height = h;
7509 gCws->new_colors = 0;
7510
7511 return wid;
7512}
7513
7514////////////////////////////////////////////////////////////////////////////////
7515/// Remove a window created by Qt (like CloseWindow1()).
7516
7518{
7519 int wid;
7520
7521 SelectWindow((int)qwid);
7522
7523 if (gCws->buffer) {
7524 gdk_pixmap_unref(gCws->buffer);
7525 }
7526 if (gCws->new_colors) {
7527 gdk_colormap_free_colors((GdkColormap *) fColormap,
7528 (GdkColor *)gCws->new_colors, gCws->ncolors);
7529
7530 delete [] gCws->new_colors;
7531 gCws->new_colors = 0;
7532 }
7533
7534 GdiFlush();
7535 gCws->open = 0;
7536
7537 if (!fWindows) return;
7538
7539 // make first window in list the current window
7540 for (wid = 0; wid < fMaxNumberOfWindows; wid++) {
7541 if (fWindows[wid].open) {
7542 gCws = &fWindows[wid];
7543 return;
7544 }
7545 }
7546 gCws = 0;
7547}
7548
7549////////////////////////////////////////////////////////////////////////////////
7550/// The Nonrectangular Window Shape Extension adds nonrectangular
7551/// windows to the System.
7552/// This allows for making shaped (partially transparent) windows
7553
7555{
7556 gdk_window_shape_combine_mask((GdkWindow *)id, (GdkBitmap *) mask, x, y);
7557}
7558
7559////////////////////////////////////////////////////////////////////////////////
7560/// Returns the width of the screen in millimeters.
7561
7563{
7564 return (UInt_t)gdk_screen_width_mm();
7565}
7566
7567//------------------------------ Drag and Drop ---------------------------------
7568
7569////////////////////////////////////////////////////////////////////////////////
7570/// Deletes the specified property on the specified window.
7571
7573{
7574 HWND hWnd = (HWND)GDK_DRAWABLE_XID((GdkWindow *)win);
7575 Atom_t atom = (Atom_t)GetProp(hWnd,(LPCTSTR)MAKELONG(prop,0));
7576 if (atom != 0) {
7577 GlobalDeleteAtom(atom);
7578 }
7579 RemoveProp(hWnd,(LPCTSTR)MAKELONG(prop,0));
7580}
7581
7582////////////////////////////////////////////////////////////////////////////////
7583/// Returns the actual type of the property, the actual format of the property,
7584/// and a pointer to the data actually returned.
7585
7587 Bool_t del, Atom_t req_type, Atom_t *act_type,
7588 Int_t *act_format, ULong_t *nitems, ULong_t *bytes,
7589 unsigned char **prop_list)
7590{
7591 HGLOBAL hdata;
7592 UChar_t *ptr, *data;
7593 UInt_t i, n, length;
7594
7595 HWND hWnd = (HWND)GDK_DRAWABLE_XID((GdkWindow *)win);
7596 if (hWnd == NULL)
7597 return 0;
7598
7599 Atom_t dndproxy = InternAtom("XdndProxy", kFALSE);
7600 Atom_t dndtypelist = InternAtom("XdndTypeList", kFALSE);
7601
7602 if (prop == dndproxy)
7603 return 0;
7604 if (prop == dndtypelist) {
7605 *act_type = XA_ATOM;
7606 *prop_list = (unsigned char *)GetProp(hWnd, (LPCTSTR)MAKELONG(prop,0));
7607 for (n = 0; prop_list[n]; n++);
7608 *nitems = n;
7609 return n;
7610 }
7611 else {
7612 if (!OpenClipboard((HWND)GDK_DRAWABLE_XID((GdkWindow *)win))) {
7613 return 0;
7614 }
7615 hdata = GetClipboardData(CF_PRIVATEFIRST);
7616 ptr = (UChar_t *)GlobalLock(hdata);
7617 length = GlobalSize(hdata);
7618 data = (UChar_t *)malloc(length + 1);
7619 for (i = 0; i < length; i++) {
7620 data[i] = ptr[i];
7621 }
7622 GlobalUnlock(hdata);
7623 CloseClipboard();
7624 *prop_list = data;
7625 *bytes = *nitems = length;
7626 return length;
7627 }
7628 return 0;
7629}
7630
7631////////////////////////////////////////////////////////////////////////////////
7632/// Changes the active cursor of the specified window.
7633
7635{
7636 UInt_t xevmask;
7637 MapEventMask(mask, xevmask);
7638 if (cur == kNone)
7639 gdk_window_set_cursor((GdkWindow *) win, fCursors[kHand]);
7640 else
7641 gdk_window_set_cursor((GdkWindow *) win, (GdkCursor *)cur);
7642}
7643
7644////////////////////////////////////////////////////////////////////////////////
7645/// Get Clipboard data.
7646
7648 Atom_t &prop, Time_t &stamp)
7649{
7650 HGLOBAL hdata;
7651
7652 static UINT gdk_selection_notify_msg =
7653 RegisterWindowMessage("gdk-selection-notify");
7654 HWND hWnd = (HWND)GDK_DRAWABLE_XID((GdkWindow *)win);
7655 if (!OpenClipboard((HWND)GDK_DRAWABLE_XID((GdkWindow *)win))) {
7656 return;
7657 }
7658 hdata = GetClipboardData(CF_PRIVATEFIRST);
7659 CloseClipboard();
7660 if (hdata == 0)
7661 return;
7662 /* Send ourselves an ersatz selection notify message so that we actually
7663 * fetch the data.
7664 */
7665 PostMessage(hWnd, gdk_selection_notify_msg, sel, target);
7666}
7667
7668////////////////////////////////////////////////////////////////////////////////
7669/// Assigns owner of Clipboard.
7670
7672{
7673 static UINT gdk_selection_request_msg =
7674 RegisterWindowMessage("gdk-selection-request");
7675 HWND hWnd = (HWND)GDK_DRAWABLE_XID((GdkWindow *)owner);
7676 OpenClipboard(hWnd);
7677 EmptyClipboard();
7678 CloseClipboard();
7679 if (owner) {
7680 ::PostMessage(hWnd, gdk_selection_request_msg, sel, 0);
7681 }
7682 return kTRUE;
7683}
7684
7685////////////////////////////////////////////////////////////////////////////////
7686/// Put data into Clipboard.
7687
7689 Int_t format, UChar_t *data, Int_t len)
7690{
7691 HGLOBAL hdata;
7692 Int_t i;
7693 UChar_t *ptr;
7694
7695 if (data == 0 || len == 0)
7696 return;
7697 if (!OpenClipboard((HWND)GDK_DRAWABLE_XID((GdkWindow *)id))) {
7698 return;
7699 }
7700 hdata = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, len + 1);
7701 ptr = (UChar_t *)GlobalLock(hdata);
7702 for (i = 0; i < len; i++) {
7703 *ptr++ = *data++;
7704 }
7705 GlobalUnlock(hdata);
7706 SetClipboardData(CF_PRIVATEFIRST, hdata);
7707 CloseClipboard();
7708}
7709
7710////////////////////////////////////////////////////////////////////////////////
7711/// Add the list of drag and drop types to the Window win.
7712
7713void TGWin32::SetTypeList(Window_t win, Atom_t prop, Atom_t *typelist)
7714{
7715 SetProp((HWND)GDK_DRAWABLE_XID((GdkWindow *)win),
7716 (LPCTSTR)MAKELONG(prop,0),
7717 (HANDLE)typelist);
7718}
7719
7720////////////////////////////////////////////////////////////////////////////////
7721/// Recursively search in the children of Window for a Window which is at
7722/// location x, y and is DND aware, with a maximum depth of maxd.
7723/// Possibility to exclude dragwin and input.
7724
7726 int x, int y, int maxd)
7727{
7728 POINT point;
7729 POINT cpt;
7730 RECT rect;
7731 HWND hwnd, hwndc;
7732 HWND hwndt;
7733 Window_t win, retwin = kNone;
7734 Atom_t version = 0;
7735 Atom_t dndaware = InternAtom("XdndAware", kFALSE);
7736
7737 cpt.x = x;
7738 cpt.y = y;
7739 hwnd = ::ChildWindowFromPointEx((HWND)GDK_DRAWABLE_XID((GdkWindow *)root),
7740 cpt, CWP_ALL);
7741 while (hwnd) {
7742 GetWindowRect(hwnd, &rect);
7743 if (PtInRect(&rect, cpt)) {
7744 if (GetProp(hwnd,(LPCTSTR)MAKELONG(dndaware,0))) {
7745 win = (Window_t) gdk_xid_table_lookup(hwnd);
7746 if (win && win != dragwin && win != input)
7747 return win;
7748 }
7749 Bool_t done = kFALSE;
7750 hwndt = hwnd;
7751 while (!done) {
7752 point = cpt;
7753 ::MapWindowPoints(NULL, hwndt, &point, 1);
7754 hwndc = ChildWindowFromPoint (hwndt, point);
7755 if (GetProp(hwnd,(LPCTSTR)MAKELONG(dndaware,0))) {
7756 win = (Window_t) gdk_xid_table_lookup(hwndc);
7757 if (win && win != dragwin && win != input)
7758 return win;
7759 }
7760 if (hwndc == NULL)
7761 done = TRUE;
7762 else if (hwndc == hwndt)
7763 done = TRUE;
7764 else
7765 hwndt = hwndc;
7766 if (GetProp(hwndt,(LPCTSTR)MAKELONG(dndaware,0))) {
7767 win = (Window_t) gdk_xid_table_lookup(hwndt);
7768 if (win && win != dragwin && win != input)
7769 return win;
7770 }
7771 }
7772 }
7773 hwnd = GetNextWindow(hwnd, GW_HWNDNEXT);
7774 }
7775 return kNone;
7776}
7777
7778////////////////////////////////////////////////////////////////////////////////
7779/// Checks if Window win is DND aware, and knows any of the DND formats
7780/// passed in argument.
7781
7783{
7784 if (!win) return kFALSE;
7785
7786 Atom_t version = 0;
7787 Atom_t dndaware = InternAtom("XdndAware", kFALSE);
7788 HWND window = (HWND)GDK_DRAWABLE_XID((GdkWindow *)win);
7789 while (window) {
7790 version = (Atom_t)GetProp(window,(LPCTSTR)MAKELONG(dndaware,0));
7791 if (version) return kTRUE;
7792 window = ::GetParent(window);
7793 }
7794 return kFALSE;
7795}
7796
7797////////////////////////////////////////////////////////////////////////////////
7798/// Add XdndAware property and the list of drag and drop types to the
7799/// Window win.
7800
7802{
7803 int n;
7804 if (!id) return;
7805
7806 DWORD dwStyle = GetWindowLong((HWND)GDK_DRAWABLE_XID((GdkWindow *)id),
7807 GWL_EXSTYLE);
7808 SetWindowLong((HWND)GDK_DRAWABLE_XID((GdkWindow *)id), GWL_EXSTYLE,
7809 dwStyle | WS_EX_ACCEPTFILES);
7810 Atom_t dndaware = InternAtom("XdndAware", kFALSE);
7811 SetProp((HWND)GDK_DRAWABLE_XID((GdkWindow *)id),
7812 (LPCTSTR)MAKELONG(dndaware,0),
7813 (HANDLE)XDND_PROTOCOL_VERSION);
7814
7815 if (typelist == 0)
7816 return;
7817 for (n = 0; typelist[n]; n++);
7818 Atom_t dndtypelist = InternAtom("XdndTypeList", kFALSE);
7819 SetProp((HWND)GDK_DRAWABLE_XID((GdkWindow *)id),
7820 (LPCTSTR)MAKELONG(dndtypelist,0),
7821 (HANDLE)typelist);
7822
7823}
7824
7825////////////////////////////////////////////////////////////////////////////////
7826/// Set user thread id. This is used when an extra thread is created
7827/// to process events.
7828
7830{
7831 if (id == 0) {
7833 }
7834 else {
7836 }
7837}
7838
const Int_t kPropMotifWMHintsElements
Definition: GX11Gui.cxx:59
static KeySymbolMap_t gKeyMap[]
Definition: GX11Gui.cxx:73
const ULong_t kMWMHintsInputMode
Definition: GX11Gui.cxx:57
const ULong_t kMWMHintsDecorations
Definition: GX11Gui.cxx:56
const Int_t kPropMWMHintElements
Definition: GX11Gui.cxx:60
const ULong_t kMWMHintsFunctions
Definition: GX11Gui.cxx:55
void AsmLong(Long_t i1, Long_t i2, Long_t &ll)
Definition: GX11Gui.cxx:159
void SplitLong(Long_t ll, Long_t &i1, Long_t &i2)
Definition: GX11Gui.cxx:148
const Mask_t kGCCapStyle
Definition: GuiTypes.h:291
EGEventType
Definition: GuiTypes.h:58
@ kSelectionClear
Definition: GuiTypes.h:62
@ kConfigureNotify
Definition: GuiTypes.h:61
@ kGKeyPress
Definition: GuiTypes.h:59
@ kExpose
Definition: GuiTypes.h:61
@ kUnmapNotify
Definition: GuiTypes.h:61
@ kButtonRelease
Definition: GuiTypes.h:59
@ kSelectionNotify
Definition: GuiTypes.h:62
@ kButtonPress
Definition: GuiTypes.h:59
@ kFocusOut
Definition: GuiTypes.h:60
@ kDestroyNotify
Definition: GuiTypes.h:61
@ kMotionNotify
Definition: GuiTypes.h:60
@ kFocusIn
Definition: GuiTypes.h:60
@ kClientMessage
Definition: GuiTypes.h:62
@ kEnterNotify
Definition: GuiTypes.h:60
@ kSelectionRequest
Definition: GuiTypes.h:62
@ kMapNotify
Definition: GuiTypes.h:61
@ kOtherEvent
Definition: GuiTypes.h:63
@ kKeyRelease
Definition: GuiTypes.h:59
@ kLeaveNotify
Definition: GuiTypes.h:60
const Mask_t kWAOverrideRedirect
Definition: GuiTypes.h:148
const Mask_t kGCBackground
Definition: GuiTypes.h:288
const Mask_t kGCForeground
Definition: GuiTypes.h:287
const Mask_t kGCLineStyle
Definition: GuiTypes.h:290
const Mask_t kGCSubwindowMode
Definition: GuiTypes.h:300
const Mask_t kGCLineWidth
Definition: GuiTypes.h:289
Handle_t Cursor_t
Definition: GuiTypes.h:33
const Mask_t kGCTile
Definition: GuiTypes.h:295
const Mask_t kWAColormap
Definition: GuiTypes.h:152
const Mask_t kButtonMotionMask
Definition: GuiTypes.h:163
const Mask_t kGCClipXOrigin
Definition: GuiTypes.h:302
const Mask_t kFocusChangeMask
Definition: GuiTypes.h:168
ULong_t Handle_t
Definition: GuiTypes.h:25
const Mask_t kButtonPressMask
Definition: GuiTypes.h:160
Handle_t FontH_t
Definition: GuiTypes.h:34
@ kNotifyNormal
Definition: GuiTypes.h:218
const Mask_t kExposureMask
Definition: GuiTypes.h:164
const Mask_t kWAEventMask
Definition: GuiTypes.h:150
const Mask_t kGCFillStyle
Definition: GuiTypes.h:293
const Mask_t kGCJoinStyle
Definition: GuiTypes.h:292
const Mask_t kKeyReleaseMask
Definition: GuiTypes.h:159
const Mask_t kWABackPixel
Definition: GuiTypes.h:139
Handle_t Display_t
Definition: GuiTypes.h:26
const Mask_t kGCFunction
Definition: GuiTypes.h:285
const Mask_t kAnyModifier
Definition: GuiTypes.h:209
EGraphicsFunction
Definition: GuiTypes.h:66
@ kGXorReverse
Definition: GuiTypes.h:78
@ kGXnand
Definition: GuiTypes.h:81
@ kGXandReverse
Definition: GuiTypes.h:69
@ kGXor
Definition: GuiTypes.h:74
@ kGXcopy
Definition: GuiTypes.h:70
@ kGXorInverted
Definition: GuiTypes.h:80
@ kGXandInverted
Definition: GuiTypes.h:71
@ kGXequiv
Definition: GuiTypes.h:76
@ kGXset
Definition: GuiTypes.h:82
@ kGXnoop
Definition: GuiTypes.h:72
@ kGXinvert
Definition: GuiTypes.h:77
@ kGXxor
Definition: GuiTypes.h:73
@ kGXand
Definition: GuiTypes.h:68
@ kGXclear
Definition: GuiTypes.h:67
@ kGXcopyInverted
Definition: GuiTypes.h:79
Handle_t Pixmap_t
Definition: GuiTypes.h:29
const Mask_t kKeyPressMask
Definition: GuiTypes.h:158
ULong_t Time_t
Definition: GuiTypes.h:41
EInitialState
Definition: GuiTypes.h:344
@ kNormalState
Definition: GuiTypes.h:345
@ kIconicState
Definition: GuiTypes.h:346
const Mask_t kGCTileStipXOrigin
Definition: GuiTypes.h:297
Handle_t Drawable_t
Definition: GuiTypes.h:30
const Mask_t kGCFont
Definition: GuiTypes.h:299
const Mask_t kPointerMotionMask
Definition: GuiTypes.h:162
Handle_t Colormap_t
Definition: GuiTypes.h:32
Handle_t Atom_t
Definition: GuiTypes.h:36
const Mask_t kLeaveWindowMask
Definition: GuiTypes.h:167
const Mask_t kStructureNotifyMask
Definition: GuiTypes.h:165
@ kIsViewable
Definition: GuiTypes.h:45
@ kInputOutput
Definition: GuiTypes.h:46
@ kClipByChildren
Definition: GuiTypes.h:52
@ kIsUnviewable
Definition: GuiTypes.h:45
@ kNotUseful
Definition: GuiTypes.h:44
@ kIsUnmapped
Definition: GuiTypes.h:45
@ kIncludeInferiors
Definition: GuiTypes.h:52
const Handle_t kParentRelative
Definition: GuiTypes.h:89
Handle_t GContext_t
Definition: GuiTypes.h:37
UInt_t Mask_t
Definition: GuiTypes.h:40
const Mask_t kGCStipple
Definition: GuiTypes.h:296
const Mask_t kButtonReleaseMask
Definition: GuiTypes.h:161
const Mask_t kGCGraphicsExposures
Definition: GuiTypes.h:301
const Mask_t kGCClipYOrigin
Definition: GuiTypes.h:303
Handle_t Region_t
Definition: GuiTypes.h:31
const Mask_t kEnterWindowMask
Definition: GuiTypes.h:166
const Mask_t kGCClipMask
Definition: GuiTypes.h:304
Handle_t FontStruct_t
Definition: GuiTypes.h:38
const Mask_t kGCTileStipYOrigin
Definition: GuiTypes.h:298
const Mask_t kWACursor
Definition: GuiTypes.h:153
EMouseButton
Definition: GuiTypes.h:213
@ kButton4
Definition: GuiTypes.h:214
@ kButton5
Definition: GuiTypes.h:214
Handle_t Window_t
Definition: GuiTypes.h:28
const Mask_t kWABackPixmap
Definition: GuiTypes.h:138
const Mask_t kWABorderWidth
Definition: GuiTypes.h:142
EKeySym
Definition: KeySymbols.h:25
@ kKey_Right
Definition: KeySymbols.h:42
@ kKey_Down
Definition: KeySymbols.h:43
@ kKey_Unknown
Definition: KeySymbols.h:189
@ kKey_Meta
Definition: KeySymbols.h:51
@ kKey_Print
Definition: KeySymbols.h:35
@ kKey_Space
Definition: KeySymbols.h:93
@ kKey_F1
Definition: KeySymbols.h:57
@ kKey_CapsLock
Definition: KeySymbols.h:53
@ kKey_Up
Definition: KeySymbols.h:41
@ kKey_Return
Definition: KeySymbols.h:30
@ kKey_Alt
Definition: KeySymbols.h:52
@ kKey_Next
Definition: KeySymbols.h:46
@ kKey_Comma
Definition: KeySymbols.h:105
@ kKey_ScrollLock
Definition: KeySymbols.h:55
@ kKey_Asterisk
Definition: KeySymbols.h:103
@ kKey_Delete
Definition: KeySymbols.h:33
@ kKey_0
Definition: KeySymbols.h:109
@ kKey_Prior
Definition: KeySymbols.h:44
@ kKey_Left
Definition: KeySymbols.h:40
@ kKey_Escape
Definition: KeySymbols.h:26
@ kKey_Shift
Definition: KeySymbols.h:49
@ kKey_Backspace
Definition: KeySymbols.h:29
@ kKey_Home
Definition: KeySymbols.h:38
@ kKey_F35
Definition: KeySymbols.h:91
@ kKey_Insert
Definition: KeySymbols.h:32
@ kKey_Enter
Definition: KeySymbols.h:31
@ kKey_Plus
Definition: KeySymbols.h:104
@ kKey_Control
Definition: KeySymbols.h:50
@ kKey_Tab
Definition: KeySymbols.h:27
@ kKey_Slash
Definition: KeySymbols.h:108
@ kKey_Period
Definition: KeySymbols.h:107
@ kKey_Backtab
Definition: KeySymbols.h:28
@ kKey_SysReq
Definition: KeySymbols.h:36
@ kKey_End
Definition: KeySymbols.h:39
@ kKey_Equal
Definition: KeySymbols.h:122
@ kKey_NumLock
Definition: KeySymbols.h:54
@ kKey_Pause
Definition: KeySymbols.h:34
@ kKey_Minus
Definition: KeySymbols.h:106
ROOT::R::TRInterface & r
Definition: Object.C:4
#define d(i)
Definition: RSha256.hxx:102
#define b(i)
Definition: RSha256.hxx:100
#define f(i)
Definition: RSha256.hxx:104
#define c(i)
Definition: RSha256.hxx:101
#define g(i)
Definition: RSha256.hxx:105
#define h(i)
Definition: RSha256.hxx:106
#define R(a, b, c, d, e, f, g, h, i)
Definition: RSha256.hxx:110
const unsigned char gStipples[26][32]
Definition: RStipples.h:26
static const double x2[5]
static const double x1[5]
unsigned short UShort_t
Definition: RtypesCore.h:36
unsigned char Byte_t
Definition: RtypesCore.h:60
int Int_t
Definition: RtypesCore.h:41
const size_t kBitsPerByte
Definition: RtypesCore.h:110
unsigned char UChar_t
Definition: RtypesCore.h:34
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
int Seek_t
Definition: RtypesCore.h:49
unsigned long ULong_t
Definition: RtypesCore.h:51
long Long_t
Definition: RtypesCore.h:50
short Width_t
Definition: RtypesCore.h:78
bool Bool_t
Definition: RtypesCore.h:59
short Font_t
Definition: RtypesCore.h:75
short Short_t
Definition: RtypesCore.h:35
short Color_t
Definition: RtypesCore.h:79
long long Long64_t
Definition: RtypesCore.h:69
short Style_t
Definition: RtypesCore.h:76
float Float_t
Definition: RtypesCore.h:53
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define BIT(n)
Definition: Rtypes.h:82
#define ClassImp(name)
Definition: Rtypes.h:363
#define TESTBIT(n, i)
Definition: Rtypes.h:85
R__EXTERN Int_t gDebug
Definition: Rtypes.h:90
R__EXTERN TApplication * gApplication
Definition: TApplication.h:165
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
@ kTempFrame
Definition: TGFrame.h:71
@ kTransientFrame
Definition: TGFrame.h:70
@ kMainFrame
Definition: TGFrame.h:58
#define CALLBACK
Definition: TGLFaceSet.cxx:30
void gdk_win32_draw_segments(GdkDrawable *drawable, GdkGC *gc, GdkSegment *segs, gint nsegs)
int GIFdecode(Byte_t *GIFarr, Byte_t *PIXarr, int *Width, int *Height, int *Ncols, Byte_t *R, Byte_t *G, Byte_t *B)
Definition: gifdecode.c:149
int GIFquantize(UInt_t width, UInt_t height, Int_t *ncol, Byte_t *red, Byte_t *green, Byte_t *blue, Byte_t *outputBuf, Byte_t *outputCmap)
#define XDND_PROTOCOL_VERSION
Definition: TGWin32.cxx:66
#define BITmask(x)
static FILE * gGifFile
Definition: TGWin32.cxx:4268
int GIFinfo(Byte_t *GIFarr, int *Width, int *Height, int *Ncols)
Definition: gifdecode.c:80
static void GetPixel(int y, int width, Byte_t *scline)
Get pixels in line y and put in array scline.
Definition: TGWin32.cxx:4288
static void _set_event_time(GdkEvent &event, UInt_t time)
Definition: TGWin32.cxx:5885
void gdk_win32_draw_text(GdkDrawable *drawable, GdkFont *font, GdkGC *gc, gint x, gint y, const gchar *text, gint text_length)
void gdk_win32_draw_polygon(GdkDrawable *drawable, GdkGC *gc, gint filled, GdkPoint *points, gint npoints)
void gdk_win32_draw_lines(GdkDrawable *drawable, GdkGC *gc, GdkPoint *points, gint npoints)
void gdk_win32_draw_points(GdkDrawable *drawable, GdkGC *gc, GdkPoint *points, gint npoints)
static GdkImage * gGifImage
Definition: TGWin32.cxx:4269
static void PutByte(Byte_t b)
Put byte b in output stream.
Definition: TGWin32.cxx:4298
VOID CALLBACK MyTimerProc(HWND hwnd, UINT message, UINT idTimer, DWORD dwTime)
Windows timer handling events while moving/resizing windows.
Definition: TGWin32.cxx:836
void gdk_win32_draw_arc(GdkDrawable *drawable, GdkGC *gc, gint filled, gint x, gint y, gint width, gint height, gint angle1, gint angle2)
long GIFencode(int Width, int Height, Int_t Ncol, Byte_t R[], Byte_t G[], Byte_t B[], Byte_t ScLine[], void(*get_scline)(int, int, Byte_t *), void(*pb)(Byte_t))
int gdk_debug_level
Definition: TGWin32.cxx:137
#define IDC_HAND
Definition: TGWin32.cxx:68
void gdk_win32_draw_rectangle(GdkDrawable *drawable, GdkGC *gc, gint filled, gint x, gint y, gint width, gint height)
#define safestrlen(s)
Definition: TGWin32.cxx:6519
unsigned long KeySym
Definition: TGWin32.h:53
static Int_t gFillHollow
Definition: TGX11.cxx:100
static ULong_t gKeybdMask
Definition: TGX11.cxx:144
static int gCapStyle
Definition: TGX11.cxx:130
static GC * gGCfill
Definition: TGX11.cxx:92
static GC gGCecho
Definition: TGX11.cxx:98
static GC * gGCinvt
Definition: TGX11.cxx:94
static Pixmap gFillPattern
Definition: TGX11.cxx:101
static Cursor gNullCursor
Definition: TGX11.cxx:154
static XWindow_t * gTws
Definition: TGX11.cxx:81
const int kMAXGC
Definition: TGX11.cxx:88
static int gLineStyle
Definition: TGX11.cxx:129
const char null_cursor_bits[]
Definition: TGX11.cxx:150
static char gDashList[10]
Definition: TGX11.cxx:132
static int gDashOffset
Definition: TGX11.cxx:134
const Int_t kBIGGEST_RGB_VALUE
Definition: TGX11.cxx:83
const Int_t kMAXMK
Definition: TGX11.cxx:118
static GC * gGCpxmp
Definition: TGX11.cxx:96
static GC * gGCline
Definition: TGX11.cxx:90
static ULong_t gMouseMask
Definition: TGX11.cxx:140
static int gJoinStyle
Definition: TGX11.cxx:131
static GC gGClist[kMAXGC]
Definition: TGX11.cxx:89
static int gDashLength
Definition: TGX11.cxx:133
static GC * gGCdash
Definition: TGX11.cxx:95
static GC * gGCmark
Definition: TGX11.cxx:91
int type
Definition: TGX11.cxx:120
static GC * gGCtext
Definition: TGX11.cxx:93
static int gDashSize
Definition: TGX11.cxx:135
static int gLineWidth
Definition: TGX11.cxx:128
XPoint xy[kMAXMK]
Definition: TGX11.cxx:122
static XFontStruct * gTextFont
Definition: TGX11.cxx:112
static XWindow_t * gCws
Definition: TGX11.cxx:80
static struct @49 gMarker
float xmin
Definition: THbookFile.cxx:93
float ymin
Definition: THbookFile.cxx:93
float xmax
Definition: THbookFile.cxx:93
float ymax
Definition: THbookFile.cxx:93
R__EXTERN TInterpreter *(* gPtr2Interpreter)()
Definition: TInterpreter.h:539
#define gROOT
Definition: TROOT.h:410
R__EXTERN TStyle * gStyle
Definition: TStyle.h:406
R__EXTERN TSystem * gSystem
Definition: TSystem.h:540
#define gVirtualX
Definition: TVirtualX.h:345
R__EXTERN TVirtualX *(* gPtr2VirtualX)()
Definition: TVirtualX.h:346
ECursor
Definition: TVirtualX.h:44
@ kRightSide
Definition: TVirtualX.h:45
@ kBottomSide
Definition: TVirtualX.h:45
@ kArrowRight
Definition: TVirtualX.h:47
@ kTopLeft
Definition: TVirtualX.h:44
@ kBottomRight
Definition: TVirtualX.h:44
@ kArrowVer
Definition: TVirtualX.h:46
@ kCaret
Definition: TVirtualX.h:47
@ kTopSide
Definition: TVirtualX.h:45
@ kLeftSide
Definition: TVirtualX.h:45
@ kWatch
Definition: TVirtualX.h:47
@ kMove
Definition: TVirtualX.h:46
@ kTopRight
Definition: TVirtualX.h:44
@ kBottomLeft
Definition: TVirtualX.h:44
@ kHand
Definition: TVirtualX.h:46
@ kCross
Definition: TVirtualX.h:46
@ kRotate
Definition: TVirtualX.h:46
@ kNoDrop
Definition: TVirtualX.h:47
@ kArrowHor
Definition: TVirtualX.h:46
@ kPointer
Definition: TVirtualX.h:47
R__EXTERN Atom_t gWM_DELETE_WINDOW
Definition: TVirtualX.h:39
R__EXTERN TWin32SplashThread * gSplash
R__EXTERN ULong_t gConsoleWindow
Definition: TWinNTSystem.h:265
segment * segs
Definition: X3DBuffer.c:23
point * points
Definition: X3DBuffer.c:22
#define TRUE
#define FALSE
#define free
Definition: civetweb.c:1539
#define calloc
Definition: civetweb.c:1537
#define malloc
Definition: civetweb.c:1536
char ** Argv() const
Definition: TApplication.h:136
virtual Color_t GetFillColor() const
Return the fill area color.
Definition: TAttFill.h:30
Style_t fFillStyle
Fill area style.
Definition: TAttFill.h:23
Color_t fFillColor
Fill area color.
Definition: TAttFill.h:22
Width_t fLineWidth
Line width.
Definition: TAttLine.h:23
Style_t fLineStyle
Line style.
Definition: TAttLine.h:22
Color_t fLineColor
Line color.
Definition: TAttLine.h:21
Color_t fMarkerColor
Marker color.
Definition: TAttMarker.h:22
Size_t fMarkerSize
Marker size.
Definition: TAttMarker.h:24
Style_t fMarkerStyle
Marker style.
Definition: TAttMarker.h:23
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition: TAttText.h:41
Float_t fTextAngle
Text angle.
Definition: TAttText.h:21
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
Definition: TAttText.h:43
Font_t fTextFont
Text font.
Definition: TAttText.h:25
Float_t fTextSize
Text size.
Definition: TAttText.h:22
The color creation and management class.
Definition: TColor.h:19
Float_t GetRed() const
Definition: TColor.h:56
Float_t GetBlue() const
Definition: TColor.h:58
Float_t GetGreen() const
Definition: TColor.h:57
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:491
Bool_t Next(ULong64_t &hash, Long64_t &key, Long64_t &value)
Get next entry from TExMap. Returns kFALSE at end of map.
Definition: TExMap.cxx:411
This class stores a (key,value) pair using an external hash.
Definition: TExMap.h:33
void Add(ULong64_t hash, Long64_t key, Long64_t value)
Add an (key,value) pair to the table. The key should be unique.
Definition: TExMap.cxx:87
Long64_t GetValue(ULong64_t hash, Long64_t key)
Return the value belonging to specified key and hash value.
Definition: TExMap.cxx:173
Proxy classes provide thread-safe interface to global objects.
static ULong_t fgPingMessageId
ping message ID
static void GlobalUnlock()
unlock any proxy (client thread)
static UInt_t fMaxResponseTime
max period for waiting response from server thread
static void GlobalLock()
lock any proxy (client thread)
static ULong_t fgUserThreadId
user (e.g. python) thread ID
static ULong_t fgPostMessageId
post message ID
static ULong_t fgMainThreadId
main thread ID
virtual void ExecuteCallBack(Bool_t sync)
Executes all batched callbacks and the latest callback This method is executed by server thread.
static TVirtualX * fgRealObject
static TVirtualX * ProxyObject()
static TVirtualX * RealObject()
This class is the basic interface to the Win32 graphics system.
Definition: TGWin32.h:67
void DrawString(Drawable_t id, GContext_t gc, Int_t x, Int_t y, const char *s, Int_t len)
Draw a string using a specific graphics context in position (x,y).
Definition: TGWin32.cxx:6654
void SetClipRectangles(GContext_t gc, Int_t x, Int_t y, Rectangle_t *recs, Int_t n)
Set clipping rectangles in graphics context.
Definition: TGWin32.cxx:7077
void MapWindow(Window_t id)
Map window on screen.
Definition: TGWin32.cxx:4595
void SetWMSizeHints(Window_t id, UInt_t wmin, UInt_t hmin, UInt_t wmax, UInt_t hmax, UInt_t winc, UInt_t hinc)
Give the window manager minimum and maximum size hints.
Definition: TGWin32.cxx:6596
void DrawImage(FT_Bitmap *source, ULong_t fore, ULong_t back, GdkImage *xim, Int_t bx, Int_t by)
Draw FT_Bitmap bitmap to xim image at position bx,by using specified foreground color.
Definition: TGWin32.cxx:1238
void MapModifierState(UInt_t &state, UInt_t &xstate, Bool_t tox=kTRUE)
Map modifier key state to or from X.
Definition: TGWin32.cxx:5873
void CloseWindow1()
Delete current window.
Definition: TGWin32.cxx:1609
void SetClassHints(Window_t id, char *className, char *resourceName)
Set the windows class and resource name.
Definition: TGWin32.cxx:6524
void LookupString(Event_t *event, char *buf, Int_t buflen, UInt_t &keysym)
Convert the keycode from the event structure to a key symbol (according to the modifiers specified in...
Definition: TGWin32.cxx:6850
void DestroyWindow(Window_t id)
Destroy window.
Definition: TGWin32.cxx:4658
void IntersectRegion(Region_t rega, Region_t regb, Region_t result)
Compute the intersection of rega and regb and return result region.
Definition: TGWin32.cxx:7158
void SetIconPixmap(Window_t id, Pixmap_t pic)
Set pixmap the WM can use when the window is iconized.
Definition: TGWin32.cxx:6512
void DrawCellArray(Int_t x1, Int_t y1, Int_t x2, Int_t y2, Int_t nx, Int_t ny, Int_t *ic)
Draw a cell array.
Definition: TGWin32.cxx:1702
void SetMarkerSize(Float_t markersize)
Set marker size index.
Definition: TGWin32.cxx:3373
void MapSetWindowAttributes(SetWindowAttributes_t *attr, ULong_t &xmask, GdkWindowAttr &xattr)
Map a SetWindowAttributes_t to a GdkWindowAttr structure.
Definition: TGWin32.cxx:4978
void UpdateMarkerColor()
Definition: TGWin32.cxx:3363
void SetClipOFF(Int_t wid)
Turn off the clipping for the window wid.
Definition: TGWin32.cxx:2900
void SetClipRegion(Int_t wid, Int_t x, Int_t y, UInt_t w, UInt_t h)
Set clipping region for the window wid.
Definition: TGWin32.cxx:2918
void SetCharacterUp(Float_t chupx, Float_t chupy)
Set character up vector.
Definition: TGWin32.cxx:2871
void DrawFillArea(Int_t n, TPoint *xy)
Fill area described by polygon.
Definition: TGWin32.cxx:1738
void SendEvent(Window_t id, Event_t *ev)
Send event ev to window id.
Definition: TGWin32.cxx:5824
void QueryColor(Colormap_t cmap, ColorStruct_t &color)
Fill in the primary color components for a specific pixel value.
Definition: TGWin32.cxx:5762
void GetPasteBuffer(Window_t id, Atom_t atom, TString &text, Int_t &nchar, Bool_t del)
Get contents of paste buffer atom into string.
Definition: TGWin32.cxx:6903
void SetInputFocus(Window_t id)
Set keyboard input focus to window id.
Definition: TGWin32.cxx:6797
void SubtractRegion(Region_t rega, Region_t regb, Region_t result)
Subtract rega from regb.
Definition: TGWin32.cxx:7167
void SetForeground(GContext_t gc, ULong_t foreground)
Set foreground color in graphics context (shortcut for ChangeGC with only foreground mask set).
Definition: TGWin32.cxx:7062
void MoveWindow(Int_t wid, Int_t x, Int_t y)
Move the window wid.
Definition: TGWin32.cxx:2090
Int_t EventsPending()
Returns number of pending events.
Definition: TGWin32.cxx:5838
const char * DisplayName(const char *dpyName=0)
Return hostname on which the display is opened.
Definition: TGWin32.cxx:2031
Int_t TextWidth(FontStruct_t font, const char *s, Int_t len)
Return length of string in pixels. Size depends on font.
Definition: TGWin32.cxx:6668
void DrawBox(Int_t x1, Int_t y1, Int_t x2, Int_t y2, EBoxMode mode)
Draw a box.
Definition: TGWin32.cxx:1663
void UnmapWindow(Window_t id)
Unmap window from screen.
Definition: TGWin32.cxx:4648
void ClearWindow()
Clear current window.
Definition: TGWin32.cxx:1574
void SetTextFont(Font_t fontnumber)
Set specified font.
Definition: TGWin32.cxx:1541
Pixmap_t ReadGIF(Int_t x0, Int_t y0, const char *file, Window_t id=0)
If id is NULL - loads the specified gif file at position [x0,y0] in the current window.
Definition: TGWin32.cxx:4512
Float_t fCharacterUpY
Character Up vector along Y.
Definition: TGWin32.h:120
Bool_t EqualRegion(Region_t rega, Region_t regb)
Returns true if two regions are equal.
Definition: TGWin32.cxx:7200
void FillPolygon(Window_t id, GContext_t gc, Point_t *points, Int_t npnt)
FillPolygon fills the region closed by the specified path.
Definition: TGWin32.cxx:6990
void UnionRegion(Region_t rega, Region_t regb, Region_t result)
Compute the union of rega and regb and return result region.
Definition: TGWin32.cxx:7149
Bool_t SetSelectionOwner(Window_t, Atom_t &)
Assigns owner of Clipboard.
Definition: TGWin32.cxx:7671
void ChangeGC(GContext_t gc, GCValues_t *gval)
Change entries in an existing graphics context, gc, by values from gval.
Definition: TGWin32.cxx:5434
void SetWMSize(Window_t id, UInt_t w, UInt_t h)
Tells window manager the desired size of window "id".
Definition: TGWin32.cxx:6585
void ShapeCombineMask(Window_t id, Int_t x, Int_t y, Pixmap_t mask)
The Nonrectangular Window Shape Extension adds nonrectangular windows to the System.
Definition: TGWin32.cxx:7554
void RenderString(Int_t x, Int_t y, ETextMode mode)
Perform the string rendering in the pad.
Definition: TGWin32.cxx:1435
Int_t fDepth
Number of color planes.
Definition: TGWin32.h:122
void SetWMTransientHint(Window_t id, Window_t main_id)
Tell window manager that window is a transient window of gdk_parent_root.
Definition: TGWin32.cxx:6644
void SetRGB(Int_t cindex, Float_t r, Float_t g, Float_t b)
Set color intensities for given color index.
Definition: TGWin32.cxx:4083
Bool_t IsDNDAware(Window_t win, Atom_t *typelist)
Checks if Window win is DND aware, and knows any of the DND formats passed in argument.
Definition: TGWin32.cxx:7782
Float_t fTextMagnitude
Text Magnitude.
Definition: TGWin32.h:121
void GetFontProperties(FontStruct_t font, Int_t &max_ascent, Int_t &max_descent)
Return some font properties.
Definition: TGWin32.cxx:6676
void SetLineType(Int_t n, Int_t *dash)
Set line type.
Definition: TGWin32.cxx:3262
void DestroySubwindows(Window_t id)
Destroy all internal subwindows.
Definition: TGWin32.cxx:4671
void CopyArea(Drawable_t src, Drawable_t dest, GContext_t gc, Int_t src_x, Int_t src_y, UInt_t width, UInt_t height, Int_t dest_x, Int_t dest_y)
Copy a drawable (i.e.
Definition: TGWin32.cxx:6307
void NextEvent(Event_t &event)
Copies first pending event from event queue to Event_t structure and removes event from queue.
Definition: TGWin32.cxx:5854
void SetOpacity(Int_t percent)
Set opacity of a window.
Definition: TGWin32.cxx:3945
void Align(void)
Compute alignment variables.
Definition: TGWin32.cxx:1208
GdkImage * GetBackground(Int_t x, Int_t y, UInt_t w, UInt_t h)
Get the background of the current window in an XImage.
Definition: TGWin32.cxx:1387
Region_t CreateRegion()
Create a new empty region.
Definition: TGWin32.cxx:7109
void DrawLine(Int_t x1, Int_t y1, Int_t x2, Int_t y2)
Draw a line.
Definition: TGWin32.cxx:1771
Pixmap_t CreatePixmapFromData(unsigned char *bits, UInt_t width, UInt_t height)
create an image from RGB data.
Definition: TGWin32.cxx:7390
Atom_t InternAtom(const char *atom_name, Bool_t only_if_exist)
Return atom handle for atom_name.
Definition: TGWin32.cxx:5339
Bool_t fMarkerStyleModified
Definition: TGWin32.h:136
void DeleteProperty(Window_t, Atom_t &)
Deletes the specified property on the specified window.
Definition: TGWin32.cxx:7572
TGWin32()
Default constructor.
Definition: TGWin32.cxx:758
void ResizeWindow(Int_t wid)
Resize the current window if necessary.
Definition: TGWin32.cxx:2792
Int_t ResizePixmap(Int_t wid, UInt_t w, UInt_t h)
Resize a pixmap.
Definition: TGWin32.cxx:2744
void IconifyWindow(Window_t id)
Iconify the window.
Definition: TGWin32.cxx:4746
void SetColor(GdkGC *gc, Int_t ci)
Set the foreground color in GdkGC.
Definition: TGWin32.cxx:2958
void SetWMPosition(Window_t id, Int_t x, Int_t y)
Tells the window manager the desired position [x,y] of window "id".
Definition: TGWin32.cxx:6575
GdkColormap * fColormap
Default colormap, 0 if b/w.
Definition: TGWin32.h:112
void GetPlanes(Int_t &nplanes)
Get maximum number of planes.
Definition: TGWin32.cxx:2039
Int_t InitWindow(ULong_t window)
Open window and return window number.
Definition: TGWin32.cxx:2163
Region_t PolygonRegion(Point_t *points, Int_t np, Bool_t winding)
Create region for the polygon defined by the points array.
Definition: TGWin32.cxx:7139
Bool_t fFillStyleModified
Definition: TGWin32.h:133
void CloseWindow()
Delete current window.
Definition: TGWin32.cxx:1601
void GetWindowSize(Drawable_t id, Int_t &x, Int_t &y, UInt_t &w, UInt_t &h)
Return geometry of window (should be called GetGeometry but signature already used).
Definition: TGWin32.cxx:6966
void RaiseWindow(Window_t id)
Put window on top of window stack.
Definition: TGWin32.cxx:4681
void SetUserThreadId(ULong_t id)
Set user thread id.
Definition: TGWin32.cxx:7829
Int_t fBlueDiv
Blue value divider.
Definition: TGWin32.h:125
void FreeFontStruct(FontStruct_t fs)
Free font structure returned by GetFontStruct().
Definition: TGWin32.cxx:6710
void DeleteGC(GContext_t gc)
Explicitely delete a graphics context.
Definition: TGWin32.cxx:5520
void TranslateCoordinates(Window_t src, Window_t dest, Int_t src_x, Int_t src_y, Int_t &dest_x, Int_t &dest_y, Window_t &child)
TranslateCoordinates translates coordinates from the frame of reference of one window to another.
Definition: TGWin32.cxx:6935
void SetWindowBackgroundPixmap(Window_t id, Pixmap_t pxm)
Set pixmap as window background.
Definition: TGWin32.cxx:4784
GdkVisual * fVisual
Definition: TGWin32.h:111
Bool_t CheckEvent(Window_t id, EGEventType type, Event_t &ev)
Check if there is for window "id" an event of type "type".
Definition: TGWin32.cxx:5790
Int_t fGreenShift
Bits to left shift green.
Definition: TGWin32.h:127
void ImgPickPalette(GdkImage *image, Int_t &ncol, Int_t *&R, Int_t *&G, Int_t *&B)
Returns in R G B the ncol colors of the palette used by the image.
Definition: TGWin32.cxx:4312
void SetTextSize(Float_t textsize)
Set current text size.
Definition: TGWin32.cxx:1565
void SetTypeList(Window_t win, Atom_t prop, Atom_t *typelist)
Add the list of drag and drop types to the Window win.
Definition: TGWin32.cxx:7713
Window_t CreateWindow(Window_t parent, Int_t x, Int_t y, UInt_t w, UInt_t h, UInt_t border, Int_t depth, UInt_t clss, void *visual, SetWindowAttributes_t *attr, UInt_t wtype)
Return handle to newly created gdk window.
Definition: TGWin32.cxx:4794
void DrawSegments(Drawable_t id, GContext_t gc, Segment_t *seg, Int_t nseg)
Draws multiple line segments. Each line is specified by a pair of points.
Definition: TGWin32.cxx:6762
virtual void GetTextExtent(UInt_t &w, UInt_t &h, char *mess)
Return the size of a character string.
Definition: TGWin32.cxx:2067
Window_t GetDefaultRootWindow() const
Return handle to the default root window created when calling XOpenDisplay().
Definition: TGWin32.cxx:5351
void SetDoubleBufferOFF()
Turn double buffer mode off.
Definition: TGWin32.cxx:3068
Int_t AddWindow(ULong_t qwid, UInt_t w, UInt_t h)
Register a window created by Qt as a ROOT window (like InitWindow()).
Definition: TGWin32.cxx:7469
void SetLineStyle(Style_t linestyle)
Set line style.
Definition: TGWin32.cxx:3292
Int_t GetDoubleBuffer(Int_t wid)
Query the double buffer value for the window wid.
Definition: TGWin32.cxx:1978
void CloseDisplay()
close display (terminate server/gMainThread thread)
Definition: TGWin32.cxx:901
void ReparentWindow(Window_t id, Window_t pid, Int_t x, Int_t y)
Reparent window, make pid the new parent and position the window at position (x,y) in new parent.
Definition: TGWin32.cxx:4758
void MapEventMask(UInt_t &emask, UInt_t &xemask, Bool_t tox=kTRUE)
Map event mask to or from gdk.
Definition: TGWin32.cxx:4899
Float_t fCharacterUpX
Character Up vector along X.
Definition: TGWin32.h:119
void GrabPointer(Window_t id, UInt_t evmask, Window_t confine, Cursor_t cursor, Bool_t grab=kTRUE, Bool_t owner_events=kTRUE)
Establish an active pointer grab.
Definition: TGWin32.cxx:6472
Window_t FindRWindow(Window_t win, Window_t dragwin, Window_t input, int x, int y, int maxd)
Recursively search in the children of Window for a Window which is at location x, y and is DND aware,...
Definition: TGWin32.cxx:7725
void CopyGC(GContext_t org, GContext_t dest, Mask_t mask)
Copies graphics context from org to dest.
Definition: TGWin32.cxx:5500
void MapRaised(Window_t id)
Map window on screen and put on top of all windows.
Definition: TGWin32.cxx:4621
void CopyPixmap(Int_t wid, Int_t xpos, Int_t ypos)
Copy the pixmap wid at the position xpos, ypos in the current window.
Definition: TGWin32.cxx:1648
Bool_t fPenModified
line syle || width modified
Definition: TGWin32.h:135
void DeletePixmap(Pixmap_t pmap)
Explicitely delete pixmap resource.
Definition: TGWin32.cxx:5589
void SelectWindow(Int_t wid)
Select window to which subsequent output is directed.
Definition: TGWin32.cxx:2841
void QueryPointer(Int_t &ix, Int_t &iy)
Query pointer position.
Definition: TGWin32.cxx:2267
void SetFillColor(Color_t cindex)
Set color index for fill areas.
Definition: TGWin32.cxx:3136
void DrawText(Int_t x, Int_t y, Float_t angle, Float_t mgn, const char *text, ETextMode mode)
Draw text using TrueType fonts.
Definition: TGWin32.cxx:1358
Bool_t fHasTTFonts
True when TrueType fonts are used.
Definition: TGWin32.h:114
void DeleteFont(FontStruct_t fs)
Explicitely delete font structure obtained with LoadQueryFont().
Definition: TGWin32.cxx:5406
void MapEvent(Event_t &ev, GdkEvent &xev, Bool_t tox=kTRUE)
Map Event_t structure to gdk_event structure.
Definition: TGWin32.cxx:5929
void DrawPolyMarker(Int_t n, TPoint *xy)
Draw n markers with the current attributes at position x, y.
Definition: TGWin32.cxx:1855
void DrawPolyLine(Int_t n, TPoint *xy)
Draw a line through all points.
Definition: TGWin32.cxx:1799
void UpdateLineStyle()
Update line style.
Definition: TGWin32.cxx:3303
void SelectInput(Window_t id, UInt_t evmask)
Defines which input events the window is interested in.
Definition: TGWin32.cxx:6776
Int_t fRedShift
Bits to left shift red, -1 if no TrueColor visual.
Definition: TGWin32.h:126
Bool_t IsVisible(Int_t x, Int_t y, UInt_t w, UInt_t h)
Test if there is really something to render.
Definition: TGWin32.cxx:1413
void DestroyRegion(Region_t reg)
Destroy region.
Definition: TGWin32.cxx:7117
Int_t FindColor(ULong_t pixel, ULong_t *orgcolors, Int_t ncolors)
Returns index in orgcolors (and new_colors) for pixel.
Definition: TGWin32.cxx:4068
void UpdateFillStyle()
Set fill area style index.
Definition: TGWin32.cxx:3181
Pixmap_t CreateBitmap(Drawable_t id, const char *bitmap, UInt_t width, UInt_t height)
Create a bitmap (i.e. pixmap with depth 1) from the bitmap data.
Definition: TGWin32.cxx:5575
void SetDoubleBuffer(Int_t wid, Int_t mode)
Set the double buffer on/off on window wid.
Definition: TGWin32.cxx:3032
void UpdateWindow(Int_t mode)
Update display.
Definition: TGWin32.cxx:4211
void LowerWindow(Window_t id)
Lower window so it lays below all its siblings.
Definition: TGWin32.cxx:4700
void WMDeleteNotify(Window_t id)
Tell WM to send message when window is closed via WM.
Definition: TGWin32.cxx:6398
Window_t GetInputFocus()
Returns the window id of the window having the input focus.
Definition: TGWin32.cxx:6788
void DeleteImage(Drawable_t img)
Deallocates the memory associated with the image img.
Definition: TGWin32.cxx:7314
Bool_t fLineColorModified
Definition: TGWin32.h:134
Int_t WriteGIF(char *name)
Writes the current window into GIF file.
Definition: TGWin32.cxx:4374
void MakeOpaqueColors(Int_t percent, ULong_t *orgcolors, Int_t ncolors)
Get RGB values for orgcolors, add percent neutral to the RGB and allocate new_colors.
Definition: TGWin32.cxx:4008
Int_t GetDepth() const
Get maximum number of planes.
Definition: TGWin32.cxx:5329
void GetWindowAttributes(Window_t id, WindowAttributes_t &attr)
Get window attributes and return filled in attributes structure.
Definition: TGWin32.cxx:5280
void GrabButton(Window_t id, EMouseButton button, UInt_t modifier, UInt_t evmask, Window_t confine, Cursor_t cursor, Bool_t grab=kTRUE)
Establish passive grab on a certain mouse button.
Definition: TGWin32.cxx:6447
void GetGeometry(Int_t wid, Int_t &x, Int_t &y, UInt_t &w, UInt_t &h)
Return position and size of window wid.
Definition: TGWin32.cxx:1998
void SetDNDAware(Window_t win, Atom_t *typelist)
Add XdndAware property and the list of drag and drop types to the Window win.
Definition: TGWin32.cxx:7801
Int_t fScreenNumber
Screen number.
Definition: TGWin32.h:113
void Warp(Int_t ix, Int_t iy, Window_t id=0)
Set pointer position.
Definition: TGWin32.cxx:4227
Drawable_t CreateImage(UInt_t width, UInt_t height)
Allocates the memory needed for an drawable.
Definition: TGWin32.cxx:7253
Cursor_t CreateCursor(ECursor cursor)
Create cursor handle (just return cursor from cursor pool fCursors).
Definition: TGWin32.cxx:5528
void MapGCValues(GCValues_t &gval, ULong_t &xmask, GdkGCValues &xgval, Bool_t tox=kTRUE)
Map a GCValues_t to a XCGValues structure if tox is true.
Definition: TGWin32.cxx:5011
void DrawRectangle(Drawable_t id, GContext_t gc, Int_t x, Int_t y, UInt_t w, UInt_t h)
Draw a rectangle outline.
Definition: TGWin32.cxx:6751
Int_t AddPixmap(ULong_t pix, UInt_t w, UInt_t h)
register pixmap created by TGWin32GLManager
Definition: TGWin32.cxx:7426
void SetMarkerType(Int_t type, Int_t n, GdkPoint *xy)
Set marker type.
Definition: TGWin32.cxx:3395
Int_t OpenPixmap(UInt_t w, UInt_t h)
Open a new pixmap.
Definition: TGWin32.cxx:2104
void SetDoubleBufferON()
Turn double buffer mode on.
Definition: TGWin32.cxx:3078
void ClearArea(Window_t id, Int_t x, Int_t y, UInt_t w, UInt_t h)
Clear a window area to the bakcground color.
Definition: TGWin32.cxx:6388
void SetKeyAutoRepeat(Bool_t on=kTRUE)
Turn key auto repeat on or off.
Definition: TGWin32.cxx:6413
void FillRectangle(Drawable_t id, GContext_t gc, Int_t x, Int_t y, UInt_t w, UInt_t h)
Draw a filled rectangle. Filling is done according to the gc.
Definition: TGWin32.cxx:6740
void SetFillStyle(Style_t style)
Set fill area style.
Definition: TGWin32.cxx:3170
static void Unlock()
Definition: TGWin32.cxx:955
void SetMWMHints(Window_t id, UInt_t value, UInt_t funcs, UInt_t input)
Set decoration style for MWM-compatible wm (mwm, ncdwm, fvwm?).
Definition: TGWin32.cxx:6563
TObject * fRefreshTimer
TGWin32RefreshTimer for GUI thread message handler.
Definition: TGWin32.h:130
void SetCursor(Int_t win, ECursor cursor)
Set the cursor.
Definition: TGWin32.cxx:3000
char ** ListFonts(const char *fontname, Int_t max, Int_t &count)
Return list of font names matching "fontname".
Definition: TGWin32.cxx:7221
void QueryColors(GdkColormap *cmap, GdkColor *colors, Int_t ncolors)
Returns the current RGB value for the pixel in the XColor structure.
Definition: TGWin32.cxx:1181
void GrabKey(Window_t id, Int_t keycode, UInt_t modifier, Bool_t grab=kTRUE)
Establish passive grab on a certain key.
Definition: TGWin32.cxx:6428
Window_t GetPrimarySelectionOwner()
Returns the window id of the current owner of the primary selection.
Definition: TGWin32.cxx:6809
void MapColorStruct(ColorStruct_t *color, GdkColor &xcolor)
Map a ColorStruct_t to a XColor structure.
Definition: TGWin32.cxx:5707
void SetWindowName(Window_t id, char *name)
Set window name.
Definition: TGWin32.cxx:6492
FontH_t GetFontHandle(FontStruct_t fs)
Return handle to font described by font structure.
Definition: TGWin32.cxx:5395
void ConvertPrimarySelection(Window_t id, Atom_t clipboard, Time_t when)
XConvertSelection() causes a SelectionRequest event to be sent to the current primary selection owner...
Definition: TGWin32.cxx:6836
void SetTextColor(Color_t cindex)
Set color index for text.
Definition: TGWin32.cxx:4180
void SetWindowBackground(Window_t id, ULong_t color)
Set the window background color.
Definition: TGWin32.cxx:4768
FT_Vector fAlign
alignment vector
Definition: TGWin32.h:73
Bool_t IsCmdThread() const
returns kTRUE if we are inside cmd/server thread
Definition: TGWin32.cxx:888
Int_t fTextAlignH
Text Alignment Horizontal.
Definition: TGWin32.h:116
static void Lock()
Definition: TGWin32.cxx:947
Handle_t fXEvent
Current native (GDK) event.
Definition: TGWin32.h:129
void RemovePixmap(GdkDrawable *pix)
Remove the pixmap pix.
Definition: TGWin32.cxx:2281
void GetGCValues(GContext_t gc, GCValues_t &gval)
Get current values from graphics context gc.
Definition: TGWin32.cxx:6688
Bool_t fFillColorModified
Definition: TGWin32.h:132
Int_t fRedDiv
Red value divider, -1 if no TrueColor visual.
Definition: TGWin32.h:123
void SetIconName(Window_t id, char *name)
Set window icon name.
Definition: TGWin32.cxx:6502
Bool_t fMarkerColorModified
Definition: TGWin32.h:137
void PutImage(Int_t offset, Int_t itran, Int_t x0, Int_t y0, Int_t nx, Int_t ny, Int_t xmin, Int_t ymin, Int_t xmax, Int_t ymax, UChar_t *image, Drawable_t id)
Draw image.
Definition: TGWin32.cxx:4437
void DeletePictureData(void *data)
Delete picture data created by the function ReadPictureDataFromFile.
Definition: TGWin32.cxx:5679
GdkGC * GetGC(Int_t which) const
Return desired Graphics Context ("which" maps directly on gGCList[]).
Definition: TGWin32.cxx:1965
void ConvertSelection(Window_t, Atom_t &, Atom_t &, Atom_t &, Time_t &)
Get Clipboard data.
Definition: TGWin32.cxx:7647
GContext_t CreateGC(Drawable_t id, GCValues_t *gval)
Create a graphics context using the values set in gval (but only for those entries that are in the ma...
Definition: TGWin32.cxx:5415
void SetLineColor(Color_t cindex)
Set color index for lines.
Definition: TGWin32.cxx:3234
XColor_t & GetColor(Int_t cid)
Return reference to internal color structure associated to color index cid.
Definition: TGWin32.cxx:1943
Int_t OpenDisplay(const char *dpyName=0)
Open the display. Return -1 if the opening fails, 0 when ok.
Definition: TGWin32.cxx:980
void UpdateMarkerStyle()
Definition: TGWin32.cxx:3419
void SetDashes(GContext_t gc, Int_t offset, const char *dash_list, Int_t n)
Specify a dash pattertn.
Definition: TGWin32.cxx:5689
void FreeFontNames(char **fontlist)
Frees the specified the array of strings "fontlist".
Definition: TGWin32.cxx:7245
Bool_t ParseColor(Colormap_t cmap, const char *cname, ColorStruct_t &color)
Parse string cname containing color name, like "green" or "#00FF00".
Definition: TGWin32.cxx:5722
void SetDrawMode(EDrawMode mode)
Set the drawing mode.
Definition: TGWin32.cxx:3107
Int_t fTextAlign
Text alignment (set in SetTextAlign)
Definition: TGWin32.h:118
void SetMarkerColor(Color_t cindex)
Set color index for markers.
Definition: TGWin32.cxx:3353
Bool_t Init(void *display=0)
Initialize Win32 system. Returns kFALSE in case of failure.
Definition: TGWin32.cxx:963
unsigned char * GetColorBits(Drawable_t wid, Int_t x, Int_t y, UInt_t width, UInt_t height)
Gets DIB bits x, y, width, height - position of bitmap returns a pointer on bitmap bits array in form...
Definition: TGWin32.cxx:7329
FontStruct_t GetFontStruct(FontH_t fh)
Retrieve associated font structure once we have the font handle.
Definition: TGWin32.cxx:6702
void GetCharacterUp(Float_t &chupx, Float_t &chupy)
Return character up vector.
Definition: TGWin32.cxx:1933
void SetLineWidth(Width_t width)
Set line width.
Definition: TGWin32.cxx:3339
void RescaleWindow(Int_t wid, UInt_t w, UInt_t h)
Rescale the window wid.
Definition: TGWin32.cxx:2703
void ChangeProperty(Window_t id, Atom_t property, Atom_t type, UChar_t *data, Int_t len)
This function alters the property for the specified window and causes the X server to generate a Prop...
Definition: TGWin32.cxx:6365
void SetMarkerStyle(Style_t markerstyle)
Set marker style.
Definition: TGWin32.cxx:3409
Int_t RequestString(Int_t x, Int_t y, char *text)
Request a string.
Definition: TGWin32.cxx:2467
void SetWMState(Window_t id, EInitialState state)
Set the initial state of the window. Either kNormalState or kIconicState.
Definition: TGWin32.cxx:6621
void MapSubwindows(Window_t id)
Maps all subwindows for the specified window "id" in top-to-bottom stacking order.
Definition: TGWin32.cxx:4610
void GetRegionBox(Region_t reg, Rectangle_t *)
Return smallest enclosing rectangle.
Definition: TGWin32.cxx:7208
Int_t fMaxNumberOfWindows
Maximum number of windows.
Definition: TGWin32.h:82
void RemoveWindow(ULong_t qwid)
Remove a window created by Qt (like CloseWindow1()).
Definition: TGWin32.cxx:7517
Bool_t ReadPictureDataFromFile(const char *filename, char ***ret_data)
Read picture data from file and store in ret_data.
Definition: TGWin32.cxx:5659
Pixmap_t CreatePixmap(Drawable_t id, UInt_t w, UInt_t h)
Creates a pixmap of the width and height you specified and returns a pixmap ID that identifies it.
Definition: TGWin32.cxx:5537
void MoveResizeWindow(Window_t id, Int_t x, Int_t y, UInt_t w, UInt_t h)
Move and resize a window.
Definition: TGWin32.cxx:4722
UInt_t ScreenWidthMM() const
Returns the width of the screen in millimeters.
Definition: TGWin32.cxx:7562
void MapKeySym(UInt_t &keysym, UInt_t &xkeysym, Bool_t tox=kTRUE)
Map to and from X key symbols.
Definition: TGWin32.cxx:6863
EAlign
Definition: TGWin32.h:70
@ kTLeft
Definition: TGWin32.h:70
@ kMRight
Definition: TGWin32.h:70
@ kMLeft
Definition: TGWin32.h:70
@ kNone
Definition: TGWin32.h:70
@ kTCenter
Definition: TGWin32.h:70
@ kTRight
Definition: TGWin32.h:70
@ kBCenter
Definition: TGWin32.h:71
@ kMCenter
Definition: TGWin32.h:70
@ kBRight
Definition: TGWin32.h:71
void ChangeWindowAttributes(Window_t id, SetWindowAttributes_t *attr)
Change window attributes.
Definition: TGWin32.cxx:6320
Bool_t AllocColor(GdkColormap *cmap, GdkColor *color)
Allocate color in colormap.
Definition: TGWin32.cxx:1164
void SetTextAlign(Short_t talign=11)
Set text alignment.
Definition: TGWin32.cxx:4120
Int_t RequestLocator(Int_t mode, Int_t ctyp, Int_t &x, Int_t &y)
Request Locator position.
Definition: TGWin32.cxx:2312
Int_t GetProperty(Window_t, Atom_t, Long_t, Long_t, Bool_t, Atom_t, Atom_t *, Int_t *, ULong_t *, ULong_t *, unsigned char **)
Returns the actual type of the property, the actual format of the property, and a pointer to the data...
Definition: TGWin32.cxx:7586
Int_t KeysymToKeycode(UInt_t keysym)
Convert a keysym to the appropriate keycode.
Definition: TGWin32.cxx:6730
void ClosePixmap()
Delete current pixmap.
Definition: TGWin32.cxx:1593
void UpdateFillColor()
Definition: TGWin32.cxx:3151
Window_t GetCurrentWindow() const
Return current window pointer. Protected method used by TGWin32TTF.
Definition: TGWin32.cxx:1956
Bool_t EmptyRegion(Region_t reg)
Return true if the region is empty.
Definition: TGWin32.cxx:7184
void XorRegion(Region_t rega, Region_t regb, Region_t result)
Calculate the difference between the union and intersection of two regions.
Definition: TGWin32.cxx:7176
void Bell(Int_t percent)
Sets the sound bell. Percent is loudness from -100% to 100%.
Definition: TGWin32.cxx:6297
void SetPrimarySelectionOwner(Window_t id)
Makes the window id the current owner of the primary selection.
Definition: TGWin32.cxx:6818
Bool_t PointInRegion(Int_t x, Int_t y, Region_t reg)
Returns true if the point x,y is in the region.
Definition: TGWin32.cxx:7192
Int_t fBlueShift
Bits to left shift blue.
Definition: TGWin32.h:128
GdkCursor * fCursors[kNumCursors]
List of cursors.
Definition: TGWin32.h:85
FontStruct_t LoadQueryFont(const char *font_name)
Load font and query font.
Definition: TGWin32.cxx:5371
void UpdateLineColor()
Definition: TGWin32.cxx:3245
void ChangeActivePointerGrab(Window_t, UInt_t, Cursor_t)
Changes the active cursor of the specified window.
Definition: TGWin32.cxx:7634
void PutPixel(Drawable_t id, Int_t x, Int_t y, ULong_t pixel)
Overwrites the pixel in the image with the specified pixel value.
Definition: TGWin32.cxx:7271
Window_t GetParent(Window_t id) const
Return the parent of the window.
Definition: TGWin32.cxx:5359
void ChangeProperties(Window_t id, Atom_t property, Atom_t type, Int_t format, UChar_t *data, Int_t len)
Put data into Clipboard.
Definition: TGWin32.cxx:7688
Bool_t CreatePictureFromData(Drawable_t id, char **data, Pixmap_t &pict, Pixmap_t &pict_mask, PictureAttributes_t &attr)
Create a pixture pixmap from data.
Definition: TGWin32.cxx:5633
void FreeColor(Colormap_t cmap, ULong_t pixel)
Free color cell with specified pixel value.
Definition: TGWin32.cxx:5780
Window_t GetWindowID(Int_t wid)
Return the X11 window identifier.
Definition: TGWin32.cxx:2078
virtual ~TGWin32()
destructor.
Definition: TGWin32.cxx:818
Bool_t GUIThreadMessageFunc(MSG *msg)
Message processing function for the GUI thread.
Definition: TGWin32.cxx:847
Int_t fTextAlignV
Text Alignment Vertical.
Definition: TGWin32.h:117
Bool_t fUseSysPointers
True when using system mouse pointers.
Definition: TGWin32.h:115
XWindow_t * fWindows
List of windows.
Definition: TGWin32.h:83
void GetImageSize(Drawable_t id, UInt_t &width, UInt_t &height)
Returns the width and height of the image id.
Definition: TGWin32.cxx:7262
Int_t fGreenDiv
Green value divider.
Definition: TGWin32.h:124
void Update(Int_t mode=0)
Flush (mode = 0, default) or synchronize (mode = 1) X output buffer.
Definition: TGWin32.cxx:7101
void WritePixmap(Int_t wid, UInt_t w, UInt_t h, char *pxname)
Write the pixmap wid in the bitmap file pxname.
Definition: TGWin32.cxx:4251
void SetInput(Int_t inp)
Set input on or off.
Definition: TGWin32.cxx:3226
ULong_t GetPixel(Color_t cindex)
Return pixel value associated to specified ROOT color number.
Definition: TGWin32.cxx:2946
Display_t GetDisplay() const
Returns handle to display (might be useful in some cases where direct X11 manipulation outside of TVi...
Definition: TGWin32.cxx:5321
void GetRGB(Int_t index, Float_t &r, Float_t &g, Float_t &b)
Get rgb values for color "index".
Definition: TGWin32.cxx:2047
void Sync(Int_t mode)
Set synchronisation on or off.
Definition: TGWin32.cxx:4198
TExMap * fColors
Hash list of colors.
Definition: TGWin32.h:84
void UnionRectWithRegion(Rectangle_t *rect, Region_t src, Region_t dest)
Union of rectangle with a region.
Definition: TGWin32.cxx:7125
Bool_t CreatePictureFromFile(Drawable_t id, const char *filename, Pixmap_t &pict, Pixmap_t &pict_mask, PictureAttributes_t &attr)
Create a picture pixmap from data on file.
Definition: TGWin32.cxx:5599
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
An array of TObjects.
Definition: TObjArray.h:37
Int_t GetEntries() const
Return the number of objects in array (i.e.
Definition: TObjArray.cxx:522
TObject * At(Int_t idx) const
Definition: TObjArray.h:165
Collectable string class.
Definition: TObjString.h:28
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition: TObject.cxx:866
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
Definition: TPoint.h:31
SCoord_t fY
Definition: TPoint.h:36
SCoord_t fX
Definition: TPoint.h:35
static void * Alloc(size_t size)
Allocate a block of memory, that later can be resized using TStorage::ReAlloc().
Definition: TStorage.cxx:152
static void * ReAlloc(void *vp, size_t size)
Reallocate (i.e.
Definition: TStorage.cxx:183
static void Dealloc(void *ptr)
De-allocate block of memory, that was allocated via TStorage::Alloc().
Definition: TStorage.cxx:170
Basic string class.
Definition: TString.h:131
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition: TString.cxx:2172
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:619
const char * GetLineStyleString(Int_t i=1) const
Return line style string (used by PostScript).
Definition: TStyle.cxx:970
void Beep(Int_t freq=-1, Int_t duration=-1, Bool_t setDefault=kFALSE)
Beep for duration milliseconds with a tone of frequency freq.
Definition: TSystem.cxx:333
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition: TSystem.cxx:480
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition: TSystem.cxx:941
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition: TSystem.cxx:425
virtual TTimer * RemoveTimer(TTimer *t)
Remove timer from list of system timers.
Definition: TSystem.cxx:490
TTF helper class containing glyphs description.
Definition: TTF.h:65
FT_Glyph fImage
glyph image
Definition: TTF.h:69
static Bool_t IsInitialized()
Definition: TTF.cxx:605
static void PrepareString(const char *string)
Put the characters in "string" in the "glyphs" array.
Definition: TTF.cxx:247
static void Init()
Initialise the TrueType fonts interface.
Definition: TTF.cxx:65
static void LayoutGlyphs()
Compute the glyphs positions, fgAscent and fgWidth (needed for alignment).
Definition: TTF.cxx:181
static void SetSmoothing(Bool_t state)
Set smoothing (anti-aliasing) flag.
Definition: TTF.cxx:362
static void SetRotationMatrix(Float_t angle)
Set the rotation matrix used to rotate the font outlines.
Definition: TTF.cxx:339
static void SetTextFont(Font_t fontnumber)
Set specified font.
Definition: TTF.cxx:488
static Int_t GetAscent()
Definition: TTF.cxx:619
static void GetTextExtent(UInt_t &w, UInt_t &h, char *text)
Get width (w) and height (h) when text is horizontal.
Definition: TTF.cxx:132
static TTGlyph * GetGlyphs()
Definition: TTF.cxx:647
static Int_t GetNumGlyphs()
Definition: TTF.cxx:626
static Int_t GetWidth()
Definition: TTF.cxx:612
static const FT_BBox & GetBox()
Definition: TTF.cxx:640
static Bool_t GetSmoothing()
Definition: TTF.cxx:598
static void SetTextSize(Float_t textsize)
Set current text size.
Definition: TTF.cxx:559
static FT_Matrix * GetRotMatrix()
Definition: TTF.cxx:633
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
void Reset()
Reset the timer.
Definition: TTimer.cxx:157
virtual Bool_t Notify()
Notify when timer times out.
Definition: TTimer.cxx:143
TTimer(const TTimer &)
Semi-Abstract base class defining a generic interface to the underlying, low level,...
Definition: TVirtualX.h:53
EDrawMode fDrawMode
Definition: TVirtualX.h:62
TPaveText * pt
TText * text
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
const Int_t n
Definition: legend1.C:16
#define G(x, y, z)
static double B[]
static constexpr double s
static constexpr double L
Double_t ACos(Double_t)
Definition: TMath.h:656
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
Double_t Sqrt(Double_t x)
Definition: TMath.h:679
Short_t Min(Short_t a, Short_t b)
Definition: TMathBase.h:180
Short_t Abs(Short_t d)
Definition: TMathBase.h:120
Definition: file.py:1
ULong_t fPixel
Definition: GuiTypes.h:310
UShort_t fRed
Definition: GuiTypes.h:311
UShort_t fGreen
Definition: GuiTypes.h:312
UShort_t fBlue
Definition: GuiTypes.h:313
EGEventType fType
Definition: GuiTypes.h:174
Int_t fY
Definition: GuiTypes.h:177
Int_t fXRoot
Definition: GuiTypes.h:178
Bool_t fSendEvent
Definition: GuiTypes.h:183
Handle_t fHandle
Definition: GuiTypes.h:184
Int_t fFormat
Definition: GuiTypes.h:185
UInt_t fWidth
Definition: GuiTypes.h:181
UInt_t fHeight
Definition: GuiTypes.h:181
Int_t fCount
Definition: GuiTypes.h:182
Window_t fWindow
Definition: GuiTypes.h:175
UInt_t fState
Definition: GuiTypes.h:180
Int_t fYRoot
Definition: GuiTypes.h:178
Int_t fX
Definition: GuiTypes.h:177
Long_t fUser[5]
Definition: GuiTypes.h:186
Time_t fTime
Definition: GuiTypes.h:176
UInt_t fCode
Definition: GuiTypes.h:179
ULong_t fBackground
Definition: GuiTypes.h:227
Pixmap_t fClipMask
Definition: GuiTypes.h:246
Int_t fClipYOrigin
Definition: GuiTypes.h:245
Int_t fClipXOrigin
Definition: GuiTypes.h:244
Int_t fLineWidth
Definition: GuiTypes.h:228
Pixmap_t fStipple
Definition: GuiTypes.h:238
Mask_t fMask
Definition: GuiTypes.h:250
Int_t fLineStyle
Definition: GuiTypes.h:229
Pixmap_t fTile
Definition: GuiTypes.h:237
Bool_t fGraphicsExposures
Definition: GuiTypes.h:243
Int_t fJoinStyle
Definition: GuiTypes.h:232
ULong_t fForeground
Definition: GuiTypes.h:226
Int_t fFillStyle
Definition: GuiTypes.h:233
FontH_t fFont
Definition: GuiTypes.h:241
Int_t fTsXOrigin
Definition: GuiTypes.h:239
EGraphicsFunction fFunction
Definition: GuiTypes.h:224
Int_t fCapStyle
Definition: GuiTypes.h:230
Int_t fTsYOrigin
Definition: GuiTypes.h:240
Int_t fSubwindowMode
Definition: GuiTypes.h:242
Short_t fX
Definition: GuiTypes.h:361
UShort_t fHeight
Definition: GuiTypes.h:362
Short_t fY
Definition: GuiTypes.h:361
UShort_t fWidth
Definition: GuiTypes.h:362
Pixmap_t fBackgroundPixmap
Definition: GuiTypes.h:93
Bool_t fOverrideRedirect
Definition: GuiTypes.h:106
ULong_t fBackgroundPixel
Definition: GuiTypes.h:94
Colormap_t fColormap
Definition: GuiTypes.h:107
Window_t fRoot
Definition: GuiTypes.h:119
Long_t fYourEventMask
Definition: GuiTypes.h:131
Bool_t fMapInstalled
Definition: GuiTypes.h:128
Colormap_t fColormap
Definition: GuiTypes.h:127
Bool_t fOverrideRedirect
Definition: GuiTypes.h:133
Description of a X11 color.
Definition: TGWin32.h:59
Bool_t fDefined
true if pixel value is defined
Definition: TGWin32.h:61
GdkColor color
Definition: TGWin32.h:60
TCanvas * style()
Definition: style.C:1
auto * m
Definition: textangle.C:8
auto * l
Definition: textangle.C:4
auto * a
Definition: textangle.C:12
#define dest(otri, vertexptr)
Definition: triangle.c:1040
#define org(otri, vertexptr)
Definition: triangle.c:1037
#define VOID
Definition: triangle.h:286
#define XA_ATOM
Definition: xatom.h:13
#define XA_WM_CLASS
Definition: xatom.h:76
#define XA_STRING
Definition: xatom.h:40
unsigned long Atom
Definition: xatom.h:9