[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CW_Field Done as the Full Monty
- Subject: CW_Field Done as the Full Monty
- From: davidf(at)dfanning.com (David Fanning)
- Date: Mon, 22 Nov 1999 22:21:12 -0700
- Newsgroups: comp.lang.idl-pvwave
- Organization: Fanning Software Consulting
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:17455
I'm sure some of you (alright, probably most of you) are
getting fed up with these long-winded, rambling posts first
thing in the morning. This is the last one for a while, I
promise. Have you ever noticed how easy is is to get
long winded when you have been sitting at the computer for
12+ hours and you've had a beer or two and ...
Here is that CW_FIELD replacement done up as a full-blown
object. The full monty. No apologies.
I've given it a separate name, FSC_INPUTFIELD, so you can
keep everything straight. But this program has the same
functionality (and then some) that the COYOTE_FIELD
program I posted the other day has. You can find it here:
(There are TWO underscore characters before the "define".
So, just to reiterate some of the advantages:
1. Text fields look (and are) editable.
2. Better event management.
3. Better aesthetics and layout capability.
4. Much easier access to program properties.
I've written the same program in two different ways so that
you can compare and contrast the traditional verses the
object programming style. So, whereas before you called
Coyote_Field like this:
fieldID = Coyote_Field(tlb, Value=5, Title='X Size:', $
Now you call FSC_InputField like this:
fieldObj = Obj_New("FSC_InputField", Value=5, $
Title='X Size:', /IntegerValue, XSize=10)
Whereas before you set a value like this:
Widget_Control, fieldID, Set_Value=7.5
Now, you set it like this:
I've written an Example program at the end of the file, so
you can play with some of the features of the program. To
run it, download the file and type this:
IDL> .compile fsc_inputfield__define.pro
I didn't get too much feedback from this morning's program,
so I either completely botched it or I scared everyone to
death. Hard to say right now. But the point is, you are
suppose to ask questions if you don't understand what's
going on. :-)
This stuff *will* improve your programming if you take
just a bit of time to learn it. It's really not hard.
Look, *I* can do it! :-)
I thought if you got tired of football this weekend, and
you were looking for something to do... Well, maybe not. :-)
Have a Good Thanksgiving!
P.S. I did implement Ben's request to change the data type
of the field on the fly. Basically, all you have to do is
load a new data value and the field data type will change
to the type of the value. (Unless you tell it otherwise,
of course.) You can see this happen in the Example program.
But Struan's request for a specified number of significant
digits is a lot harder and more subtle than I expected it
to be. I may have to leave it to him to implement this
feature. I tried, without much success, for several hours
to make this work, but there are problems going from a
string (which is what is in the text widget) to a number
that I wasn't able to overcome satisfactorily in the time
I worked on it. I may have another go between the football
and the turkey, but I can't promise anything.
PPS. I'm under no illusions about the bug-free nature of
my code. I only promise that if you report them, I do try
to fix them. Cheers.
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: email@example.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155