' Color Palette for Rapid-Q by William Yu
'
' Extended by AiKi2000 to show values for Rapid-Q
' Values are represented in DEC format and HEX format
' 
' Application can represent all 255^3 colors or only
' web safe colors (colors that must have 00 33 66 99 CC FF
' representation for Red, Green and Blue part --> 33 in HEX = 51 in DEC)

$APPTYPE GUI
$INCLUDE "RAPIDQ.INC"

DIM Form AS QFORM
DIM LabelRed AS QLabel
DIM LabelGreen AS QLabel
DIM LabelBlue AS QLabel
DIM LabelNum1 AS QLabel
DIM LabelNum2 AS QLabel
DIM LabelNum3 AS QLabel
DIM ScrollRed AS QScrollBar
DIM ScrollGreen AS QScrollBar
DIM ScrollBlue AS QScrollBar
DIM Group AS QGroupbox
DIM PaintBox AS QRichedit
DIM RGBValue AS QLabel
DIM RAPIDQValue AS QLabel
DIM RAPIDQValue2 AS QLabel
DIM RGBValueNUM AS QLabel
DIM RAPIDQValueNUM AS QEdit
DIM RAPIDQValue2NUM AS QEdit
DIM Copy1 AS QCoolbtn
DIM Copy2 AS QCoolbtn
DIM Normal AS QCoolbtn
DIM Websafe AS QCoolbtn

SUB Paint
  PaintBox.Color = RGB(ScrollRed.Position,ScrollGreen.Position,ScrollBlue.Position)

  RGBValueNUM.Caption = "("+STR$(ScrollRed.Position)+","+STR$(ScrollGreen.Position)+","+STR$(ScrollBlue.Position)+")"

  RAPIDQValueNUM.Text = STR$(RGB(ScrollRed.Position,ScrollGreen.Position,ScrollBlue.Position))
   
  IF ScrollBlue.Position < 16 THEN
     HEXBlue$ = "0" + CONVBASE$(STR$(ScrollBlue.Position),10,16)
  ELSE
     HEXBlue$ = CONVBASE$(STR$(ScrollBlue.Position),10,16)
  END IF
  IF ScrollGreen.Position < 16 THEN
     HEXGreen$ = "0" + CONVBASE$(STR$(ScrollGreen.Position),10,16)
  ELSE
     HEXGreen$ = CONVBASE$(STR$(ScrollGreen.Position),10,16)
  END IF
  IF ScrollRed.Position < 16 THEN
     HEXRed$ = "0" + CONVBASE$(STR$(ScrollRed.Position),10,16)
  ELSE
     HEXRed$ = CONVBASE$(STR$(ScrollRed.Position),10,16)
  END IF
  IF ScrollBlue.Position = 0 THEN HEXBlue$ = "00" END IF
  IF ScrollGreen.Position = 0 THEN HEXGreen$ = "00" END IF
  IF ScrollRed.Position = 0 THEN HEXRed$ = "00" END IF
  RAPIDQValue2NUM.Text = "#H" + HEXBlue$ + HEXGreen$ + HEXRed$
END SUB

SUB ColorChange
  LabelNum1.Caption = STR$(ScrollRed.Position)
  LabelNum2.Caption = STR$(ScrollGreen.Position)
  LabelNum3.Caption = STR$(ScrollBlue.Position)
  Paint
END SUB

SUB Normalclick
  ScrollRed.Largechange = 5
  ScrollRed.Smallchange = 1
  ScrollGreen.Largechange = 5
  ScrollGreen.Smallchange = 1
  ScrollBlue.Largechange = 5
  ScrollBlue.Smallchange = 1
END SUB

SUB Websafeclick
  ScrollRed.Largechange = 51
  ScrollRed.Smallchange = 51
  ScrollGreen.Largechange = 51
  ScrollGreen.Smallchange = 51
  ScrollBlue.Largechange = 51
  ScrollBlue.Smallchange = 51
  ScrollRed.Position = ROUND((ScrollRed.Position)/51)*51
  ScrollGreen.Position = ROUND((ScrollGreen.Position)/51)*51
  ScrollBlue.Position = ROUND((ScrollBlue.Position)/51)*51
  ColorChange
END SUB

SUB CopyToClipboard1
  ClipBoard.Text = RAPIDQValueNUM.Text
END SUB

