home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / windows / x / motif / 8483 < prev    next >
Encoding:
Text File  |  1993-01-11  |  3.2 KB  |  100 lines

  1. Path: sparky!uunet!think.com!spool.mu.edu!agate!ucbvax!oceanroutes.ns.ca!deveau
  2. From: deveau@oceanroutes.ns.ca ("Terry J. Deveau")
  3. Newsgroups: comp.windows.x.motif
  4. Subject: Re: dynamically change background resource value
  5. Message-ID: <9301071922.AA15200@BU.EDU>
  6. Date: 7 Jan 93 19:21:03 GMT
  7. References: <1993Jan6.143453.11318@afterlife.ncsc.mil>
  8. Sender: usenet@ucbvax.BERKELEY.EDU
  9. Reply-To: deveau@koala.drea.dnd.ca
  10. Distribution: inet
  11. Organization: Seimac Limited
  12. Lines: 86
  13.  
  14. Lori M. Pieniazeck writes:
  15.  
  16. > I have a motif program that uses a resource file with the following line in it:
  17. > *background:  green
  18. > I would like to change this value while the program is running. Is there
  19. > a way to do this so that it will change all of the widgets backgrounds to
  20. > a new color without having to change the XmNbackground resource for 
  21. > every widget?
  22.  
  23. There were a couple of messages in this newsgroup that might help you
  24. with this. I've attached them below.
  25.  
  26. --
  27.  
  28. Terry J. Deveau                   Internet: deveau@oceanroutes.ns.ca
  29. Seimac Limited                    Phone: (902) 468-3007
  30. Dartmouth, N.S., Canada           Fax: (902) 468-3009
  31.  
  32. ================== begin included messages ===========================
  33. Subject: Setting resources by class
  34. To: motif@alfalfa.com (comp.windows.x.motif)
  35. Date: Wed, 28 Oct 92 15:19:59 AST
  36. From: "Terry J. Deveau" <deveau@oceanroutes.ns.ca>
  37. Sender: deveau@oceanroutes.ns.ca
  38. Organization: Oceanroutes Canada Inc.
  39. Phone: (902) 468-3007, FAX: (902) 468-3009
  40. Mailer: Elm [revision: 64.9]
  41.  
  42. I've just figured out how to do something that I've been wanting
  43. to do for a long while.  I'll post it in case someone else has
  44. been wondering about it also.
  45.  
  46. Resources can be set for individual widgets within an application
  47. using XtSetValues.  Resources for a whole class of widgets can
  48. be set outside the application in a defaults file.  But how can
  49. you set resources for a class of widgets within an application.
  50.  
  51. The example below shows how.  It sets the foreground colours of
  52. all label widgets to green, all row-columns to red, and all 
  53. push-buttons to pink.  Children of widgets whose colours are set
  54. this way still take the colours of their parents however.  Does
  55. anyone know how to prevent that?
  56.  
  57. I've also tried a variant of this to set translations on a
  58. class-wide basis, it also works.
  59.  
  60.  
  61. #include <X11/Xresource.h>
  62.  
  63. main(argc, argv)
  64. int argc;
  65. char *argv[];
  66. {
  67.   Widget shell;
  68.   XrmDatabase rmd;
  69.  
  70.   shell = XtInitialize ("main",argv[0], NULL, 0, &argc, argv); 
  71.   rmd = XtDatabase(XtDisplay(shell));
  72.   XrmPutLineResource (&rmd,"*XmLabel*foreground: green");
  73.   XrmPutLineResource (&rmd,"*XmRowColumn*foreground: red");
  74.   XrmPutLineResource (&rmd,"*XmPushButton*foreground: pink");
  75.  
  76.  ... 
  77.  
  78. }
  79.  
  80.  
  81. Date: Thu, 29 Oct 92 09:57:55 EST
  82. From: mark@bhanu.andyne.on.ca (Mark Levison)
  83. Message-Id: <9210291457.AA00497@bhanu.andyne.on.ca>
  84. To: deveau@oceanroutes.ns.ca
  85. Subject: re:Setting resources by class
  86.  
  87.  
  88. Terry,
  89.         You could also set these resources as fallbacks and pass them into
  90. XtAppInitialize.  The disadvantage of your route is it overrides anything in
  91. a users defaults file.  See O'Reilly Volume 6 for more details.
  92.  
  93. Cheers
  94. Mark Levison
  95. mark@bhanu.andyne.on.ca
  96.  
  97. ================== end included messages ===========================
  98.  
  99.