' commdlg.bas -- Common Dialog Library for DVX BASIC
'
' Provides file dialogs, input dialogs, and other common UI dialogs.
' Wrappers handle the AppContextT parameter internally so BASIC
' programs just pass the visible arguments.
'
' Usage: Add this file to your project.

DECLARE LIBRARY "basrt"
    ' Show a file Open dialog. Returns selected path, or "" if cancelled.
    ' filter$ specifies file type filters, pipe-delimited:
    '   "Label (pattern)|Label (pattern)|..."
    ' The pattern is extracted from inside the parentheses.
    ' Examples:
    '   "*.txt"                                         (single pattern, legacy)
    '   "Text Files (*.txt)|All Files (*.*)"            (two filters)
    '   "Images (*.bmp;*.png;*.jpg)|All Files (*.*)"    (multi-extension)
    DECLARE FUNCTION basFileOpen(BYVAL title AS STRING, BYVAL filter AS STRING) AS STRING

    ' Show a file Save dialog. Returns selected path, or "" if cancelled.
    ' filter$ uses the same format as basFileOpen.
    DECLARE FUNCTION basFileSave(BYVAL title AS STRING, BYVAL filter AS STRING) AS STRING

    ' Show a modal text input box. Returns entered text, or "" if cancelled.
    DECLARE FUNCTION basInputBox2(BYVAL title AS STRING, BYVAL prompt AS STRING, BYVAL defaultText AS STRING) AS STRING

    ' Show a choice dialog with a listbox. items$ is pipe-delimited
    ' (e.g. "Red|Green|Blue"). Returns chosen index (0-based), or -1.
    DECLARE FUNCTION basChoiceDialog(BYVAL title AS STRING, BYVAL prompt AS STRING, BYVAL items AS STRING, BYVAL defaultIdx AS INTEGER) AS INTEGER

    ' Show a modal integer input box with spinner. Returns the entered value.
    DECLARE FUNCTION basIntInput(BYVAL title AS STRING, BYVAL prompt AS STRING, BYVAL defaultVal AS INTEGER, BYVAL minVal AS INTEGER, BYVAL maxVal AS INTEGER) AS INTEGER

    ' Show a "Save changes?" prompt with Yes/No/Cancel buttons.
    DECLARE FUNCTION basPromptSave(BYVAL title AS STRING) AS INTEGER
END DECLARE

' Return value constants for basPromptSave
CONST DVX_SAVE_YES    = 1
CONST DVX_SAVE_NO     = 2
CONST DVX_SAVE_CANCEL = 3
