File: w_main.srw
Size: 10755
Date: Tue, 14 May 2019 06:41:58 +0200
$PBExportHeader$w_main.srw
forward
global type w_main from window
end type
type sle_hexvalues from singlelineedit within w_main
end type
type sle_rgbvalues from singlelineedit within w_main
end type
type sle_colorcode from singlelineedit within w_main
end type
type st_6 from statictext within w_main
end type
type st_5 from statictext within w_main
end type
type st_4 from statictext within w_main
end type
type st_3 from statictext within w_main
end type
type dw_crayolacolors from datawindow within w_main
end type
type st_2 from statictext within w_main
end type
type dw_webcolors from datawindow within w_main
end type
type st_1 from statictext within w_main
end type
type cb_cancel from commandbutton within w_main
end type
type dw_pbcolors from datawindow within w_main
end type
end forward

global type w_main from window
integer width = 3342
integer height = 2028
boolean titlebar = true
string title = "Color Functions"
boolean controlmenu = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
sle_hexvalues sle_hexvalues
sle_rgbvalues sle_rgbvalues
sle_colorcode sle_colorcode
st_6 st_6
st_5 st_5
st_4 st_4
st_3 st_3
dw_crayolacolors dw_crayolacolors
st_2 st_2
dw_webcolors dw_webcolors
st_1 st_1
cb_cancel cb_cancel
dw_pbcolors dw_pbcolors
end type
global w_main w_main

forward prototypes
public subroutine wf_splitrgb (long al_color, ref unsignedinteger aui_red, ref unsignedinteger aui_green, ref unsignedinteger aui_blue)
public function string wf_nbr2hex (unsignedlong aul_number, integer ai_digit)
end prototypes

public subroutine wf_splitrgb (long al_color, ref unsignedinteger aui_red, ref unsignedinteger aui_green, ref unsignedinteger aui_blue);// This function splits color into Red/Green/Blue.

aui_blue  = (al_color / 65536)
aui_green = (al_color - (aui_blue * 65536)) / 256
aui_red   = (al_color - (aui_blue * 65536) - (aui_green * 256))

end subroutine

public function string wf_nbr2hex (unsignedlong aul_number, integer ai_digit);// This function converts a number to a hex string.

ULong lul_temp0, lul_temp1
Char lc_ret

If ai_digit > 0 Then
   lul_temp0 = Abs(aul_number / (16 ^ (ai_digit - 1)))
   lul_temp1 = lul_temp0 * (16 ^ (ai_digit - 1))
   If lul_temp0 > 9 Then
      lc_ret = Char(lul_temp0 + 55)
   Else
      lc_ret = Char(lul_temp0 + 48)
   End If
   Return lc_ret + wf_Nbr2Hex(aul_number - lul_temp1, ai_digit - 1)
End If

Return ""

end function

on w_main.create
this.sle_hexvalues=create sle_hexvalues
this.sle_rgbvalues=create sle_rgbvalues
this.sle_colorcode=create sle_colorcode
this.st_6=create st_6
this.st_5=create st_5
this.st_4=create st_4
this.st_3=create st_3
this.dw_crayolacolors=create dw_crayolacolors
this.st_2=create st_2
this.dw_webcolors=create dw_webcolors
this.st_1=create st_1
this.cb_cancel=create cb_cancel
this.dw_pbcolors=create dw_pbcolors
this.Control[]={this.sle_hexvalues,&
this.sle_rgbvalues,&
this.sle_colorcode,&
this.st_6,&
this.st_5,&
this.st_4,&
this.st_3,&
this.dw_crayolacolors,&
this.st_2,&
this.dw_webcolors,&
this.st_1,&
this.cb_cancel,&
this.dw_pbcolors}
end on

on w_main.destroy
destroy(this.sle_hexvalues)
destroy(this.sle_rgbvalues)
destroy(this.sle_colorcode)
destroy(this.st_6)
destroy(this.st_5)
destroy(this.st_4)
destroy(this.st_3)
destroy(this.dw_crayolacolors)
destroy(this.st_2)
destroy(this.dw_webcolors)
destroy(this.st_1)
destroy(this.cb_cancel)
destroy(this.dw_pbcolors)
end on

type sle_hexvalues from singlelineedit within w_main
integer x = 1938
integer y = 1824
integer width = 334
integer height = 68
integer taborder = 60
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long backcolor = 67108864
boolean displayonly = true
borderstyle borderstyle = stylelowered!
end type

type sle_rgbvalues from singlelineedit within w_main
integer x = 1170
integer y = 1824
integer width = 334
integer height = 68
integer taborder = 50
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long backcolor = 67108864
boolean displayonly = true
borderstyle borderstyle = stylelowered!
end type

