alias mdx { var %dll $scriptdirmdx\mdx.dll } | return $dll(%dll,$1,$2-) }
alias dialogx { return $scriptdirmdx\dialog.mdx }
alias mdxbegin { mdx SetMircVersion $version | mdx MarkDialog $dname }

alias Pw.ric.nick { if (!$dialog(Pw.ric.nick)) dialog -m Pw.ric.nick Pw.ric.nick |  if ( %cc181p == on ) { $tunder TDDialog $dialog(pw.ric.nick).hwnd > 10 } }
dialog Pw.ric.nick {
  title "Crea Richiamo Arcan]G[elo 2 "
  size -1 -1 195 87
  option dbu
  box "", 1, 2 1 191 29
  edit "", 2, 6 17 80 10, right
  edit "", 3, 108 17 81 10
  text "NICK", 4, 87 17 20 10, center
  text "Parte iniziale", 5, 20 8 48 8, center
  text "Parte finale", 6, 122 8 49 8, center
  box "Prewiev", 7, 2 31 191 27
  button "Button", 8, 6 41 182 12
  button "OK", 9, 152 69 29 11, ok
  text "Arcan]G[elo 2", 10, 76 69 59 8, disable center
  box "Custom", 11, 2 59 69 26
  combo 12, 6 67 60 80, size drop
  box "", 13, 140 59 53 26
  box "", 14, 73 59 66 26
  text "", 15, 73 6 48 10
}
on *:dialog:Pw.ric.nick:init:*:{
  mdxbegin
  mdx SetBorderStyle $dname 4,9 windowedge clientedge
  if (%unome == 1) {
    mdx SetFont $dname 4,5,6,9,10 13 650 tahoma
    mdx SetMircVersion $version
    mdx MarkDialog $dname $dialog($dname).hwnd
    mdx SetDialog $dname bgcolor $rgb(0,72,170)
    mdx SetColor $dname 7,11 background $rgb(255,134,0)
    mdx  SetColor $dname 1,4,5,6,10,12,13,14,15 background $rgb(0,72,170)
    mdx  SetColor $dname 2,3 background $rgb(0,0,0)
    mdx  SetColor $dname 2,3 textbg $rgb(0,0,0)
    mdx  SetColor $dname 1,4,5,6,10,12,13,14,15 textbg $rgb(0,72,170)
    mdx  SetColor 1,2,3,4,5,6,10,12,13,14,15 text $rgb(255,255,255)
    mdx  SetColor $dname 8,9 background $rgb(0,72,170)
  }
  if (%unome == 2) {
    mdx SetFont $dname 4,5,6,9,10 13 650 tahoma
    mdx SetMircVersion $version
    mdx MarkDialog $dname $dialog($dname).hwnd
    mdx SetDialog $dname bgcolor $rgb(0,0,95)
    mdx SetColor $dname 7,11 background $rgb(196,196,196)
    mdx  SetColor $dname 1,4,5,6,10,12,13,14,15 background $rgb(0,0,95)
    mdx  SetColor $dname 2,3 background $rgb(0,0,0)
    mdx  SetColor $dname 2,3 textbg $rgb(0,0,0)
    mdx  SetColor $dname 1,4,5,6,10,12,13,14,15 textbg $rgb(0,0,95)
    mdx  SetColor 1,2,3,4,5,6,10,12,13,14,15 text $rgb(255,255,255)
    mdx  SetColor $dname 8,9 background $rgb(0,0,95)
  }
  did -a $dname 2 %Pw.ric.nick.a
  did -a $dname 3 %Pw.ric.nick.b
  var %nc = did -a Pw.ric.nick

  %nc 12 Personale
  %nc 12 Arcan]G[elo
  %nc 12 Arcan]G[elo Oscuro
  Pw.Custom.nk

  window -adhk0o +d @preview.ric.nick 1 1 1 1 12
  mdx SetControlMDX $dname 8 Window > $dialogx
  did -a $dname 8 grab $window(@preview.ric.nick).hwnd @preview.ric.nick
  Pw.preview.nc
  sline @preview.ric.nick 1

}
on *:dialog:Pw.ric.nick:edit:*:{
  if ($did == 2) { 
    set %Pw.ric.nick.ax $did(Pw.ric.nick,2)
    Pw.preview.nc
  }
  if ($did == 3) { 
    set %Pw.ric.nick.bx $did(Pw.ric.nick,3)
    Pw.preview.nc
  }
}
alias Pw.preview.nc  { 
  if ($window(@preview.ric.nick)) {
    clear @preview.ric.nick
    echo @preview.ric.nick $did(Pw.ric.nick,2).text $+ $me $+ $did(Pw.ric.nick,3) 
  }
}
on *:dialog:Pw.ric.nick:sclick:*: {
  if ($did == 12) { 
    %Pw.ric.nick.custom = $did(Pw.ric.nick, 12, 1).sel
    dec %Pw.ric.nick.custom 
    $Pw.Custom.nk

  }
}

alias Pw.Custom.nk {
  if (%Pw.ric.nick.custom = 0) { 
    set %Pw.ric.nick.a %Pw.ric.nick.ax 
    set %Pw.ric.nick.b %Pw.ric.nick.bx
    did -ra $dname 2 %Pw.ric.nick.a
    did -ra $dname 3 %Pw.ric.nick.b
  }
  if (%Pw.ric.nick.custom = 1) {
    set %Pw.ric.nick.a 7~11`7(11«7  
    set %Pw.ric.nick.b   11»7)11`7~
    Pw.preview.nc2
  }
  if (%Pw.ric.nick.custom = 2) {
    set %Pw.ric.nick.a 3~15`3(15«8 
    set %Pw.ric.nick.b 15»3)15`3~
    Pw.preview.nc2
  }
}


alias Pw.preview.nc2  { 
  if ($window(@preview.ric.nick)) {
    clear @preview.ric.nick
    echo @preview.ric.nick %Pw.ric.nick.a $+ $me $+ %Pw.ric.nick.b 
  }
}
on *:load: {
  set %Pw.ric.nick.custom 5
}
on *:unload: {
  unset %Pw.ric.nick.*
}
