Re: Sharing Colour Tables in IDL [message #9050] |
Fri, 30 May 1997 00:00 |
David Foster
Messages: 341 Registered: January 1996
|
Senior Member |
|
|
Daniel Lang wrote:
>
> Hi,
>
> As part of my work I am looking into reducing the number of colours
> used by various applications. Because we are running a fair few
> IDL applications, this is now one of my main targets.
>
> My basic aim is this: To have all IDL applications running on a
> certain display to share the same set of 32 colours.
>
<snip of two possible methods for sharing colors>
Daniel:
Both of the methods you suggest seem pretty involved, and I'm wondering
if the results will really be worth it. The approach I have taken is
to allow each program to load it's own color-table, and then
use keyboard focus events (an IDL 5.0 feature) to enable the program
to restore it's own color-table whenever the program gains keyboard
focus. This was done so that the active command-line in IDL 5.0 won't
screw up colors for my applications.
This technique is quite easy, and it might be close to what you are
looking for. Trying to get multiple applications to share only 32
colors may be like getting multiple PhD's to share an office (sorry
to all those PhD's ;-) ). It's usually the case that the user only
needs to "see" one application at a time; obviously if this isn't
the case then the apps need to share the colors somehow.
In any case, to use the keyboard focus method, create the TLB widget
with something like this:
ids.base = WIDGET_BASE(title=title, group_leader=parent, /column, $
/modal, /kbrd_focus_events)
and then in the event handler put in something like:
PRO mrsegreg_event, event
widget_control, event.id, get_uvalue=uvalue
name = strmid(tag_names(event, /structure_name), 7, 1000)
case (name) of
"BUTTON": begin
...
"KBRD_FOCUS": begin
; Entering program area so load colors
if ( event.enter eq 1 ) then $
ret = mrsegreg_color_table()
end
where MRSEGREG_COLOR_TABLE() is a function that updates the colors
for this application.
Hope this is useful. You might also want to check out David Fanning's
web page, as he has some examples of how to make programs restore
their own colors (I think he uses tracking events, which is very
similar): http://www.dfanning.com .
Dave
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2200
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
"I have this theory that if we're told we're bad,
then that's the only idea we'll ever have.
But maybe if we are surrounded in beauty,
someday we will become what we see." - Jewel Kilcher
|
|
|