type sle_colorcode from singlelineedit within w_main
integer x = 402
integer y = 1824
integer width = 334
integer height = 68
integer taborder = 40
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
long backcolor = 67108864
boolean displayonly = true
borderstyle borderstyle = stylelowered!
end type

type st_6 from statictext within w_main
integer x = 1573
integer y = 1828
integer width = 334
integer height = 60
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "HEX Values:"
boolean focusrectangle = false
end type

type st_5 from statictext within w_main
integer x = 805
integer y = 1828
integer width = 334
integer height = 60
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "RGB Values:"
boolean focusrectangle = false
end type

type st_4 from statictext within w_main
integer x = 37
integer y = 1828
integer width = 334
integer height = 60
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Color Code:"
boolean focusrectangle = false
end type

type st_3 from statictext within w_main
integer x = 2231
integer y = 32
integer width = 663
integer height = 68
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "120 Crayola Colors:"
boolean focusrectangle = false
end type

type dw_crayolacolors from datawindow within w_main
integer x = 2231
integer y = 116
integer width = 1029
integer height = 1616
integer taborder = 30
string title = "none"
string dataobject = "d_crayolacolors"
boolean vscrollbar = true
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type

event constructor;this.SetRowFocusIndicator(Hand!)
this.Event RowFocusChanged(this.GetRow())

end event

event rowfocuschanged;UInt li_red, li_green, li_blue
Long ll_color
String ls_colorname, ls_hexcolor

ls_colorname = this.GetItemString(currentrow, "color_name")

ll_color = f_getcrayolacolor(ls_colorname)

wf_SplitRGB(ll_color, li_red, li_green, li_blue)

ls_hexcolor  = wf_nbr2hex(li_red, 2)
ls_hexcolor += wf_nbr2hex(li_green, 2)
ls_hexcolor += wf_nbr2hex(li_blue, 2)

sle_colorcode.text = String(ll_color)
sle_rgbvalues.text = String(li_red) + "," + String(li_green) + "," + String(li_blue)
sle_hexvalues.text = "#" + ls_hexcolor

end event

type st_2 from statictext within w_main
integer x = 1134
integer y = 32
integer width = 663
integer height = 68
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "140 Web Colors:"
boolean focusrectangle = false
end type

type dw_webcolors from datawindow within w_main
integer x = 1134
integer y = 116
integer width = 1029
integer height = 1616
integer taborder = 20
string title = "none"
string dataobject = "d_webcolors"
boolean vscrollbar = true
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type

event constructor;this.SetRowFocusIndicator(Hand!)
this.Event RowFocusChanged(this.GetRow())

end event

event rowfocuschanged;UInt li_red, li_green, li_blue
Long ll_color
String ls_colorname, ls_hexcolor

ls_colorname = this.GetItemString(currentrow, "color_name")

ll_color = f_getwebcolor(ls_colorname)

wf_SplitRGB(ll_color, li_red, li_green, li_blue)

ls_hexcolor  = wf_nbr2hex(li_red, 2)
ls_hexcolor += wf_nbr2hex(li_green, 2)
ls_hexcolor += wf_nbr2hex(li_blue, 2)

sle_colorcode.text = String(ll_color)
sle_rgbvalues.text = String(li_red) + "," + String(li_green) + "," + String(li_blue)
sle_hexvalues.text = "#" + ls_hexcolor

end event

type st_1 from statictext within w_main
integer x = 37
integer y = 32
integer width = 663
integer height = 68
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "52 PowerBuilder Colors:"
boolean focusrectangle = false
end type

type cb_cancel from commandbutton within w_main
integer x = 2926
integer y = 1792
integer width = 334
integer height = 100
integer taborder = 70
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "Cancel"
boolean cancel = true
end type

event clicked;Close(Parent)

end event

type dw_pbcolors from datawindow within w_main
integer x = 37
integer y = 116
integer width = 1029
integer height = 1616
integer taborder = 10
string title = "none"
string dataobject = "d_pbcolors"
boolean vscrollbar = true
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type

event constructor;this.SetRowFocusIndicator(Hand!)
this.Event RowFocusChanged(this.GetRow())

end event

event rowfocuschanged;UInt li_red, li_green, li_blue
Long ll_color
String ls_colorname, ls_hexcolor

ls_colorname = this.GetItemString(currentrow, "color_name")

ll_color = f_getpbcolor(ls_colorname)

wf_SplitRGB(ll_color, li_red, li_green, li_blue)

ls_hexcolor  = wf_nbr2hex(li_red, 2)
ls_hexcolor += wf_nbr2hex(li_green, 2)
ls_hexcolor += wf_nbr2hex(li_blue, 2)

sle_colorcode.text = String(ll_color)
sle_rgbvalues.text = String(li_red) + "," + String(li_green) + "," + String(li_blue)
sle_hexvalues.text = "#" + ls_hexcolor

end event