67 #include <X11/keysymdef.h> 71 #include "pixmap_helper.h" 77 #define THIS_SUBSYSTEM DebugSubSystem_Dialog 134 static int InternalCreateChildWindows(
DIALOG_WINDOW *pDlg,
const char *szDialogResource);
136 int DLGDefaultCallback(Window wID, XEvent *pEvent);
140 static XColor clrFG, clrBG, clrBD;
141 static int iInitColorFlag = 0;
143 static void __internal_destroy_dialog_window(
DIALOG_WINDOW *pTemp)
159 "%s - Destroy contents %d\n",
160 __FUNCTION__, i1 + 1);
190 void WBDialogWindowExit()
199 pDialogs = pDialogs->
pNext;
201 WB_ERROR_PRINT(
"WARNING: %s - dialog window %d not previously destroyed\n", __FUNCTION__, (
int)(pTemp->
wbDLG.
wID));
205 __internal_destroy_dialog_window(pTemp);
218 #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));} 220 static void InternalCheckColors(
void)
229 char szFG[16], szBG[16], szBD[16];
237 LOAD_COLOR0(
"*Dialog.foreground",szFG)
else LOAD_COLOR0(
"*Form.foreground", szFG)
238 else LOAD_COLOR0(
"*WmDialogShell.foreground",szFG)
else LOAD_COLOR0(
"*WmForm.foreground", szFG)
239 else LOAD_COLOR(
"*foreground", szFG,
"#000000");
240 LOAD_COLOR0(
"*Dialog.background",szBG)
else LOAD_COLOR0(
"*Form.background", szBG)
241 else LOAD_COLOR0(
"*WmDialogShell.background",szBG)
else LOAD_COLOR0(
"*WmForm.background", szBG)
242 else LOAD_COLOR(
"*background", szBG,
"#dcdad5");
243 LOAD_COLOR0(
"*Dialog.border",szBD)
else LOAD_COLOR0(
"*Form.border", szBD)
244 else LOAD_COLOR0(
"*WmDialogShell.border",szBD)
else LOAD_COLOR0(
"*WmForm.border", szBD)
245 else LOAD_COLOR0(
"*borderColor", szBD)
246 else LOAD_COLOR(
"*border", szBD,
"black");
261 int iX,
int iY,
int iWidth,
int iHeight,
262 WBWinEvent pUserCallback,
int iFlags,
void *pUserData)
266 XSetWindowAttributes xswa;
270 XClientMessageEvent evt;
281 WB_ERROR_PRINT(
"%s - not enough memory to create dialog window (1)\n", __FUNCTION__);
287 InternalCheckColors();
289 bzero(pNew,
sizeof(*pNew));
303 WB_ERROR_PRINT(
"%s - not enough memory to create dialog window (2)\n", __FUNCTION__);
311 pNew->
pNext = pDialogs;
317 memcpy(&(pNew->
wbDLG.
clrFG), &clrFG,
sizeof(clrFG));
318 memcpy(&(pNew->
wbDLG.
clrBG), &clrBG,
sizeof(clrBG));
319 memcpy(&(pNew->
wbDLG.
clrBD), &clrBD,
sizeof(clrBD));
322 bzero(&xswa,
sizeof(xswa));
325 xswa.background_pixel = pNew->
wbDLG.
clrBG.pixel;
326 xswa.colormap = DefaultColormap(pDisplay, DefaultScreen(pDisplay));
327 xswa.bit_gravity = CenterGravity;
330 "%s - creating dialog window at %d %d %d %d\n",
331 __FUNCTION__, iX, iY, iWidth, iHeight);
334 iX, iY, iWidth, iHeight, 1, InputOutput,
335 CWBorderPixel | CWBackPixel | CWColormap | CWBitGravity,
349 pNew->pDLGCallback = pUserCallback;
353 if(!InternalCreateChildWindows(pNew, szDialogResource))
358 WB_WARN_PRINT(
"%s - InternalCreateChildWindows failed, destroying dialog box\n", __FUNCTION__);
366 bzero(&xsh,
sizeof(xsh));
368 xsh.flags = (USPosition | USSize | PWinGravity);
371 xsh.win_gravity = NorthWestGravity;
373 if(pNew->wbDLG.iClientWidth > 0 && pNew->wbDLG.iClientHeight > 0)
376 "%s setting width/height, iClientWidth=%d iClientHeight=%d\n",
377 __FUNCTION__, pNew->wbDLG.iClientWidth, pNew->wbDLG.iClientHeight);
384 xsh.width = xsh.base_width = iWidth;
385 xsh.height = xsh.base_height = iHeight;
389 "%s calling XMoveResizeWindow, iX=%d iY=%d iWidth=%d iHeight=%d xsh.width=%d xsh.height=%d\n",
390 __FUNCTION__, iX, iY, iWidth, iHeight, xsh.width, xsh.height);
392 XMoveResizeWindow(pDisplay, pNew->wbDLG.wID, iX, iY, xsh.width, xsh.height);
396 xsh.flags |= (PMinSize | PMaxSize);
398 xsh.min_width = xsh.max_width = xsh.width;
399 xsh.min_height = xsh.max_height = xsh.height;
401 xsh.flags |= PBaseSize;
402 xsh.base_width = xsh.min_width;
403 xsh.base_height = xsh.min_height;
410 bzero(&xwmh,
sizeof(xwmh));
411 xwmh.flags = InputHint;
450 aProto[
sizeof(aProto)/
sizeof(aProto[0]) - 1] = None;
452 XSetWMProtocols(pDisplay, pNew->wbDLG.wID, aProto,
sizeof(aProto)/
sizeof(aProto[0]) - 1);
469 bzero(&evt,
sizeof(evt));
470 evt.type = ClientMessage;
471 evt.display = pDisplay;
472 evt.window = pNew->wbDLG.wID;
476 if(!pUserCallback(pNew->wbDLG.wID, (XEvent *)&evt))
480 WB_ERROR_PRINT(
"DLGCreateDialogWindow - callback returns zero on init\n");
489 for(i1=0; i1 < pNew->nContents; i1++)
518 XWarpPointer(pDisplay, None, pNew->wbDLG.wID, 0, 0, 0, 0, xsh.width / 2, xsh.height / 2);
538 a1, XA_ATOM, 32, PropModeReplace, (
unsigned char *)ai1, 2);
542 a1, XA_WINDOW, 32, PropModeReplace, (
unsigned char *)&wIDOwner, 1);
583 wID = pDialogWindow->
wID;
587 "%s - Destroying dialog window %d (%08xH)\n",
588 __FUNCTION__, (
int)wID, (
int)wID);
593 pTemp = pTemp->
pNext;
600 else if(pDialogs == pTemp)
601 pDialogs = pTemp->
pNext;
612 __internal_destroy_dialog_window((
DIALOG_WINDOW *)pDialogWindow);
626 int DLGDefaultCallback(Window wID, XEvent *pEvent)
635 WB_WARN_PRINT(
"%s - invalid 'pDialogWindow' for window %d (%08xH)\n",
636 __FUNCTION__, (
unsigned int)wID, (
unsigned int)wID);
652 "%s - BUTTON PRESS - dialog window\n", __FUNCTION__);
658 "%s - BUTTON RELEASE - dialog window\n", __FUNCTION__);
664 "%s - MOTION NOTIFY - dialog window\n", __FUNCTION__);
670 "%s - CLIENT MESSAGE - dialog window\n", __FUNCTION__);
672 if(pEvent->xclient.message_type ==
aWM_PROTOCOLS && pEvent->xclient.window == wID)
677 "%s - WM_DELETE_WINDOW (calling WBDestroyWindow(%d))\n", __FUNCTION__, (
int)wID);
686 __internal_destroy_dialog_window(pDialogWindow);
727 (pEvent->xclient.data.l[1] ==
IDOK || pEvent->xclient.data.l[1] ==
IDCANCEL ||
728 pEvent->xclient.data.l[1] ==
IDYES || pEvent->xclient.data.l[1] ==
IDNO ||
729 pEvent->xclient.data.l[1] ==
IDRETRY || pEvent->xclient.data.l[1] ==
IDABORT ||
730 pEvent->xclient.data.l[1] ==
IDIGNORE))
736 else if(pEvent->xclient.data.l[0] == (
long)
aLIST_NOTIFY)
748 char *p1 =
WBGetAtomName(pDisplay, (Atom)pEvent->xclient.data.l[0]);
749 WB_WARN_PRINT(
"%s - TODO: LIST_NOTIFY control notification message %ld (%s) %ld (%08lxH), %ld (%08lxH)\n",
750 __FUNCTION__, pEvent->xclient.data.l[0], p1,
751 pEvent->xclient.data.l[1], pEvent->xclient.data.l[1],
752 pEvent->xclient.data.l[2], pEvent->xclient.data.l[2]);
765 char *p1 =
WBGetAtomName(pDisplay, (Atom)pEvent->xclient.data.l[0]);
766 WB_WARN_PRINT(
"%s - TODO: control notification messages %ld (%s) %ld (%08lxH), %ld (%08lxH)\n",
767 __FUNCTION__, pEvent->xclient.data.l[0], p1,
768 pEvent->xclient.data.l[1], pEvent->xclient.data.l[1],
769 pEvent->xclient.data.l[2], pEvent->xclient.data.l[2]);
777 else if(pEvent->xclient.message_type ==
aGOTFOCUS)
785 (((
unsigned long)pEntry - (
unsigned long)pDialogWindow->
pwContents) %
sizeof(*pEntry)) != 0)
789 WB_WARN_PRINT(
"%s - WARNING: invalid dialog entry pointer in GOTFOCUS message (ignored)\n",
795 "%s - INFO: control already has focus in GOTFOCUS message\n",
802 for(i1=0; i1 < pDialogWindow->
nContents; i1++)
823 for(i1 = i2 + 1; i1 < pDialogWindow->
nContents; i1++)
838 for(i2=0; i2 < pDialogWindow->
nContents; i2++)
862 for(i1 = 0; i1 < i2; i1++)
877 for(i2=0; i2 < pDialogWindow->
nContents; i2++)
902 XClientMessageEvent evt = {
916 "%s - sending 'DLG_FOCUS notification - control id %d\n",
923 WB_WARN_PRINT(
"%s - received 'GOTFOCUS' for non-input control id %d\n",
928 else if(pEvent->xclient.message_type ==
aLOSTFOCUS)
936 (((
unsigned long)pEntry - (
unsigned long)pDialogWindow->
pwContents) %
sizeof(*pEntry)) != 0)
940 WB_WARN_PRINT(
"%s - WARNING: invalid dialog entry pointer in GOTFOCUS message (ignored)\n",
945 WB_WARN_PRINT(
"%s - TODO: handle 'LOST FOCUS' notifications - control id %d\n",
946 __FUNCTION__, pEntry->
iID);
949 else if(pEvent->xclient.message_type ==
aDLG_FOCUS)
962 if(!pEvent->xclient.data.l[0])
964 for(i1=0; i1 < pDialogWindow->
nContents; i1++)
966 if(pDialogWindow->
pwContents[i1].
iID == pEvent->xclient.data.l[1])
976 for(iCurFocus = -1, i1=0; i1 < pDialogWindow->
nContents; i1++)
988 if(pEvent->xclient.data.l[0] < 0)
990 for(i1=pDialogWindow->
nContents - 1; i1 >= 0; i1--)
1003 for(i1=0; i1 < pDialogWindow->
nContents; i1++)
1017 if(pEvent->xclient.data.l[0] < 0)
1019 for(i1=iCurFocus - 1; i1 >= 0; i1--)
1032 for(i1=pDialogWindow->
nContents - 1; i1 > iCurFocus; i1--)
1046 for(i1=iCurFocus + 1; i1 < pDialogWindow->
nContents; i1++)
1059 for(i1=0; i1 < iCurFocus; i1++)
1076 WB_WARN_PRINT(
"%s - unable to set focus for DLG_FOCUS event, l[0]=%ld, l[1]=%ld\n",
1077 __FUNCTION__, pEvent->xclient.data.l[0], pEvent->xclient.data.l[1]);
1084 "%s - setting focus for DLG_FOCUS event, l[0]=%ld, l[1]=%ld\n",
1085 __FUNCTION__, pEvent->xclient.data.l[0], pEvent->xclient.data.l[1]);
1090 for(i1=0; i1 < pDialogWindow->
nContents; i1++)
1108 XGetInputFocus(pDisplay, &wFocus, &i1);
1116 "%s - me or child has focus, setting to %d (%s), %d (%08xH)\n",
1117 __FUNCTION__, pEntry->
iID, p1,
1118 (
int)pEntry->
wID, (
int)pEntry->
wID);
1133 if(pEvent->xclient.data.l[2])
1158 WB_DEBUG_PRINT(DebugLevel_Heavy | DebugSubSystem_Keyboard | DebugSubSystem_Dialog,
1159 "%s KEY PRESS/RELEASE - dialog window - check for hotkeys\n", __FUNCTION__);
1173 "%s - FocusIn handler\n", __FUNCTION__);
1177 for(i1=0; i1 < pDialogWindow->
nContents; i1++)
1196 WBDebugPrint(
"%s - me or child has focus, setting to %d (%s), %d (%08xH)\n",
1197 __FUNCTION__, iCtrlID,
1198 (
const char *)(p1 ? p1 :
"NULL"),
1210 XClientMessageEvent evt = {
1211 .type=ClientMessage,
1220 evt.data.l[1] = iCtrlID;
1230 WB_WARN_PRINT(
"Warning: %s %s:%d window %d (%08xH) isn't valid, can't set focus\n",
1231 __FUNCTION__, __FILE__, __LINE__, (
int)wID, (
int)wID);
1238 for(i1=0; i1 < pDialogWindow->
nContents; i1++)
1259 WBDebugPrint(
"%s - me or child has focus, setting to %d (%s), %d (%08xH)\n",
1260 __FUNCTION__, iCtrlID,
1261 (
const char *)(p1 ? p1 :
"NULL"),
1275 XClientMessageEvent evt = {
1276 .type=ClientMessage,
1285 evt.data.l[1] = iCtrlID;
1293 WB_WARN_PRINT(
"Warning: %s %s:%d window %d (%08xH) isn't valid, can't set focus\n",
1294 __FUNCTION__, __FILE__, __LINE__, (
int)wID, (
int)wID);
1314 switch(pEvent->type)
1318 "%s - DestroyNotify and user callback returned a non-zero value\n", __FUNCTION__);
1334 if(pEvent->type == DestroyNotify &&
1335 pEvent->xdestroywindow.window == wID)
1337 WB_DEBUG_PRINT(DebugLevel_Heavy | DebugSubSystem_Event | DebugSubSystem_Dialog,
1338 "%s - DestroyNotify Window=%d\n", __FUNCTION__, (
int)wID);
1345 __internal_destroy_dialog_window(pDialogWindow);
1351 if(wIDOwner != None)
1489 int iACSMask = ShiftMask | ControlMask | Mod1Mask;
1490 int i1, iCurFocus, iCanHaveFocus = 0, iNoEnter = 0, iNoEsc = 0, iNoTab = 0;
1491 WBDialogEntry *pFocusEntry = NULL, *pDefaultEntry = NULL, *pCancelEntry = NULL;
1495 iACSMask &= ((XKeyEvent *)pEvent)->state;
1532 if(pDefaultEntry && pFocusEntry && pCancelEntry)
1553 if(pEvent->type == KeyPress || pEvent->type == KeyRelease)
1555 ks = XLookupKeysym((XKeyEvent *)pEvent, 0);
1557 if(iACSMask == Mod1Mask)
1559 const char *pKey = XKeysymToString(ks);
1569 || strlen(pKey) > 1)
1575 WB_DEBUG_PRINT(DebugLevel_Light | DebugSubSystem_Event | DebugSubSystem_Dialog | DebugSubSystem_Keyboard,
1576 "%s - user pressed Alt+%s %d (%xH)\n",
1578 (
unsigned int)ks, (
unsigned int)ks);
1580 if(pEvent->type == KeyRelease && iCanHaveFocus)
1594 for(i1=iCurFocus + 1; i1 != iCurFocus && i1 < ((
DIALOG_WINDOW *)pDLG)->nContents;
1613 const char *p1 = strchr(pCaption,
'_');
1616 if(toupper(p1[1]) == toupper(*pKey))
1618 WB_ERROR_PRINT(
"TEMPORARY: %s - key release, key=\"%s\", ks=%d\n", __FUNCTION__, pKey, (
int)ks);
1622 XClientMessageEvent evt = {
1623 .type=ClientMessage,
1632 evt.data.l[1] = pEntry->
iID;
1648 && pEvent->type == KeyRelease
1649 && ((
int)ks == XK_Return || (
int)ks == XK_KP_Enter)
1652 WB_DEBUG_PRINT(DebugLevel_Light | DebugSubSystem_Event | DebugSubSystem_Dialog | DebugSubSystem_Keyboard,
1653 "%s - DIALOG WINDOW - <enter> detected\n", __FUNCTION__);
1656 || pFocusEntry == pDefaultEntry)
1658 XClientMessageEvent evt = {
1659 .type=ClientMessage,
1668 evt.data.l[1] = pDefaultEntry->iID;
1677 && pEvent->type == KeyRelease
1678 && ((
int)ks == XK_Escape)
1681 WB_DEBUG_PRINT(DebugLevel_Light | DebugSubSystem_Event | DebugSubSystem_Dialog | DebugSubSystem_Keyboard,
1682 "%s - DIALOG WINDOW - <ESC> detected\n", __FUNCTION__);
1687 XClientMessageEvent evt = {
1688 .type=ClientMessage,
1697 evt.data.l[1] = pCancelEntry->iID;
1706 && pEvent->type == KeyRelease
1707 && ((
int)ks == XK_Tab || (
int)ks == XK_KP_Tab)
1708 && (iACSMask == 0 || iACSMask == ShiftMask))
1710 XClientMessageEvent evt = {
1711 .type=ClientMessage,
1719 evt.data.l[0] = iACSMask == 0 ? 1 : -1;
1726 else if(pEvent->type == KeyRelease)
1735 WB_WARN_PRINT(
"%s - calling DLGProcessHotKey and it's not a key event\n", __FUNCTION__);
1749 enum DlgResourceStringKeywordIndices
1751 DlgResourceKW__BEGIN_DIALOG=0,
1752 DlgResourceKW__END_DIALOG,
1753 DlgResourceKW__FONT,
1754 DlgResourceKW__CONTROL,
1758 DlgResourceKW__WIDTH,
1759 DlgResourceKW__HEIGHT,
1760 DlgResourceKW__VISIBLE,
1761 DlgResourceKW__INVISIBLE,
1762 DlgResourceKW__TITLE,
1763 DlgResourceKW__VA_DLGTOP,
1764 DlgResourceKW__VA_DLGBOTTOM,
1765 DlgResourceKW__VA_DLGCENTER,
1766 DlgResourceKW__HA_DLGLEFT,
1767 DlgResourceKW__HA_DLGRIGHT,
1768 DlgResourceKW__HA_DLGCENTER,
1769 DlgResourceKW__VRESIZE,
1770 DlgResourceKW__HRESIZE,
1771 DlgResourceKW__BORDER,
1772 DlgResourceKW__NOBORDER,
1773 DlgResourceKW__CLICKABLE,
1774 DlgResourceKW__CHECKED,
1775 DlgResourceKW__ENABLED,
1776 DlgResourceKW__DISABLED,
1777 DlgResourceKW__VA_TEXT_TOP,
1778 DlgResourceKW__VA_TEXT_BOTTOM,
1779 DlgResourceKW__VA_TEXT_CENTER,
1780 DlgResourceKW__HA_TEXT_LEFT,
1781 DlgResourceKW__HA_TEXT_RIGHT,
1782 DlgResourceKW__HA_TEXT_CENTER,
1785 static const char *
const aszKeywords[]={
"BEGIN_DIALOG",
"END_DIALOG",
"FONT",
"CONTROL",
"ID",
1786 "X",
"Y",
"WIDTH",
"HEIGHT",
"VISIBLE",
"INVISIBLE",
"TITLE",
1787 "VALIGN_DIALOG_BOTTOM",
"VALIGN_DIALOG_TOP",
"VALIGN_DIALOG_CENTER",
1788 "HALIGN_DIALOG_LEFT",
"HALIGN_DIALOG_RIGHT",
"HALIGN_DIALOG_CENTER",
1789 "VRESIZE",
"HRESIZE",
"BORDER",
"NOBORDER",
"CLICKABLE",
1790 "CHECKED",
"ENABLED",
"DISABLED",
1791 "VALIGN_TEXT_TOP",
"VALIGN_TEXT_BOTTOM",
"VALIGN_TEXT_CENTER",
1792 "HALIGN_TEXT_LEFT",
"HALIGN_TEXT_RIGHT",
"HALIGN_TEXT_CENTER",
1796 static const char *
const aszSymbols[]={
"IDOK",
"IDCANCEL",
"IDYES",
"IDNO",
"IDRETRY",
"IDABORT",
"IDIGNORE",
"IDSTATIC",
"IDNONE", NULL };
1799 static int InternalCreateChildWindowsSub(
DIALOG_WINDOW *pDlg,
const char **pszDialogResource);
1801 static int InternalCreateChildWindows(
DIALOG_WINDOW *pDlg,
const char *szDialogResource)
1803 const char *p1, *p2;
1806 if(!szDialogResource || !*szDialogResource)
1811 p1 = szDialogResource;
1812 while(*p1 && *p1 <=
' ')
1816 while(*p1 && *p1 >
' ')
1820 if((p1 - p2) != strlen(aszKeywords[DlgResourceKW__BEGIN_DIALOG]) ||
1821 memcmp(p2, aszKeywords[DlgResourceKW__BEGIN_DIALOG], (p1 - p2)) != 0)
1823 WB_WARN_PRINT(
"%s - dialog box resource missing 'BEGIN_DIALOG'\n", __FUNCTION__);
1827 while(*p1 && *p1 <=
' ')
1830 iRval = InternalCreateChildWindowsSub(pDlg, &p1);
1833 WB_ERROR_PRINT(
"%s - InternalCreateChildWindowsSub failure at \"%-.30s\"\n", __FUNCTION__, p1);
1839 static int get_id_val(
const char *szVal,
int iLen)
1848 if(iLen >=
sizeof(tbuf))
1850 iLen =
sizeof(tbuf) - 1;
1853 memcpy(tbuf, szVal, iLen);
1870 if(tbuf[0] >=
'0' && tbuf[0] <=
'9')
1877 for(i1=0; aszSymbols[i1]; i1++)
1879 if(!strcmp(tbuf, aszSymbols[i1]))
1881 return iIDSymbols[i1];
1894 static int InternalCreateChildWindowsSub(
DIALOG_WINDOW *pDlg,
const char **pszDialogResource)
1896 const char *p1, *p2, *p3;
1897 int i1, iKW, nKids = 0, iRval = 0;
1898 unsigned int iCurSize = 0, iCurContentSize = 0;
1903 int iX, iY, iWidth, iHeight;
1911 p1 = p2 = *pszDialogResource;
1916 while(*p1 && *p1 >
' ')
1918 if(*p1 ==
'"' || *p1 ==
'\'')
1924 (*p1 != c || p1[1] == c))
1931 if(*p1 ==
'\n' || *p1 ==
'\r')
1933 WB_WARN_PRINT(
"%s - Illegal newline/return character in embedded string within dialog resource\n",
1935 *pszDialogResource = p2;
1953 for(iKW=0; aszKeywords[iKW]; iKW++)
1955 i1 = strlen(aszKeywords[iKW]);
1956 if(i1 <= (p1 - p2) &&
1957 (p2[i1] <=
' ' || p2[i1] ==
':') &&
1958 !memcmp(p2, aszKeywords[iKW], i1))
1971 if(!aszKeywords[iKW])
1973 WB_WARN_PRINT(
"%s - NULL in aszKeywords in InternalCreateChildWindowsSub within dialog resource\n", __FUNCTION__);
1975 *pszDialogResource = p2;
1979 if(iKW == DlgResourceKW__END_DIALOG)
1983 pKids =
WBAlloc(
sizeof(*pKids));
1990 if(iKW == DlgResourceKW__BEGIN_DIALOG)
1992 WB_WARN_PRINT(
"%s - nested dialogs not supported (yet)\n", __FUNCTION__);
1994 *pszDialogResource = p2;
2000 case DlgResourceKW__CONTROL:
2004 pKids =
WBAlloc(iCurSize = (256 *
sizeof(*pKids)));
2007 WB_ERROR_PRINT(
"%s - not enough memory for controls\n", __FUNCTION__);
2018 else if((nKids + 1) *
sizeof(*pKids) > iCurSize)
2023 iNewSize = (nKids + 128) *
sizeof(*pKids);
2028 WB_ERROR_PRINT(
"%s - not enough memory for all controls\n", __FUNCTION__);
2039 pKids = (
struct _KIDS_ *)p0;
2047 memset(pKids + nKids - 1, 0,
sizeof(*pKids));
2053 WB_WARN_PRINT(
"%s - Invalid control name %-.20s\n", __FUNCTION__, p3);
2059 memcpy(tbuf, p3, p1 - p3);
2063 "%s - control %s\n", __FUNCTION__, tbuf);
2069 case DlgResourceKW__ID:
2072 WB_WARN_PRINT(
"%s - Ignoring ID for dialog box, %.20s\n", __FUNCTION__, p3);
2076 pKids[nKids - 1].iID = get_id_val(p3, p1 - p3);
2081 case DlgResourceKW__X:
2084 WB_WARN_PRINT(
"%s - Ignoring X for dialog box, %.20s\n", __FUNCTION__, p3);
2088 pKids[nKids - 1].iX = get_id_val(p3, p1 - p3);
2093 case DlgResourceKW__Y:
2096 WB_WARN_PRINT(
"%s - Ignoring Y for dialog box, %.20s\n", __FUNCTION__, p3);
2100 pKids[nKids - 1].iY = get_id_val(p3, p1 - p3);
2105 case DlgResourceKW__WIDTH:
2112 pKids[nKids - 1].iWidth = get_id_val(p3, p1 - p3);
2117 case DlgResourceKW__HEIGHT:
2124 pKids[nKids - 1].iHeight = get_id_val(p3, p1 - p3);
2129 case DlgResourceKW__VA_DLGTOP:
2132 WB_WARN_PRINT(
"%s - RESERVED: 'top aligned' property on dialog box\n", __FUNCTION__);
2142 case DlgResourceKW__VA_DLGBOTTOM:
2145 WB_WARN_PRINT(
"%s - RESERVED: 'bottom aligned' property on dialog box\n", __FUNCTION__);
2155 case DlgResourceKW__VA_DLGCENTER:
2158 WB_WARN_PRINT(
"%s - RESERVED: 'center aligned' property on dialog box\n", __FUNCTION__);
2168 case DlgResourceKW__HA_DLGLEFT:
2171 WB_WARN_PRINT(
"%s - RESERVED: 'left aligned' property on dialog box\n", __FUNCTION__);
2181 case DlgResourceKW__HA_DLGRIGHT:
2184 WB_WARN_PRINT(
"%s - RESERVED: 'right aligned' property on dialog box\n", __FUNCTION__);
2194 case DlgResourceKW__HA_DLGCENTER:
2197 WB_WARN_PRINT(
"%s - RESERVED: 'center aligned' property on dialog box\n", __FUNCTION__);
2207 case DlgResourceKW__VA_TEXT_TOP:
2210 WB_WARN_PRINT(
"%s - RESERVED: 'top text aligned' property on dialog box\n", __FUNCTION__);
2221 case DlgResourceKW__VA_TEXT_BOTTOM:
2224 WB_WARN_PRINT(
"%s - RESERVED: 'bottom text aligned' property on dialog box\n", __FUNCTION__);
2235 case DlgResourceKW__VA_TEXT_CENTER:
2238 WB_WARN_PRINT(
"%s - RESERVED: 'vertical center text aligned' property on dialog box\n", __FUNCTION__);
2249 case DlgResourceKW__HA_TEXT_LEFT:
2252 WB_WARN_PRINT(
"%s - RESERVED: 'left text aligned' property on dialog box\n", __FUNCTION__);
2263 case DlgResourceKW__HA_TEXT_RIGHT:
2266 WB_WARN_PRINT(
"%s - RESERVED: 'top text aligned' property on dialog box\n", __FUNCTION__);
2277 case DlgResourceKW__HA_TEXT_CENTER:
2280 WB_WARN_PRINT(
"%s - RESERVED: 'center text aligned' property on dialog box\n", __FUNCTION__);
2291 case DlgResourceKW__HRESIZE:
2298 WB_WARN_PRINT(
"%s - WARNING: 'HRESIZE' property on dialog control (ignored)\n", __FUNCTION__);
2303 case DlgResourceKW__VRESIZE:
2310 WB_WARN_PRINT(
"%s - WARNING: 'VRESIZE' property on dialog control (ignored)\n", __FUNCTION__);
2315 case DlgResourceKW__TITLE:
2324 WB_WARN_PRINT(
"%s - Not enough memory for dialog box title %-.20s\n", __FUNCTION__, p3);
2329 memcpy(pDlg->
szTitle, p3, p1 - p3);
2336 struct _KIDS_ *pKid = pKids + nKids - 1;
2341 pKid->szTitle =
WBAlloc(p1 - p3 + 1);
2344 WB_WARN_PRINT(
"%s - Not enough memory for control title %-.20s\n", __FUNCTION__, p3);
2349 memcpy(pKid->szTitle, p3, p1 - p3);
2350 pKid->szTitle[p1 - p3] = 0;
2357 case DlgResourceKW__FONT:
2359 "%s - font definition %-.20s\n", __FUNCTION__, p3);
2363 case DlgResourceKW__VISIBLE:
2366 WB_WARN_PRINT(
"%s - RESERVED: 'visible' property on dialog box\n", __FUNCTION__);
2375 case DlgResourceKW__INVISIBLE:
2378 WB_WARN_PRINT(
"%s - RESERVED: 'invisible' property on dialog box\n", __FUNCTION__);
2387 case DlgResourceKW__BORDER:
2390 WB_WARN_PRINT(
"%s - RESERVED: 'noborder' property on dialog box\n", __FUNCTION__);
2399 case DlgResourceKW__NOBORDER:
2402 WB_WARN_PRINT(
"%s - RESERVED: 'noborder' property on dialog box\n", __FUNCTION__);
2411 case DlgResourceKW__CLICKABLE:
2414 WB_WARN_PRINT(
"%s - RESERVED: 'clickable' property on dialog box\n", __FUNCTION__);
2423 case DlgResourceKW__CHECKED:
2426 WB_WARN_PRINT(
"%s - RESERVED: 'checked' property on dialog box\n", __FUNCTION__);
2438 case DlgResourceKW__ENABLED:
2441 WB_WARN_PRINT(
"%s - RESERVED: 'disabled' property on dialog box\n", __FUNCTION__);
2450 case DlgResourceKW__DISABLED:
2453 WB_WARN_PRINT(
"%s - RESERVED: 'disabled' property on dialog box\n", __FUNCTION__);
2467 for(i1=0; i1 < nKids; i1++)
2469 if(pKids[i1].szTitle)
2471 WBFree(pKids[i1].szTitle);
2473 if(pKids[i1].szProp)
2475 WBFree(pKids[i1].szProp);
2486 while(*p1 && *p1 <=
' ')
2492 WB_ERROR_PRINT(
"%s - NULL 'pKids' in InternalCreateChildWindowsSub\n", __FUNCTION__);
2493 *pszDialogResource = p2;
2500 iCurContentSize = ((nKids + 384) & 0xffffff00L)
2506 iCurContentSize = 0;
2508 WB_ERROR_PRINT(
"%s - NULL 'pwContents' in InternalCreateChildWindowsSub\n", __FUNCTION__);
2510 for(i1=0; i1 < nKids; i1++)
2512 if(pKids[i1].szTitle)
2514 WBFree(pKids[i1].szTitle);
2516 if(pKids[i1].szProp)
2518 WBFree(pKids[i1].szProp);
2524 *pszDialogResource = p1;
2546 WB_ERROR_PRINT(
"%s - NULL 'pwContents' (re-alloc) in InternalCreateChildWindowsSub\n", __FUNCTION__);
2547 for(i1=0; i1 < nKids; i1++)
2549 if(pKids[i1].szTitle)
2551 WBFree(pKids[i1].szTitle);
2553 if(pKids[i1].szProp)
2555 WBFree(pKids[i1].szProp);
2561 *pszDialogResource = p1;
2582 for(i1=0, iRval = 1; i1 < nKids; i1++)
2588 pEntry->
aClass = pKids[i1].aClass;
2589 pEntry->
iID = pKids[i1].iID;
2590 pEntry->
iX = pKids[i1].iX;
2591 pEntry->
iY = pKids[i1].iY;
2592 pEntry->
iWidth = pKids[i1].iWidth;
2593 pEntry->
iHeight = pKids[i1].iHeight;
2595 pEntry->
iFlags = pKids[i1].iFlags;
2601 pKids[i1].szTitle, pKids[i1].szProp);
2608 WB_ERROR_PRINT(
"%s - Unable to create control %d via WBDialogControlCreate\n", __FUNCTION__, i1);
2609 WB_WARN_PRINT(
"%s - class: %s title: %s id: %d\n", __FUNCTION__, p1, pKids[i1].szTitle, pKids[i1].iID);
2621 pEntry->
wID = pCtrl->
wID;
2628 for(i1=0; i1 < nKids; i1++)
2630 if(pKids[i1].szTitle)
2632 WBFree(pKids[i1].szTitle);
2634 if(pKids[i1].szProp)
2636 WBFree(pKids[i1].szProp);
2642 *pszDialogResource = p1;
XColor clrBD
border pixel color
Atom aLOSTFOCUS
CONTROL_NOTIFY ClientMessage for LOSTFOCUS event.
DIALOG_WINDOW structure, an extension of WBDialogWindow.
void WBSetWMProperties(Window wID, const char *szTitle, XSizeHints *pNormalHints, XWMHints *pWMHints, XClassHint *pClassHints)
assign standard WM (Window Manager) properties via XSetWMProperties
XColor clrBG
background pixel color
unsigned int ulTag
tag word, always assigned to DIALOG_ENTRY_TAG
Structure identifying one of the controls that appears on a dialog window.
void * DLGGetDialogWindowUserData(Window wID)
Returns a pointer to the dialog window's 'user data' assigned at create time.
'window helper' main header file for the X11workbench Toolkit API
unsigned long ulFlags
generic flag bits
Atom aGOTFOCUS
CONTROL_NOTIFY ClientMessage for GOTFOCUS event.
Horizontal text alignment bits.
set for "default" controls
#define WB_DEBUG_PRINT(L,...)
Preferred method of implementing conditional debug output.
Utilities for copying and drawing text, determining text extents, and so on.
BUTTON - Tri-state button.
int WBUnmapWindow(Display *pDisplay, Window wID)
wrapper for XUnmapWindow, makes window invisible without destroying it
BUTTON - Checkbox button.
void WBCreateWindowDefaultGC(Window wID, unsigned long clrFG, unsigned long clrBG)
creates a default WBGC for a window
WBDialogControl * WBDialogControlCreate(Atom aClass, WBDialogWindow *pOwner, WBDialogEntry *pDialogEntry, int iX, int iY, int iWidth, int iHeight, const char *szTitle, const char *szPropertyList)
Create a dialog control window.
Atom aLIST_NOTIFY
CONTROL_NOTIFY ClientMessage for LIST_NOTIFY event.
int WBShowModal(Window wID, int bMenuSplashFlag)
Shows a 'modal' window by processing events until the window closes.
WBDialogWindow * pOwner
pointer to owner dialog box
Window DLGGetNextDialogControl(WBDialogWindow *pDialog, Window idControl)
Return the Window ID of the NEXT dialog control within the 'tab order', based on the specified contro...
Auto-center mouse pointer.
WBWinEvent pDLGCallback
pointer to dialog window callback function
int iFlags
visibility, focus, etc.
int iID
control unique identifier (number or atom, as appropriate, unique to dialog window)
Atom aWM_DELETE_WINDOW
Delete Window notification event.
int DLGPixelHeight(WBDialogWindow *pDlg, int iHeight)
Height of a single dialog unit (in pixels)
Atom aWM_PROTOCOLS
WM supported protocols.
void * pUserData
user data that's assignable via API
int WBPostPriorityEvent(Window wID, XEvent *pEvent)
Places a copy of the specified event at the end of the priority (internal) event queue.
static __inline__ Display * WBGetDefaultDisplay(void)
Returns the default Display.
char * szTitle
title bar string (WBAlloc'd pointer, must WBFree on destroy)
'configuration helper' main header file for the X11 Work Bench Toolkit API
for edit controls, prevents trapping <ENTER>
Window DLGGetFirstDialogControl(WBDialogWindow *pDialog)
Return the Window ID of the FIRST dialog control within the 'tab order'.
Atom aDLG_FOCUS
dialog focus messages
Horizontally align text center.
Horizontally align text right.
void * WBReAlloc(void *pBuf, int nNewSize)
High performance memory sub-allocator 're-allocate'.
Atom aDIALOG_INIT
DIALOG_INIT ClientMessage, sent to dialog window callback on frame create.
prevents trapping <ESC> <ENTER> and anything else
WBDialogEntry * pwContents
WBAlloc'd array of child window/control information as WBDialogEntry following order of windows creat...
BUTTON - Radio button (generic)
WBDialogWindow * DLGCreateDialogWindow(Window wIDOwner, const char *szTitle, const char *szDialogResource, int iX, int iY, int iWidth, int iHeight, WBWinEvent pUserCallback, int iFlags, void *pUserData)
create a dialog window using a text resource
int nMaxContents
extent of 'pwContents' when pwContents is not NULL
#define COPY_COLOR_NAME(X, Y, Z)
macro to get a color name or use default if it does not exist in settings
Structure identifying a dialog (frame) window.
Atom aRADIOBUTTON_CONTROL
Standard Dialog Control - radio button - see RADIOBUTTON_CONTROL_STR.
int iWidth
width of control
void WBInvalidateGeom(Window wID, const WB_GEOM *pGeom, int bPaintNow)
'Paint' helper, invalidates a geometry for asynchronous Expose event generation
unsigned int ulTag
tag word, always assigned to DIALOG_WINDOW_TAG
#define DIALOG_WINDOW_TAG
void WBDeQuoteString(char *pString)
De-Quote a string 'in place', that is modifying the original string by removing quotes.
dialog box flag, can be resized vertically
void WBSetApplicationWindow(Window wID)
Assign the main 'Appklication' window.
const char * CHGetTextColor(Display *pDisplay)
returns text color
void * WBAlloc(int nSize)
High performance memory sub-allocator 'allocate'.
re-alignment with respect to center (as a percentage, stretching allowed)
Window WBGetParentWindow(Window wID)
Returns the window's parent (or None if there is no parent)
#define END_XCALL_DEBUG_WRAPPER
wrapper macro for calls into the X11 library. This macro follows the call(s)
Window DLGGetDialogControl(WBDialogWindow *pDialog, int iControlID)
returns the Window ID of a member control of the dialog window using the 'control ID'
BUTTON - 'First' radio button in a group.
int DLGProcessHotKey(WBDialogWindow *pDLG, XEvent *pEvent)
return non-zero if a hot-key was processed and no further processing should be done....
#define WB_ERROR_PRINT(...)
Preferred method of implementing an 'error level' debug message for all subsystems.
resize maintains position/size with respect to bottom
void DLGSetUserCallback(WBDialogWindow *pDialogWindow, WBWinEvent pCallBack)
Assign the callback function for a dialog window.
void WBFree(void *pBuf)
High performance memory sub-allocator 'free'.
Window wID
Window ID of the dialog control window.
int WBPostEvent(Window wID, XEvent *pEvent)
Places a copy of the specified event at the end of the regular (internal) event queue.
const char * CHGetDialogBackgroundColor(Display *pDisplay)
returns background color for dialog frame elements
void WBDestroyWindow(Window wID)
Destroy a window.
int iX
horizontal position of upper left corner of control (client-relative)
causes the control to be drawn 'disabled' and NOT be selectable for focus
Window wID
window ID of control
Vertically align text center (default)
int WBAllocUsableSize(void *pBuf)
High performance memory sub-allocator, similar to 'malloc_usable_size'.
int iClientWidth
width of the dialog window's client area
Atom aEDIT_CONTROL
Standard Dialog Control - editable text (single or multi-line, scrollable, clipboard) - see EDIT_CONT...
int DLGPixelWidth(WBDialogWindow *pDlg, int iWidth)
Width of a single dialog unit (in pixels)
Window WBCreateWindow(Display *pDisplay, Window wIDParent, WBWinEvent pProc, const char *szClass, int iX, int iY, int iWidth, int iHeight, int iBorder, int iIO, WB_UINT64 iFlags, XSetWindowAttributes *pXSWA)
Create a window.
set for 'pushbuttons' (which override 'default' for <ENTER>)
int WBIsChildWindow(Window wIDParent, Window wIDChild)
Returns non-zero if wIDParent is in a parent relationsihp with wIDChild.
int WBIsValid(Display *pDisplay, Window wID)
returns non-zero if 'valid' (i.e. 'not destroyed')
int iFlags
bitmask of attribute flags (see 'WBDialogWindowFlags' enumeration)
void DLGDestroyDialogWindow(Window wID)
Destroy a modeless dialog window via its window ID.
#define WB_STANDARD_INPUT_MASK
'Standard' input mask, bit flag for window creation
Atom aCANCELBUTTON_CONTROL
Standard Dialog Control - cancel pushbutton control (accepts <ESC> as hotkey) - see CANCELBUTTON_CONT...
int(* WBWinEvent)(Window wID, XEvent *pEvent)
event callback function type for window events
Atom aWM_TAKE_FOCUS
'Take Focus' - TODO document this properly
Atom aCHECKBUTTON_CONTROL
Standard Dialog Control - check[box] button - push-on/push-off with 'check mark' (or whatever) - see ...
void DLGAssignOwner(WBDialogWindow *pDlg, Window wIDOwner)
Assign owning window to dialog.
const char * WBDialogControlGetCaption(WBDialogControl *pCtrl)
Obtain a pointer to the assigned text for the 'CAPTION' property of a dialog control.
void DLGDestroyDialogWindow2(WBDialogWindow *pDialogWindow)
Destroy a modeless dialog window via a pointer to its WBDialogWindow structure.
resize maintains position/size with respect to top
Display * WBGetWindowDisplay(Window wID)
returns the Display associated with a window
Atom aCONTROL_NOTIFY
dialog control and child window notification messages
static __inline__ WBDialogWindow * DLGGetDialogWindowStruct(Window wID)
Returns a pointer to the dialog window's WBDialogWindow structure.
set when item gets focus. cleared when no focus
void WBSetWindowData(Window wID, int iIndex, void *pData)
assign 'data pointer' for a window and specified index value
resize maintains position/size with respect to right
Atom aFIRSTRADIOBUTTON_CONTROL
Standard Dialog Control - 'first' radio button - defines start of radio button 'group' - see FIRSTRAD...
void WBSetWMProtocols(Window wID, Atom aProperty,...)
re-assign standard WM (Window Manager) 'window type' properties and notify the root window (reserved)
'no border' flag (don't display a border - statics, typically)
#define WB_MIN_STD_CTRL_ID
WBDialogWindow wbDLG
WBDialogWIndow structure, required to be at the beginning.
#define BEGIN_XCALL_DEBUG_WRAPPER
wrapper macro for calls into the X11 library. This macro precedes the call(s)
re-alignment with respect to center (as a percentage, stretching allowed)
Horizontally align text left (default)
void WBSetInputFocus(Window wID)
set input focus to a specific window
struct s_DIALOG_WINDOW * pNext
internal use only, pointer to next entry in chain (linked list)
Window DLGGetPrevDialogControl(WBDialogWindow *pDialog, Window idControl)
Return the Window ID of the PREVIOUS dialog control within the 'tab order', based on the specified co...
Window wIDOwner
window ID of the dialog's OWNER (can be 'None', should be assigned for Modal dialogs)
Atom aBUTTON_PRESS
CONTROL_NOTIFY ClientMessage for BUTTON_PRESS event.
WBDialogEntry * DLGGetDialogControlEntry(WBDialogWindow *pDialog, Window idControl)
returns a pointer to the WBDialogEntry for a member control using the control's Window ID
Vertically align text top.
void WBDebugPrint(const char *pFmt,...) __attribute__((format(printf
conditional debug message output
resize maintains position/size with respect to left
Atom aTRISTATEBUTTON_CONTROL
Standard Dialog Control - tristate - like check, but with a third state - see TRISTATEBUTTON_CONTROL_...
void WBEndModal(Window wID, int iRval)
End a modal window with a specific return value.
BUTTON - 'type mask' for buttons.
set when item CAN have focus.
#define WB_KEYBOARD_INPUT_MASK
'Keyboard' input mask, bit flag for window creation
void DLGRecalcLayout(Window wID)
Force re-calculation of dialog window (and control) layout.
horizontal alignment mask
Vertical text alignment bits.
#define WB_IF_DEBUG_LEVEL(L)
Preferred method of implementing conditional debug 'if block' code.
struct s_DIALOG_WINDOW DIALOG_WINDOW
DIALOG_WINDOW structure, an extension of WBDialogWindow.
void WBDialogControlSetCheck(WBDialogControl *pCtrl, int iCheck)
Assign the TEXT property for a control, which is different from the CAPTION or Title.
dialog box flag, can be resized horizontally
const char * CHGetBorderColor(Display *pDisplay)
returns border color
Vertically align text bottom.
int WBMapWindow(Display *pDisplay, Window wID)
Wrapper for XMapWindow, makes window visible.
XColor clrFG
foreground pixel color
void WBDialogControlsInit(void)
Initialization function for dialog controls.
Window wID
window ID of the dialog (frame) window
#define WB_WARN_PRINT(...)
Preferred method of implementing a 'warning level' debug message for all subsystems.
int iClientHeight
height of the dialog window's client area
static __inline__ WBDialogControl * DLGGetDialogControlStruct(Window wID)
Returns a pointer to the WBDialogControl structure for a dialog control with validation....
Structure identifying the properties of a dialog box control.
int iY
vertical position of upper left corner of control (client-relative)
int nContents
size of 'pwContents' when pwContents is not NULL
int iHeight
height of control
void WBPostDelayedSetFocusAppEvent(Display *pDisplay, Window wID, Window wIDFrom, unsigned int iDelay)
Creates a 'set focus' ClientMessage event for the application event handler.
Atom aClass
control class identifier