#include <WinApi.au3>
#include <StructureConstants.au3>
#include <WindowsConstants.au3>


; #FUNCTION# ====================================================================================================================
; Name ..........: _SpinLabel_SetStyle
; Description ...:
; Syntax ........: _SpinLabel_SetStyle($Ctrl[, $Italic = False[, $Underline = False[, $Strike = False]]])
; Parameters ....: $Ctrl                - Control to change
;                  $Italic              - [optional]  Default is False.
;                  $Underline           - [optional]  Default is False.
;                  $Strike              - [optional]  Default is False.
; Return values .: None
; Author ........: minx
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _SpinLabel_SetStyle($Ctrl, $Italic=False, $Underline=False, $Strike=False)
	$Ctrl[8] = $Italic
	$Ctrl[9] = $Underline
	$Ctrl[10] = $Strike
	_SpinLabel_Create($Ctrl[0], $Ctrl[1], $Ctrl[2], $Ctrl[3], $Ctrl[4], $Ctrl[5], $Ctrl[6], $Ctrl[7], $Ctrl[8], $Ctrl[9], $Ctrl[10], $Ctrl[11], $Ctrl[12])
	Return $Ctrl
EndFunc

; #FUNCTION# ====================================================================================================================
; Name ..........: _SpinLabel_SetRotation
; Description ...:
; Syntax ........: _SpinLabel_SetRotation($Ctrl, $Angle)
; Parameters ....: $Ctrl                - Control to change
;                  $Angle               - Angle
; Return values .: None
; Author ........: minx
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _SpinLabel_SetRotation($Ctrl, $Angle)
	$Ctrl[5] = $Angle
	_SpinLabel_Create($Ctrl[0], $Ctrl[1], $Ctrl[2], $Ctrl[3], $Ctrl[4], $Ctrl[5], $Ctrl[6], $Ctrl[7], $Ctrl[8], $Ctrl[9], $Ctrl[10], $Ctrl[11], $Ctrl[12])
	Return $Ctrl
EndFunc

; #FUNCTION# ====================================================================================================================
; Name ..........: _SpinLabel_SetPos
; Description ...:
; Syntax ........: _SpinLabel_SetPos($Ctrl, $Left, $Top)
; Parameters ....: $Ctrl                - Control to change
;                  $Left                -
;                  $Top                 -
; Return values .: None
; Author ........: minx
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _SpinLabel_SetPos($Ctrl, $Left, $Top)
	$Ctrl[2] = $Left
	$Ctrl[3] = $Top
	_SpinLabel_Create($Ctrl[0], $Ctrl[1], $Ctrl[2], $Ctrl[3], $Ctrl[4], $Ctrl[5], $Ctrl[6], $Ctrl[7], $Ctrl[8], $Ctrl[9], $Ctrl[10], $Ctrl[11], $Ctrl[12])
	Return $Ctrl
EndFunc

; #FUNCTION# ====================================================================================================================
; Name ..........: _SpinLabel_SetBkColor
; Description ...:
; Syntax ........: _SpinLabel_SetBkColor($Ctrl, $Color)
; Parameters ....: $Ctrl                - Control to change
;                  $Color               - Backround Color
; Return values .: None
; Author ........: minx
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _SpinLabel_SetBkColor($Ctrl, $Color)
	$Ctrl[12] = $Color
	_SpinLabel_Create($Ctrl[0], $Ctrl[1], $Ctrl[2], $Ctrl[3], $Ctrl[4], $Ctrl[5], $Ctrl[6], $Ctrl[7], $Ctrl[8], $Ctrl[9], $Ctrl[10], $Ctrl[11], $Ctrl[12])
	Return $Ctrl
EndFunc

; #FUNCTION# ====================================================================================================================
; Name ..........: _SpinLabel_SetColor
; Description ...:
; Syntax ........: _SpinLabel_SetColor($Ctrl, $Color)
; Parameters ....: $Ctrl                - Control to change
;                  $Color               - Color
; Return values .: None
; Author ........: minx
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _SpinLabel_SetColor($Ctrl, $Color)
	$Ctrl[11] = $Color
	_SpinLabel_Create($Ctrl[0], $Ctrl[1], $Ctrl[2], $Ctrl[3], $Ctrl[4], $Ctrl[5], $Ctrl[6], $Ctrl[7], $Ctrl[8], $Ctrl[9], $Ctrl[10], $Ctrl[11], $Ctrl[12])
	Return $Ctrl
EndFunc

