Native Window Driver (cdnative.h)
This driver provides access to an existing Native Window, a basic element of the user-interface system.
Use
The canvas is created by means of a call to the function cdCreateCanvas(CD_NATIVEWINDOW, Data), after which other functions in the CD library can be called as usual. This function creates a CD canvas based on an existing system canvas. The parameter Data is a pointer to a handle of the canvas. It is system-dependent, having a different meaning in each platform:
Microsoft Windows: can be the handle of the Windows window (HWND) or the handle of a previously created Device Context (HDC), or can be a string in the format "hdc width height" or, in C, "%p %d %d".
X-Windows: "display window" or, in C, "%p %lu" (uses the default screen).The string has the same format as the IUP attribute CONID, so it is possible to create a canvas using this driver, but based on a IUP canvas. Therefore, it is no longer necessary to use the IUP driver. For instance:
cdCreateCanvas(CD_NATIVEWINDOW, IupGetAttribute(myIupCanvas, "CONID")).
IupSetAttribute(myIupCanvas, "_CD_CANVAS", myCdCanvas);Any amount of such canvases may exist simultaneously, but they should not use the same window. It is important to note that a call to function cdKillCanvas is required to close the file properly.
In CDLUA, the creation parameter must be a string in X-Windows and a userdata in Microsoft Windows.
Exclusive Functions
void cdGetScreenSize(int *width, int *height, double
*width_mm, double *height_mm); [in C]
cdGetScreenSize()
-> (width, heigth, mm_width, mm_height: number)
[in Lua]
Equivalent to function cdGetCanvasSize, but returns the values relative to the main screen of the window system.
int cdGetScreenColorPlanes(void); [in C]
cdGetScreenColorPlanes() -> (bpp: number) [in Lua]
Equivalent to function cdGetColorPlanes, but returns the value relative to the main screen of the window system.
Behavior of Functions
This driver is greatly platform-dependent. For further detail, see the Behavior of Functions in each platform: Macintosh (QuickDraw), Microsoft Windows (GDI), Windows Using GDI+, X-Windows (XLIB). However, it should be noted that some functions behave differently from the basic functions of each platform.
Control
- cdActivate: updates the canvas size; it might have been resized.