DIM DLcolor AS colorDialog
    DLcolor.fullOpen=True

OBJECT form AS Form
   center = True
   caption = "Panel Test"
   width = 400: height = 280
   onShow=Init

' ------------------------------------------------------------------------------   
   OBJECT p1 AS Panel
      top = 10: left = 10: height = 100
      color=&hC8D0D4
   END OBJECT

   OBJECT lblInnerP1 AS Label
      top = 6: left = 210: caption = "bevelInner"
      fontName = "Arial": fontBold = True
   END OBJECT
   OBJECT cmbInnerP1 AS comboBox
      top = 20: left = 210: width = 80
      Item(0)="bvNone"
      Item(1)="bvLowered"
      Item(2)="bvRaised"
      Item(3)="bvSpace"
      onChange=innerP1Change
   END OBJECT

   OBJECT lblOuterP1 AS Label
      top = 6: left = 300: caption = "bevelOuter"
      fontName="Arial": fontBold=True
   END OBJECT
   OBJECT cmbOuterP1 AS comboBox
      top = 20: left = 300: width = 80
      Item(0)="bvNone"
      Item(1)="bvLowered"
      Item(2)="bvRaised"
      Item(3)="bvSpace"
      onChange=outerP1Change
   END OBJECT

   OBJECT lblWidthP1 AS Label
      top = 48: left = 210: caption = "bevelWidth"
      fontName="Arial": fontBold=True
   END OBJECT
   OBJECT cmbWidthP1 AS comboBox
      top = 62: left = 210: width = 80
      Item(0)="0"
      Item(1)="1"
      Item(2)="2"
      Item(3)="3"
      Item(4)="4"
      Item(5)="5"
      onChange=WidthP1Change
   END OBJECT
   
   OBJECT btnColorP1 AS Button
      top = 62: left = 300: width = 78: height = 21
      caption="Color"
      fontName="Arial": fontBold=True
      onClick=colorP1Click
   END OBJECT
   
   OBJECT lblRgbP1 AS Label
      top = 92: left = 210
      fontName="Arial": fontSize=7
   END OBJECT      
   OBJECT lblHexP1 AS Label
      top = 92: left = 280
      fontName="Arial": fontSize=7
   END OBJECT      
   OBJECT lblDecP1 AS Label
      top = 92: left = 335
      fontName="Arial": fontSize=7
   END OBJECT      

' ------------------------------------------------------------------------------   
   OBJECT p2 AS Panel
      top = 130:left = 10: height = 100
      color=RGB(255,255,128)
   END OBJECT   
   OBJECT lblInnerP2 AS Label
      top = 126: left = 210: caption = "bevelInner"
      fontName="Arial": fontBold=True
   END OBJECT
   OBJECT cmbInnerP2 AS comboBox
      top = 140: left = 210: width = 80
      Item(0)="bvNone"
      Item(1)="bvLowered"
      Item(2)="bvRaised"
      Item(3)="bvSpace"
      onChange=innerP2Change
   END OBJECT

   OBJECT lblOuterP2 AS Label
      top = 126: left = 300: caption = "bevelOuter"
      fontName="Arial": fontBold=True
   END OBJECT
   OBJECT cmbOuterP2 AS comboBox
      top = 140: left = 300: width = 80
      Item(0)="bvNone"
      Item(1)="bvLowered"
      Item(2)="bvRaised"
      Item(3)="bvSpace"
      onChange=outerP2Change
   END OBJECT

   OBJECT lblWidthP2 AS Label
      top = 168: left = 210: caption = "bevelWidth"
      fontName="Arial": fontBold=True
   END OBJECT
   OBJECT cmbWidthP2 AS comboBox
      top = 182: left = 210: width = 80
      Item(0)="0"
      Item(1)="1"
      Item(2)="2"
      Item(3)="3"
      Item(4)="4"
      Item(5)="5"
      onChange=WidthP2Change
   END OBJECT
   
   OBJECT lblColorP2 AS Label
      top = 168: left = 300: caption = "Color"
      fontName="Arial": fontBold=True 
   END OBJECT
   OBJECT btnColorP2 AS Button
      top = 182: left = 300: width = 78: height = 21
      caption="Color"
      fontName="Arial": fontBold=True
      onClick=colorP2Click
   END OBJECT

   OBJECT lblRgbP2 AS Label
      top = 212: left = 210
      fontName="Arial": fontSize=7
   END OBJECT      
   OBJECT lblHexP2 AS Label
      top = 212: left = 280
      fontName="Arial": fontSize=7
   END OBJECT      
   OBJECT lblDecP2 AS Label
      top = 212: left = 335
      fontName="Arial": fontSize=7
   END OBJECT      

