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

Re: st: Unpublicised -color- command in dialogs

From   Roger Newson <[email protected]>
To   [email protected]
Subject   Re: st: Unpublicised -color- command in dialogs
Date   Fri, 20 Aug 2004 13:16:53 +0100

Thanks to James Hassell for his very, very helpful answer to my query. Thanks also to James, Jean-Marie Linhart, Alan Riley and Tom Steichen for their very helpful FAQs on dialog programming.

I have thought of two more wish list items re dialogs:

1. THe DEFINE command would be even better if the defined quantities could be evaluated using expressions (similarly to macros). For instance, we could define positions of comboboxes by reference to the positions of group boxes containing them.

2. In the dialogs for -graph twoway-, the Scheme combobox on the Overall tab should ideally be an ordinary dropdown combobox, instead of being a dropdown-list combobox as at present. That way, the user would be able to specify unofficial Stata schemes, such as Sven Juul's black-and-white -lean- schemes. (A lot of people like to have a black and white scheme with no grays, because grays do not photocopy very well.)

On the other hand, I realise that StataCorp have done (and are continuing to do) an excellent job in producing a new graphics system and a dialog interface at the same time, and that they therefore have many other things to do.

Best wishes


At 17:26 19/08/2004, James Hassell wrote:

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.

POSITION . . 300 250

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

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

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

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

POSITION . . 300 250

DIALOG main, tabtitle("Main") label("Color test")
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)

LIST option1_select_list
BEGIN // actions used to show and hide custom color picker

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

PROGRAM command
put "someCommand "
if H(main.cl_option1) { // if custom color picker is hidden -H-
optionarg main.cb_option1
optionarg /quoted main.cl_option1

>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.


-- James
[email protected]

* For searches and help try:

Roger Newson
Lecturer in Medical Statistics
Department of Public Health Sciences
King's College London
5th Floor, Capital House
42 Weston Street
London SE1 3QD
United Kingdom

Tel: 020 7848 6648 International +44 20 7848 6648
Fax: 020 7848 6620 International +44 20 7848 6620
  or 020 7848 6605 International +44 20 7848 6605
Email: [email protected]

Opinions expressed are those of the author, not the institution.

*   For searches and help try:

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