Reflex — File Browser
Reflexv0.1 / Reflexv0.1 / Reflex / system / scripts / switchbar.mrc
switchbar.mrc — 16.2 KB — Download this file
alias switchbar_init {
var %c = $cid , %w = $active
window -ipoB +dx @hide_switchbar 0 0 $window(-2).w $data(switch_height)
ktools DockWindow $window(@hide_switchbar).hwnd > $data(switch_pos) 3
switchbar_draw
scon %c
if (%w == Status Window) { window -ax "status window" }
elseif (%w == Channels List) { window -ax "Channels List" }
else { window -ax %w }
sz WatchWindow @hide_switchbar
}
alias switchbar_close {
window -c @hide_switchbar
window -x $iif($active = status window,"status window",$active)
}
alias switchbar_move {
if ($1 == top) && ($data(switch_pos) != top) { ktools MoveDockWindow $window(@hide_switchbar).hwnd > top 3 | data switch_pos top | dccarea_draw }
if ($1 == bottom) && ($data(switch_pos) != bottom) { ktools MoveDockWindow $window(@hide_switchbar).hwnd > bottom 3 | data switch_pos bottom | dccarea_draw }
}
alias switchbar_draw {
var %w = $iif($1,$1,@hide_switchbar)
if ($window(%w)) {
if (!$window(@hide_switch_data)) { window -hi @hide_switch_data }
clear @hide_switch_data
drawrect -frn %w $col(background) 1 0 0 $window(%w).w $data(switch_height)
var %c = 1 , %p = 2
while (%c <= $scon(0)) {
scon %c
if (%c = 1) && ($data(switch_showGripper)) {
%p = $switchbar_drawBox(%w,%p,Gripper)
}
elseif (%c != 1) && ($data(switch_showSeperator)) {
%p = $switchbar_drawBox(%w,%p,Seperator)
}
%p = $switchbar_drawBox(%w,%p,Status)
if (!$istok($temp(switch_hideserver),$scon(%c),32)) {
var %i = 1
while (%i <= $chan(0)) { %p = $switchbar_drawBox(%w,%p,Chan,%i) | inc %i }
var %i = 1
while (%i <= $query(0)) { %p = $switchbar_drawBox(%w,%p,Query,%i) | inc %i }
var %i = 1
while (%i <= $window(0)) {
if ($window(%i).cid == $scon(%c)) && (!$window(%i).anysc) && ($window(%i).state != hidden) && ($gettok($window(%i),1,95) != @popup) { %p = $switchbar_drawBox(%w,%p,Window,%i) }
inc %i
}
if ($window(channels List)) && ($window(channels list).cid == $scon(%c)) { %p = $switchbar_drawBox(%w,%p,Clist) }
}
inc %c
}
var %i = 1 , %f = 1
while (%i <= $window(0)) {
if ($window(%i).anysc) && ($window(%i).state != hidden) && ($gettok($window(%i),1,95) != @hide) {
if (%f) { %p = $switchbar_drawBox(%w,%p,Seperator) }
%f = 0
%p = $switchbar_drawBox(%w,%p,Window,%i)
}
inc %i
}
drawline %w
}
}
alias switchbar_drawBox {
if ($window($1)) {
if ($3 == Gripper) {
var %i = 5
while (%i <= $calc($data(switch_height) - 5)) {
if ($calc(%i % 2)) { drawdot -rn $1 $col(border) 1 $2 %i }
inc %i
}
echo @hide_switch_data $calc($2 - 2) $calc($2 + 4) Gripper
return $calc($2 + 4)
}
elseif ($3 == Seperator) {
if ($calc($2 + 25) > $window($1).w) {
echo @hide_switch_data SEPERATOR POPUP
if ($data(sitch_style) == 2) {
drawline -nr $1 $col(highlight) 1 $calc($window($1).w - 22) $calc($data(switch_height) - 3) $calc($window($1).w - 22) 3 $calc($window($1).w - 4) 3
drawline -nr $1 $col(shadow) 1 $calc($window($1).w - 22) $calc($data(switch_height) - 3) $calc($window($1).w - 3) $calc($data(switch_height) - 3) $calc($window($1).w - 3) 3
}
else {
drawrect -nr $1 $col(border) 1 $calc($window($1).w - 22) 3 20 $calc($data(switch_height) - 6)
drawline -nr $1 $col(highlight) 1 $calc($window($1).w - 21) $calc($data(switch_height) - 5) $calc($window($1).w - 21) 4 $calc($window($1).w - 4) 4
drawline -nr $1 $col(shadow) 1 $calc($window($1).w - 21) $calc($data(switch_height) - 5) $calc($window($1).w - 4) $calc($data(switch_height) - 5) $calc($window($1).w - 4) 4
}
drawtext -nr $1 $col(text) webdings 15 $calc($window($1).w - 19) $calc(($data(switch_height) / 2) - ($height(5,webdings,15) / 2)) 5
return $2
}
else {
drawline -nr $1 $col(shadow) 2 $calc($2 + 1) 5 $calc($2 + 1) $calc($data(switch_height) - 5)
drawline -nr $1 $col(highlight) 1 $calc($2 + 2) 5 $calc($2 + 2) $calc($data(switch_height) - 5)
return $calc($2 + 5)
}
}
else {
var %a
if ($3 == Status) { var %t = $iif($network,$network,Status) , %i = 0 $SwitchbarIcons , %n = "status window" | if ($active == Status Window) && ($cid == $activecid) { %a = $true } }
elseif ($3 == Chan) { var %t = $chan($4) , %i = 1 $SwitchbarIcons , %n = %t | if ($active == %t) && ($cid == $activecid) { %a = $true } }
elseif ($3 == Query) { var %t = $query($4) , %i = 2 $SwitchbarIcons , %n = %t | if ($active == %t) && ($cid == $activecid) { %a = $true } }
elseif ($3 == Window) { var %t = $window($4) , %i = 3 $SwitchbarIcons , %n = %t | if ($active == %t) && ($cid == $activecid) { %a = $true } }
elseif ($3 == Clist) { var %t = Channel List , %i = 4 $SwitchbarIcons , %n = "channels list" | if ($active == Channels List) && ($cid == $activecid) { %a = $true } }
else { return $2 }
var %w = $calc($width(%t,tahoma,10) + 10) , %h = $height(%t,tahoma,10) , %e = ""
if ($data(switch_showIcons)) { %w = %w + 17 }
if ($calc($2 + %w + 25) > $window($1).w) {
if ($gettok($line(@hide_switch_data,$line(@hide_switch_data,0)),-1,32) != POPUP) {
echo @hide_switch_data $calc($window($1).w - 22) $calc($window($1).w - 2) POPUP
if ($data(switch_style) == 2) {
drawline -nr $1 $col(highlight) 1 $calc($window($1).w - 22) $calc($data(switch_height) - 3) $calc($window($1).w - 22) 3 $calc($window($1).w - 4) 3
drawline -nr $1 $col(shadow) 1 $calc($window($1).w - 22) $calc($data(switch_height) - 3) $calc($window($1).w - 3) $calc($data(switch_height) - 3) $calc($window($1).w - 3) 3
}
else {
drawrect -nr $1 $col(border) 1 $calc($window($1).w - 22) 3 20 $calc($data(switch_height) - 6)
drawline -nr $1 $col(highlight) 1 $calc($window($1).w - 21) $calc($data(switch_height) - 5) $calc($window($1).w - 21) 4 $calc($window($1).w - 4) 4
drawline -nr $1 $col(shadow) 1 $calc($window($1).w - 21) $calc($data(switch_height) - 5) $calc($window($1).w - 4) $calc($data(switch_height) - 5) $calc($window($1).w - 4) 4
}
drawtext -nr $1 $col(text) webdings 15 $calc($window($1).w - 19) $calc(($data(switch_height) / 2) - ($height(5,webdings,15) / 2)) 5
%w = $calc($window($1).w - $2 - 25)
%e = Popup
if ($3 == Status) { echo @hide_switch_data scid $cid %e }
echo @hide_switch_data $2 $calc($2 + %w) $3- POPUP
echo @hide_switch_data $3- POPUP
}
else { if ($3 == Status) { echo @hide_switch_data scid $cid %e } | echo @hide_switch_data $3- POPUP | return $2 }
}
if (%w > 2) {
if ($istok($temp(switch_hideserver),$cid,32)) && ($cid $3- == $temp(switch_hover)) && ($mouse.key & 2) { drawrect -fnr $1 $col(hover) 1 $2 3 %w $calc($data(switch_height) - 6) }
elseif ($istok($temp(switch_hideserver),$cid,32)) { drawrect -fnr $1 $col(greyed) 1 $2 3 %w $calc($data(switch_height) - 6) }
elseif (%a) { drawrect -fnr $1 $col(active) 1 $2 3 %w $calc($data(switch_height) - 6) }
elseif ($istok($temp(s_highlight),$cid $+ $chr(44) $+ %n,32)) { drawrect -fnr $1 $col(hover) 1 $2 3 %w $calc($data(switch_height) - 6) }
elseif ($cid $3- == $temp(switch_hover)) { drawrect -fnr $1 $col(hover) 1 $2 3 %w $calc($data(switch_height) - 6) }
if ($data(switch_style) == 2) {
drawline -nr $1 $col(highlight) 1 $2 $calc($data(switch_height) - 3) $2 3 $calc($2 + %w) 3
drawline -nr $1 $col(shadow) 1 $2 $calc($data(switch_height) - 3) $calc($2 + %w) $calc($data(switch_height) - 3) $calc($2 + %w) 3
}
else {
drawrect -nr $1 $col(border) 1 $2 3 %w $calc($data(switch_height) - 6)
drawline -nr $1 $col(highlight) 1 $calc($2 + 1) $calc($data(switch_height) - 5) $calc($2 + 1) 4 $calc($2 + %w - 1) 4
drawline -nr $1 $col(shadow) 1 $calc($2 + 1) $calc($data(switch_height) - 5) $calc($2 + %w - 2) $calc($data(switch_height) - 5) $calc($2 + %w - 2) 4
}
if ($data(switch_showIcons)) && (%w > 22) {
drawtext -cnr $1 $col(text) tahoma 10 $calc($2 + 22) $calc(($data(switch_height) / 2) - (%h / 2)) $calc(%w - 26) 1000 %t
if (%i) { drawpic -sconr $1 $calc($2 + 3) $calc(($data(switch_height) / 2) - 8) 16 16 %i }
}
else {
drawtext -cnr $1 $col(text) tahoma 10 $calc($2 + 5) $calc(($data(switch_height) / 2) - (%h / 2)) $calc(%w - 9) 1000 %t
}
}
if (!%e) {
if ($3 == Status) { echo @hide_switch_data scid $cid POPUP }
echo @hide_switch_data $2 $calc($2 + %w) $3-
}
return $calc($2 + %w + 3)
}
drawline $1
}
}
alias switch_getItem {
var %i = 1 , %t , %c = 1
while (%i <= $line(@hide_switch_data,0)) {
%t = $line(@hide_switch_data,%i)
if ($gettok(%t,1,32) == scid) { %c = $gettok(%t,2,32) }
elseif ($1 >= $gettok(%t,1,32)) && ($1 <= $gettok(%t,2,32)) {
if ($prop == id) { return %c }
elseif ($prop == both) { return %c $gettok(%t,3-,32) }
else { return $gettok(%t,3-,32) }
}
inc %i
}
}
menu @hide_switchbar {
sclick: switchbar_sclick $mouse.x $mouse.y
rclick: switchbar_rclick $mouse.x $mouse.y
}
alias switchbar_sclick {
if ($2 >= 3) && ($2 <= $calc($data(switch_height) - 3)) {
if ($switch_getItem($1)) {
var %v = $v1
scid $switch_getItem($1).id
if (%v == Status) && ($mouse.key & 2) {
if ($istok($temp(switch_hideserver),$cid,32)) { temp switch_hideserver $remtok($temp(switch_hideserver),$cid,1,32) }
else { temp switch_hideserver $addtok($temp(switch_hideserver),$cid,32) }
}
elseif (%v == Status) { if ($mouse.key & 4) { disconnect } | window $iif($mouse.key & 4,-c,-a) "status window" }
elseif (%v == Clist) { window $iif($mouse.key & 4,-c,-a) "channels List" }
elseif ($gettok(%v,1,32) == Chan) { if ($mouse.key & 4) { part $chan($gettok(%v,2,32)) } | window $iif($mouse.key & 4,-c,-a) $chan($gettok(%v,2,32)) }
elseif ($gettok(%v,1,32) == Query) { window $iif($mouse.key & 4,-c,-a) $query($gettok(%v,2,32)) }
elseif ($gettok(%v,1,32) == Window) { window $iif($mouse.key & 4,-c,-a) $window($gettok(%v,2,32)) }
elseif ($gettok(%v,1,32) == Popup) { switchbar_endPopup }
elseif ($gettok(%v,1,32) == Gripper) {
switchbar_drag $1-
temp mouse.x $1 | temp mouse.y $2
}
}
}
switchbar_draw
}
alias switchbar_endPopup {
var %i = 1 , %t , %c = 1 , %e
while (%i <= $line(@hide_switch_data,0)) {
%t = $line(@hide_switch_data,%i)
if ($gettok(%t,1,32) == scid) { %c = $gettok(%t,2,32) | scid %c }
elseif ($gettok(%t,3,32) == POPUP) && ($gettok(%t,1,32) isnum) {
%e = $true
popup_create switchbar_endPopup
popup_setstyle switchbar_endPopup colors $rgb(text) $rgb(shadow) $rgb(text) $rgb(shadow) $rgb(face) $rgb(face) $col(hover) 15394529 $rgb(frame) $rgb(face) $rgb(shadow)
}
elseif (%e) {
if (%t == Status POPUP) { popup_add switchbar_endPopup $network $cr switchbar_endPopupClick %c "Status Window" }
elseif (%t == Clist POPUP) { popup_add switchbar_endPopup Channels List $cr switchbar_endPopupClick %c "channels List" }
elseif ($gettok(%t,1,32) == Chan) { popup_add switchbar_endPopup $chan($gettok(%t,2,32)) $cr switchbar_endPopupClick %c $chan($gettok(%t,2,32)) }
elseif ($gettok(%t,1,32) == Query) { popup_add switchbar_endPopup $query($gettok(%t,2,32)) $cr switchbar_endPopupClick %c $query($gettok(%t,2,32)) }
elseif ($gettok(%t,1,32) == Window) { popup_add switchbar_endPopup $window($gettok(%t,2,32)) $cr switchbar_endPopupClick %c $window($gettok(%t,2,32)) }
elseif ($gettok(%t,1,32) == SEPERATOR) { popup_add switchbar_endPopup - }
}
inc %i
}
if (%e) { popup switchbar_endPopup }
}
alias switchbar_endPopupClick {
scon $1
window -a $2-
switchbar_draw
}
alias switchbar_rclick {
if ($2 >= 3) && ($2 <= $calc($data(switch_height) - 3)) {
if ($switch_getItem($1)) {
var %v = $v1
scid $switch_getItem($1).id
popup_create switchbar_Popup
popup_setstyle switchbar_Popup colors $rgb(text) $rgb(shadow) $rgb(text) $rgb(shadow) $rgb(face) $rgb(face) $col(hover) 15394529 $rgb(frame) $rgb(face) $rgb(shadow)
if (%v == Status) {
popup_add switchbar_Popup $+ $iif($network,$network,Status Window) $cr scid $switch_getItem($1).id window -a "status window"
popup_add switchbar_Popup -
popup_add switchbar_Popup Clear $cr scid $switch_getItem($1).id clear "status window"
popup_add switchbar_Popup Disconnect $cr switchbar_close_server $1
}
elseif (%v == Clist) {
popup_add switchbar_Popup $+ $network $cr scid $switch_getItem($1).id window -a "channels list"
popup_add switchbar_Popup -
popup_add switchbar_Popup Clear $cr scid $switch_getItem($1).id clear "channels list"
popup_add switchbar_Popup Close $cr scid $switch_getItem($1).id window -c "channels list"
}
elseif ($gettok(%v,1,32) == Chan) {
popup_add switchbar_Popup $+ $chan($gettok(%v,2,32)) $cr scid $switch_getItem($1).id window -a $chan($gettok(%v,2,32))
popup_add switchbar_Popup -
popup_add switchbar_Popup Clear $cr scid $switch_getItem($1).id clear $chan($gettok(%v,2,32))
popup_add switchbar_Popup Hop $cr scid $switch_getItem($1).id hop $chan($gettok(%v,2,32))
popup_add switchbar_Popup Part $cr scid $switch_getItem($1).id part $chan($gettok(%v,2,32))
}
elseif ($gettok(%v,1,32) == Query) {
popup_add switchbar_Popup $+ $query($gettok(%v,2,32)) $cr scid $switch_getItem($1).id window -a $query($gettok(%v,2,32))
popup_add switchbar_Popup -
popup_add switchbar_Popup Whois $cr scid $switch_getItem($1).id whois $query($gettok(%v,2,32))
popup_add switchbar_Popup Clear $cr scid $switch_getItem($1).id clear $query($gettok(%v,2,32))
popup_add switchbar_Popup Close $cr scid $switch_getItem($1).id window -c $query($gettok(%v,2,32))
}
elseif ($gettok(%v,1,32) == Window) {
popup_add switchbar_Popup $+ $window($gettok(%v,2,32)) $cr scid $switch_getItem($1).id window -a $window($gettok(%v,2,32))
popup_add switchbar_Popup -
popup_add switchbar_Popup Clear $cr scid $switch_getItem($1).id clear $window($gettok(%v,2,32))
popup_add switchbar_Popup Close $cr scid $switch_getItem($1).id window -c $window($gettok(%v,2,32))
}
elseif (%v == Gripper) {
popup_add switchbar_Popup Top $cr switchbar_move top
popup_add switchbar_Popup Bottom $cr switchbar_move bottom
}
elseif ($gettok(%v,1,32) == Popup) { switchbar_endPopup }
popup switchbar_Popup
}
}
switchbar_draw
}
alias switchbar_drag {
if (!$window(@hide_mswitchbar)) {
window -idopB +dx @hide_mswitchbar $calc($mouse.dx - $temp(mouse.x)) $calc($mouse.dy - $temp(mouse.y)) $calc($window(-2).w - 6) $data(switch_height)
switchbar_draw @hide_mswitchbar
setlayer @hide_mswitchbar 100
}
}
menu @hide_mswitchbar {
mouse: switchbar_draging
drop: window -c @hide_mswitchbar
leave: {
if ($mouse.key & 1) { switchbar_draging }
else { window -c @hide_mswitchbar }
}
}
alias switchbar_draging {
if ($mouse.key & 1) {
if ($inrect($mouse.dx,$mouse.dy,$window(-2).x,$calc($window(-2).y + 10 + $iif($data(side_pos) == top,$data(side_width))),$window(-2).w,40)) { switchbar_move top }
if ($inrect($mouse.dx,$mouse.dy,$window(-2).x,$calc($window(-2).y + $window(-2).h - $data(switch_height) - $iif($data(side_pos) == top,$data(side_width))),$window(-2).w,30)) { switchbar_move bottom }
window @hide_mswitchbar $calc($window(@hide_mswitchbar).x + $mouse.x - $temp(mouse.x)) $calc($window(@hide_mswitchbar).y + $mouse.y - $temp(mouse.y))
}
else {
window -c @hide_mswitchbar
}
}
alias switchbar_close_server {
scid $switch_getItem($1).id
if ($status != connected) { window -c "status window" }
else { disconnect | window -c "status window" }
}