1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/** \file
* \brief IUP Driver
*
* See Copyright Notice in "iup.h"
*/
#include <stdlib.h>
#include <stdio.h>
#include "iup.h"
#include <cd.h>
#include <cd_private.h>
#include <cdiup.h>
#include <cdnative.h>
static void (*cdcreatecanvasNATIVE)(cdCanvas* canvas, void* data) = NULL;
static void cdcreatecanvasIUP(cdCanvas* canvas, Ihandle *ih_canvas)
{
#ifndef WIN32
char str[50] = "";
#endif
char* data;
if (IupGetInt(ih_canvas, "CD_GDK"))
data = IupGetAttribute(ih_canvas, "DRAWABLE"); /* new IUP 3 attribute, works for GTK only */
else
{
#ifdef WIN32
data = IupGetAttribute(ih_canvas, "HWND"); /* new IUP 3 attribute, works for Windows and GTK */
if (!data)
data = IupGetAttribute(ih_canvas, "WID"); /* OLD IUP 2 attribute */
if (!data)
return;
#else
void *dpy = IupGetAttribute(ih_canvas, "XDISPLAY"); /* works for Motif and GTK */
unsigned long wnd = (unsigned long)IupGetAttribute(ih_canvas, "XWINDOW");
if (!wnd || !dpy)
return;
data = str;
#ifdef SunOS_OLD
sprintf(str, "%d %lu", (int)dpy, wnd);
#else
sprintf(str, "%p %lu", dpy, wnd);
#endif
#endif
}
/* Inicializa driver NativeWindow */
cdcreatecanvasNATIVE(canvas, data);
IupSetAttribute(ih_canvas, "_CD_CANVAS", (char*)canvas);
}
static cdContext cdIupContext;
cdContext* cdContextIup(void)
{
/* call cdContextNativeWindow every time, because of ContextPlus */
cdContext* ctx = cdContextNativeWindow();
cdcreatecanvasNATIVE = ctx->cxCreateCanvas;
cdIupContext = *ctx;
cdIupContext.cxCreateCanvas = cdcreatecanvasIUP;
return &cdIupContext;
}
|