Skip to content

Commit 77ef85e

Browse files
committed
Configuration Dialog: Prepare support for more control types
1 parent 225faca commit 77ef85e

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

Lib/Configuration.ahk

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ Class Configuration {
2929
If Not ControlType
3030
ControlType := "CheckBox"
3131
If Not ControlProperties
32-
ControlProperties := ""
33-
ControlProperties .= " "
32+
ControlProperties := {Options: "", Params: ""}
3433
Setting := {FileName: FileName, SectionName: SectionName, KeyName: KeyName, DefaultValue: DefaultValue, Label: Label, Tab: Tab, ControlType: ControlType, ControlProperties: ControlProperties, FuncOnInit: FuncOnInit, FuncOnChange: FuncOnChange, FuncOnSet: FuncOnSet}
3534
Setting.Value := IniRead(FileName, SectionName, KeyName, DefaultValue)
3635
IniWrite(Setting.Value, FileName, SectionName, KeyName)
@@ -119,16 +118,25 @@ Class Configuration {
119118
FirstControl := False
120119
If Not This.GuiControls.Has(Setting.SectionName)
121120
This.GuiControls[Setting.SectionName] := Map()
121+
Options := ""
122+
Params := ""
123+
If Setting.ControlProperties Is Object And Setting.ControlProperties.HasOwnProp("Options")
124+
Options := Setting.ControlProperties.Options
125+
If Setting.ControlProperties Is Object And Setting.ControlProperties.HasOwnProp("Params")
126+
Params := Setting.ControlProperties.Params
122127
If Setting.ControlType = "Edit" Or Setting.ControlType = "Hotkey" {
123128
This.ConfigBox.AddText("Section XS", Setting.Label)
124-
This.GuiControls[Setting.SectionName][Setting.KeyName] := This.ConfigBox.Add%Setting.ControlType%("YS", Setting.Value)
129+
This.GuiControls[Setting.SectionName][Setting.KeyName] := This.ConfigBox.Add%Setting.ControlType%("YS " . Options, Setting.Value)
125130
FirstControl := True
126131
}
132+
Else If Setting.ControlType = "CheckBox" {
133+
Checked := ""
134+
If Setting.Value = 1
135+
Checked := "Checked "
136+
This.GuiControls[Setting.SectionName][Setting.KeyName] := This.ConfigBox.Add%Setting.ControlType%(Position . Checked . Options, Setting.Label)
137+
}
127138
Else {
128-
Properties := Setting.ControlProperties
129-
If Setting.ControlType = "CheckBox" And Setting.Value = 1
130-
Properties .= "Checked"
131-
This.GuiControls[Setting.SectionName][Setting.KeyName] := This.ConfigBox.Add%Setting.ControlType%(Position . Properties, Setting.Label)
139+
This.GuiControls[Setting.SectionName][Setting.KeyName] := This.ConfigBox.Add%Setting.ControlType%(Position . Options, Params)
132140
}
133141
If Setting.FuncOnInit Is Object And Setting.FuncOnInit.HasMethod("Call")
134142
Setting.FuncOnInit.Call(This.GuiControls[Setting.SectionName][Setting.KeyName])

0 commit comments

Comments
 (0)