62 #include "pixmap_helper.h" 85 #define COPY_COLOR_NAME(X,Y,Z) {const char *pX = X(WBGetDefaultDisplay()); if(pX) strncpy(Y,pX,sizeof(Y)); else strncpy(Y,Z,sizeof(Y));} 96 static const char *szBorder2=
"#FFFFFF", *szBorder2W=
"#C8C6C0", *szBorder3=
"#9C9A94";
97 char szFG[16], szBG[16], szBD[16], szHFG[16], szHBG[16], szAFG[16], szABG[16];
172 " iScrollState = %d,\n" 173 " iVScrollWidth = %d, iHScrollHeight = %d, iVBarHeight = %d, iHBarWidth = %d,\n" 174 " iHKnob = %d, iVKnob = %d, iHKnobSize = %d, iVKnobSize = %d,\n" 175 " iHMin = %d, iHMax = %d iVMin = %d, iVMax = %d, iHPos = %d, iVPos = %d\n" 176 " geomHBar: %d,%d,%d,%d\n" 177 " geomHLeft: %d,%d,%d,%d\n" 178 " geomHRight: %d,%d,%d,%d\n" 179 " geomHKnob: %d,%d,%d,%d\n" 180 " geomVBar: %d,%d,%d,%d\n" 181 " geomVUp: %d,%d,%d,%d\n" 182 " geomVDown: %d,%d,%d,%d\n" 183 " geomVKnob: %d,%d,%d,%d\n",
201 static char ilog2n(
unsigned char y)
217 static char ilog2c(
unsigned char y)
220 return ilog2n(y >> 4) + 4;
227 static int ilog2s(
unsigned short y)
231 return ilog2c((
unsigned char)(y >> 8)) + 8;
234 return ilog2c((
unsigned char)y);
239 static int ilog2(
unsigned int y)
243 return ilog2s((
unsigned short)(y >> 16)) + 16;
246 return ilog2s((
unsigned short)y);
253 if(y & 0xffffffff00000000LL)
255 return ilog2((
unsigned int)(y >> 32)) + 32;
258 return ilog2((
unsigned int)y);
273 return (pSI->
iVMin < pSI->
iVMax) != iRval ? 1 : 0;
286 return (pSI->
iHMin < pSI->
iHMax) != iRval ? 1 : 0;
301 static int InternalNotifySelf(Window wID, Atom aNotify,
long lData0,
long lData1,
long lData2,
long lData3,
long lData4)
305 XClientMessageEvent evt = {
311 .message_type=aNotify,
314 evt.data.l[0] = lData0;
315 evt.data.l[1] = lData1;
316 evt.data.l[2] = lData2;
317 evt.data.l[3] = lData3;
318 evt.data.l[4] = lData4;
324 static void InternalCalcVScrollBar(
WB_SCROLLINFO *pScrollInfo,
WB_GEOM *pgeomClient,
int iVScrollWidth,
int iHScrollHeight)
326 int iKnobSize, iKnobPos, iBarHeight;
331 iBarHeight = pgeomClient->
height;
336 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Expose,
337 "%s.%d - iVScrollWidth=%d, iHScrollHeight=%d iBarHeight=%d geomClient=%d,%d,%d,%d border=%d\n",
338 __FUNCTION__, __LINE__, iVScrollWidth, iHScrollHeight, iBarHeight,
339 pgeomClient->
x, pgeomClient->
y, pgeomClient->
width, pgeomClient->
height, pgeomClient->
border);
343 pScrollInfo->
iVPos = -1;
346 nListItems = pScrollInfo->
iVMax - pScrollInfo->
iVMin + 1;
352 iKnobSize = (iBarHeight - 4 * iHScrollHeight - 2);
354 if(iKnobSize > iHScrollHeight)
356 i1 = iHScrollHeight * (2 * iHScrollHeight + 1);
357 i2 = iHScrollHeight * 2;
359 while(i2 > 2 && i1 > iKnobSize)
367 if(nListItems > iKnobSize || iKnobSize - i1 < iHScrollHeight / 2)
374 iKnobSize -= (nListItems - iHScrollHeight * 2 + 1);
380 - (nListItems + 1) * nListItems / 2;
383 if(iKnobSize < iHScrollHeight)
385 iKnobSize = iHScrollHeight;
390 iKnobSize = iHScrollHeight;
400 + 2 * pgeomClient->
border;
405 + 2 * pgeomClient->
border;
435 if(pScrollInfo->
iVPos <= 0 || nListItems <= 0)
446 if(pScrollInfo->
iVPos >= (nListItems - 1))
448 iKnobPos = iBarScrollArea;
469 DebugDumpScrollInfo(pScrollInfo);
474 static void InternalCalcHScrollBar(
WB_SCROLLINFO *pScrollInfo,
WB_GEOM *pgeomClient,
int iVScrollWidth,
int iHScrollHeight)
476 int iKnobSize, iKnobPos, iBarWidth;
482 iBarWidth = pgeomClient->
width;
488 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Expose,
489 "%s.%d - iVScrollWidth=%d, iHScrollHeight=%d iBarWidth=%d geomClient=%d,%d,%d,%d border=%d\n",
490 __FUNCTION__, __LINE__, iVScrollWidth, iHScrollHeight, iBarWidth,
491 pgeomClient->
x, pgeomClient->
y, pgeomClient->
width, pgeomClient->
height, pgeomClient->
border);
496 pScrollInfo->
iHPos = -1;
499 nListItems = pScrollInfo->
iHMax - pScrollInfo->
iHMin + 1;
505 iKnobSize = (iBarWidth - 4 * iVScrollWidth - 2);
507 if(iKnobSize > iVScrollWidth)
509 i1 = iVScrollWidth * (2 * iVScrollWidth + 1);
510 i2 = iVScrollWidth * 2;
512 while(i2 > 2 && i1 > iKnobSize)
520 if(nListItems > iKnobSize || iKnobSize - i1 < iVScrollWidth / 2)
527 iKnobSize -= (nListItems - iVScrollWidth * 2 + 1);
533 - (nListItems + 1) * nListItems / 2;
536 if(iKnobSize < iVScrollWidth)
538 iKnobSize = iVScrollWidth;
543 iKnobSize = iVScrollWidth;
555 + 2 * pgeomClient->
border;
557 + 2 * pgeomClient->
border;
586 if(pScrollInfo->
iHPos <= 0 || nListItems <= 0)
599 if(pScrollInfo->
iHPos >= (nListItems - 1))
601 iKnobPos = iBarScrollArea;
627 DebugDumpScrollInfo(pScrollInfo);
635 int iHScrollHeight,
int nListItems,
int nPos)
637 int iBarHeight, iBarWidth;
640 iBarHeight = pgeomClient->
height;
641 iBarWidth = pgeomClient->
width;
645 pScrollInfo->
iVKnob >= 0 &&
647 pScrollInfo->
iVPos == nPos &&
648 pScrollInfo->
iVMin == 0 &&
649 pScrollInfo->
iVMax == (nListItems - 1))
665 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Expose,
666 "%s.%d - %d %d %d %d %d\n", __FUNCTION__, __LINE__,
667 iBarHeight, iVScrollWidth, iHScrollHeight, nListItems, nPos);
669 pScrollInfo->
iVMin = 0;
670 pScrollInfo->
iVMax = nListItems - 1;
673 (nPos >= pScrollInfo->
iVMin && nPos <= pScrollInfo->iVMax))
675 pScrollInfo->
iVPos = nPos;
679 pScrollInfo->
iVPos = nPos = -1;
682 InternalCalcVScrollBar(pScrollInfo, pgeomClient, iVScrollWidth, iHScrollHeight);
687 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Expose,
688 "%s.%d - iHScrollHeight=%d, iBarWidth=%d\n", __FUNCTION__, __LINE__,
689 iHScrollHeight, iBarWidth);
694 int iHScrollHeight,
int nListItems,
int nPos)
696 int iBarHeight, iBarWidth;
699 iBarHeight = pgeomClient->
height;
700 iBarWidth = pgeomClient->
width;
704 pScrollInfo->
iVKnob >= 0 &&
706 pScrollInfo->
iVPos == nPos &&
707 pScrollInfo->
iVMin == 0 &&
708 pScrollInfo->
iVMax == (nListItems - 1))
724 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Expose,
725 "%s.%d - %d %d %d %d %d\n", __FUNCTION__, __LINE__,
726 iBarWidth, iVScrollWidth, iHScrollHeight, nListItems, nPos);
728 pScrollInfo->
iHMin = 0;
729 pScrollInfo->
iHMax = nListItems - 1;
733 (nPos >= 0 && nPos < nListItems))
735 pScrollInfo->
iHPos = nPos;
739 pScrollInfo->
iHPos = nPos = -1;
742 InternalCalcHScrollBar(pScrollInfo, pgeomClient, iVScrollWidth, iHScrollHeight);
747 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Expose,
748 "%s.%d - iHScrollHeight=%d, iBarWidth=%d\n", __FUNCTION__, __LINE__,
749 iVScrollWidth, iBarHeight);
759 int nListItems = pScrollInfo->
iVMax - pScrollInfo->
iVMin + 1;
761 int iKnobPos = iY - iKnobSize / 3
769 if(iBarScrollArea <= 0)
771 return pScrollInfo->
iVMin;
778 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Expose,
779 "%s.%d iY=%d; nLI=%d KS=%d KP=%d BSA=%d nP=%d\n",
780 __FUNCTION__, __LINE__,
781 iY, nListItems, iKnobSize, iKnobPos, iBarScrollArea, nPos);
783 if(nPos < pScrollInfo->iVMin)
785 return pScrollInfo->
iVMin;
787 else if(nPos > pScrollInfo->
iVMax)
789 return pScrollInfo->
iVMax;
806 int nListItems = pScrollInfo->
iHMax - pScrollInfo->
iHMin + 1;
808 int iKnobPos = iX - iKnobSize / 3
816 if(iBarScrollArea <= 0)
818 return pScrollInfo->
iHMin;
825 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Expose,
826 "%s.%d iX=%d; nLI=%d KS=%d KP=%d BSA=%d nP=%d\n",
827 __FUNCTION__, __LINE__,
828 iX, nListItems, iKnobSize, iKnobPos, iBarScrollArea, nPos);
830 if(nPos < pScrollInfo->iHMin)
832 return pScrollInfo->
iHMin;
834 else if(nPos > pScrollInfo->
iHMax)
836 return pScrollInfo->
iHMax;
853 int iVScrollWidth, iHScrollHeight;
863 geom.
x = pgeomClient->
x;
864 geom.
y = pgeomClient->
y;
871 iVScrollWidth =
WBTextWidth(pFont,
"X", 1) * 2 + 4;
872 iHScrollHeight = xBounds.ascent + xBounds.descent + 4;
874 WB_DEBUG_PRINT(DebugLevel_Heavy | DebugSubSystem_ScrollBar | DebugSubSystem_Expose,
875 "%s.%d - iVScrollWidth=%d, iHScrollHeight=%d geom=%d,%d,%d,%d (%d)\n",
876 __FUNCTION__, __LINE__, iVScrollWidth, iHScrollHeight,
885 InternalCalcVScrollBar(pSI, pgeomClient, iVScrollWidth, iHScrollHeight);
887 geom.
width -= iVScrollWidth;
894 InternalCalcHScrollBar(pSI, pgeomClient, iVScrollWidth, iHScrollHeight);
897 geom.
height -= iHScrollHeight;
902 memcpy(pgeomUsable, &geom,
sizeof(*pgeomUsable));
905 WB_DEBUG_PRINT(DebugLevel_Heavy | DebugSubSystem_ScrollBar | DebugSubSystem_Expose,
906 " SCROLL INFO: iVBarHeight = %-6d iHBarWidth = %d\n" 907 " iVKnob = %-6d iHKnob = %d\n" 908 " iVKnobSize = %-6d iHKnobSize = %d\n" 909 " iVPos = %-6d iHPos = %d\n" 910 " iVMin = %-6d iVMin = %d\n" 911 " iVMax = %-6d iVMax = %d\n\n",
924 if(wID == None || !pScrollInfo)
957 if(wID == None || !pScrollInfo)
989 int iRval, iX, iY, iDirection, iPosition;
992 if(wID == None || !pEvent || pEvent->type != ClientMessage || !pScrollInfo)
1005 !pEvent->xclient.data.l[2])
1007 iX = pEvent->xclient.data.l[3];
1008 iY = pEvent->xclient.data.l[4];
1020 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Event,
1021 "%s Mouse click in vertical scroll bar (up)\n", __FUNCTION__);
1026 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Event,
1027 "%s Mouse click in vertical scroll bar (down)\n", __FUNCTION__);
1038 iPosition = pScrollInfo->
iVMin;
1041 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Event,
1042 "%s Mouse click in vertical scroll bar (knob), iPosition=%d\n", __FUNCTION__, iPosition);
1045 iY < pScrollInfo->geomVKnob.y)
1048 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Event,
1049 "%s Mouse click in vertical scroll bar (page up)\n", __FUNCTION__);
1052 iY < pScrollInfo->geomVDown.y)
1055 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Event,
1056 "%s Mouse click in vertical scroll bar (page down)\n", __FUNCTION__);
1060 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Event,
1061 "%s Mouse click in vertical scroll bar (unknown)\n", __FUNCTION__);
1073 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Event,
1074 "%s Mouse click in horizontal scroll bar (left)\n", __FUNCTION__);
1079 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Event,
1080 "%s Mouse click in horizontal scroll bar (right)\n", __FUNCTION__);
1092 iPosition = pScrollInfo->
iHMin;
1095 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Event,
1096 "%s Mouse click in horizontal scroll bar (knob). iPosition=%d\n", __FUNCTION__, iPosition);
1101 iX < pScrollInfo->geomHKnob.x)
1104 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Event,
1105 "%s Mouse click in horizontal scroll bar (page left)\n", __FUNCTION__);
1108 iX < pScrollInfo->geomHRight.x)
1111 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Event,
1112 "%s Mouse click in horizontal scroll bar (page right)\n", __FUNCTION__);
1116 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Event,
1117 "%s Mouse click in horizontal scroll bar (unknown)\n", __FUNCTION__);
1130 !pEvent->xclient.data.l[2])
1132 iX = pEvent->xclient.data.l[3];
1133 iY = pEvent->xclient.data.l[4];
1143 XClientMessageEvent evt;
1144 memcpy(&evt, pEvent,
sizeof(evt));
1155 XClientMessageEvent evt;
1156 memcpy(&evt, pEvent,
sizeof(evt));
1188 !pEvent->xclient.data.l[2])
1190 iX = pEvent->xclient.data.l[3];
1191 iY = pEvent->xclient.data.l[4];
1212 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Event,
1213 "%s Mouse drag in vert scroll bar (knob)\n", __FUNCTION__);
1223 iPosition = pScrollInfo->
iVMin;
1228 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Event,
1229 "%s Mouse motion in scroll bar (knob) iPosition=%d\n", __FUNCTION__, iPosition);
1242 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Event,
1243 "%s Mouse drag in horiz scroll bar (knob)\n", __FUNCTION__);
1253 iPosition = pScrollInfo->
iHMin;
1258 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Event,
1259 "%s Mouse motion in scroll bar (knob) iPosition=%d\n", __FUNCTION__, iPosition);
1268 WB_DEBUG_PRINT(DebugLevel_Medium | DebugSubSystem_ScrollBar | DebugSubSystem_Event,
1269 "%s mouse motion in scroll bar outside of knob\n", __FUNCTION__);
1309 else if(pEvent->xclient.message_type ==
aWB_CHAR)
1313 long lKey
WB_UNUSED = pEvent->xclient.data.l[0];
1314 long lAltCtrlShift
WB_UNUSED = pEvent->xclient.data.l[1];
1316 int nChar
WB_UNUSED = (int)pEvent->xclient.data.l[2];
1317 char *pBuf
WB_UNUSED = (
char *)&(pEvent->xclient.data.l[3]);
1320 #warning scroll bar hot keys have not been implemented yet 1351 if(pScrollInfo->
iHPos < pScrollInfo->
iHMin ||
1355 WB_DEBUG_PRINT(DebugLevel_Chatty | DebugSubSystem_ScrollBar | DebugSubSystem_Expose,
1356 "%s - grey out iHPos=%d iHMin=%d iHMax=%d\n", __FUNCTION__,
1362 WB_DEBUG_PRINT(DebugLevel_Verbose | DebugSubSystem_ScrollBar | DebugSubSystem_Expose,
1363 "%s - paint 'left' button %d %d %d %d (%d)\n", __FUNCTION__,
1373 WB_DEBUG_PRINT(DebugLevel_Verbose | DebugSubSystem_ScrollBar | DebugSubSystem_Expose,
1374 "%s - paint 'right' button %d %d %d %d (%d)\n", __FUNCTION__,
1384 WB_DEBUG_PRINT(DebugLevel_Verbose | DebugSubSystem_ScrollBar | DebugSubSystem_Expose,
1385 "%s - paint horizontal 'knob' %d %d %d %d (%d)\n", __FUNCTION__,
1419 if(pScrollInfo->
iVPos < pScrollInfo->
iVMin ||
1423 WB_DEBUG_PRINT(DebugLevel_Chatty | DebugSubSystem_ScrollBar | DebugSubSystem_Expose,
1424 "%s - grey out iVPos=%d iVMin=%d iVMax=%d\n", __FUNCTION__,
1430 WB_DEBUG_PRINT(DebugLevel_Verbose | DebugSubSystem_ScrollBar | DebugSubSystem_Expose,
1431 "%s - paint 'up' button %d %d %d %d (%d)\n", __FUNCTION__,
1441 WB_DEBUG_PRINT(DebugLevel_Verbose | DebugSubSystem_ScrollBar | DebugSubSystem_Expose,
1442 "%s - paint 'down' button %d %d %d %d (%d)\n", __FUNCTION__,
1452 WB_DEBUG_PRINT(DebugLevel_Verbose | DebugSubSystem_ScrollBar | DebugSubSystem_Expose,
1453 "%s - paint vertical 'knob' %d %d %d %d (%d)\n", __FUNCTION__,
1483 WB_GEOM *pgeomBorder,
unsigned long lBorderColor)
1487 if(!pgeomBorder || !pDisplay || wID == None || gc == None)
1494 xpt[0].x=pgeomBorder->
x;
1495 xpt[0].y=pgeomBorder->
y;
1498 + pgeomBorder->
width 1501 xpt[1].y = xpt[0].y;
1503 xpt[2].x = xpt[1].x;
1508 xpt[3].x = xpt[0].x;
1509 xpt[3].y = xpt[2].y;
1511 xpt[4].x = xpt[0].x;
1512 xpt[4].y = xpt[0].y + 1;
1514 WBDrawLines(pDisplay, wID, gc, xpt, 5, CoordModeOrigin);
1518 unsigned long lBorderColor1,
unsigned long lBorderColor2)
1525 if(!pgeomBorder || !pDisplay || wID == None || gc == None)
1531 xpt[0].x = pgeomBorder->
x;
1532 xpt[0].y = pgeomBorder->
y 1533 + pgeomBorder->
height - 1 - 1;
1535 xpt[1].x = xpt[0].x;
1536 xpt[1].y = pgeomBorder->
y;
1539 + pgeomBorder->
width - 1 - 1;
1540 xpt[2].y = xpt[1].y;
1542 WBDrawLines(pDisplay, wID, gc, xpt, 3, CoordModeOrigin);
1546 xpt[0].x = pgeomBorder->
x 1547 + pgeomBorder->
width - 1;
1548 xpt[0].y = pgeomBorder->
y + 1;
1550 xpt[1].x = xpt[0].x;
1551 xpt[1].y = pgeomBorder->
y 1552 + pgeomBorder->
height - 1;
1554 xpt[2].x = pgeomBorder->
x + 1;
1555 xpt[2].y = xpt[1].y;
1557 WBDrawLines(pDisplay, wID, gc, xpt, 3, CoordModeOrigin);
1561 bzero(&clr,
sizeof(clr));
1562 clr.pixel = lBorderColor1;
1566 iR = (clr.flags & DoRed) ? (
unsigned int)clr.red : 0;
1567 iG = (clr.flags & DoGreen) ? (
unsigned int)clr.green : 0;
1568 iB = (clr.flags & DoBlue) ? (
unsigned int)clr.blue : 0;
1570 bzero(&clr,
sizeof(clr));
1571 clr.pixel = lBorderColor2;
1575 iR += (clr.flags & DoRed) ? (
unsigned int)clr.red : 0;
1576 iG += (clr.flags & DoGreen) ? (
unsigned int)clr.green : 0;
1577 iB += (clr.flags & DoBlue) ? (
unsigned int)clr.blue : 0;
1579 bzero(&clr,
sizeof(clr));
1582 clr.green = iG >> 1;
1593 xpt[0].x = pgeomBorder->
x;
1594 xpt[1].y = pgeomBorder->
y;
1596 xpt[1].x = xpt[0].x + pgeomBorder->
width - 1;
1597 xpt[0].y = xpt[1].y + pgeomBorder->
height - 1;
1599 WBDrawPoints(pDisplay, wID, gc, xpt, 2, CoordModeOrigin);
1606 WB_GEOM *pgeomBorder,
unsigned long lBorderColor)
1608 if(!pgeomBorder || !pDisplay || wID == None || gc == None)
1616 pgeomBorder->
x, pgeomBorder->
y,
1622 unsigned long lBorderColor1,
unsigned long lBorderColor2)
1624 if(!pgeomBorder || !pDisplay || wID == None || gc == None)
1635 pgeomBorder->
x, pgeomBorder->
y,
1642 pgeomBorder->
x, pgeomBorder->
y,
1647 pgeomBorder->
x, pgeomBorder->
y,
1649 -135 * 64, -180 * 64);
1662 static const char dash_list[4]={1,2,2,1};
1670 WBDrawBorderRect(pDisplay, wID, gc2, pgeomRect, WhitePixel(pDisplay, DefaultScreen(pDisplay)));
1680 WB_ERROR_PRINT(
"%s:%d - unable to create GC\n", __FUNCTION__, __LINE__);
1696 xpt[0].x = pgeomRect->
x + (pgeomRect->
width >> 2);
1697 xpt[0].y = pgeomRect->
y + (pgeomRect->
height >> 2) + (pgeomRect->
height >> 2);
1698 xpt[1].x = xpt[0].x + (pgeomRect->
width >> 1) - 1;
1699 xpt[1].y = pgeomRect->
y + (pgeomRect->
height >> 2);
1700 xpt[2].x = xpt[1].x;
1701 xpt[2].y = pgeomRect->
y + pgeomRect->
height - 1 - (pgeomRect->
height >> 2);
1702 xpt[3].x = xpt[0].x;
1703 xpt[3].y = xpt[2].y - (pgeomRect->
height >> 2);
1704 xpt[4].x = xpt[0].x;
1705 xpt[4].y = xpt[0].y;
1707 WBDrawLines(pDisplay, wID, gc, xpt, 5, CoordModeOrigin);
1708 WBFillPolygon(pDisplay, wID, gc, xpt, 5, Nonconvex, CoordModeOrigin);
1725 xpt[0].x = pgeomRect->
x + (pgeomRect->
width >> 2) + (pgeomRect->
width >> 2);
1726 xpt[0].y = pgeomRect->
y + (pgeomRect->
height >> 2);
1727 xpt[1].x = pgeomRect->
x + (pgeomRect->
width >> 2);
1728 xpt[1].y = xpt[0].y + (pgeomRect->
height >> 1) - 1;
1729 xpt[2].x = pgeomRect->
x + pgeomRect->
width - 1 - (pgeomRect->
width >> 2);
1730 xpt[2].y = xpt[1].y;
1731 xpt[3].x = xpt[2].x - (pgeomRect->
width >> 2);
1732 xpt[3].y = xpt[0].y;
1733 xpt[4].x = xpt[0].x;
1734 xpt[4].y = xpt[0].y;
1736 WBDrawLines(pDisplay, wID, gc, xpt, 5, CoordModeOrigin);
1737 WBFillPolygon(pDisplay, wID, gc, xpt, 5, Nonconvex, CoordModeOrigin);
1755 xpt[0].x = pgeomRect->
x + pgeomRect->
width - 1 - (pgeomRect->
width >> 2);
1756 xpt[0].y = pgeomRect->
y + (pgeomRect->
height >> 2) + (pgeomRect->
height >> 2);
1757 xpt[1].x = xpt[0].x - (pgeomRect->
width >> 1) + 1;
1758 xpt[1].y = pgeomRect->
y + (pgeomRect->
height >> 2);
1759 xpt[2].x = xpt[1].x;
1760 xpt[2].y = pgeomRect->
y + pgeomRect->
height - 1 - (pgeomRect->
height >> 2);
1761 xpt[3].x = xpt[0].x;
1762 xpt[3].y = xpt[2].y - (pgeomRect->
height >> 2);
1763 xpt[4].x = xpt[0].x;
1764 xpt[4].y = xpt[0].y;
1766 WBDrawLines(pDisplay, wID, gc, xpt, 5, CoordModeOrigin);
1767 WBFillPolygon(pDisplay, wID, gc, xpt, 5, Nonconvex, CoordModeOrigin);
1784 xpt[0].x = pgeomRect->
x + (pgeomRect->
width >> 2) + (pgeomRect->
width >> 2);
1785 xpt[0].y = pgeomRect->
y + pgeomRect->
height - 1 - (pgeomRect->
height >> 2);
1786 xpt[1].x = pgeomRect->
x + (pgeomRect->
width >> 2);
1787 xpt[1].y = xpt[0].y - (pgeomRect->
height >> 1) + 1;
1788 xpt[2].x = pgeomRect->
x + pgeomRect->
width - 1 - (pgeomRect->
width >> 2);
1789 xpt[2].y = xpt[1].y;
1790 xpt[3].x = xpt[2].x - (pgeomRect->
width >> 2);
1791 xpt[3].y = xpt[0].y;
1792 xpt[4].x = xpt[0].x;
1793 xpt[4].y = xpt[0].y;
1795 WBDrawLines(pDisplay, wID, gc, xpt, 5, CoordModeOrigin);
1796 WBFillPolygon(pDisplay, wID, gc, xpt, 5, Nonconvex, CoordModeOrigin);
1803 int fFocus,
unsigned long lFGColor,
unsigned long lBGColor,
1804 unsigned long lBorderColor1,
unsigned long lBorderColor2,
1805 unsigned long lHighlightColor,
1807 Atom aGraphic,
const char *szText)
1810 XColor clrAvg, clrTemp;
1811 unsigned long lHighlightColor2;
1812 int iFontHeight, bFocus;
1813 int i1, i2, iR, iG, iB, iY, iU, iV, iYBG, iY0, iU0, iV0;
1838 xpt[0].x = pgeomOutline->
x;
1839 xpt[0].y = pgeomOutline->
y + pgeomOutline->
height + 1;
1842 xpt[1].x = xpt[0].x + 2;
1843 xpt[1].y = pgeomOutline->
y + 3;
1846 xpt[2].x = xpt[1].x + 1;
1847 xpt[2].y = xpt[1].y - 1;
1848 xpt[3].x = xpt[2].x + 1;
1849 xpt[3].y = xpt[2].y - 1;
1850 xpt[4].x = xpt[3].x + 1;
1851 xpt[4].y = xpt[3].y - 1;
1854 xpt[5].x = xpt[0].x + pgeomOutline->
width - 5;
1855 xpt[5].y = xpt[4].y;
1858 xpt[6].x = xpt[5].x + 1;
1859 xpt[6].y = xpt[5].y + 1;
1860 xpt[7].x = xpt[6].x + 1;
1861 xpt[7].y = xpt[6].y + 1;
1862 xpt[8].x = xpt[7].x + 1;
1863 xpt[8].y = xpt[7].y + 1;
1866 xpt[9].x = pgeomOutline->
x + pgeomOutline->
width;
1867 xpt[9].y = xpt[0].y;
1869 xpt[10].x = xpt[0].x;
1870 xpt[10].y = xpt[0].y;
1872 rgnClip = XPolygonRegion(xpt, 11, WindingRule);
1875 WB_ERROR_PRINT(
"ERROR: %s - unable to create polygon region\n", __FUNCTION__);
1885 XDestroyRegion(rgnClip);
1887 WB_ERROR_PRINT(
"ERROR: %s - unable to create GC\n", __FUNCTION__);
1897 bFocus = fFocus > 0 || fFocus == -1;
1899 lHighlightColor2 = lHighlightColor;
1905 clrTemp.pixel = lBGColor;
1908 iR = clrTemp.red >> 8;
1909 iG = clrTemp.green >> 8;
1910 iB = clrTemp.blue >> 8;
1916 iYBG = (iYBG + 256) / 2;
1921 clrTemp.pixel = lHighlightColor;
1924 iR = clrTemp.red >> 8;
1925 iG = clrTemp.green >> 8;
1926 iB = clrTemp.blue >> 8;
1932 if(iY0 > 5 * iYBG / 8)
1936 else if(iY0 < 3 * iYBG / 8)
1943 clrTemp.red = (iR << 8) + 128;
1944 clrTemp.green = (iG << 8) + 128;
1945 clrTemp.blue = (iB << 8) + 128;
1949 lHighlightColor2 = clrTemp.pixel;
1952 i2 = 6 * (xpt[0].y - xpt[5].y - 2) / 7;
1957 for(i1=xpt[5].y; i1 < xpt[0].y - 2; i1++)
1960 int iR2 = abs(i1 - (xpt[5].y + i2 / 2));
1962 iR2 = 128 +
WB_icos(iR2 * 240 / i2);
1964 iR2 = ((int)iR2 * (
int)iR2) / 256;
1975 iY = (iYBG - iY + iY / 2) * iR2 / 256 + iY + iY / 2 + 4;
1981 iU = 128 + (iU - 128) * 255 / iY * 255 / iY;
1982 iV = 128 + (iV - 128) * 255 / iY * 255 / iY;
1988 clrTemp.red = (iR << 8) + 128;
1989 clrTemp.green = (iG << 8) + 128;
1990 clrTemp.blue = (iB << 8) + 128;
1991 clrTemp.flags = DoRed | DoGreen | DoBlue;
2001 xpt2[0].x = pgeomOutline->
x + 1;
2003 xpt2[1].x = pgeomOutline->
x + pgeomOutline->
width - 2;
2004 xpt2[1].y = xpt2[0].y;
2006 if(i1 < xpt[5].y + 2)
2008 xpt2[0].x += (xpt[5].y + 2) - i1;
2009 xpt2[1].x -= (xpt[5].y + 2) - i1;
2013 WBDrawLines(pDisplay, dw, gc2, xpt2, 2, CoordModeOrigin);
2023 for(i1=0; i1 < 5; i1++)
2029 for(i1=5; i1 < 10; i1++)
2043 xpt[9].y = xpt[0].y;
2045 xpt[10].x = xpt[0].x;
2046 xpt[10].y = xpt[0].y;
2056 bzero(&clrAvg,
sizeof(clrAvg));
2057 clrAvg.pixel = lBorderColor1;
2061 iR = (clrAvg.flags & DoRed) ? (
unsigned int)clrAvg.red : 0;
2062 iG = (clrAvg.flags & DoGreen) ? (
unsigned int)clrAvg.green : 0;
2063 iB = (clrAvg.flags & DoBlue) ? (
unsigned int)clrAvg.blue : 0;
2065 bzero(&clrAvg,
sizeof(clrAvg));
2066 clrAvg.pixel = lBorderColor2;
2070 iR += (clrAvg.flags & DoRed) ? (
unsigned int)clrAvg.red : 0;
2071 iG += (clrAvg.flags & DoGreen) ? (
unsigned int)clrAvg.green : 0;
2072 iB += (clrAvg.flags & DoBlue) ? (
unsigned int)clrAvg.blue : 0;
2074 bzero(&clrAvg,
sizeof(clrAvg));
2076 clrAvg.red = iR >> 1;
2077 clrAvg.green = iG >> 1;
2078 clrAvg.blue = iB >> 1;
2085 WBDrawLines(pDisplay, dw, gc2, xpt, 7, CoordModeOrigin);
2088 WBDrawLines(pDisplay, dw, gc2, xpt + 8, 2, CoordModeOrigin);
2097 WBDrawLines(pDisplay, dw, gc2, xpt + 9, 2, CoordModeOrigin);
2101 WBDrawPoints(pDisplay, dw, gc2, xpt + 6, 2, CoordModeOrigin);
2106 WBDrawPoints(pDisplay, dw, gc2, xpt, 1, CoordModeOrigin);
2113 rctTemp.
left = pgeomOutline->
x + 1;
2114 rctTemp.
top = pgeomOutline->
y + 1;
2120 szText =
"{untitled}";
2173 rctTemp.
top = pgeomOutline->
y + 2;
2174 rctTemp.
bottom = rctTemp.
top + iFontHeight;
2175 rctTemp.
right = pgeomOutline->
x + pgeomOutline->
width - 6;
2176 rctTemp.
left = rctTemp.
right - iFontHeight + 2;
2214 XDestroyRegion(rgnClip);
const char * CHGetHighlightForegroundColor(Display *pDisplay)
returns highlight foreground color
int WBDrawPoints(Display *display, Drawable d, WBGC gc, XPoint *points, int npoints, int mode)
Wrapper for XDrawPoints()
void WBDraw3DBorderElipse(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomBorder, unsigned long lBorderColor1, unsigned long lBorderColor2)
Draw a 3D 'border' elipse within a bounding geometry.
2nd parameter (direction) - up, left
void PXM_RGBToYUV(int iR, int iG, int iB, int *piY, int *piU, int *piV)
Convert R, G, B values to Y, U, V with 0-255 range.
#define WB_POINTER_DBLCLICK
WB_POINTER 'double-click' event, send in lieu of WB_POINTER_CLICK for double-click.
#define WB_POINTER_CLICK
Mouse 'click' event.
static XColor clrScrollABG
active background scroll bar color
#define WB_DEBUG_PRINT(L,...)
Preferred method of implementing conditional debug output.
#define WB_POINTER_DROP
WB_POINTER 'drop' event, only sent if drag/drop supported AND was not 'canceled'; see WB_POINTER_CANC...
int WBFontHeight(WB_FONTC pFont0)
Get the maximum character height from a WB_FONT.
Utilities for copying and drawing text, determining text extents, and so on.
static XColor clrScrollBG
background scroll bar color
void WBPaintHScrollBar(WB_SCROLLINFO *pScrollInfo, Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomClient)
Paint the horizontal scroll bar within a window based on WB_SCROLLINFO.
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()
generic 'NA' or 'UNDEFINED' value
#define WB_POINTER_SCROLLDOWN
WB_POINTER 'scroll down' event, caused by mouse button 5.
void PXM_YUVToRGB(int iY, int iU, int iV, int *piR, int *piG, int *piB)
Convert Y, U, V values to R, G, B with 0-255 range.
int WBScrollBarEvent(Window wID, XEvent *pEvent, WB_SCROLLINFO *pScrollInfo)
Event handler for scroll bars.
const char * CHGetActiveBackgroundColor(Display *pDisplay)
returns background color for active elements
int WBWindowDispatch(Window wID, XEvent *pEvent)
Dispatches a window XEvent. May be called directly.
int WBCalcHScrollDragPos(WB_SCROLLINFO *pScrollInfo, int iX)
Calculate and assign the correct horizontal scroll bar position from mouse coordinates.
1st parameter (bar) - The vertical scroll bar for the control or window.
2nd parameter (direction) - 'knob track' - pos in data.l[2]
static XColor clrScrollBD3
3D highlight scroll bar border color (dark)
int WBFillPolygon(Display *display, Drawable d, WBGC gc, XPoint *points, int npoints, int shape, int mode)
Wrapper for XFillPolygon()
horizontally centered text. tabs are treated as white space
void WBDrawLeftArrow(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomRect, unsigned long lColor)
Draw a left arrow in a window within a specified geometry.
static int iInitScrollColorFlag
initialization flag for scroll colors. when zero, colors not yet initialized
Atom aWB_CHAR
keystroke/character notifications generated by API
static __inline__ Display * WBGetDefaultDisplay(void)
Returns the default Display.
internal wrapper struct for X11 'geometry' definition
'configuration helper' main header file for the X11 Work Bench Toolkit API
void PXM_RGBToPixel(XStandardColormap *pMap, XColor *pColor)
Icon Registration for application 'large' and 'small' icons.
const char * CHGetActiveTextColor(Display *pDisplay)
returns 'active' text color
void PXM_PixelToRGB(XStandardColormap *pMap, XColor *pColor)
Convert the pixel menber of an XColor to RGB.
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
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()
Atom aWB_POINTER
pointer click/double-click/drag notifications generated by API
#define COPY_COLOR_NAME(X, Y, Z)
macro to get a color name or use default if it does not exist in settings
#define WBGetWindowCopyGC2(wID, gcSrc)
makes a copy of the specified WBGC for the desired window
internal flag, applies simple anti-aliasing. See WBSimpleAntiAliasImage() and WBSimpleAntiAliasPixmap...
void WBInvalidateHScrollGeom(Window wID, WB_SCROLLINFO *pScrollInfo, int bAll, int bUpdate)
Utility function to invalidate the geometry for the horizontal scroll bar.
void WBInvalidateGeom(Window wID, const WB_GEOM *pGeom, int bPaintNow)
'Paint' helper, invalidates a geometry for asynchronous Expose event generation
1st parameter (bar) - The horizontal scroll bar for the control or window
int WBDrawLines(Display *display, Drawable d, WBGC gc, XPoint *points, int npoints, int mode)
Wrapper for XDrawLine()
void WBDrawRightArrow(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomRect, unsigned long lColor)
Draw a right arrow in a window within a specified geometry.
static XColor clrScrollBD2
3D highlight scroll bar border color (light)
left button in 'drag' state on vertical scroll bar (relies on drag cancel)
center using entire text height (ascent + descent for single line)
const char * CHGetTextColor(Display *pDisplay)
returns text color
#define WB_POINTER_SCROLLUP
WB_POINTER 'scroll up' event, caused by mouse button 4.
int WBSetRegion(WBGC hGC, Region rgnClip)
Assign clipping region, wrapper for XSetRegion()
const char * CHGetHighlightBackgroundColor(Display *pDisplay)
returns highlight background color
#define WB_ERROR_PRINT(...)
Preferred method of implementing an 'error level' debug message for all subsystems.
void WBSetHScrollPos(WB_SCROLLINFO *pSI, int iPos)
Set the scroll range for a horizontal scrollbar in the WB_SCROLLINFO structure.
const char * CHGetDialogBackgroundColor(Display *pDisplay)
returns background color for dialog frame elements
2nd parameter (direction) - pgup, pgleft
#define WB_POINTER_CANCEL
WB_POINTER 'cancel' event, cancels an ongoing operation, such as drag/drop (useful for resource clean...
XCharStruct WBFontMaxBounds(WB_FONTC pFont0)
Get a 'maximized' copy of 'max_bounds' (applicable to all font faces in the WB_FONT)
middle button in 'drag' state on vertical scroll bar
#define WB_POINTER_MOVE
WB_POINTER 'move' event, for motion notification during drag/drop.
#define WB_POINTER_DRAG
WB_POINTER 'drag' event, window proc MUST return the window ID to auto-support drag/drop.
#define WB_POINTER_BUTTON1
WB_POINTER button bitmask indicating that button 1 is pressed.
int WBSetHScrollRange(WB_SCROLLINFO *pSI, int iMin, int iMax)
Set the scroll range for a horizontal scrollbar in the WB_SCROLLINFO structure.
int WBCalcVScrollDragPos(WB_SCROLLINFO *pScrollInfo, int iY)
Calculate and assign the correct vertical scroll bar position from mouse coordinates.
void WBDrawDashedRect(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomRect, unsigned long lColor)
Draw a 'dashed' rectangle.
void WBSetVScrollPos(WB_SCROLLINFO *pSI, int iPos)
Set the scroll range for a vertical scrollbar in the WB_SCROLLINFO structure.
static XColor clrScrollFG
foreground scroll bar color
static XColor clrScrollHBG
highlight background scroll bar color
static XColor clrScrollBD
standard scroll bar border color
char WB_icos(int iVal)
integer 127 * cos(iVal * pi / 512) calculation via lookup table
internal wrapper struct for 'rectangle' definition
static XColor clrScrollAFG
active foreground scroll bar color
void WBDrawUpArrow(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomRect, unsigned long lColor)
Draw an up arrow in a window within a specified geometry.
int WBTextWidth(WB_FONTC pFont, const char *szText, int cbText)
Obtain the pixel width of specified text for a specified WB_FONT.
Display * WBGetWindowDisplay(Window wID)
returns the Display associated with a window
void WBFreeGC(WBGC hGC)
Free resources for a WBGC, wrapper for XFreeGC()
void WBInvalidateVScrollGeom(Window wID, WB_SCROLLINFO *pScrollInfo, int bAll, int bUpdate)
Utility function to invalidate the geometry for the vertical scroll bar.
2nd parameter (direction) - pgdn, pgright
void WBDraw3DBorderRect(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomBorder, unsigned long lBorderColor1, unsigned long lBorderColor2)
Draw a 3D 'border' rectangle.
unsigned long WBGetGCFGColor(WBGC gc)
returns the currently assigned foreground color for a WBGC
unsigned long WBGetGCBGColor(WBGC gc)
returns the currently assigned background color for a WBGC
WBGC WBCopyDrawableGC(Display *pDisplay, Drawable dw, WBGC hGCOrig)
makes a copy of the specified WBGC for the desired 'Drawable'
static void CheckInitScrollColors(void)
internal utility to check and initialize scroll bar standard colors
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()
void WBDebugPrint(const char *pFmt,...) __attribute__((format(printf
conditional debug message output
An allocated structure containing XFontStruct, XFontInfo, and XftFont [as applicable] for a specified...
int WBSetVScrollRange(WB_SCROLLINFO *pSI, int iMin, int iMax)
Set the scroll range for a vertical scrollbar in the WB_SCROLLINFO structure.
static XColor clrScrollHFG
highlight foreground scroll bar color
void WBCalcHScrollBar(WB_SCROLLINFO *pScrollInfo, WB_GEOM *pgeomClient, int iVScrollWidth, int iHScrollHeight, int nListItems, int nPos)
Calculate the parameters for a horizontal scroll bar.
void WBCalcVScrollBar(WB_SCROLLINFO *pScrollInfo, WB_GEOM *pgeomClient, int iVScrollWidth, int iHScrollHeight, int nListItems, int nPos)
Calculate the parameters for a vertical scroll bar.
#define WB_IF_DEBUG_LEVEL(L)
Preferred method of implementing conditional debug 'if block' code.
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()
#define WBPointInGeom(X, Y, G)
Returns logical TRUE if the point (X,Y) is within the borders of the geometry 'G'.
void WBDrawBorderRect(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomBorder, unsigned long lBorderColor)
Draw a 'border' rectangle.
void WBDrawBorderElipse(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomBorder, unsigned long lBorderColor)
Draw a 'border' elipse within a bounding geometry.
2nd parameter (direction) - down, right
void WBPaintVScrollBar(WB_SCROLLINFO *pScrollInfo, Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomClient)
Paint the vertical scroll bar within a window based on WB_SCROLLINFO.
const char * CHGetBorderColor(Display *pDisplay)
returns border color
left button in 'drag' state on horizontal scroll bar (relies on drag cancel)
right button in 'drag' state on vertical scroll bar
void WBDraw3DBorderTab(Display *pDisplay, Drawable dw, WBGC gc, WB_GEOM *pgeomOutline, int fFocus, unsigned long lFGColor, unsigned long lBGColor, unsigned long lBorderColor1, unsigned long lBorderColor2, unsigned long lHighlightColor, WB_FONTC pFont, WB_FONTC pFontBold, Atom aGraphic, const char *szText)
Draw a 'tab' within a specified 'outline' rectangle.
void WBUpdateScrollBarGeometry(WB_SCROLLINFO *pSI, WB_FONTC pFont, WB_GEOM *pgeomClient, WB_GEOM *pgeomUsable)
Update the scroll bar geometry within the WB_SCROLLINFO structure.
void WBDrawDownArrow(Display *pDisplay, Drawable wID, WBGC gc, WB_GEOM *pgeomRect, unsigned long lColor)
Draw a down arrow in a window within a specified geometry.
WB_FONTC WBGetDefaultFont(void)
Returns a pointer to the default font WB_FONT for the default display. This is a shared resource; do ...