lanzo@wgate.wgate.com (Mark Lanzo) (05/31/91)
Quick question: I am trying to change the symbol pixmap on a MessageBox widget. I can change the symbol at _creation time_ for the widget, but I don't seem to have any luck at all changing it after it has been creating, using XtSetValues(). Is this a bug? Or am I just doing something stupid ... First, some background info: HP9000/370 running HP-UX version 7.0B Motif 1.0 with X11R3 Here's a sample code fragment (I assume you can figure out what my "ARGLIST" macros do): ARGLIST_RESET(); ARGLIST_ADD(XmNmessageString, msg_str); ARGLIST_ADD(XmNmessageAlignment, alignment); ARGLIST_ADD(XmNmappedWhenManaged, False); ARGLIST_ADD(XmNdialogType, XmDIALOG_MESSAGE); dialog = XmCreateMessageDialog(RootWidget, "Notice", ARGS); label = XmMessageBoxGetChild(dialog,XmDIALOG_MESSAGE_LABEL); XtManageChild(dialog); shell = XtParent(dialog); if (options.symbol_name) /* E.G. "wm_error" */ { Pixel fg, bg; Pixmap symbol; ARGLIST_RESET(); ARGLIST_ADD(XmNforeground, &fg); ARGLIST_ADD(XmNbackground, &bg); XtGetValues(dialog, ARGS); symbol = XmGetPixmap(screen,options.symbol_name,fg,bg); if (symbol != XmUNSPECIFIED_PIXMAP) { ARGLIST_RESET(); ARGLIST_ADD(XmNsymbolPixmap, symbol); XtSetValues(dialog, ARGS); } } Now, I can rearrange the code to go something like this: if (options.symbol_name) { Pixel fg, bg; ARGLIST_RESET(); ARGLIST_ADD(XmNforeground, &fg); ARGLIST_ADD(XmNbackground, &bg); XtGetValues(RootWidget, ARGS); symbol = XmGetPixmap(screen,options.symbol_name,fg,bg); if (symbol == XmUNSPECIFIED_PIXMAP) symbol = NULL; } ARGLIST_RESET(); ARGLIST_ADD(XmNmessageString, msg_str); ARGLIST_ADD(XmNmessageAlignment, alignment); ARGLIST_ADD(XmNmappedWhenManaged, False); ARGLIST_ADD(XmNdialogType, XmDIALOG_MESSAGE); if (symbol) ARGLIST_ADD(XmNsymbolPixmap, symbol); dialog = XmCreateMessageDialog(RootWidget, "Notice", ARGS); ... in which case it almost works. I do get my symbol; but it is not in the colors I wanted (I wanted it to be the same color as the message string). This is pretty much irrelevant though, since I'm more interested in why XtSetValues() doesn't work rather than what workarounds exist. Thanks in advance for any info you have, Mark
david@lta.lta.com (06/03/91)
> I am trying to change the symbol pixmap on a MessageBox widget. > Motif 1.0 with X11R3 Sounds like PIRS 1268 ("MessageBox doesn't handle changes in dialog type well"), fixed by OSF in the 1.0.4 release. -- David B. Lewis Lewis, Trachtenberg & Associates (LTA) Note new address!: david@lta.com +1 617 225 0366 "Conversational time-sharing was invented as a way of keeping people seated while waiting for better response time instead of milling about the ready room waiting for spooled printer output." - PJ Plaugher in 11/87 Computer Language
webb@cow.melco.co.jp (webb) (06/07/91)
I think that your problem could be your XtSetValues, and XtGetValues. These functions both take 3 parameters. Your program only passes 2 parameters, the widget, and ARGS. You must also specify the number of args as the 3rd parameter. Also you said that you wanted to use the foreground and background colours of the text in the dialog box, so maybe you should use: XtGetValues(label, ARGS, num_args); instead of XtGetValues(dialog, ARGS) which you have now. From webb@mickey.cow.melco.co.jp
lanzo@wgate.UUCP (Mark Lanzo) (06/11/91)
In a prior article webb@cow.melco.co.jp (webb) wrote: > I think that your problem could be your XtSetValues, and XtGetValues. > These functions both take 3 parameters. Your program only passes 2 > parameters, the widget, and ARGS. You must also specify the number of > args as the 3rd parameter. Sigh. I suppose I should have gone ahead and shown the macro def's. As the old adage goes "assumption is the mother of all screwups." :-) At any rate, my def's actually look like: #define MAX_WIDGET_ARGS 16 #define ARGS WidgetArgs, WidgetArgCount #define ARGLIST_RESET() WidgetArgCount = 0 #define ARGLIST_ADD(tag,value) \ (XtSetArg(WidgetArgs[WidgetArgCount],tag,value), \ WidgetArgCount++) Arg WidgetArgs[MAX_WIDGET_ARGS]; Cardinal WidgetArgCount; So as you can see, the "ARGS" macro expands to two actual arguments. > Also you said that you wanted to use the foreground and background > colours of the text in the dialog box, so maybe you should use: > XtGetValues(label, ARGS, num_args); > instead of XtGetValues(dialog, ARGS) which you have now. I *did* try to get the colors from the label. They come back as fg=bg=0. I suspect this is because a label gadget is used in the message-box widget, rather than a label widget. It seems like it would have made more sense for XtGetValues to have returned the fg & bg colors for the parent window containing the label, but it doesn't appear to work that way. At any rate, the fg/bg colors for the message-box widget should have been the same as that used for the text; I just used the generic "*foreground" resource and didn't specify different colors for specific components of the message-box.
jabir@ivory.SanDiego.NCR.COM (Jabir Hussien) (06/11/91)
One thing I have found is that if the message box is initially created with a NULL pixmap (XmDIALOG_MESSAGE), subsequent changes do not work too well. I had to create it as type INFORMATION and change it later... This is under X11R3 Motif 1.0. Jabir
bonnett@seismo.CSS.GOV (H. David Bonnett) (06/12/91)
In article <191@atesysv.UUCP>, lanzo@wgate.UUCP (Mark Lanzo) writes: |> In a prior article webb@cow.melco.co.jp (webb) wrote: |> |> > I think that your problem could be your XtSetValues, and XtGetValues. |> > These functions both take 3 parameters. Your program only passes 2 |> > parameters, the widget, and ARGS. You must also specify the number of |> > args as the 3rd parameter. |> |> Sigh. I suppose I should have gone ahead and shown the macro def's. |> As the old adage goes "assumption is the mother of all screwups." :-) |> At any rate, my def's actually look like: |> |> #define MAX_WIDGET_ARGS 16 |> #define ARGS WidgetArgs, WidgetArgCount |> #define ARGLIST_RESET() WidgetArgCount = 0 |> #define ARGLIST_ADD(tag,value) \ |> (XtSetArg(WidgetArgs[WidgetArgCount],tag,value), \ |> WidgetArgCount++) |> Arg WidgetArgs[MAX_WIDGET_ARGS]; |> Cardinal WidgetArgCount; |> |> So as you can see, the "ARGS" macro expands to two actual arguments. Hmmm, I don't have the time to really check this out myself, but what will happen with this upon exansion, given that XtSetArg is a macro itself that is evaluated twice (see D. Young's book, p24 -or- OSF Motif Prog Guide p3.6) This may be part of the problem since you inc the counter inside the (nested) macro calls. Just a thought.. -- -dave bonnett- Center for Seismic Studies; Arlington, VA bonnett@seismo.css.gov : All standard disclaimers apply.
lanzo@wgate.UUCP (Mark Lanzo) (06/13/91)
In a prior article jabir@ivory.SanDiego.NCR.COM (Jabir Hussien) wrote: One thing I have found is that if the message box is initially created with a NULL pixmap (XmDIALOG_MESSAGE), subsequent changes do not work too well. I had to create it as type INFORMATION and change it later... This is under X11R3 Motif 1.0. BINGO! This indeed solves the problem. Many Thanks, -- Mark --