dialog _topic {
title "Topic"
option -dbu
size -1 -1 390 60
edit "",1,5 10 380 10,autohs limit 400
icon 2,5 30 380 9
check "Generate preview automatical", 7,5 45 80 10
button "&Generate Preview", 3,90 45 70 10,default disabled
button "&Strip Topic", 4,165 45 70 10
button "Set &Topic", 5,240 45 70 10,Ok
button "&Cancel", 6,315 45 70 10,Cancel
box "Edit Topic:", 8,2 2 386 20
box "Topic Preview:", 9,2 22 386 20
}
on 1:dialog:_topic:init:0:{ did -c _topic 7 | _topic1 | if $strip($did(1)) == $did(1) { did -b _topic 4 } | else { did -e _topic 4 } }
on 1:dialog:_topic:edit:1:{ if $did(7).state { .timer.:preview:. -m 1 500 _preview _topic 2 $active } | if $strip($did(1)) == $did(1) { did -b _topic 4 } | else { did -e _topic 4 } }
on 1:dialog:_topic:sclick:3:{ _preview _topic 2 $active }
on 1:dialog:_topic:sclick:4:{ if $input(Are you sure?,8,Strip Topic) { set -u5 %_topic $gettok($dialog(_topic).title,2-,183) | _topic2 } }
on 1:dialog:_topic:sclick:5:{ topic $gettok($dialog(_topic).title,2-,183) $did(1) }
on 1:dialog:_topic:sclick:7:{ if $did(7).state { did -b _topic 3 | _preview _topic 2 $active } | else { did -e _topic 3 } }
alias -l _mode { return $iif($prop == null,$gettok($chan($iif($1,$1,$chan)).mode,1,32),$chan($iif($1,$1,$chan)).mode) }
alias -l _topic1 {
dialog -t _topic $dialog(_topic).title $chr(183) %_topic
var %t = $gettok($dialog(_topic).title,2-,183)
did -o _topic 1 1 $_topic(%_topic)
_preview _topic 2 %_topic $_topic(%_topic)
if t isincs $_mode(%_topic).null && $me !isop %_topic { did -b _topic 5 }
}
alias -l _topic2 {
var %t = $gettok($dialog(_topic).title,2-,183)
did -o _topic 1 1 $strip($did(_topic,1))
_preview _topic 2 %_topic $strip($did(_topic,1))
did -b _topic 4
}
alias _topic {
if $isid { return $chan($iif($1,$1,#)).topic }
else {
if $1 ischan { set -u5 %_topic $1 | if !$dialog(_topic) { dialog -m _topic _topic } }
elseif $active ischan && !$1 { set -u5 %_topic $active | if !$dialog(_topic) { dialog -m _topic _topic } }
else { echo $color(info) -a * /_topic :invalid channel }
}
}
alias -l _preview {
if $1-3 {
set %preview 1
window -pfh @preview 1 1 $int($calc($dbuw * 380)) $int($calc($dbuh * 9))
drawfill @preview $colour(t) $colour(b) 0 0
if $did(_topic,1) { .drawtext -pb @preview $colour(t) $colour(b) "MS Sans Serif" 9 2 2 $ifmatch }
drawsave @preview $mircdirpreview.bmp
if $dialog($1) { .did -g $1-2 $mircdirpreview.bmp }
.remove $mircdirpreview.bmp
window -c @preview
}
}