X11 Work Bench Toolkit  1.0
dialog_controls.h
Go to the documentation of this file.
1 
2 // //
3 // _ _ _ _ _ _ //
4 // __| |(_) __ _ | | ___ __ _ ___ ___ _ __ | |_ _ __ ___ | | ___ | |__ //
5 // / _` || | / _` || | / _ \ / _` | / __|/ _ \ | '_ \ | __|| '__|/ _ \ | |/ __| | '_ \ //
6 // | (_| || || (_| || || (_) || (_| | | (__| (_) || | | || |_ | | | (_) || |\__ \ _| | | | //
7 // \__,_||_| \__,_||_| \___/ \__, |_____\___|\___/ |_| |_| \__||_| \___/ |_||___/(_)_| |_| //
8 // |___/|_____| //
9 // //
10 // dialog control support //
11 // //
13 
14 /*****************************************************************************
15 
16  X11workbench - X11 programmer's 'work bench' application and toolkit
17  Copyright (c) 2010-2016 by Bob Frazier (aka 'Big Bad Bombastic Bob')
18  all rights reserved
19 
20  DISCLAIMER: The X11workbench application and toolkit software are supplied
21  'as-is', with no warranties, either implied or explicit.
22  Any claims to alleged functionality or features should be
23  considered 'preliminary', and might not function as advertised.
24 
25  BSD-like license:
26 
27  There is no restriction as to what you can do with this software, so long
28  as you include the above copyright notice and DISCLAIMER for any distributed
29  work that is equal to or derived from this one, along with this paragraph
30  that explains the terms of the license if the source is also being made
31  available. A "derived work" describes a work that uses a significant portion
32  of the source files or algorithms that are included with this one.
33  Specifically excluded from this are files that were generated by the software,
34  or anything that is included with the software that is part of another package
35  (such as files that were created or added during the 'configure' process).
36  Specifically included is the use of part or all of any of the X11 workbench
37  toolkit source or header files in your distributed application. If you do not
38  ship the source, the above copyright statement is still required to be placed
39  in a reasonably prominent place, such as documentation, splash screens, and/or
40  'about the application' dialog boxes.
41 
42  Use and distribution are in accordance with GPL, LGPL, and/or the above
43  BSD-like license. See COPYING and README files for more information.
44 
45 
46  Additional information at http://sourceforge.net/projects/X11workbench
47 
48 ******************************************************************************/
49 
50 
51 #ifndef DIALOG_CONTROLS_H_INCLUDED
52 #define DIALOG_CONTROLS_H_INCLUDED
53 
54 #include "window_helper.h"
55 #include "dialog_window.h"
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif // __cplusplus
60 
61 
81 #define DIALOG_CONTROL_TAG (*((const unsigned int *)"DLGC"))
82 
112 typedef struct __WB_DIALOG_PROP__
113 {
114  Atom aProp;
115  unsigned long lVal;
116  void *pVal;
118 
119 
155 {
157  int nProps,
159  nMaxProps;
170 
171 
222 typedef struct __WB_DIALOG_CONTROL__
223 {
224  unsigned int ulTag;
225  Window wID;
226  Atom aClass;
230  unsigned long ulFlags;
231  XColor clrFG,
232  clrBG,
233  clrBD;
234  XColor clrBD2,
235  clrBD3;
236  XColor clrHFG,
237  clrHBG;
238  XColor clrAFG,
239  clrABG;
240  char *pCaption;
243 
244  // unique per-control data members follow (see cbStructSize for validation)
245 
247 
248 
258 void WBDialogControlsInit(void); // call once before using (dialog_window.c does this for you)
259 
281  WBDialogEntry *pDialogEntry, // pointer to the dialog entry I'll be using
282  int iX, int iY, int iWidth, int iHeight,
283  const char *szTitle, const char *szPropertyList);
284 
298 void DLGRegisterControlCallback(WBDialogControl *pDialogControl, const char *szClassName, WBWinEvent pCallback);
299 
300 
301 // generic property list helpers (low level)
307 int WBDialogControlSetDialogProp(WBDialogControl *pCtrl, WB_DIALOG_PROP *pPropVal); // returns 0 on success
313 void WBDialogControlDelDialogProp(WBDialogControl *pCtrl, Atom aProp);
326 {
327  if(pCtrl)
328  {
329  return pCtrl->pPropList;
330  }
331  return NULL;
332 }
333 
334 // generic property list helpers (mid-level)
335 
341 int WBDialogControlSetPropList(WBDialogControl *pCtrl, const char *szPropList); // prop:value prop:"value" etc. separated by white space
351 int WBDialogControlSetProperty(WBDialogControl *pCtrl, Atom aPropName, const char *szPropVal);
362 void WBDialogControlSetProperty2(WBDialogControl *pCtrl, Atom aPropName, void *szPropVal); // szPropVal must be WBAlloc'd pointer or NULL
363 
373 const char *WBDialogControlGetProperty(WBDialogControl *pCtrl, Atom aPropName);
384 void *WBDialogControlGetProperty2(WBDialogControl *pCtrl, Atom aPropName); // returns actual WBAlloc'd pointer or NULL
385 
386 // NOTE: use WBDialogControlSetProperty2 to directly assign WBAlloc'd pointer, and modify actual data returned by above
387 // Assigning different pointer in WBDialogControlGetProperty2 'WBFree's existing pointer
388 // Destroying property list does the same thing.
389 
390 
401 static __inline__ WBDialogControl *DLGGetDialogControlStruct(Window wID) // for frame windows, returns the frame window struct
402 {
403  WBDialogControl *pRval = (WBDialogControl *)WBGetWindowData(wID, 0); // offset 0 for window-specific structs
404 
405  if(pRval && pRval->ulTag == DIALOG_CONTROL_TAG)
406  return(pRval);
407 
408  return(NULL);
409 }
410 
411 
412 
413 // dialog control property management (high level)
414 
424 void WBDialogControlSetCaption(WBDialogControl *pCtrl, const char *szCaption); // caption (all, equiv to 'title')
434 const char *WBDialogControlGetCaption(WBDialogControl *pCtrl);
435 
445 void WBDialogControlSetPixmap(WBDialogControl *pCtrl, Pixmap pixmap); // pixmaps (image, icon, button?)
456 
470 void WBDialogControlSetIconPixmap(WBDialogControl *pCtrl, Pixmap pixmap, Pixmap pixmap2); // icons only
484 Pixmap WBDialogControlGetIconPixmap(WBDialogControl *pCtrl, Pixmap *pPixmap2);
485 
494 static __inline__ void WBDialogControlSetText(WBDialogControl *pCtrl, const char *szText)
495 {
496 #ifdef DIALOG_SUPPORT_C
497 extern Atom aDLGC_TEXT;
498 #else // DIALOG_SUPPORT_C
499 extern const Atom aDLGC_TEXT;
500 #endif // DIALOG_SUPPORT_C
501 
502  // multi-line edit, listboxes, and combo boxes use this
503 
504  WBDialogControlSetProperty(pCtrl, aDLGC_TEXT, szText);
505 }
506 
515 static __inline__ const char *WBDialogControlGetText(WBDialogControl *pCtrl)
516 {
517 #ifdef DIALOG_SUPPORT_C
518 extern Atom aDLGC_TEXT;
519 #else // DIALOG_SUPPORT_C
520 extern const Atom aDLGC_TEXT;
521 #endif // DIALOG_SUPPORT_C
522 
523  return WBDialogControlGetProperty(pCtrl, aDLGC_TEXT);
524 }
525 
526 
527 
528 // combined functionality with dialog window
529 
542 static __inline__ WBDialogControl *DLGGetDialogControlStructFromID(WBDialogWindow *pDialog, int iControlID)
543 {
544  if(pDialog)
545  {
546  Window idCtrl = DLGGetDialogControl(pDialog, iControlID);
547  if(idCtrl > 0)
548  {
549  WBDialogControl *pRval = (WBDialogControl *)WBGetWindowData(idCtrl, 0); // offset 0 for window-specific structs
550 
551  if(pRval && pRval->ulTag == DIALOG_CONTROL_TAG)
552  return(pRval);
553  }
554  }
555  return NULL;
556 }
557 
573 static __inline__ void DLGSetControlCaption(WBDialogWindow *pDialog, int iControlID, const char *szCaption)
574 {
575  if(pDialog)
576  {
577  Window idCtrl = DLGGetDialogControl(pDialog, iControlID);
578  if(idCtrl > 0)
579  {
580  WBDialogControl *pCtrl = (WBDialogControl *)WBGetWindowData(idCtrl, 0); // offset 0 for window-specific structs
581 
582  if(pCtrl && pCtrl->ulTag == DIALOG_CONTROL_TAG)
583  {
584  WBDialogControlSetCaption(pCtrl, szCaption);
585  }
586  }
587  }
588 }
589 
604 static __inline__ const char * DLGGetControlCaption(WBDialogWindow *pDialog, int iControlID)
605 {
606  if(pDialog)
607  {
608  Window idCtrl = DLGGetDialogControl(pDialog, iControlID);
609  if(idCtrl > 0)
610  {
611  WBDialogControl *pCtrl = (WBDialogControl *)WBGetWindowData(idCtrl, 0); // offset 0 for window-specific structs
612 
613  if(pCtrl && pCtrl->ulTag == DIALOG_CONTROL_TAG)
614  {
615  return WBDialogControlGetCaption(pCtrl);
616  }
617  }
618  }
619 
620  return NULL;
621 }
622 
638 static __inline__ void DLGSetControlText(WBDialogWindow *pDialog, int iControlID, const char *szText)
639 {
640  if(pDialog)
641  {
642  Window idCtrl = DLGGetDialogControl(pDialog, iControlID);
643  if(idCtrl > 0)
644  {
645  WBDialogControl *pCtrl = (WBDialogControl *)WBGetWindowData(idCtrl, 0); // offset 0 for window-specific structs
646 
647  if(pCtrl && pCtrl->ulTag == DIALOG_CONTROL_TAG)
648  {
649  WBDialogControlSetText(pCtrl, szText);
650  }
651  }
652  }
653 }
654 
669 static __inline__ const char * DLGGetControlText(WBDialogWindow *pDialog, int iControlID)
670 {
671  if(pDialog)
672  {
673  Window idCtrl = DLGGetDialogControl(pDialog, iControlID);
674  if(idCtrl > 0)
675  {
676  WBDialogControl *pCtrl = (WBDialogControl *)WBGetWindowData(idCtrl, 0); // offset 0 for window-specific structs
677 
678  if(pCtrl && pCtrl->ulTag == DIALOG_CONTROL_TAG)
679  {
680  return WBDialogControlGetText(pCtrl);
681  }
682  }
683  }
684 
685  return NULL;
686 }
687 
688 // simplified string property handlers
689 
708 static __inline__ int DLGSetControlProperty(WBDialogWindow *pDialog, int iControlID, Atom aPropName, const char *szPropVal)
709 {
710  if(pDialog)
711  {
712  Window idCtrl = DLGGetDialogControl(pDialog, iControlID);
713  if(idCtrl > 0)
714  {
715  WBDialogControl *pCtrl = (WBDialogControl *)WBGetWindowData(idCtrl, 0); // offset 0 for window-specific structs
716 
717  if(pCtrl && pCtrl->ulTag == DIALOG_CONTROL_TAG)
718  {
719  return WBDialogControlSetProperty(pCtrl, aPropName, szPropVal);
720  }
721  }
722  }
723 
724  return -1; // error
725 }
726 
745 static __inline__ const char * DLGGetControlProperty(WBDialogWindow *pDialog, int iControlID, Atom aPropName)
746 {
747  if(pDialog)
748  {
749  Window idCtrl = DLGGetDialogControl(pDialog, iControlID);
750  if(idCtrl > 0)
751  {
752  WBDialogControl *pCtrl = (WBDialogControl *)WBGetWindowData(idCtrl, 0); // offset 0 for window-specific structs
753 
754  if(pCtrl && pCtrl->ulTag == DIALOG_CONTROL_TAG)
755  {
756  return WBDialogControlGetProperty(pCtrl, aPropName);
757  }
758  }
759  }
760 
761  return NULL;
762 }
763 
764 
768 // standard control IDs
769 #define WB_MIN_STD_CTRL_ID 0x7ffffff0
770 #define IDOK 0x7ffffff0
771 #define IDNO 0x7ffffff1
772 #define IDYES 0x7ffffff2
773 #define IDABORT 0x7ffffff3
774 #define IDRETRY 0x7ffffff4
775 #define IDIGNORE 0x7ffffff5
776 #define IDCANCEL 0x7fffffff
777 #define IDSTATIC -1
778 #define IDNONE 0
781 // standard atoms for control types
782 
784 #define FRAME_CONTROL_STR "Frame"
786 #define TEXT_CONTROL_STR "Text"
788 #define ICON_CONTROL_STR "Icon"
790 #define IMAGE_CONTROL_STR "Image"
792 #define EDIT_CONTROL_STR "Edit"
794 #define PUSHBUTTON_CONTROL_STR "PushButton"
796 #define DEFPUSHBUTTON_CONTROL_STR "DefPushButton"
798 #define CANCELBUTTON_CONTROL_STR "CancelButton"
800 #define RADIOBUTTON_CONTROL_STR "RadioButton"
802 #define FIRSTRADIOBUTTON_CONTROL_STR "FirstRadioButton"
804 #define CHECKBUTTON_CONTROL_STR "CheckButton"
806 #define TRISTATEBUTTON_CONTROL_STR "TriStateButton"
808 #define HSCROLL_CONTROL_STR "HScroll"
810 #define VSCROLL_CONTROL_STR "VScroll"
812 #define SLIDER_CONTROL_STR "Slider"
814 #define KNOB_CONTROL_STR "Knob"
816 #define LIST_CONTROL_STR "List"
818 #define COMBO_CONTROL_STR "Combo"
820 #define TREE_CONTROL_STR "Tree"
822 #define COMBOTREE_CONTROL_STR "ComboTree"
824 #define FILE_LIST_CONTROL_STR "FileList"
826 #define FILE_COMBO_CONTROL_STR "FileCombo"
828 #define PATH_TREE_CONTROL_STR "PathTree"
830 #define TAB_CONTROL_STR "Tab"
833 // atoms and strings for standard control types (doxygen - these are documented in dialog_controls.c)
834 #ifndef DIALOG_SUPPORT_C
835 
836 // static controls
837 
838 extern const Atom aFRAME_CONTROL; // transparent frame with optional text - \ref FRAME_CONTROL_STR
839 extern const Atom aTEXT_CONTROL; // static text (single or multi-line) - \ref TEXT_CONTROL_STR
840 extern const Atom aICON_CONTROL; // icon container (has a nice 3D border) - \ref ICON_CONTROL_STR
841 extern const Atom aIMAGE_CONTROL; // generic image/pixmap holder - \ref IMAGE_CONTROL_STR
842 
843 
844 // text entry
845 
846 extern const Atom aEDIT_CONTROL; // editable text (single or multi-line, scrollable, clipboard) - \ref EDIT_CONTROL_STR
847 
848 
849 // buttons, knobs, and sliders
850 
851 extern const Atom aPUSHBUTTON_CONTROL; // Pushbutton control - \ref PUSHBUTTON_CONTROL_STR
852 extern const Atom aDEFPUSHBUTTON_CONTROL; // default Pushbutton control (has dark border, accepts <ENTER> as hotkey) - \ref DEFPUSHBUTTON_CONTROL_STR
853 extern const Atom aCANCELBUTTON_CONTROL; // cancel pushbutton control (accepts <ESC> as hotkey) - \ref CANCELBUTTON_CONTROL_STR
854 extern const Atom aRADIOBUTTON_CONTROL; // radio button - \ref RADIOBUTTON_CONTROL_STR
855 extern const Atom aFIRSTRADIOBUTTON_CONTROL; // 'first' radio button - defines start of radio button 'group' - \ref FIRSTRADIOBUTTON_CONTROL_STR
856 extern const Atom aCHECKBUTTON_CONTROL; // check[box] button - push-on/push-off with 'check mark' (or whatever) - \ref CHECKBUTTON_CONTROL_STR
857 extern const Atom aTRISTATEBUTTON_CONTROL; // tristate - like check, but with a third state - \ref TRISTATEBUTTON_CONTROL_STR
858 extern const Atom aHSCROLL_CONTROL; // horizontal scroll - \ref HSCROLL_CONTROL_STR
859 extern const Atom aVSCROLL_CONTROL; // vertical scroll - \ref VSCROLL_CONTROL_STR
860 extern const Atom aSLIDER_CONTROL; // volume control (slider bar) (h or v depending on geometry) - \ref SLIDER_CONTROL_STR
861 extern const Atom aKNOB_CONTROL; // "volume knob" (270 degrees of rotation, left to right) - \ref KNOB_CONTROL_STR
862 
863 
864 // lists
865 
866 extern const Atom aLIST_CONTROL; // list - single, multi, extended select (h, v, multicol) - \ref LIST_CONTROL_STR
867 extern const Atom aCOMBO_CONTROL; // classic 'combo box' control - \ref COMBO_CONTROL_STR
868 extern const Atom aTREE_CONTROL; // class 'tree' control - \ref TREE_CONTROL_STR
869 extern const Atom aCOMBOTREE_CONTROL; // 'combo tree' (tree with interlocked edit/text box like combo box) - \ref COMBOTREE_CONTROL_STR
870 
871 
872 // file lists
873 
874 extern const Atom aFILE_LIST_CONTROL; // File List - \ref FILE_LIST_CONTROL_STR
875 extern const Atom aFILE_COMBO_CONTROL; // file combo control - \ref FILE_COMBO_CONTROL_STR
876 extern const Atom aPATH_TREE_CONTROL; // path tree - directory hierarchy - \ref PATH_TREE_CONTROL_STR
877 
878 
879 // containers
880 
881 extern const Atom aTAB_CONTROL; // 'tab' container (auto enable/disable contents) - \ref TAB_CONTROL_STR
882 
883 
884 
885 // messages
886 
887 // generic control notification - use aCONTROL_NOTIFY (doxygen docs in dialog_controls.c)
888 
889 //extern const Atom aCONTROL_NOTIFY;
890 // 'notify' message - l[0] is notify code, l[1] is control ID, l[2] is pointer to control object
891 // others are message-specific
892 
893 // CONTROL_NOTIFY "NOTIFICATION" CODES (code will be in data.l[0])
894 // button-specific notifications
895 extern const Atom aBUTTON_PRESS;
896 // l[1] is control ID, l[2] is (truncated) pointer to pDlgControlEntry
897 
898 // list-specific
899 extern const Atom aLIST_NOTIFY; // also applies to tab controls, combos, etc.
900 // data.l[1] is control ID, data.l[2] is notification, data.l[3] is selection index
901 // on receipt default dialog proc will end dialog with 'IDOK'
902 
903 // edit-specific, combo-specific
904 extern const Atom aTEXT_CHANGED;
905 extern const Atom aTEXTSELECT_CHANGE;
906 
907 
908 // other notification messages
909 
910 // scroll notifications
911 extern const Atom aSCROLL_NOTIFY; // specific notification for scrollbars (see enumeration, below)
912 // data.l[0] is scrollbar enum, data.l[1] is notification enum, data.l[2] is optional position modifier
913 
914 
915 // common to all
916 extern const Atom aGOTFOCUS; // sent as its own message type - data.l[0] = wID, data.l[1] = pDlgControlEntry
917 extern const Atom aLOSTFOCUS; // sent as its own message type - data.l[0] = wID, data.l[1] = pDlgControlEntry
918 
919 
920 // low level common (not all return these)
921 extern const Atom aMOUSE_DOWN;
922 extern const Atom aMOUSE_UP;
923 extern const Atom aMOUSE_DRAG;
924 extern const Atom aKEY_DOWN;
925 extern const Atom aKEY_UP;
926 extern const Atom aKEYSTROKE; // valid key down/up sequence, including repeat
927 
928 
929 // other dialog-related message atoms
930 extern const Atom aDIALOG_INIT;
931 
932 //extern const Atom aDIALOG_SETFOCUS; // l[0] is <,0,> for prev, 'set to', next. For 'set to' l[1] is item ID
933 extern Atom aDLGC_PROP_NOTIFY; // l[0] is the property Atom
934 
935 // control-specific 'globally known' atoms
936 
937 extern Atom aDLGC_PATH; // PATH information for file-related controls
938 
939 #endif // DIALOG_SUPPORT_C
940 
941 
942 // NOTIFICATION PARAMETERS
943 
944 // data.l[2] parameter definitions for aCONTROL_NOTIFY + aLIST_NOTIFY ClientMessage
945 
947 #define WB_LIST_NONE 0
949 #define WB_LIST_SELCHANGE 1
951 #define WB_LIST_DBLCLICK 2
955 // parameter enumerations for aSCROLL_NOTIFY ClientMessage
956 
957 // consider moving this to another group
965 enum
966 {
970 
978 
980 
983 
984  WB_SCROLL_NA = 0x80000000
985 };
986 
987 
989 // control-specific definitions
991 
992 // LISTBOX-related (applies to anything with a LIST property)
993 
1001 {
1003  ControlListIndex_LAST = 0x7fffffff,
1008 };
1009 
1015 {
1024 
1025  // others are reserved
1026 };
1027 
1028 
1029 
1030 // 'ulFlags' bits 0000ffff is "common", 00ff0000 is control-specific, ff000000 is 'reserved for custom'
1040 {
1041  // COMMON bits (APPLIES TO ALL)
1042  CONTROL_Reserved00 = 0x00000001,
1043  CONTROL_Reserved01 = 0x00000002,
1044  CONTROL_Reserved02 = 0x00000004,
1045  CONTROL_Reserved03 = 0x00000008,
1046  CONTROL_Reserved04 = 0x00000010,
1047  CONTROL_Reserved05 = 0x00000020,
1048  CONTROL_Reserved06 = 0x00000040,
1049  CONTROL_Reserved07 = 0x00000080,
1050  CONTROL_Reserved08 = 0x00000100,
1051  CONTROL_Reserved09 = 0x00000200,
1052  CONTROL_Reserved10 = 0x00000400,
1053  CONTROL_Reserved11 = 0x00000800,
1054  CONTROL_Reserved12 = 0x00001000,
1055  CONTROL_Reserved13 = 0x00002000,
1056  CONTROL_Reserved14 = 0x00004000,
1057 
1059  // NOTE: A \ref WBListCurSel struct must immediately follow the \ref WBDialogControl members
1060 
1061  // CONTROL TYPE-SPECIFIC bits
1062 
1063  // STATIC bits
1064 
1065  STATIC_Frame = 0x00010000,
1066  STATIC_Text = 0x00020000,
1067  STATIC_Icon = 0x00030000,
1068  STATIC_Image = 0x00040000,
1069 
1070  STATIC_TYPEMASK = 0x000f0000,
1071 
1072  STATIC_3DBorder = 0x00100000,
1073 
1074 
1075  // BUTTON bits
1076 
1077  BUTTON_PushButton = 0x00010000,
1078  BUTTON_DefPushButton = 0x00020000,
1079  BUTTON_CancelButton = 0x00030000,
1080  BUTTON_RadioButton = 0x00040000,
1082  BUTTON_CheckButton = 0x00060000,
1083  BUTTON_TriStateButton = 0x00070000,
1084 
1085  BUTTON_TYPEMASK = 0x000f0000,
1086 
1087 
1088  // others here
1089 
1090  // auto-alignment flags (for resizable dialog boxes)
1091 
1097 
1103 
1105 
1106  // reserved for custom controls
1107 
1108  CUSTOM_Reserved24 = 0x01000000,
1109  CUSTOM_Reserved25 = 0x02000000,
1110  CUSTOM_Reserved26 = 0x04000000,
1111  CUSTOM_Reserved27 = 0x08000000,
1112  CUSTOM_Reserved28 = 0x10000000,
1113  CUSTOM_Reserved29 = 0x20000000,
1114  CUSTOM_Reserved30 = 0x40000000,
1115  CUSTOM_Reserved31 = 0x80000000
1116 };
1117 
1118 
1120 // control-specific utility functions
1122 
1128 void * DLGCDefaultListInfoAllocator(const void *pData, int cbData);
1129 
1135 const char * DLGGetControlListText(WBDialogControl *pCtrl, int iIndex); // retrieve data pointer for single list entry
1141 const void * DLGGetControlListData(WBDialogControl *pCtrl, int iIndex); // retrieve data pointer for single list entry
1142 
1159 int DLGInitControlListInfo(WBDialogControl *pCtrl, int nFlags,
1160  void *(*pfnAllocator)(const void *,int), void (*pfnDestructor)(void *),
1161  void (*pfnDisplay)(WBDialogControl *, void *, int, GC, WB_GEOM *, XFontSet),
1162  int (*pfnSort)(const void *, const void *));
1163 
1172 #define DLGInitControlListInfoDefault(X) \
1173  DLGInitControlListInfo(X, ListInfoFlags_SORTED, DLGCDefaultListInfoAllocator, WBFree, NULL, NULL)
1174 
1175 
1176 
1199 int DLGModifyControlListInfo(WBDialogControl *pCtrl, int bFlags, int nFlags,
1200  int bAllocator, void *(*pfnAllocator)(const void *,int),
1201  int bDestructor, void (*pfnDestructor)(void *),
1202  int bDisplay, void (*pfnDisplay)(WBDialogControl *, void *, int, GC, WB_GEOM *, XFontSet),
1203  int bSort, int (*pfnSort)(const void *, const void *));
1204 
1222 int DLGAddControlListEntry(WBDialogControl *pCtrl, const char *pData, long cbData, int iIndex);
1223 
1234 void DLGDelControlListEntry(WBDialogControl *pCtrl, int iIndex); // delete item at index 'iIndex' (iIndex < 0 to delete all)
1235 
1247 int DLGGetControlListSelection(WBDialogControl *pCtrl); // get selection for single-selection list
1248 
1260 void DLGSetControlListSelection(WBDialogControl *pCtrl, int iIndex); // set single selection for list
1261 
1274 void DLGSetControlListSelectionValue(WBDialogControl *pCtrl, int iIndex, int iSelState); // set sel state for specific index
1275 
1298 int DLGGetControlListSelectionBits(WBDialogControl *pCtrl, unsigned int *piBits, int nSize);
1299  // piBits and nSize must be large enough to accomodate bits. 'nSize' is number of integers (not bytes)
1300  // return value is 0 for no sel, >0 for number of selections, < 0 on error. assume 32 bits per entry ( LSbit is entry '0' )
1301  // a '1' in a bit position indicates the entry has been selected.
1302 
1313 char * DLGGetControlListSelectionText(WBDialogControl *pCtrl); // caller must 'WBFree()' non-NULL returned pointer
1314  // this returns TEXT elements (separated by line feeds) for corresponding selected LB entries
1315  // use this for multi-selection listboxes with unique text entries for which the list text is desired
1316 
1317 
1318 // SCROLL NOTIFICATION GENERATOR - generic pre-filter / handler for embedded scroll bars
1319 
1336 int DLGScrollBarHandler(Window wID, WBDialogControl *pCtrl, XEvent *pEvent);
1337  // NOTE: if this function returns a non-zero value, that same value should be returned
1338  // unmodified from the control's message callback in order for this to work properly.
1339 
1340 
1341 // notification methods (inline functions) - messages "sent" (not placed in queue)
1342 
1353 static __inline__ void DLGNotifyOwner(WBDialogControl *pDialogControl, Atom aNotify,
1354  long lData0, long lData1, long lData2, long lData3, long lData4)
1355 {
1356 Display *pDisplay = WBGetWindowDisplay(pDialogControl->wID);
1357 
1358  if(pDialogControl->pOwner)
1359  {
1360 // C99 constructs are cool, but maybe not portable...
1361 // XClientMessageEvent evt = {
1362 // .type=ClientMessage,
1363 // .serial=0,
1364 // .send_event=0,
1365 // .display=pDisplay,
1366 // .window=pDialogControl->pOwner->wID,
1367 // .message_type=aNotify, // typically aCONTROL_NOTIFY
1368 // .format=32
1369 // };
1370  XClientMessageEvent evt;
1371 
1372  evt.type=ClientMessage;
1373  evt.serial=0;
1374  evt.send_event=0;
1375  evt.display=pDisplay;
1376  evt.window=pDialogControl->pOwner->wID;
1377  evt.message_type=aNotify; // typically aCONTROL_NOTIFY
1378  evt.format=32;
1379 
1380  evt.data.l[0] = lData0; // nearly always an Atom
1381  evt.data.l[1] = lData1; // typically the window ID
1382  evt.data.l[2] = lData2;
1383  evt.data.l[3] = lData3;
1384  evt.data.l[4] = lData4;
1385 
1386  WBWindowDispatch(pDialogControl->pOwner->wID, (XEvent *)&evt);
1387  }
1388 }
1389 
1407 static __inline__ void DLGNotifySelf(WBDialogControl *pDialogControl, Atom aNotify,
1408  long lData0, long lData1, long lData2, long lData3, long lData4)
1409 {
1410 Display *pDisplay = WBGetWindowDisplay(pDialogControl->wID);
1411 
1412  XClientMessageEvent evt = {
1413  .type=ClientMessage,
1414  .serial=0,
1415  .send_event=0,
1416  .display=pDisplay,
1417  .window=pDialogControl->wID,
1418  .message_type=aNotify,
1419  .format=32
1420  };
1421  evt.data.l[0] = lData0;
1422  evt.data.l[1] = lData1;
1423  evt.data.l[2] = lData2;
1424  evt.data.l[3] = lData3;
1425  evt.data.l[4] = lData4;
1426 
1427  WBWindowDispatch(pDialogControl->wID, (XEvent *)&evt);
1428 }
1429 
1430 // asynchronous versions (posts priority event on message queue)
1431 
1443 static __inline__ void DLGNotifyOwnerAsync(WBDialogControl *pDialogControl, Atom aNotify,
1444  long lData0, long lData1, long lData2, long lData3, long lData4)
1445 {
1446 Display *pDisplay = WBGetWindowDisplay(pDialogControl->wID);
1447 
1448  if(pDialogControl->pOwner)
1449  {
1450  XClientMessageEvent evt = {
1451  .type=ClientMessage,
1452  .serial=0,
1453  .send_event=0,
1454  .display=pDisplay,
1455  .window=pDialogControl->pOwner->wID,
1456  .message_type=aNotify,
1457  .format=32
1458  };
1459  evt.data.l[0] = lData0;
1460  evt.data.l[1] = lData1;
1461  evt.data.l[2] = lData2;
1462  evt.data.l[3] = lData3;
1463  evt.data.l[4] = lData4;
1464 
1465  WBPostPriorityEvent(pDialogControl->pOwner->wID, (XEvent *)&evt);
1466  }
1467 }
1468 
1487 static __inline__ void DLGNotifySelfAsync(WBDialogControl *pDialogControl, Atom aNotify,
1488  long lData0, long lData1, long lData2, long lData3, long lData4)
1489 {
1490 Display *pDisplay = WBGetWindowDisplay(pDialogControl->wID);
1491 
1492  XClientMessageEvent evt = {
1493  .type=ClientMessage,
1494  .serial=0,
1495  .send_event=0,
1496  .display=pDisplay,
1497  .window=pDialogControl->wID,
1498  .message_type=aNotify,
1499  .format=32
1500  };
1501  evt.data.l[0] = lData0;
1502  evt.data.l[1] = lData1;
1503  evt.data.l[2] = lData2;
1504  evt.data.l[3] = lData3;
1505  evt.data.l[4] = lData4;
1506 
1507  WBPostPriorityEvent(pDialogControl->wID, (XEvent *)&evt);
1508 }
1509 
1510 #ifdef __cplusplus
1511 };
1512 #endif // __cplusplus
1513 
1514 
1515 #endif // DIALOG_CONTROLS_H_INCLUDED
1516 
1517