/* ** dashlist.c ** ** How to make a widget to choose a dashlist. ** ** NOTE: This file uses static variables. Therefore, trying to use these ** functions to create more than one of these dashlist choice things ** will fail in a big way. */ /* $XFree86$ */ #include #include #include #include #include #include #include #include #include "xgc.h" static void change_dashlist(Widget, caddr_t, caddr_t); static short dashlist = 240; /* in binary, becomes the dashlist (240 = XXXX____) */ static Widget *dashes; /* the toggle widgets */ /* create_dashlist_choice(w) ** ------------------------- ** Inside w (a form widget), creates a bunch of little toggle buttons ** in a row, representing the dash list. There's also a label so ** the user knows what it is. */ void create_dashlist_choice(Widget w) { /* callback list for the toggle widgets */ static XtCallbackRec callbacklist[] = { {(XtCallbackProc) change_dashlist, NULL}, {NULL, NULL} }; /* ArgList for the label */ static Arg labelargs[] = { {XtNborderWidth, (XtArgVal) 0}, {XtNjustify, (XtArgVal) XtJustifyRight}, {XtNvertDistance, (XtArgVal) 4} }; /* ArgList for the toggles */ static Arg dashargs[] = { {XtNcallback, (XtArgVal) NULL}, {XtNhorizDistance, (XtArgVal) NULL}, {XtNfromHoriz, (XtArgVal) NULL}, {XtNwidth, (XtArgVal) 10}, {XtNheight, (XtArgVal) 10}, {XtNhighlightThickness, (XtArgVal) 1}, {XtNstate, (XtArgVal) False}, {XtNlabel, (XtArgVal) ""} }; static Widget label; /* the label, of course */ static int *dashinfo; /* contains integers saying which bit a particular button is; sent to change_dashlist to tell it which bit got changed */ int i; /* counter */ char name[11]; /* allocate space for stuff that we don't know the size of yet */ dashes = (Widget *) malloc(DASHLENGTH * sizeof(Widget)); dashinfo = (int *) malloc(DASHLENGTH * sizeof(int)); /* make the label widget */ label = XtCreateManagedWidget("dashlist",labelWidgetClass,w, labelargs,XtNumber(labelargs)); dashargs[0].value = (XtArgVal) callbacklist; for (i=0;i