home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / windows / x / motif / 5770 < prev    next >
Encoding:
Internet Message Format  |  1992-08-22  |  3.1 KB

  1. Path: sparky!uunet!olivea!mintaka.lcs.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!timkwan
  2. From: timkwan@athena.mit.edu (Unknown)
  3. Newsgroups: comp.windows.x.motif
  4. Subject: Resetting radiobuttons with new pixmaps
  5. Message-ID: <1992Aug22.111856.16746@athena.mit.edu>
  6. Date: 22 Aug 92 11:18:56 GMT
  7. Sender: news@athena.mit.edu (News system)
  8. Organization: Massachusetts Institute of Technology
  9. Lines: 87
  10. Nntp-Posting-Host: w20-575-79.mit.edu
  11.  
  12.  
  13. Help!  I create pushbuttons on the fly according to some user
  14. response.  Each pushbutton has the same activate callback.  The
  15. callback function opens a dialog box (created only once and kept around
  16. for the duration of the program) which has 5 radiobuttons:
  17.  
  18.   static Widget dialog = NULL;
  19.  
  20.   if (!dialog) {
  21.     dialog = XmCreateFormDialog(theAppData.inputShell, "branchParam", NULL, 0);
  22.         :
  23.     :
  24.     :
  25.     radiobox = XmCreateRadioBox(frame, "radiobox", NULL, 0);
  26.  
  27.     for (i = 0; i < 5; i++) {
  28.       sprintf(s, "radio%d", i);
  29.       radiobtn[i] = XtVaCreateManagedWidget(s,
  30.                        xmToggleButtonWidgetClass, radiobox,
  31.                        XmNlabelType, XmPIXMAP,
  32.                        NULL);
  33.       XtAddCallback(radiobtn[i], XmNvalueChangedCallback,
  34.                     DoSelectBranchType, i);
  35.     :
  36.     :
  37.     :
  38.     }
  39.   }
  40.  
  41.   XtManageChild(radiobox);
  42.  
  43.   /* The following looks verbose and redundant but I see no reason why
  44.      it won't work as I expect it to. */
  45.  
  46.   XtVaSetValues(radiobox, XmNradioAlwaysOne, False, NULL);
  47.   XFlush(XtDisplay(w));
  48.  
  49.   for (i = 0; i < 5; i++)
  50.     XtVaSetValues(radiobtn[i],
  51.     XmNset, True,  /* Set ALL radiobuttons to 'selected' state */
  52.     NULL);
  53.   XFlush(XtDisplay(w));
  54.  
  55.   for (i = 0; i < 5; i++)
  56.     XtVaSetValues(radiobtn[i],
  57.     XmNselectPixmap, toolPix[currentDomain][i],
  58.     NULL);
  59.   XFlush(XtDisplay(w));
  60.  
  61.   for (i = 0; i < 5; i++)
  62.     XtVaSetValues(radiobtn[i],
  63.     XmNset, False, /* Set ALL radiobuttons to 'UNselected' state */
  64.     NULL);
  65.   XFlush(XtDisplay(w));
  66.  
  67.   for (i = 0; i < 5; i++)
  68.     XtVaSetValues(radiobtn[i],
  69.           XmNunselectPixmap, toolPix[currentDomain][i],
  70.           NULL);
  71.   XFlush(XtDisplay(w));
  72.  
  73.   XtVaSetValues(XtParent(radiobtn[0]), XmNradioAlwaysOne, True, NULL);
  74.   XFlush(XtDisplay(w));
  75.  
  76. -------------
  77.  
  78. The problem is the first time the dialog box is opened, all the radio
  79. buttons have their respective pixmaps that are each the same whether
  80. it is selected or unselected.  This is the desired effect.
  81.  
  82. But susequent openings of the same dialog box shows the radiobuttons
  83. to have the SAME pixmaps even tho 'currentDomain' is different.  But
  84. then clicking on EACH radiobutton will show that its OTHER pixmap is
  85. in fact the new pixmap that was assigned to it according to the value
  86. of 'currentDomain'.  E.g. let's say when the dialog box is first
  87. opened, the pixmaps are A,B,C,D, and E for both selected and
  88. unselected states (which is what I want).  Then on the next (and
  89. subsequent) openings of the same dialog box, I see the same A,B,C,D,
  90. and E pixmaps, but as I toggle each radiobutton in turn, I see the new
  91. F,G,H,I, and J pixmaps.
  92.  
  93. Why is that?  How do I RESET the radiobuttons with new pixmaps that
  94. are the same for both states?
  95.  
  96. Please respond to me directly via email.  Thanks.
  97.  
  98. -Tim
  99.