77 #include <X11/cursorfont.h> 80 #include <X11/keysymdef.h> 84 #include "pixmap_helper.h" 88 static XImage *__internalGetClipImage(
WBGC hGC)
91 Display *display = hGC->
display;
92 const XGCValues *pGCValues = &(hGC->
values);
95 if(pGCValues->clip_mask != None)
97 Window winRoot = None;
99 unsigned int iWidth0=0, iHeight0=0, iBorder;
100 unsigned int uiDepth = 0;
106 XGetGeometry(display, pGCValues->clip_mask, &winRoot, &iX0, &iY0, &iWidth0, &iHeight0, &iBorder, &uiDepth);
116 pRval =
WBXGetImage(display, pGCValues->clip_mask, 0, 0, iWidth0, iHeight0, 1, XYPixmap);
129 #error not ready for WIN32 yet 146 iRval = XDrawPoint(display, d, gc->
gc, x, y);
161 int npoints,
int mode)
166 #error not ready for WIN32 yet 183 iRval = XDrawPoints(display, d, gc->
gc, points, npoints, mode);
198 int x1,
int y1,
int x2,
int y2)
203 #error not ready for WIN32 yet 220 iRval = XDrawLine(display, d, gc->
gc, x1, y1, x2, y2);
235 int npoints,
int mode)
240 #error not ready for WIN32 yet 257 iRval = XDrawLines(display, d, gc->
gc, points, npoints, mode);
262 iRval =
WBXDrawLines(pImage, gc, points, npoints, mode);
272 unsigned int width,
unsigned int height)
277 #error not ready for WIN32 yet 294 iRval = XDrawRectangle(display, d, gc->
gc, x, y, width, height);
309 unsigned int width,
unsigned int height)
314 #error not ready for WIN32 yet 331 iRval = XFillRectangle(display, d, gc->
gc, x, y, width, height);
346 unsigned int width,
unsigned int height,
347 int angle1,
int angle2)
352 #error not ready for WIN32 yet 369 iRval = XDrawArc(display, d, gc->
gc, x, y, width, height, angle1, angle2);
374 iRval =
WBXDrawArc(pImage, gc, x, y, width, height, angle1, angle2);
384 unsigned int width,
unsigned int height,
385 int angle1,
int angle2)
390 #error not ready for WIN32 yet 407 iRval = XFillArc(display, d, gc->
gc, x, y, width, height, angle1, angle2);
412 iRval =
WBXFillArc(pImage, gc, x, y, width, height, angle1, angle2);
422 int npoints,
int shape,
int mode)
427 #error not ready for WIN32 yet 444 iRval = XFillPolygon(display, d, gc->
gc, points, npoints, shape, mode);
459 const char *
string,
int length)
464 #error not ready for WIN32 yet 488 memcpy(pTemp,
string, length);
492 #ifdef X11WORKBENCH_TOOLKIT_HAVE_XFT 496 #warning TODO: IMPLEMENT THIS PART for Xft FONTS 499 #endif // X11WORKBENCH_TOOLKIT_HAVE_XFT 503 "%s.%d using WB_DRAW_STRING for \"%-.*s\" color=#%08lxH bkgnd=#%08lxH\n",
504 __FUNCTION__, __LINE__, length, pTemp,
522 (
GCAll & ~(GCClipMask | GCDashList)),
529 "%s.%d using XDrawString for \"%-.*s\" color=#%08lxH bkgnd=#%08lxH\n",
530 __FUNCTION__, __LINE__, length, pTemp,
534 iRval = XDrawString(display, d, gc->
gc, x, y, pTemp, length);
566 const XGCValues *values)
587 memset(pRval, 0,
sizeof(*pRval));
590 if(valuemask && values)
592 memcpy(&(pRval->
values), values,
sizeof(pRval->
values));
600 pRval->
gc = XCreateGC(pDisplay, dw, valuemask, valuemask && values ? &(pRval->
values) : NULL);
603 if(pRval->
gc == None)
613 XGetGCValues(pDisplay, pRval->
gc,
614 (
GCAll & ~(GCClipMask | GCDashList)),
622 if((CARD32)pRval->
values.font & 0xe0000000)
624 pRval->
values.font = None;
627 if((CARD32)pRval->
values.tile & 0xe0000000)
629 pRval->
values.tile = None;
632 if((CARD32)pRval->
values.stipple & 0xe0000000)
634 pRval->
values.stipple = None;
638 if((CARD32)pRval->
values.clip_mask & 0xe0000000)
640 WB_ERROR_PRINT(
"ERROR - %s - hGCDest->values.clip_mask not valid, %d (%08xH)\n",
641 __FUNCTION__, (
int)pRval->
values.clip_mask, (
int)pRval->
values.clip_mask);
643 pRval->
values.clip_mask = None;
649 if(values && (valuemask & GCClipMask) && values->clip_mask != None)
651 if(values->clip_mask & 0xe0000000)
653 WB_ERROR_PRINT(
"ERROR - %s - values 'clip_mask' not valid, %d (%08xH)\n",
654 __FUNCTION__, (
int)values->clip_mask, (
int)values->clip_mask);
656 pRval->
values.clip_mask = None;
661 pRval->
values.clip_mask = values->clip_mask;
665 pRval->
clip_image = __internalGetClipImage(pRval);
667 pRval->
values.clip_mask = None;
677 const XGCValues *values)
685 if(valuemask & GCDashList)
687 hGC->
values.dashes = values->dashes;
690 if(valuemask & GCFont)
710 if(valuemask & GCTile)
722 if(valuemask & GCStipple)
740 if(valuemask & GCClipMask)
745 #warning if I am NOT making a copy and assign anyway, will the ref count be messed up??? 747 if(hGC->
values.clip_mask != None)
753 hGC->
values.clip_mask = None;
756 if(hGC->
clip_image && (!values || values->clip_mask != hGC->
values.clip_mask))
779 memcpy(&valtemp, values,
sizeof(valtemp));
782 iRval = XChangeGC(hGC->
display, hGC->
gc, valuemask, &valtemp);
784 (
GCAll & ~(GCClipMask | GCDashList)),
792 if((CARD32)hGC->
values.font & 0xe0000000)
797 if((CARD32)hGC->
values.tile & 0xe0000000)
802 if((CARD32)hGC->
values.stipple & 0xe0000000)
804 hGC->
values.stipple = None;
808 if((CARD32)hGC->
values.clip_mask & 0xe0000000)
810 WB_ERROR_PRINT(
"ERROR - %s - hGCDest->values.clip_mask not valid, %d (%08xH)\n",
811 __FUNCTION__, (
int)hGC->
values.clip_mask, (
int)hGC->
values.clip_mask);
813 hGC->
values.clip_mask = None;
816 if(valuemask & GCClipMask)
827 hGC->
clip_image = __internalGetClipImage(hGC);
843 if(valuemask & GCClipMask)
845 if(values->clip_mask != None)
848 XFreePixmap(hGC->
display, values->clip_mask);
851 values->clip_mask = None;
855 if(valuemask & GCDashList)
861 rval = XGetGCValues(hGC->
display, hGC->
gc,
865 if((CARD32)values->font & 0xe0000000)
870 if((CARD32)values->tile & 0xe0000000)
875 if((CARD32)values->stipple & 0xe0000000)
877 values->stipple = None;
881 if((CARD32)values->clip_mask & 0xe0000000)
883 WB_ERROR_PRINT(
"ERROR - %s - values->clip_mask not valid, %d (%08xH)\n",
884 __FUNCTION__, (
int)values->clip_mask, (
int)values->clip_mask);
886 values->clip_mask = None;
888 else if(values->clip_mask & 0xffffffffe0000000LL)
890 WB_ERROR_PRINT(
"ERROR ERROR !!! - %s - values->clip_mask not valid, %d (%08xH)\n",
891 __FUNCTION__, (
int)values->clip_mask, (
int)values->clip_mask);
893 values->clip_mask = None;
896 if(valuemask & GCDashList)
899 values->dashes = hGC->
values.dashes;
915 if(!hGCOrig || hGCOrig->
gc == None)
917 WB_ERROR_PRINT(
"ERROR - %s - invalid source WBGC\n", __FUNCTION__);
921 if(hGCOrig->
dw == None)
923 WB_ERROR_PRINT(
"ERROR - %s - invalid (NULL) drawable in source WBGC\n", __FUNCTION__);
933 memset(pRval, 0,
sizeof(*pRval));
936 pRval->
dw = hGCOrig->
dw;
940 pRval->
gc = XCreateGC(pRval->
display, pRval->
dw, 0, NULL);
943 if(pRval->
gc == None)
962 if(!hGCOrig || !hGCDest || hGCOrig->
gc == None || hGCDest->
gc == None)
968 iRet = XCopyGC(hGCOrig->
display, hGCOrig->
gc, valuemask, hGCDest->
gc);
976 if(valuemask & GCFont)
985 hGCDest->
pFont = NULL;
997 if(valuemask & GCTile)
1006 if(valuemask & GCStipple)
1015 if(valuemask & GCClipMask)
1017 if(hGCDest->
values.clip_mask != None)
1043 if(valuemask & GCDashList)
1050 XGetGCValues(hGCDest->
display, hGCDest->
gc,
1051 (
GCAll & ~(GCClipMask | GCDashList)),
1064 if((CARD32)hGCDest->
values.tile & 0xe0000000)
1066 hGCDest->
values.tile = None;
1069 if((CARD32)hGCDest->
values.stipple & 0xe0000000)
1071 hGCDest->
values.stipple = None;
1075 if((CARD32)hGCDest->
values.clip_mask & 0xe0000000)
1077 WB_ERROR_PRINT(
"ERROR - %s - hGCDest->values.clip_mask not valid, %d (%08xH)\n",
1078 __FUNCTION__, (
int)hGCDest->
values.clip_mask, (
int)hGCDest->
values.clip_mask);
1080 else if(hGCDest->
values.clip_mask & 0xffffffffe0000000LL)
1082 WB_ERROR_PRINT(
"ERROR ERROR !!! - %s - hGCDest->values.clip_mask not valid, %d (%08xH)\n",
1083 __FUNCTION__, (
int)hGCDest->
values.clip_mask, (
int)hGCDest->
values.clip_mask);
1092 if(hGCOrig->
values.dashes != 0)
1099 if(valuemask & GCClipMask)
1120 if(valuemask & GCTile)
1133 if(valuemask & GCStipple)
1146 if(valuemask & GCFont)
1172 if(!hGCOrig || hGCOrig->
gc == None)
1177 if(pDisplay == NULL)
1193 memset(pRval, 0,
sizeof(*pRval));
1201 pRval->
gc = XCreateGC(pDisplay, dw, 0, NULL);
1204 if(pRval->
gc == None)
1227 if(hGC->
values.clip_mask != None)
1234 hGC->
values.clip_mask = None;
1298 rval = XGContextFromGC(hGC->
gc);
1339 pF = XQueryFont(pDisplay, gc->
values.font);
1343 unsigned long lName = 0;
1344 if(XGetFontProperty(pF, XA_FONT, &lName))
1349 gc->
pFont = XLoadQueryFont(pDisplay, pName);
1359 XFreeFontInfo(NULL, pF, 1);
1388 iRet = XSetRegion(hGC->
display, hGC->
gc, rgnClip);
1397 if(hGC->
values.clip_mask != None)
1404 hGC->
values.clip_mask = None;
1427 iRet = XSetClipOrigin(hGC->
display, hGC->
gc, clip_x_origin, clip_y_origin);
1430 hGC->
values.clip_x_origin = clip_x_origin;
1431 hGC->
values.clip_y_origin = clip_y_origin;
1441 iRet = XSetClipMask(hGC->
display, hGC->
gc, pixmap);
1469 iRet = XSetFunction(hGC->
display, hGC->
gc,
function);
1472 hGC->
values.function =
function;
1482 iRet = XSetForeground(hGC->
display, hGC->
gc, foreground);
1485 hGC->
values.foreground = foreground;
1495 iRet = XSetBackground(hGC->
display, hGC->
gc, background);
1498 hGC->
values.background = background;
1524 if(iRet && pNewFont)
1553 #warning verify that XSetFont returns a zero on success and then enable this check 1558 #warning verify that XSetFont returns a zero on success and then remove this next line 1566 int line_style,
int cap_style,
int join_style)
1571 iRet = XSetLineAttributes(hGC->
display, hGC->
gc, line_width, line_style, cap_style, join_style);
1574 hGC->
values.line_width = line_width;
1575 hGC->
values.line_style = line_style;
1576 hGC->
values.cap_style = cap_style;
1577 hGC->
values.join_style = join_style;
1597 memcpy(pDashList, dash_list, n);
1605 iRet = XSetDashes(hGC->
display, hGC->
gc, dash_offset, pDashList, n);
1608 if(pDashList != &c1)
XImage * clip_image
cached XImage for the GC, for 'clip mask'
int WBDrawPoints(Display *display, Drawable d, WBGC gc, XPoint *points, int npoints, int mode)
Wrapper for XDrawPoints()
int WBXDrawArc(XImage *pImage, WBGC hGC, int x, int y, unsigned int width, unsigned int height, int angle1, int angle2)
XImage version for XDrawArc()
XImage * tile_image
cached XImage for the GC, for 'tile'
int WBChangeGC(WBGC hGC, unsigned long valuemask, const XGCValues *values)
Change a WBGC, a wrapper for XChangeGC()
'window helper' main header file for the X11workbench Toolkit API
Display * display
the Display associated with the WBGC (NULL implies 'Default Display')
int WBDrawLine(Display *display, Drawable d, WBGC gc, int x1, int y1, int x2, int y2)
Wrapper for XDrawLines()
void WBFreeFont(Display *pDisplay, WB_FONT pFont)
free a WB_FONT that was created using one of the WBFont APIs
#define WB_DEBUG_PRINT(L,...)
Preferred method of implementing conditional debug output.
int WBXFillPolygon(XImage *pImage, WBGC hGC, XPoint *points, int npoints, int shape, int mode)
XImage version for XFillPolygon()
int WBSetLineAttributes(WBGC hGC, unsigned int line_width, int line_style, int cap_style, int join_style)
Assign font to a WBGC, a wrapper for XSetLineAttributes()
XImage * WBGetWindowImage(Display *pDisplay, Window wID)
Obtain an XImage for the entire window.
WB_FONT WBCopyFont(Display *pDisplay, WB_FONTC pOldFont)
make a copy of an existing font (best when assigning to a window)
int WBDrawPoint(Display *display, Drawable d, WBGC gc, int x, int y)
Wrapper for XDrawPoint()
static __inline__ unsigned long WBGetForeground(WBGC hGC)
Get the (cached) foreground color for a WBGC.
int WBXDrawRectangle(XImage *pImage, WBGC hGC, int x, int y, unsigned int width, unsigned int height)
XImage version for XDrawRectangle()
Drawable dw
the Drawable for which this WBGC was created (None implies default Window)
XImage * stip_image
cached XImage for the GC, for 'stipple'
int WBFillPolygon(Display *display, Drawable d, WBGC gc, XPoint *points, int npoints, int shape, int mode)
Wrapper for XFillPolygon()
WB_FONT pFont
cached default font
static __inline__ Display * WBGetDefaultDisplay(void)
Returns the default Display.
'configuration helper' main header file for the X11 Work Bench Toolkit API
int WBXFillRectangle(XImage *pImage, WBGC hGC, int x, int y, unsigned int width, unsigned int height)
XImage version for XFillRectangle()
Region WBCopyRegion(Region rgnSource)
Simple utility to copy a region.
#define GCAll
A bit mask for ALL GC properties (used when copying a GC)
int WBSetFont(WBGC hGC, WB_FONTC pFont)
Assign font to a WBGC, a wrapper for XSetFont()
int WBDrawString(Display *display, Drawable d, WBGC gc, int x, int y, const char *string, int length)
wrapper for XDrawString()
int WBXDrawLine(XImage *pImage, WBGC hGC, int x1, int y1, int x2, int y2)
XImage version for XDrawLines()
XImage * WBXCopyImage(Display *pDisplay, XImage *pImage)
Make a copy of an XImage.
int WBSetForeground(WBGC hGC, unsigned long foreground)
Assign foreground color, a wrapper for XSetForeground()
int WBDrawArc(Display *display, Drawable d, WBGC gc, int x, int y, unsigned int width, unsigned int height, int angle1, int angle2)
Wrapper for XDrawArc()
int WBDrawRectangle(Display *display, Drawable d, WBGC gc, int x, int y, unsigned int width, unsigned int height)
Wrapper for XDrawRectangle()
int WBDrawLines(Display *display, Drawable d, WBGC gc, XPoint *points, int npoints, int mode)
Wrapper for XDrawLine()
void * WBAlloc(int nSize)
High performance memory sub-allocator 'allocate'.
#define END_XCALL_DEBUG_WRAPPER
wrapper macro for calls into the X11 library. This macro follows the call(s)
GContext WBGContextFromGC(WBGC hGC)
Free resources for a WBGC, wrapper for XGContextFromGC()
int WBSetFontNoCopy(WBGC hGC, WB_FONT pFont)
Assign font to a WBGC, a wrapper for XSetFont()
int WBSetRegion(WBGC hGC, Region rgnClip)
Assign clipping region, wrapper for XSetRegion()
int WBXDrawPoint(XImage *pImage, WBGC hGC, int x, int y)
XImage version for XDrawPoint()
int WBXDrawString(XImage *pImage, WB_FONTC pFont, WBGC hGC, int x, int y, const char *string, int length)
XImage version for XDrawString() or DTDrawString()
WBGC WBCopyGC(WBGC hGCOrig)
makes a copy of a WBGC, a more sensible wrapper for XCopyGC()
int WBFillArc(Display *display, Drawable d, WBGC gc, int x, int y, unsigned int width, unsigned int height, int angle1, int angle2)
Wrapper for XFillArc()
#define WB_ERROR_PRINT(...)
Preferred method of implementing an 'error level' debug message for all subsystems.
Window WBGetHiddenHelperWindow(void)
Returns a special 'hidden' window used for information purposes.
int WBXDrawPoints(XImage *pImage, WBGC hGC, XPoint *points, int npoints, int mode)
XImage version for XDrawPoints()
void WBFree(void *pBuf)
High performance memory sub-allocator 'free'.
XGCValues values
cached XGCValues for the GC
WBGC WBCreateGC(Display *pDisplay, Drawable dw, unsigned long valuemask, const XGCValues *values)
Creates a WBGC, wrapper for XCreateGC()
int WBCopyGC2(WBGC hGCOrig, unsigned long valuemask, WBGC hGCDest)
makes a copy of a WBGC, a wrapper for XCopyGC()
int WBSetClipMask(WBGC hGC, Pixmap pixmap)
Set clip mask, a wrapper for XSetClipMask()
static __inline__ unsigned long WBGetBackground(WBGC hGC)
Get the (cached) background color for a WBGC.
XImage * WBXGetImage(Display *pDisplay, Drawable dw, int x, int y, unsigned int width, unsigned int height, unsigned long plane_mask, int format)
Read contents of a Drawable onto an XImage.
XFontSet fsFont
legacy 'XFontSet' for X11 raster fonts (UTF-8)
WB_FONT WBGetGCFont(Display *pDisplay, WBGC gc)
return a copy of the WB_FONT object that was assigned to a WBGC
int WBXDestroyImage(XImage *pImage)
Destroy an XImage - call this instead of XDestroyImage()
XFontStruct * pFontStruct
legacy 'XFontStruct' for X11 raster fonts
int WBSetClipOrigin(WBGC hGC, int clip_x_origin, int clip_y_origin)
Set clip origin, a wrapper for XSetClipOrigin()
Display * WBGetWindowDisplay(Window wID)
returns the Display associated with a window
void WBFreeGC(WBGC hGC)
Free resources for a WBGC, wrapper for XFreeGC()
Status WBGetGCValues(WBGC hGC, unsigned long valuemask, XGCValues *values)
Change a WBGC, a wrapper for XGetGCValues()
#define BEGIN_XCALL_DEBUG_WRAPPER
wrapper macro for calls into the X11 library. This macro precedes the call(s)
struct s_WBGC * WBGC
internal wrapper struct for GC with local cache
WBGC WBCopyDrawableGC(Display *pDisplay, Drawable dw, WBGC hGCOrig)
makes a copy of the specified WBGC for the desired 'Drawable'
Region clip_rgn
clipping region (or None to use clip_image) - owned by the object
int WBXDrawLines(XImage *pImage, WBGC hGC, XPoint *points, int npoints, int mode)
XImage version for XDrawLine()
int WBFillRectangle(Display *display, Drawable d, WBGC gc, int x, int y, unsigned int width, unsigned int height)
Wrapper for XFillRectangle()
int WBSetBackground(WBGC hGC, unsigned long background)
Assign background color, a wrapper for XSetBackground()
An allocated structure containing XFontStruct, XFontInfo, and XftFont [as applicable] for a specified...
internal wrapper struct for GC with local cache
int WBSetDashes(WBGC hGC, int dash_offset, const char dash_list[], int n)
Assign font to a WBGC, a wrapper for XSetFont()
Pixmap PXM_CopyPixmap(Display *pDisplay, Drawable dw, Pixmap pxSource)
Copy a pixmap for the specified Display and Drawable.
int WBXFillArc(XImage *pImage, WBGC hGC, int x, int y, unsigned int width, unsigned int height, int angle1, int angle2)
XImage version for XFillArc()
int WBSetFunction(WBGC hGC, int function)
Set the 'function' for the WBGC, a wrapper for XSetFunction()
WB_FONTC WBQueryGCFont(WBGC gc)
return the WB_FONTC object that was assigned to a WBGC
WB_FONTC WBGetDefaultFont(void)
Returns a pointer to the default font WB_FONT for the default display. This is a shared resource; do ...