;###########################################################
;# (sinnlose) UDF um mit Controls zu zeichnen               #
;# In diesem Skript sind Funktionen & Das Beispiel am GUI   #
;# by campweb                                               #
;###########################################################

;INCLUDES###################################################
#include <ButtonConstants.au3>                            ;# 
#include <GUIConstantsEx.au3>                             ;#
#include <WindowsConstants.au3>                           ;#
;INCLUDES###################################################

; HINWEIS ZUM BEISPIELGUI###################################
MsgBox(0, "ControlPen UDF", "Zur Demonstration sind alle Pens auf Blau gestellt! Möchtest du einen anderen Pen, das Programm neustarten!")

;BEISPIELFARBDEFINITION, KÖNNEN AUCH MEHR SEIN!#############
$Blau = 0x0000FF
$Rot = 0xFF0000
$Gelb = 0xFFFF00

;AUFRUF DES TESTGUI´S#######################################
test()

;TESTGUIFUNKTION############################################
Func test()
$Form1 = GUICreate("ControlPen UDF by campweb", 725, 443, 0, 0)
$btn1 = GUICtrlCreateButton("Square", 640, 5, 80, 21)
$btn2 = GUICtrlCreateButton("DeepSquare|0", 640, 31, 80, 21)
$btn3 = GUICtrlCreateButton("Ellipse", 640, 56, 80, 21)
$btn4 = GUICtrlCreateButton("RoundSquare", 640, 81, 80, 21)
$btn5 = GUICtrlCreateButton("BorderSquare", 640, 106, 80, 21)
$btn6 = GUICtrlCreateButton("DeepSquare|1", 640, 131, 80, 21)
GUISetState(@SW_SHOW)

While 1
	$msg = GUIGetMsg()
	Switch $msg
		Case $btn1
			Pen_Square($Blau)
		Case $btn2
			Pen_DeepSquare($Blau, 0)
		Case $btn3
			Pen_Ellipse($Blau)
		Case $btn4
			Pen_RoundSquare($Blau)
		Case $btn5
			Pen_BorderSquare($Blau)
		Case $btn6
			Pen_DeepSquare($Blau, 1)
	EndSwitch
WEnd
EndFunc ;=> TESTGUI

;##########################################################################################################
;;#############################################Funktionen##################################################
;##########################################################################################################

;###########################################################
; Funktion zum Zeichnen mit Buttons
; $Farbe = Vordefinierte Farben oder Codes
; $x1, $y1, $x2, $y2 Sind die Koordinaten der Zeichenfläche
Func Pen_RoundSquare($Farbe, $x1 = 0, $y1 = 625, $x2 = 0, $y2 = 443)
While 1
	If GUIGetMsg() = $GUI_EVENT_CLOSE Then
		Exit
	EndIf
	If MouseGetPos(0) > $x1 and MouseGetPos(0) < $y1 and MouseGetPos(1) > $x2 and MouseGetPos(1) < $y2 Then
		GUICtrlCreateButton("", MouseGetPos(0), MouseGetPos(1), 14, 14)
		GUICtrlSetBkColor(-1, $Farbe)
	Else
		MouseGetPos(1)
	EndIf
WEnd
EndFunc
;###########################################################


;###########################################################
; Funktion zum Zeichnen mit Checkboxen die Erste
; $Farbe = Vordefinierte Farben oder Codes
; $x1, $y1, $x2, $y2 Sind die Koordinaten der Zeichenfläche
; $Checked = gehackt oder nicht?
Func Pen_DeepSquare($Farbe, $Checked = 1, $x1 = 0, $y1 = 625, $x2 = 0, $y2 = 443)
While 1
	If GUIGetMsg() = $GUI_EVENT_CLOSE Then
		Exit
	EndIf
	If MouseGetPos(0) > $x1 and MouseGetPos(0) < $y1 and MouseGetPos(1) > $x2 and MouseGetPos(1) < $y2 Then
		GUICtrlCreateCheckbox("", MouseGetPos(0), MouseGetPos(1), 14, 14)
		GUICtrlSetBkColor(-1, $Farbe)
		If $Checked = 1 Then
			GUICtrlSetState(-1, $GUI_CHECKED)
		EndIf
	Else
		MouseGetPos(1)
	EndIf
WEnd
EndFunc
;###########################################################

;###########################################################
; Funktion zum Zeichnen mit Radio´s
; $Farbe = Vordefinierte Farben oder Codes
; $x1, $y1, $x2, $y2 Sind die Koordinaten der Zeichenfläche
Func Pen_Ellipse($Farbe, $x1 = 0, $y1 = 625, $x2 = 0, $y2 = 443); Farbiges Rechteck mit weißem Kreis :D
While 1
	If GUIGetMsg() = $GUI_EVENT_CLOSE Then
		Exit
	EndIf
	If MouseGetPos(0) > $x1 and MouseGetPos(0) < $y1 and MouseGetPos(1) > $x2 and MouseGetPos(1) < $y2 Then
		GUICtrlCreateRadio("", MouseGetPos(0), MouseGetPos(1), 14, 14)
		GUICtrlSetBkColor(-1, $Farbe)
	Else
		MouseGetPos(1)
	EndIf
WEnd
EndFunc
;###########################################################

;###########################################################
; Funktion zum Zeichnen mit Edit´s :D
; $Farbe = Vordefinierte Farben oder Codes
; $x1, $y1, $x2, $y2 Sind die Koordinaten der Zeichenfläche
Func Pen_Square($Farbe, $x1 = 0, $y1 = 625, $x2 = 0, $y2 = 443); Quadrat ohne Umrandung
While 1
	If GUIGetMsg() = $GUI_EVENT_CLOSE Then
		Exit
	EndIf
	If MouseGetPos(0) > $x1 and MouseGetPos(0) < $y1 and MouseGetPos(1) > $x2 and MouseGetPos(1) < $y2 Then
		GUICtrlCreateEdit("", MouseGetPos(0), MouseGetPos(1), 14, 14)
		GUICtrlSetBkColor(-1, $Farbe)
	Else
		MouseGetPos(1)
	EndIf
WEnd
EndFunc
;###########################################################

;###########################################################
; Funktion zum Zeichnen mit ListView´s (Der da oben weiß warum! :D)
; $Farbe = Vordefinierte Farben oder Codes
; $x1, $y1, $x2, $y2 Sind die Koordinaten der Zeichenfläche
Func Pen_BorderSquare($Farbe, $x1 = 0, $y1 = 625, $x2 = 0, $y2 = 443); Quadrat mit Umrandung
While 1
	If GUIGetMsg() = $GUI_EVENT_CLOSE Then
		Exit
	EndIf
	If MouseGetPos(0) > $x1 and MouseGetPos(0) < $y1 and MouseGetPos(1) > $x2 and MouseGetPos(1) < $y2 Then
		GUICtrlCreatelistView("", MouseGetPos(0), MouseGetPos(1), 14, 14)
		GUICtrlSetBkColor(-1, $Farbe)
	Else
		MouseGetPos(1)
	EndIf
WEnd
EndFunc
;###########################################################