📄 anyview_g.class
字号:
// anyview_g
//
// Parent class for view.class and subview.class. Contains programs shared
// by both classes.
*! version 1.0.2 22jul2004
version 8
class {
xstretch = .stretchability.new /* fixed by default */
ystretch = .stretchability.new /* fixed by default */
} , inherit(object)
/* -------------------------------------------------------------------------*/
program define new
if `"`0'"' != `""' {
.set `0'
}
end
program define set
syntax [, XSTretchability(string) YSTretchability(string) /*
*/ Style(passthru) STYLEREF(passthru) ]
if "`xstretchability'" != "" {
.xstretch.set `"`xstretchability'"'
}
if "`ystretchability'" != "" {
.ystretch.set `"`ystretchability'"'
}
if `"`style'`styleref'"' != `""' {
.setstyle , `style' `styleref'
}
end
// ---------------------------------------------------------------------------
//
// Usage: .setstyle [ , style(stylename) styleref(name|key) ]
//
// if reference is specified the style is assigned by reference rather
// than by copying (by value)
//
// Note, assumes that the child class names the style ".style"
program define setstyle
syntax [, Style(passthru) STYLEREF(string) ]
if "`.Local.style.isa'" == "" {
exit // no .style in the view
}
if "`styleref'" != "" { // style assigned by ref
.style.ref = .`styleref'.ref
exit
}
if "`style'" != "" { // style by named style
.style.setstyle, `style'
}
end
// ---------------------------------------------------------------------------
//
// Draw a view after first adjusting the location of the view within the
// specified size to the compass location in an instance of compass2dir
// specified in align().
//
// Also allows a program other than .draw to perform the drawing after
// adjustment, this is specified in drawpgm(). NOTE, this option is almost
// always specified; rarely would .draw be OK.
//
// The effect of any number of margins can also be accounted for by
// specifying instances of .margin.class in margin().
program compass_draw
syntax [ , Align(string) XSize(real -1) YSize(real -1) ///
Drawpgm(string) Margins(string) * ]
if `"`drawpgm'"' == `""' {
local drawpgm "draw"
}
if "`.`align'.classname'" != "compass2dir" {
di in smcl "{txt}{p 0 8}note, `align' is not an instance of compass2dir, alignment not possible{p_end}"
.`drawpgm' , xsize(`xsize') ysize(`ysize') `options'
exit // Exit
}
local actual_xsz = ///
cond("`.xstretch.setting'" == "fixed", 0`.xsize', `xsize')
local actual_ysz = ///
cond("`.ystretch.setting'" == "fixed", 0`.ysize', `ysize')
foreach margin of local margins {
if "`.xstretch.setting'" == "fixed" {
local actual_xsz = `actual_xsz' + ///
0`.`margin'.gmleft' + 0`.`margin'.gmright'
}
if "`.ystretch.setting'" == "fixed" {
local actual_ysz = `actual_ysz' + ///
0`.`margin'.gmtop' + 0`.`margin'.gmbottom'
}
}
foreach dim in x y {
local fulltest = cond("`dim'"=="x", "iseast", "isnorth")
local halftest = cond("`dim'"=="x", "iswest", "issouth")
if `actual_`dim'sz' < ``dim'size' {
if `.`align'.`fulltest'' {
local `dim'shift = ``dim'size'- `actual_`dim'sz'
}
else {
if ! `.`align'.`halftest'' {
local `dim'shift = (``dim'size'- `actual_`dim'sz') / 2
}
}
if 0``dim'shift' { // we are not a container
tempname `dim'transform // so get a temp transform
.``dim'transform' = .transform.new , dimension(`dim')
.``dim'transform'.get_from_gdi
.``dim'transform'.translate ``dim'shift'
}
local `dim'size `actual_`dim'sz'
}
}
.`drawpgm', xsize(`xsize') ysize(`ysize') `options'
foreach dim in x y {
if 0``dim'shift' {
if "`.``dim'transform'.isa'" != "" {
.``dim'transform'.reset
}
}
}
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -