#include-once #include #Include #include #include ;~ $__g_hGDIPDll ; #INDEX# ======================================================================================================================= ; Title .........: _Button ; AutoIt Version : 3.3.12.0 ; Language ......: English, maybe ; Description ...: Buttons as I like. ; Author ........: Marco Ferrario (OneWay) ; Version .......: 1.0 ; Thanks ........: GDIPlus's authors and all those who implemented it ; Thanks ........: Yashied for Icons ; Big Thanks ....: Jonathan Bennett & AutoIt Team & whole community of Autoit ; Dll ...........: Shell32.dll ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ; _GDICreate_Button ; _GDIPush_Button ; _GDIFlash_ON ; _GDIButton_OFF ; =============================================================================================================================== ; #INTERNAL_USE_ONLY# =========================================================================================================== ; _GDIText ; _GDIIcon ; _GDIColor_Button ; _GDIButton_ON ; _GDIButton_OFF ; =============================================================================================================================== ; #FUNCTION# ;=================================================================================================================== ; Name...........: _GDICreate_Button ; Description ...: Creates a graphic object which contains a label and a iconcontrols, and preps the 'border array' ; Syntax.........: _GDICreate_Button($WGUI, $FCtr, $Type, $BHandle, $FApp, $FTxt, $FIco) ; Parameters ....: $WGUI - Window which contains the Buttons ; $FCtr - Array Button Object ; $Type - Name of Button Style ; $BHandle - Graphic Handler ; $FApp - Array Color On/Off ; $FTxt - Array Text Object ; $FIco - Array Icon Object ; Return values .: Array - See _ArrayDisplay ; Author ........: Marco Ferrario (OneWay) ; =========================================================================================== func _GDICreate_Button($WGUI, $FCtr, $Type, $BHandle, $FApp, $FTxt, $FIco);, $BW, $BH $Obj = GUICtrlCreatePic('', $FCtr[3], $FCtr[4], $FCtr[5], $FCtr[6]) $CLR=_GDIColor_Button($FApp[2]);$ColOFF) Local $AARR[5][11] = [[$Obj,$FCtr[2],$FCtr[3], $FCtr[4], $FCtr[5], $FCtr[6]],[$FTxt[1],$FTxt[2],$FTxt[3],$FTxt[4],$FTxt[5],$FTxt[6],$FTxt[7],$FTxt[8],$FTxt[9],$FTxt[10],$FTxt[11]],[$FApp[1],$FApp[2],$FApp[3]],[$FIco[1],$FIco[2],$FIco[3],$FIco[4]],[$WGUI,$Type,$BHandle]];,$BW,$BH Return _GDIButton_ON($AARR, $CLR) EndFunc ; #FUNCTION# ;=============================================================================== ; Name...........: _GDIText ; Description ...: Creates a Text object ; Syntax.........: _GDIText($Obj, $N = 0) ; Parameters ....: $Obj - Array Object ; $N - 0 Enable / 1 Disable Flash ; Author ........: Marco Ferrario (OneWay) ; =========================================================================================== func _GDIText($Obj, $N = 0);, $NewTxt = '', $NewDim = '', $NewFnt = '', $NewStl = '', $NewCol = '') $XI=$Obj[0][2] $YI=$Obj[0][3] $XF=$Obj[0][2]+$Obj[0][4] $YF=$Obj[0][3]+$Obj[0][5] $TTX=$Obj[1][0] $DTX=$Obj[1][3] $FTX=$Obj[1][5] $STX=$Obj[1][4] $CTX=$Obj[1][2] if $N=1 And $Obj[1][6] <> '' then $TTX=$Obj[1][6] if $N=1 And $Obj[1][8] <> '' then $DTX=$Obj[1][8] if $N=1 And $Obj[1][10] <> '' then $FTX=$Obj[1][10] if $N=1 And $Obj[1][9] <> '' then $STX=$Obj[1][9] if $N=1 And $Obj[1][7] <> '' then $CTX=$Obj[1][7] Local $hBrush = _GDIPlus_BrushCreateSolid('0xFF' & $CTX) Local $hFamily = _GDIPlus_FontFamilyCreate($FTX) ;"Arial") Local $hFont = _GDIPlus_FontCreate($hFamily, $DTX, $STX) ;12, 800=1) $BPosTxt=$Obj[1][1] ;~ if $BPosTxt = 0 then ;Centro ;~ $XI = $XI ;~ $YI = $YI ;~ EndIf if $BPosTxt = 1 then ;Destra $XI = $XI-$Obj[0][4] $YI = $YI EndIf if $BPosTxt = 2 then ;Sinistra $XI = $XI+$Obj[0][4] $YI = $YI EndIf if $BPosTxt = 3 then ;Sopra $XI = $XI $YI = $YI-20 EndIf if $BPosTxt = 4 then ;Sotto $XI = $XI $YI = $YI+$Obj[0][5]+20 EndIf Local $hLayout = _GDIPlus_RectFCreate($XI, $YI, $Obj[0][4], $Obj[0][5]) ;$Wdith, $Height) ;~ Local $hLayout = _GDIPlus_RectFCreate($XI, $YI, $Obj[0][4], $Obj[0][5]) ;$Wdith, $Height) Local $hStringFormat = _GDIPlus_StringFormatCreate(0x0800) _GDIPlus_StringFormatSetAlign($hStringFormat, 1) _GDIPlus_StringFormatSetLineAlign($hStringFormat, 1) _GDIPlus_GraphicsDrawStringEx($hGraphic, $TTX, $hFont, $hLayout, $hStringFormat, $hBrush) _GDIPlus_BrushDispose($hBrush) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_StringFormatDispose($hStringFormat) EndFunc ; #FUNCTION# ;=============================================================================== ; Name...........: _GDIIcon ; Description ...: Creates a Icon object ; Syntax.........: _GDIIcon($Obj, $N = 0) ; Parameters ....: $Obj - Array Object ; $N - 0 Enable / 1 Disable Flash ; Author ........: Marco Ferrario (OneWay) ; =========================================================================================== func _GDIIcon($Obj, $N = 0);, $NewIco = '', $NewDim = '') $XI=$Obj[0][2] $YI=$Obj[0][3] $XF=$Obj[0][2]+$Obj[0][4] $YF=$Obj[0][3]+$Obj[0][5] $NIC=$Obj[3][0] $DIC=$Obj[3][1] if $N=1 And $Obj[3][2] <> '' then $NIC=$Obj[3][2] if $N=1 And $Obj[3][3] <> '' then $DIC=$Obj[3][3] $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', $NIC, $DIC, $DIC);32 $hBitIcon = _GDIPlus_BitmapCreateFromHICON32($hIcon) _GDIPlus_GraphicsDrawImage ($hGraphic, $hBitIcon, ($XF+$XI)/2-$DIC/2, ($YF+$YI)/2-$DIC/2 ) _WinAPI_DestroyIcon($hIcon) _GDIPlus_BitmapDispose($hBitIcon) EndFunc Func _GDIColor_Button($Color) $RU=Dec(StringMid(hex($Color),3,2)) $GU=Dec(StringMid(hex($Color),5,2)) $BU=Dec(StringMid(hex($Color),7,2)) $left_color=StringSplit('255|255|255', '|') $Mid_color = StringSplit($RU & '|' & $GU & '|' & $BU, '|') $right_color=StringSplit('0|0|0', '|') $MaxY = 5 $Col='' $color1=($left_color[1]-$Mid_color[1])/($MaxY) $color2=($left_color[2]-$Mid_color[2])/($MaxY) $color3=($left_color[3]-$Mid_color[3])/($MaxY) For $Y=1 to $MaxY $red=StringRight(hex(floor($left_color[1]-($Y*$color1))),2) $green=StringRight(hex(floor($left_color[2]-($Y*$color2))),2) $blue=StringRight(hex(floor($left_color[3]-($Y*$color3))),2) $Col &= $red & $green & $blue & '|' next $color1=($Mid_color[1]-$right_color[1])/($MaxY) $color2=($Mid_color[2]-$right_color[2])/($MaxY) $color3=($Mid_color[3]-$right_color[3])/($MaxY) For $Y=1 to $MaxY $red=StringRight(hex(floor($Mid_color[1]-($Y*$color1))),2) $green=StringRight(hex(floor($Mid_color[2]-($Y*$color2))),2) $blue=StringRight(hex(floor($Mid_color[3]-($Y*$color3))),2) $Col &= $red & $green & $blue & '|' next Return StringSplit($Col, '|') EndFunc Func _GDIFlash_ON($Obj) $RU=Dec(StringMid(hex($Obj[2][1]),3,2))+30 ;-30 $GU=Dec(StringMid(hex($Obj[2][1]),5,2))+30 ;+30 $BU=Dec(StringMid(hex($Obj[2][1]),7,2))+30 ;+30 IF $RU <0 THEN $RU=0 IF $RU >255 THEN $RU=255 IF $GU <0 THEN $GU=0 IF $GU >255 THEN $GU=255 IF $BU <0 THEN $BU=0 IF $BU >255 THEN $BU=255 $Col = '0x' & StringRight(hex(int($RU)),2) & StringRight(hex(int($GU)),2) & StringRight(hex(int($BU)),2) $CLR=_GDIColor_Button($Col) #Corpo Call($Obj[4][1] & '_ON', $Obj, $CLR) #Icon _GDIIcon($Obj, 1);, 135, '') #Text ;~ _GDITxt($Obj, $NewTxt = '', $NewDim = '', $NewFnt = '', $NewStl = '', $NewCol = '') _GDIText($Obj, 1);, '', '12', '', 1, 'FF0000') _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) ; Draw bitmap to GUI (graphics). EndFunc Func _GDIFlash_OFF($Obj);, $hContext) $CLR=_GDIColor_Button($Obj[2][1]) #Corpo Call($Obj[4][1] & '_ON', $Obj, $CLR) #Icon _GDIIcon($Obj) #Text _GDIText($Obj) _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) ; Draw bitmap to GUI (graphics). EndFunc Func _GDIPush_Button($Obj);, $hContext) ;~ $_Butt_GUI = $WGUI if StringUpper($Obj[2][0])="ON" then $CLR=_GDIColor_Button($Obj[2][1]) $TmpX = _GDIButton_ON($Obj, $CLR) endif if StringUpper($Obj[2][0])="OFF" Then $CLR=_GDIColor_Button($Obj[2][2]) $TmpX = _GDIButton_OFF($Obj, $CLR) endif ;~ $PP = ControlGetPos ($_Butt_GUI, "", GUICtrlGetHandle($Tmp[2]));$ButtX)) _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) ; Draw bitmap to GUI (graphics). Return $TmpX EndFunc Func _GDIButton_ON($Obj, $CLR) #Corpo Call($Obj[4][1] & '_ON', $Obj, $CLR) #Immagine ;~ $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Torus.png") ;load a transparent PNG image which should be placed on the bitmap ;~ _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, $XI, $YI, 50, 50) ;copy the image onto the bitmap. if image dimension <> bitmap dimension than the image will be displayed deformed ;~ _GDIPlus_ImageDispose($hImage) ;release image #Icon _GDIIcon($Obj) #Text ;~ _GDITxt($Obj, $NewTxt = '', $NewDim = '', $NewFnt = '', $NewStl = '', $NewCol = '') _GDIText($Obj) $Obj[2][0]='OFF' return $Obj EndFunc Func _GDIButton_OFF($Obj, $CLR) #Corpo Call($Obj[4][1] & '_OFF', $Obj, $CLR) #Immagine ;~ $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Torus.png") ;load a transparent PNG image which should be placed on the bitmap ;~ _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, $XI, $YI, 50, 50) ;copy the image onto the bitmap. if image dimension <> bitmap dimension than the image will be displayed deformed ;~ _GDIPlus_ImageDispose($hImage) ;release image #Icon _GDIIcon($Obj) #Text _GDIText($Obj);, 'STOCA', '12', '', 1, 'FF0000') $Obj[2][0]='ON' return $Obj EndFunc