SUB CopyToClipboard2
  ClipBoard.Text = RAPIDQValue2NUM.Text
END SUB

WITH Form
  .Caption = "RapidQ Palette v 1.1"
  .Height = 380
  .Width = 300
  .BorderStyle = bsSingle
END WITH

WITH LabelRed
  .Parent = Form
  .Left = 8
  .Top = 22
  .Caption = "Red:"
END WITH

WITH LabelGreen
  .Parent = Form
  .Left = 7
  .Top = 52
  .Caption = "Green:"
END WITH

WITH LabelBlue
  .Parent = Form
  .Left = 8
  .Top = 82
  .Caption = "Blue:"
END WITH

WITH LabelNum1
  .Parent = Form
  .Left = 260
  .Top = 22
  .Caption = "0"
END WITH

WITH LabelNum2
  .Parent = Form
  .Left = 260
  .Top = 52
  .Caption = "0"
END WITH

WITH LabelNum3
  .Parent = Form
  .Left = 260
  .Top = 82
  .Caption = "0"
END WITH

WITH ScrollRed
  .Parent = Form
  .Left = 50
  .Top = 20
  .Width = 200
  .Height = 20
  .Min = 0
  .Max = 255
  .Smallchange = 1
  .Largechange = 5
  .ShowHint =  True
  .Hint = "Red Attribute"
  .OnChange = ColorChange
END WITH

WITH ScrollGreen
  .Parent = Form
  .Left = 50
  .Top = 50
  .Width = 200
  .Height = 20
  .Min = 0
  .Max = 255
  .Smallchange = 1
  .Largechange = 5
  .ShowHint =  True
  .Hint = "Green Attribute"
  .OnChange = ColorChange
END WITH

WITH ScrollBlue
  .Parent = Form
  .Left = 50
  .Top = 80
  .Width = 200
  .Height = 20
  .Min = 0
  .Max = 255
  .Smallchange = 1
  .Largechange = 5
  .ShowHint =  True
  .Hint = "Blue Attribute"
  .OnChange = ColorChange
END WITH

WITH Group
  .Parent = Form
  .Caption = "Chosen Color
  .Top = 110
  .Left = 50
  .Height = 90
  .Width = 200
END WITH

WITH PaintBox
  .Parent = Form
  .Text = ""
  .Enabled = False
  .Left = 55
  .Top = 128
  .Height = 67
  .Width = 190
  .Color = #H000000
'    .OnChange = Paint
END WITH

WITH RGBValue
  .Parent = Form
  .Left = 8
  .Top = 215
  .Caption = "RGB Value:"
END WITH 

WITH RAPIDQValue
  .Parent = Form
  .Left = 8
  .Top = 245
  .Caption = "RAPID-Q Value (DEC):"
END WITH

WITH RAPIDQValue2
  .Parent = Form
  .Left = 8
  .Top = 275
  .Caption = "RAPID-Q Value (HEX):"
END WITH

WITH RGBValueNUM
  .Parent = Form
  .Left = 150
  .Top = 215
  .Caption = "(0,0,0)"
END WITH

WITH RAPIDQValueNUM
  .Parent = Form
  .Left = 150
  .Top = 242
  .Width = 100
  .Text = "0"
END WITH

WITH RAPIDQValue2NUM
  .Parent = Form
  .Left = 150
  .Top = 272
  .Width = 100
  .Text = "#H000000"
END WITH

WITH Copy1
  .Parent = Form
  .Left = 260
  .Top = 242
  .BMP = "copy.bmp"
  .Flat = True
  .Hint = "Copy value to Clipboard"
  .ShowHint = True
  .OnClick = CopyToClipboard1
END WITH

WITH Copy2
  .Parent = Form
  .Left = 260
  .Top = 272
  .BMP = "copy.bmp"
  .Flat = True
  .Hint = "Copy value to Clipboard"
  .ShowHint = True
  .OnClick = CopyToClipboard2
END WITH

WITH Normal
  .Parent = Form
  .Left = 20
  .Top = 310
  .Width = 110
  .Caption = "All colors"
  .Groupindex = 1
  .Down = True
  .OnClick = Normalclick
END WITH

WITH Websafe
  .Parent = Form
  .Left = 150
  .Top = 310
  .Width = 110
  .Caption = "Web safe colors"
  .Groupindex = 1
  .OnClick = Websafeclick
END WITH

Form.Center
Form.ShowModal
