36#include "gdk/gdkkeysyms.h"
65#define XDND_PROTOCOL_VERSION 5
67#define IDC_HAND MAKEINTRESOURCE(32649)
120 GdkDrawable *drawing;
141GdkAtom gClipboardAtom = GDK_NONE;
142static XWindow_t *
gCws;
143static XWindow_t *
gTws;
178static const char *
gTextFont =
"arial.ttf";
206 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK
207 | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK
208 | GDK_KEY_RELEASE_MASK;
210 GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK | GDK_ENTER_NOTIFY_MASK |
211 GDK_LEAVE_NOTIFY_MASK;
217 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
218 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
219 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
223static bool gdk_initialized =
false;
227struct MWMHintsProperty_t {
246struct KeySymbolMap_t {
251static const char *keyCodeToString[] = {
305static KeySymbolMap_t
gKeyMap[] = {
308#ifndef GDK_ISO_Left_Tab
362 int n =
event->fUser[1];
364 for (i = 0; i <
n; i++) {
365 buf[i] =
event->fUser[2 + i];
371 if (event->
fCode <= 0x20) {
372 strncpy(buf, keyCodeToString[event->
fCode], buflen - 1);
404 conv.i[0] = (
Int_t) i1;
405 conv.i[1] = (
Int_t) i2;
412static BOOL
CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam)
414 ::ShowWindow(hwndChild, SW_SHOWNORMAL);
415 GdkWindow *child = gdk_window_lookup(hwndChild);
417 ((GdkWindowPrivate *) child)->mapped =
TRUE;
423static void _ChangeProperty(HWND w,
char *np,
char *dp,
int n,
Atom_t type)
428 hMem = ::GetProp(w, np);
432 hMem = ::GlobalAlloc(GHND,
n +
sizeof(
Atom_t));
433 p = (
char *) ::GlobalLock(hMem);
435 memcpy(p +
sizeof(
Atom_t), dp,
n);
436 ::GlobalUnlock(hMem);
437 ::SetProp(w, np, hMem);
445 int format,
int mode,
const unsigned char *data,
453 if (mode == GDK_PROP_MODE_REPLACE || mode == GDK_PROP_MODE_PREPEND) {
454 len = (int) ::GlobalGetAtomName(property, buffer,
sizeof(buffer));
455 if ((atomName = (
char *)
malloc(len + 1)) == NULL) {
458 strcpy(atomName, buffer);
460 sprintf(propName,
"#0x%0.4x", (
unsigned) atomName);
461 _ChangeProperty(w, propName, (
char *) data, nelements,
type);
469static int _GetWindowProperty(GdkWindow *
id,
Atom_t property,
Long_t long_offset,
471 Atom_t * actual_type_return,
477 char *data, *destPtr;
482 w = (HWND) GDK_DRAWABLE_XID(
id);
484 if (::IsClipboardFormatAvailable(CF_TEXT) && ::OpenClipboard(NULL)) {
485 handle = ::GetClipboardData(CF_TEXT);
486 if (handle != NULL) {
487 data = (
char *) ::GlobalLock(handle);
488 *nitems_return = strlen(data);
490 destPtr = (
char *) *prop_return;
491 while (*data !=
'\0') {
499 ::GlobalUnlock(handle);
501 *bytes_after_return = 0;
507 ::RemoveProp(w, propName);
519 GdkImage *image = (GdkImage *)
id;
522 if (image->depth == 1) {
523 pixel = (((
char *) image->mem)[
y * image->bpl + (
x >> 3)] & (1 << (7 - (
x & 0x7)))) != 0;
526 switch (image->bpp) {
532 pixel = pixelp[0] | (pixelp[1] << 8);
535 pixel = pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16);
538 pixel = pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16);
548static void CollectImageColors(
ULong_t pixel,
ULong_t * &orgcolors,
551 if (maxcolors == 0) {
557 for (
int i = 0; i < ncolors; i++) {
558 if (pixel == orgcolors[i])
return;
560 if (ncolors >= maxcolors) {
568 orgcolors[ncolors++] = pixel;
574static char *EventMask2String(
UInt_t evmask)
576 static char bfr[500];
581 if (evmask & k##x##Mask) \
582 p += sprintf (p, "%s" #x, (p > bfr ? " " : ""))
600class TGWin32MainThread {
605 static LPCRITICAL_SECTION fCritSec;
606 static LPCRITICAL_SECTION fMessageMutex;
609 ~TGWin32MainThread();
610 static void LockMSG();
611 static void UnlockMSG();
614TGWin32MainThread *gMainThread = 0;
615LPCRITICAL_SECTION TGWin32MainThread::fCritSec = 0;
616LPCRITICAL_SECTION TGWin32MainThread::fMessageMutex = 0;
622TGWin32MainThread::~TGWin32MainThread()
625 ::LeaveCriticalSection(fCritSec);
626 ::DeleteCriticalSection(fCritSec);
632 ::LeaveCriticalSection(fMessageMutex);
633 ::DeleteCriticalSection(fMessageMutex);
634 delete fMessageMutex;
639 ::PostThreadMessage(fId, WM_QUIT, 0, 0);
640 ::CloseHandle(fHandle);
648void TGWin32MainThread::LockMSG()
650 if (fMessageMutex) ::EnterCriticalSection(fMessageMutex);
656void TGWin32MainThread::UnlockMSG()
658 if (fMessageMutex) ::LeaveCriticalSection(fMessageMutex);
662class TGWin32RefreshTimer :
public TTimer {
672 while (::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE)) {
673 ::PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE);
686static DWORD WINAPI MessageProcessingLoop(void *p)
690 Bool_t endLoop = kFALSE;
691 TGWin32RefreshTimer *refersh = 0;
693 // force to create message queue
694 ::PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
696 // periodically we refresh windows
697 // Don't create refresh timer if the application has been created inside PVSS
699 TString arg = gSystem->BaseName(gApplication->Argv(0));
700 if (!arg.Contains("PVSS"))
701 refersh = new TGWin32RefreshTimer();
705 erret = ::GetMessage(&msg, NULL, NULL, NULL);
706 if (erret <= 0) endLoop = kTRUE;
707 endLoop = MessageProcessingFunc(&msg);
710 TGWin32::Instance()->CloseDisplay();
716 erret = ::GetLastError();
717 Error("MsgLoop", "Error in GetMessage");
726Bool_t GUIThreadMessageWrapper(MSG* msg)
738TGWin32MainThread::TGWin32MainThread()
740 fCritSec =
new CRITICAL_SECTION;
741 ::InitializeCriticalSection(fCritSec);
742 fMessageMutex =
new CRITICAL_SECTION;
743 ::InitializeCriticalSection(fMessageMutex);
803 if (!
gROOT->IsBatch() && !gMainThread) {
804 gMainThread =
new TGWin32MainThread();
822 while (it.
Next(key, value)) {
846 static Int_t m_timer = 0;
848 if ( (msg->message == WM_NCLBUTTONDOWN) ) {
850 m_timer = SetTimer(NULL, 1, 20, (TIMERPROC)
MyTimerProc);
852 else if (msg->message == WM_NCMOUSELEAVE ) {
854 KillTimer(NULL, m_timer);
873 TGWin32MainThread::LockMSG();
874 TranslateMessage(msg);
875 DispatchMessage(msg);
876 TGWin32MainThread::UnlockMSG();
886#ifdef OLD_THREAD_IMPLEMENTATION
908 TGWin32MainThread *delThread = gMainThread;
938 if (gMainThread && gMainThread->fCritSec) ::EnterCriticalSection(gMainThread->fCritSec);
946 if (gMainThread && gMainThread->fCritSec) ::LeaveCriticalSection(gMainThread->fCritSec);
954 if (!gdk_initialized) {
955 if (!gdk_init_check(NULL, NULL))
return kFALSE;
956 gdk_initialized =
true;
959 if (!gClipboardAtom) {
960 gClipboardAtom = gdk_atom_intern(
"CLIPBOARD",
kFALSE);
971 GdkPixmap *pixmp1, *pixmp2;
977 if (!
Init((
void*)dpyName)) {
987 fore.red = fore.green = fore.blue = 0;
988 back.red = back.green = back.blue = 0;
989 color.red = color.green = color.blue = 0;
992 fVisual = gdk_visual_get_best();
994 fDepth = gdk_visual_get_best_depth();
1003 for (i = 0; i <
kMAXGC; i++) {
1004 gGClist[i] = gdk_gc_new(GDK_ROOT_PARENT());
1017 gdk_gc_get_values(
gGCtext, &gcvals);
1018 gdk_gc_set_foreground(
gGCinvt, &gcvals.background);
1019 gdk_gc_set_background(
gGCinvt, &gcvals.foreground);
1023 gdk_color_black(
fColormap, &echov.foreground);
1024 gdk_color_white(
fColormap, &echov.background);
1025 echov.function = GDK_INVERT;
1026 echov.subwindow_mode = GDK_CLIP_BY_CHILDREN;
1028 gdk_gc_new_with_values((GdkWindow *) GDK_ROOT_PARENT(), &echov,
1029 (GdkGCValuesMask) (GDK_GC_FOREGROUND |
1034 pixmp1 = gdk_bitmap_create_from_data(GDK_ROOT_PARENT(),
1037 pixmp2 = gdk_bitmap_create_from_data(GDK_ROOT_PARENT(),
1040 gNullCursor = gdk_cursor_new_from_pixmap((GdkDrawable *)pixmp1, (GdkDrawable *)pixmp2,
1041 &fore, &back, 0, 0);
1090 if ( gdk_visual_get_best_type() == GDK_VISUAL_TRUE_COLOR) {
1096 if ((
fVisual->blue_mask >> i) == 1) {
1105 if ((
fVisual->green_mask >> i) == 1) {
1114 if ((
fVisual->red_mask >> i) == 1) {
1122 SetTitle(
"ROOT interface to Win32 with TrueType fonts");
1156 if ( gdk_color_alloc((GdkColormap *)cmap, (GdkColor *)color) )
return kTRUE;
1175 GdkColorContext *cc = gdk_color_context_new(gdk_visual_get_system(), cmap);
1176 gdk_color_context_query_colors(cc, color, ncolors);
1177 gdk_color_context_free(cc);
1179 for (
Int_t i = 0; i < ncolors; i++) {
1234 static GdkColor col[5];
1235 GdkColor *bcol = 0, *bc;
1243 const Int_t maxdots = 50000;
1245 dots =
Int_t(source->width * source->rows);
1246 dots = dots > maxdots ? maxdots : dots;
1247 bcol =
new GdkColor[dots];
1252 for (
y = 0;
y < (int) source->rows;
y++) {
1253 for (
x = 0;
x < (int) source->width;
x++, bc++) {
1254 bc->pixel = GetPixelImage((
Drawable_t)xim, bx +
x, by +
y);
1255 if (++dotcnt >= maxdots)
break;
1262 for (
y = 0;
y < (int) source->rows;
y++) {
1263 for (
x = 0;
x < (int) source->width;
x++, bc++) {
1267 if (++dotcnt >= maxdots)
break;
1276 if (bc->red ==
r && bc->green ==
g && bc->blue ==
b) {
1290 if (fore != col[4].pixel || back != col[0].pixel) {
1291 col[4].pixel = fore;
1293 col[3].pixel = back;
1301 for (
x = 3;
x > 0;
x--) {
1302 col[
x].red = (col[4].red *
x + col[0].red *(4-
x)) /4;
1303 col[
x].green = (col[4].green*
x + col[0].green*(4-
x)) /4;
1304 col[
x].blue = (col[4].blue *
x + col[0].blue *(4-
x)) /4;
1306 Warning(
"DrawImage",
"cannot allocate smoothing color");
1307 col[
x].pixel = col[
x+1].pixel;
1314 for (
y = 0;
y < (int) source->rows;
y++) {
1315 for (
x = 0;
x < (int) source->width;
x++) {
1317 d = ((
d + 10) * 5) / 256;
1319 if (
d &&
x < (
int) source->width) {
1328 for (
int y = 0;
y < (int) source->rows;
y++) {
1331 for (
int x = 0;
x < (int) source->width;
x++) {
1332 if (
n == 0)
d = *
s++;
1338 row += source->pitch;
1394 if (
y+
h > height)
h = height -
y;
1396 return gdk_image_get((GdkDrawable*)cws,
x,
y, w,
h);
1411 if ((
int)w == 0 || (
int)
h == 0)
return kFALSE;
1415 if (
y + (
int)h <= 0 || y >= (
int)height)
return kFALSE;
1443 GdkImage *xim = gdk_image_new(GDK_IMAGE_SHARED, gdk_visual_get_best(), w,
h);
1452 gdk_gc_get_values((GdkGC*)
GetGC(3), &gcvals);
1459 Error(
"DrawText",
"error getting background image");
1464 Int_t xo = 0, yo = 0;
1465 if (
x1 < 0) xo = -
x1;
1466 if (y1 < 0) yo = -y1;
1468 for (
int yp = 0; yp < (int) bim->height; yp++) {
1469 for (
int xp = 0; xp < (int) bim->width; xp++) {
1470 pixel = GetPixelImage((
Drawable_t)bim, xp, yp);
1475 gdk_image_unref((GdkImage *)bim);
1483 pixel = gcvals.background.pixel;
1485 pixel = GetPixelImage((
Drawable_t)bim, 0, 0);
1487 Int_t xo = 0, yo = 0;
1488 if (
x1 < 0) xo = -
x1;
1489 if (y1 < 0) yo = -y1;
1491 for (
int yp = 0; yp <
h; yp++) {
1492 for (
int xp = 0; xp < (int) w; xp++) {
1497 gdk_image_unref((GdkImage *)bim);
1507 if (FT_Glyph_To_Bitmap(&glyph->
fImage,
1509 : ft_render_mode_mono,
1511 FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph->
fImage;
1512 FT_Bitmap* source = &bitmap->bitmap;
1515 bx = bitmap->left+Xoff;
1516 by =
h - bitmap->top-Yoff;
1517 DrawImage(source, gcvals.foreground.pixel, bg, xim, bx, by);
1522 gdk_draw_image((GdkDrawable *)cws,
GetGC(6), xim, 0, 0,
x1, y1, w,
h);
1524 gdk_image_unref(xim);
1567 if (!
gCws->ispixmap && !
gCws->double_buffer) {
1568 gdk_window_set_background(
gCws->drawing, (GdkColor *) &
GetColor(0).color);
1569 gdk_window_clear(
gCws->drawing);
1602 if (
gCws->ispixmap) {
1603 gdk_pixmap_unref(
gCws->window);
1605 gdk_window_destroy(
gCws->window,
kTRUE);
1609 gdk_pixmap_unref(
gCws->buffer);
1611 if (
gCws->new_colors) {
1612 gdk_colormap_free_colors((GdkColormap *)
fColormap,
1613 (GdkColor *)
gCws->new_colors,
gCws->ncolors);
1615 delete []
gCws->new_colors;
1616 gCws->new_colors = 0;
1642 gdk_window_copy_area(
gCws->drawing,
gGCpxmp, xpos, ypos,
gTws->drawing,
1694 int i, j, icol, ix, iy, w,
h, current_icol;
1706 for (i = 0; i < nx; i++) {
1708 for (j = 0; j < ny; j++) {
1709 icol = ic[i + (nx * j)];
1710 if (icol != current_icol) {
1712 current_icol = icol;
1730 static int lastn = 0;
1731 static GdkPoint *
xy = 0;
1739 delete [] (GdkPoint *)
xy;
1740 xy =
new GdkPoint[
n];
1743 for (i = 0; i <
n; i++) {
1744 xy[i].x = xyt[i].
fX;
1745 xy[i].y = xyt[i].
fY;
1776 dashes[i] = (gint8) 0;
1796 for (i = 0; i <
n; i++) {
1797 xy[i].fX = xyt[i].
fX;
1798 xy[i].fY = xyt[i].
fY;
1815 dashes[i] = (gint8) 0;
1822 for (i = 1; i <
n; i++) {
1823 int dx =
xy[i].fX -
xy[i - 1].fX;
1824 int dy =
xy[i].fY -
xy[i - 1].fY;
1826 if (dx < 0) dx = -dx;
1827 if (dy < 0) dy = -dy;
1847 static int lastn = 0;
1848 static GdkPoint *
xy = 0;
1856 delete [] (GdkPoint *)
xy;
1857 xy =
new GdkPoint[
n];
1861 for (i = 0; i <
n; i++) {
1862 xy[i].x = xyt[i].
fX;
1863 xy[i].y = xyt[i].
fY;
1872 for (
m = 0;
m <
n;
m++) {
1890 for (i = 0; i <
gMarker.n; i++) {
1899 for (i = 0; i <
gMarker.n; i++) {
1906 for (i = 0; i <
gMarker.n; i += 2) {
1956 if (which >=
kMAXGC || which < 0) {
1957 Error(
"GetGC",
"trying to get illegal GdkGC (which = %d)", which);
1976 return gTws->double_buffer;
1996 w = gdk_screen_width();
1997 h = gdk_screen_height();
2003 gdk_window_get_geometry((GdkDrawable *)
gTws->window, &
x, &
y,
2004 &
width, &height, &depth);
2006 gdk_window_get_deskrelative_origin((GdkDrawable *)
gTws->window, &
x, &
y);
2008 if (
width > 0 && height > 0) {
2010 gTws->height = height;
2030 nplanes = gdk_visual_get_best_depth();
2040 }
else if (index == 1) {
2084 if (!
gTws->open)
return;
2086 gdk_window_move((GdkDrawable *)
gTws->window,
x,
y);
2113 newsize *
sizeof(XWindow_t),
2122 depth =gdk_visual_get_best_depth();
2123 gCws->window = (GdkPixmap *) gdk_pixmap_new(GDK_ROOT_PARENT(),wval,hval,depth);
2124 gdk_drawable_get_size((GdkDrawable *)
gCws->window, &ww, &hh);
2126 for (i = 0; i <
kMAXGC; i++) {
2127 gdk_gc_set_clip_mask((GdkGC *)
gGClist[i], (GdkDrawable *)None);
2138 gCws->double_buffer = 0;
2142 gCws->height = hval;
2143 gCws->new_colors = 0;
2154 GdkWindowAttr attributes;
2155 unsigned long attr_mask = 0;
2158 int wval, hval, depth;
2160 GdkWindow *wind = (GdkWindow *) win;
2162 gdk_window_get_geometry(wind, &xval, &yval, &wval, &hval, &depth);
2180 newsize *
sizeof(XWindow_t),
2192 attributes.wclass = GDK_INPUT_OUTPUT;
2193 attributes.event_mask = 0
L;
2194 attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK |
2195 GDK_PROPERTY_CHANGE_MASK;
2198 attributes.x = xval;
2200 attributes.x = -1.0 * xval;
2204 attributes.y = yval;
2206 attributes.y = -1.0 * yval;
2208 attributes.width = wval;
2209 attributes.height = hval;
2210 attributes.colormap = gdk_colormap_get_system();
2211 attributes.visual = gdk_window_get_visual(wind);
2212 attributes.override_redirect =
TRUE;
2214 if ((attributes.y > 0) && (attributes.x > 0)) {
2215 attr_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_COLORMAP |
2216 GDK_WA_WMCLASS | GDK_WA_NOREDIR;
2218 attr_mask = GDK_WA_COLORMAP | GDK_WA_WMCLASS | GDK_WA_NOREDIR;
2221 if (attributes.visual != NULL) {
2222 attr_mask |= GDK_WA_VISUAL;
2224 attributes.window_type = GDK_WINDOW_CHILD;
2225 gCws->window = gdk_window_new(wind, &attributes, attr_mask);
2226 HWND window = (HWND)GDK_DRAWABLE_XID((GdkWindow *)
gCws->window);
2227 ::ShowWindow(window, SW_SHOWNORMAL);
2228 ::ShowWindow(window, SW_RESTORE);
2229 ::BringWindowToTop(window);
2232 ::SetClassLong(window, GCL_HCURSOR,
2240 gCws->double_buffer = 0;
2244 gCws->height = hval;
2245 gCws->new_colors = 0;
2272 gdk_pixmap_unref((GdkPixmap *)pix);
2303 static int xloc = 0;
2304 static int yloc = 0;
2305 static int xlocp = 0;
2306 static int ylocp = 0;
2307 static GdkCursor *cursor = NULL;
2315 if (cursor == NULL) {
2317 gdk_window_set_cursor((GdkWindow *)
gCws->window, (GdkCursor *)
gNullCursor);
2321 cursor = gdk_syscursor_new((
ULong_t)IDC_CROSS);
2323 cursor = gdk_cursor_new((GdkCursorType)GDK_CROSSHAIR);
2324 gdk_window_set_cursor((GdkWindow *)
gCws->window, (GdkCursor *)cursor);
2334 while (button_press == 0) {
2335 event = gdk_event_get();
2348 radius = (int)
TMath::Sqrt((
double)((xloc - xlocp) * (xloc - xlocp) +
2349 (yloc - ylocp) * (yloc - ylocp)));
2352 xlocp - radius, ylocp - radius,
2353 2 * radius, 2 * radius, 0, 23040);
2357 gdk_draw_line(
gCws->window,
gGCecho, xlocp, ylocp, xloc, yloc);
2370 xloc =
event->button.x;
2371 yloc =
event->button.y;
2373 switch (event->type) {
2375 case GDK_LEAVE_NOTIFY:
2378 event = gdk_event_get();
2380 if (event->type == GDK_ENTER_NOTIFY) {
2381 gdk_event_free(event);
2384 gdk_event_free(event);
2391 case GDK_BUTTON_PRESS:
2392 button_press =
event->button.button;
2393 xlocp =
event->button.x;
2394 ylocp =
event->button.y;
2395 gdk_cursor_unref(cursor);
2399 case GDK_BUTTON_RELEASE:
2401 button_press = 10 +
event->button.button;
2402 xlocp =
event->button.x;
2403 ylocp =
event->button.y;
2409 button_press =
event->key.keyval;
2410 xlocp =
event->button.x;
2411 ylocp =
event->button.y;
2415 case GDK_KEY_RELEASE:
2417 button_press = -1 * (int)(event->key.keyval);
2418 xlocp =
event->button.x;
2419 ylocp =
event->button.y;
2427 xtmp =
event->button.x;
2428 ytmp =
event->button.y;
2430 gdk_event_free(event);
2433 if (button_press == 0) {
2444 return button_press;
2458 static GdkCursor *cursor = NULL;
2459 static int percent = 0;
2460 static GdkWindow *CurWnd;
2465 int len_text = strlen(
text);
2469 CurWnd = (GdkWindow *)
gCws->window;
2471 if (cursor == NULL) {
2473 cursor = gdk_syscursor_new((
ULong_t)IDC_HELP);
2475 cursor = gdk_cursor_new((GdkCursorType)GDK_QUESTION_ARROW);
2478 gdk_window_set_cursor(CurWnd, cursor);
2480 for (nt = len_text; nt > 0 &&
text[nt - 1] ==
' '; nt--);
2483 focuswindow = ::SetFocus((HWND)GDK_DRAWABLE_XID(CurWnd));
2498 event = gdk_event_get();
2501 ::SleepEx(10,
kTRUE);
2512 char *stmp =
new char[
pt+1];
2520 if (
pt < len_text) {
2528 if (event != NULL) {
2529 switch (event->type) {
2530 case GDK_BUTTON_PRESS:
2531 case GDK_ENTER_NOTIFY:
2532 focuswindow = ::SetFocus((HWND)GDK_DRAWABLE_XID(CurWnd));
2535 case GDK_LEAVE_NOTIFY:
2536 ::SetFocus(focuswindow);
2539 nbytes =
event->key.length;
2540 for (i = 0; i < nbytes; i++) {
2541 keybuf[i] =
event->key.string[i];
2543 keysym =
event->key.keyval;
2579 if (isascii(keybuf[0]) && isprint(keybuf[0])) {
2581 if (nt < len_text) {
2584 for (i = nt - 1; i >
pt; i--) {
2587 if (
pt < len_text) {
2592 switch (keybuf[0]) {
2599 for (i =
pt; i < nt; i++) {
2620 for (i =
pt; i < nt; i++) {
2640 for (i =
pt; i < nt; i++)
2670 gdk_event_free(event);
2674 ::SetFocus(focuswindow);
2679 gdk_cursor_unref(cursor);
2703 if (
gTws->width == w &&
gTws->height ==
h)
2706 gdk_window_resize((GdkWindow *)
gTws->window, w,
h);
2710 if (
gTws->width < w ||
gTws->height <
h) {
2711 gdk_pixmap_unref(
gTws->buffer);
2712 gTws->buffer = gdk_pixmap_new(GDK_ROOT_PARENT(),
2713 w,
h, gdk_visual_get_best_depth());
2715 for (i = 0; i <
kMAXGC; i++) {
2716 gdk_gc_set_clip_mask(
gGClist[i], None);
2750 if (
gTws->width >= wval - 1 &&
gTws->width <= wval + 1 &&
2751 gTws->height >= hval - 1 &&
gTws->height <= hval + 1)
2755 if (
gTws->width < wval ||
gTws->height < hval) {
2756 gdk_pixmap_unref((GdkPixmap *)
gTws->window);
2757 depth = gdk_visual_get_best_depth();
2758 gTws->window = gdk_pixmap_new(GDK_ROOT_PARENT(), wval, hval, depth);
2761 gdk_drawable_get_size(
gTws->window, &ww, &hh);
2763 for (i = 0; i <
kMAXGC; i++) {
2764 gdk_gc_set_clip_mask((GdkGC *)
gGClist[i], (GdkDrawable *)None);
2774 gTws->height = hval;
2784 int xval = 0, yval = 0;
2785 GdkWindow *win, *root = NULL;
2786 int wval = 0, hval = 0, depth = 0;
2792 win = (GdkWindow *)
gTws->window;
2793 gdk_window_get_geometry(win, &xval, &yval,
2794 &wval, &hval, &depth);
2797 if (
gTws->width == wval &&
gTws->height == hval) {
2801 gdk_window_resize((GdkWindow *)
gTws->window, wval, hval);
2804 if (
gTws->width < wval ||
gTws->height < hval) {
2805 gdk_pixmap_unref((GdkPixmap *)
gTws->buffer);
2806 depth = gdk_visual_get_best_depth();
2807 gTws->buffer = (GdkPixmap *) gdk_pixmap_new(GDK_ROOT_PARENT(),
2811 for (i = 0; i <
kMAXGC; i++) {
2812 gdk_gc_set_clip_mask((GdkGC *)
gGClist[i], (GdkDrawable *)None);
2824 gTws->height = hval;
2841 if (
gCws->clip && !
gCws->ispixmap && !
gCws->double_buffer) {
2842 rect.x =
gCws->xclip;
2843 rect.y =
gCws->yclip;
2844 rect.width =
gCws->wclip;
2845 rect.height =
gCws->hclip;
2847 for (i = 0; i <
kMAXGC; i++) {
2848 gdk_gc_set_clip_rectangle((GdkGC *)
gGClist[i], &rect);
2851 for (i = 0; i <
kMAXGC; i++) {
2852 gdk_gc_set_clip_mask((GdkGC *)
gGClist[i], (GdkDrawable *)None);
2864 if (chupx == 0 && chupy == 0) {
2866 }
else if (chupx == 0 && chupy == 1) {
2868 }
else if (chupx == -1 && chupy == 0) {
2870 }
else if (chupx == 0 && chupy == -1) {
2872 }
else if (chupx == 1 && chupy == 0) {
2878 180.) / 3.14159) - 90;
2896 for (
int i = 0; i <
kMAXGC; i++) {
2897 gdk_gc_set_clip_mask((GdkGC *)
gGClist[i], (GdkDrawable *)None);
2920 if (
gTws->clip && !
gTws->ispixmap && !
gTws->double_buffer) {
2921 rect.x =
gTws->xclip;
2922 rect.y =
gTws->yclip;
2923 rect.width =
gTws->wclip;
2924 rect.height =
gTws->hclip;
2926 for (
int i = 0; i <
kMAXGC; i++) {
2927 gdk_gc_set_clip_rectangle((GdkGC *)
gGClist[i], &rect);
2941 return col.
color.pixel;
2961 }
else if (!
fColormap && (ci < 0 || ci > 1)) {
2966 gdk_gc_get_values(gc, &gcvals);
2968 color.pixel = col.
color.pixel ^ gcvals.background.pixel;
2969 color.red = GetRValue(color.pixel);
2970 color.green = GetGValue(color.pixel);
2971 color.blue = GetBValue(color.pixel);
2972 gdk_gc_set_foreground(gc, &color);
2975 gdk_gc_set_foreground(gc, &col.
color);
2978 gdk_gc_get_values(gc, &gcvals);
2980 if (gcvals.foreground.pixel != gcvals.background.pixel) {
2981 gdk_gc_set_background(gc, &
GetColor(!ci).color);
2994 gdk_window_set_cursor((GdkWindow *)
gTws->window, (GdkCursor *)
fCursors[cursor]);
3004 static GdkWindow *lid = 0;
3005 static GdkCursor *lcur = 0;
3007 if ((lid == (GdkWindow *)
id) && (lcur==(GdkCursor *)curid))
return;
3008 lid = (GdkWindow *)
id;
3009 lcur = (GdkCursor *)curid;
3011 gdk_window_set_cursor((GdkWindow *)
id, (GdkCursor *)curid);
3041 if (!
gTws->open)
return;
3059 if (!
gTws->double_buffer)
return;
3060 gTws->double_buffer = 0;
3071 if (!
gTws->buffer) {
3072 gTws->buffer = gdk_pixmap_new(GDK_ROOT_PARENT(),
3074 gdk_visual_get_best_depth());
3080 for (
int i = 0; i <
kMAXGC; i++) {
3081 gdk_gc_set_clip_mask(
gGClist[i], None);
3083 gTws->double_buffer = 1;
3102 for (i = 0; i <
kMAXGC; i++) {
3103 gdk_gc_set_function(
gGClist[i], GDK_COPY);
3108 for (i = 0; i <
kMAXGC; i++) {
3109 gdk_gc_set_function(
gGClist[i], GDK_XOR);
3114 for (i = 0; i <
kMAXGC; i++) {
3115 gdk_gc_set_function(
gGClist[i], GDK_INVERT);
3172 static int current_fasi = 0;
3181 gdk_gc_set_fill(
gGCfill, GDK_SOLID);
3190 gdk_gc_set_fill(
gGCfill, GDK_STIPPLED);
3192 if (fasi != current_fasi) {
3197 int stn = (fasi >= 1 && fasi <=25) ? fasi : 2;
3198 gFillPattern = gdk_bitmap_create_from_data(GDK_ROOT_PARENT(),
3201 current_fasi = fasi;
3217 EnableWindow((HWND) GDK_DRAWABLE_XID(
gCws->window), inp);
3225 if ((cindex < 0) || (cindex==
fLineColor))
return;
3294 static Int_t dashed[2] = { 3, 3 };
3295 static Int_t dotted[2] = { 1, 2 };
3296 static Int_t dasheddotted[4] = { 3, 4, 1, 4 };
3312 for (
Int_t j = 0; j<nt; j++) {
3314 sscanf(((
TObjString*)tokens->
At(j))->GetName(),
"%d", &it);
3315 linestyle[j] = (
Int_t)(it/4);
3318 delete [] linestyle;
3389 for (
int i = 0; i <
gMarker.n; i++) {
3400 if ((
fMarkerStyle == markerstyle) || (markerstyle >= 50))
return;
3410 static GdkPoint shape[30];
3652 shape[0].x = 0; shape[0].y = im;
3653 shape[1].x = im; shape[1].y = -im;
3654 shape[2].x = -im; shape[2].y = -im;
3655 shape[3].x = 0; shape[3].y = im;
3660 shape[0].x =-imx; shape[0].y = 0;
3661 shape[1].x = 0; shape[1].y = -im;
3662 shape[2].x = imx; shape[2].y = 0;
3663 shape[3].x = 0; shape[3].y = im;
3664 shape[4].x =-imx; shape[4].y = 0;
3669 shape[0].x = -im; shape[0].y =-imx;
3670 shape[1].x =-imx; shape[1].y =-imx;
3671 shape[2].x =-imx; shape[2].y = -im;
3672 shape[3].x = imx; shape[3].y = -im;
3673 shape[4].x = imx; shape[4].y =-imx;
3674 shape[5].x = im; shape[5].y =-imx;
3675 shape[6].x = im; shape[6].y = imx;
3676 shape[7].x = imx; shape[7].y = imx;
3677 shape[8].x = imx; shape[8].y = im;
3678 shape[9].x =-imx; shape[9].y = im;
3679 shape[10].x=-imx; shape[10].y= imx;
3680 shape[11].x= -im; shape[11].y= imx;
3681 shape[12].x= -im; shape[12].y=-imx;
3685 shape[0].x = -im; shape[0].y = -im;
3686 shape[1].x = im; shape[1].y = -im;
3687 shape[2].x = im; shape[2].y = im;
3688 shape[3].x = -im; shape[3].y = im;
3689 shape[4].x = -im; shape[4].y = -im;
3690 shape[5].x = im; shape[5].y = im;
3691 shape[6].x = -im; shape[6].y = im;
3692 shape[7].x = im; shape[7].y = -im;
3696 shape[0].x =-im; shape[0].y = 0;
3697 shape[1].x = 0; shape[1].y = -im;
3698 shape[2].x = im; shape[2].y = 0;
3699 shape[3].x = 0; shape[3].y = im;
3700 shape[4].x =-im; shape[4].y = 0;
3701 shape[5].x = im; shape[5].y = 0;
3702 shape[6].x = 0; shape[6].y = im;
3703 shape[7].x = 0; shape[7].y =-im;
3708 shape[0].x = 0; shape[0].y = 0;
3709 shape[1].x =-im2; shape[1].y = im;
3710 shape[2].x = -im; shape[2].y = 0;
3711 shape[3].x = 0; shape[3].y = 0;
3712 shape[4].x =-im2; shape[4].y = -im;
3713 shape[5].x = im2; shape[5].y = -im;
3714 shape[6].x = 0; shape[6].y = 0;
3715 shape[7].x = im; shape[7].y = 0;
3716 shape[8].x = im2; shape[8].y = im;
3717 shape[9].x = 0; shape[9].y = 0;
3722 shape[0].x = -im; shape[0].y = 0;
3723 shape[1].x = -im; shape[1].y =-im2;
3724 shape[2].x =-im2; shape[2].y =-im;
3725 shape[3].x = im2; shape[3].y = -im;
3726 shape[4].x = im; shape[4].y =-im2;
3727 shape[5].x = im; shape[5].y = im2;
3728 shape[6].x = im2; shape[6].y = im;
3729 shape[7].x =-im2; shape[7].y = im;
3730 shape[8].x = -im; shape[8].y = im2;
3731 shape[9].x = -im; shape[9].y = 0;
3732 shape[10].x = im; shape[10].y = 0;
3733 shape[11].x = 0; shape[11].y = 0;
3734 shape[12].x = 0; shape[12].y = -im;
3735 shape[13].x = 0; shape[13].y = im;
3736 shape[14].x = 0; shape[14].y = 0;
3741 shape[0].x = 0; shape[0].y = 0;
3742 shape[1].x =-im2; shape[1].y = im;
3743 shape[2].x = -im; shape[2].y = 0;
3744 shape[3].x = 0; shape[3].y = 0;
3745 shape[4].x =-im2; shape[4].y = -im;
3746 shape[5].x = im2; shape[5].y = -im;
3747 shape[6].x = 0; shape[6].y = 0;
3748 shape[7].x = im; shape[7].y = 0;
3749 shape[8].x = im2; shape[8].y = im;
3754 shape[0].x = 0; shape[0].y = 0;
3755 shape[1].x = im2; shape[1].y = im;
3756 shape[2].x = im; shape[2].y = im2;
3757 shape[3].x = 0; shape[3].y = 0;
3758 shape[4].x = im; shape[4].y = -im2;
3759 shape[5].x = im2; shape[5].y = -im;
3760 shape[6].x = 0; shape[6].y = 0;
3761 shape[7].x = -im2; shape[7].y = -im;
3762 shape[8].x = -im; shape[8].y = -im2;
3763 shape[9].x = 0; shape[9].y = 0;
3764 shape[10].x = -im; shape[10].y = im2;
3765 shape[11].x = -im2; shape[11].y = im;
3766 shape[12].x = 0; shape[12].y = 0;
3771 shape[0].x = 0; shape[0].y = 0;
3772 shape[1].x = im2; shape[1].y = im;
3773 shape[2].x = im; shape[2].y = im2;
3774 shape[3].x = 0; shape[3].y = 0;
3775 shape[4].x = im; shape[4].y = -im2;
3776 shape[5].x = im2; shape[5].y = -im;
3777 shape[6].x = 0; shape[6].y = 0;
3778 shape[7].x = -im2; shape[7].y = -im;
3779 shape[8].x = -im; shape[8].y = -im2;
3780 shape[9].x = 0; shape[9].y = 0;
3781 shape[10].x = -im; shape[10].y = im2;
3782 shape[11].x = -im2; shape[11].y = im;
3783 shape[12].x = 0; shape[12].y = 0;
3788 shape[0].x= 0; shape[0].y= im;
3789 shape[1].x= -imx; shape[1].y= imx;
3790 shape[2].x = -im; shape[2].y = 0;
3791 shape[3].x = -imx; shape[3].y = -imx;
3792 shape[4].x = 0; shape[4].y = -im;
3793 shape[5].x = imx; shape[5].y = -imx;
3794 shape[6].x = im; shape[6].y = 0;
3795 shape[7].x= imx; shape[7].y= imx;
3796 shape[8].x= 0; shape[8].y= im;
3801 shape[0].x = 0; shape[0].y = im;
3802 shape[1].x = -imx; shape[1].y = imx;
3803 shape[2].x = -im; shape[2].y = 0;
3804 shape[3].x = -imx; shape[3].y = -imx;
3805 shape[4].x = 0; shape[4].y = -im;
3806 shape[5].x = imx; shape[5].y = -imx;
3807 shape[6].x = im; shape[6].y = 0;
3808 shape[7].x = imx; shape[7].y = imx;
3809 shape[8].x = 0; shape[8].y = im;
3814 shape[0].x = 0; shape[0].y = 0;
3815 shape[1].x = im2; shape[1].y = im;
3816 shape[2].x = -im2; shape[2].y = im;
3817 shape[3].x = im2; shape[3].y = -im;
3818 shape[4].x = -im2; shape[4].y = -im;
3819 shape[5].x = 0; shape[5].y = 0;
3820 shape[6].x = im; shape[6].y = im2;
3821 shape[7].x = im; shape[7].y = -im2;
3822 shape[8].x = -im; shape[8].y = im2;
3823 shape[9].x = -im; shape[9].y = -im2;
3824 shape[10].x = 0; shape[10].y = 0;
3830 shape[0].x = im0; shape[0].y = im0;
3831 shape[1].x = im2; shape[1].y = im;
3832 shape[2].x = -im2; shape[2].y = im;
3833 shape[3].x = -im0; shape[3].y = im0;
3834 shape[4].x = -im; shape[4].y = im2;
3835 shape[5].x = -im; shape[5].y = -im2;
3836 shape[6].x = -im0; shape[6].y = -im0;
3837 shape[7].x = -im2; shape[7].y = -im;
3838 shape[8].x = im2; shape[8].y = -im;
3839 shape[9].x = im0; shape[9].y = -im0;
3840 shape[10].x = im; shape[10].y = -im2;
3841 shape[11].x = im; shape[11].y = im2;
3842 shape[12].x = im0; shape[12].y = im0;
3847 shape[0].x = 0; shape[0].y = im2;
3848 shape[1].x = -im2; shape[1].y = im;
3849 shape[2].x = -im; shape[2].y = im2;
3850 shape[3].x = -im2; shape[3].y = 0;
3851 shape[4].x = -im; shape[4].y = -im2;
3852 shape[5].x = -im2; shape[5].y = -im;
3853 shape[6].x = 0; shape[6].y = -im2;
3854 shape[7].x = im2; shape[7].y = -im;
3855 shape[8].x = im; shape[8].y = -im2;
3856 shape[9].x = im2; shape[9].y = 0;
3857 shape[10].x = im; shape[10].y = im2;
3858 shape[11].x = im2; shape[11].y = im;
3859 shape[12].x = 0; shape[12].y = im2;
3864 shape[0].x = 0; shape[0].y = im2;
3865 shape[1].x = -im2; shape[1].y = im;
3866 shape[2].x = -im; shape[2].y = im2;
3867 shape[3].x = -im2; shape[3].y = 0;
3868 shape[4].x = -im; shape[4].y = -im2;
3869 shape[5].x = -im2; shape[5].y = -im;
3870 shape[6].x = 0; shape[6].y = -im2;
3871 shape[7].x = im2; shape[7].y = -im;
3872 shape[8].x = im; shape[8].y = -im2;
3873 shape[9].x = im2; shape[9].y = 0;
3874 shape[10].x = im; shape[10].y = im2;
3875 shape[11].x = im2; shape[11].y = im;
3876 shape[12].x = 0; shape[12].y = im2;
3881 shape[0].x = 0; shape[0].y = im2*1.005;
3882 shape[1].x = -im2; shape[1].y = im;
3883 shape[2].x = -im; shape[2].y = im2;
3884 shape[3].x = -im2; shape[3].y = 0;
3885 shape[4].x = -im; shape[4].y = -im2;
3886 shape[5].x = -im2; shape[5].y = -im;
3887 shape[6].x = 0; shape[6].y = -im2;
3888 shape[7].x = im2; shape[7].y = -im;
3889 shape[8].x = im; shape[8].y = -im2;
3890 shape[9].x = im2; shape[9].y = 0;
3891 shape[10].x = im; shape[10].y = im2;
3892 shape[11].x = im2; shape[11].y = im;
3893 shape[12].x = 0; shape[12].y = im2*0.995;
3894 shape[13].x = im2*0.995; shape[13].y = 0;
3895 shape[14].x = 0; shape[14].y = -im2*0.995;
3896 shape[15].x = -im2*0.995; shape[15].y = 0;
3897 shape[16].x = 0; shape[16].y = im2*0.995;
3902 shape[0].x =-imx; shape[0].y =-imx*1.005;
3903 shape[1].x =-imx; shape[1].y = -im;
3904 shape[2].x = imx; shape[2].y = -im;
3905 shape[3].x = imx; shape[3].y =-imx;
3906 shape[4].x = im; shape[4].y =-imx;
3907 shape[5].x = im; shape[5].y = imx;
3908 shape[6].x = imx; shape[6].y = imx;
3909 shape[7].x = imx; shape[7].y = im;
3910 shape[8].x =-imx; shape[8].y = im;
3911 shape[9].x =-imx; shape[9].y = imx;
3912 shape[10].x = -im; shape[10].y = imx;
3913 shape[11].x = -im; shape[11].y =-imx;
3914 shape[12].x =-imx; shape[12].y =-imx*0.995;
3915 shape[13].x =-imx; shape[13].y = imx;
3916 shape[14].x = imx; shape[14].y = imx;
3917 shape[15].x = imx; shape[15].y =-imx;
3918 shape[16].x =-imx; shape[16].y =-imx*1.005;
3936 Int_t depth = gdk_visual_get_best_depth();
3938 if (depth <= 8)
return;
3939 if (percent == 0)
return;
3942 ULong_t *orgcolors = 0, *tmpc = 0;
3943 Int_t maxcolors = 0, ncolors, ntmpc = 0;
3946 if (
gCws->new_colors) {
3947 tmpc =
gCws->new_colors;
3948 ntmpc =
gCws->ncolors;
3951 GdkImage *image = gdk_image_get((GdkDrawable*)
gCws->drawing, 0, 0,
3956 for (
y = 0;
y < (int)
gCws->height;
y++) {
3957 for (
x = 0;
x < (int)
gCws->width;
x++) {
3959 CollectImageColors(pixel, orgcolors, ncolors, maxcolors);
3963 gdk_image_unref(image);
3964 ::operator
delete(orgcolors);
3971 for (
y = 0;
y < (int)
gCws->height;
y++) {
3972 for (
x = 0;
x < (int)
gCws->width;
x++) {
3980 gdk_draw_image(
gCws->drawing,
gGCpxmp, (GdkImage *)image,
3981 0, 0, 0, 0,
gCws->width,
gCws->height);
3986 gdk_colors_free((GdkColormap *)
fColormap, tmpc, ntmpc, 0);
3989 gdk_image_unref(image);
3990 ::operator
delete(orgcolors);
4000 if (ncolors <= 0)
return;
4001 GdkColor *xcol =
new GdkColor[ncolors];
4004 for (i = 0; i < ncolors; i++) {
4005 xcol[i].pixel = orgcolors[i];
4006 xcol[i].red = xcol[i].green = xcol[i].blue = 0;
4009 GdkColorContext *cc;
4010 cc = gdk_color_context_new(gdk_visual_get_system(), (GdkColormap *)
fColormap);
4011 gdk_color_context_query_colors(cc, xcol, ncolors);
4012 gdk_color_context_free(cc);
4017 for (i = 0; i < ncolors; i++) {
4018 val = xcol[i].red + add;
4023 val = xcol[i].green + add;
4028 val = xcol[i].blue + add;
4034 ret = gdk_color_alloc((GdkColormap *)
fColormap, &xcol[i]);
4038 "failed to allocate color %hd, %hd, %hd", xcol[i].red,
4039 xcol[i].green, xcol[i].blue);
4045 gCws->ncolors = ncolors;
4047 for (i = 0; i < ncolors; i++) {
4048 gCws->new_colors[i] = xcol[i].pixel;
4059 for (
int i = 0; i < ncolors; i++) {
4060 if (pixel == orgcolors[i])
return i;
4062 Error(
"FindColor",
"did not find color, should never happen!");
4080 xcol.pixel = RGB(xcol.red, xcol.green, xcol.blue);
4085 if (col.
color.red == xcol.red && col.
color.green == xcol.green &&
4086 col.
color.blue == xcol.blue)
4089 gdk_colormap_free_colors((GdkColormap *)
fColormap,
4090 (GdkColor *)&col, 1);
4096 col.
color.pixel = xcol.pixel;
4097 col.
color.red = xcol.red;
4098 col.
color.green = xcol.green;
4099 col.
color.blue = xcol.blue;
4112 if (talign==current)
return;
4115 Int_t txalh = talign / 10;
4116 Int_t txalv = talign % 10;
4171 static Int_t current = 0;
4173 if ((cindex < 0) || (
Int_t(cindex)==current))
return;
4178 gdk_gc_get_values(
gGCtext, &values);
4179 gdk_gc_set_foreground(
gGCinvt, &values.background);
4180 gdk_gc_set_background(
gGCinvt, &values.foreground);
4182 current =
Int_t(cindex);
4223 dw = (HWND) GDK_DRAWABLE_XID((GdkWindow *)
gCws->window);
4225 dw = (HWND) GDK_DRAWABLE_XID((GdkWindow *)
id);
4227 tmp.x = ix > 0 ? ix : cpt.x;
4228 tmp.y = iy > 0 ? iy : cpt.y;
4229 ClientToScreen(dw, &tmp);
4230 SetCursorPos(tmp.x, tmp.y);
4266 void (*get_scline) (
int,
int,
Byte_t *),
4270 int GIFinfo(
Byte_t * GIFarr,
int *Width,
int *Height,
int *Ncols);
4279 for (
int i = 0; i <
width; i++) {
4305 Int_t maxcolors = 0, ncolors;
4309 for (
x = 0;
x < (int)
gCws->width;
x++) {
4310 for (
y = 0;
y < (int)
gCws->height;
y++) {
4312 CollectImageColors(pixel, orgcolors, ncolors, maxcolors);
4317 GdkColor *xcol =
new GdkColor[ncolors];
4320 for (i = 0; i < ncolors; i++) {
4321 xcol[i].pixel = orgcolors[i];
4323 xcol[i].red = GetRValue(xcol[i].pixel);
4324 xcol[i].green = GetGValue(xcol[i].pixel);
4325 xcol[i].blue = GetBValue(xcol[i].pixel);
4328 GdkColorContext *cc;
4329 cc = gdk_color_context_new(gdk_visual_get_system(), (GdkColormap *)
fColormap);
4330 gdk_color_context_query_colors(cc, xcol, ncolors);
4331 gdk_color_context_free(cc);
4339 for (i = 0; i < ncolors; i++) {
4341 G[i] = xcol[i].green;
4342 B[i] = xcol[i].blue;
4347 for (
x = 0;
x < (int)
gCws->width;
x++) {
4348 for (
y = 0;
y < (int)
gCws->height;
y++) {
4357 ::operator
delete(orgcolors);
4365 Byte_t scline[2000],
r[256],
b[256],
g[256];
4367 Int_t ncol, maxcol, i;
4373 gGifImage = gdk_image_get((GdkDrawable*)
gCws->drawing, 0, 0,
4381 "can not create GIF of image containing more than 256 colors");
4389 for (i = 0; i < ncol; i++) {
4390 if (maxcol <
R[i]) maxcol =
R[i];
4391 if (maxcol <
G[i]) maxcol =
G[i];
4392 if (maxcol <
B[i]) maxcol =
B[i];
4398 for (i = 0; i < ncol; i++) {
4399 r[i] =
R[i] * 255 / maxcol;
4400 g[i] =
G[i] * 255 / maxcol;
4401 b[i] =
B[i] * 255 / maxcol;
4413 Error(
"WriteGIF",
"cannot write file: %s",
name);
4430 const int MAX_SEGMENT = 20;
4431 int i,
n,
x,
y, xcur,
x1,
x2, y1, y2;
4432 unsigned char *jimg, *jbase, icol;
4434 GdkSegment lines[256][MAX_SEGMENT];
4438 id = (GdkDrawable*)wid;
4443 for (i = 0; i < 256; i++) nlines[i] = 0;
4446 y1 = y0 + ny -
ymax - 1;
4448 y2 = y0 + ny -
ymin - 1;
4449 jbase = image + (
ymin - 1) * nx +
xmin;
4451 for (
y = y2;
y >= y1;
y--) {
4454 for (jimg = jbase, icol = *jimg++,
x =
x1 + 1;
x <=
x2; jimg++,
x++) {
4455 if (icol != *jimg) {
4456 if (icol != itran) {
4458 lines[icol][
n].x1 = xcur;
4459 lines[icol][
n].y1 =
y;
4460 lines[icol][
n].x2 =
x - 1;
4461 lines[icol][
n].y2 =
y;
4462 if (nlines[icol] == MAX_SEGMENT) {
4465 (GdkSegment *) &lines[icol][0], MAX_SEGMENT);
4473 if (icol != itran) {
4475 lines[icol][
n].x1 = xcur;
4476 lines[icol][
n].y1 =
y;
4477 lines[icol][
n].x2 =
x - 1;
4478 lines[icol][
n].y2 =
y;
4479 if (nlines[icol] == MAX_SEGMENT) {
4482 (GdkSegment *)&lines[icol][0], MAX_SEGMENT);
4488 for (i = 0; i < 256; i++) {
4489 if (nlines[i] != 0) {
4492 (GdkSegment *)&lines[icol][0], nlines[i]);
4505 unsigned char *GIFarr, *PIXarr,
R[256],
G[256],
B[256], *j1, *j2, icol;
4506 int i, j, k,
width, height, ncolor, irep, offset;
4510 fd = fopen(
file,
"r+b");
4512 Error(
"ReadGIF",
"unable to open GIF file");
4517 filesize =
Seek_t(ftell(fd));
4520 if (!(GIFarr = (
unsigned char *)
calloc(filesize + 256, 1))) {
4522 Error(
"ReadGIF",
"unable to allocate array for gif");
4526 if (fread(GIFarr, filesize, 1, fd) != 1) {
4528 Error(
"ReadGIF",
"GIF file read failed");
4539 if (!(PIXarr = (
unsigned char *)
calloc((
width * height), 1))) {
4540 Error(
"ReadGIF",
"unable to allocate array for image");
4552 for (i = 0; i < ncolor; i++) {
4562 for (i = 1; i <= height / 2; i++) {
4563 j1 = PIXarr + (i - 1) *
width;
4564 j2 = PIXarr + (height - i) *
width;
4565 for (k = 0; k <
width; k++) {
4573 PutImage(offset, -1, x0, y0,
width, height, 0, 0,
width-1, height-1, PIXarr, pic);
4575 if (pic)
return pic;
4588 gdk_window_show((GdkWindow *)
id);
4589 if ((GDK_DRAWABLE_TYPE((GdkWindow *)
id) != GDK_WINDOW_TEMP) &&
4591 HWND window = (HWND)GDK_DRAWABLE_XID((GdkWindow *)
id);
4592 ::SetForegroundWindow(window);
4603 EnumChildWindows((HWND)GDK_DRAWABLE_XID((GdkWindow *)
id),
4604 EnumChildProc, (LPARAM) NULL);
4614 HWND hwnd = ::GetForegroundWindow();
4615 HWND window = (HWND)GDK_DRAWABLE_XID((GdkWindow *)
id);
4616 gdk_window_show((GdkWindow *)
id);
4617 if (GDK_DRAWABLE_TYPE((GdkWindow *)
id) != GDK_WINDOW_TEMP) {
4618 ::BringWindowToTop(window);
4619 if (GDK_DRAWABLE_TYPE((GdkWindow *)
id) != GDK_WINDOW_CHILD)
4620 ::SetForegroundWindow(window);
4626 HWND fore = ::GetForegroundWindow();
4627 ::GetWindowRect(fore, &r2);
4628 if (!::IntersectRect(&r3, &r2, &r1)) {
4641 gdk_window_hide((GdkWindow *)
id);
4653 gdk_window_hide((GdkWindow *)
id);
4654 gdk_window_destroy((GdkDrawable *)
id,
kTRUE);
4664 gdk_window_destroy((GdkDrawable *)
id,
kFALSE);
4674 HWND window = (HWND)GDK_DRAWABLE_XID((GdkWindow *)
id);
4675 if (GDK_DRAWABLE_TYPE((GdkWindow *)
id) == GDK_WINDOW_TEMP) {
4676 ::SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0,
4677 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
4680 ::BringWindowToTop(window);
4681 if (GDK_DRAWABLE_TYPE((GdkWindow *)
id) != GDK_WINDOW_CHILD)
4682 ::SetForegroundWindow(window);
4693 HWND window = (HWND)GDK_DRAWABLE_XID((GdkWindow *)
id);
4694 ::SetWindowPos(window, HWND_BOTTOM, 0, 0, 0, 0,
4695 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
4705 gdk_window_move((GdkDrawable *)
id,
x,
y);
4716 gdk_window_move_resize((GdkWindow *)
id,
x,
y, w,
h);
4729 gdk_window_resize((GdkWindow *)
id, w,
h);
4739 gdk_window_lower((GdkWindow *)
id);
4751 gdk_window_reparent((GdkWindow *)
id, (GdkWindow *)pid,
x,
y);
4763 back.red = GetRValue(color);
4764 back.green = GetGValue(color);
4765 back.blue = GetBValue(color);
4767 gdk_window_set_background((GdkWindow *)
id, &back);
4777 gdk_window_set_back_pixmap((GdkWindow *)
id, (GdkPixmap *) pxm, 0);
4789 GdkWindowAttr xattr;
4791 GdkColor background_color;
4796 xattr.window_type = GDK_WINDOW_CHILD;
4798 xattr.window_type = GDK_WINDOW_TOPLEVEL;
4801 xattr.window_type = GDK_WINDOW_DIALOG;
4804 xattr.window_type = GDK_WINDOW_TEMP;
4806 newWin = gdk_window_new((GdkWindow *) parent, &xattr, xmask);
4810 xattr.wclass = GDK_INPUT_OUTPUT;
4811 xattr.event_mask = 0
L;
4812 xattr.event_mask |= GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK |
4813 GDK_PROPERTY_CHANGE_MASK;
4825 xattr.colormap = gdk_colormap_get_system();
4826 xattr.cursor = NULL;
4827 xattr.override_redirect =
TRUE;
4828 if ((xattr.y > 0) && (xattr.x > 0)) {
4829 xmask = GDK_WA_X | GDK_WA_Y | GDK_WA_COLORMAP |
4830 GDK_WA_WMCLASS | GDK_WA_NOREDIR;
4832 xmask = GDK_WA_COLORMAP | GDK_WA_WMCLASS | GDK_WA_NOREDIR;
4834 if (visual != NULL) {
4835 xattr.visual = (GdkVisual *) visual;
4836 xmask |= GDK_WA_VISUAL;
4838 xattr.visual = gdk_visual_get_system();
4839 xmask |= GDK_WA_VISUAL;
4841 xattr.window_type = GDK_WINDOW_CHILD;
4843 xattr.window_type = GDK_WINDOW_TOPLEVEL;
4846 xattr.window_type = GDK_WINDOW_DIALOG;
4849 xattr.window_type = GDK_WINDOW_TEMP;
4851 newWin = gdk_window_new((GdkWindow *) parent, &xattr, xmask);
4852 gdk_window_set_events(newWin, (GdkEventMask) 0
L);
4855 gdk_window_set_decorations(newWin,
4856 (GdkWMDecoration) GDK_DECOR_BORDER);
4861 gdk_window_set_back_pixmap(newWin, (GdkPixmap *) GDK_NONE, 0);
4863 gdk_window_set_back_pixmap(newWin, (GdkPixmap *) GDK_NONE, 1);
4865 gdk_window_set_back_pixmap(newWin,
4866 (GdkPixmap *) attr->
4867 fBackgroundPixmap, 0);
4875 gdk_window_set_background(newWin, &background_color);
4879 ::SetClassLong((HWND)GDK_DRAWABLE_XID(newWin), GCL_HCURSOR,
4893 lxemask |= GDK_KEY_PRESS_MASK;
4896 lxemask |= GDK_KEY_RELEASE_MASK;
4899 lxemask |= GDK_BUTTON_PRESS_MASK;
4902 lxemask |= GDK_BUTTON_RELEASE_MASK;
4905 lxemask |= GDK_POINTER_MOTION_MASK;
4908 lxemask |= GDK_BUTTON_MOTION_MASK;
4911 lxemask |= GDK_EXPOSURE_MASK;
4914 lxemask |= GDK_STRUCTURE_MASK;
4917 lxemask |= GDK_ENTER_NOTIFY_MASK;
4920 lxemask |= GDK_LEAVE_NOTIFY_MASK;
4923 lxemask |= GDK_FOCUS_CHANGE_MASK;
4925 xemask = (
UInt_t) lxemask;
4928 if ((xemask & GDK_KEY_PRESS_MASK)) {
4931 if ((xemask & GDK_KEY_RELEASE_MASK)) {
4934 if ((xemask & GDK_BUTTON_PRESS_MASK)) {
4937 if ((xemask & GDK_BUTTON_RELEASE_MASK)) {
4940 if ((xemask & GDK_POINTER_MOTION_MASK)) {
4943 if ((xemask & GDK_BUTTON_MOTION_MASK)) {
4946 if ((xemask & GDK_EXPOSURE_MASK)) {
4949 if ((xemask & GDK_STRUCTURE_MASK)) {
4952 if ((xemask & GDK_ENTER_NOTIFY_MASK)) {
4955 if ((xemask & GDK_LEAVE_NOTIFY_MASK)) {
4958 if ((xemask & GDK_FOCUS_CHANGE_MASK)) {
4969 GdkWindowAttr & xattr)
4975 xmask |= GDK_WA_NOREDIR;
4981 xattr.event_mask = xmsk;
4984 xmask |= GDK_WA_COLORMAP;
4985 xattr.colormap = (GdkColormap *) attr->
fColormap;
4988 xmask |= GDK_WA_CURSOR;
4990 xattr.cursor = (GdkCursor *) attr->
fCursor;
4993 xattr.wclass = GDK_INPUT_OUTPUT;
5009 xmask |= GDK_GC_FUNCTION;
5012 xgval.function = GDK_CLEAR;
5015 xgval.function = GDK_AND;
5018 xgval.function = GDK_AND_REVERSE;
5021 xgval.function = GDK_COPY;
5024 xgval.function = GDK_AND_INVERT;
5027 xgval.function = GDK_NOOP;
5030 xgval.function = GDK_XOR;
5033 xgval.function = GDK_OR;
5036 xgval.function = GDK_EQUIV;
5039 xgval.function = GDK_INVERT;
5042 xgval.function = GDK_OR_REVERSE;
5045 xgval.function = GDK_COPY_INVERT;
5048 xgval.function = GDK_OR_INVERT;
5051 xgval.function = GDK_NAND;
5054 xgval.function = GDK_SET;
5059 xmask |= GDK_GC_SUBWINDOW;
5061 xgval.subwindow_mode = GDK_INCLUDE_INFERIORS;
5063 xgval.subwindow_mode = GDK_CLIP_BY_CHILDREN;
5067 xmask |= GDK_GC_FOREGROUND;
5069 xgval.foreground.red = GetRValue(gval.
fForeground);
5070 xgval.foreground.green = GetGValue(gval.
fForeground);
5071 xgval.foreground.blue = GetBValue(gval.
fForeground);
5074 xmask |= GDK_GC_BACKGROUND;
5076 xgval.background.red = GetRValue(gval.
fBackground);
5077 xgval.background.green = GetGValue(gval.
fBackground);
5078 xgval.background.blue = GetBValue(gval.
fBackground);
5081 xmask |= GDK_GC_LINE_WIDTH;
5085 xmask |= GDK_GC_LINE_STYLE;
5086 xgval.line_style = (GdkLineStyle) gval.
fLineStyle;
5089 xmask |= GDK_GC_CAP_STYLE;
5090 xgval.cap_style = (GdkCapStyle) gval.
fCapStyle;
5093 xmask |= GDK_GC_JOIN_STYLE;
5094 xgval.join_style = (GdkJoinStyle) gval.
fJoinStyle;
5097 xmask |= GDK_GC_FILL;
5101 xmask |= GDK_GC_TILE;
5102 xgval.tile = (GdkPixmap *) gval.
fTile;
5105 xmask |= GDK_GC_STIPPLE;
5106 xgval.stipple = (GdkPixmap *) gval.
fStipple;
5109 xmask |= GDK_GC_TS_X_ORIGIN;
5113 xmask |= GDK_GC_TS_Y_ORIGIN;
5117 xmask |= GDK_GC_FONT;
5118 xgval.font = (GdkFont *) gval.
fFont;
5121 xmask |= GDK_GC_EXPOSURES;
5125 xmask |= GDK_GC_CLIP_X_ORIGIN;
5129 xmask |= GDK_GC_CLIP_Y_ORIGIN;
5133 xmask |= GDK_GC_CLIP_MASK;
5134 xgval.clip_mask = (GdkPixmap *) gval.
fClipMask;
5140 if ((xmask & GDK_GC_FUNCTION)) {
5143 switch (xgval.function) {
5150 case GDK_AND_REVERSE:
5156 case GDK_AND_INVERT:
5174 case GDK_OR_REVERSE:
5177 case GDK_COPY_INVERT:
5191 if (xmask & GDK_GC_SUBWINDOW) {
5193 if (xgval.subwindow_mode == GDK_INCLUDE_INFERIORS)
5198 if ((xmask & GDK_GC_FOREGROUND)) {
5202 if ((xmask & GDK_GC_BACKGROUND)) {
5206 if ((xmask & GDK_GC_LINE_WIDTH)) {
5210 if ((xmask & GDK_GC_LINE_STYLE)) {
5214 if ((xmask & GDK_GC_CAP_STYLE)) {
5218 if ((xmask & GDK_GC_JOIN_STYLE)) {
5222 if ((xmask & GDK_GC_FILL)) {
5226 if ((xmask & GDK_GC_TILE)) {
5230 if ((xmask & GDK_GC_STIPPLE)) {
5234 if ((xmask & GDK_GC_TS_X_ORIGIN)) {
5238 if ((xmask & GDK_GC_TS_Y_ORIGIN)) {
5242 if ((xmask & GDK_GC_FONT)) {
5246 if ((xmask & GDK_GC_EXPOSURES)) {
5250 if ((xmask & GDK_GC_CLIP_X_ORIGIN)) {
5254 if ((xmask & GDK_GC_CLIP_Y_ORIGIN)) {
5258 if ((xmask & GDK_GC_CLIP_MASK)) {
5273 RECT rcClient, rcWind;
5274 ::GetClientRect((HWND)GDK_DRAWABLE_XID((GdkWindow *)
id), &rcClient);
5275 ::GetWindowRect((HWND)GDK_DRAWABLE_XID((GdkWindow *)
id), &rcWind);
5277 gdk_window_get_geometry((GdkWindow *)
id, &attr.
fX, &attr.
fY,
5279 attr.
fX = ((rcWind.right - rcWind.left) - rcClient.right) / 2;
5280 attr.
fY = ((rcWind.bottom - rcWind.top) - rcClient.bottom) - attr.
fX;
5285 attr.
fVisual = gdk_window_get_visual((GdkWindow *)
id);
5292 if (!gdk_window_is_visible((GdkWindow *)
id)) {
5294 }
else if (!gdk_window_is_viewable((GdkWindow *)
id)) {
5300 UInt_t tmp_mask = (
UInt_t)gdk_window_get_events((GdkWindow *)
id);
5320 return gdk_visual_get_best_depth();
5330 GdkAtom
a = gdk_atom_intern((
const gchar *) atom_name, only_if_exist);
5332 if (
a == None)
return kNone;
5342 return (
Window_t) GDK_ROOT_PARENT();
5352 return (
Window_t)gdk_window_get_parent((GdkWindow *)
id);
5362 char family[100], weight[32], slant[32], fontname[256];
5363 Int_t n1, pixel, numfields;
5365 numfields = sscanf(font_name,
"%s -%d%n", family, &pixel, &n1);
5366 if (numfields == 2) {
5367 sprintf(weight,
"medium");
5368 if (strstr(font_name,
"bold"))
5369 sprintf(weight,
"bold");
5371 if (strstr(font_name,
"italic"))
5373 sprintf(fontname,
"-*-%s-%s-%s-*-*-%d-*-*-*-*-*-iso8859-1",
5374 family, weight, slant, pixel);
5377 sprintf(fontname,
"%s", font_name);
5387 return (
FontH_t)gdk_font_ref((GdkFont *) fs);
5397 gdk_font_unref((GdkFont *) fs);