' Multi-tab settings dialog with controls via Win32 DECLARE
#COMPILE EXE
#DIM ALL

%ID_TAB      = 100
%ID_CHECKBOX = 101
%ID_RADIO1   = 102
%ID_RADIO2   = 103
%ID_EDIT     = 104
%ID_COMBO    = 105
%ID_SLIDER   = 106
%ID_OK       = 200
%ID_CANCEL   = 201

TYPE Settings
    autoSave AS LONG
    showGrid AS LONG
    snapToGrid AS LONG
    theme AS LONG
    fontSize AS LONG
    language AS STRING
    recentFiles AS LONG
END TYPE

SUB DefaultSettings(BYREF s AS Settings)
    s.autoSave = 1
    s.showGrid = 1
    s.snapToGrid = 0
    s.theme = 0
    s.fontSize = 12
    s.language = "English"
    s.recentFiles = 5
END SUB

SUB PrintSettings(BYREF s AS Settings)
    PRINT "Current settings:"
    PRINT "  Auto-save: "; s.autoSave
    PRINT "  Show grid: "; s.showGrid
    PRINT "  Snap to grid: "; s.snapToGrid
    PRINT "  Theme: "; s.theme
    PRINT "  Font size: "; s.fontSize
    PRINT "  Language: "; s.language
    PRINT "  Recent files: "; s.recentFiles
END SUB

SUB GeneralTab(BYREF s AS Settings)
    PRINT "--- General Settings ---"
    PRINT "  [x] Auto-save every "; s.fontSize; " minutes"
    PRINT "  [ ] Check for updates"
    PRINT "  [ ] Show startup tips"
    PRINT "  Language: "; s.language
    PRINT "  Recent files: "; s.recentFiles
END SUB

SUB EditorTab(BYREF s AS Settings)
    PRINT "--- Editor Settings ---"
    PRINT "  [x] Show line numbers"
    PRINT "  [x] Highlight current line"
    PRINT "  [ ] Word wrap"
    PRINT "  [x] Show grid: "; IIF(s.showGrid, "on", "off")
    PRINT "  [ ] Snap to grid: "; IIF(s.snapToGrid, "on", "off")
    PRINT "  Font size: "; s.fontSize
    PRINT "  Theme: "
    IF s.theme = 0 THEN PRINT "Light"
    IF s.theme = 1 THEN PRINT "Dark"
    IF s.theme = 2 THEN PRINT "High Contrast"
END SUB

SUB AdvancedTab(BYREF s AS Settings)
    PRINT "--- Advanced Settings ---"
    PRINT "  [ ] Enable telemetry"
    PRINT "  [x] Hardware acceleration"
    PRINT "  [ ] Developer mode"
    PRINT "  Max undo levels: 100"
    PRINT "  Auto-recovery interval: 30s"
END SUB

SUB TabNavigation()
    PRINT "Tab navigation simulation:"
    LOCAL s AS Settings
    DefaultSettings(s)
    PRINT ""
    GeneralTab(s)
    PRINT ""
    EditorTab(s)
    PRINT ""
    AdvancedTab(s)
END SUB

SUB ModifySettings(BYREF s AS Settings)
    s.autoSave = 0
    s.fontSize = 14
    s.theme = 1
    s.snapToGrid = 1
    s.recentFiles = 10
    PRINT "Settings modified:"
    PrintSettings(s)
END SUB

SUB ResetToDefaults(BYREF s AS Settings)
    DefaultSettings(s)
    PRINT "Settings reset to defaults"
END SUB

SUB CompareSettings(BYREF a AS Settings, BYREF b AS Settings) AS LONG
    IF a.autoSave <> b.autoSave THEN FUNCTION = 0
    IF a.showGrid <> b.showGrid THEN FUNCTION = 0
    IF a.snapToGrid <> b.snapToGrid THEN FUNCTION = 0
    IF a.theme <> b.theme THEN FUNCTION = 0
    IF a.fontSize <> b.fontSize THEN FUNCTION = 0
    FUNCTION = 1
END SUB

SUB DialogSimulation()
    PRINT "Settings dialog with multiple tabs:"
    PRINT "  Tab 1: General (language, auto-save)"
    PRINT "  Tab 2: Editor (grid, font, theme)"
    PRINT "  Tab 3: Advanced (telemetry, recovery)"
    PRINT ""
    LOCAL s  AS Settings
    LOCAL modified  AS Settings
    DefaultSettings(s)
    PrintSettings(s)
    PRINT ""
    modified = s
    modified.theme = 2
    modified.fontSize = 16
    PRINT "Preview change: Dark theme, size 16"
    PrintSettings(modified)
    LOCAL eq AS LONG
    eq = CompareSettings(s, modified)
    PRINT "Changed: "; IIF(eq, "no", "yes")
END SUB

FUNCTION PBMAIN() AS LONG
    PRINT "=== Settings Dialog Demo ==="
    PRINT "Win32: TabControl, CheckBox, Radio via DECLARE"
    PRINT ""
    TabNavigation()
    PRINT ""
    DialogSimulation()
    PRINT ""
    LOCAL cfg AS Settings
    DefaultSettings(cfg)
    ModifySettings(cfg)
    PRINT ""
    ResetToDefaults(cfg)
    PrintSettings(cfg)
    PRINT ""
    PRINT "=== End Settings Dialog ==="
    FUNCTION = 0
END FUNCTION