; #FUNCTION# ====================================================================================================================
; Name ..........: _SpinLabel_SetFont
; Description ...:
; Syntax ........: _SpinLabel_SetFont($Ctrl, $Size[, $Width = 400[, $Font = "Verdana"]])
; Parameters ....: $Ctrl                - Control to change
;                  $Size                - Fontsize
;                  $Width               - [optional]  Default is 400.
;                  $Font                - [optional]  Default is "Verdana".
; Return values .: None
; Author ........: minx
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _SpinLabel_SetFont($Ctrl, $Size, $Width=400, $Font="Verdana")
	$Ctrl[4] = $Size
	$Ctrl[7] = $Width
	$Ctrl[6] = $Font
	_SpinLabel_Create($Ctrl[0], $Ctrl[1], $Ctrl[2], $Ctrl[3], $Ctrl[4], $Ctrl[5], $Ctrl[6], $Ctrl[7], $Ctrl[8], $Ctrl[9], $Ctrl[10], $Ctrl[11], $Ctrl[12])
	Return $Ctrl
EndFunc

; #FUNCTION# ====================================================================================================================
; Name ..........: _SpinLabel_SetData
; Description ...:
; Syntax ........: _SpinLabel_SetData($Ctrl, $Data)
; Parameters ....: $Ctrl                - Control to change
;                  $Data                - New Data
; Return values .: None
; Author ........: minx
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _SpinLabel_SetData($Ctrl, $Data)
	$Ctrl[1] = $Data
	_SpinLabel_Create($Ctrl[0], $Ctrl[1], $Ctrl[2], $Ctrl[3], $Ctrl[4], $Ctrl[5], $Ctrl[6], $Ctrl[7], $Ctrl[8], $Ctrl[9], $Ctrl[10], $Ctrl[11], $Ctrl[12])
	Return $Ctrl
EndFunc

; #FUNCTION# ====================================================================================================================
; Name ..........: _SpinLabel_Create
; Description ...:
; Syntax ........: _SpinLabel_Create($hWnd, $Text, $Left, $Top, $Height, $Angle[, $Font = "Verdana"[, $Width = 400[, $Italic = False[,
;                  $Underline = False[, $Strike = False[, $TextColor = 0x000000[, $BkColor = 0xFFFFFF]]]]]]])
; Parameters ....: $hWnd                - A handle value.
;                  $Text                - Text
;                  $Left                - Left
;                  $Top                 - Top
;                  $Height              - Fontsize
;                  $Angle               - Rotation
;                  $Font                - [optional]  Default is "Verdana".
;                  $Width               - [optional]  Default is 400.
;                  $Italic              - [optional]  Default is False.
;                  $Underline           - [optional]  Default is False.
;                  $Strike              - [optional]  Default is False.
;                  $TextColor           - [optional]  Default is 0x000000.
;                  $BkColor             - [optional]  Default is 0xFFFFFF.
; Return values .: None
; Author ........: minx & BugFix
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _SpinLabel_Create($hWnd, $Text, $Left, $Top, $Height, $Angle, $Font="Verdana", $Width=400, $Italic=False, $Underline=False, $Strike=False, $TextColor=0x000000, $BkColor=0xFFFFFF)
	_WinAPI_RedrawWindow ($hWnd)
	 $tRect = DllStructCreate ($tagRECT)
	DllStructSetData ($tRect, 'Left', $Left)
    DllStructSetData ($tRect, 'Top', $Top)
	$RotateMe = DllStructCreate ($tagLOGFONT)
    DllStructSetData ($RotateMe, 'Escapement', $Angle * 10)
    DllStructSetData ($RotateMe, 'Height', ($Height * -20)/_WinAPI_TwipsPerPixelY())
    DllStructSetData ($RotateMe, 'Weight', $Width)
    DllStructSetData ($RotateMe, 'Italic', $Italic)
	DllStructSetData ($RotateMe, 'Underline', $Underline)
	DllStructSetData ($RotateMe, 'StrikeOut', $Strike)
    DllStructSetData ($RotateMe, 'FaceName', $Font)
	$rFont = _WinAPI_CreateFontIndirect ($RotateMe)
	$hDC = _WinAPI_GetDC ($hWnd)
	_WinAPI_SetTextColor ($hDC, $TextColor)
    _WinAPI_SetBkColor ($hDC, $BkColor)
	_WinAPI_SelectObject ($hdc, $rFont)
	_WinAPI_DrawText ($hDC, $Text, $tRect, BitOR ($DT_NOCLIP,$DT_NOPREFIX))
	_WinAPI_ReleaseDC ($hWnd, $hDC)
	Dim $aReturn[13] = [$hWnd, $Text, $Left, $Top, $Height, $Angle, $Font, $Width, $Italic, $Underline, $Strike, $TextColor, $BkColor]
	Return $aReturn
EndFunc