<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
<!Converted with LaTeX2HTML 95 (Thu Jan 19 1995) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
<HEAD>
<TITLE> Dialogs</TITLE>
</HEAD>
<BODY>
<meta name="description" value=" Dialogs">
<meta name="keywords" value="vwebref">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
 <BR> <HR><A NAME=tex2html1422 HREF="node8.html"><IMG ALIGN=BOTTOM ALT="next" SRC="../icons/next.gif"></A>   <A NAME=tex2html1420 HREF="vwebref.html"><IMG ALIGN=BOTTOM ALT="up" SRC="../icons/up.gif"></A>   <A NAME=tex2html1414 HREF="node6.html"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/prev.gif"></A>   <A NAME=tex2html1424 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="../icons/contents.gif"></A>      <BR>
<B> Next:</B> <A NAME=tex2html1423 HREF="node8.html"> Drawing</A>
<B>Up:</B> <A NAME=tex2html1421 HREF="vwebref.html">V Reference Manual</A>
<B> Previous:</B> <A NAME=tex2html1415 HREF="node6.html"> Command Windows</A>
<BR> <HR> <P>
<H1><A NAME=SECTION00700000000000000000> Dialogs</A></H1>
<P>
This chapter covers the classes used to build dialogs, and the various
kinds of command objects that can be included in a dialog.
<P>
The classes and command objects covered in this chapter include:
<P>
<DL ><DT>CmdAttribute
<DD> A type describing attributes of various command objects.
	<DT>CommandObject
<DD> Main type used to define commands to dialogs and command panes.
	<DT>Commands
<DD> Command items used in building dialogs.
	<DT>vIcon
<DD> Used to define V
  icons.
	<DT>vDialog
<DD> Class to build a modeless dialog.
	<DT>vModalDialog
<DD> Used to show modal dialogs.
<P>
 </DL>
<P>

<H1><A NAME=SECTION00710000000000000000> CmdAttribute</A></H1>
<P>
<A NAME=2928>&#160;</A>
<P>
<A NAME=seccmdattribute>&#160;</A>
<P>
A type describing attributes of various command objects.
<P>
<H2><A NAME=SECTION00711000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/v_defs.h&gt;</tt>
	<DT>Type name:
<DD> CmdAttribute
<P>
 </DL><H2><A NAME=SECTION00712000000000000000> Description</A></H2>
<P>
These attributes are used when defining command items.
They are used to modify default behavior. These attributes are
bit values, and some can be combined with an <em>OR</em> operation.
Note that not all attributes can be used with all commands.
<P>
<H2><A NAME=SECTION00713000000000000000> Attributes</A></H2>
<P>
<H5><A NAME=SECTION00713001000000000000> CA_DefaultButton</A></H5>
<P>
 Used with a <tt>
 C_Button</tt> to
<A NAME=2818>&#160;</A>
indicate that this button will be the default button. The user
can activate the default button by pressing the Enter key as well
as using the mouse. It will most often be associated with the OK
button.
<P>
<H5><A NAME=SECTION00713002000000000000> CA_Hidden</A></H5>
<P>
 Sometimes you may find it useful to have a
<A NAME=2820>&#160;</A>
<A NAME=2821>&#160;</A>
<A NAME=2822>&#160;</A>
command object that is not displayed at first. By using the
<tt>
 CA_Hidden</tt> attribute, the command object will not be
displayed. The space it will require in the dialog or dialog pane
will still be allocated, but the command will not be displayed.
You can then unhide (or hide) the command using the <tt>
 SetValue</tt>
method: <tt>
 SetValue(CmdID, TrueOrFalse, Hidden)</tt>.
<P>
<H5><A NAME=SECTION00713003000000000000> CA_Horizontal</A></H5>
<P>
 Command will have horizontal orientation.
<A NAME=2827>&#160;</A>
This attribute is used with Sliders and Progress Bars.
<P>
<H5><A NAME=SECTION00713004000000000000> CA_Large</A></H5>
<P>
 The object should be larger than usual. It can
<A NAME=2829>&#160;</A>
be used with Lists, Progress Bars, Sliders, Text Ins, and Value
Boxes.
<P>
<H5><A NAME=SECTION00713005000000000000> CA_MainMsg</A></H5>
<P>
 Used with a <tt>
 C_Label</tt> to indicate that
<A NAME=2832>&#160;</A>
its string will be replaced with the message supplied to the
<tt>
 ShowDialog</tt> method.
<P>
<H5><A NAME=SECTION00713006000000000000> CA_NoBorder</A></H5>
<P>
 Used for frames and status bar labels,
<A NAME=2835>&#160;</A>
<tt>
 CA_NoBorder</tt> specifies that the object is to be displayed
with no border.
<P>
<H5><A NAME=SECTION00713007000000000000> CA_NoLabel</A></H5>
<P>
 Used for progress bars to suppress display of
<A NAME=2838>&#160;</A>
the value label.
<P>
<H5><A NAME=SECTION00713008000000000000> CA_NoNotify</A></H5>
<P>
 Used for combo boxes and lists. When
<A NAME=2840>&#160;</A>
specified, the program will not be notified for each selection of
a combo box item or a list item. When specified, the program is
notified only when the combo box button is pressed, and must then
use <tt>
 GetValue</tt> to retrieve the item selected in the combo
box list. For lists, you will need another command button in the
dialog to indicate list selection is done.
<P>
<H5><A NAME=SECTION00713009000000000000> CA_NoSpace</A></H5>
<P>
 Used for frames, this attribute causes the
<A NAME=2843>&#160;</A>
command objects within the frame to be spaced together as tightly
as possible. Normally, command objects have a space of several
pixels between them when laid out in a dialog. The <tt>
 CA_NoSpace</tt>
attribute is especially useful for producing a tightly spaced
set of command buttons.
<P>
<H5><A NAME=SECTION007130010000000000000> CA_None</A></H5>
<P>
 No special attributes. Used as a symbolic
filler when defining items, and is really zero.
<P>
<H5><A NAME=SECTION007130011000000000000> CA_Percent</A></H5>
<P>
 Used with progress bars to add a % to the
<A NAME=2847>&#160;</A>
value label.
<P>
<H5><A NAME=SECTION007130012000000000000> CA_Small</A></H5>
<P>
 The object should be smaller than usual. It can
<A NAME=2849>&#160;</A>
be used with Progress Bars and Text Ins. On Progress Bars,
<tt>
 CA_Small</tt> means that the text value box will not be shown.
<P>
<H5><A NAME=SECTION007130013000000000000> CA_Text</A></H5>
<P>
 Used for Spinners to specify that a text list
<A NAME=2852>&#160;</A>
of possible values has been supplied.
<P>
<H5><A NAME=SECTION007130014000000000000> CA_Vertical</A></H5>
<P>
 Command will have vertical orientation.
<A NAME=2854>&#160;</A>
This attribute is used with Sliders and Progress Bars.
<P>

<H1><A NAME=SECTION00720000000000000000> CommandObject</A></H1>
<P>
<A NAME=2945>&#160;</A>
<P>
<A NAME=2857>&#160;</A>
<P>
Used to define commands to dialogs and command panes.
<P>
<H2><A NAME=SECTION00721000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/v_defs.h&gt;</tt>
	<DT>Type name:
<DD> CommandObject
	<DT>Part of:
<DD> vDialog, vCommandPane
<P>
 </DL><H2><A NAME=SECTION00722000000000000000> Description</A></H2>
<P>
This structure is used to define command items in dialogs and
command panes. You will define a static array of <tt>
 CommandObject</tt>
items. This array is then passed to the <tt>
 AddDialogCmds</tt>
method of a dialog class such as <tt>
 vDialog</tt> or <tt>
 vModalDialog</tt>,
or the constructor of a <tt>
 vCommandPane</tt> object, or more
typically, a class derived from one of those.
<P>
<H2><A NAME=SECTION00723000000000000000> Definition</A></H2>
<P>
<PRE>typedef struct CommandObject
  {
    CmdType cmdType;    // what kind of item is this
    ItemVal cmdId;      // unique id for the item
    ItemVal retVal;     // initial value of object
    char* title;        // string
    void* itemList;     // used when cmd needs a list
    CmdAttribute attrs; // list of attributes
    int Sensitive;      // if item is sensitive or not
    ItemVal cFrame;     // Frame used for an item
    ItemVal cRightOf;   // Item placed left of this id
    ItemVal cBelow;     // Item placed below this one
    int size;           // Used for size information
  } CommandObject;
</PRE>
<P>
<H2><A NAME=SECTION00724000000000000000> Structure Members</A></H2>
<P>
<H5><A NAME=SECTION00724001000000000000> CmdType cmdType</A></H5>
<P>
 This value determines what kind of command
item this is. The types of commands are explained in the
section <em>Commands</em>.
<P>
<H5><A NAME=SECTION00724002000000000000> ItemVal cmdId</A></H5>
<P>
 This unique id for the command defined by
<A NAME=2873>&#160;</A>
the programmer. Each command item belonging to a dialog should
have a unique id, and it is advisable to use some scheme to be
sure the ids are unique. The V
  system does not do anything to
check for duplicate ids, and the behavior is undefined for
duplicate ids. The id for a command is passed to the
<tt>
 DialogCommand</tt> method of the dialog, as well as being used
for calls to the various <tt>
 SetX</tt> and <tt>
 GetX</tt> methods.
There are many predefined values that can be used for ids as
described in the chapter <em>Standard V Values</em>
.
<P>
The values you use for your id in menus and controls should
be limited to being less than 30,000. The predefined
V
  values are all above 30,000, and are reserved. <em>
There is no enforcement of this policy.</em> It is up to you
to pick reasonable values.
<P>
The type <tt>
 ItemVal</tt> exists for historical reasons, and
is equivalent to an int, and will remain so. Thus, the easiest
way to assign and maintain unique ids for your controls
is to use a C++ <tt>
 enum</tt>. As many as possible examples
in this manual will use <tt>
 enums</tt>, but examples using the old style
<tt>
 const</tt> codeItemVal declarations may
continue to exist. There is more discussion of assigning ids
in the following example.
<P>
<H5><A NAME=SECTION00724003000000000000> int retVal</A></H5>
<P>
 The use of this value depends on the type
of command. For buttons, for example, this value will be passed
(along with the <tt>
 cmdId</tt>) to the <tt>
 DialogCommand</tt> method.
The <tt>
 retVal</tt> is also used for the initial on/off state of check
boxes and radio buttons. For some commands, <tt>
 retVal</tt> is
unused. Note that the static storage provided in the declaration
is <em>not</em> used to hold the value internally. You should
use <tt>
 GetValue</tt> to retrieve the current value of a
command object.
<P>
<H5><A NAME=SECTION00724004000000000000> char* title</A></H5>
<P>
 This is used for the label or text string
used for command items.
<P>
<H5><A NAME=SECTION00724005000000000000> void* itemList</A></H5>
<P>
 This is used to pass values to commands
that need lists or strings. The ListCmd is an example. Note the
<tt>
 void *</tt> to allow arbitrary lists.
<P>
<H5><A NAME=SECTION00724006000000000000> CmdAttribute attrs</A></H5>
<P>
 Some command items use attributes
to describe their behavior.  These attributes are summarized
in Section <A HREF="node7.html#seccmdattribute"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/crossref.gif"></A>, <em>CmdAttribute</em>
.
<P>
<H5><A NAME=SECTION00724007000000000000> int Sensitive</A></H5>
<P>
 This is used to determine if an item is
sensitive or not. Note that the static storage provided in the
declaration is used by the V
  system to track the value, and
should be changed by the <tt>
 SetValue</tt> method rather than
