VrS (Variant realities Script) — File Browser
VrSVariantrealitiesScriptv2.0 / VrSVariantrealitiesScriptv2.0 / VrS / System / Modules / vGui / VGUI.MRC
VGUI.MRC — 29.05 KB — Download this file
;#[vHD@3.0 C!vGui@2.1.0;2001.7.18;Variant<variant@variantrealities.com>]
;#[SD ]
;#[Incl C!vGuiObjects@2.1.0;C!vGuiObjects2@2.1.0;C!vGuiGrfx@2.1.0]
;#[VrS' custom GUI engine]
;#[ ]
;#[ ]
; Syntax: /vGui.window [-bcdhlomqtkr] <Name> <x> <y> <w> <h> [Control buttons -xmq] [Title text]
; Don't use an @ in your Window name.
on *:signal:start.0: { if ($hget(vGui) == $null) { hmake vGui 50 } | vGui.Set vrsdefault }
alias vGui.SizeAdjust {
vReg U vGui SizeAdjustW $1
vReg U vGui SizeAdjustH $2
}
alias vGui.Window {
if ($hget(vGui) == $null) { hmake vGui 50 }
if ($isid) {
;Identifier mode
; Syntax: $vGui.Window(<X/Y/W/H>,[Win])
var %Counter = 1,%Y = 0, %W = $window(-3).dw, %X = $iif($hget(vSwitch,Mode) == Left && !$prop,$window(@vGui.vSwitch).w,0), %H = $calc($window(-3).dh - 1)
while (%Counter <= $numtok(%vGui.vGuiCORE.Toolbars,32)) {
if ($gettok(%vGui.vGuiCORE.Toolbars,%Counter,32) == $2) { break }
if ($gettok(%vGui.vGuiCORE.Toolbars,%Counter,32) == vSwitch) && ($istok(Left Right,$hget(vSwitch,Mode),32)) { }
else {
dec %h $window(@vGui. [ $+ [ $gettok(%vGui.vGuiCORE.Toolbars,%Counter,32) ] ] ).h
if ($gettok(%vGui.vGuiCORE.Toolbars,%Counter,32) == vSwitch) && ($hget(vSwitch,Mode) == Bottom) { }
elseif ($gettok(%vGui.vGuiCORE.Toolbars,%Counter,32) == vSwitch) && ($prop) { }
else { inc %Y $window(@vGui. [ $+ [ $gettok(%vGui.vGuiCORE.Toolbars,%Counter,32) ] ] ).h }
}
if ($gettok(%vGui.vGuiCORE.Toolbars,%Counter,32) == vSwitch) && ($istok(Left Right,$hget(vSwitch,Mode),32)) && (!$prop) {
dec %W $window(@vGui. [ $+ [ $gettok(%vGui.vGuiCORE.Toolbars,%Counter,32) ] ] ).w
}
inc %Counter
}
if ($1 == x) { return %X }
elseif ($1 == y) { return %Y }
elseif ($1 == w) { return $iif($vReg(U,vGui,SizeAdjustW) && !$prop,$calc(%W + $vReg(U,vGui,SizeAdjustW)),%W) }
elseif ($1 == h) { return $iif($vReg(U,vGui,SizeAdjustH) && !$prop,$calc(%H + 1 + $vReg(U,vGui,SizeAdjustH)),$calc(%H + 1)) }
;return $iif($prop == bar,%W,$iif($hget(vSwitch,Mode) != Right,$calc(%W + 1),%W))
;return $iif($hget(vSwitch,Mode) != Bottom,$calc(%H + 1),%H)
}
else {
;Command mode
if ($left($1,1) == -) { var %Opt = $1 | tokenize 32 $2- }
else { var %Opt = - }
var %Sw1 = -pBk0, %Sw2 = +, %Win = @vGui. $+ $1
if ($window(%Win)) { var %Open = 1 }
var %Opt = $replace(%Opt,n,h)
if (c isin %Opt) { vGui.Close $1 | return }
%Sw2 = %Sw2 $+ d
if (d isin %Opt) { %Sw1 = %Sw1 $+ d | if (o isin %Opt) { %Sw1 = %Sw1 $+ o } }
if (m isin %Opt) && (n !isin %Sw1) { %Sw1 = %Sw1 $+ n }
if (l isin %Opt) {
var %UpdateToolbar = 1
if (i isin %Opt) && (!$istok(%vGui.vGuiCORE.Toolbars,$1,32)) { %vGui.vGuiCORE.Toolbars = $instok(%vGui.vGuiCORE.Toolbars,$1,1,32) }
else { %vGui.vGuiCORE.Toolbars = $addtok(%vGui.vGuiCORE.Toolbars,$1,32) }
vGui.SortToolbars
}
set %vGui. [ $+ [ $1 ] $+ ] .Options %Opt
set %vGui.vGuiCORE.Win $1
if ($window(%Win) == $null) {
if (d isin %Opt) { %Sw1 = %Sw1 $+ hn }
else { %Sw1 = %Sw1 $+ h }
%Sw2 = %Sw2 $+ L
!window %Sw1 %Sw2 %Win $2 $3 $4 $5
}
else { !window %Win $2 $3 $4 $5 }
if (%vGui.vGuiCORE.mIRCWinSize == $null) { set %vGui.vGuiCORE.mIRCWinSize $window(-2).w $window(-2).h $vMenuWindow(y) $vTBWindow(y) }
.timervGui -m 0 $iif($vReg(U,vGui,Timer),$ifmatch,100) vGui.InactiveEvents
if (!%Open) { vGui.Event $1 WINDOW Init }
if (b !isin %Opt) {
vGui.DrawBorder $1
if (t isin %Opt) { vGui.Obj.!Titlebar.Draw $1 Normal $6- }
if (u isin %Opt) { vGui.Obj.!Menu.Draw $1 Normal }
}
vGui.Event $1 WINDOW DrawObjects
vGui.Update $1
if (h !isin %Opt) { !window -a %Win | if (t isin %Opt) { vGui.Obj.!Titlebar.Draw $1 Normal $6- } | vGui.Update $1 }
if (q !isin %Opt) && ($script(vswitch.mrc)) { vS.AddWindow %Win }
if (%UpdateToolbar) { vGui.ToolbarUpdate $1 }
if (!$istok(vPopup,$gettok($1,1,46),32)) { vGui.ActiveEvent }
unset %vGui.vGuiCORE.Win
}
}
alias vGui.SortToolbars {
var %Bars = %vGui.vGuiCORE.Toolbars,%NewBars,%Counter = 1
if ($istok(%Bars,vMenu,32)) { %NewBars = $addtok(%NewBars,vMenu,32) | %Bars = $remtok(%Bars,vMenu,1,32) }
;if ($istok(%Bars,vTB,32)) { %NewBars = $addtok(%NewBars,vTB,32) | %Bars = $remtok(%Bars,vTB,1,32) }
if ($istok(%Bars,vSwitch,32)) { var %vSwitch = 1 | %Bars = $remtok(%Bars,vSwitch,1,32) }
while (%Counter <= $numtok(%Bars,32)) {
%NewBars = $addtok(%NewBars,$gettok(%Bars,%Counter,32),32)
inc %Counter
}
if (%vSwitch == 1) { %NewBars = $addtok(%NewBars,vSwitch,32) }
%vGui.vGuiCORE.Toolbars = %NewBars
}
alias vGui.SetTimer {
vReg U vGui Timer $1
.timervGui -m 0 $iif($vReg(U,vGui,Timer),$ifmatch,100) vGui.InactiveEvents
}
alias vGui.Process {
if ($vGui.InputLock == Keyboard) {
if ($active != %vGui.vGuiCORE.Active) && ($active != @vGui.Dropdown) { vGui.ActiveEvent | vGui.InActiveEvents | if ($script(vswitch.mrc)) { vSwitchActive } }
}
if ($vGui.InputLock == Keyboard) { return }
;Tokenize $1-Event $2-Parent $3-FullWin $4-Dynamic $5-MouseX $6-MouseY
tokenize 32 $1 $gettok($2,2,46) $gettok($2,2-,46) $iif($gettok($2,3-,46),$ifmatch,NoDynamic) $3 $4
set %vGui.vGuiCORE.Win $3
var %Win = @vGui. $+ $3
;%vGui.vGuiCORE.CurrentObj =
;Window MouseState ObjectType ObjectName X Y W H
;----------------------------------------------------------------------------------------------------------------------Mouse
if ($1 == Mouse) {
if (%vGui.vGuiCORE.CurrentObj) {
if ($inrect($5,$6, [ $replace($gettok(%vGui.vGuiCORE.CurrentObj,5-8,32),$chr(32),$chr(44)) ] )) && ($3 == $gettok(%vGui.vGuiCORE.CurrentObj,1,32)) {
;Mouse is in the object, send MouseMove.
vGui.ObjEvent $gettok(%vGui.vGuiCORE.CurrentObj,1,32) $gettok(%vGui.vGuiCORE.CurrentObj,3,32) MouseMove $gettok(%vGui.vGuiCORE.CurrentObj,4-,32)
if ($gettok(%vGui.vGuiCORE.CurrentObj,2,32) == MouseOutDown) {
set %vGui.vGuiCORE.CurrentObj $gettok(%vGui.vGuiCORE.CurrentObj,1,32) MouseDown $gettok(%vGui.vGuiCORE.CurrentObj,3-,32)
vGui.ObjEvent $3 $gettok(%vGui.vGuiCORE.CurrentObj,3,32) MouseDown $gettok(%vGui.vGuiCORE.CurrentObj,4-,32)
var %Update = $3
}
}
else {
;Mouse isn't in object, check if its MouseOutDown, if so, don't do anything.
if ($gettok(%vGui.vGuiCORE.CurrentObj,2,32) == MouseDown) {
set %vGui.vGuiCORE.CurrentObj $gettok(%vGui.vGuiCORE.CurrentObj,1,32) MouseOutDown $gettok(%vGui.vGuiCORE.CurrentObj,3-,32)
vGui.ObjEvent $gettok(%vGui.vGuiCORE.CurrentObj,1,32) $gettok(%vGui.vGuiCORE.CurrentObj,3,32) MouseOutDown $gettok(%vGui.vGuiCORE.CurrentObj,4-,32)
var %Update = $gettok(%vGui.vGuiCORE.CurrentObj,1,32)
}
elseif ($gettok(%vGui.vGuiCORE.CurrentObj,2,32) != MouseOutDown) {
vGui.CloseTooltip
vGui.ObjEvent $gettok(%vGui.vGuiCORE.CurrentObj,1,32) $gettok(%vGui.vGuiCORE.CurrentObj,3,32) MouseOut $gettok(%vGui.vGuiCORE.CurrentObj,4-,32)
var %UpdateOld = $gettok(%vGui.vGuiCORE.CurrentObj,1,32)
if (%vGui.vGuiCORE.ParentObject. [ $+ [ $gettok(%vGui.vGuiCORE.LastObject,4,32) ] ] == $null) {
unset %vGui.vGuiCORE.ParentObject*
}
unset %vGui.vGuiCORE.CurrentObj
goto checkmouse
}
}
}
else {
:checkmouse
;Check if the mouse is in an object
;if not, don't do anything at all.
if (r isin %vGui. [ $+ [ $3 ] $+ ] .Options) && ($inrect($5,$6,$calc($window(%Win).w - 30),$calc($window(%Win).h - 30),30,30)) { var %Obj = WinResize WINDOW_Resize $calc($window(%Win).w - 30) $calc($window(%Win).h - 30) 30 30 }
elseif (t isin %vGui. [ $+ [ $3 ] $+ ] .Options) && ($6 >= 0) && ($6 <= 20) { var %Obj = !Titlebar WINDOW_Titlebar 0 0 $window(@vGui. [ $+ [ $3 ] ] ).w 20 }
elseif (u isin %vGui. [ $+ [ $3 ] $+ ] .Options) && ($6 >= 20) && ($6 <= 40) { var %Obj = !Menu WINDOW_Menu 0 20 $window(@vGui. [ $+ [ $3 ] ] ).w 20 }
elseif ($vGui. [ $+ [ $2 ] $+ ] .CheckObjects($5,$6,$iif($4 != NoDynamic,$ifmatch))) { var %Obj = $ifmatch }
if (%Obj) {
set %vGui.vGuiCORE.CurrentObj $3 MouseOver %Obj
if ($left($gettok(%vGui.vGuiCORE.CurrentObj,3,32),1) == !) {
set %vGui.vGuiCORE.ParentObjectRoot %vGui.vGuiCORE.CurrentObj
while ($vGui.Obj. [ $+ [ $gettok(%vGui.vGuiCORE.CurrentObj,3,32) ] $+ ] (CheckObjects,$3,$5,$6,$gettok(%vGui.vGuiCORE.CurrentObj,5-8,32),$gettok(%vGui.vGuiCORE.CurrentObj,4,32),$gettok(%vGui.vGuiCORE.CurrentObj,9-,32))) {
if ($ifmatch != NoObject) {
var %vGui.vGuiCORE.InternalObject = $ifmatch
if (%vGui.vGuiCORE.InternalObject) {
set %vGui.vGuiCORE.ParentObject. [ $+ [ $gettok(%vGui.vGuiCORE.InternalObject,2,32) ] ] %vGui.vGuiCORE.CurrentObj
set %vGui.vGuiCORE.CurrentObj $3 MouseOver %vGui.vGuiCORE.InternalObject
}
}
else { unset %vGui.vGuiCORE.CurrentObj | goto end }
}
}
set %vGui.TooltipText $gettok(%vGui. [ $+ [ $3 ] $+ . $+ [ $gettok(%vGui.vGuiCORE.CurrentObj,4,32) ] $+ ] .tooltip,2-,32)
if (%vGui.TooltipText) { .timervGui-Tooltip -m 1 $gettok(%vGui. [ $+ [ $3 ] $+ . $+ [ $gettok(%vGui.vGuiCORE.CurrentObj,4,32) ] $+ ] .tooltip,1,32) vGui.object.tooltip }
else { unset %vGui.TooltipText }
vGui.ObjEvent $3 $gettok(%vGui.vGuiCORE.CurrentObj,3,32) MouseOver $gettok(%vGui.vGuiCORE.CurrentObj,4-,32)
var %Update = $3
:end
}
}
if (%Update) { vGui.Update %Update }
if (%UpdateOld) && (%UpdateOld != %Update) { vGui.Update %UpdateOld }
}
;----------------------------------------------------------------------------------------------------------------------SClick
elseif ($1 == SClick) {
if (%vGui.vGuiCORE.CurrentObj) {
if ($active != %vGui.vGuiCORE.Active) && (!%vGui.Dropdown.Parent) { vGui.ActiveEvent | vGui.InActiveEvents | if ($script(vswitch.mrc)) { vSwitchActive } }
;MouseDown
vGui.CloseTooltip
set %vGui.vGuiCORE.CurrentObj $3 MouseDown $gettok(%vGui.vGuiCORE.CurrentObj,3-,32)
vGui.InputLock Mouse
if (k isin %vGui. [ $+ [ $3 ] $+ ] .Options) {
if ($gettok(%vGui.vGuiCORE.CurrentObj,3-,32) != $gettok(%vGui.vGuiCORE.ParentObjectRoot,3-,32)) && (%vGui.vGuiCORE.ParentObjectRoot) { var %Obj = $gettok(%vGui.vGuiCORE.ParentObjectRoot,4,32) }
else { var %Obj = $gettok(%vGui.vGuiCORE.CurrentObj,4,32) }
.vGui.Focus $3 %Obj
}
vGui.ObjEvent $3 $gettok(%vGui.vGuiCORE.CurrentObj,3,32) MouseDown $gettok(%vGui.vGuiCORE.CurrentObj,4-,32)
vGui.Update $3
}
}
;----------------------------------------------------------------------------------------------------------------------UClick
elseif ($1 == UClick) {
if (%vGui.vGuiCORE.CurrentObj) {
;MouseClicked
if ($inrect($5,$6, [ $replace($gettok(%vGui.vGuiCORE.CurrentObj,5-8,32),$chr(32),$chr(44)) ] )) && ($gettok(%vGui.vGuiCORE.CurrentObj,1,32) == $3) {
if ($active != @vGui.Editbox) { vGui.InputUnlock }
vGui.ObjEvent $3 $gettok(%vGui.vGuiCORE.CurrentObj,3,32) MouseClicked $gettok(%vGui.vGuiCORE.CurrentObj,4-,32)
unset %vGui.vGuiCORE.CurrentObj %vGui.vGuiCORE.ParentObject*
}
else {
vGui.ObjEvent $gettok(%vGui.vGuiCORE.CurrentObj,1,32) $gettok(%vGui.vGuiCORE.CurrentObj,3,32) $iif($istok(WinResize WinMove,$gettok(%vGui.vGuiCORE.CurrentObj,3,32),32),MouseClicked,MouseOut) $gettok(%vGui.vGuiCORE.CurrentObj,4-,32)
vGui.Update $gettok(%vGui.vGuiCORE.CurrentObj,1,32)
unset %vGui.vGuiCORE.CurrentObj %vGui.vGuiCORE.ParentObject*
}
}
}
;----------------------------------------------------------------------------------------------------------------------RClick
elseif ($1 == RClick) {
vGui.CloseTooltip
vGui.Event $3 RClick MouseClicked
vGui.Update $3
}
unset %vGui.vGuiCORE.Win
}
alias vGui.InactiveEvents {
;Mouse routines
if ($gettok($mouse.win,1,46) == @vGui) && ($mouse.win != $active) {
if ($istok(MouseDown MouseOutDown,$gettok(%vGui.vGuiCORE.CurrentObj,2,32),32)) {
var %Win = @vGui. [ $+ [ $gettok(%vGui.vGuiCORE.CurrentObj,1,32) ] ]
if ($active != @vGui.Editbox) { vGui.InputUnlock }
if ($mouse.key != 1) { vGui.Process Mouse %Win -1 -1 | vGui.Process UClick %Win -1 -1 }
}
if ($mouse.x != %vGui.vGuiCORE.MouseX) || ($mouse.y != %vGui.vGuiCORE.MouseY) {
vGui.Process Mouse $mouse.win $mouse.x $mouse.y
set %vGui.vGuiCORE.MouseX $mouse.x
set %vGui.vGuiCORE.MouseY $mouse.y
}
}
elseif ($mouse.win != @vGui. [ $+ [ $gettok(%vGui.vGuiCORE.CurrentObj,1,32) ] ] ) && ($active != @vGui. [ $+ [ $gettok(%vGui.vGuiCORE.CurrentObj,1,32) ] ] ) {
if (%vGui.vGuiCORE.CurrentObj) && ($window( @vGui. [ $+ [ $gettok(%vGui.vGuiCORE.CurrentObj,1,32) ] ] )) {
;Window is not active, and the mouse is not in it.
var %Win = @vGui. [ $+ [ $gettok(%vGui.vGuiCORE.CurrentObj,1,32) ] ]
if ($active != @vGui.Editbox) { vGui.InputUnlock }
vGui.Process Mouse %Win -1 -1
if ($istok(MouseDown MouseOutDown,$gettok(%vGui.vGuiCORE.CurrentObj,2,32),32)) { vGui.Process UClick %Win -1 -1 }
}
}
elseif ($active == @vGui. [ $+ [ $gettok(%vGui.vGuiCORE.CurrentObj,1,32) ] ] ) && ($mouse.win != @vGui. [ $+ [ $gettok(%vGui.vGuiCORE.CurrentObj,1,32) ] ] ) {
;Window is active, but the mouse is not in it.
var %Win = @vGui. [ $+ [ $gettok(%vGui.vGuiCORE.CurrentObj,1,32) ] ]
if ($vGui.InputLock == Mouse) { vGui.InputUnlock }
vGui.Process Mouse %Win -1 -1
if ($istok(MouseDown MouseOutDown,$gettok(%vGui.vGuiCORE.CurrentObj,2,32),32)) && ($mouse.key != 1) {
vGui.Process UClick %Win -1 -1
}
}
if ($window(-3).dw $window(-3).dh != $gettok(%vGui.vGuiCORE.mIRCWinSize,1-2,32)) {
;vGui.EventAll WINDOW_mIRC Resized
set %vGui.vGuiCORE.mIRCWinSize $window(-3).dw $window(-3).dh
;VrS.CheckActiveSize
wm_size
;
;.timervGuiToolbarRedraw -m 1 500 vGui.ToolbarRedraw
}
vGui.EventAll vGuiTimer Triggered
unset %vGui.vGuiCORE.Win
}
alias wm_size {
vGui.ToolbarUpdate
}
;on *:start: { dll $dlldir(rh.dll) Load _ }
;on *:exit: { dll -u $dlldir(rh.dll) }
alias vGui.ToolbarUpdate {
var %Counter = 1, %Total = $numtok(%vGui.vGuiCORE.Toolbars,32)
while (%Counter <= %Total) {
set %vGui.vGuiCORE.Win $gettok(%vGui.vGuiCORE.Toolbars,%Counter,32)
if ($window($+(@vGui.,%vGui.vGuiCORE.Win))) && (%vGui.vGuiCORE.Win != $1) {
vGui.Event $gettok(%vGui.vGuiCORE.Toolbars,%Counter,32) WINDOW ToolbarMove
}
inc %Counter
}
if ($hvar(vSMaximized)) && (@vMI* iswm $hget(vSwitch,Active)) {
!window $hget(vSwitch,Active) $vGui.Window(X) $vGui.Window(Y) $vGui.Window(W) $vGui.Window(H)
}
.timervGuiToolbarRedraw -m 1 100 vGui.ToolbarRedraw
;vGui.ToolbarRedraw
}
alias vGui.ToolbarRedraw {
var %Counter = 1, %Total = $numtok(%vGui.vGuiCORE.Toolbars,32)
while (%Counter <= %Total) {
set %vGui.vGuiCORE.Win $gettok(%vGui.vGuiCORE.Toolbars,%Counter,32)
if ($window(@vGui. [ $+ [ $gettok(%vGui.vGuiCORE.Toolbars,%Counter,32) ] ] )) && ($gettok(%vGui.vGuiCORE.Toolbars,%Counter,32) != $1) { vGui.Event $gettok(%vGui.vGuiCORE.Toolbars,%Counter,32) WINDOW ToolbarRedraw | vGui.Update $gettok(%vGui.vGuiCORE.Toolbars,%Counter,32) }
inc %Counter
}
}
alias vGui.ActiveEvent {
if ($window(%vGui.vGuiCORE.Active) != $active) && ($window(%vGui.vGuiCORE.Active)) && ($istok(@vGui.Editbox @vGui.Dropdown,$active,32) == $false) && (@vGui.vPopup.vPopupMenu* !iswm $active) {
if (t isin %vGui. [ $+ [ $gettok(%vGui.vGuiCORE.Active,2-,46) ] $+ ] .Options) { vGui.Titlebar.Draw -i $gettok(%vGui.vGuiCORE.Active,2-,46) | vGui.Update $gettok(%vGui.vGuiCORE.Active,2-,46) }
vGui.Event $gettok(%vGui.vGuiCORE.Active,2-,46) WINDOW InActive
unset %vGui.vGuiCORE.Active
}
if ($gettok($active,1,46) == @vGui) && ($istok(%vGui.vGuiCORE.Active @vGui.vSwitch @vGui.vTB @vGui.vMenu,$active,32) == $false) {
vGui.Event $gettok($active,2-,46) WINDOW Active
if ($istok(@vGui.Editbox @vGui.Dropdown,%vGui.vGuiCORE.Active,32) == $false) {
if (t isin %vGui. [ $+ [ $gettok($active,2-,46) ] $+ ] .Options) { vGui.Titlebar.Draw $gettok($active,2-,46) | vGui.Update $gettok($active,2-,46) }
}
set %vGui.vGuiCORE.Active $active
}
if ($window(@vConsole).h != 0) && ($window($active) != @vConsole) {
vConsole.DropUp
if ($window($hget(vSwitch,Active)).state != hidden) && ($window($hget(vSwitch,Active))) { !window -a $hget(vSwitch,Active) }
}
}
on *:active:@*: {
vGui.ActiveEvent
}
on *:appactive: {
if ($appactive == $false) {
if ($istok(MouseDown MouseOutDown,$gettok(%vGui.vGuiCORE.CurrentObj,1,32),32)) && ($window( @vGui. [ $+ [ $gettok(%vGui.vGuiCORE.CurrentObj,2,32) ] ] )) {
var %Win = @vGui. [ $+ [ $gettok(%vGui.vGuiCORE.CurrentObj,2,32) ] ]
vGui.InputUnlock
vGui.Process Mouse %Win -1 -1
vGui.Process UClick %Win -1 -1
if ($gettok($mouse.win,1,46) == @vGui) { vGui.Process Mouse $mouse.win $mouse.x $mouse.y }
}
if ($window(%vGui.vGuiCORE.Active)) {
vGui.Event $gettok(%vGui.vGuiCORE.Active,2-,46) WINDOW InActive
if (t isin %vGui. [ $+ [ $gettok(%vGui.vGuiCORE.Active,2-,46) ] $+ ] .Options) { vGui.Titlebar.Draw -i $gettok(%vGui.vGuiCORE.Active,2-,46) | vGui.Update $gettok(%vGui.vGuiCORE.Active,2-,46) }
unset %vGui.vGuiCORE.Active
}
}
}
alias vGui.UClick { vGui.Process UClick $mouse.win $mouse.x $mouse.y | vGui.Process Mouse $mouse.win $mouse.x $mouse.y }
menu @vGui.* {
mouse: { vGui.Process Mouse $mouse.win $mouse.x $mouse.y }
sclick: { if ($mouse.win != %vGui.vGuiCORE.Active) { vGui.Process Mouse $mouse.win $mouse.x $mouse.y } | vGui.Process SClick $mouse.win $mouse.x $mouse.y }
dclick: { vGui.Process SClick $mouse.win $mouse.x $mouse.y }
uclick: { vGui.Process UClick $mouse.win $mouse.x $mouse.y | vGui.Process Mouse $mouse.win $mouse.x $mouse.y }
rclick: { vGui.Process RClick $mouse.win $mouse.x $mouse.y }
}
alias vGui.Close {
if ($hget(vGui) == $null) { hmake vGui 50 }
if ($left($1,1) == -) { var %Opt = $1 | tokenize 32 $2- }
var %Win = @vGui. $+ $1
if ($gettok(%vGui.vGuiCORE.CurrentObj,1,32) == $1) { unset %vGui.vGuiCORE.CurrentObj }
var %WinSize = $window(%Win).x $window(%Win).y $window(%Win).w $window(%Win).h
if ($window(%Win)) && (c !isin %Opt) {
!window -c %Win
if (q !isin %Opt) && (q !isin %vGui. [ $+ [ $1 ] $+ ] .Options) && ($script(vswitch.mrc)) { vS.RemWindow %Win | vGui.Update vSwitch }
}
set %vGui.vGuiCORE.Win $1
if ($show) { vGui.Event $1 WINDOW Close %WinSize }
if ($istok(%vGui.vGuiCORE.Toolbars,$1,32)) {
%vGui.vGuiCORE.Toolbars = $remtok(%vGui.vGuiCORE.Toolbars,$1,1,32)
vGui.ToolbarUpdate
}
unset %vGui. [ $+ [ $1 ] $+ ] .*
hfree -w $1 $+ .*
hdel -w vGui $1 $+ .*
unset %vGui.vGuiCORE.Win
}
on *:close:@vGui.*: { vGui.Close -c $gettok($target,2-,46) }
alias vGui.Update {
if ($window(@vGui. [ $+ [ $1 ] ] )) { drawdot @vGui. [ $+ [ $1 ] ] }
}
; Syntax: /vGui.Event <Win> <Object> <Event> [Extra params]
alias vGui.NestEvent { vGui. [ $+ [ $gettok($1,1,46) ] $+ ] .Process $2 $3 $iif($gettok($1,2-,46),$ifmatch) $4- }
alias vGui.Event {
if (%vGui.vGuiCORE.ParentObject. [ $+ [ $2 ] ] ) {
vGui.Obj. [ $+ [ $gettok(%vGui.vGuiCORE.ParentObject. [ $+ [ $2 ] ] ,3,32) ] ] ObjectProcess $gettok(%vGui.vGuiCORE.ParentObject. [ $+ [ $2 ] ] ,4,32) $1-
}
else { vGui. [ $+ [ $gettok($1,1,46) ] $+ ] .Process $2 $3 $iif($gettok($1,2-,46),$ifmatch) $4- }
}
; Syntax: /vGui.ObjEvent <Win> <Object> <Event> <Object Name> <X> <Y> <W> <H> [Extra params]
alias vGui.ObjEvent { vGui.Obj. [ $+ [ $2 ] ] Process $3 $1 $iif($gettok($1,2-,46),$ifmatch,NoDynamic) $4- }
alias vGui.EventAll {
var %Counter = 1, %Total = $window(@vGui.*,0)
while (%Counter <= %Total) {
if ($window(@vGui.*,%Counter)) { vGui.Event $gettok($ifmatch,2-,46) $1- }
inc %Counter
}
}
alias vGui.Win { return %vGui.vGuiCORE.Win }
;----------------------------------------------------------------------------------------------------------------------Keyboard support
on *:keydown:@vGui.*:9: {
vGui.KeyboardTab $target
}
alias vGui.KeyboardTab {
if ($vGui.InputLock) { return }
tokenize 32 Keydown $gettok($1,2,46) $gettok($1,2-,46) $iif($gettok($1,3-,46),$ifmatch,NoDynamic)
if (k !isin %vGui. [ $+ [ $3 ] $+ ] .Options) { return }
set %vGui.vGuiCORE.Win $3
var %Objects = $vGui. [ $+ [ $2 ] $+ ] .CheckObjects(ObjectOrder)
if (%Objects) {
if ( %vGui. [ $+ [ $3 ] $+ ] .Focus == $null) { var %ObjNum = 1 }
else {
var %ObjNum = $vGui.GetObjNum($3, %vGui. [ $+ [ $3 ] $+ ] .Focus )
%ObjNum = $calc(%ObjNum $iif($mouse.key & 4,-,+) 1)
if (%ObjNum > $numtok(%Objects,32)) { %ObjNum = 1 }
if (%ObjNum < 1) { %ObjNum = $numtok(%Objects,32) }
}
vGui.Focus -k $3 $vGui.GetObjName($3,%ObjNum)
}
unset %vGui.vGuiCORE.Win
}
on *:keydown:@vGui.*:32: {
if ($vGui.InputLock == Mouse) || ($keyrpt) { return }
tokenize 32 Keydown $gettok($target,2,46) $gettok($target,2-,46) $iif($gettok($target,3-,46),$ifmatch,NoDynamic)
if (k !isin %vGui. [ $+ [ $3 ] $+ ] .Options) { return }
set %vGui.vGuiCORE.Win $3
var %Objects = $vGui. [ $+ [ $2 ] $+ ] .CheckObjects(ObjectOrder)
if (%Objects) {
if ( %vGui. [ $+ [ $3 ] $+ ] .Focus ) {
vGui.InputLock Keyboard
set %vGui.vGuiCORE.LastObject %vGui.vGuiCORE.CurrentObj
if ($gettok(%vGui.vGuiCORE.LastObject,2,32) == MouseOver) {
vGui.ObjEvent $gettok(%vGui.vGuiCORE.LastObject,1,32) $gettok(%vGui.vGuiCORE.LastObject,3,32) MouseOut $gettok(%vGui.vGuiCORE.LastObject,5-,32)
unset %vGui.vGuiCORE.CurrentObj
}
set %vGui.vGuiCORE.CurrentObj $3 MouseDown $vGui.GetObjInfo($2, %vGui. [ $+ [ $3 ] $+ ] .Focus )
vGui.ObjEvent $3 $gettok(%vGui.vGuiCORE.CurrentObj,3,32) MouseDown $gettok(%vGui.vGuiCORE.CurrentObj,4-,32)
vGui.Update $3
}
}
unset %vGui.vGuiCORE.Win
}
on *:keydown:@vGui.*:37,38,39,40: {
if ($vGui.InputLock == Mouse) { return }
tokenize 32 Keydown $gettok($target,2,46) $gettok($target,2-,46) $iif($gettok($target,3-,46),$ifmatch,NoDynamic)
if (k !isin %vGui. [ $+ [ $3 ] $+ ] .Options) { return }
set %vGui.vGuiCORE.Win $3
var %Objects = $vGui. [ $+ [ $2 ] $+ ] .CheckObjects(ObjectOrder)
if (%Objects) {
if ( %vGui. [ $+ [ $3 ] $+ ] .Focus ) {
if ($keyval == 37) { var %Event = ArrowLeft }
elseif ($keyval == 38) { var %Event = ArrowUp }
elseif ($keyval == 39) { var %Event = ArrowRight }
elseif ($keyval == 40) { var %Event = ArrowDown }
;set %vGui.vGuiCORE.CurrentObj $3 $3
var %Obj = $vGui.GetObjInfo($2, %vGui. [ $+ [ $3 ] $+ ] .Focus )
vGui.ObjEvent $3 $gettok(%Obj,1,32) %Event $gettok(%Obj,2-,32)
vGui.Update $3
}
}
unset %vGui.vGuiCORE.Object %vGui.vGuiCORE.Win
}
on *:keyup:@vGui.*:32: {
if ($vGui.InputLock == Mouse) { return }
tokenize 32 Keyup $gettok($target,2,46) $gettok($target,2-,46) $iif($gettok($target,3-,46),$ifmatch,NoDynamic)
if (k !isin %vGui. [ $+ [ $3 ] $+ ] .Options) { return }
set %vGui.vGuiCORE.Win $3
var %Objects = $vGui. [ $+ [ $2 ] $+ ] .CheckObjects(ObjectOrder)
if (%Objects) {
if ( %vGui. [ $+ [ $3 ] $+ ] .Focus ) {
vGui.InputUnlock
set %vGui.vGuiCORE.FocusState MouseClicked
var %Obj = $vGui.GetObjInfo($2, %vGui. [ $+ [ $3 ] $+ ] .Focus )
vGui.ObjEvent $3 $gettok(%Obj,1,32) MouseClicked $gettok(%Obj,2-,32)
unset %vGui.vGuiCORE.CurrentObj
vGui.Process Mouse $mouse.win $mouse.x $mouse.y
vGui.Update $3
}
}
unset %vGui.vGuiCORE.Win %vGui.vGuiCORE.FocusState
}
; Syntax: /vGui.Focus <Win> [Object Name]
alias vGui.Focus {
if ($left($1,1) == -) { var %Opt = $1 | tokenize 32 $2- }
if ($2) && ( %vGui. [ $+ [ $1 ] $+ ] .Focus == $2) { return }
if (k !isin %vGui. [ $+ [ $1 ] $+ ] .Options) { return }
var %Objects = $vGui. [ $+ [ $gettok($1,1,46) ] $+ ] .CheckObjects(ObjectOrder)
if (%Objects) {
if ( %vGui. [ $+ [ $1 ] $+ ] .Focus ) {
var %Info = $vGui.GetObjInfo($1, %vGui. [ $+ [ $1 ] $+ ] .Focus )
unset %vGui. [ $+ [ $1 ] $+ ] .Focus
if ($gettok(%vGui.vGuiCORE.CurrentObj,1,32) == $1) && ($gettok(%vGui.vGuiCORE.CurrentObj,4,32) == $gettok(%Info,2,32)) { set %vGui.vGuiCORE.FocusState $gettok(%vGui.vGuiCORE.CurrentObj,2,32) }
else { set %vGui.vGuiCORE.FocusState MouseOut }
vGui.ObjEvent $1 $gettok(%Info,1,32) LostFocus $gettok(%Info,2,32) $gettok(%Info,3-,32)
}
if ($istok(%Objects,$2,32)) {
set %vGui. [ $+ [ $1 ] $+ ] .Focus $2
var %Info = $vGui.GetObjInfo($1,$2)
if ($gettok(%vGui.vGuiCORE.CurrentObj,1,32) == $1) && ($gettok(%vGui.vGuiCORE.CurrentObj,4,32) == $gettok(%Info,2,32)) { set %vGui.vGuiCORE.FocusState $gettok(%vGui.vGuiCORE.CurrentObj,2,32) }
else { set %vGui.vGuiCORE.FocusState MouseOut }
if (k isin %Opt) { set %vGui.vGuiCORE.KeyboardTab 1 }
vGui.ObjEvent $1 $gettok(%Info,1,32) GotFocus $gettok(%Info,2,32) $gettok(%Info,3-,32)
}
vGui.Update $1
unset %vGui.vGuiCORE.FocusState %vGui.vGuiCORE.KeyboardTab
}
}
; Syntax: $vGui.GetObjInfo(<Win>,<Object Name or Num>).num
alias vGui.GetObjInfo { return $vGui. [ $+ [ $gettok($1,1,46) ] $+ ] .CheckObjects($iif($prop == num,$vGui.GetObjName($1,$2),$2)) }
; Syntax: $vGui.GetObjName(<Win>,<Object Number>)
alias vGui.GetObjName { return $iif($2,$gettok($vGui. [ $+ [ $gettok($1,1,46) ] $+ ] .CheckObjects(ObjectOrder),$2,32)) }
; Syntax: $vGui.GetObjNum(<Win>,<Object Name>)
alias vGui.GetObjNum { return $iif($2,$findtok($vGui. [ $+ [ $gettok($1,1,46) ] $+ ] .CheckObjects(ObjectOrder),$2,1,32)) }
;----------------------------------------------------------------------------------------------------------------------Misc theme stuff
alias vGui.InputLock {
if ($isid) { return %vGui.vGuiCORE.InputLock }
set %vGui.vGuiCORE.InputLock $1
}
alias vGui.InputUnlock { unset %vGui.vGuiCORE.InputLock }
alias vGui.Dir {
if ($prop) { return $vrsdir( Themes\ [ $+ [ $iif($hget(Theme,vGui),$ifmatch,vrsdefault) ] $+ \ $+ [ $1- ] ] ).n }
return $vrsdir( Themes\ [ $+ [ $iif($hget(Theme,vGui),$ifmatch,vrsdefault) ] $+ \ $+ [ $1- ] ] )
}
alias vGui.Setting {
return $hget(Theme, vGuiSetting. [ $+ [ $1 ] $+ . $+ [ $2 ] ] )
}
on *:signal:vTheme.Load: { vGui.Set $theme.setting(vGui) }
on *:signal:vTheme.Finish: { vGui.ToolbarUpdate | vGui.ToolbarRedraw }
alias vGui.Set {
if ($exists( $vrsdir( Themes\ [ $+ [ $1 ] $+ ] \vguiset.ini )) == $false) { var %Theme = vrsdefault }
else { var %Theme = $1 }
hunset -w Theme vGui*
if ($themefile) { theme.write vGui %Theme }
drawpic -c
var %Counter = 1, %Total = $ini($vGui.Dir(vguiset.ini).n,0)
while (%Counter <= %Total) {
var %Section = $ini($vGui.Dir(vguiset.ini).n,%Counter)
loadbufhash -ip $+(vGuiSetting.,%Section,.) Theme %Section $vGui.Dir(vguiset.ini).n
inc %Counter
}
;Call redraw for all vGui windows.
vGui.RedrawAll
}
alias vGui.RedrawAll {
var %Counter = 1, %Total = $window(@vGui.*,0)
while (%Counter <= %Total) {
if (!$istok(%vGui.vGuiCORE.Toolbars,$window(@vGui.*,%Counter),32)) {
var %Win = $window(@vGui.*,%Counter)
set %vGui.vGuiCORE.Win $gettok(%Win,2-,46)
if (b !isin %vGui. [ $+ [ $gettok(%Win,2-,46) ] $+ ] .Options ) {
vGui.DrawBorder $gettok(%Win,2-,46)
if (t isin %vGui. [ $+ [ $gettok(%Win,2-,46) ] $+ ] .Options) {
var %Title = %vGui. [ $+ [ $gettok(%Win,2-,46) ] $+ ] .Title
vGui.Obj.!Titlebar.Draw $gettok(%Win,2-,46) Normal %vGui. [ $+ [ $gettok(%Win,2-,46) ] $+ ] .TitleOptions %Title
}
if (u isin %vGui. [ $+ [ $gettok(%Win,2-,46) ] $+ ] .Options) { vGui.Obj.!Menu.Draw $gettok(%Win,2-,46) Normal }
}
vGui.Event $gettok(%Win,2-,46) WINDOW ThemeChange
vGui.Event $gettok(%Win,2-,46) WINDOW DrawObjects
vGui.Update $gettok(%Win,2-,46)
unset %vGui.vGuiCORE.Win
}
inc %Counter
}
}
alias vGui.vSProcess {
if ($1 == Sort) { return $sorttok($2-,32) }
elseif ($left($1,1) == @) {
set -u %vGui.vGuiCORE.Win $gettok($1,2-,46)
var %vSConfig = $vGui. [ $+ [ $gettok($1,2,46) ] $+ ] .checkobjects(vSConfig , [ $+ [ $1 ] $+ ] )
if (%vSConfig == $null) {
var %Group = vX-vGui
var %WinIcon = $vGui. [ $+ [ $gettok($1,2-,46) ] $+ ] .CheckObjects(WINDOW,Icon)
if (* iswm %WinIcon) { var %Icon = $gettok(%WinIcon,1-2,32) 14 14 $remove($gettok(%WinIcon,3-,32),$mircdir,$chr(34)) }
else { var %Icon = 186 0 14 14 $remove($vGui.Dir($vGui.Setting(Titlebar,Image)),$mircdir,$chr(34)) }
var %Caption = $gettok($1,2-,46)
var %Tooltip = $gettok($1,2-,46)
}
else {
var %Group = $gettok(%vSConfig,1,44)
var %Icon = $gettok(%vSConfig,2,44)
var %Caption = $gettok(%vSConfig,3,44)
var %Tooltip = $gettok(%vSConfig,4-,44)
}
return %Group %Caption $+ , $+ %Icon $+ , $+ %Tooltip
}
}