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

CONST ID_TAB = 100
CONST ID_CHECKBOX = 101
CONST ID_RADIO1 = 102
CONST ID_RADIO2 = 103
CONST ID_EDIT = 104
CONST ID_COMBO = 105
CONST ID_SLIDER = 106
CONST ID_OK = 200
CONST 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 "  [ ] LONG wrap"
    IF s.showGrid THEN PRINT "  [x] Show grid: on" ELSE PRINT "  [x] Show grid: off"
    IF s.snapToGrid THEN PRINT "  [ ] Snap to grid: on" ELSE PRINT "  [ ] Snap to grid: 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

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

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)
    IF eq THEN PRINT "Changed: no" ELSE PRINT "Changed: 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
