The graphics example from above coded in. ( Create your own design )
Why Red? Because that's the theme that the ddl has and I didn't want to change it
.
Code: Select all
;****************************************************************************************************************************************************************************
#Include <My Altered GDIP lib> ;<<<<<<<<<<<<<<<<<<--------------------------- gdip.ahk
#Include <PopUpWindow_V2> ; At the bottom of the script
;****************************************************************************************************************************************************************************
#SingleInstance, Force
SetBatchLines, -1
Gdip_Startup()
CanUse := 1
return
*ESC::ExitApp
;~ RALT::PopUpWindow.Helper()
SelectionGUI( set1 , set2 , set3 ){ ;Pass 3 sets of data ( each has a current value a max value a min value and an optional replacement array of text values )
;**********
Sections := 3
SectionWidth := 130
SectionHeight := 40
Margin := 15
;**********
CoordMode, Mouse, Screen
MouseGetPos, x , y
;**********
w := 450
h := 70
x := x - w / 2
y := y - h / 2
;**********
global MyGui := New PopUpWindow( { AutoShow: 1 , X: x , Y: y , W: w , H: h , Options: " +AlwaysOnTop -DPIScale +ToolWindow " } ) ;+E0x20 = click through window
;**********
;********************************************
MyList := Set2.TextReplacementArray
MyGui.MyCenterDDL := New DropDownListv1( { rows: 1
, X: 155
, Y: 15
, ScaleFactor: 1
, W: 130
, FontSize: 17
, FontColor: "0xFFFF0000"
, MainColor: "0xFF0F1011"
, Font: "MV Boli"
, Parent: MyGui.Hwnd
, Selected: 1
, HighlightFontColor: "0xFFFFFFFF"
, FontOptions: "Center vCenter NoWrap Bold "
, List: MyList } )
;********************************************
MyGui.Controls.Section1 := { X: 20 , Y: 15 , W: 130 , H: 40 }
for k , v in Set1
MyGui.Controls.Section1[ k ] := Set1[ k ]
;**********
;transfer values to the window object to make passing values to the drawing function easier.
MyGui.Sections := Sections
MyGui.SectionWidth := SectionWidth
MyGui.SectionHeight := SectionHeight
MyGui.Margin := Margin
;**********
MyGui.MyValues := []
MyGui.MyValues[ 1 ] := Set1
MyGui.MyValues[ 2 ] := Set2
MyGui.MyValues[ 3 ] := Set3
;**********
DrawWindow( MyGui )
;**********
MyGui.Active := 1
;**********
}
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
#If ( CanUse ) ;For demo purposes. If you wanted to have a way of turning on and off the RButton hotkey you can change the value of "CanUse"
RButton:: ;RButton down
set1 := { CurrentValue: 10 , MaxValue: 80 , MinValue: 10 }
set2 := { CurrentValue: 1 , MaxValue: 7 , MinValue: 1 , TextReplacementArray: [ "Pink", "Yellow", "Black", "Blue", "Red", "white", "Green"] }
set3 := { CurrentValue: 91 , MaxValue: 97 , MinValue: 91 }
SelectionGUI( set1 , set2 , set3 )
keyWait, RButton
return
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
RButton Up::
MyGui.MyValues[ 2 ].CurrentValue := MyGui.MyCenterDDL.Selected
Loop, 3 {
if( MyGui.MyValues[ A_Index ].Haskey( "TextReplacementArray" ) )
v%A_Index% := MyGui.MyValues[ A_Index ].TextReplacementArray[ MyGui.MyValues[ A_Index ].CurrentValue ]
else
v%A_Index% := MyGui.MyValues[ A_Index ].CurrentValue
}
;()___()___()___()___()___()
;()___()___()___()___()___()
output := [ v1 , v2 , v3 ] ;<<<---- Your output [ 10 , "Pink" , 92 ]
;()___()___()___()___()___()
;()___()___()___()___()___()
MyGui.MyCenterDDL.Delete()
MyGui.Active := 0
MyGui.DeleteWindow()
MyGui := ""
;~ Msgbox, % output[ 1 ] "`n" output[ 2 ] "`n" output[ 3 ]
ToolTip, % output[ 1 ] "`n" output[ 2 ] "`n" output[ 3 ]
return
#If
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
CheckDDL( MyGui ){
MouseGetPos,,, win , ctrl , 2
if( ctrl = MyGui.MyCenterDDL.ToggleButton.Hwnd || win = MyGui.MyCenterDDL.Gui2.Hwnd )
return 1
return 0
}
;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
#If ( MyGui.Active && !CheckDDL( MyGui ) )
WheelUp::
CoordMode, Mouse , Screen
MouseGetPos, x , y
x -= MyGui.X
currentSection := ""
if( x <= ( MyGui.SectionWidth + MyGui.Margin * 1.5 ) ){
currentSection := 1
}else if( x <= ( MyGui.SectionWidth * 2 + MyGui.Margin * 2.5 ) ){
return
currentSection := 2
}else{
currentSection := 3
}
if( y < MyGui.Y ){
if( !MyGui.MyValues[ currentSection ].HasKey( "TextReplacementArray" ) ){
MyGui.MyValues[ currentSection ].CurrentValue += 0.1
if( MyGui.MyValues[ currentSection ].CurrentValue > MyGui.MyValues[ currentSection ].MaxValue ){
MyGui.MyValues[ currentSection ].CurrentValue := MyGui.MyValues[ currentSection ].MaxValue
}
DrawWindow( MyGui )
}
}else if( y <= MyGui.Y + MyGui.H ){
MyGui.MyValues[ currentSection ].CurrentValue += 1
if( MyGui.MyValues[ currentSection ].CurrentValue > MyGui.MyValues[ currentSection ].MaxValue ){
MyGui.MyValues[ currentSection ].CurrentValue := MyGui.MyValues[ currentSection ].MaxValue
}
DrawWindow( MyGui )
}else{
MyGui.MyValues[ currentSection ].CurrentValue += 10
if( MyGui.MyValues[ currentSection ].CurrentValue > MyGui.MyValues[ currentSection ].MaxValue ){
MyGui.MyValues[ currentSection ].CurrentValue := MyGui.MyValues[ currentSection ].MaxValue
}
DrawWindow( MyGui )
}
return
;#################################
;#################################
WheelDown::
CoordMode, Mouse , Screen
MouseGetPos, x , y
x -= MyGui.X
currentSection := ""
if( x <= ( MyGui.SectionWidth + MyGui.Margin * 1.5 ) ){
currentSection := 1
}else if( x <= ( MyGui.SectionWidth * 2 + MyGui.Margin * 2.5 ) ){
currentSection := 2
}else{
currentSection := 3
}
if( y < MyGui.Y ){
if( !MyGui.MyValues[ currentSection ].HasKey( "TextReplacementArray" ) ){
MyGui.MyValues[ currentSection ].CurrentValue -= 0.1
if( MyGui.MyValues[ currentSection ].CurrentValue < MyGui.MyValues[ currentSection ].MinValue ){
MyGui.MyValues[ currentSection ].CurrentValue := MyGui.MyValues[ currentSection ].MinValue
}
DrawWindow( MyGui )
}
}else if( y <= MyGui.Y + MyGui.H ){
MyGui.MyValues[ currentSection ].CurrentValue -= 1
if( MyGui.MyValues[ currentSection ].CurrentValue < MyGui.MyValues[ currentSection ].MinValue ){
MyGui.MyValues[ currentSection ].CurrentValue := MyGui.MyValues[ currentSection ].MinValue
}
DrawWindow( MyGui )
}else{
MyGui.MyValues[ currentSection ].CurrentValue -= 10
if( MyGui.MyValues[ currentSection ].CurrentValue < MyGui.MyValues[ currentSection ].MinValue ){
MyGui.MyValues[ currentSection ].CurrentValue := MyGui.MyValues[ currentSection ].MinValue
}
DrawWindow( MyGui )
}
return
#If
;*******************************************************************
;*******************************************************************
DrawWindow( obj ){
obj.ClearWindow()
obj.DrawBitmap( WindowGraphics( obj ) , { X: 0 , Y: 0 , W: obj.W , H: obj.H } , dispose := 1 , AutoUpdate := 1 )
}
;*******************************************************************
WindowGraphics( obj , ScaleFactor := 1 ){
;Bitmap Created Using: HB Bitmap Maker
pBitmap := Gdip_CreateBitmap( 450 * ScaleFactor , 70 * ScaleFactor ) , G := Gdip_GraphicsFromImage( pBitmap ) , Gdip_SetSmoothingMode( G , 2 )
;~ Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRectangle( G , Brush , -10 * ScaleFactor , -10 * ScaleFactor , 600 * ScaleFactor , 200 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0x99000000" ) , Gdip_FillRoundedRectangle( G , Brush , 11 * ScaleFactor , 11 * ScaleFactor , 418 * ScaleFactor , 49 * ScaleFactor , 15 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateHatch( "0xff880000" , "0xFF000000" , 39 ) , Gdip_FillRoundedRectangle( G , Brush , 10 * ScaleFactor , 10 * ScaleFactor , 417 * ScaleFactor , 47 * ScaleFactor , 15 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 12 * ScaleFactor , 15 * ScaleFactor , 413 * ScaleFactor , 40 * ScaleFactor , "0xFFFF0000" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 2 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 10 * ScaleFactor , 10 * ScaleFactor , 417 * ScaleFactor , 47 * ScaleFactor , 15 * ScaleFactor ) , Gdip_DeletePen( Pen )
;section 1
Brush := Gdip_CreateLineBrush( 62 * ScaleFactor , 14 * ScaleFactor , 87 * ScaleFactor , 13 * ScaleFactor , "0x66880000" , "0x66000000" , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 20 * ScaleFactor , 15 * ScaleFactor , 130 * ScaleFactor , 40 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
;section 1
Brush := Gdip_CreateLineBrush( 62 * ScaleFactor , 14 * ScaleFactor , 87 * ScaleFactor , 13 * ScaleFactor , "0x33F0F0F0" , "0x66000000" , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 20 * ScaleFactor , 15 * ScaleFactor , 130 * ScaleFactor , 40 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
;section 1
Brush := Gdip_CreateLineBrushFromRect( 21 * ScaleFactor , 14 * ScaleFactor , 127 * ScaleFactor , 40 * ScaleFactor , "0x66ff0000" , "0x66000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , 20 * ScaleFactor , 15 * ScaleFactor , 130 * ScaleFactor , 40 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 22 * ScaleFactor , 17 * ScaleFactor , 128 * ScaleFactor , 37 * ScaleFactor , "0xFFFF0000" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , 20 * ScaleFactor , 15 * ScaleFactor , 130 * ScaleFactor , 40 * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 31 * ScaleFactor , 22 * ScaleFactor , 112 * ScaleFactor , 31 * ScaleFactor , "0xFF000000" , "0xFF32363a" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , 25 * ScaleFactor , 18 * ScaleFactor , 120 * ScaleFactor , 32 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
value := obj.MyValues[ 1 ].CurrentValue
value := Round( value , 1 )
if( instr( value , ".0" ) )
value := StrSplit( value , "." )[ 1 ]
( StrLen( Value ) > 3 ) ? ( fs := 18 ) : ( fs := 20 )
Brush := Gdip_BrushCreateSolid( "0xFFff0000" ) , Gdip_TextToGraphics( G , value , "s" fs * ScaleFactor " Center vCenter Bold NoWrap c" Brush " x" 19 * ScaleFactor " y" 15 * ScaleFactor , "MV Boli" , 130 * ScaleFactor , 40 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , value , "s" fs * ScaleFactor " Center vCenter Bold NoWrap c" Brush " x" 21 * ScaleFactor " y" 17 * ScaleFactor , "MV Boli" , 130 * ScaleFactor , 40 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF880000" ) , Gdip_TextToGraphics( G , value , "s" fs * ScaleFactor " Center vCenter Bold NoWrap c" Brush " x" 20 * ScaleFactor " y" 16 * ScaleFactor , "MV Boli" , 130 * ScaleFactor , 40 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 25 * ScaleFactor , 21 * ScaleFactor , 119 * ScaleFactor , 28 * ScaleFactor , "0xFFFF0000" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 3 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawEllipse( G , Pen , 25 * ScaleFactor , 18 * ScaleFactor , 120 * ScaleFactor , 32 * ScaleFactor ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( 25 * ScaleFactor , 21 * ScaleFactor , 119 * ScaleFactor , 28 * ScaleFactor , "0xFF000000" , "0x99FF0000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 2 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawEllipse( G , Pen , 25 * ScaleFactor , 19 * ScaleFactor , 120 * ScaleFactor , 30 * ScaleFactor ) , Gdip_DeletePen( Pen )
;*****************************************
;section 3
x := 290
y := 15
w := 130
h := 40
;~ Brush := Gdip_BrushCreateSolid( "0xFF333333" ) , Gdip_FillRoundedRectangle( G , Brush , x * ScaleFactor , y * ScaleFactor , w * ScaleFactor , h * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
;section 1
Brush := Gdip_CreateLineBrush( ( x + 42 ) * ScaleFactor , 14 * ScaleFactor , 87 * ScaleFactor , 13 * ScaleFactor , "0x66880000" , "0x66000000" , 1 ) , Gdip_FillRoundedRectangle( G , Brush , x * ScaleFactor , y * ScaleFactor , w * ScaleFactor , h * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
;section 1
Brush := Gdip_CreateLineBrush( ( x + 42 ) * ScaleFactor , 14 * ScaleFactor , 87 * ScaleFactor , 13 * ScaleFactor , "0x33F0F0F0" , "0x66000000" , 1 ) , Gdip_FillRoundedRectangle( G , Brush , x * ScaleFactor , y * ScaleFactor , w * ScaleFactor , h * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
;section 1
Brush := Gdip_CreateLineBrushFromRect( x * ScaleFactor , y * ScaleFactor , w * ScaleFactor , h * ScaleFactor , "0x66ff0000" , "0x66000000" , 1 , 1 ) , Gdip_FillRoundedRectangle( G , Brush , x * ScaleFactor , y * ScaleFactor , w * ScaleFactor , h * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( x * ScaleFactor , y * ScaleFactor , w * ScaleFactor , h * ScaleFactor , "0xFFFF0000" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( G , Pen , x * ScaleFactor , y * ScaleFactor , w * ScaleFactor , h * ScaleFactor , 5 * ScaleFactor ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( x * ScaleFactor , y * ScaleFactor , w * ScaleFactor , h * ScaleFactor , "0xFF000000" , "0xFF32363a" , 1 , 1 ) , Gdip_FillEllipse( G , Brush , ( x + 5 ) * ScaleFactor , ( y + 3 ) * ScaleFactor , ( w - 10 ) * ScaleFactor , ( h - 8 ) * ScaleFactor ) , Gdip_DeleteBrush( Brush )
value := obj.MyValues[ 3 ].CurrentValue
value := Round( value , 1 )
if( instr( value , ".0" ) )
value := StrSplit( value , "." )[ 1 ]
( StrLen( Value ) > 3 ) ? ( fs := 18 ) : ( fs := 20 )
Brush := Gdip_BrushCreateSolid( "0xFFff0000" ) , Gdip_TextToGraphics( G , value , "s" fs * ScaleFactor " Center vCenter Bold NoWrap c" Brush " x" (x - 1 ) * ScaleFactor " y" y * ScaleFactor , "MV Boli" , w * ScaleFactor , h * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF000000" ) , Gdip_TextToGraphics( G , value , "s" fs * ScaleFactor " Center vCenter Bold NoWrap c" Brush " x" ( x + 1 ) * ScaleFactor " y" ( y + 2 ) * ScaleFactor , "MV Boli" , w * ScaleFactor , h * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFF880000" ) , Gdip_TextToGraphics( G , value , "s" fs * ScaleFactor " Center vCenter Bold NoWrap c" Brush " x" x * ScaleFactor " y" ( y + 1 ) * ScaleFactor , "MV Boli" , w * ScaleFactor , h * ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( ( x + 5 ) * ScaleFactor , ( y + 3 ) * ScaleFactor , ( w - 10 ) * ScaleFactor , ( h - 8 ) * ScaleFactor , "0xFFFF0000" , "0xFF000000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 3 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawEllipse( G , Pen , ( x + 5 ) * ScaleFactor , ( y + 3 ) * ScaleFactor , ( w - 10 ) * ScaleFactor , ( h - 8 ) * ScaleFactor ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrushFromRect( ( x + 5 ) * ScaleFactor , 21 * ScaleFactor , 119 * ScaleFactor , 28 * ScaleFactor , "0xFF000000" , "0x99FF0000" , 1 , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 2 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawEllipse( G , Pen , ( x + 5 ) * ScaleFactor , 19 * ScaleFactor , ( w - 10 ) * ScaleFactor , ( h - 10 ) * ScaleFactor ) , Gdip_DeletePen( Pen )
Gdip_DeleteGraphics( G )
return pBitmap
}
;*******************&&&&&&&&&&&&&&&&&&&&&&&&************************************&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;*******************&&&&&&&&&&&&&&&&&&&&&&&&************************************&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
;*******************&&&&&&&&&&&&&&&&&&&&&&&&************************************&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
class DropDownListv1 {
Value[]{
Get{
return This.List[ This.Selected ]
}
}
__New( obj := "" ){
This._SetDefaults()
This._UpdateDefaults( obj )
This._CreateWindows()
This._CreateControls()
This._DrawHeader()
This._SetTimer( This.HoverTimer , 100 )
;~ SoundBeep 777
}
_SetDefaults(){
This.Parent := ""
This.ScaleFactor := 1
This.X := 10
This.Y := 10
This.W := 300
This.HeaderMargin := 5
This.Font := "Arial"
This.FontSize := 12
;~ This.FontColor := "0xFF000000"
This.FontColor := "0xFFFFFFFF"
This.FontOptions := "Center vCenter NoWrap "
This.H := Floor( This._GetTextSize() + 2 * This.HeaderMargin )
This.PanelStartingPositionY := 9
This.Selected := 1
This.StartingPosition := 1
;~ This.MainColor := "0xFFFFFFFF"
This.MainColor := "0xFF32363a"
;~ This.ArrowColor := "0xFF000000"
This.ArrowColor := "0xFFFF0000"
This.Rows := 10
This.BodyMargin := 3
This.PanelTextPading := 1
This.PanelTextHeight := Floor( This._GetTextSize() )
This.PanelHeight := This.PanelTextHeight + 2 * This.PanelTextPading
This.BodyHeight := This.BodyMargin * 2 + ( This.PanelHeight * This.Rows ) + ( This.BodyMargin * ( This.Rows - 1 ) ) + This.PanelStartingPositionY
This.ThumbMinY := This.PanelStartingPositionY + 2
This.ThumbRange := This.BodyHeight - This.ThumbMinY - 6
This.ThumbY := This.ThumbMinY
This.Interval := Floor( This.ThumbRange / This.List.Length() )
;~ This.PanelColor1 := "0xFFCFCFCF"
This.PanelColor1 := "0xFF22262a"
;~ This.PanelColor2 := "0xFFEFEFEF"
This.PanelColor2 := "0xFF12161a"
;~ This.HighLightPanelColor := "0x3300AAFF"
This.HighLightPanelColor := "0x33ff0000"
;~ This.SelectedPanelColor := "0x990099FF"
This.SelectedPanelColor := "0x99ff2222"
This.SelectedFontColor := This.FontColor
;~ This.HighlightFontColor := This.FontColor
This.HighlightFontColor := "0xFFFFFFFF"
This.HeaderFontColor := This.FontColor
;~ This.SliderTrackColor := "0xFFDCDCDC"
This.SliderTrackColor := "0xFF12161a"
;~ This.SliderButtonColor := "0xFFFFFFFF"
This.SliderButtonColor := "0xFF22262a"
;~ This.SliderRidgeColor := "0x33333333"
This.SliderRidgeColor := "0x66ff0000"
;~ This.BorderColor := "0x33000000"
This.BorderColor := "0x99880000"
;~ This.BorderColor := "0xff0000ff"
This.Hovered := ""
This.PanelControls := []
This.Active := 0
This.CallBind := This._CallBind.Bind( This )
This.HoverTimer := This._Hover.Bind( This )
;~ This.FocusColor := "0x990099FF"
This.FocusColor := "0x99ff0000"
This.Focused := 0
}
_UpdateDefaults( obj := "" ){
for k, v in obj
This[ k ] := obj[ k ]
This.H := Floor( This._GetTextSize() + 2 * This.HeaderMargin )
This.Roundness := This.H / 5
if( !IsObject( obj.Bind ) && obj.Bind )
This.Bind := func( obj.Bind ).Bind( This )
if( This.Rows < 5 )
This.Rows := 5
This.PanelTextHeight := Floor( This._GetTextSize() )
This.PanelHeight := This.PanelTextHeight + 2 * This.PanelTextPading
This.BodyHeight := This.BodyMargin * 2 + ( This.PanelHeight * This.Rows ) + ( This.BodyMargin * ( This.Rows - 1 ) ) + This.PanelStartingPositionY
This.ThumbMinY := This.PanelStartingPositionY + 2
This.ThumbRange := This.BodyHeight - This.ThumbMinY - 6 - 2
if( ( This.ThumbRange / 0.5 ) < This.List.Length() ){
Msgbox, 262144, Error, The list you are using exceeds the current maximum length. `n1
exitApp
}
This.Interval := Floor( ( This.ThumbRange * This.ScaleFactor) / This.List.Length() )
This.TotalInterval := This.Interval * This.List.Length()
This.ThumbHeight := This.ThumbRange - This.TotalInterval
While( This.Interval > 1 ){
;~ This.Interval -= 1
This.Interval -= 0.5
This.TotalInterval := This.Interval * This.List.Length()
This.ThumbHeight := This.ThumbRange - This.TotalInterval
}
if( ( This.ThumbHeight ) < 30 || !This.Interval ){
Msgbox, 262144, Error, % "The list you are using exceeds the current maximum length. `n2 "
exitApp
}
This.Thumb := { X: ( This.W - 32 ) , Y: This.ThumbMinY , W: 26 , H: This.ThumbHeight }
This._MoveThumbControl()
This.Panels := []
This.PanelHandles := []
temp := This.PanelStartingPositionY - 2
Loop, % This.Rows {
This.Panels[ A_Index ] := { X: 4 , Y: temp , W: ( This.W - 34 - 6 ) , H: This.PanelHeight , Hwnd: "" }
temp += This.PanelHeight + This.BodyMargin
}
This.ToggleButton := { X: 2 , Y: 2 , W: ( This.W - 4 ) , H: ( This.H - 4 ) , Hwnd: "" }
This.WheelActive := 0
This.FT := 0
OnMessage( 0x020A , This._WheelChange.Bind( This ) )
OnMessage( 0x201 , This._WatchFocus.Bind( This ) )
OnMessage( 0x100 , This._WatchKeyPress.Bind( This ) )
if( !obj.HasKey( "HeaderFontColor" ) )
This.HeaderFontColor := This.FontColor
if( !obj.HasKey( "HighlightFontColor" ) )
This.HighlightFontColor := This.FontColor
}
_CreateWindows(){
This.Gui1 := New PopUpWindow( { AutoShow: 1 , X: This.X * This.ScaleFactor , Y: This.Y * This.ScaleFactor , W: This.W * This.ScaleFactor , H: This.H * This.ScaleFactor , Options: " -DPIScale +AlwaysOnTop +Parent" This.Parent } )
This.Gui2 := New PopUpWindow( { AutoShow: 1 , X: This.X * This.ScaleFactor , Y: This.Y * This.ScaleFactor , W: This.W * This.ScaleFactor , H: This.BodyHeight * This.ScaleFactor , Options: " -DPIScale +AlwaysOnTop +Owner" This.Gui1.Hwnd } )
}
_CreateControls(){
Gui, % This.Gui2.Hwnd ":Add", Text, % "x" ( This.W - 34 ) * This.ScaleFactor " y" This.ThumbY * This.ScaleFactor " w" 30 * This.ScaleFactor " h" This.ThumbHeight * This.ScaleFactor " hwndhwnd"
This.ThumbHwnd := hwnd
bd := This._AdjustSlider.Bind( This )
GuiControl, % This.Gui2.Hwnd ":+G", % hwnd, % bd
Loop, % This.Rows {
Gui, % This.Gui2.Hwnd ":Add", Text, % "x" This.Panels[ A_Index ].X * This.ScaleFactor " y" This.Panels[ A_Index ].Y * This.ScaleFactor " w" This.Panels[ A_Index ].W * This.ScaleFactor " h" This.Panels[ A_Index ].H * This.ScaleFactor " hwndhwnd"
This.Panels[ A_Index ].Hwnd := hwnd
This.PanelHandles[ hwnd ] := A_Index
bd := This._SelectPanel.Bind( This )
GuiControl, % This.Gui2.Hwnd ":+G" , % hwnd , % bd
}
Gui, % This.Gui1.Hwnd ":Add", Text, % "x" This.ToggleButton.X * This.ScaleFactor " y" This.ToggleButton.Y * This.ScaleFactor " w" This.ToggleButton.W * This.ScaleFactor " h" This.ToggleButton.H * This.ScaleFactor " hwndhwnd"
This.ToggleButton.Hwnd := hwnd
This.HKBind := This._LButtonHK.Bind( This )
bd := This._ToggleBody.Bind( This )
GuiControl, % This.Gui1.Hwnd ":+G" , % hwnd , % bd
}
_MoveThumbControl(){
GuiControl, % This.Gui2.Hwnd ":Move" , % This.ThumbHwnd , % "y" This.Thumb.Y * This.ScaleFactor " h" This.ThumbHeight * This.ScaleFactor
}
_Hover(){
MouseGetPos,,, win , ctrl , 2
if( win = This.Gui2.Hwnd ){
if( !This.Hovered && This.PanelHandles[ ctrl ] ){
This.Hovered := ctrl
This._DrawBody()
}
}
if( This.Hovered && ctrl != This.Hovered ){
This.Hovered := ""
if( This.Active )
This._DrawBody()
}
}
_WheelChange( input ){
local ctrl , Dir , win
if( This.WheelActive )
return
if( This.ft := !This.ft )
return
This.WheelActive := 1
Dir := ( (input >> 16 ) > 0x7FFF ) || ( ( input < 0 ) ? ( 1 ) : ( 0 ) )
MouseGetPos,,, win, ctrl, 2
if( !Dir && ctrl = This.ToggleButton.Hwnd ){
( --This.Selected < 1 ) ? ( This.Selected := 1 )
This.StartingPosition := This.Selected
}else if( Dir && ctrl = This.ToggleButton.Hwnd ){
( ++This.Selected > This.List.Length() ) ? ( This.Selected := This.List.Length() )
This.StartingPosition := This.Selected
}else if( !Dir && win = This.Gui2.Hwnd ){
( --This.StartingPosition < 1 ) ? ( This.StartingPosition := 1 )
}else if( Dir && win = This.Gui2.Hwnd ){
( ++This.StartingPosition > This.List.Length() ) ? ( This.StartingPosition := This.List.Length() )
}
This.Thumb.Y := This.ThumbMinY + This.StartingPosition
This._MoveThumbControl()
This._DrawHeader()
if( This.Active )
This._DrawBody()
if( ctrl = This.ToggleButton.Hwnd )
This._SetTimer( This.CallBind , -30 )
This.WheelActive := 0
}
_WatchKeyPress( key ){
if( key = 9 && This.Focused )
This.SetFocus( 0 )
}
_WatchFocus(){
MouseGetPos,,, win, ctrl, 2
if( This.Focused && ctrl != This.ToggleButton.Hwnd && win != This.Gui2.Hwnd && ctrl )
This.SetFocus( 0 )
else if( !This.Focused && ( ctrl = This.ToggleButton.Hwnd || win = This.Gui2.Hwnd ) )
This.SetFocus( 1 )
}
SetFocus( value , option := 1 ){
if( This.Focused := value )
GuiControl, % This.Gui1.Hwnd ":Focus" , % This.ToggleButton.Hwnd
This._DrawHeader()
}
_SetTimer( Timer , Amount := 30 ){
SetTimer, % Timer, % Amount
}
_CallBind(){
Try
This.Bind.Call()
}
_SelectPanel(){
MouseGetPos,,,, ctrl, 2
if( This.List[ This.PanelHandles[ ctrl ] + This.StartingPosition - 1 ] != "" ){
This.Output := This.List[ This.PanelHandles[ ctrl ] + This.StartingPosition - 1 ]
This.Selected := This.PanelHandles[ ctrl ] + This.StartingPosition - 1
This._DrawBody()
bd := This.HKBind
HotKey, ~LButton, % bd , Off
This.Active := 0
This.Gui2.ClearWindow( 1 )
This._DrawHeader()
This._SetTimer( This.CallBind , -30 )
;~ This.Gui2.ClearWindow( 1 )
;~ ToolTip, % "Here`n" This.Gui2.hwnd
}
}
_ToggleBody(){
if( This.Active := !This.Active ){
WinGetPos, x, y,,, % "ahk_Id " This.Gui1.Hwnd
This.Gui2.UpdateSettings( { X: x , Y: y + ( This.Gui1.H ) } )
This.StartingPosition := This.Selected
This.Focused := 1
This._DrawBody()
bd := This.HKBind
Hotkey, ~LButton , % bd , On
}else{
This.Gui2.ClearWindow( 1 )
bd := This.HKBind
HotKey, ~LButton, % bd , Off
}
This._DrawHeader()
}
_LButtonHK(){
MouseGetPos,,, win, ctrl, 2
if( win != This.Gui2.Hwnd && ctrl != This.ToggleButton.Hwnd ){
bd := This.HKBind
HotKey, ~LButton, % bd , Off
This.Active := 0
This.Gui2.ClearWindow( 1 )
This._DrawHeader()
}
}
_AdjustSlider(){
local ly
CoordMode, Mouse, Client
While( GetKeyState( "LButton" ) ){
MouseGetPos,, y
if( ly != y ){
ly := y
y /= This.ScaleFactor
if( ( y - This.ThumbHeight / 2 ) < This.ThumbMinY ){
This.Thumb.Y := This.ThumbMinY
This.StartingPosition := 1
}else if( ( y + This.ThumbHeight / 2 ) > ( This.ThumbMinY + This.ThumbRange ) ){
This.Thumb.Y := This.ThumbMinY + This.ThumbRange - This.ThumbHeight
This.StartingPosition := This.List.Length()
}else{
This.Thumb.Y := y - This.ThumbHeight / 2
;~ This.StartingPosition := floor( This.Thumb.Y - This.ThumbMinY )
This.StartingPosition := floor( ( This.Thumb.Y - This.ThumbMinY ) / This.Interval )
}
This._MoveThumbControl()
This._DrawBody()
}
sleep, 10
}
}
_DrawHeader(){
local brush , pen
This.Gui1.ClearWindow()
Brush := Gdip_CreateLineBrushFromRect( 1 * This.ScaleFactor , 1 * This.ScaleFactor , ( This.W - 2 ) * This.ScaleFactor , ( This.H - 2 ) * This.ScaleFactor , This.MainColor , ( This.MainColor2 != "" ) ? ( This.MainColor2 ) : ( This.MainColor ) , 1 , 1 )
, Gdip_FillRoundedRectangle( This.Gui1.G , Brush , 2 * This.ScaleFactor , 2 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.H - 4 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
;~ Brush := Gdip_CreateLineBrush( 1 * This.ScaleFactor , 1 * This.ScaleFactor , ( This.W / 2 ) * This.ScaleFactor , ( This.H - 2 ) * This.ScaleFactor , "0xaaaaaaaa" , "0xFF000000" , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.Gui1.G , Pen , 2 * This.ScaleFactor , 2 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.H - 4 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeletePen( Pen )
Brush := Gdip_CreateLineBrush( 1 * This.ScaleFactor , 1 * This.ScaleFactor , ( This.W / 2 ) * This.ScaleFactor , ( This.H - 2 ) * This.ScaleFactor , "0xaa880000" , "0xFF000000" , 1 ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.Gui1.G , Pen , 2 * This.ScaleFactor , 2 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.H - 4 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeletePen( Pen )
if( This.Focused ){
Brush := Gdip_BrushCreateSolid( This.FocusColor )
, Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush )
, Gdip_DrawRoundedRectangle( This.Gui1.G , Pen , 4 * This.ScaleFactor , 4 * This.ScaleFactor , ( This.W - 8 ) * This.ScaleFactor , ( This.H - 8 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor )
, Gdip_DeletePen( Pen )
}
Brush := Gdip_BrushCreateSolid( This.HeaderFontColor ) , Gdip_TextToGraphics( This.Gui1.G , This.List[ This.Selected ] , "s" This.FontSize * This.ScaleFactor " " This.FontOptions " NoWrap c" Brush " x" 5 * This.ScaleFactor " y" 2 * This.ScaleFactor , This.Font , ( This.W - ( This.W / 4 ) ) * This.ScaleFactor , This.H * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.ArrowColor ) , Gdip_TextToGraphics( This.Gui1.G , ( !This.Active ) ? ( 6 ) : ( 5 ) , "s" ( s := 16 ) * This.ScaleFactor " " This.FontOptions " c" Brush " x" ( This.W - 30 ) * This.ScaleFactor " y" 1 * This.ScaleFactor , "WebDings" , 30 * This.ScaleFactor , This.H * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
This.Gui1.UpdateWindow()
}
_DrawBody(){
local temp , brush , pen , tog
This.Gui2.ClearWindow()
Brush := Gdip_BrushCreateSolid( This.MainColor ) , Gdip_FillRoundedRectangle( This.Gui2.G, Brush , 2 * This.ScaleFactor , 7 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.BodyHeight - 4 - 7 ) * This.ScaleFactor , 5 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
;**************************************
;~ ToolTip, % This.BorderColor
Pen := Gdip_CreatePen( This.BorderColor , 1 ) , Gdip_DrawRoundedRectangle( This.Gui2.G , Pen , 2 * This.ScaleFactor , 7 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.BodyHeight - 4 - 7 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeletePen( Pen )
;~ Brush := Gdip_BrushCreateSolid( This.BorderColor ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.Gui2.G , Pen , 2 * This.ScaleFactor , 7 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.BodyHeight - 4 - 7 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeletePen( Pen )
;~ Brush := Gdip_BrushCreateSolid( "0xFF0000FF" ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.Gui2.G , Pen , 2 * This.ScaleFactor , 7 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.BodyHeight - 4 - 7 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeletePen( Pen )
;~ Bob := This.BorderColor
;~ Brush := Gdip_BrushCreateSolid( Bob ) , Pen := Gdip_CreatePenFromBrush( Brush , 1 ) , Gdip_DeleteBrush( Brush ) , Gdip_DrawRoundedRectangle( This.Gui2.G , Pen , 2 * This.ScaleFactor , 7 * This.ScaleFactor , ( This.W - 4 ) * This.ScaleFactor , ( This.BodyHeight - 4 - 7 ) * This.ScaleFactor , This.Roundness * This.ScaleFactor ) , Gdip_DeletePen( Pen )
;**************************************
Brush := Gdip_BrushCreateSolid( This.MainColor ) , Gdip_FillPolygon( This.Gui2.G, Brush , ( This.W / 2 ) * This.ScaleFactor "," 0 * This.ScaleFactor "|" ( This.W - ( This.W / 5 ) ) * This.ScaleFactor "," 100 * This.ScaleFactor "|" ( This.W / 5 ) * This.ScaleFactor "," 100 * This.ScaleFactor "|" ) , Gdip_DeleteBrush( Brush )
temp := This.PanelStartingPositionY
Loop, % This.Rows {
tog := !tog
if( ( A_Index + This.StartingPosition - 1 ) = This.Selected ){
Brush := Gdip_BrushCreateSolid( This.SelectedPanelColor ) , Gdip_FillRoundedRectangle( This.Gui2.G, Brush , 4 * This.ScaleFactor , temp * This.ScaleFactor , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor , 5 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.SelectedFontColor ) , Gdip_TextToGraphics( This.Gui2.G, This.List[ A_Index + This.StartingPosition - 1 ] , "s" This.FontSize * This.ScaleFactor " NoWrap vCenter c" Brush " x" 4 * This.ScaleFactor " y" ( temp + 1 ) * This.ScaleFactor , This.Font , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
}else if( A_Index = This.PanelHandles[ This.Hovered ] ){
Brush := Gdip_BrushCreateSolid( This.HighLightPanelColor ) , Gdip_FillRoundedRectangle( This.Gui2.G, Brush , 4 * This.ScaleFactor , temp * This.ScaleFactor , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor , 5 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.HighlightFontColor ) , Gdip_TextToGraphics( This.Gui2.G, This.List[ A_Index + This.StartingPosition - 1 ] , "s" This.FontSize * This.ScaleFactor " NoWrap vCenter c" Brush " x" 4 * This.ScaleFactor " y" ( temp + 1 ) * This.ScaleFactor , This.Font , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
}else{
Brush := Gdip_BrushCreateSolid( ( !tog ) ? ( This.PanelColor1 ) : ( This.PanelColor2 ) ) , Gdip_FillRoundedRectangle( This.Gui2.G, Brush , 4 * This.ScaleFactor , temp * This.ScaleFactor , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor , 5 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.FontColor ) , Gdip_TextToGraphics( This.Gui2.G, This.List[ A_Index + This.StartingPosition - 1 ] , "s" This.FontSize * This.ScaleFactor " NoWrap vCenter c" Brush " x" 4 * This.ScaleFactor " y" ( temp + 1 ) * This.ScaleFactor , This.Font , ( This.W - 34 - 6 ) * This.ScaleFactor , This.PanelHeight * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
}
temp += This.PanelHeight + This.BodyMargin
}
Brush := Gdip_BrushCreateSolid( This.SliderTrackColor ) , Gdip_FillRoundedRectangle( This.Gui2.G, Brush , ( This.W - 34 ) * This.ScaleFactor , 9 * This.ScaleFactor , 30 * This.ScaleFactor , ( This.BodyHeight - 15 ) * This.ScaleFactor , 5 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.SliderButtonColor ) , Gdip_FillRoundedRectangle( This.Gui2.G, Brush , ( This.W - 32 ) * This.ScaleFactor , This.Thumb.Y * This.ScaleFactor , 26 * This.ScaleFactor , This.ThumbHeight * This.ScaleFactor , 5 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.SliderRidgeColor ) , Gdip_FillRectangle( This.Gui2.G , Brush , ( This.Thumb.X + 3 ) * This.ScaleFactor , ( This.Thumb.Y + ( This.ThumbHeight / 2 ) - 5 ) * This.ScaleFactor , ( This.Thumb.W - 6 ) * This.ScaleFactor , 3 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.SliderRidgeColor ) , Gdip_FillRectangle( This.Gui2.G , Brush , ( This.Thumb.X + 3 ) * This.ScaleFactor , ( This.Thumb.Y + ( This.ThumbHeight / 2 ) + 5 ) * This.ScaleFactor , ( This.Thumb.W - 6 ) * This.ScaleFactor , 3 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( This.SliderRidgeColor ) , Gdip_FillRectangle( This.Gui2.G , Brush , ( This.Thumb.X + 3 ) * This.ScaleFactor , ( This.Thumb.Y + ( This.ThumbHeight / 2 ) ) * This.ScaleFactor , ( This.Thumb.W - 6 ) * This.ScaleFactor , 3 * This.ScaleFactor ) , Gdip_DeleteBrush( Brush )
This.Gui2.UpdateWindow()
}
_GetTextSize( index := 4 ){
local pBitmap, G, Brush, temparr
pBitmap := Gdip_CreateBitmap( 10 , 10 ) , G := Gdip_GraphicsFromImage( pBitmap ), Gdip_SetSmoothingMode( G , 2 )
Brush := Gdip_BrushCreateSolid( "0xFF000000")
temparr := StrSplit( Gdip_TextToGraphics( G , ( This.Text ) ? ( This.Text ) : ( "Test String" ), " s" This.Fontsize " c" Brush " " This.FontOptions " x" 0 " y" 0 , This.Font , 10000, 10000 ),"|","|" ) , Gdip_DeleteBrush( Brush )
Gdip_DeleteGraphics( G ) , Gdip_DisposeImage( pBitmap )
return temparr[ index ]
}
Delete(){
This.Gui2.DeleteWindow()
This.Gui1.DeleteWindow()
}
}