Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Unpublicised -color- command in dialogs


From   [email protected] (James Hassell)
To   [email protected]
Subject   Re: st: Unpublicised -color- command in dialogs
Date   Thu, 19 Aug 2004 11:26:04 -0500

Roger Newson wrote:

>In the course of examining the Stata .idlg files
>mentioned in the very helpful FAQ by Jean Marie Linhart and Alan Riley, I
>have found frequent appearances of a COLOR command, which does not seem to
>be mentioned in -[P] dialogs- or even in -whelp undocumented-, and which
>appears to be connected with enabling the "Custom color" option in
>comboboxes for color selection. Is this documented anywhere? And how does
>it work?

Roger is correct that the custom COLOR picker used in Stata graphics dialogs
is not documented. We have not documented some features in the dialog
system because we thought that we might want to change their behavior or
their implementation in the future. This was true at the time Stata 8 was
initially released and is still true today.

Since the COLOR control is not documented, let me explain how it can be used.
A custom COLOR control can be used by itself or in conjunction with a
COMBOBOX control. I will give an example of the stand alone implementation
first, since that is the easiest.

*********
VERSION 8
POSITION . . 300 250

DIALOG main, tabtitle("Main") label("Color test")
BEGIN
  COLOR cl_option1 10 10 20 ., default( 0 0 255 ) option(bcolor)
END

OK ok1,      label("OK")
CANCEL can1, label("Cancel")
SUBMIT sub1, label("Submit")
RESET res1

PROGRAM command
BEGIN
	put `"display "Color code: "'
	put main.cl_option1
	put `"""'
END
*********

Notice that a COLOR control can take two options; -default- and -option-.
In this example I used -put- to get the contents of the control into the
command string (U-action), but just as other dialog controls that produce
arguments, -optionarg- could be used.

In our own graphics dialogs we use the combination of a COMBOBOX and
a custom COLOR picker. When "Custom color" is selected in the COMBOBOX,
the custom COLOR picker becomes visible.

Here is an example of how to code these two controls so they will work
together.

*********
VERSION 8
POSITION . . 300 250

DIALOG main, tabtitle("Main") label("Color test")
BEGIN
  COMBOBOX cb_option1  10  10 100 .,				///
		dropdownlist contents(colors) values(colors)	///
		onselchangelist(option1_select_list) option(bcolor)
  COLOR    cl_option1  +105 @ 20  ., default( 0 0 255 ) option(bcolor)
END

LIST option1_select_list
BEGIN   // actions used to show and hide custom color picker
	main.cl_option1.hide
	main.cl_option1.show
	main.cl_option1.hide
END

OK ok1,      label("OK")
CANCEL can1, label("Cancel")
SUBMIT sub1, label("Submit")
RESET res1

PROGRAM command
BEGIN
	put "someCommand "
	beginoptions
		if H(main.cl_option1) { // if custom color picker is hidden -H-
			optionarg main.cb_option1
		}
		optionarg /quoted main.cl_option1
	endoptions
END
*********

>More generally, is there any documentation on how to implement comboboxes
>and list boxes for standard frequently-used graphics options such as
>symbols, sizes and colors? For instance, the file -_glist_def.idlg-
>contains references to -contents()- specifications with names such as
>"symbols", "symbolsizes" and "colors". Do these refer to standard LISTs
>which the dialog programmer is well-advised to use, instead of defining
>them anew and re-inventing the wheel?

This too is not documented for the reasons stated above. What you are seeing
in -_glist_def.idlg- is a set of dummy comboboxes that are used to initialize
LISTS that will contain the appropriate entries. This is done because of the
large number of lists which must be used inside our graphics dialogs, and
therefore, we create the list once in -_glist_def.idlg- and then
recycle it. The contents of the first list can be referenced by (_dclst_0)
and it values by (_dvlst_0). The next list will have a contents of (_dclst_1)
and so on... Our own graphics dialogs must create these dummy comboxes first,
because the order of creation determines the reference point for the list
in the future.

If you are not creating dialogs that reuse the same list over and over,
the technique above is not necessary. Just use the name of the list that either
you the programmer have defined, or we have made available. A manifest of built
in LISTs are below. Feel free to use them.

symbols
symbolsizes
colors
clockpos
linepatterns
linewidths
connecttypes
textsizes
justification
alignment
margin
tickpos
angles
yesno
compass

-- James
[email protected]

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index