📄 dialog_programming.hlp
字号:
{pstd}
Part of specifying how a dialog appears is defining where things go
and how big they are.
{pstd}
Positions are indicated by a pair of numbers, {it:x} and {it:y}. They are
measured in pixels and are interpreted as being measured from the top-left
corner: {it:x} is how far to the right, and {it:y} is how far down.
{pstd}
Sizes are similarly indicated by a pair of numbers, {it:xsize} and
{it:ysize}. They, too, are measured in pixels and indicate the size starting
at the top-left corner of the object.
{pstd}
Any command that needs a position or a size always takes all four
numbers{hline 2}position and size{hline 2}and you must specify all four. In
addition to each element being allowed to be a number, some extra codes are
allowed. A position or size element is defined as
{p2colset 9 17 17 0}{...}
{p2col :{it:#}}any unsigned integer number, such as 0, 1, 10, 200, . . .{p_end}
{p2col :{it:.}}(period) meaning the context-specific default value for
this position/size element. {cmd:.} is allowed only with heights
of controls (heights are measured from the top down) and for the initial
position of a dialog box.{p_end}
{p2col :{cmd:@}}means the previous value for this position/size element.
If {cmd:@} is used for an {it:x} or a {it:y}, then the {it:x} or {it:y} from
the preceding command will be used. If {cmd:@} is used for an {it:xsize} or
a {it:ysize}, then the previous {it:xsize} or {it:ysize} will be used.{p_end}
{p2col :{cmd:+}{it:#}}means a positive offset from the last value (meaning to
the right or down or bigger). If {cmd:+10} is used for {it:x}, the result
will be 10 pixels to the right of the previous position. If {cmd:+10} were used
for a {it:ysize}, it would mean 10 pixels taller.{p_end}
{p2col :{cmd:-}{it:#}}means a negative offset from the last value (meaning to
the left or up or smaller). If {cmd:-10} is used for {it:y}, the result will
be 10 pixels above the previous position. If {cmd:-10} were used for a {it:xsize},
it would mean 10 pixels narrower.{p_end}
{p2col :{it:name}}means the value last recorded for {it:name} by the
{hi:DEFINE} command.{p_end}
{p2colreset}{...}
{pstd}
The {cmd:DEFINE} command has the syntax
{bind:DEFINE {it:name} { {cmd:.}|{it:#}|{cmd:+}{it:#}|{cmd:-}{it:#}|{cmd:@x}|{cmd:@y}|{opt @xs:ize}|{opt @ys:ize} }}
{pstd}
and may appear anywhere in your dialog code, even inside the
{hi:BEGIN}/{hi:END} of {hi:DIALOG}. Anywhere you need to specify a
position or size element, you can use a {it:name} defined by {hi:DEFINE}.
{pstd}
The first four possibilities for defining {it:name} have the obvious
meaning: {cmd:.} means the default, {it:#} means the number specified, {cmd:+}{it:#}
means a positive offset, and {cmd:-}{it:#} means a negative offset. The other
four possibilities{hline 2}{cmd:@x}, {cmd:@y}, {cmd:@xsize}, and {cmd:@ysize}{hline 2}refer
to the previous {it:x}, {it:y}, {it:xsize}, and {it:ysize} values, with
previous meaning previous to the time the {cmd:DEFINE} command was issued.
{marker remarks2.3}{...}
{title:2.3 Default values}
{pstd}
You can also load input controls with initial, or default, values.
For instance, perhaps as a default you want one
checkbox checked and another unchecked, and you want an edit field filled in
with "Default title".
{pstd}
The syntax of the {hi:CHECKBOX} command, which creates checkboxes, is
{bind:{hi:CHECKBOX} . . . {cmd:[,} . . . {opt default(defnumval)} . . .{cmd:]}}
{pstd}
In checkboxes, the {opt default()} option specifies how the box is to be
filled in initially, and 1 corresponds to checked and 0 to unchecked.
{pstd}
The syntax of {hi:EDIT}, which creates edit fields, is
{bind:{cmd:EDIT} . . . {cmd:[,} . . . {opt default(defstrval)} . . .{cmd:]}}
{pstd}
In edit fields, {opt default()} specifies what the box will contain initially.
{pstd}
Wherever {it:defnumval} appears in a syntax diagram, you may type
{p2colset 5 34 36 2}{...}
{p2col :{it:defnumval}}definition{p_end}
{p2line}
{p2col :{it:#}}meaning the number specified{p_end}
{p2col :{opt literal} {it:#}}same as {it:#}{p_end}
{p2col :{opt c(name)}}value of {opt c(name)}; see {helpb creturn}{p_end}
{p2col :{opt r(name)}}value of {opt r(name)}; see {helpb return}{p_end}
{p2col :{opt e(name)}}value of {opt e(name)}; see {helpb ereturn}{p_end}
{p2col :{opt s(name)}}value of {opt s(name)}; see {helpb return}{p_end}
{p2col :{cmd:global} {it:name}}value of global macro {cmd:$}{it:name}{p_end}
{p2line}
{p2colreset}{...}
{pstd}
Wherever {it:defstrval} appears in a syntax diagram, you may type
{p2colset 5 34 36 2}{...}
{p2col :{it:defstrval}}definition{p_end}
{p2line}
{p2col :{it:string}}meaning the string specified{p_end}
{p2col :{cmd:literal} {it:string}}same as {it:string}{p_end}
{p2col :{opt c(name)}}contents of {opt c(name)}; see {helpb creturn}{p_end}
{p2col :{opt r(name)}}contents of {opt r(name)}; see {helpb return}{p_end}
{p2col :{opt e(name)}}contents of {opt e(name)}; see {helpb ereturn}{p_end}
{p2col :{opt s(name)}}contents of {opt s(name)}; see {helpb return}{p_end}
{p2col :{cmd:char} {it:varname}[{it:charname}]}value of characteristic; see {helpb char}{p_end}
{p2col :{cmd:global} {it:name}}contents of global macro {cmd:$}{it:name}{p_end}
{p2line}
{p 4 6 2}Note: If {it:string} is enclosed in double quotes (simple or compound),
the first set of such quotes is stripped.{p_end}
{p2colreset}{...}
{pstd}
List and combo boxes present the user with a list of items from which
to choose. In dialog-box jargon, rather than having initial
or default values, the boxes are said to be populated. The syntax for
creating a list-box input control is
{bind:{cmd:LISTBOX} . . . {cmd:[,} . . . {opt contents(conspec)} . . .{cmd:]}}
{pstd}
Wherever a {it:conspec} appears in a syntax diagram, you may type
{phang}
{cmd:list} {it:listname}{break}
populates the box with the specified list, which you create separately using
the {cmd:LIST} command. {cmd:LIST} has the following syntax:
{cmd:LIST}
{cmd:BEGIN}
{it:item to appear}
{it:item to appear}
. . .
{cmd:END}
{phang}
{opt mat:rix}{break}
populates the box with the names of all matrices currently defined in Stata.
{phang}
{opt vec:tor}{break}
populates the box with the names of all 1 {it:x} {it:k} and {it:k} {it:x} 1
matrices currently defined in Stata.
{phang}
{cmd:row}{break}
populates the box with the names of all 1 {it:x} {it:k} matrices currently
defined in Stata.
{phang}
{opt col:umn}{break}
populates the box with the names of all {it:k} {it:x} 1 matrices currently
defined in Stata.
{phang}
{opt sq:uare}{break}
populates the box with the names of all {it:k} {it:x} {it:k} matrices currently
defined in Stata.
{phang}
{opt sca:lar}{break}
populates the box with the names of all scalars currently defined in Stata.
{phang}
{opt constr:aint}{break}
populates the box with the names of all constraints currently defined in
Stata.
{phang}
{opt est:imates}{break}
populates the box with the names of all saved estimates currently defined in
Stata.
{phang}
{cmd:char} {it:varname}{cmd:[}{it:charname}{cmd:]}{break}
populates the box with the elements of the characteristic
{bind:{it:varname}{cmd:[}{it:charname}{cmd:]}}, parsed on spaces.
{phang}
{opt e(name)}{break}
populates the box with the elements of {opt e(name)}, parsed on spaces.
{phang}
{opt glo:bal}{break}
populates the box with the names of all global macros currently defined in
Stata.
{phang}
{opt valuelab:els}{break}
populates the box with the names of all values labels currently defined in
Stata.
{pstd}
{hi:Predefined defined lists for use with Stata graphics:}
{p2colset 9 32 34 2}{...}
{p2col :predefined lists}definition{p_end}
{p2line}
{p2col :{opt symbols}}list of marker symbols{p_end}
{p2col :{opt symbolsizes}}list of marker symbol sizes{p_end}
{p2col :{opt colors}}list of colors{p_end}
{p2col :{opt clockpos}}list of clock positions{p_end}
{p2col :{opt linepatterns}}list of line patterns{p_end}
{p2col :{opt linewidths}}list of line widths{p_end}
{p2col :{opt connecttypes}}list of line connecting types{p_end}
{p2col :{opt textsizes}}list of text sizes{p_end}
{p2col :{opt justification}}list of horizontal text justifications{p_end}
{p2col :{opt alignment}}list of vertical text alignments{p_end}
{p2col :{opt margin}}list of margins{p_end}
{p2col :{opt tickpos}}list of axis-tick positions{p_end}
{p2col :{opt angles}}list of angles; usually used for axis labels{p_end}
{p2col :{opt compass}}list of compass directions{p_end}
{p2col :{opt yesno}}list containing Default, Yes, and No. Usually accompanied
by a user-defined {it:values} list{p_end}
{p2line}
{p2colreset}{...}
{marker remarks2.4}{...}
{title:2.4 Memory (recollection)}
{pstd}
All input control commands have a {opt default()} or {opt contents()}
option that specifies how the control is to be filled in, for example
{bind:{hi:CHECKBOX} . . . {cmd:[,} . . . {opt default(defnumval)} . . .{cmd:]}}
{pstd}
In this command, if {it:defnumval} evaluates to 0, the checkbox is initially
unchecked; otherwise, it is checked. If {opt default()} is not
specified, the box is initially unchecked.
{pstd}
Dialogs remember how they were last filled in
during a session, so the next time the user invokes the dialog box that
contains this {hi:CHECKBOX} command, the {opt default()} option will be
ignored and the checkbox will be as the user last left it. That is, the
setting will be remembered unless you specify the
input control's {opt nomemory} option:
{bind:{hi:CHECKBOX} . . . {cmd:[,} . . . {opt default(defnumval)} {cmd:nomemory} . . .{cmd:]}}
{pstd}
{opt nomemory} specifies that the dialog-box manager not remember between
invocations how the control is filled in; it will always reset it
to the default, whether that default is explicitly specified or implied.
{pstd}
Whether or not you specify {opt nomemory}, explicit or implicit defaults are
also restored when the user presses the Reset helper button.
{pstd}
The contents of dialog boxes are only remembered during a session, not between
them. Within a session, the {helpb discard} command causes Stata to forget
the contents of all dialog boxes.
{pstd}
The issues of initialization and memory are in fact more complicated than they
first appears. Consider a list box. A list box might be
populated with the currently saved estimates. If the dialog box containing
this list box is closed and reopened, the available estimates may have
changed. So, list boxes are always repopulated according to the
instructions given. Even so, list boxes remember the choice that was made.
If that choice is still among the possibilities, that choice will be the one
selected unless {opt nomemory} is specified; otherwise, the choice goes back to
being the default{hline 2}the first choice in the list of alternatives.
{pstd}
The same issues arise with combo boxes, and that is why some controls have the
option {opt default()} and others have {opt contents()}. {opt default()} is used
once, and, after that, memory is substituted (unless {cmd:nomemory} is
specified). {opt contents()} is always used{hline 2}{cmd:nomemory} or
not{hline 2}but the choice made is remembered (unless {cmd:nomemory} is
specified).
{marker remarks2.5}{...}
{title:2.5 I-actions and member functions}
{pstd}
I-actions{hline 2}intermediate actions{hline 2}refer to all actions taken
in producing the u-action. An i-action might disable or hide
controls when another control is checked or unchecked, although there are
many other possibilities. I-actions are always optional.
{pstd}
I-actions are invoked by {opt on}{it:*}{cmd:()} options{hline 2}those
that begin with the letters "{opt on}". For instance, the syntax for the
{hi:CHECKBOX} command{hline 2}the command for defining a checkbox
control{hline 2}is
{bind:{hi:CHECKBOX} {it:controlname} . . . {cmd:[,} . . . {opt onclickon(iaction)} {opt onclickoff(iaction)} . . .{cmd:]}}
{pstd}
{opt onclickon()} is the i-action to be taken when the checkbox is checked,
and {opt onclickoff()} is the i-action for when the checkbox is unchecked.
You do not have to fill in the {opt onclickon()} and {opt onclickoff()}
options{hline 2}the checkbox will work fine taking no i-actions{hline 2}but
you may fill them in if you want, say, to disable or to enable other controls
when this control is checked. For instance, you might code
{bind:{cmd:CHECKBOX sw2} . . . {cmd:, onclickon(d2.sw3.show) onclickoff(d2.sw3.hide)} . . .}
{pstd}
{opt d2.sw3} refers to the control named {opt sw3} in the dialog
{opt d2} (for instance, the control we just defined is named {opt sw2}).
{opt hide} and {opt show} are called member functions. {opt hide} is the
member function that hides a control, and {opt show} is its inverse. Controls
have other member functions as well; what member functions are available is
documented with the command that creates the specific control.
{pstd}
Many commands have {opt on}{it:*}{cmd:()} options that allow you to specify
i-actions. When {it:iaction} appears in a syntax diagram, you can specify
{phang}
{cmd:.} (period){break}
Do nothing; take no action. This is the default if you do not specify the
{opt on}{it:*}{opt ()} option.
{phang}
{bind:{cmd:gaction} {cmd:{it:dialogname}.{it:controlname}.{it:memberfunction}} {cmd:[}{it:arguments}{cmd:]}}{break}
Execute the specified {it:memberfunction} on the specified control, where
{it:memberfunction} may be
{pmore}
{bind:{{cmd:hide}|{cmd:show}|{cmd:disable}|{cmd:enable}|{cmd:setposition}|{it:something_else} {cmd:[}{it:arguments}{cmd:]}}}
{pmore}
All controls provide the {it:memberfunctions} {opt hide}, {opt show},
{opt disable}, {opt enable}, and {opt setposition}, and some controls make
other, special {it:memberfunctions} available.
{pmore}
{opt hide} specifies that the control disappear from view (if it has not
already done so). {opt show} specifies that it reappear (if it is not already
visible).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -