## Improved Simple Gadgets Part 2

You can post your code snippets here for others to use and learn from
Redlion
Posts: 71
Joined: Sun Jul 10, 2011 5:05 am
Location: Perth, Western Australia

### Improved Simple Gadgets Part 2

Hi all,

Here are some of the gadget files. I will write some simple instructions and post them at the end.

(Save as G_Label.hws )

Code: Select all

``````; ************************************************************************************************
; GadgetLabel -  Text only gadget. Read, Write no Input.
; Gadget Type = 1
; By Leo den Hollander
; *************************************************************************************************

If Border = 0
SetFillStyle(#FILLCOLOR)
Box(x, y, w, h, ScreenC)
ElseIf Border = 1
SetFillStyle(#FILLCOLOR)
Box(x, y, w, h, BGC)
ElseIf Border = 2
SetFillStyle(#FILLCOLOR)
Box(x, y, w, h, #BLACK)
Box(x+1, y+1, w-2, h-2,BGC)
EndIf
SetFont(Font,Size)
SetFontColor(FGC)
TextOut(x+4,y+3,Text\$)
EndFunction
``````
(Save as G_String.hws )

Code: Select all

``````; ************************************************************************************************
; GadgetString -  String. Read, Write and Input.
; Gadget Type = 2
; By Leo den Hollander
; *************************************************************************************************

Function GadgetString(GID, x, y, w, h, Text\$)
SetFillStyle(#FILLCOLOR)
Box(x, y, w, h, #SILVER)
Box(x+2, y+2, w-4, h-4, #WHITE)
SetFillStyle(#FILLNONE)
Line(x+1, y+1, x+w-2, y+1, #BLACK)
Line(x+1, y+1, x+1, y+h-2, #BLACK)
Line(x+w-2, y+1, x+w-2, y+h-2, RGB(224,224,224))
Line(x+1, y+h-2, x+w-2, y+h-2, RGB(224,224,224))
TextOut(x+4, y+3, Text\$)
MakeButton(GID, #SIMPLEBUTTON, x, y, w, h, Gadget)
EndFunction
``````
( Save as G_Button.hws )

Code: Select all

``````; ************************************************************************************************
; Gadget Button - Input.
; Gadget Type = 3
; By Leo den Hollander
; *************************************************************************************************

Function GadgetButton(GID, x, y, w, h, Text\$)
SetLineWidth(1)
SetFillStyle(#FILLCOLOR)                                      ; Gadget bevel
Box(x, y, w, h, #SILVER)                                      ; Draw bevel
SetFillStyle(#FILLNONE)                                       ; BC fill drawing
Line(x+1, y+1, x+w-2, y+1,RGB(224,224,224))                   ; Inner bevel
Line(x+1, y+1, x+1, y+h-2,RGB(224,224,224))                   ; Inner bevel
Line(x+w-2, y+1, x+w-2, y+h-2, #BLACK)                        ; Inner bevel
Line(x+1, y+h-2, x+w-2, y+h-2, #BLACK)                        ; Gadget face
SetFont(Font,Size)                                            ; Font used on gadget face
Local TW = TextWidth(Text\$)                                   ; size of text on gadget face
Local BW =(w / 2) - (TW / 2)                                  ; Centre text position
Local TH = TextHeight(Text\$)                                  ; size of text on gadget face
Local BH =(h / 2) - (TH / 2)
SetFontColor(FGC)                                             ; Text colour
TextOut(x + BW,y + BH, Text\$)
MakeButton(GID, #SIMPLEBUTTON, x, y, w, h, Button)