All pastes #35245 Raw Edit

Untitled

public text v1 · immutable
#35245 ·published 2005-12-30 03:06 UTC
rendered paste body
;  +-----------------------------+
;  | Icon Selector               |
;  +-----------------------------+

dialog IconSel {
  title "Icon Selection"
  size -1 -1 167 170
  option dbu
  icon $_zicl, 3
  text "", 1, 3 3 159 13
  text "Select Icon", 2, 7 6 90 8
  text "", 3, 0 0 0 0, hide result
  edit "", 5, 3 20 146 10
  button "!", 6, 152 20 10 10
  box "", 10, 3 30 159 4
  list 4, 3 37 160 111, size extsel
  button "ok", 8, 84 155 37 12, default ok
  button "cancel", 9, 125 155 37 12, default cancel
  box "", 7, 3 148 159 4
  text "30 0 100", 11, 37 88 90 10
  text "", 13, 63 79 41 8
}
alias iconsel::open { dialog -mo iconsel iconsel }
alias iconsel::close { dialog -x iconsel iconsel }
on *:dialog:iconsel:init:*: {
  _mdx::load $dname
  _mdx::button $dname 6,8,9
  _mdx::font $dname 4,5,6,7,8,9
  _mdx::font $dname 2 large bold
  _mdx::border $dname 1,4,5
  _mdx SetBorderStyle $dname 4 windowedge clientedge
  var %r = $rgb($rgb(face))
  var %r = $+($iif($calc($gettok(%r,1,44) + 20) > 255,255,$v1),$chr(44),$iif($calc($gettok(%r,2,44) + 20) > 255,255,$v1),$chr(44),$iif($calc($gettok(%r,3,44) + 20) > 255,255,$v1))
  _mdx SetColor $dname 1,2 background $rgb( [ %r ] )
  _mdx SetColor $dname 1,2 textbg $rgb( [ %r ] )
  did -i $dname 4 1 bmpsize 32 32
  _mdx SetControlMDX $dname 4 listview icon single noheader flatsb autoarrange > $_mdxviews
  did -h $dname 11,13
  did -v $dname 13
  _mdx SetControlMDX $dname 11 ProgressBar smooth > $_mdxctl
  did -f $dname 8
  iconsel::fill $_zicl
}
alias iconsel::fill { 
  var %d = $dialog(iconsel)
  if (%d) {
    iconsel::clear
    did -c %d 5
    var %icl = $1
    did -a %d 11 0
    did -h %d 4
    did -v %d 11,13
    did -i %d 13 1 Loading Icons... 
    var %x = 0,%y = $calc(100 / $counticons(%icl))
    while (%x <= $counticons(%icl)) {
      did -i %d 4 1 seticon normal 0 $+(%x,$chr(44),%icl)
      did -a %d 4 0 + %x 0 0 %x
      did -a %d 11 $round($calc(%y * %x),0) 0 100
      inc %x
    }
    did -a %d 5 ~ $gettok(%icl,-5-,92)
    did -h %d 11
    did -h %d 13
    did -v %d 4
    did -d %d 4 2
    if ($did($dname,4).lines == 1) { var %n = $input(This file contains no icons,uow,Error) | halt }
  } 
}
alias iconsel::clear { did -i iconsel 4 1 clearicons normal | did -r iconsel 4 | did -r iconsel 5 }
on *:dialog:iconsel:sclick:6: {
  var %x = $sfile($_gfx,Select a Icon File,Ok),%y = ico icl exe dll
  if ($gettok($gettok(%x,-1,92),-1,46) !isin %y) { var %n = $input(That is not a valid icon file,uow,Error) | halt }
  iconsel::fill $shortfn(%x)
}
on *:dialog:iconsel:sclick:8: {
  if ($did($dname,4).seltext == $null) { var %n = $input(Please choose an icon or click cancel,uow,Error) | halt }
  var %x = $longfn($did($dname,5)),%y = $gettok($did($dname,4).seltext,6,32)
  echo -a File: %x Icon: %y
  ;writeini whatever.ini icons wtfever-bar $+(%y,$chr(44),%x)
  ; ^^^ In format mdx.dll uses for specifying icons from .icl files. 
}
on *:dialog:iconsel:dclick:4: {
  if ($did($dname,4).seltext == $null) { var %n = $input(Please choose an icon or click cancel,uow,Error) | halt }
  var %x = $longfn($did($dname,5)),%y = $gettok($did($dname,4).seltext,6,32)
  ;blah
  dialog -k $dname
}