END OBJECT
form.showModal

' ------------------------------------------------------------------------------
SUB Init()
   cmbInnerP1.ItemIndex=p1.bevelInner
   cmbOuterP1.ItemIndex=p1.bevelOuter
   cmbWidthP1.ItemIndex=p1.bevelWidth
   
   cmbInnerP2.ItemIndex=p2.bevelInner
   cmbOuterP2.ItemIndex=p2.bevelOuter
   cmbWidthP2.ItemIndex=p2.bevelWidth
   
   lblDecP1.caption=STR$(p1.color)
   lblHexP1.caption=separHex(p1.color)
   lblRgbP1.caption=decToRgb(p1.color)
   
   lblDecP2.caption=STR$(p2.color)
   lblHexP2.caption=separHex(p2.color)
   lblRgbP2.caption=decToRgb(p2.color)
 
END SUB

' ------------------------------------------------------------------------------
SUB innerP1Change()
   p1.bevelInner=cmbInnerP1.ItemIndex
END SUB
' ------------------------------------------------------------------------------
SUB outerP1Change()
   p1.bevelOuter=cmbOuterP1.ItemIndex
END SUB
' ------------------------------------------------------------------------------
SUB widthP1Change()
   p1.bevelWidth=cmbWidthP1.ItemIndex
END SUB
' ------------------------------------------------------------------------------
SUB colorP1Click()
   IF DLcolor.show=true THEN p1.color=DLcolor.color
   lblDecP1.caption=STR$(p1.color)
   lblHexP1.caption=separHex(p1.color)
   lblRgbP1.caption=decToRgb(p1.color)
END SUB

' ------------------------------------------------------------------------------
SUB innerP2Change()
   p2.bevelInner=cmbInnerP2.ItemIndex
END SUB
' ------------------------------------------------------------------------------
SUB outerP2Change()
   p2.bevelOuter=cmbOuterP2.ItemIndex
END SUB
' ------------------------------------------------------------------------------
SUB WidthP2Change()
   p2.bevelWidth=cmbWidthP2.ItemIndex
END SUB
' ------------------------------------------------------------------------------
SUB colorP2Click()
   IF DLcolor.show=true THEN p2.color=DLcolor.color
   lblDecP2.caption=STR$(p2.color)
   lblHexP2.caption=separHex(p2.color)
   lblRgbP2.caption=decToRgb(p2.color)
END SUB
' ------------------------------------------------------------------------------

FUNCTION separHex(number AS INTEGER) AS STRING
DIM txt AS STRING, i AS INTEGER

   txt = HEX$(number)
   IF LEN(txt) < 6 THEN txt = STRING$("0", 6-LEN(txt))+txt
   
   FOR i = 3 TO LEN(txt)*3 STEP 3 
      txt = INSERT$(txt," ",i)
   NEXT i
   
   Result = txt
       
END FUNCTION
' ------------------------------------------------------------------------------
FUNCTION decToRGB(number AS INTEGER) AS STRING
DIM R AS BYTE, G AS BYTE, B AS BYTE
   fragRGB(number,R,G,B)
   Result="("+STR$(R)+","+STR$(G)+","+STR$(B)+")"
END FUNCTION
' -------------------------------------
SUB fragRGB(ncolor AS INTEGER, R AS BYTE byAddress, G AS BYTE byAddress, B AS BYTE byAddress)
   B = FLOOR(ncolor/65536)
   G = FLOOR((ncolor MOD 65536)/256)
   R = ncolor - (B*65536) - (G * 256)
END SUB
' -------------------------------------
FUNCTION ConvertRGB(R AS BYTE, G AS BYTE, B AS BYTE) AS INTEGER
  Result = SHL(B,16) OR SHL(G,8) OR R
END FUNCTION
