Microsoft Windows Base Driver
This driver represents a base driver for all system-dependent drivers implemented in the Microsoft Windows system. The implementation uses Win32 API graphics functions, the GDI. The driver works better in Windows NT, but it may also work in Windows 9x/Me.
Behavior of Functions
Control
Coordinate System and Clipping
- cdUpdateYAxis: the orientation of axis Y is the opposite to its orientation in the CD library.
Primitives
- cdMark: is simulated.
- cdText: when Write Mode is XOR or NOT_XOR, the XOR effect is simulated using bitmaps.
- cdLine: needs to draw an extra pixel in the final position.
Attributes
- cdWriteMode: for the client and server image functions, the mode NOT_XOR works as XOR.
- cdStipple: is always opaque. If not in Windows NT and if width or height are greater than 8, the stipple is simulated using non-regular Windows clipping regions and bitmaps. The simulation is made when filled boxes, sectors and polygons are drawn.
- cdPattern: If not in Windows NT and if width or height are greater than 8, the pattern is simulated using non-regular Windows clipping regions and bitmaps. The simulation is made when filled boxes, sectors and polygons are drawn.
- cdTextAlignment: the vertical alignment of CD_CENTER, CD_EAST, CD_WEST is manually calculated.
- cdLineWidth: If not in Windows NT line width is always 1. If line width is 1, then a cosmetic pen is used for fast drawing.
- cdLineStyle: If line width is 1, the style is a little different from when line width is not 1, because a cosmetic pen is used for width=1.
-
cdNativeFont: the font string
describer has the following format:
"fontname, size [style] [-k] [-u]", where fontname is the name of the font in Windows (notice the comma after the font name), size is given in points or in pixels, style is the same as cdFont, -u means underline and -k means strikethrough, or "-d" to show the font-selection dialogue box. However, this function also accepts the font string used by the WINFONT attribute of the IUP library. - cdFont: see the font mapping table for the equivalence used to map CD fonts into Windows fonts:
CD Fonts | Windows Fonts |
---|---|
CD_SYSTEM | System |
CD_COURIER | Courier New |
CD_TIMES_ROMAN | Times New Roman |
CD_HELVETICA | Arial |
Client Images
- cdPutImageRGBA: Try to use the new GDI function AlphaBlend, if not available captures an image from the canvas to blend it manually.
Colors
- cdPalette: is useful only if the device has 256 colors. If it has less than 256 colors, ignore this function, for it will not make much difference. If two different canvases have their palettes modified, the last one to be modified will have the best quality; the other one will not have good quality and the colors might have a completely different appearance.
Exclusive Attributes
- "HDC": returns the HDC of the Win32 canvas. It can only be retrieved (get only). In Lua is returned as a user data.
- "SIMXORTEXT": controls the internal XOR simulation for text. Assumes values "1" (active) and "0" (inactive). Default value: "1". When a text is drawn with write mode XOR it must be simulated. Using this attribute you can disable the simulation, but XOR will not work for cdText.
- "SIMPATTERN8X8": controls the internal pattern and stipple simulation. Assumes values "1" (active) and "0" (inactive). Default value: "1". When patterns and stipples are used If not in Windows NT and they have size different of 8x8, then they must be simulated. Using this attribute you can disable the simulation, but patterns and stipple are restricted to 8x8 size in non Windows NT systems.
- "PENFILLPOLY": controls the polygon filling outline. Assumes values "1" (active) and "0" (inactive). Default value: "1". When a filled polygon is drawn, a line in the same color is used to draw the border which is not included in the filling. Deactivating this attribute solves the problem of polygons with holes, in which there is a line connecting the external polygon to the internal polygon.
- "IMAGEFORMAT": defines the number of bits per pixel used to create server images. It uses 1 integer that can have the values: "32" or "24" (%d). Use NULL to remove the attribute. It is used only in the cdCreateImage. When not defined, the server images use the same format of the canvas.
- "IMAGEALPHA": allows the usage of an alpha channel for server images if also IMAGEFORMAT=32. The attribute format is a pointer to the transparency values in a sequence of chars in the same format of alpha for client images. The attribute is used only in the cdCreateImage, but the pointer must exists while the image exists. The alpha values are transfered to the image only in cdPutImageRect, so they can be freely changed any time. It will use the AlphaBlend GDI function. The data is not duplicated, only the pointer is stored. The size of the data must be the same size of the image. Use NULL to remove the attribute. Not accessible in Lua. Unsupported in non Windows NT systems.
- "IMAGEMASK": defines a binary transparency mask for server images. The format is the same of a stipple, can contain only 0s and 1s. Use 2 integers, width and height, and a char pointer to the mask values inside a string ("%d %d %p"). Use NULL to remove the attribute. It can not be retrieved (set only). Not accessible in Lua. It will use the MaskBlt GDI function. Unsupported in non Windows NT systems.
- "IMAGEPOINTS": define 3 coordinates of a paralelogram that will be used to warp server images. Use 6 integer values inside a string ("%d %d %d %d %d %d" = x1 y1 x2 y2 x3 y3). Use NULL to remove the attribute. The respective specified points are the upper-left corner, the upper-right corner and the lower left corner. The drawing is also affected by the "IMAGEMASK" attribute. It will use the PlgBlt GDI function. Unsupported in non Windows NT systems.
- "ROTATE": allows the usage of 1 angle and 1 coordinate (x, y), that define a global rotation transformation centered in the specified coordinate. Use 1 real and 2 integer values inside a string ("%g %d %d" = angle x y). Unsupported in non Windows NT systems.