66 #include "pixmap_helper.h" 95 const WB_RECT *prcSource,
WB_RECT *prcDest,
int iAlignment,
int iStartLine,
int iEndLine);
101 static void __internalDoAntiAlias(Display *pDisplay, Drawable dw,
WBGC gc,
int iX,
int iY,
int iWidth,
int iHeight);
112 WBGC gc,
int x,
int y,
const char *pString,
int nLength)
129 if(!pDisplay || !pString || drawable == None || !pFont || !gc || nLength <= 0)
131 if(pString && nLength > 0)
133 WB_ERROR_PRINT(
"ERROR: %s.%d returning error for \"%-.*s\"\n", __FUNCTION__, __LINE__, nLength, pString);
137 WB_ERROR_PRINT(
"ERROR: %s.%d returning error for %d,%p\n", __FUNCTION__, __LINE__, nLength, pString);
165 use_the_stack_buffer:
171 memcpy(tbuf, pString, nLength);
181 nLength =
sizeof(tbuf);
182 goto use_the_stack_buffer;
185 memcpy(pS, pString, nLength);
195 #ifdef X11WORKBENCH_TOOLKIT_HAVE_XFT 196 if(pFont && pFont->pxftFont)
198 #warning TODO: IMPLEMENT THIS PART for Xft FONTS 201 #endif // X11WORKBENCH_TOOLKIT_HAVE_XFT 206 "%s.%d using WB_DRAW_STRING for \"%-.*s\" color=#%08lxH bkgnd=#%08lxH\n",
207 __FUNCTION__, __LINE__, nLength, pString,
219 __internalDoAntiAlias(pDisplay, drawable, gc, x, y - ext.
height, ext.
width, ext.
height);
227 "%s.%d using XDrawString for \"%-.*s\" color=#%08lxH bkgnd=#%08lxH\n",
228 __FUNCTION__, __LINE__, nLength, pString,
233 memset(&gcv, 0,
sizeof(gcv));
234 memset(&gcv2, 0,
sizeof(gcv2));
237 XGetGCValues(gc->
display, gc->
gc, GCFont, &gcv);
240 memcpy(&gcv2, &gcv,
sizeof(gcv));
248 XChangeGC(gc->
display, gc->
gc, GCFont, &gcv2);
254 XDrawString(pDisplay, drawable, gc->
gc, x, y, pS, nLength);
262 XChangeGC(gc->
display, gc->
gc, GCFont, &gcv);
269 if(pS && pS != &(tbuf[0]) && pS != (
char *)pString)
291 #define INITIAL_DT_WORDS_COUNT 256 293 static int CheckReAllocWords(
DT_WORDS **ppWords)
299 int iNewLen =
sizeof(*pRval)
300 + ((pRval->
nMax & 0xffffff80) + 127) *
sizeof(
DT_WORD);
306 WB_ERROR_PRINT(
"%s - ERROR: not enough memory to allocate new struct (%d required)\n",
307 __FUNCTION__, iNewLen);
318 pRval->
nMax = (pRval->
nMax & 0xffffff80) + 128;
383 pRval->
nMax = INITIAL_DT_WORDS_COUNT;
386 if(!szText || !*szText)
397 while(*p1 && (
unsigned char)*p1 <=
' ')
403 if(!CheckReAllocWords(&pRval))
417 while(*(p1 + 1) ==
'\t')
429 else if(*p1 ==
'\n' || *p1 ==
'\r')
431 if(!CheckReAllocWords(&pRval))
457 if(*p1 ==
'\n' && p1[1] ==
'\r')
461 else if(*p1 ==
'\r' && p1[1] ==
'\n')
468 if(p1[1] !=
'\r' && p1[1] !=
'\n')
483 else if((
unsigned char)*p1 <=
' ')
485 if(!CheckReAllocWords(&pRval))
501 while(*(p1 + 1) && (
unsigned char)*(p1 + 1) <=
' ' && *(p1 + 1) !=
'\t' && *(p1 + 1) !=
'\r' && *(p1 + 1) !=
'\n')
519 int iUnderscoreFlag = 0;
524 while( (
unsigned char)*p1 >
' ')
534 if(!CheckReAllocWords(&pRval))
598 iRval =
InternalCalcIdealBounds(pDisplay, pFont, pWords, iTabWidth, iTabOrigin, prcSource, prcDest, iAlignment, 0, -1);
606 static void DoHCenterWrappedLines(
DT_WORDS *pWords,
int iWidth)
608 int i1, i2, i3, iMax;
627 while(i1 < pWords->nCount)
629 pW = &(pWords->
aWords[i1]);
651 i3 = (iWidth - iMax) / 2;
657 pW = &(pWords->
aWords[i2]);
666 }
while(i1 < pWords->nCount);
689 const WB_RECT *prcSource,
WB_RECT *prcDest,
int iAlignment,
int iStartLine,
int iEndLine)
691 int iFontWidth, iFontHeight, iFontAscent, iFontDescent, iLineSpacing;
692 int iHPos, iHPos0, iMaxLen, iLines;
699 if(!pWords || (!prcSource && !prcDest))
701 WB_ERROR_PRINT(
"%s - returns ERROR (bad values pWords=%p, prcSource=%p, prcDest=%p)\n",
702 __FUNCTION__, pWords, prcSource, prcDest);
708 rctSource.
top = prcSource->
top;
714 bzero(&rctSource,
sizeof(rctSource));
717 memcpy(&rctBounds, &rctSource,
sizeof(rctBounds));
746 iFontHeight = iFontAscent + iFontDescent;
749 iLineSpacing = iFontDescent / 2;
757 iTabWidth = -iTabWidth;
761 iTabOrigin *= iFontWidth;
762 iTabWidth *= iFontWidth;
767 iHPos0 = iHPos = rctSource.
left;
774 for(i1=0; i1 < pWords->
nCount; i1++)
776 pW = &(pWords->
aWords[i1]);
780 pW->
iY = pW->
iX = -1;
791 for(i2=i1 + 1; i2 < pWords->
nCount; i2++)
793 pW2 = &(pWords->
aWords[i2]);
809 pW->
iY = pW->
iX = -1;
819 iHPos += pW->
nLength * iFontWidth;
823 i3 = (iHPos - iHPos0 + iTabOrigin) % iTabWidth;
836 iHPos += iTabWidth * (pW->
nLength - 1);
842 for(i2=i1 + 1; i2 < pWords->
nCount; i2++)
844 pW2 = &(pWords->
aWords[i2]);
845 pW2->
iX = pW2->
iY = -1;
863 pW->
iY = pW->
iX = -1;
865 if(iMaxLen < iHPos - iHPos0)
867 iMaxLen = iHPos - iHPos0;
871 (i1 + 1) == pWords->
nCount)
892 pW->
iX = iHPos - iHPos0;
893 pW->
iY = (iLines - 1) * iFontHeight + iFontAscent;
907 "%s.%d - iHPos=%d, iMaxLen=%d, iLines=%d, iFontHeight=%d, *=%d\n", __FUNCTION__, __LINE__,
908 iHPos, iMaxLen, iLines, iFontHeight, (iLines * iFontHeight));
911 rctBounds.
top = rctSource.
top;
912 rctBounds.
right = iMaxLen;
913 rctBounds.
bottom = rctBounds.
top + (iLines * iFontHeight);
916 "%s.%d - rctSource %d,%d,%d,%d rctBounds: %d,%d,%d,%d\n", __FUNCTION__, __LINE__,
923 "%s.%d - %d lines - font height %d, line spacing %d\n",
924 __FUNCTION__, __LINE__, iLines, iFontHeight, iLineSpacing);
925 rctBounds.
bottom += (iLines - 1) * iLineSpacing;
932 WB_ERROR_PRINT(
"WARNING: %s.%d - source rectangle too small, alignment flags may not work\n", __FUNCTION__, __LINE__);
936 WB_ERROR_PRINT(
" Lines: %d Font ascent=%d, descent=%d, height=%d, line spacing %d\n",
937 iLines, iFontAscent, iFontDescent, iFontHeight, iLineSpacing);
942 "INFO: %s - source rectangle seems to fit\n", __FUNCTION__);
944 " %d,%d,%d,%d bounds vs source %d,%d,%d,%d\n",
948 " Lines: %d Font ascent=%d, descent=%d, height=%d, line spacing %d\n",
949 iLines, iFontAscent, iFontDescent, iFontHeight, iLineSpacing);
959 "%s.%d - 'it fits' bounds rectangle is %d,%d,%d,%d iAlighment=%d (%08xH)\n",
960 __FUNCTION__, __LINE__,
962 iAlignment, iAlignment);
983 "%s.%d - here I am, %d, %d, %d, %d\n", __FUNCTION__, __LINE__,
988 rctBounds.
left += i1;
989 rctBounds.
right += i1;
996 DoHCenterWrappedLines(pWords, rctBounds.
right - rctBounds.
left);
1009 switch(iAlignment & DTAlignment_VMASK)
1018 i1 = ((rctSource.
bottom - rctBounds.
bottom + 1) >> 1) - 1;
1019 rctBounds.
top += i1;
1024 i2 = iFontDescent >> 1;
1025 i1 = ((rctSource.
bottom - rctBounds.
bottom + 1) >> 1) - 1;
1029 rctBounds.
top += i1;
1035 i2 = (iFontAscent - iFontDescent) >> 1;
1036 i1 = ((rctSource.
bottom - rctBounds.
bottom + 1) >> 1) - 1;
1038 if(i1 < rctSource.
bottom)
1040 rctBounds.
top += i1;
1058 memcpy(prcDest, &rctBounds,
sizeof(*prcDest));
1068 if(rctSource.
right > 0 &&
1074 iHPos0 = iHPos = rctSource.
left;
1082 for(i1=0; i1 < pWords->
nCount; i1++)
1084 pW = &(pWords->
aWords[i1]);
1088 pW->
iY = pW->
iX = -1;
1099 for(i2=i1 + 1; i2 < pWords->
nCount; i2++)
1101 pW2 = &(pWords->
aWords[i2]);
1117 pW->
iY = pW->
iX = -1;
1127 iHPos += pW->
nLength * iFontWidth;
1131 i3 = (iHPos - iHPos0 + iTabOrigin) % iTabWidth;
1144 iHPos += iTabWidth * (pW->
nLength - 1);
1148 if(iHPos > rctSource.
right)
1152 while((i1 + 1) < pWords->
nCount)
1154 pW2 = &(pWords->
aWords[i1]);
1155 pW2->
iX = pW2->
iY = -1;
1172 if(iMaxLen < iHPos - iHPos0)
1174 iMaxLen = iHPos - iHPos0;
1177 if(iHPos > iHPos0 &&
1178 (i1 + 1) == pWords->
nCount)
1195 for(i2=i1 + 1; i2 < pWords->
nCount; i2++)
1197 pW2 = &(pWords->
aWords[i2]);
1198 pW2->
iX = pW2->
iY = -1;
1217 pW->
iY = pW->
iX = -1;
1219 if(iMaxLen < iHPos - iHPos0)
1221 iMaxLen = iHPos - iHPos0;
1224 if(iHPos > iHPos0 &&
1225 (i1 + 1) == pWords->
nCount)
1251 pW->
iX = iHPos - iHPos0;
1252 pW->
iY = (iLines - 1) * iFontHeight + iFontAscent;
1258 if(iMaxLen < iHPos - iHPos0)
1260 iMaxLen = iHPos - iHPos0;
1263 if(iHPos > iHPos0 &&
1264 (i1 + 1) == pWords->
nCount)
1294 rctBounds.
top = rctSource.
top;
1295 rctBounds.
right = rctBounds.
left + iMaxLen;
1296 rctBounds.
bottom = rctBounds.
top + (iLines * iFontHeight);
1300 rctBounds.
bottom += (iLines - 1) * iLineSpacing;
1312 "%s - 'it does not fit' bounds rectangle is %d,%d,%d,%d\n",
1343 memcpy(prcDest, &rctBounds,
sizeof(*prcDest));
1356 static void __internalDoAntiAlias(Display *pDisplay, Drawable dw,
WBGC gc,
int iX,
int iY,
int iWidth,
int iHeight)
1358 XStandardColormap map;
1360 unsigned long lPixel;
1364 unsigned int iWidth0=0, iHeight0=0, iBorder;
1365 unsigned int uiDepth = 0;
1386 "%s.%d - geom %d,%d,%d,%d\n", __FUNCTION__, __LINE__, iX, iY, iWidth, iHeight);
1390 XGetGeometry(pDisplay, dw, &winRoot, &iX0, &iY0, &iWidth0, &iHeight0, &iBorder, &uiDepth);
1396 if(iX >= iWidth0 + iX0 || iY >= iHeight0 + iY0)
1398 WB_ERROR_PRINT(
"ERROR: %s.%d - drawable smaller than requested geom: %d,%d,%d,%d %d,%d,%d,%d\n",
1399 __FUNCTION__, __LINE__, iX0, iY0, iWidth0, iHeight0,
1400 iX, iY, iWidth, iHeight);
1406 iWidth0 = (iWidth0 + iX0) - iX;
1407 iHeight0 = (iHeight0 + iY0) - iY;
1412 if(iWidth0 < iWidth)
1414 geom.
width = iWidth0;
1418 geom.
width = iWidth;
1421 if(iHeight0 < iHeight)
1434 pxTemp = XCreatePixmap(pDisplay, dw, geom.
width, geom.
height,
1435 DefaultDepth(pDisplay, DefaultScreen(pDisplay)));
1440 WB_ERROR_PRINT(
"ERROR: %s - unable to create temporary pixmap via XCreatePixmap()\n", __FUNCTION__);
1447 WB_ERROR_PRINT(
"ERROR: %s - unable to create temporary clipping region\n", __FUNCTION__);
1454 WB_ERROR_PRINT(
"ERROR: %s - unable to create temporary WBGC copy\n", __FUNCTION__);
1464 XCopyArea(pDisplay, dw, pxTemp, gc2->
gc,
1482 WB_ERROR_PRINT(
"ERROR: %s - unable to create image via WBXGetImage()\n", __FUNCTION__);
1500 XCopyArea(pDisplay, pxTemp, dw, gc->
gc,
1520 XFreePixmap(pDisplay, pxTemp);
1524 XDestroyRegion(rgnClip);
1532 int iTabWidth,
int iTabOrigin,
const WB_RECT *prcBounds,
int iAlignment)
1539 int iTabWidth,
int iTabOrigin,
const WB_RECT *prcBounds,
int iAlignment)
1541 int i1, i2, i3, iH, iH2, iFontDescent;
1546 XCharStruct xMaxBounds;
1574 "%s.%d call to DTGetWordsFromText\n", __FUNCTION__, __LINE__);
1585 memcpy(&rcDest, prcBounds,
sizeof(rcDest));
1588 "%s.%d bounds rectangle is INITIALLY %d,%d,%d,%d\n",
1592 "%s.%d call to InternalCalcIdealBounds\n", __FUNCTION__, __LINE__);
1601 WB_ERROR_PRINT(
"%s - ERROR: InternalCalcIdealBounds returns error\n",
1613 "%s.%d bounds rectangle is NOW %d,%d,%d,%d\n",
1619 "%s.%d loop to display 'words'\n", __FUNCTION__, __LINE__);
1620 for(i1=0; i1 < pWords->
nCount; i1++)
1622 pW = &(pWords->
aWords[i1]);
1624 if(pW->
iX >= 0 && pW->
iY >= 0 && pW->
iWidth > 0)
1632 "%s.%d DTDrawString at %d,%d %d chars of %s\n",
1640 "%s.%d normal display of \"%-.*s\"\n", __FUNCTION__, __LINE__, pW->
nLength, pW->
pText);
1644 iH = rcDest.
left + pW->
iX;
1648 "%s.%d loop to handle underscores\n", __FUNCTION__, __LINE__);
1649 for(i2=0, i3=0; i2 < pW->
nLength; )
1651 if(pW->
pText[i2] ==
'_')
1657 else if(i3 && i3 == i2)
1664 "%s.%d DTDrawString at %d,%d %d chars of %s\n",
1665 __FUNCTION__, __LINE__, iH, rcDest.
top + pW->
iY, pW->
nLength - i3, (
char *)(pW->
pText) + i3);
1669 (
const char *)(pW->
pText) + i3, i2 - i3);
1675 xpt[0].y=rcDest.
top + pW->
iY + iFontDescent + 1;
1680 WBDrawLines(pDisplay, dw, gc, xpt, 2, CoordModeOrigin);
1698 if(i3 < pW->nLength)
1708 xpt[0].y=rcDest.
top + pW->
iY + xMaxBounds.descent + 1;
1713 WBDrawLines(pDisplay, dw, gc, xpt, 2, CoordModeOrigin);
1728 "%s.%d call to __internalDoAntiAlias\n", __FUNCTION__, __LINE__);
1729 __internalDoAntiAlias(pDisplay, dw, gc,
1746 WB_RECT *prcBounds,
int iAlignment,
int iStartLine,
int iEndLine)
1773 memcpy(&rcDest, prcBounds,
sizeof(rcDest));
1781 WB_ERROR_PRINT(
"%s - ERROR: InternalCalcIdealBounds returns error\n",
1792 int iHScrollBy,
int iVScrollBy,
const WB_RECT *prcBounds,
const WB_RECT *prcViewport,
int iAlignment)
1806 WBDebugPrint(
"===================================================\n" 1807 "%s - DUMPING pWords array\n ", __FUNCTION__);
1809 for(i1=0; i1 < pWords->
nCount; i1++)
1815 for(i2=0; i2 < pW->
nLength; i2++)
1822 for(i2=0; i2 < pW->
nLength; i2++)
1829 for(i2=0; i2 < pW->
nLength; i2++)
1836 i2 = pW->
nLength >
sizeof(tbuf) - 1 ?
sizeof(tbuf) - 1: pW->
nLength;
1837 memcpy(tbuf, pW->
pText, i2);
1847 for(i1=0; i1 < pWords->
nCount; i1++)
1853 WBDebugPrint(
" LF: length=%d,width=%d,height=%d X=%d,Y=%d\n",
1858 WBDebugPrint(
" TAB: length=%d,width=%d,height=%d X=%d,Y=%d\n",
1863 WBDebugPrint(
" WS: length=%d,width=%d,height=%d X=%d,Y=%d\n",
1868 i2 = pW->
nLength >
sizeof(tbuf) - 1 ?
sizeof(tbuf) - 1: pW->
nLength;
1869 memcpy(tbuf, pW->
pText, i2);
1871 WBDebugPrint(
" STR: length=%d,width=%d,height=%d X=%d,Y=%d \"%s\"\n",
1876 WBDebugPrint(
"\n===================================================\n");
const char * szText
original text pointer
int DTCalcIdealBounds(Display *pDisplay, WB_FONTC pFont, const char *szText, int iTabWidth, unsigned int iTabOrigin, const WB_RECT *prcSource, WB_RECT *prcDest, int iAlignment)
Calculate the ideal bounding rectangle for the specified text and font.
static void InternalDebugDumpWords(DT_WORDS *pWords)
internal debug function to dump 'DT_WORDS' 'words' object
'window helper' main header file for the X11workbench Toolkit API
Display * display
the Display associated with the WBGC (NULL implies 'Default Display')
int iWidth
width of text in pixels (based on font size) (NA for tabs, LF, valid for white space)
#define WB_DEBUG_PRINT(L,...)
Preferred method of implementing conditional debug output.
unsigned int width
the 'width' value of the extent.
int WBFontHeight(WB_FONTC pFont0)
Get the maximum character height from a WB_FONT.
int WBFontAscent(WB_FONTC pFont0)
Get the maximum character ascent from a WB_FONT.
void WBDefaultStandardColormap(Display *pDisplay, XStandardColormap *pMap)
returns a default XStandardColormap structure for the default screen of the specified display
center along the font baseline (single line only)
Utilities for copying and drawing text, determining text extents, and so on.
internal flag, indicates that an underscore underlines the next character
int nMax
max number of items in aWords (for memory allocation purposes)
int WBFontAvgCharWidth(WB_FONTC pFont0)
Get the average character width for a font.
XImage * WBGetWindowImage(Display *pDisplay, Window wID)
Obtain an XImage for the entire window.
internal flag, 'single line only' (no line breaks). Implies DTAlignment_NO_WORD_WRAP
int nCount
number of items in aWords
top-aligned text (using highest vertical ascent)
static __inline__ unsigned long WBGetForeground(WBGC hGC)
Get the (cached) foreground color for a WBGC.
int WBXPutImage(Display *pDisplay, Drawable dw, WBGC gc, XImage *pImage, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height)
Write contents of an XImage onto a Drawable.
WB_FONT DTCalcIdealFont(Display *pDisplay, WB_FONTC pRefFont, const char *szText, WB_GEOM *geomBounds)
Calculate the ideal font based on the text and rectangle.
horizontally centered text. tabs are treated as white space
static __inline__ Display * WBGetDefaultDisplay(void)
Returns the default Display.
internal wrapper struct for X11 'geometry' definition
struct tagDT_WORDS DT_WORDS
A collection of DT_WORD structures along with a pointer to the original text.
void DTDrawSingleLineText(WB_FONTC pFont, const char *szText, Display *pDisplay, WBGC gc, Drawable dw, int iTabWidth, int iTabOrigin, const WB_RECT *prcBounds, int iAlignment)
draw single-line text
void * WBReAlloc(void *pBuf, int nNewSize)
High performance memory sub-allocator 're-allocate'.
void DTPreRender(Display *pDisplay, WB_FONTC pFont, DT_WORDS *pWords, int iTabWidth, int iTabOrigin, WB_RECT *prcBounds, int iAlignment, int iStartLine, int iEndLine)
Pre-render a 'DT_WORDS' structure for subsequent display.
Structure defining a 'word' for rendering purposes.
internal flag, applies simple anti-aliasing. See WBSimpleAntiAliasImage() and WBSimpleAntiAliasPixmap...
int WBFontEnableAntiAlias(void)
returns non-zero value if certain fonts should be anti-aliased when rendered
int WBDrawLines(Display *display, Drawable d, WBGC gc, XPoint *points, int npoints, int mode)
Wrapper for XDrawLine()
A collection of DT_WORD structures along with a pointer to the original text.
center using entire text height (ascent + descent for single line)
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)
int WBSetRegion(WBGC hGC, Region rgnClip)
Assign clipping region, wrapper for XSetRegion()
center within the top half of the rectangle (single line only)
int WBXDrawString(XImage *pImage, WB_FONTC pFont, WBGC hGC, int x, int y, const char *string, int length)
XImage version for XDrawString() or DTDrawString()
Do not shrink the bounding rectangle for ideal text dimension.
#define WB_ERROR_PRINT(...)
Preferred method of implementing an 'error level' debug message for all subsystems.
void WBFree(void *pBuf)
High performance memory sub-allocator 'free'.
center within the bottom half of the rectangle (single line only)
XCharStruct WBFontMaxBounds(WB_FONTC pFont0)
Get a 'maximized' copy of 'max_bounds' (applicable to all font faces in the WB_FONT)
int iIsTab
indicates that the text consists of tabs (nLength for number of tabs, pText is NULL)
int iIsWhiteSpace
indicates that it is 'white space' (regular or special character) (nLength, width,...
int WBAllocUsableSize(void *pBuf)
High performance memory sub-allocator, similar to 'malloc_usable_size'.
static __inline__ unsigned long WBGetBackground(WBGC hGC)
Get the (cached) background color for a WBGC.
void DTDrawString(Display *pDisplay, Drawable drawable, WB_FONTC pFont, WBGC gc, int x, int y, const char *pString, int nLength)
Draw text in a platform-independent manner for UTF-8 or multi-byte text, equivalent to WBDrawString()...
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.
struct tagDT_WORD DT_WORD
Structure defining a 'word' for rendering purposes.
int iHeight
height of text in pixels (based on font size) (NA for tabs, LF, valid for white space)
XFontSet fsFont
legacy 'XFontSet' for X11 raster fonts (UTF-8)
void WBSimpleAntiAliasImage(const XStandardColormap *pMap, XImage *pImage, unsigned long lPixel, WB_GEOM *pGeom)
Simple anti-alias of an XImage using foreground pixel color.
DT_WORD aWords[1]
The actual data (self-contained within the memory block)
internal wrapper struct for 'extent' definition
int WBXDestroyImage(XImage *pImage)
Destroy an XImage - call this instead of XDestroyImage()
XFontStruct * pFontStruct
legacy 'XFontStruct' for X11 raster fonts
internal wrapper struct for 'rectangle' definition
horizontal alignment mask
int WBFontDescent(WB_FONTC pFont0)
Get the maximum character descent from a WB_FONT.
int iY
Relative 'Y' pixel position for the beginning of this element (when pre-rendered, else -1)
int WBTextWidth(WB_FONTC pFont, const char *szText, int cbText)
Obtain the pixel width of specified text for a specified WB_FONT.
void WBFreeGC(WBGC hGC)
Free resources for a WBGC, wrapper for XFreeGC()
static int InternalCalcIdealBounds(Display *pDisplay, WB_FONTC pFont, DT_WORDS *pWords, int iTabWidth, unsigned int iTabOrigin, const WB_RECT *prcSource, WB_RECT *prcDest, int iAlignment, int iStartLine, int iEndLine)
calculate ideal bounds rectangle for text given a font, tab spacing, tab origin, and alignment
DT_WORDS * DTGetWordsFromText(Display *pDisplay, WB_FONTC pFont, const char *szText, int iAlignment)
Parse 'DT_WORDS' structure from single-line or multi-line text.
#define BEGIN_XCALL_DEBUG_WRAPPER
wrapper macro for calls into the X11 library. This macro precedes the call(s)
unsigned long WBGetGCFGColor(WBGC gc)
returns the currently assigned foreground color for a WBGC
WBGC WBCopyDrawableGC(Display *pDisplay, Drawable dw, WBGC hGCOrig)
makes a copy of the specified WBGC for the desired 'Drawable'
int iIsLineFeed
indicates a line feed (CR, CRLF, LF, or LFCR) (nLength for number of line feeds, pText is NULL)
Region WBGeomToRegion(const WB_GEOM *pGeom)
'Paint' helper, converts a WB_GEOM structure to a Region.
void WBDebugPrint(const char *pFmt,...) __attribute__((format(printf
conditional debug message output
void DTDrawMultiLineText(WB_FONTC pFont, const char *szText, Display *pDisplay, WBGC gc, Drawable dw, int iTabWidth, int iTabOrigin, const WB_RECT *prcBounds, int iAlignment)
draw multi-line text
center halfway up the 'ascent' portion (single line only)
void DTRender(Display *pDisplay, WB_FONTC pFont, const DT_WORDS *pWords, WBGC gc, Drawable dw, int iHScrollBy, int iVScrollBy, const WB_RECT *prcBounds, const WB_RECT *prcViewport, int iAlignment)
Using pre-rendered 'DT_WORDS' structure, display.
An allocated structure containing XFontStruct, XFontInfo, and XftFont [as applicable] for a specified...
unsigned int height
the 'height' value of the extent.
internal wrapper struct for GC with local cache
int nLength
length of text element (in bytes)
bottom-aligned text (using lowest vertical descent)
void WBTextExtent(WB_FONTC pFont, const char *szText, int cbText, WB_EXTENT *pExtent)
Obtain the pixel extent of specified text for a specified XFontSet.
int iX
Relative 'X' pixel position for the beginning of this element (when pre-rendered, else -1)
WB_FONTC WBGetDefaultFont(void)
Returns a pointer to the default font WB_FONT for the default display. This is a shared resource; do ...