📄 pos_textbox.class
字号:
// pos_textbox
//
// Textbox that tracks its own position (in whatever scales are set when it
// is drawn).
//
// Ignores boxmargin.
*! version 1.0.2 02sep2003
class {
.xpos = .gsize.new , style(0)
.ypos = .gsize.new , style(0)
} , inherit(sized_textbox)
// ---------------------------------------------------------------------------
program set
syntax [ , XPOS(string) YPOS(string) datesok(string) * ]
.Super.set , `options'
if `"`datesok'"' != "" {
_date2elapsed, format(`datesok') datelist(`xpos')
if ("`s(fmt)'" != "") local xpos `s(args)'
}
foreach d in x y {
if `"``d'pos'"' != `""' {
capture numlist "``d'pos'" , min(1) max(1)
if _rc {
di as error `"``d'pos' is not a number"'
exit 198
}
.`d'pos.setstyle , style(``d'pos')
}
}
end
program setpos
syntax [ , XPOS(string) YPOS(string) ]
foreach d in x y {
if `"``d'pos'"' != `""' {
capture numlist "``d'pos'" , min(1) max(1)
if _rc {
di as error `"``d'pos' is not a number"'
exit 198
}
.`d'pos.setstyle , style(``d'pos')
}
}
end
// ---------------------------------------------------------------------------
program xsize
if `.as_textbox.istrue' {
class exit .Super.xsize
}
if 0`.text.arrnels' == 0 {
class exit 0
}
if index("`.orientation.setting'", "horizontal") {
if `.specified_textwidth' < . {
local sz = `.specified_textwidth'
}
else {
local sz = `.textwidth'
}
}
else {
if `.specified_textheight' < . {
local sz = `.specified_textheight'
}
else {
local sz = `.textheight'
}
}
class exit `sz'
end
program ysize
if `.as_textbox.istrue' {
class exit .Super.ysize
}
if 0`.text.arrnels' == 0 {
class exit 0
}
if index("`.orientation.setting'", "vertical") {
if `.specified_textwidth' < . {
local sz = `.specified_textwidth'
}
else {
local sz = `.textwidth'
}
}
else {
if `.specified_textheight' < . {
local sz = `.specified_textheight'
}
else {
local sz = `.textheight'
}
}
class exit = `sz'
end
// ---------------------------------------------------------------------------
program draw
if ! `.draw_view.istrue' {
exit /* Exit */
}
if 0`.text.arrnels' == 0 {
exit /* Exit */
}
.style.setgdifull , angle(`.orientation.val') // style and orient
local xsz = `.extent x' // full size w/ margin
local ysz = `.extent y'
gdi moveto `.xpos.val' `.ypos.val' // x-y position
gdi gm_rmoveto `.xoffset' `.yoffset'
local x = `.xpos.val' + `.xoffset'
local y = `.ypos.val' + `.yoffset'
if `.style.box_alignment.iswest' { // box alignment
gdi gm_rmoveto -`xsz' 0
}
else {
if ! `.style.box_alignment.iseast' {
gdi gm_rmoveto `=-`xsz'/2' 0
}
}
if `.style.box_alignment.issouth' {
gdi gm_rmoveto 0 -`ysz'
}
else {
if ! `.style.box_alignment.isnorth' {
gdi gm_rmoveto 0 `=-`ysz'/2'
}
}
// draw bounding box
if `.style.drawbox.istrue' {
._draw_box `xsz' `ysz'
}
// handle margin
gdi gm_rmoveto 0`.style.margin.gmleft' 0`.style.margin.gmbottom'
.xsize_ren = .xsize
.ysize_ren = .ysize
// shift for orientation
._get_x_y_delta xshift yshift xdelta ydelta : 0 0
gdi gm_rmoveto `xshift' `yshift'
forvalues i = 1/0`.text.arrnels' {
gdi ctext `.text[`i']'
gdi gm_rmoveto `xdelta' `ydelta'
}
end
// ---------------------------------------------------------------------------
program _draw_box
args xsz ysz
if 0`.style.linestyle.patterned_line' {
tempname linesty
.`linesty' = .linestyle.new, style(background)
.`linesty'.setgdifull
_draw_rect `xsz' `ysz'
.style.linestyle.setgdifull
_draw_rect `xsz' `ysz'
}
else {
_draw_rect `xsz' `ysz'
}
end
program _draw_rect
args xsz ysz
gdi polybegin
gdi gm_rmoveto 0 0
gdi gm_rlineto `xsz' 0
gdi gm_rlineto 0 `ysz'
gdi gm_rlineto -`xsz' 0
gdi gm_rlineto 0 -`ysz'
gdi polyend
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -