
#compact
$ filename "t.exe"
'uses RTL64
uses Controls


class ColorDialogBox
====================
  '
  indexbase 0
  '
  DialogBox   d1
  Slider      s1,s2,s3,s4,s5,s6
  Slider      v1,v2,v3,v4,v5,v6,v7,v8
  Knob        k1
  RoundButton b1,b2,b3
  RectButton  r1,r2,r3
  sys         r,g,b,h,l,s,p,q
  sys         RgbZone,HcsZone
  '
  method constructor()
  int i
  '
  'images
  '
  '
  'controls
  '
  d1<=20,40,600,400,"Background Colors"
  s1<=100,100,10,15,50,150,100,100,"Red"
  s2<=100,140,10,15,50,150,140,140,"Green"
  s3<=100,180,10,15,50,150,180,180,"Blue"
  s4<=100,220,10,15,50,150,220,220,"Hue"
  s5<=100,260,10,15,50,150,260,260,"Luminance"
  s6<=100,300,10,15,50,150,300,300,"Saturation"
  s4.sc=240 'show scale
  s5.sc=240 'show scale
  s6.sc=240 'show scale
  k1<=360,110,19,19,.012,.5,""
  b1<=360,150,10,10,0x00eeee,0,""
  b2<=360,180,10,10,0x00eeee,0,""
  b3<=360,210,10,10,0x00eeee,0,""
  r1<=400,150,10,10,0x00eeee,1,""
  r2<=400,180,10,10,0x00eeee,1,""
  r3<=400,210,10,10,0x00eeee,1,""
  v1<=360,300,08,07,360,360,250,350,"A"
  v2<=380,300,08,07,380,380,250,350,"B"
  v3<=400,300,08,07,400,400,250,350,"C"
  v4<=420,300,08,07,420,420,250,350,"D"
  v5<=440,300,08,07,440,440,250,350,"E"
  v6<=460,300,08,07,460,460,250,350,"F"
  v7<=480,300,08,07,480,480,250,350,"G"
  v8<=500,300,08,07,500,500,250,350,"H"
  end method
  '
  method destructor
  end method
  '
  method set()
  s1.set
  s2.set
  s3.set
  s4.set
  s5.set
  s6.set
  k1.set
  b1.set
  b2.set
  b3.set
  r1.set
  r2.set
  r3.set
  v1.set
  v2.set
  v3.set
  v4.set
  v5.set
  v6.set
  v7.set
  v8.set
  end method
  '
  method show()
  d1.show
  s1.show
  s2.show
  s3.show
  s4.show
  s5.show
  s6.show
  k1.show
  b1.show
  b2.show
  b3.show
  r1.show
  r2.show
  r3.show
  v1.show
  v2.show
  v3.show
  v4.show
  v5.show
  v6.show
  v7.show
  v8.show
  end method
  '
  method anchor()
  d1.anchor
  s1.anchor
  s2.anchor
  s3.anchor
  s4.anchor
  s5.anchor
  s6.anchor
  k1.anchor
  b1.anchor
  b2.anchor
  b3.anchor
  r1.anchor
  r2.anchor
  r3.anchor
  v1.anchor
  v2.anchor
  v3.anchor
  v4.anchor
  v5.anchor
  v6.anchor
  v7.anchor
  v8.anchor
  end method

  method move(sys tx,ty)
  sys x,y
  d1.move tx,ty
  x=d1.px-d1.spx 'with limits
  y=d1.py-d1.spy 'with limits
  s1.move x,y
  s2.move x,y
  s3.move x,y
  s4.move x,y
  s5.move x,y
  s6.move x,y
  k1.move x,y
  b1.move x,y
  b2.move x,y
  b3.move x,y
  r1.move x,y
  r2.move x,y
  r3.move x,y
  v1.move x,y
  v2.move x,y
  v3.move x,y
  v4.move x,y
  v5.move x,y
  v6.move x,y
  v7.move x,y
  v8.move x,y
  end method
  '
  method HcsSet(sys c)
  ColorRGBToHLS c,h,l,s
  s4.fset h,240
  s5.fset l,240
  s6.fset s,240
  end method
  '
  method RgbSet(sys c)
  r=c and 255
  shr c,8
  g=c and 255
  shr c,8
  b=c and 255
  s1.bset r
  s2.bset g
  s3.bset b
  end method
  '
  method GetHcsColor() as sys
  h=s4.fget 240
  l=s5.fget 240
  s=s6.fget 240
  return ColorHLStoRGB h,l,s
  end method
  '
  method GetRgbColor() as sys
  return s1.bget()+s2.bget()*0x100+s3.bget()*0x10000
  end method
  '
  method zone() as sys
  return d1.zone
  end method
  '
  method zones(sys *RgbZone,*HcsZone)
  RgbZone=s1.zone()+s2.zone()+s3.zone()
  HcsZone=s4.zone()+s5.zone()+s6.zone()
  end method
  '
  method action()
  if mouseButton=0
    anchor
    q=0
  end if
  if q
    move xMouse-sxMouse,yMouse-syMouse
  elseif MouseButton
    set
    zones RgbZone,HcsZone
    if RgbZone then
      HcsSet GetRgbColor
    elseif HcsZone
      RgbSet GetHcsColor
    elseif k1.zone() or
    b1.zone() or b2.zone() or b3.zone() or
    r1.zone() or r2.zone() or r3.zone() or
    v1.zone() or v2.zone() or v3.zone() or v4.zone() or
    v5.zone() or v6.zone() or v7.zone() or v8.zone()
      '
    elseif zone
      q=1
    end if
  end if
  show
  end method
  '
end class

's=recordof ColorDialogBox
'putfile "t.txt", s


new ColorDialogBox cdb

do
  if EscKey then exit do
  if mouseButton=0
    sxMouse=xMouse
    syMouse=yMouse
  end if
  ClsColor cdb.GetRgbColor
  cdb.action
  FlipBuffer
  if MouseButton or AscKey then sleep 10 else sleep 100
end do

del cdb