directly. Thus dialogs sharing the same static declaration will
all have the same value. This is usually desired behavior.
<P>
<H5><A NAME=SECTION00724008000000000000> ItemVal cFrame</A></H5>
<P>
 Command items may be placed within a frame.
If this value is 0 (or better, the symbol <tt>
 NoFrame</tt>), the
command will be placed in the main dialog area. If a value is
supplied, then the command will be placed within the frame with
the id <tt>
 cFrame</tt>.
<P>
<A NAME=2902>&#160;</A>
<H5><A NAME=SECTION00724009000000000000> ItemVal cRightOf, ItemVal cBelow</A></H5>
<P>
 These are used to describe
the placement of a command within a dialog.  Ids of other commands
in the same dialog are used to determine placement. The current
command will be placed to the right of the command <tt>
 cRightOf</tt>,
and below the command <tt>
 cBelow</tt>. The commands left and above
don't necessarily have to be adjacent. By careful use of these
values, you can design very attractive dialogs. You can control
the width of command objects by padding the label with blanks.
Thus, for example, you can design a dialog with all buttons the
same size.
<P>
You can also use the <tt>
 CA_Hidden</tt> attribute to selectively
<A NAME=2907>&#160;</A>
hide command objects that occupy the same location in the
dialog. Thus, you might have a button labeled <tt>
 Hide</tt>
right of and below the same command object as another button
labeled <tt>
 UnHide</tt>. By giving one of the two buttons
the <tt>
 CA_Hidden</tt> attribute, only one will be displayed.
Then you can use <tt>
 SetValue</tt> at runtime to switch which
button is displayed in the same location. The bigger of the
two command objects will control the spacing.
<P>
<H5><A NAME=SECTION007240010000000000000> int size</A></H5>
<P>
The size parameter can be used for some command objects to
specify size. For example, for labeled Button commands,
the <tt>
 size</tt> specifies the minimum width in pixels of the
button. It is also used in various other command objects as
needed. A value of zero for <tt>
 size</tt> always means use the
default size. Thus, you can take advantage of how C++ handles
declarations and write <tt>
 CommandObject</tt> declarations that
leave off the <tt>
 size</tt> values, which
default to zero. Many of the examples in this reference do not
specify these values.
<P>
<H2><A NAME=SECTION00725000000000000000> Example</A></H2>
<P>
The following example defines a simple dialog with a message
label on the top row, a check box on the second row, two buttons
in a horizontally organized frame on the third row, and an OK
button on the bottom row. The ids in this example are
defined using an <tt>
 enum</tt>. Remember that your ids must be
less than 30,000, and using 0 is not a good idea.
Thus, the <tt>
 enum</tt> in this example gives the ids
values from 101 to 106.
An alternative used in V
  code prior to release 1.13 was
to provide <tt>
 const</tt>
declarations to define meaningful symbolic values for the ids.
Many examples of this type of id declaration will likely
persist.
<P>
It also helps to use a consistent naming convention for ids.
The quick reference appendix lists suggested prefixes for
each control type under the <tt>
 CmdType</tt> section. For
example, use an id of the form <tt>
 btnXXX</tt> for buttons.
Predefined ids follow the form <tt>
 M_XXX</tt>.
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/dlgcmd.gif">

