home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!think.com!spool.mu.edu!agate!ucbvax!oceanroutes.ns.ca!deveau
- From: deveau@oceanroutes.ns.ca ("Terry J. Deveau")
- Newsgroups: comp.windows.x.motif
- Subject: Re: dynamically change background resource value
- Message-ID: <9301071922.AA15200@BU.EDU>
- Date: 7 Jan 93 19:21:03 GMT
- References: <1993Jan6.143453.11318@afterlife.ncsc.mil>
- Sender: usenet@ucbvax.BERKELEY.EDU
- Reply-To: deveau@koala.drea.dnd.ca
- Distribution: inet
- Organization: Seimac Limited
- Lines: 86
-
- Lori M. Pieniazeck writes:
-
- > I have a motif program that uses a resource file with the following line in it:
- > *background: green
- >
- > I would like to change this value while the program is running. Is there
- > a way to do this so that it will change all of the widgets backgrounds to
- > a new color without having to change the XmNbackground resource for
- > every widget?
-
- There were a couple of messages in this newsgroup that might help you
- with this. I've attached them below.
-
- --
-
- Terry J. Deveau Internet: deveau@oceanroutes.ns.ca
- Seimac Limited Phone: (902) 468-3007
- Dartmouth, N.S., Canada Fax: (902) 468-3009
-
- ================== begin included messages ===========================
- Subject: Setting resources by class
- To: motif@alfalfa.com (comp.windows.x.motif)
- Date: Wed, 28 Oct 92 15:19:59 AST
- From: "Terry J. Deveau" <deveau@oceanroutes.ns.ca>
- Sender: deveau@oceanroutes.ns.ca
- Organization: Oceanroutes Canada Inc.
- Phone: (902) 468-3007, FAX: (902) 468-3009
- Mailer: Elm [revision: 64.9]
-
- I've just figured out how to do something that I've been wanting
- to do for a long while. I'll post it in case someone else has
- been wondering about it also.
-
- Resources can be set for individual widgets within an application
- using XtSetValues. Resources for a whole class of widgets can
- be set outside the application in a defaults file. But how can
- you set resources for a class of widgets within an application.
-
- The example below shows how. It sets the foreground colours of
- all label widgets to green, all row-columns to red, and all
- push-buttons to pink. Children of widgets whose colours are set
- this way still take the colours of their parents however. Does
- anyone know how to prevent that?
-
- I've also tried a variant of this to set translations on a
- class-wide basis, it also works.
-
-
- #include <X11/Xresource.h>
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- Widget shell;
- XrmDatabase rmd;
-
- shell = XtInitialize ("main",argv[0], NULL, 0, &argc, argv);
- rmd = XtDatabase(XtDisplay(shell));
- XrmPutLineResource (&rmd,"*XmLabel*foreground: green");
- XrmPutLineResource (&rmd,"*XmRowColumn*foreground: red");
- XrmPutLineResource (&rmd,"*XmPushButton*foreground: pink");
-
- ...
-
- }
-
-
- Date: Thu, 29 Oct 92 09:57:55 EST
- From: mark@bhanu.andyne.on.ca (Mark Levison)
- Message-Id: <9210291457.AA00497@bhanu.andyne.on.ca>
- To: deveau@oceanroutes.ns.ca
- Subject: re:Setting resources by class
-
-
- Terry,
- You could also set these resources as fallbacks and pass them into
- XtAppInitialize. The disadvantage of your route is it overrides anything in
- a users defaults file. See O'Reilly Volume 6 for more details.
-
- Cheers
- Mark Levison
- mark@bhanu.andyne.on.ca
-
- ================== end included messages ===========================
-
-