Here is how you would go about adding your other controls.
Code: Select all
;****************************************************************************************************************************************************************************
#Include <GDIP_All> ;<<<<<<<<<<<<<<<<<<--------------------------- gdip.ahk
;~ #Include <Gen 3 Buttons> ;***At The Bottom Of The Script*** - https://www.autohotkey.com/boards/viewtopic.php?f=6&t=88153&p=395985
;****************************************************************************************************************************************************************************
#SingleInstance, Force
SetBatchLines, -1
Gdip_Startup()
Gui, margin, 0,0
Gui, Add, ActiveX, x250 y250 w400 h400 vWB1, HTMLfile
WB1.write(HTML())
w := 900 , h := 900
;____________________________________________________________________________
;Custom Buttons / Controls. ~~~ Replace these controls with your other controls
Gui, Font, s16
Gui, Add, DDL, x260 y670 w380 r10 , Item||Item|Item|Item|Item|Item|Item|Item|Item|Item|Item|Item|
Gui, Add, CheckBox, x260 y+20, Check
Theme1 := HBCustomButton()
GuiButtonType1.SetSessionDefaults( Theme1.All , Theme1.Default , Theme1.Hover , Theme1.Pressed )
BackButton := New HButton( { Owner: 1 , X: x := 260 , Y: 250 + 400 + 10 + 100 , W: 120 , H: 55 , Text: "Back" , Label: "TestFunction" } , { BackgroundColor: "0xFFF0F0F0" } )
CancelButton := New HButton( { Owner: 1 , X: x += 130 , Y: 250 + 400 + 10 + 100 , W: 120 , H: 55 , Text: "Cancel" , Label: "TestFunction" } , { BackgroundColor: "0xFFF0F0F0" } )
OkButton := New HButton( { Owner: 1 , X: x += 130 , Y: 250 + 400 + 10 + 100 , W: 120 , H: 55 , Text: "OK" , Label: "TestFunction" } , { BackgroundColor: "0xFFF0F0F0" } )
;____________________________________________________________________________
;Add BG Pic Control ( +0x4000000 = Cut a hole for the controls added before this control )
Gui, Add, Pic, x0 y0 w%w% h%h% hwndPicHwnd 0xE +0x4000000
BG_ART( PicHwnd , w , h )
Gui, show, w%w% h%h%
SetTimer, Change , 1000
return
GuiClose:
GuiContextMenu:
*ESC::ExitApp
Change:
BG_ART( PicHwnd , w , h )
return
;Button press
TestFunction:
SoundBeep
return
BG_ART( hwnd , w := 900 , h := 900 ){
static tog , index := 0
tog := !tog
pBitmap := Gdip_CreateBitmap( w , h )
G := Gdip_GraphicsFromImage(pBitmap)
Gdip_SetSmoothingMode(G, 4)
Brush1 := Gdip_BrushCreateSolid( ( tog ) ? ( "0x99cc00cc" ) : ( "0x99aa00aa" ) )
Gdip_FillRectangle(G, Brush1, 0, 0, 900, 450)
Gdip_DeleteBrush( Brush1 )
Brush2 := Gdip_BrushCreateSolid( ( tog ) ? ( "0x9900cc00" ) : ( "0x9900aa00" ) )
Gdip_FillRectangle(G, Brush2, 0, 450, 900, 450)
Gdip_DeleteBrush( Brush2 )
Brush3 := Gdip_BrushCreateSolid( "0xFFF0F0F0" )
Gdip_FillRoundedRectangle( G, Brush3, 250 , 250 + 400 + 5 , 400 , 165 , 10 )
;~ Gdip_FillRectangle(G, Brush3, 250 , 250 + 400 + 5 , 400 , 65 )
Gdip_DeleteBrush( Brush3 )
;____________________________________________________________________________
;Text
DrawText( G , 11 , 11 , ++index , "0xFF000000" , 300 , 150 , options := " Center vCenter Bold s132 " , type := "comic Sans MS" )
DrawText( G , 10 , 10 , index , "0xFFFFFFFF" , 300 , 150 , options := " Center vCenter Bold s132 " , type := "comic Sans MS" )
;____________________________________________________________________________
;Display Image and Cleanup
Gdip_DeleteGraphics( G )
hBitmap := Gdip_CreatehBitmapFromBitmap( pBitmap )
Gdip_DisposeImage( pBitmap )
SetImage( hwnd , hBitmap )
DeleteObject( hBitmap )
}
HTML(){
HTML_page =
(
<!DOCTYPE html><html lang='en'><head><meta charset='utf-8'/>
<style>body {font-family: sans-serif; background-color: yellow}</style></head>
<body><h1>Hello World</h1></body>
</html>
)
return HTML_page
}
DrawText( G , x , y , text , color , width , height , options := " Center vCenter Bold s12 " , type := "comic Sans MS" ){
Brush := Gdip_BrushCreateSolid( color ) , Gdip_TextToGraphics( G , text , options " c" brush " x" x " y" y , type , width , height ) , Gdip_DeleteBrush( Brush )
}
HBCustomButton(){
local MyButtonDesign := {}
MyButtonDesign.All := {}
MyButtonDesign.Default := {}
MyButtonDesign.Hover := {}
MyButtonDesign.Pressed := {}
;********************************
;All
MyButtonDesign.All.W := 100 , MyButtonDesign.All.H := 40 , MyButtonDesign.All.Text := "Go" , MyButtonDesign.All.BackgroundColor := "0xFFffffff" , MyButtonDesign.All.ButtonAddGlossy := "0"
;********************************
;Default
MyButtonDesign.Default.W := 100 , MyButtonDesign.Default.H := 40 , MyButtonDesign.Default.Text := "Go" , MyButtonDesign.Default.Font := "Arial" , MyButtonDesign.Default.FontOptions := " Bold Center vCenter " , MyButtonDesign.Default.FontSize := "12" , MyButtonDesign.Default.H := "0x0002112F" , MyButtonDesign.Default.TextBottomColor2 := "0x0002112F" , MyButtonDesign.Default.TextTopColor1 := "0xFF32363a" , MyButtonDesign.Default.TextTopColor2 := "0xFFFFFFFF" , MyButtonDesign.Default.TextOffsetX := "0" , MyButtonDesign.Default.TextOffsetY := "0" , MyButtonDesign.Default.TextOffsetW := "0" , MyButtonDesign.Default.TextOffsetH := "0" , MyButtonDesign.Default.BackgroundColor := "0xFFffffff" , MyButtonDesign.Default.ButtonOuterBorderColor := "0xFFc2c6ca" , MyButtonDesign.Default.ButtonCenterBorderColor := "0xFF72767a" , MyButtonDesign.Default.ButtonInnerBorderColor1 := "0xFFFFFFFF" , MyButtonDesign.Default.ButtonInnerBorderColor2 := "0xFFF0F0F0" , MyButtonDesign.Default.ButtonMainColor1 := "0xFFffffff" , MyButtonDesign.Default.ButtonMainColor2 := "0xFFc2c6ca" , MyButtonDesign.Default.ButtonAddGlossy := "0" , MyButtonDesign.Default.GlossTopColor := "0x11FFFFFF" , MyButtonDesign.Default.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Default.GlossBottomColor := "33000000"
;********************************
;Hover
MyButtonDesign.Hover.W := 100 , MyButtonDesign.Hover.H := 40 , MyButtonDesign.Hover.Text := "Go" , MyButtonDesign.Hover.Font := "Arial" , MyButtonDesign.Hover.FontOptions := " Bold Center vCenter " , MyButtonDesign.Hover.FontSize := "12" , MyButtonDesign.Hover.H := "0x0002112F" , MyButtonDesign.Hover.TextBottomColor2 := "0x0002112F" , MyButtonDesign.Hover.TextTopColor1 := "0xFF22262a" , MyButtonDesign.Hover.TextTopColor2 := "0xFFFFFFFF" , MyButtonDesign.Hover.TextOffsetX := "0" , MyButtonDesign.Hover.TextOffsetY := "0" , MyButtonDesign.Hover.TextOffsetW := "0" , MyButtonDesign.Hover.TextOffsetH := "0" , MyButtonDesign.Hover.BackgroundColor := "0xFFffffff" , MyButtonDesign.Hover.ButtonOuterBorderColor := "0xFF92969a" , MyButtonDesign.Hover.ButtonCenterBorderColor := "0xFFa2a6aa" , MyButtonDesign.Hover.ButtonInnerBorderColor1 := "0xFF5FE1C8" , MyButtonDesign.Hover.ButtonInnerBorderColor2 := "0xFF166BFF" , MyButtonDesign.Hover.ButtonMainColor1 := "0xFFFFFFFF" , MyButtonDesign.Hover.ButtonMainColor2 := "0x9942E5EC" , MyButtonDesign.Hover.ButtonAddGlossy := "0" , MyButtonDesign.Hover.GlossTopColor := "0x11FFFFFF" , MyButtonDesign.Hover.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Hover.GlossBottomColor := "33000000"
;********************************
;Pressed
MyButtonDesign.Pressed.W := 100 , MyButtonDesign.Pressed.H := 40 , MyButtonDesign.Pressed.Text := "Go" , MyButtonDesign.Pressed.Font := "Arial" , MyButtonDesign.Pressed.FontOptions := " Bold Center vCenter " , MyButtonDesign.Pressed.FontSize := "12" , MyButtonDesign.Pressed.H := "0x0002112F" , MyButtonDesign.Pressed.TextBottomColor2 := "0x0002112F" , MyButtonDesign.Pressed.TextTopColor1 := "0xFFFFFFFF" , MyButtonDesign.Pressed.TextTopColor2 := "0xFFFFFFFF" , MyButtonDesign.Pressed.TextOffsetX := "0" , MyButtonDesign.Pressed.TextOffsetY := "0" , MyButtonDesign.Pressed.TextOffsetW := "0" , MyButtonDesign.Pressed.TextOffsetH := "0" , MyButtonDesign.Pressed.BackgroundColor := "0xFFffffff" , MyButtonDesign.Pressed.ButtonOuterBorderColor := "0xFFf0f0f0" , MyButtonDesign.Pressed.ButtonCenterBorderColor := "0xFFa2a6aa" , MyButtonDesign.Pressed.ButtonInnerBorderColor1 := "0xFF0488E6" , MyButtonDesign.Pressed.ButtonInnerBorderColor2 := "0xFFF0F0F0" , MyButtonDesign.Pressed.ButtonMainColor1 := "0xFF42E5EC" , MyButtonDesign.Pressed.ButtonMainColor2 := "0xFFa2a6aa" , MyButtonDesign.Pressed.ButtonAddGlossy := "0" , MyButtonDesign.Pressed.GlossTopColor := "0x11FFFFFF" , MyButtonDesign.Pressed.GlossTopAccentColor := "05FFFFFF" , MyButtonDesign.Pressed.GlossBottomColor := "33000000"
;********************************
return MyButtonDesign
}
; | ((( For Demo ))) | ((( For Demo ))) | ((( For Demo ))) | ((( For Demo ))) | ((( For Demo ))) | ((( For Demo ))) | ((( For Demo ))) | ((( For Demo ))) | ((( For Demo ))) |
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
Class HButton {
;Gen 3 Button Class By Hellbent
static init , Button := [] , Active , LastControl , HoldCtrl
__New( Input := "" , All := "" , Default := "" , Hover := "" , Pressed := "" ){
local hwnd
;If this is the first time the class is being used.
if( !HButton.init && HButton.init := 1 )
;Set a timer to watch to see if the cursor goes over one of the controls.
HButton._SetHoverTimer()
This._CreateNewButtonObject( hwnd := This._CreateControl( Input ) , Input )
This._BindButton( hwnd , Input )
This._GetButtonBitmaps( hwnd , Input , All , Default , Hover , Pressed )
This._DisplayButton( hwnd , HButton.Button[hwnd].Bitmaps.Default.hBitmap )
return hwnd
}
_DisplayButton( hwnd , hBitmap){
SetImage( hwnd , hBitmap )
}
_GetButtonBitmaps( hwnd , Input := "" , All := "" , Default := "" , Hover := "" , Pressed := "" ){
HButton.Button[hwnd].Bitmaps := GuiButtonType1.CreateButtonBitmapSet( Input , All , Default , Hover , Pressed )
}
_CreateNewButtonObject( hwnd , Input ){
local k , v
HButton.Button[ hwnd ] := {}
for k , v in Input
HButton.Button[ hwnd ][ k ] := v
HButton.Button[ hwnd ].Hwnd := hwnd
}
_CreateControl( Input ){
local hwnd
Gui , % Input.Owner ":Add" , Pic , % "x" Input.X " y" Input.Y " w" Input.W " h" Input.H " hwndhwnd 0xE"
return hwnd
}
_BindButton( hwnd , Input ){
local bd
bd := This._OnClick.Bind( This )
GuiControl, % Input.Owner ":+G" , % hwnd , % bd
}
_SetHoverTimer( timer := "" ){
local HoverTimer
if( !HButton.HoverTimer )
HButton.HoverTimer := ObjBindMethod( HButton , "_OnHover" )
HoverTimer := HButton.HoverTimer
SetTimer , % HoverTimer , % ( Timer ) ? ( Timer ) : ( 100 )
}
_OnHover(){
local Ctrl
MouseGetPos,,,,ctrl,2
if( HButton.Button[ ctrl ] && !HButton.Active ){
HButton.Active := 1
HButton.LastControl := ctrl
HButton._DisplayButton( ctrl , HButton.Button[ ctrl ].Bitmaps.Hover.hBitmap )
}else if( HButton.Active && ctrl != HButton.LastControl ){
HButton.Active := 0
HButton._DisplayButton( HButton.LastControl , HButton.Button[ HButton.LastControl ].Bitmaps.Default.hBitmap )
}
}
_OnClick(){
local Ctrl, last
HButton._SetHoverTimer( "Off" )
MouseGetPos,,,, Ctrl , 2
last := ctrl
HButton._SetFocus( ctrl )
HButton._DisplayButton( last , HButton.Button[ last ].Bitmaps.Pressed.hBitmap )
While(GetKeyState("LButton"))
sleep, 60
HButton._SetHoverTimer()
loop, 2
This._OnHover()
MouseGetPos,,,, Ctrl , 2
if(ctrl!=last){
HButton._DisplayButton( last , HButton.Button[ last ].Bitmaps.Default.hBitmap )
}else{
HButton._DisplayButton( last , HButton.Button[ last ].Bitmaps.Hover.hBitmap )
if( HButton.Button[ last ].Label ){
if(IsFunc( HButton.Button[ last ].Label ) )
fn := Func( HButton.Button[ last ].Label )
, fn.Call()
else
gosub, % HButton.Button[ last ].Label
}
}
}
_SetFocus( ctrl ){
GuiControl, % HButton.Button[ ctrl ].Owner ":Focus" , % ctrl
}
DeleteButton( hwnd ){
for k , v in HButton.Button[ hwnd ].Bitmaps
Gdip_DisposeImage( HButton.Button[hwnd].Bitmaps[k].pBitmap )
, DeleteObject( HButton.Button[ hwnd ].Bitmaps[k].hBitmap )
GuiControl , % HButton.Button[ hwnd ].Owner ":Move", % hwnd , % "x-1 y-1 w0 h0"
HButton.Button[ hwnd ] := ""
}
}
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
Class GuiButtonType1 {
static List := [ "Default" , "Hover" , "Pressed" ]
_CreatePressedBitmap(){
local arr := [] , Bitmap := {} , fObj := This.CurrentBitmapData.Pressed
Bitmap.pBitmap := Gdip_CreateBitmap( fObj.W , fObj.H ) , G := Gdip_GraphicsFromImage( Bitmap.pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
Brush := Gdip_BrushCreateSolid( fObj.BackgroundColor ) , Gdip_FillRectangle( G , Brush , -1 , -1 , fObj.W+2 , fObj.H+2 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.ButtonOuterBorderColor ) , Gdip_FillRoundedRectangle( G , Brush , 3 , 4 , fObj.W-7 , fObj.H-7 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 0 , 0 , fObj.W , fObj.H , fObj.ButtonInnerBorderColor1 , fObj.ButtonInnerBorderColor2 , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 2 , 3 , fObj.W-5 , fObj.H-8 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 0 , 0 , fObj.W-7 , fObj.H-10 , fObj.ButtonMainColor1 , fObj.ButtonMainColor2 , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 5 , 5 , fObj.W-11 , fObj.H-12 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 0 , 2 , fObj.W , fObj.H , fObj.TextBottomColor1 , fObj.TextBottomColor2 , 1 , 1 )
arr := [ { X: -1 , Y: -1 } , { X: 0 , Y: -1 } , { X: 1 , Y: -1 } , { X: -1 , Y: 0 } , { X: 1 , Y: 0 } , { X: -1 , Y: 1 } , { X: 0 , Y: 1 } , { X: 1 , Y: 1 } ]
Loop, % 8
Gdip_TextToGraphics( G , fObj.Text , "s" fObj.FontSize " " fObj.FontOptions " c" Brush " x" 1 + arr[A_Index].X + fObj.TextOffsetX " y" 3 + arr[A_Index].Y + fObj.TextOffsetY , fObj.Font , fObj.W + fObj.TextOffsetW , fObj.H + fObj.TextOffsetH )
Brush := Gdip_CreateLineBrushFromRect( 0 , 2 , fObj.W , fObj.H , fObj.TextTopColor1 , fObj.TextTopColor2 , 1 , 1 )
Gdip_TextToGraphics( G , fObj.Text , "s" fObj.FontSize " " fObj.FontOptions " c" Brush " x" 1 + fObj.TextOffsetX " y" 3 + fObj.TextOffsetY , fObj.Font , fObj.W + fObj.TextOffsetW , fObj.H + fObj.TextOffsetH )
if( fObj.ButtonAddGlossy ){
Brush := Gdip_BrushCreateSolid( fObj.GlossTopColor ) , Gdip_FillRectangle( G , Brush , 5 , 10 , fObj.W-11 , ( fObj.H / 2 ) - 10 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.GlossTopAccentColor ) , Gdip_FillRectangle( G , Brush , 10 , 12 , fObj.W-21 , fObj.H / 15 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.GlossBottomColor ) , Gdip_FillRectangle( G , Brush , 5 , 10 + ( fObj.H / 2 ) - 10 , fObj.W-11 , ( fObj.H / 2 ) - 7 ) , Gdip_DeleteBrush( Brush )
}
Gdip_DeleteGraphics( G )
Bitmap.hBitmap := Gdip_CreateHBITMAPFromBitmap( Bitmap.pBitmap )
return Bitmap
}
_CreateHoverBitmap(){
local arr := [] , Bitmap := {} , fObj := This.CurrentBitmapData.Hover
Bitmap.pBitmap := Gdip_CreateBitmap( fObj.W , fObj.H ) , G := Gdip_GraphicsFromImage( Bitmap.pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
Brush := Gdip_BrushCreateSolid( fObj.BackgroundColor ) , Gdip_FillRectangle( G , Brush , -1 , -1 , fObj.W+2 , fObj.H+2 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.ButtonOuterBorderColor ) , Gdip_FillRoundedRectangle( G , Brush , 2 , 3 , fObj.W-5 , fObj.H-7 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.ButtonCenterBorderColor ) , Gdip_FillRoundedRectangle( G , Brush , 3 , 4 , fObj.W-7 , fObj.H-9 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 0 , 0 , fObj.W , fObj.H-10 , fObj.ButtonInnerBorderColor1 , fObj.ButtonInnerBorderColor2 , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 4 , 5 , fObj.W-9 , fObj.H-11 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 5 , 7 , fObj.W-11 , fObj.H-14 , fObj.ButtonMainColor1 , fObj.ButtonMainColor2 , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 5 , 7 , fObj.W-11 , fObj.H-14 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 0 , 2 , fObj.W , fObj.H , fObj.TextBottomColor1 , fObj.TextBottomColor2 , 1 , 1 )
arr := [ { X: -1 , Y: -1 } , { X: 0 , Y: -1 } , { X: 1 , Y: -1 } , { X: -1 , Y: 0 } , { X: 1 , Y: 0 } , { X: -1 , Y: 1 } , { X: 0 , Y: 1 } , { X: 1 , Y: 1 } ]
Loop, % 8
Gdip_TextToGraphics( G , fObj.Text , "s" fObj.FontSize " " fObj.FontOptions " c" Brush " x" 0 + arr[A_Index].X + fObj.TextOffsetX " y" 2 + arr[A_Index].Y + fObj.TextOffsetY , fObj.Font , fObj.W + fObj.TextOffsetW , fObj.H + fObj.TextOffsetH )
Brush := Gdip_CreateLineBrushFromRect( 0 , 2 , fObj.W , fObj.H , fObj.TextTopColor1 , fObj.TextTopColor2 , 1 , 1 )
Gdip_TextToGraphics( G , fObj.Text , "s" fObj.FontSize " " fObj.FontOptions " c" Brush " x" 0 + fObj.TextOffsetX " y" 2 + fObj.TextOffsetY , fObj.Font , fObj.W + fObj.TextOffsetW , fObj.H + fObj.TextOffsetH )
if( fObj.ButtonAddGlossy = 1 ){
Brush := Gdip_BrushCreateSolid( fObj.GlossTopColor ) , Gdip_FillRectangle( G , Brush , 6 , 10 , fObj.W-13 , ( fObj.H / 2 ) - 10 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.GlossTopAccentColor ) , Gdip_FillRectangle( G , Brush , 10 , 12 , fObj.W-21 , fObj.H / 15 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.GlossBottomColor ) , Gdip_FillRectangle( G , Brush , 6 , 10 + ( fObj.H / 2 ) - 10 , fObj.W-13 , ( fObj.H / 2 ) - 7 ) , Gdip_DeleteBrush( Brush )
}
Gdip_DeleteGraphics( G )
Bitmap.hBitmap := Gdip_CreateHBITMAPFromBitmap( Bitmap.pBitmap )
return Bitmap
}
_CreateDefaultBitmap(){
local arr := [] , Bitmap := {} , fObj := This.CurrentBitmapData.Default
Bitmap.pBitmap := Gdip_CreateBitmap( fObj.W , fObj.H ) , G := Gdip_GraphicsFromImage( Bitmap.pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
Brush := Gdip_BrushCreateSolid( fObj.BackgroundColor ) , Gdip_FillRectangle( G , Brush , -1 , -1 , fObj.W+2 , fObj.H+2 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.ButtonOuterBorderColor ) , Gdip_FillRoundedRectangle( G , Brush , 2 , 3 , fObj.W-5 , fObj.H-7 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.ButtonCenterBorderColor ) , Gdip_FillRoundedRectangle( G , Brush , 3 , 4 , fObj.W-7 , fObj.H-9 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 0 , 0 , fObj.W , fObj.H-10 , fObj.ButtonInnerBorderColor1 , fObj.ButtonInnerBorderColor2 , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 4 , 5 , fObj.W-9 , fObj.H-11 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 5 , 7 , fObj.W-11 , fObj.H-14 , fObj.ButtonMainColor1 , fObj.ButtonMainColor2 , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 5 , 7 , fObj.W-11 , fObj.H-14 , 5 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 0 , 2 , fObj.W , fObj.H , fObj.TextBottomColor1 , fObj.TextBottomColor2 , 1 , 1 )
arr := [ { X: -1 , Y: -1 } , { X: 0 , Y: -1 } , { X: 1 , Y: -1 } , { X: -1 , Y: 0 } , { X: 1 , Y: 0 } , { X: -1 , Y: 1 } , { X: 0 , Y: 1 } , { X: 1 , Y: 1 } ]
Loop, % 8
Gdip_TextToGraphics( G , fObj.Text , "s" fObj.FontSize " " fObj.FontOptions " c" Brush " x" 0 + arr[A_Index].X + fObj.TextOffsetX " y" 2 + arr[A_Index].Y + fObj.TextOffsetY , fObj.Font , fObj.W + fObj.TextOffsetW , fObj.H + fObj.TextOffsetH )
Brush := Gdip_CreateLineBrushFromRect( 0 , 2 , fObj.W , fObj.H , fObj.TextTopColor1 , fObj.TextTopColor2 , 1 , 1 )
Gdip_TextToGraphics( G , fObj.Text , "s" fObj.FontSize " " fObj.FontOptions " c" Brush " x" 0 + fObj.TextOffsetX " y" 2 + fObj.TextOffsetY , fObj.Font , fObj.W + fObj.TextOffsetW , fObj.H + fObj.TextOffsetH )
if( fObj.ButtonAddGlossy ){
Brush := Gdip_BrushCreateSolid( fObj.GlossTopColor ) , Gdip_FillRectangle( G , Brush , 6 , 10 , fObj.W-13 , ( fObj.H / 2 ) - 10 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.GlossTopAccentColor ) , Gdip_FillRectangle( G , Brush , 10 , 12 , fObj.W-21 , fObj.H / 15 ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( fObj.GlossBottomColor ) , Gdip_FillRectangle( G , Brush , 6 , 10 + ( fObj.H / 2 ) - 10 , fObj.W-13 , ( fObj.H / 2 ) - 7 ) , Gdip_DeleteBrush( Brush )
}
Gdip_DeleteGraphics( G )
Bitmap.hBitmap := Gdip_CreateHBITMAPFromBitmap( Bitmap.pBitmap )
return Bitmap
}
_GetMasterDefaultValues(){ ;Default State
local Default := {}
Default.pBitmap := ""
, Default.hBitmap := ""
, Default.Font := "Arial"
, Default.FontOptions := " Bold Center vCenter "
, Default.FontSize := "12"
, Default.Text := "Button"
, Default.W := 10
, Default.H := 10
, Default.TextBottomColor1 := "0x0002112F"
, Default.TextBottomColor2 := Default.TextBottomColor1
, Default.TextTopColor1 := "0xFFFFFFFF"
, Default.TextTopColor2 := "0xFF000000"
, Default.TextOffsetX := 0
, Default.TextOffsetY := 0
, Default.TextOffsetW := 0
, Default.TextOffsetH := 0
, Default.BackgroundColor := "0xFF22262A"
, Default.ButtonOuterBorderColor := "0xFF161B1F"
, Default.ButtonCenterBorderColor := "0xFF262B2F"
, Default.ButtonInnerBorderColor1 := "0xFF3F444A"
, Default.ButtonInnerBorderColor2 := "0xFF24292D"
, Default.ButtonMainColor1 := "0xFF272C32"
, Default.ButtonMainColor2 := "" Default.ButtonMainColor1
, Default.ButtonAddGlossy := 0
, Default.GlossTopColor := "0x11FFFFFF"
, Default.GlossTopAccentColor := "0x05FFFFFF"
, Default.GlossBottomColor := "0x33000000"
return Default
}
_GetMasterHoverValues(){ ;Hover State
local Default := {}
Default.pBitmap := ""
, Default.hBitmap := ""
, Default.Font := "Arial"
, Default.FontOptions := " Bold Center vCenter "
, Default.FontSize := "12"
, Default.Text := "Button"
, Default.W := 10
, Default.H := 10
, Default.TextBottomColor1 := "0x0002112F"
, Default.TextBottomColor2 := Default.TextBottomColor1
, Default.TextTopColor1 := "0xFFFFFFFF"
, Default.TextTopColor2 := "0xFF000000"
, Default.TextOffsetX := 0
, Default.TextOffsetY := 0
, Default.TextOffsetW := 0
, Default.TextOffsetH := 0
, Default.BackgroundColor := "0xFF22262A"
, Default.ButtonOuterBorderColor := "0xFF161B1F"
, Default.ButtonCenterBorderColor := "0xFF262B2F"
, Default.ButtonInnerBorderColor1 := "0xFF3F444A"
, Default.ButtonInnerBorderColor2 := "0xFF24292D"
, Default.ButtonMainColor1 := "0xFF373C42"
, Default.ButtonMainColor2 := "" Default.ButtonMainColor1
, Default.ButtonAddGlossy := 0
, Default.GlossTopColor := "0x11FFFFFF"
, Default.GlossTopAccentColor := "0x05FFFFFF"
, Default.GlossBottomColor := "0x33000000"
return Default
}
_GetMasterPressedValues(){ ;Pressed State
local Default := {}
Default.pBitmap := ""
, Default.hBitmap := ""
, Default.Font := "Arial"
, Default.FontOptions := " Bold Center vCenter "
, Default.FontSize := "12"
, Default.Text := "Button"
, Default.W := 10
, Default.H := 10
, Default.TextBottomColor1 := "0x0002112F"
, Default.TextBottomColor2 := Default.TextBottomColor1
, Default.TextTopColor1 := "0xFFFFFFFF"
, Default.TextTopColor2 := "0xFF000000"
, Default.TextOffsetX := 0
, Default.TextOffsetY := 0
, Default.TextOffsetW := 0
, Default.TextOffsetH := 0
, Default.BackgroundColor := "0xFF22262A"
, Default.ButtonOuterBorderColor := "0xFF62666a"
, Default.ButtonCenterBorderColor := "0xFF262B2F"
, Default.ButtonInnerBorderColor1 := "0xFF151A20"
, Default.ButtonInnerBorderColor2 := "0xFF151A20"
, Default.ButtonMainColor1 := "0xFF12161a"
, Default.ButtonMainColor2 := "0xFF33383E"
, Default.ButtonAddGlossy := 0
, Default.GlossTopColor := "0x11FFFFFF"
, Default.GlossTopAccentColor := "0x05FFFFFF"
, Default.GlossBottomColor := "0x33000000"
return Default
}
SetSessionDefaults( All := "" , Default := "" , Hover := "" , Pressed := "" ){ ;Set the default values based on user input
This.SessionBitmapData := {}
, This.Preset := 1
, This.init := 0
This._LoadDefaults("SessionBitmapData")
This._SetSessionData( All , Default , Hover , Pressed )
}
_SetSessionData( All := "" , Default := "" , Hover := "" , Pressed := "" ){
local index , k , v , i , j
if( IsObject( All ) ){
Loop, % GuiButtonType1.List.Length() {
index := A_Index
For k , v in All
This.SessionBitmapData[ GuiButtonType1.List[ index ] ][ k ] := v
}
}
For k , v in GuiButtonType1.List
if( isObject( %v% ) )
For i , j in %v%
This.SessionBitmapData[ GuiButtonType1.List[ k ] ][ i ] := j
}
_LoadDefaults( input := "" ){
This.CurrentBitmapData := "" , This.CurrentBitmapData := {}
For k , v in This.SessionBitmapData
This.CurrentBitmapData[k] := {}
This[ input ].Default := This._GetMasterDefaultValues()
, This[ input ].Hover := This._GetMasterHoverValues()
, This[ input ].Pressed := This._GetMasterPressedValues()
}
_SetCurrentBitmapDataFromSessionData(){
local k , v , i , j
This.CurrentBitmapData := "" , This.CurrentBitmapData := {}
For k , v in This.SessionBitmapData
{
This.CurrentBitmapData[k] := {}
For i , j in This.SessionBitmapData[k]
This.CurrentBitmapData[k][i] := j
}
}
_UpdateCurrentBitmapData( All := "" , Default := "" , Hover := "" , Pressed := "" ){
local k , v , i , j
if( IsObject( All ) ){
Loop, % GuiButtonType1.List.Length() {
index := A_Index
For k , v in All
This.CurrentBitmapData[ GuiButtonType1.List[ index ] ][ k ] := v
}
}
For k , v in GuiButtonType1.List
if( isObject( %v% ) )
For i , j in %v%
This.CurrentBitmapData[ GuiButtonType1.List[ k ] ][ i ] := j
}
_UpdateInstanceData( obj := ""){
For k , v in GuiButtonType1.List
This.CurrentBitmapData[v].Text := obj.Text
, This.CurrentBitmapData[v].W := obj.W
, This.CurrentBitmapData[v].H := obj.H
}
CreateButtonBitmapSet( obj := "" , All := "" , Default := "" , Hover := "" , Pressed := "" ){ ;Create a new button
local Bitmaps := {}
if( This.Preset )
This._SetCurrentBitmapDataFromSessionData()
else
This._LoadDefaults( "CurrentBitmapData" )
This._UpdateCurrentBitmapData( All , Default , Hover , Pressed )
This._UpdateInstanceData( obj )
Bitmaps.Default := This._CreateDefaultBitmap()
, Bitmaps.Hover := This._CreateHoverBitmap()
, Bitmaps.Pressed := This._CreatePressedBitmap()
return Bitmaps
}
}
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************
;****************************************************************************************************************************************************************************************