<P>
<PRE>enum {lbl1 = 101, frm1, btn1, btn2,
static CommandObject Sample[] =
  {
    {C_Label, lbl1, 0,&quot;Sample&quot;,NoList,CA_MainMsg,isSens,NoFrame,0,0},
    {C_Frame, frm1, 0, &quot;&quot;, NoList,CA_None,isSens,NoFrame,0,lbl1},
    {C_Button, btn1, 0, &quot;Button 1&quot;, NoList, CA_None, isSens,frm1,0,0},
    {C_Button, btn2, 0, &quot;Button 2&quot;, NoList, CA_None, isSens,frm1,btn1,0},
    {C_Button, M_OK, M_OK, &quot; OK &quot;, NoList, CA_DefaultButton, 
        isSens, NoFrame,0,frm1},
    {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  };
</PRE>
<P>
<H2><A NAME=SECTION00726000000000000000> See Also</A></H2>
<P>
vWindow, Predefined ItemVals, CmdAttribute, Commands
<P>

<H1><A NAME=SECTION00730000000000000000> Commands</A></H1>
<P>
<A NAME=3024>&#160;</A>
<P>
This section describes how each of the command objects available
in V
  is used to build dialogs.
<P>
<H2><A NAME=SECTION00731000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/v_defs.h&gt;</tt>
	<DT>Type name:
<DD> CmdType
<P>
 </DL><H2><A NAME=SECTION00732000000000000000> Description</A></H2>
<P>
V
  provides several different kinds of command items that are used
in dialogs. The kind of command is specified in the <tt>
 cmdType</tt>
field of the <tt>
 CommandObject</tt> structure when defining a
dialog. This section describes current dialog commands available
with V
 . They will be constructed by V
  to conform to the
conventions of the host windowing system. Each command is named
by the value used to define it in the <tt>
 CommandObject</tt>
structure.
<P>
<H2><A NAME=SECTION00733000000000000000> Commands</A></H2>
<P>
<H3><A NAME=SECTION00733100000000000000> C_Blank</A></H3>
<P>
<A NAME=3027>&#160;</A>
<P>
<A NAME=2996>&#160;</A>
<P>
A Blank can help you control the layout of your dialogs.
The Blank object will occupy the space it would take
if it were a <tt>
 C_Label</tt>, but nothing will be displayed. This
is especially useful for leaving space between other command
objects, and getting nice layouts with RightOfs and Belows. You
control the size of the Blank by providing a string with an
appropriate number of blanks for the <tt>
 title</tt> field.
<P>

<H3><A NAME=SECTION00733200000000000000> C_BoxedLabel</A></H3>
<P>
<A NAME=3030>&#160;</A>
<P>
<A NAME=3001>&#160;</A>
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/boxlabel.gif">

<P>
This command object is just like a <tt>
 C_Label</tt>, but drawn
with a surrounding box. See <tt>
 C_Label</tt>.
<P>

<H3><A NAME=SECTION00733300000000000000> C_Button</A></H3>
<P>
<A NAME=3053>&#160;</A>
<P>
<A NAME=3045>&#160;</A>
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/button.gif">

<P>
A Button is one of the primary command input items used in dialog
boxes. When the user clicks on a Button, the values set in the
<tt>
 cmdId</tt> and <tt>
 retVal</tt> fields are passed to the <tt>
 DialogCommand</tt>
method. In practice, the <tt>
 retVal</tt> field is not really used
for buttons -- the <tt>
 cmdId</tt> field is used in the
<tt>
 switch</tt> statement of the <tt>
 DialogCommand</tt> method.
<P>
A button is defined in a <tt>
 CommandObject</tt> array. This is a
typical definition:
<P>
<PRE> {C_Button, btnId, 0,&quot;Save&quot;,NoList,CA_None,isSens,NoFrame,0,0}
</PRE>
<P>
The <tt>
 retVal</tt> field can be used to hold any value you wish.
For example, the predefined color button frame (see <tt>
 vColor</tt>)
uses the <tt>
 cmdId</tt> field to identify each color button, and
uses the <tt>
 retVal</tt> field to hold the index into the standard
V
  color array. If you don't need to use the <tt>
 retVal</tt>,
a safe convention is to a 0 for
the <tt>
 retVal</tt>. You can put any label you
wish in the <tt>
 title</tt> field.
<P>
If you provide the attribute <tt>
 CA_DefaultButton</tt> to the
<tt>
 CmdAttribute</tt> field, then this button will be considered
the default button for the dialog. The default button will be
visually different than other buttons (usually a different
border), and pressing the Return key is the same as clicking on
the button.
<P>
You can change the label of a button with:
<tt>
 SetString(btnId,</tt> <tt>
 &quot;New Label&quot;)</tt>. You can change the
sensitivity of a button with <tt>
 SetValue(btnID, OnOrOff,
Sensitive)</tt>.
<P>
<H3><A NAME=SECTION00733400000000000000> C_CheckBox</A></H3>
<P>
<A NAME=3094>&#160;</A>
<P>
<A NAME=3086>&#160;</A>
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/chkbox.gif">

<P>
A CheckBox is usually used to set some option on or off. A
CheckBox command item consists of a check box and an associated
label. When the user clicks on the check box, the <tt>
 DialogCommand</tt>
method is invoked with the <tt>
 Id</tt> set to the <tt>
 cmdId</tt> and
the <tt>
 Val</tt> set to the current state of the CheckBox. The
system takes care of checking and unchecking the displayed check
box -- the user code tracks the logical state of the check box.
<P>
A CheckBox is defined in a <tt>
 CommandObject</tt> array. This is a
typical definition:
<P>
<PRE> {C_CheckBox, chkId, 1,&quot;Show Details&quot;,NoList,CA_None,isSens,NoFrame,0,0}
</PRE>
<P>
The <tt>
 retVal</tt> is used to indicate the initial state of the
check box. You should use the <tt>
 GetValue</tt> method to get the
current state of a check box. You can also track the state
dynamically in the <tt>
 DialogCommand</tt> method. You can put any
label you wish in the <tt>
 title</tt> field.
<P>
You can change the label of a check box with: <tt>
 SetString(chkId,</tt>
<tt>
 &quot;New Label&quot;)</tt>. You can change the sensitivity of a check
box with <tt>
 SetValue(chkID, OnOrOff,Sensitive)</tt>. You can
change the checked state with <tt>
 SetValue(chkID, OnOrOff,
Checked)</tt>.
<P>
If the user clicks the Cancel button and your code calls the
default <tt>
 DialogCommand</tt> method, V
  will automatically reset
any check boxes back to their original state, and call the
<tt>
 DialogCommand</tt> method an additional time with the original
value if the state has changed.  Thus, your code can track the
state of check boxes as the user checks them, yet rely on the
behavior of the Cancel button to reset changed check boxes to the
original state.
<P>
The source code for the V
  <tt>
 vDebugDialog</tt> class provides a
good example of using check boxes (at least for the X version).
It is found in <tt>
 v/src/vdebug.cxx</tt>.
<P>
<H3><A NAME=SECTION00733500000000000000> C_ColorButton</A></H3>
<P>
<A NAME=3144>&#160;</A>
<P>
<A NAME=3132>&#160;</A>
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/color.gif">

<P>
A color command button. This works exactly the same as a <tt>
 C_Button</tt>
except that the button may be colored. You use <tt>
 C_ColorButton</tt>
for the <tt>
 cmdType</tt> field, and provide a pointer to a <tt>
 vColor</tt>
structure in the <tt>
 itemList</tt> field using a <tt>
 (void*)</tt>
cast. The label is optional.
<P>
The <tt>
 retVal</tt> field of a color button is not used. You can
generate a square color button of a specified size by specifying
an empty label (<code>&quot;&quot;</code>) <em>and</em> a <tt>
 size</tt> value greater
than 0. When you specify the <tt>
 size</tt> field,  the color button
will be a colored square <tt>
 size</tt> pixels per side. When used
within a <tt>
 CA_NoSpace</tt> frame, this feature would allow you
to build a palette of small, tightly spaced color buttons. In
fact, V
  provides a couple of such palettes in 
<tt>
 v/vcb2x4.h</tt> and <tt>
 v/vcb2x8.h</tt>. These
include files, as well as the other details of the <tt>
 vColor</tt>
class are described in the section <tt>
 vColor</tt> in the <em>Drawing</em>
<P>
chapter.
<P>
There are two ways to change to color of a button. The most direct
way is to change each of the RGB values in three successive calls
to <tt>
 SetValue</tt> using <tt>
 Red</tt>, <tt>
 Green</tt>, and finally
<tt>
 Blue</tt> as the <tt>
 ItemSetType</tt> to change the RGB values. 
The call with <tt>
 Blue</tt> causes the color to be updated. I know
this isn't the most elegant way to do this, but it fits with the
<tt>
 SetValue</tt> model.
<P>
An alternate way is to change the value of the original <tt>
 vColor</tt>
used to define the initial color of the control, and then call
<tt>
 SetValue</tt> with the <tt>
 ChangeColor</tt> set type.
<P>
This is a short example of defining a red button, and then changing it.
<P>
<PRE>    static vColor btncolor(255,0,0};  // define red
    ...

    // part of a CommandObject definition
    {C_ColorButton, cbt1, 0, &quot;&quot;, (void*)&amp;btncolor,
        CA_None, isSens, NoFrame, 0, btnXXX},

    ...
    // Code to change the color by some arbitrary values
    btncolor.Set(btncolor.r()+127, btncolor.g()+63, btncolor.b()+31);
#ifdef ByColor    // by vColor after changing btncolor
    SetValue(cbt1,0,btncolor);
#else          // by individual colors
    SetValue(cbt1,(ItemVal)btncolor.r(),Red);
    SetValue(cbt1,(ItemVal)btncolor.g(),Green);
    // This final call with Blue causes color to update in dialog
    SetValue(cbt1,(ItemVal)btncolor.b(),Blue);
#endif
    ...
</PRE>
<P>
<H3><A NAME=SECTION00733600000000000000> C_ComboBox</A></H3>
<P>
<A NAME=3231>&#160;</A>
<P>
<A NAME=3207>&#160;</A>
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/combobox.gif">

<P>
A combo box is a drop-down list. It normally
appears as box with text accompanied by some kind of down arrow
button. You pass a list of alternative text values in the <tt>
 itemList</tt>
field of the <tt>
 CommandObject</tt> structure. You also must set
the <tt>
 retVal</tt> field to the index (starting at 0) of the item
in the list that is the default value for the combo box text
title.
<P>
If the user clicks the arrow, a list pops up with a set of
alternative text values for the combo box label. If the user
picks one of the alternatives, the popup closes and the new value
fills the text part of the combo box. V
  supports up to 32
items in the combo box list. You need to use a <tt>
 C_List</tt> if
you need more than 32 items.
<P>
With default attributes, a combo box will send a message to
<tt>
 DialogCommand</tt> whenever a user picks a selection from the
combo box dialog. This can be useful for monitoring the item
selected. If you define the combo box with the attribute
<tt>
 CA_NoNotify</tt>, the dialog in not notified on each pick.
You can use <tt>
 GetValue</tt> to retrieve the index of the
item shown in the combo box text field.
<P>
You can preselect the value by using <tt>
 SetValue</tt>.
You can change the contents of the combo list by using 
<tt>
 vDialog::SetValue</tt> with either  <tt>
 ChangeList</tt> or
<tt>
 ChangeListPtr</tt>. See <tt>
 vDialog::SetValue</tt> for more
details.
<P>
<H3><A NAME=SECTION00733700000000000000> Example</A></H3>
<P>
The following is a simple example of using a combo box in a modal
dialog.  This example does not process items as they are clicked,
and does not show code that would likely be in an overridden
<tt>
 DialogCommand</tt> method. The code interface to a list and a
combo box is very similar -- the interaction with the user is
different. This example will initially fill the combo box label
with the text of  <tt>
 comboList[2]</tt>.
<P>
<PRE>enum { cbxId = 300 };
char* comboList[] =
  {
    &quot;First 0&quot;,   // The first item in the list
     ...
    &quot;Item N&quot;,    // The last item in the list
    0            // 0 terminates the list
  };
  ...
CommandObject ComboList[] =
  {
    {C_ComboBox, cbxId, 2, &quot;A Combo Box&quot;, (void*)comboList,
       CA_NoNotify,isSens,NoFrame,0,0},
    {C_Button, M_OK, M_OK, &quot; OK &quot;, NoList,
       CA_DefaultButton, isSens, NoFrame, 0, ListId},
    {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  };
    ...
    vModalDialog cd(this);    // create list dialog
    int cid, cval;
    ...
    cd.AddDialogCmds(comboList);   // Add commands to dialog
    cid = ld.ShowModalDialog(&quot;&quot;,cval);  // Wait for OK
    cval = ld.GetValue(cbxId);  // Retrieve the item selected
</PRE>
<P>
<H3><A NAME=SECTION00733800000000000000> C_EndOfList</A></H3>
<P>
<A NAME=3321>&#160;</A>
<P>
<A NAME=3286>&#160;</A>
<P>
This is not really a command, but is used to denote end of the
command list when defining a <tt>
 CommandObject</tt> structure.
<P>
<H3><A NAME=SECTION00733900000000000000> C_Frame</A></H3>
<P>
<A NAME=3324>&#160;</A>
<P>
<A NAME=3290>&#160;</A>
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/frame.gif">

<P>
The frame is a line around a related group of dialog command
items. The dialog window itself can be considered to be the
outermost frame. Just as the placement of commands within the
dialog can be controlled with the <tt>
 cRightOf</tt> and <tt>
 cBelow</tt>
fields, the placement of controls within the frame use the same
fields. You then specify the id of the frame with the <tt>
 cFrame</tt>
field, and then relative position within that frame.
<P>
The <tt>
 title</tt> field of a frame is not used.
<P>
You may supply the <tt>
 CA_NoBorder</tt> attribute to any frame,
which will cause the frame to be drawn without a border. This can
be used as a layout tool, and is especially useful to force
buttons to line up in vertical columns.
<P>
See the section <em>CommandObject</em>
 for an example of defining a
frame.
<P>

<H3><A NAME=SECTION007331000000000000000> C_Icon</A></H3>
<P>
<A NAME=3378>&#160;</A>
<P>
<A NAME=3356>&#160;</A>
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/icon.gif">

<P>
A display only icon. This works exactly the same as a <tt>
 C_Label</tt>
except that an icon is displayed instead of text. You use <tt>
 C_Icon</tt>
for the <tt>
 cmdType</tt> field, and provide a pointer to the
<tt>
 vIcon</tt> object in the <tt>
 itemList</tt> field using a
<tt>
 (void*)</tt> cast. You should also provide a meaningful label
for the <tt>
 title</tt> field since some versions of V
  may not
support icons.
<P>
You can't dynamically change the icon.
<P>
<H3><A NAME=SECTION007331100000000000000> C_IconButton</A></H3>
<P>
<A NAME=3416>&#160;</A>
<P>
<A NAME=3403>&#160;</A>
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/iconbtn.gif">

<P>
A command button Icon. This works exactly the same as a <tt>
 C_Button</tt>
except that an icon is displayed for the button instead of text.
You use <tt>
 C_IconButton</tt> for the <tt>
 cmdType</tt> field, and
provide a pointer to the <tt>
 vIcon</tt> object in the <tt>
 itemList</tt>
field using a <tt>
 (void*)</tt> cast. You should also provide a
meaningful label for the <tt>
 title</tt> field since some versions
of V
  may not support icons.
<P>
You can't dynamically change the icon. The button will be sized to
fit the icon. Note that the <tt>
 v/icons</tt> directory contains
quite a few icons suitable for using on command bars.
<P>
<H3><A NAME=SECTION007331200000000000000> C_Label</A></H3>
<P>
<H3><A NAME=SECTION007331300000000000000> C_ColorLabel</A></H3>
<P>
<A NAME=3490>&#160;</A>
<P>
<A NAME=3492>&#160;</A>
<P>
<A NAME=3457>&#160;</A>
<P>
<H4>Select Options</H4>
This places a label in a dialog. A label is defined in
a <tt>
 CommandObject</tt> array. This is a typical definition:
<P>
<PRE> {C_Label, lblId,0,&quot;Select Options&quot;,NoList,CA_None,isSens,NoFrame,0,0, 0,0}
</PRE>
<P>
While the value of a label can be changed with 
<tt>
 SetString(lblId,</tt> <tt>
 &quot;New Label&quot;)</tt>, they are usually static
items. If the label is defined with the <tt>
 CA_MainMsg</tt>
attribute, then that label position will be used to fill the the
message provided to the <tt>
 ShowDialog</tt> method.
<P>
A <tt>
 C_ColorLabel</tt> is a label that uses the
List parameter of the <tt>
 CommandObject</tt> array to
specify a <tt>
 vColor</tt>. You can
specify the color and change the color in the same fashion as
described in the <tt>
 C_ColorButton</tt> command.
<P>
<H3><A NAME=SECTION007331400000000000000> C_List</A></H3>
<P>
<A NAME=3495>&#160;</A>
<P>
<A NAME=3471>&#160;</A>
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/list.gif">

<P>
A list is a scrollable window of text items. The list can be made
up of any number of items, but only a limited number are
displayed in the list scroll box.  Most implementations will show
eight items at a time.
<P>
The user uses the scroll bar to show various parts of the list.
Normally, when the user clicks on a list item, the <tt>
 DialogCommand</tt>
is invoked with the id of the List command in the <tt>
 Id</tt>
parameter, and the index into the list of the item selected in
the <tt>
 Val</tt> parameter.  This value may be less than zero,
which means the user has unselected an item, and your code
should properly handle this situation. This only means the user
has selected the given item, but not that the selection is final.
There usually must be a command Button such as OK to indicate
final selection of the list item.
<P>
If the List is defined with the attribute <tt>
 CA_NoNotify</tt>,
<tt>
 DialogCommand</tt> is not called with each pick. You must then
use <tt>
 GetValue</tt> to get which item in the list was selected.
<P>
It is possible to preselect a given list item with the
<tt>
 SetValue</tt> method. Use the <tt>
 GetValue</tt> to
retrieve the selected item's index after the OK button is selected.
A value less than zero means no item was selected.
<P>
Change the contents of the list with
<tt>
 vDialog::SetValue</tt> using either <tt>
 ChangeList</tt> or
<tt>
 ChangeListPtr</tt>. See <tt>
 vDialog::SetValue</tt> for more
details.
<P>
<H3><A NAME=SECTION007331500000000000000> Example</A></H3>
<P>
The following is a simple example of using a list box in a modal
dialog.  This example does not process items as they are clicked.
<P>
<PRE>enum {lstId = 200 };
char* testList[] =
  {
    &quot;First 0&quot;,   // The first item in the list
     ...
    &quot;Item N&quot;,    // The last item in the list
    0            // 0 terminates the list
  };
  ...
CommandObject ListList[] =
  {
    {C_List, lstId, 0, &quot;A List&quot;, (void*)testList,
       CA_NoNotify,isSens,NoFrame,0,0},
    {C_Button, M_OK, M_OK, &quot; OK &quot;, NoList,
       CA_DefaultButton, isSens, NoFrame, 0, lstId},
    {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  };
    ...
    vModalDialog ld(this);    // create list dialog
    int lid, lval;
    ...
    ld.AddDialogCmds(ListList);   // Add commands to dialog
    ld.SetValue(lstId,8,Value);  // pre-select 8th item
    lid = ld.ShowModalDialog(&quot;&quot;,lval);  // Wait for OK
    lval = ld.GetValue(lstId);  // Retrieve the item selected
</PRE>
<P>
<H3><A NAME=SECTION007331600000000000000> C_ProgressBar</A></H3>
<P>
<A NAME=3593>&#160;</A>
<P>
<A NAME=3553>&#160;</A>
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/progress.gif">

<P>
Bar to show progress. Used with <tt>
 CA_Vertical</tt>
or <tt>
 CA_Horizontal</tt> attributes to control orientation.
You change the value of the progress bar with
<tt>
 SetValue(ProgID, val, Value)</tt>, where <tt>
 val</tt> is
a value between 0 and 100, inclusive. Normally, the
progress bar will show both a graphical indication of the value,
and a text indication of the value between 0 and 100.
<P>
If you don't want the text value (for example, your value
represents something other than 0 to 100), then define the
progress bar with the <tt>
 CA_NoLabel</tt> attribute. Use
the <tt>
 CA_Percent</tt> attribute to have a % added to the
displayed value. You can also use <tt>
 CA_Small</tt> or <tt>
 CA_Large</tt>
to make the progress bar smaller or larger than normal. If you
need a text value display for ranges other than 0 to 100, you can
build a <tt>
 CA_NoSpace</tt> frame with a progress bar and a text
label that you modify yourself.
<P>
<H2><A NAME=SECTION00734000000000000000> Example</A></H2>
<P>
The following shows how to define a progress bar, and how to
set its value.
<P>
<PRE>enum{frm1 = 200, lbl1, pbrH, pbrV, ... };
  static CommandObject Cmds[] =
  {
    ...
    // Progress Bar in a frame
    {C_Frame, frm1, 0, &quot;&quot;,NoList,CA_None,isSens,NoFrame, 0,0},
    {C_Label, lbl1, 0, &quot;Progress&quot;,NoList,CA_None,isSens,frm1,0,0},
    {C_ProgressBar, pbrH, 50, &quot;&quot;, NoList,
        CA_Horizontal,isSens,frm1, 0, lbl1},  // Horiz, with label

    {C_ProgressBar, pbrV, 50, &quot;&quot;, NoList,  // Vertical, no value
      CA_Vertical | CA_Small, isSens,NoFrame, 0, frm1},
    ...
  };
  ...
  // Set the values of both bars to same
  SetValue(pbrH,retval,Value);    // The horizontal bar
  SetValue(pbrV,retval,Value);    // The vertical bar
</PRE>
<P>
<H3><A NAME=SECTION00734100000000000000> C_RadioButton</A></H3>
<P>
<A NAME=3674>&#160;</A>
<P>
<A NAME=3645>&#160;</A>
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/radiob.gif">

<P>
Radio buttons are used to select one and only one item from a
group. When the user clicks on one button of the group, the
currently set button is turned off, and the new button is turned
on. Note that for each radio button press, <em>two</em> events are
generated. One a call to <tt>
 DialogCommand</tt> with the
id of the button being turned off, and the other a call with the
id of the button being turned on. The order of these two events is
not guaranteed. The <tt>
 retVal</tt> field indicates the initial on
or off state, and only one radio button in a group should be on.
<P>
Radio buttons are grouped by frame. You will typically put
a group of radio buttons together in a frame. Any buttons
not in a frame (in other words, those just in the dialog
window) are grouped together.
<P>
Radio buttons are handled very much like check boxes. Your code
should dynamically monitor the state of each radio button with
the <tt>
 DialogCommand</tt> method. Selecting Cancel will
automatically generate calls to <tt>
 DialogCommand</tt> to restore
the each of the buttons to the original state.
<P>
You can use <tt>
 SetValue</tt> with a <tt>
 Value</tt> parameter to
change the settings of the buttons at runtime. <tt>
 SetValue</tt>
will enforce a single button on at a time.
<P>
<H2><A NAME=SECTION00735000000000000000> Example</A></H2>
<P>
The following example of defining and using radio buttons was
extracted from the sample file <tt>
 v/examp/mydialog.cpp</tt>. It
starts with the button <tt>
 RB1</tt> pushed.
<P>
<PRE>enum {
    frmV1 = 200, rdb1, rdb2, rdb3, ...
...
  };
...
static CommandObject DefaultCmds[] =
  {
    {C_Frame, frmV1, 0,&quot;Radios&quot;,NoList,CA_Vertical,isSens,NoFrame,0,0},
    {C_RadioButton, rdb1, 1, &quot;KOB&quot;,  NoList,CA_None,isSens, fmV1,0,0},
    {C_RadioButton, rdb2, 0, &quot;KOAT&quot;, NoList,CA_None, isSens,frmV1,0,0},
    {C_RadioButton, rdb3, 0, &quot;KRQE&quot;, NoList,CA_None, isSens,frmV1,0,0},
    {C_Button, M_Cancel,M_Cancel,&quot;Cancel&quot;,NoList,CA_None,
        isSens, NoFrame, 0, frmV1},
    {C_Button, M_OK, M_OK, &quot; OK &quot;, NoList, CA_DefaultButton, 
        isSens, NoFrame, M_Cancel, frmV1},
    {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  };
...
void myDialog::DialogCommand(ItemVal Id, ItemVal Val, CmdType Ctype)
  {
    switch (Id)              // switch on command id
      {
        case rdb1:            // Radio Button KOB
            // do something useful - current state is in retval
            break;
        ...
        // cases for other radio buttons

      }
    // let the super class handle M_Cancel and M_OK
    vDialog::DialogCommand(id,retval,ctype);
  }
</PRE>
<P>
<H3><A NAME=SECTION00735100000000000000> C_Slider</A></H3>
<P>
<A NAME=3732>&#160;</A>
<P>
<A NAME=3711>&#160;</A>
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/slider.gif">

<P>
Used to enter a value with a slider handle. The slider will provide
your program with a value between 0 and 100, inclusive. Your program
can then scale that value to whatever it needs.
<P>
V
  will draw sliders in one of three sizes. Use <tt>
 CA_Small</tt>
for a small slider (which may not be big enough to return all
values between 0 and 100 on all platforms), <tt>
 CA_Large</tt> to
get a larger than normal slider, and no attribute to get a standard
size slider that will return all values between 0 and 100. Use
the <tt>
 CA_Vertical</tt> and <tt>
 CA_Horizontal</tt> attributes to
specify orientation of the slider.
<P>
When the user changes the value of the slider, the <tt>
 DialogCommand</tt>
method is called with the id of the slider for the <tt>
 Id</tt> value,
and the current value of the slider for the <tt>
 Retval</tt> value.
You can use <tt>
 SetVal</tt> to set a value for the slider.
<P>
<H2><A NAME=SECTION00736000000000000000> Example</A></H2>
<P>
The following example shows the definition line of a slider, and
a code fragment from an overridden <tt>
 DialogCommand</tt> method
to get the value of the dialog and update a <tt>
 C_Text</tt> item
with the current value of the slider. The slider starts with a
value of 50.
<P>
<PRE>enum { frm1 = 80, sld1, txt1 };
CommandObject Commands[] =
  {
    ...
    {C_Frame, frm1, 0, &quot;&quot;,NoList,CA_None,isSens,NoFrame,0,0},
    {C_Slider, sld1, 50, &quot;&quot;,NoList,CA_Horizontal,isSens,frm1,0,0},
    {C_Text, txt1, 0, &quot;&quot;, &quot;50&quot;,CA_None,isSens, frm1, sld1, 0},
    ...
  };
  ...
void testDialog::DialogCommand(ItemVal id,
  ItemVal retval, CmdType ctype)
  { 
    ...
    switch (id)     // Which dialog command item?
      {
        ...
        case sld1:    // The slider
          {
            char buff[20];
            sprintf(buff,&quot;%d&quot;,retval);  // To string
            SetString(txt1,buff);      // Show value
          }
        ...
      }
    ...
  }
</PRE>
<P>
<H3><A NAME=SECTION00736100000000000000> C_Spinner</A></H3>
<P>
<A NAME=3762>&#160;</A>
<P>
<A NAME=3755>&#160;</A>
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/spinner.gif">

<P>
This command item is used to provide an easy way for the user to
enter a value from a list of possible values, or in a range of values.
Depending on the attributes supplied to the <tt>
 CommandObject</tt>
definition, the user will be able to select from a short list of
text values, from a range of integers, or starting with some
initial integer value. As the user presses either the up or down
arrow, the value changes to the next permissible value. The
<tt>
 retVal</tt> field specifies the initial value of the integer,
or the index of the initial item of the text list. You use the
<tt>
 GetValue</tt> method to retrieve the final value from the
<tt>
 C_Spinner</tt>.
<P>
You can change the contents of the spinner list by using 
<tt>
 vDialog::SetValue</tt> with either  <tt>
 ChangeList</tt> or
<tt>
 ChangeListPtr</tt>. See <tt>
 vDialog::SetValue</tt> for more
details.
<P>
<H3><A NAME=SECTION00736200000000000000> Example</A></H3>
<P>
This example shows how to setup the <tt>
 C_Spinner</tt> to select
a value from a text list (when supplied with a list and the
<tt>
 CA_Text</tt> attribute), from a range of integers (when
supplied a range list), or from a starting value (when no list is
provided). The definitions of the rest of the dialog are not
included.
<P>
<PRE>  static char* spinList[] =    // a list of colors
    {
      &quot;Red&quot;,&quot;Green&quot;,&quot;Blue&quot;, 0
    };
  static int minMaxStep[3] =  // specify range of
    {                         // -10 to 10
      -10, 10, 2              // in steps of 2
    };
  enum { spnColor = 300, spnMinMax, spnInt, ... };
  CommandObject SpinDialog[] =
    {
      ...
      {C_Spinner,spnColor,0,&quot;Vbox&quot;, // A text list.
        (void*)spinList,CA_Text,     // the list is CA_Text
        isSens,NoFrame, 0,0},
      {C_Spinner,spnMinMax,0,&quot;Vbox&quot;, // a range -10 to 10
        (void*)minMaxStep,CA_None,  // by 2's starting at 0
        isSens,NoFrame, 0,0},
      {C_Spinner,spnInt,32,&quot;Vbox&quot;,  // int values step by 1
        NoList,CA_None,             // starting at 32
        isSens,NoFrame, 0,0},
      ...
    };
</PRE>
<P>

<H3><A NAME=SECTION00736300000000000000> C_Text</A></H3>
<P>
<A NAME=3826>&#160;</A>
<P>
<A NAME=3806>&#160;</A>
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/textbox.gif">

<P>
This draws boxed text. It is intended for displaying information
that might be changed, unlike a label, which is usually constant.
The text may be multi-line by using a <tt>
 '<IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img6.gif">n`</tt>. The
<tt>
 retVal</tt> and <tt>
 title</tt> fields are not used. The text to
display is passed in the <tt>
 itemList</tt> field.
<P>
You can use the <tt>
 CA_NoBorder</tt> attribute to suppress the border.
<P>
A definition of a <tt>
 C_Text</tt> item in a <tt>
 CommandObject</tt>
definition would look like:
<P>
<PRE> {C_Text, txtId, 0, &quot;&quot;, &quot;This is an example\nof a two line text.&quot;,
          CA_None,isSens,NoFrame, 0, 0, 0,0},
</PRE>
<P>
You can change the label of text box with:
<tt>
 SetString(txtId,</tt> <tt>
 &quot;New text</tt> <tt>
 to show.&quot;)</tt>.
<P>

<H3><A NAME=SECTION00736400000000000000> C_TextIn</A></H3>
<P>
<A NAME=3863>&#160;</A>
<P>
<A NAME=3852>&#160;</A>
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/textin.gif">

<P>
This command is used for text entry from the
user. The text input command item will typically be boxed
field that the user can use to enter text.
<P>
The strategy for using a TextIn command item is similar to
the List command item. You need an OK button, and then
retrieve the text after the dialog has been closed.
<P>
You can provide a default string in the <tt>
 title</tt> field
which will be displayed in the TextIn field.  The user will
be able to edit the default string. Use an empty string
to get a blank text entry field. The <tt>
 retVal</tt> field is
not used.
<P>
There are two ways to control the size of the TextIn control.
If you specify <tt>
 CA_None</tt>, you will get a TextIn
useful form most simple input commands. Using <tt>
 CA_Large</tt>
gets a wider TextIn, while <tt>
 CA_Small</tt> gets a smaller
TextIn. You can also use the <tt>
 size</tt> field of the
<tt>
 CommandObject</tt> to explicitly specify a width in
characters. When you specify a size, that number of
characters will fit in the TextIn, but the control
does <em>not</em> enforce that size as a limit.
<P>
<H3><A NAME=SECTION00736500000000000000> Example</A></H3>
<P>
The following example demonstrates how to use a TextIn.
<P>
<PRE>CommandObject textInList[] =
  {
    ...
    {C_TextIn, txiId,0,&quot;&quot;,NoList,CA_None,isSens,NoFrame,0,0},
    ...
    {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  };
 ...
    vModalDialog md(this);      /// make a dialog
    int ans, val;
    char text_buff[255];        // get text back to this buffer
 ...
    md.AddDialogCmds(textInList);  // add commands
    ans = md.ShowModalDialog(&quot;Enter text.&quot;, val);  // Show it
    text_buff[0] = 0;          // make an empty string
    (void) md.GetTextIn(txiId, text_buff, 254); // get the string
 ...
</PRE>
<P>

<H3><A NAME=SECTION00736600000000000000> C_ToggleButton</A></H3>
<P>
<A NAME=3893>&#160;</A>
<P>
<A NAME=3885>&#160;</A>
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/button.gif">

<P>
A <tt>
 C_ToggleButton</tt> is a combination of a
button and a checkbox. When the toggle button is pressed,
the <tt>
 vCmdWindow::WindowCommand</tt> method is called, just
as with a regular command button. However, the system will change
the look of the toggle button to indicate it has been
pressed. Each click on a <tt>
 C_ToggleButton</tt> will cause
the button to appear pressed in or pressed out.
<P>
The <tt>
 retVal</tt> field of the <tt>
 CommandObject</tt>
definition is used to indicate the initial state of the
toggle.
<P>
The behavior of a toggle button is like a check box, and
not a radio button. This is more flexible, but if you need
exclusive radio button like selection, you will have to
enforce it yourself using <tt>
 SetValue(toggleId,val,Value)</tt>.
<P>
<PRE> // Define a toggle button with id tbtToggle and
 // an initial state of 1, which means pressed in
 {C_ToggleButton,tbtToggle, 1,&quot;&quot;, NoList,CA_None,
     isSens, NoFrame, 0, 0},
 ...

 // The case in WindowCommand should be like this:

    case tbtToggle:
      {
	// Always safest to retrieve current value
        ItemVal curval = GetValue(tbtToggle);
        // Now, do whatever you need to
        if (curval)
           ... it is pressed
        else
           ... it is not pressed
        break;
      }
</PRE>
<P>

<H3><A NAME=SECTION00736700000000000000> C_ToggleFrame</A></H3>
<P>
<A NAME=3921>&#160;</A>
<P>
<A NAME=3912>&#160;</A>
<A NAME=3913>&#160;</A>
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/frame.gif">

<P>
A <tt>
 C_ToggleFrame</tt> is V
 's answer to the Windows Tab
control. While V
  doesn't have real Tab controls, using
a combination of <tt>
 C_ToggleFrames</tt> and either
radio buttons or toggle buttons, you can design very nice
multi-frame dialogs.
<P>
A Toggle Frame works just like a regular <tt>
 C_Frame</tt> except
that you can use <tt>
 SetValue</tt> with a type <tt>
 Value</tt> to
hide or make visible all controls contained or nested in the
toggle frame. (Note: setting the <tt>
 Value</tt> of a toggle
frame is <em>not</em> the same as setting its <tt>
 Hidden</tt>
attribute.)
<P>
The strategy for using toggle frames follows. First, you
will usually use two or more toggle frames together.
In the dialog <tt>
 CommandObject</tt> definition, you first
define one radio button or one toggle button for each
toggle frame used in the dialog. You then define a
regular bordered <tt>
 C_Frame</tt> positioned below the radio/toggle
buttons. Then place <tt>
 CA_NoBorder</tt> toggle frames
inside that outer frame. The outer frame will be the
border for all the toggle frames. Inside each toggle frame,
you define controls in the normal way.
<P>
You must select just <em>one</em> of the toggle frames to
be initially visible. This will correspond to the checked
radio button or pressed toggle button. The remaining
toggle frames <em>and</em> their controls should all be
defined using the <tt>
 CA_Hidden</tt> attribute.
<P>
You then hide and unhide toggle frames by responding
to the <tt>
 vDialog::DialogCommand</tt> messages generated
when a radio button or toggle button is pressed. You
<tt>
 SetValue(togID, 1, Value)</tt> to show a toggle pane
and all its controls, and <tt>
 SetValue(togID, 0, Value)</tt>
to hide all its controls.
<P>
The following example shows how to define and control
toggle frames:
<P>
<PRE>    enum {lbl1 = 400, tbt1, tbt2, tbt3, frm1, tfr1, tfr2,
          btnA1, btnB1, btnA2, btnB2 };
    static CommandObject DefaultCmds[] =
      {
        // A label, then 2 toggle buttons to select toggle frames
        {C_Label,lbl1,0,&quot;Tab Frame Demo&quot;,NoList,CA_None,isSens,
                 NoFrame,0,0},
        {C_ToggleButton,tbt1,1,&quot;Tab 1&quot;,NoList, CA_None, isSens, 
                 lbl1, 0, 0},
        {C_ToggleButton,tbt2,0,&quot;Tab 2&quot;,NoList, CA_None, isSens, 
                 lbl1, tbt, 0},
        {C_ToggleButton,tbt3,0,&quot;Tab 3&quot;,NoList, CA_None, isSens,
                 lbl1, tbt2 0},

        // A Master frame to give uniform border to toggle frames
        {C_Frame,frm1,0, &quot;&quot;, NoList,CA_None,isSens,lbl1,0,tbt1},

        // Toggle Frame 1 - default frame on
        {C_ToggleFrame, tfr1,1,&quot;&quot;,NoList, CA_NoBorder,isSens,frm1,0,0},
        {C_Button,btnA1,0,&quot;Button A(1)&quot;,NoList,CA_None,isSens,tfr1,0,0},
        {C_Button,btnB1,0,&quot;Button B(1)&quot;,NoList,CA_None,isSens,tfr1,
                  0,btnA1},

        // Toggle Frame 2 - default off (CA_Hidden!)
        {C_ToggleFrame,tfr2,0,&quot;&quot;,NoList,CA_NoBorder | CA_Hidden,
                isSens,frm1,0,0},
        {C_Button,btnA2,0,&quot;Button A(2)&quot;,NoList,CA_Hidden,isSens,tfr2,0,0},
        {C_Button,btnB2,0,&quot;Button B(2)&quot;,NoList,CA_Hidden,isSens,tfr2,
                  btnA2,0},

        {C_EndOfList,0,0,0,0,CA_None,0,0,0}
      };


    ...

    // In the DialogCommand method:

    switch (id)         // We will do some things depending on value
      {
        case tbt1:       // For toggle buttons, assume toggle to ON
          {
            SetValue(id,1,Value);     // turn on toggle button
            SetValue(tbt2,0,Value);    // other one off
            SetValue(tfr2,0,Value);    // Toggle other frame off
            SetValue(tfr1,1,Value);    // and ours on
            break;
          }

        case tbt2:       // Toggle 2
          {
            SetValue(id,1,Value);     // turn on toggle button
            SetValue(tbt1,0,Value);    // other off
            SetValue(tfr1,0,Value);    // Toggle other off
	    SetValue(tfr2,1,Value);    // and ours on
            break;
          }

      }
    // All commands should also route through the parent handler
    vDialog::DialogCommand(id,retval,ctype);
  }
</PRE>
<P>

<H3><A NAME=SECTION00736800000000000000> C_ToggleIconButton</A></H3>
<P>
<A NAME=3985>&#160;</A>
<P>
<A NAME=3964>&#160;</A>
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/iconbtn.gif">

<P>
A <tt>
 C_ToggleIconButton</tt> is a combination of an icon
button and a checkbox. When the toggle icon button is pressed,
the <tt>
 vCmdWindow::WindowCommand</tt> method is called, just
as with a regular icon button. However, the system will change
the look of the toggle icon button to indicate it has been
pressed. This is useful for good looking icon based interfaces
to indicate to a user that some option has been selected.
An additional press will change the appearance back to a
normal icon button. The <tt>
 retVal</tt> field of the <tt>
 CommandObject</tt>
definition is used to indicate the initial state of the
toggle.
<P>
The behavior of a toggle icon button is like a check box, and
not a radio button. This is more flexible, but if you need
exclusive radio button like selection, you will have to
enforce it yourself using <tt>
 SetValue(toggleId,val,Value)</tt>.
<P>
<PRE> // Define a toggle icon button with id tibToggle and
 // an initial state of 1, which means pressed
 {C_ToggleIconButton,tibToggle, 1,&quot;&quot;, &amp;anIcon,CA_None,
     isSens, NoFrame, 0, 0},
 ...

 // The case in WindowCommand should be like this:

    case tibToggle:
      {
        // Always safest to retrieve current value
        ItemVal curval = GetValue(tibToggle);
        // Now, do whatever you need to
        if (curval)
           ... it is pressed
        else
           ... it is not pressed
        break;
      }
</PRE>
<P>

<H1><A NAME=SECTION00740000000000000000> vIcon</A></H1>
<P>
<A NAME=4136>&#160;</A>
<P>
<A NAME=4021>&#160;</A><A NAME=4022>&#160;</A>
<P>
Used to define V
  icons.
<P>
<H2><A NAME=SECTION00741000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/v_icon.h&gt;</tt>
	<DT>Class name:
<DD> vIcon
<P>
 </DL><H2><A NAME=SECTION00742000000000000000> Description</A></H2>
<P>
Icons may be used for simple graphical labels in dialogs,
as well as for graphical command buttons in dialogs and command bars.
See the sections <tt>
 vButton</tt> and <em>Dialog Commands</em>
 for
descriptions of using icons.
<P>
Presently, V
  supports monochrome icons which allow an on or
off state for each pixel, and color icons of either 256 or <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img7.gif"> colors.
The format of V
  monochrome icons is identical to the X bitmap format. This
is a packed array of unsigned characters (or bytes), with each bit
representing one pixel. The size of the icon is specified
separately from the icon array. The V
  color icon format is internally
defined, and allows easy conversion to various color file formats
used by X and Windows.
<P>
<H2><A NAME=SECTION00743000000000000000> Definition</A></H2>
<P>
<PRE>    class vIcon     // an icon
      {
      public:             //---------------------------------------- public
        vIcon(unsigned char* ic, int h, int w, int d = 1);
        ~vIcon();
        int height;             // height in pixels
        int width;              // width in pixels
        int depth;              // bits per pixel (1,8, or 24)
        unsigned char* icon;    // ptr to icon array

      protected:        //--------------------------------------- protected
      private:          //--------------------------------------- private
      };
</PRE>
<P>
<H2><A NAME=SECTION00744000000000000000> Constructor</A></H2>
 
<P>
<H3><A NAME=SECTION00744100000000000000> vIcon(unsigned char* icon, int height, int width, int depth = 1)</A></H3>
<P>
<A NAME=4140>&#160;</A>
<P>
The constructor for a <tt>
 vIcon</tt> has been designed to allow you to
easily define an icon. The first parameter is a pointer to the static icon
array. (Note: <tt>
 vIcon</tt> does not make a copy of the icon - it
needs to be a static or persistent definition in your code.) The second and third
parameters specify the height and width of the icon. The last
parameter specifies depth.
<P>
<H2><A NAME=SECTION00745000000000000000> Class Members</A></H2>
<P>
<H5><A NAME=SECTION00745001000000000000> int height</A></H5>
<P>
 This is the height in pixels of the icon.
<P>
<H5><A NAME=SECTION00745002000000000000> int width</A></H5>
<P>
 This is the width in pixels of the icon. A icon
will thus require (height * width) pixels.  These bits are packed
into bytes, with 0's padding the final byte if needed.
<P>
<H5><A NAME=SECTION00745003000000000000> int depth</A></H5>
<P>
 For monochrome icons, this will be one.
For color icons, the value is either 8 (for <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img8.gif"> or 256 colors) or 24
(for <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img9.gif"> colors).
<P>
<H5><A NAME=SECTION00745004000000000000> unsigned char* icon</A></H5>
<P>
 This is a pointer to the array of
bytes that contain the icon. V
  basically uses the format
defined by X (<tt>
 .XBM</tt>) bitmaps for monochrome bitmaps.
It uses an internal format consisting of a color map followed
by a one byte per pixel color icon description, or a three
bytes per pixel color icon description.
<P>
<H2><A NAME=SECTION00746000000000000000> Defining Icons</A></H2>
<P>
The easiest way to define an icon is to include the definition of
it in your code (either directly or by an <tt>
 #include</tt>).
You then provide the address of the icon data plus its height and
width to the initializer of the <tt>
 vIcon</tt> object.
<P>
The V
  distribution includes a simple icon editor that can
be used to create and edit icons in standard <tt>
 .vbm</tt> format,
as well as several other formats.
You can also generate monochrome icons is with the X
<tt>
 bitmap</tt> utility. That program allows you to
draw a bitmap, and then save the definition as C code. This code
can be included directly in your code and used in the initialization
of the <tt>
 vIcon</tt> object.  If you follow the example, you should
be able to modify and play with your icons very easily.
<P>
A simple converter that converts a Windows <tt>
 .bmp</tt> format file
to a V
  <tt>
 .vbm</tt> V
  bitmap format is also included in the
standard V
  distribution. There are many utilities that let
you generate <tt>
 .bmp</tt> files on both Windows and X, so this
tool easily lets you add color icons of arbitrary size. 
Chapter 9 has more details on <tt>
 bmp2vbm</tt>.
<P>
The standard V
  distribution also contains a directory 
(<tt>
 v/icons</tt>) with quite a few sample icons suitable for using
in a command bar.
<P>
Once you have a <tt>
 .vbm</tt> file, the easiest way to add an icon
to your program is to include code similar to this in your source:
<P>
<PRE>#include &quot;bruce.vbm&quot;    // Picture of Bruce
  static vIcon bruceIcon(&amp;bruce_bits[0], bruce_height,
                          bruce_width,8);
</PRE>
<P>
The following sections describe the format of the
<tt>
 unsigned char* icon</tt> data for 1, 8, and 24 bit
V
  icons.
<P>
<H3><A NAME=SECTION00746100000000000000> 1 Bit Icons</A></H3>
<P>
Icon definitions are packed into bytes. A bit value of 1
represents Black, a 0 is White. The bytes are arranged by rows,
starting with the top row, with the bytes padded with leading
zeros to come out to whole bytes. The bytes are scanned in
ascending order (<tt>
 icon[0], icon[1],</tt> etc.). Within bytes,
the bits are scanned from LSB to MSB. A 12 bit row with the
pattern <tt>
 BBBWWBBWBWBW</tt> would be represented as <tt>
 unsigned
char row[] =</tt> <tt>
 { 0x67, 0x05 };</tt>. This is the format
produced by the X <tt>
 bitmap</tt> program.
<P>
<H3><A NAME=SECTION00746200000000000000> 8 Bit Icons</A></H3>
<P>
Eight bit icons support 256 colors. Each pixel of the icon is
represented by one byte. Bytes are arranged in row order,
starting with the top row. Each byte represents an index into a
color map. The color map consists of RGB byte entries.
While an 8 bit icon can only have 256 colors, it can map into
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img10.gif"> possible colors. Thus, each 8 bit icon must also include
the color map as part of its data.
The very first byte of the <tt>
 icon</tt> data is the number of
entries in the color map <em>minus one</em><A NAME=tex2html191 HREF="footnode.html#4129"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/foot.gif"></A> (you don't have to define all 256
colors), followed by the color map RGB bytes, followed by the
icon pixels. The following is a very simple example of an icon:
<P>
<PRE>//vbm8
#define color_width 16
#define color_height 12
#define color_depth 8
static unsigned char color_bits[] = {
       2,       // 3 colors in color map (2 == 3-1)
       255,0,0, // byte value 0 maps to red
       0,255,0, // 1 -&gt; green
       0,0,255, // 2 -&gt; blue
       // Now, the pixels: an rgb &quot;flag&quot;, 3 16x4 rows
       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // RRRRRRRRRRRRRRRR
       0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0, // RRRRRRRRRRBBBBBR
       0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0, // RRRRRRRRRRBBBBBR
       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // RRRRRRRRRRRRRRRR
       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // GGGGGGGGGGGGGGGG
       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // GGGGGGGGGGGGGGGG
       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // GGGGGGGGGGGGGGGG
       1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // GGGGGGGGGGGGGGGG
       2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // BBBBBBBBBBBBBBBB
       2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // BBBBBBBBBBBBBBBB
       2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // BBBBBBBBBBBBBBBB
       2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2  // BBBBBBBBBBBBBBBB
     };

static vIcon colorIcon(&amp;color_bits[0], color_height, color_width,
     color_depth);
</PRE>
<P>
<H3><A NAME=SECTION00746300000000000000> 24 Bit Icons</A></H3>
<P>
Twenty-four bit icons are arranged in rows, staring with the top
row, of three bytes per pixel. Each 3 byte pixel value represents
an RGB value. There is no color map, and the RGB pixel values
start immediately in the <tt>
 unsigned char* icon</tt> data array.
This is a simple example of a 24 bit icon.
<P>
<PRE>//vbm24
#define c24_height 9
#define c24_width 6
#define c24_depth 24
    static unsigned char c24_bits[] = {
     255,0,0,255,0,0,255,0,0,255,0,0,0,255,0,0,255,0, //RRRRGG
     255,0,0,255,0,0,255,0,0,255,0,0,0,255,0,0,255,0, //RRRRGG
     255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0, //RRRRRR
     0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0, //GGGGGG
     0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0, //GGGGGG
     0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0, //GGGGGG
     0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255, //BBBBBB
     0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255, //BBBBBB
     0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255  //BBBBBB
    };
    static vIcon c24Icon(&amp;c24_bits[0], c24_height, c24_width,
        c24_depth);
</PRE>
<P>
<H2><A NAME=SECTION00747000000000000000> Example</A></H2>
<P>
This example uses the definition of the checked box used by the
Athena checkbox dialog command.
<P>
<PRE>// This code is generated by the V Icon Editor:
//vbm1
#define checkbox_width 12
#define checkbox_height 12
#define checkbox_depth 1
static unsigned char checkbox_bits[] = {
   0xff, 0x0f, 0x03, 0x0c, 0x05, 0x0a, 0x09, 0x09, 
   0x91, 0x08, 0x61,  0x08, 0x61, 0x08, 0x91, 0x08,
   0x09, 0x09, 0x05, 0x0a, 0x03, 0x0c, 0xff, 0x0f};

// This code uses the above definitions to define an icon
// in the initializer of checkIcon to vIcon.

static vIcon checkIcon(&amp;checkbox_bits[0],
    checkbox_height, checkbox_width, checkbox_depth);
</PRE>
<P>
<H2><A NAME=SECTION00748000000000000000> See Also</A></H2>
<P>
vButton, Dialog Commands C_Icon and C_IconButton
<P>

<H1><A NAME=SECTION00750000000000000000> vDialog</A></H1>
<P>
<A NAME=4147>&#160;</A>
<P>
Class to build a modeless dialog.
<P>
<H2><A NAME=SECTION00751000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vdialog.h&gt;</tt>
	<DT>Class name:
<DD> vDialog
 	<DT>Hierarchy:
<DD> (vBaseWindow,vCmdParent) -&gt;
  vDialog
	<DT>Contains:
<DD> CommandObject
<P>
 </DL><H2><A NAME=SECTION00752000000000000000> Description</A></H2>
<P>
The <tt>
 vDialog</tt> class is used to build modeless dialogs. Since
most dialogs will require a response to the commands they define,
you will almost always derive your own subclass based on <tt>
 vDialog</tt>,
and override the <tt>
 DialogCommand</tt> method to handle those
commands. Note that <tt>
 vDialog</tt> is multiply derived from the
<tt>
 vBaseWindow</tt> and the <tt>
 vCmdParent</tt> classes.
<P>
<H2><A NAME=SECTION00753000000000000000> Constructor</A></H2>
 
<P>

<H3><A NAME=SECTION00753100000000000000> vDialog(vBaseWindow* parent)</A></H3>
<P>
<A NAME=4150>&#160;</A>
<P>
<H3><A NAME=SECTION00753200000000000000> vDialog(vApp* parent)</A></H3>
<P>
<H3><A NAME=SECTION00753300000000000000> vDialog(vBaseWindow* parent, int isModal = 0, char* title = &quot;&quot;)</A></H3>
<P>
<H3><A NAME=SECTION00753400000000000000> vDialog(vApp* parent, int isModal = 0, char* title = &quot;&quot;)</A></H3>
<P>
A dialog is constructed by calling it with a pointer to a
vBaseWindow or vApp, which is usually the 'this' of the object that
creates the <tt>
 vDialog</tt>. The <tt>
 isModal</tt> parameter
indicates if the dialog should be modal or modeless. You would
usually use the default of 0. The modal flag is used by the
derived <tt>
 vModalDialog</tt> class. The <tt>
 title</tt> parameter can
be used to set a title for your dialog (see <tt>
 SetDialogTitle</tt>
for information on titles). If you create a derived dialog class,
you might provide a <tt>
 parent</tt> and a <tt>
 title</tt> in your
constructor, and provide the 0 for the <tt>
 isModal</tt> flag in the
call to the <tt>
 vDialog</tt> constructor.
<P>
The constructor builds an empty dialog. The <tt>
 AddDialogCmds</tt>
method must be called in order to build a useful dialog, which
you would usually do from within the constructor of your derived
dialog class.
<P>
<em>IMPORTANT!</em> When you derive your own <tt>
 vDialog</tt> objects,
you should write constructors for both the <tt>
 vBaseWindow*</tt> and
<tt>
 vApp*</tt> versions. These two different constructors allow
dialogs to be used both from windows directly, and from the
<tt>
 vApp</tt> code as well. Normally, you would construct a dialog
from a window. Occasionally, it will be useful to build a dialog
from the vApp that applies to all windows, and not just the window
that constructed it.
<P>

<H3><A NAME=SECTION00753500000000000000> void vDialog::AddDialogCmds(CommandObject* cList)</A></H3>
<P>
<A NAME=4156>&#160;</A>
<P>
This method is used to add a list of commands to a dialog.
It is called after the dialog object has been created.
You can usually do this in the constructor for your
derived Dialog class. This method is passed an array
of <tt>
 CommandObject</tt> structures.
<P>

<H3><A NAME=SECTION00753600000000000000> void vDialog::SetDialogTitle(char* title)</A></H3>
<P>
<A NAME=4159>&#160;</A>
<P>
This can be used to dynamically change the title of any object
derived from a <tt>
 vDialog</tt> object. Note that the title will
not always be displayed. This depends on the host system. For
example, the user can set up their X window manager to not show
decorations on transient windows, which is how dialogs
are implemented on X. You should write your applications to
provide a meaningful title as they are often helpful when
displayed.
<P>
<H2><A NAME=SECTION00754000000000000000> Example</A></H2>
<P>
This example shows the steps required to use a dialog object.
Note that the example uses the <tt>
 vDialog</tt> class directly,
and thus only uses the default behavior of responding to the
<tt>
 OK</tt> button.
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/dialog.gif">

<P>
<PRE>#include &lt;v/vdialog.h&gt;
    CommandObject cmdList[] =           // list of the commands
      {
        {C_Label, lbl1, 0, &quot;Label&quot;,NoList,CA_MainMsg,isSens,0,0},
        {C_Button, M_OK, M_OK, &quot; OK &quot;, NoList,
            CA_DefaultButton, isSens,lbl1,0},
        {C_EndOfList,0,0,0,0,CA_None,0,0}  // This ends list
      };
    ...
    vDialog curDialog(this,0,&quot;Sample Dialog&quot;); // create dialog instance

    curDialog.AddDialogCmds(cmdList);          // add the commands

    curDialog.ShowDialog(&quot;Sample modeless dialog.&quot;); // invoke
    ...
</PRE>
<P>
This example creates a simple modeless dialog with a label and
an OK button placed below the label (see the description
of layout control below). <tt>
 ShowDialog</tt> displays the dialog,
and the <tt>
 vDialog::DialogCommand</tt> method will be invoked with
the id (2) and value (<tt>
 M_OK</tt>) of the OK button when it is
pressed.
<P>
Use the <tt>
 vModalDialog</tt> class to define modal
dialogs.
<P>
The <tt>
 CommandObject</tt> structure includes the following:
<P>
<PRE>    typedef struct CommandObject
      {
        CmdType cmdType;    // what kind of item is this
        ItemVal cmdId;      // unique id for the item
        ItemVal retVal;     // initial value
                            //  depends on type of command
        char* title;        // string for label or title
        void* itemList;     // a list of stuff to use for the cmd
                            //  depends on type of command
        CmdAttribute attrs; // list of attributes of command
        unsigned
             Sensitive:1;   // if item is sensitive or not
        ItemVal cFrame;     // if item part of a frame
        ItemVal cRightOf;   // Item placed left of this id
        ItemVal cBelow;     // Item placed below this one
        int size;           // Used for size information
      } CommandObject;
</PRE>
<P>
Placements of command objects within the dialog box are controlled
by the <tt>
 cRightOf</tt> and <tt>
 cBelow</tt> fields. By specifying
where an object goes in relation to other command objects in the
dialog, it is simple to get a very pleasing layout of the dialog.
The exact spacing of command objects is controlled by the <tt>
 vDialog</tt>
class, but the application can used <tt>
 C_Blank</tt> command
objects to help control spacing.
<P>
The various types of command objects that can be added include
(with suggested id prefix in parens):
<P>
<PRE>    C_EndOfList:   Used to denote end of command list
    C_Blank:       filler to help RightOfs, Belows work (blk)
    C_BoxedLabel:  a label with a box (bxl)
    C_Button:      Button (btn)
    C_CheckBox:    Checked Item (chk)
    C_ColorButton: Colored button (cbt)
    C_ColorLabel:  Colored label (clb)
    C_ComboBox:    Popup combo list (cbx)
    C_Frame:       General purpose frame (frm)
    C_Icon:        a display only Icon (ico)
    C_IconButton:  a command button Icon (icb)
    C_Label:       Regular text label (lbl)
    C_List:        List of items (lst)
    C_ProgressBar: Bar to show progress (pbr)
    C_RadioButton: Radio button (rdb)
    C_Slider:      Slider to enter value (sld)
    C_Spinner:     Spinner value entry (spn)
    C_TextIn:      Text input field (txi)
    C_Text:        wrapping text out (txt)
    C_ToggleButton: a toggle button (tbt)
    C_ToggleFrame: a toggle frame (tfr)
    C_ToggleIconButton:  a toggle Icon button (tib)
</PRE>
<P>
The use of these commands is described in the <tt>
 DialogCommand</tt>
section.
<P>

<H3><A NAME=SECTION00754100000000000000> virtual void CancelDialog()</A></H3>
<P>
<A NAME=4388>&#160;</A>
<P>
This method is used to cancel any action that took place in the
dialog.  The values of any items in the dialog are reset to their
original values, and the  This method is automatically invoked
when the user selects a button with the value <tt>
 M_Cancel</tt>
and the <tt>
 DialogCommand</tt> method invoked as appropriate to
reset values of check boxes and so on. <tt>
 CancelDialog</tt> can
also be invoked by the application code.
<P>

<H3><A NAME=SECTION00754200000000000000> virtual void CloseDialog()</A></H3>
<P>
<A NAME=4391>&#160;</A>
<P>
The <tt>
 CloseDialog</tt> is used to close the dialog. It can be
called by user code, and is automatically invoked if the user
selects the <tt>
 M_Done</tt> or <tt>
 M_OK</tt> buttons and the the
user either doesn't override the <tt>
 DialogCommand</tt> or calls
the default <tt>
 DialogCommand</tt> from any derived <tt>
 DialogCommand</tt>
methods.
<P>

<H3><A NAME=SECTION00754300000000000000> virtual void DialogCommand(ItemVal Id, ItemVal Val, CmdType Type)</A></H3>
<P>
<A NAME=4394>&#160;</A>
<P>
This method is invoked when a user selects some command item
of the dialog. The default <tt>
 DialogCommand</tt> method will
normally be overridden by a user derived class. It is useful to
call the default <tt>
 DialogCommand</tt> from the derived method for
default handling of the <tt>
 M_Cancel</tt> and <tt>
 M_OK</tt>
buttons.
<P>
The <tt>
 Id</tt> parameter is the value of the <tt>
 cmdId</tt> field of
the <tt>
 CommandObject</tt> structure. The <tt>
 Val</tt> parameter is
the <tt>
 retVal</tt> value, and the <tt>
 Type</tt> is the <tt>
 cmdType</tt>.
<P>
The user defined <tt>
 DialogCommand</tt> is where most of the work
defined by the dialog is done. Typically the derived
<tt>
 DialogCommand</tt> will have a <tt>
 switch</tt> statement with a
<tt>
 case</tt> for each of the command <tt>
 cmdId</tt> values defined
for items in the dialog.
<P>

<H3><A NAME=SECTION00754400000000000000> void DialogDisplayed()</A></H3>
<P>
<A NAME=4397>&#160;</A>
<P>
This method is called by the V
  runtime system after a dialog
has actually been displayed on the screen. This method is especially
useful to override to set values of dialog controls with
<tt>
 SetValue</tt> and <tt>
 SetString</tt>.
<P>
It is important to understand that the dialog does not get
displayed until <tt>
 ShowDialog</tt> or <tt>
 ShowModalDialog</tt> has
been called. There is a very important practical limitation
implied by this, especially for modal dialogs. The values of
controls <em>cannot</em> be changed until the dialog has been
displayed, even though the <tt>
 vDialog</tt> object may exist. Thus,
you can't call <tt>
 SetValue</tt> or <tt>
 SetString</tt> until after
you call <tt>
 ShowDialog</tt> for modeless dialogs, or <tt>
 ShowModalDialog</tt>
for modal dialogs. Since <tt>
 ShowModalDialog</tt> does not return
until the user has closed the dialog, you must override <tt>
 DialogDisplayed</tt>
if you want to change the values of controls in a modal dialog
dynamically.
<P>
For most applications, this is not a problem because the
static definitions of controls in the <tt>
 CommandObject</tt> definition
will be usually be what is needed. However, if you need to create
a dialog that has those values changed at runtime, then the
easiest way is to include the required <tt>
 SetValue</tt> and
<tt>
 SetString</tt> calls inside the overridden <tt>
 DialogDisplayed</tt>.
<P>

<H3><A NAME=SECTION00754500000000000000> void GetDialogPosition(int&amp; left, int&amp; top, int&amp; width, int&amp; height)</A></H3>
<P>
<A NAME=4400>&#160;</A>
<P>
Returns the position and size of <tt>
 this</tt> dialog. These values
reflect the actual position and size on the screen of the dialog.
The intent of this method
is to allow you to find out where a dialog is so
position it so that it
doesn't cover a window.
<P>

<H3><A NAME=SECTION00754600000000000000> virtual int GetTextIn(ItemVal Id, char* str, int maxlen)</A></H3>
<P>
<A NAME=4403>&#160;</A>
<P>
This method is called by the application to retrieve any text
entered into any <tt>
 C_TextIn</tt> items included in the dialog
box. It will usually be called after the dialog is closed.
You call <tt>
 GetTextIn</tt> with the <tt>
 Id</tt> of the TextIn
command, the address of a buffer (<tt>
 str</tt>), and the
size of <tt>
 str</tt> in <tt>
 maxlen</tt>.
<P>

<H3><A NAME=SECTION00754700000000000000> virtual int GetValue(ItemVal Id)</A></H3>
<P>
<A NAME=4406>&#160;</A>
<P>
This method is called by the user code to retrieve values of
command items, usually after the dialog is closed.  The most
typical use is to get the index of any item selected by the
user in a <tt>
 C_List</tt> or <tt>
 C_ComboBox</tt>.
<P>

<H3><A NAME=SECTION00754800000000000000> int IsDisplayed()</A></H3>
<P>
<A NAME=4409>&#160;</A>
<P>
This returns true if the dialog object is currently displayed,
and false if it isn't. Typically, it will make sense only to
have a single displayed instance of any dialog, and your code
will want to create only one instance of any dialog. Since
modal dialogs allow the user to continue to interact with the
parent window, you must prevent multiple calls to <tt>
 ShowDialog</tt>.
One way would be to make the command that displays the dialog to
be insensitive. <tt>
 IsDisplayed()</tt> is provided as an alternative
method. You can check the <tt>
 IsDisplayed()</tt> status before
calling <tt>
 ShowDialog</tt>.
<P>

<H3><A NAME=SECTION00754900000000000000> virtual void SetDialogPosition(int left, int top)</A></H3>
<P>
<A NAME=4412>&#160;</A>
<P>
Moves <tt>
 this</tt> dialog to the location <tt>
 left</tt> and
<tt>
 top</tt>. This function can be used to move dialogs so
they don't cover other windows.
<P>

<H3><A NAME=SECTION007541000000000000000> virtual void SetValue(ItemVal Id, ItemVal val, ItemSetType type)</A></H3>
<P>
<A NAME=4415>&#160;</A>
<P>
This method is used to change the state of dialog command items.
The <tt>
 ItemSetType</tt> parameter is used to control what is set.
Not all dialog command items can use all types of settings. The possibilities
include:
<P>
<H4><A NAME=SECTION007541010000000000000> Checked</A></H4>
<P>
<A NAME=4417>&#160;</A>
<P>
The <tt>
 Checked</tt> type is used to change the checked status
of check boxes. V
  will normally handle checkboxes, but if
you implement a command such as <em>Check All</em>, you can
use <tt>
 SetValue</tt> to change the check state according to
<tt>
 ItemVal val</tt>.
<P>
<H4><A NAME=SECTION007541020000000000000> Sensitive</A></H4>
<P>
<A NAME=4419>&#160;</A>
<P>
The <tt>
 Sensitive</tt> type is used to change the sensitivity of
a dialog command.
<P>
<H4><A NAME=SECTION007541030000000000000> Value</A></H4>
<P>
<A NAME=4421>&#160;</A>
<P>
The <tt>
 Value</tt> type is used primarily to preselect the item
specified by <tt>
 ItemVal val</tt> in a list or combo box list.
<P>
<H4><A NAME=SECTION007541040000000000000> ChangeList, ChangeListPtr</A></H4>
<P>
<A NAME=4423>&#160;</A>
<P>
<A NAME=4425>&#160;</A>
<P>
<A NAME=4280>&#160;</A>
<A NAME=4281>&#160;</A>
<P>
Lists, Combo Boxes, and Spinners use the <tt>
 itemList</tt>
field of the defining <tt>
 CommandObject</tt> to specify
an appropriate list. <tt>
 SetValue</tt> provides two ways
to change the list values associated with these controls.
<P>
The key to using <tt>
 ChangeListPtr</tt> and <tt>
 ChangeList</tt>
is an understanding of just how the controls use the list.
When a list type control is instantiated, it keeps a private
copy of the pointer to the original list as specified
in the <tt>
 itemList</tt> field of the defining <tt>
 CommandObject</tt>.
<P>
So if you want to change the original list, then
<tt>
 ChangeList</tt> is used. The original list may be
longer or shorter, but it must be in the same place.
Remember that a NULL entry marks the end of the list.
So you could allocate a 100 item array, for example,
and then reuse it to hold 0 to 100 items.
<P>
Call <tt>
 SetValue</tt> with <tt>
 type</tt> set to <tt>
 ChangeList</tt>.
This will cause the list to be updated. Note that you must not
change the <tt>
 itemList</tt> pointer used when you defined the list
or combo box. The contents of the list can change, but the
pointer must be the same. The <tt>
 val</tt> parameter is not used
for <tt>
 ChangeList</tt>.
<P>
Sometimes, especially for regular list controls, a statically
sized list just won't work. Using <tt>
 ChangeListPtr</tt> allows
you to use dynamically created list, but with a small coding
penalty. To use <tt>
 ChangeListPtr</tt>, you must first modify
the contents of the <tt>
 itemList</tt> field of the original 
<tt>
 CommandObject</tt> definition to point the the new list.
Then call <tt>
 SetValue</tt> with <tt>
 ChangeListPtr</tt>. Note
that this will both update the pointer, and update the
contents of the list. You <em>don't</em> need to call again with
<tt>
 ChangeList</tt>.
<P>
The following illustrates using both types of list change:
<P>
<PRE>  char* comboList[] = {
    &quot;Bruce&quot;, &quot;Katrina&quot;, &quot;Risa&quot;, &quot;Van&quot;, 0 };
  char* list1[] = {&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, 0};
  char* list2[] = {&quot;A&quot;, &quot;B&quot;, &quot;C&quot;, &quot;D&quot;, 0};

  // The definition of the dialog
  CommandObject ListExample[] = {
    {C_ComboBox,100,0,&quot;&quot;,(void*)comboList,CA_None,isSens,0,0,0},
    {C_List,200,0,&quot;&quot;,(void*)list1,CA_None,isSens,0,0,0},
    ...
    };
   ...

    // Change the contents of the combo list
    comboList[0] = &quot;Wampler&quot;;  // Change Bruce to Wampler
    SetValue(200,0,ChangeList);
   ...
    // Change to a new list entirely for list
    // Note that we have to change ListExample[1], the
    // original definition of the list control.
    ListExample[1].itemList = (void*)list2;  // change to list2
    SetValue(100,0,ChangeListPtr);
   ...
</PRE>
<P>
Note that this example uses static definitions of lists. It is
perfectly fine to use completely dynamic lists: you just have
to dynamically fill in the appropriate <tt>
 itemList</tt> field
of the defining <tt>
 CommandObject</tt>.
<P>
Please see the description of <tt>
 DialogDisplayed</tt>
for an important discussion of setting dialog control values.
<P>

<H3><A NAME=SECTION007541100000000000000> virtual void SetString(ItemVal Id, char* str)</A></H3>
<P>
<A NAME=4428>&#160;</A>
<P>
This method is called to set the string values of dialog items. This
can include the labels on check boxes and radio buttons and
labels, as well as the text value of a Text item.
<P>
Please see the description of <tt>
 DialogDisplayed</tt>
for an important discussion of setting dialog control values.
<P>

<H3><A NAME=SECTION007541200000000000000> virtual void ShowDialog(char* message)</A></H3>
<P>
<A NAME=4431>&#160;</A>
<P>
After the dialog has been defined, it must then be displayed by
calling the <tt>
 ShowDialog</tt> method. If a  <tt>
 C_Label</tt> was
defined with a <tt>
 CA_MainMsg</tt> attribute, then the message
provided to <tt>
 ShowDialog</tt> will be used for that label.
<P>
<tt>
 ShowDialog</tt> returns to the calling code as soon as the
dialog is displayed. It is up to the <tt>
 DialogCommand</tt> method
to then handle command input to the dialog, and to close the
dialog when done.
<P>
Please see the description of <tt>
 DialogDisplayed</tt>
for an important discussion of setting dialog control values.
<P>
<H2><A NAME=SECTION00755000000000000000> Derived Methods</A></H2>
<P>
None.
<P>
<H2><A NAME=SECTION00756000000000000000> Inherited Methods</A></H2>
<P>
None.
<P>
<H2><A NAME=SECTION00757000000000000000> See Also</A></H2>
<P>
vModalDialog
<P>

<P>
<H1><A NAME=SECTION00760000000000000000> vModalDialog</A></H1>
<P>
<A NAME=4434>&#160;</A>
<P>
Used to show modal dialogs.
<P>
<H2><A NAME=SECTION00761000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vmodald.h&gt;</tt>
	<DT>Class name:
<DD> vModalDialog
 	<DT>Hierarchy:
<DD> (vBaseWindow,vCmdParent) -&gt;
  vDialog -&gt;
  vModalDialog
	<DT>Contains:
<DD> CommandObject
<P>
 </DL><H2><A NAME=SECTION00762000000000000000> Description</A></H2>
<P>
This class is an implementation of a modal dialog.  This means
that the dialog grabs control, and waits for the user to select
an appropriate command from the dialog.  You can use any of
the methods defined by the <tt>
 vDialog</tt> class, as well as the
new <tt>
 ShowModalDialog</tt> method.
<P>
<H2><A NAME=SECTION00763000000000000000> Constructor</A></H2>
 
<P>

<H3><A NAME=SECTION00763100000000000000> vModalDialog(vBaseWindow* parent, char* title)</A></H3>
<P>
<A NAME=4437>&#160;</A>
<P>
<H3><A NAME=SECTION00763200000000000000> vModalDialog(vApp* parent, char* title)</A></H3>
<P>
There are two versions of the constructor, one for constructing
dialogs from windows, the other from the vApp object. See the
description of the <tt>
 vDialog</tt> constructor for more details.
<P>
The default value for the title is an empty string, so you
can declare instances of modal dialogs without the title
string if you wish. The dialog title will always show in
Windows, but in X is dependent on how the window manager
treats decorations on transient windows.
<P>
<H2><A NAME=SECTION00764000000000000000> New Methods</A></H2>
<P>

<H3><A NAME=SECTION00764100000000000000> virtual ItemVal ShowModalDialog(char* message, ItemVal&amp; retval)</A></H3>
<P>
<A NAME=4441>&#160;</A>
<P>
This method displays the dialog, and does not return until
the modal dialog is closed. It returns the id of the
button that caused the return, and in <tt>
 retval</tt>, the value of
the button causing the return as defined in the dialog
declaration.
<P>
Please see the description of <tt>
 DialogDisplayed</tt>
for an important discussion of setting dialog control values.
<P>
There are a couple of ways to close a modal dialog and make
<tt>
 ShowModalDialog</tt> return, all controlled by the <tt>
 DialogCommand</tt>
method. The default <tt>
 DialogCommand</tt> will close the modal
dialog automatically when the user clicks the <tt>
 M_Cancel</tt>,
<tt>
 M_Done</tt>, or <tt>
 M_OK</tt> buttons.
<P>
All command actions are still passed to the virtual <tt>
 DialogCommand</tt>
method, which is usually overridden in the derived class. By
first calling <tt>
 vModalDialog::DialogCommand</tt>
to handle the default operation, and then checking for the
other buttons that should close the dialog, you can also close
the dialog by calling the <tt>
 CloseDialog</tt> method, which will
cause the return.
<P>
The following code demonstrates this.
<P>
<PRE>    void myModal::DialogCommand(ItemVal id, ItemVal val,
        CmdType ctype)
      {
        // Call the parent for default processing
        vModalDialog::DialogCommand(id,val,ctype);
        if (id == M_Yes || id == M_No) // These close, too.
            CloseDialog();
      }
</PRE>
<P>
<H2><A NAME=SECTION00765000000000000000> Derived Methods</A></H2>
<P>

<H3><A NAME=SECTION00765100000000000000> virtual void DialogCommand(ItemVal Id, ItemVal val, CmdType type)</A></H3>
<P>
<A NAME=4444>&#160;</A>
<P>
Adds a little functionality for handling this modally.
<P>
<H2><A NAME=SECTION00766000000000000000> Inherited Methods</A></H2>
<P>
<H3><A NAME=SECTION00766100000000000000> vDialog(vBaseWindow* parent)</A></H3>
<P>
<A NAME=4447>&#160;</A>
<P>
<H3><A NAME=SECTION00766200000000000000> vDialog(vBaseWindow* parent, int modalflag)</A></H3>
<P>
<H3><A NAME=SECTION00766300000000000000> vDialog(vApp* parent)</A></H3>
<P>
<H3><A NAME=SECTION00766400000000000000> vDialog(vApp* parent, int modalflag)</A></H3>
<P>
<H3><A NAME=SECTION00766500000000000000> void vDialog::AddDialogCmds(CommandObject* cList)</A></H3>
<P>
<A NAME=4453>&#160;</A>
<P>
<H3><A NAME=SECTION00766600000000000000> virtual void CancelDialog()</A></H3>
<P>
<A NAME=4456>&#160;</A>
<P>
<H3><A NAME=SECTION00766700000000000000> virtual void CloseDialog()</A></H3>
<P>
<A NAME=4459>&#160;</A>
<P>
<H3><A NAME=SECTION00766800000000000000> virtual int GetTextIn(ItemVal Id, char* str, int maxlen)</A></H3>
<P>
<A NAME=4462>&#160;</A>
<P>
<H3><A NAME=SECTION00766900000000000000> virtual int GetValue(ItemVal Id)</A></H3>
<P>
<A NAME=4465>&#160;</A>
<P>
<H3><A NAME=SECTION007661000000000000000> virtual void SetValue(ItemVal Id, ItemVal val, ItemSetType type)</A></H3>
<P>
<A NAME=4468>&#160;</A>
<P>
<H3><A NAME=SECTION007661100000000000000> virtual void SetString(ItemVal Id, char* str)</A></H3>
<P>
<A NAME=4471>&#160;</A>
<P>
<H3><A NAME=SECTION007661200000000000000> virtual void ShowDialog(char* message)</A></H3>
<P>
<A NAME=4474>&#160;</A>
<P>
<H2><A NAME=SECTION00767000000000000000> See Also</A></H2>
<P>
vDialog
<P>
<BR> <HR><A NAME=tex2html1422 HREF="node8.html"><IMG ALIGN=BOTTOM ALT="next" SRC="../icons/next.gif"></A>   <A NAME=tex2html1420 HREF="vwebref.html"><IMG ALIGN=BOTTOM ALT="up" SRC="../icons/up.gif"></A>   <A NAME=tex2html1414 HREF="node6.html"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/prev.gif"></A>   <A NAME=tex2html1424 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="../icons/contents.gif"></A>      <BR>
<B> Next:</B> <A NAME=tex2html1423 HREF="node8.html"> Drawing</A>
<B>Up:</B> <A NAME=tex2html1421 HREF="vwebref.html">V Reference Manual</A>
<B> Previous:</B> <A NAME=tex2html1415 HREF="node6.html"> Command Windows</A>
<BR> <HR> <P>
<BR> <HR>
<P><ADDRESS>
<I>Bruce Wampler <BR>
Thu Nov 14 09:25:45 MST 1996</I>
</ADDRESS>
</BODY>
