#pragma once
#include <wx/wx.h>
#include <wx/dialog.h>

class wxSpinCtrl;
class wxRadioBox;
class wxCheckBox;
class wxStaticText;

// Modal dialog presented before each print job (and Print Preview).
// Captures the user's choices for scaling, level handling, color, and grid.
class PrintOptionsDialog : public wxDialog {
public:
    enum class ScaleMode {
        FitToPage,        // auto-fit layout onto one page
        ActualScale,      // 1:N — N is the denominator typed by user
        CustomPercent     // explicit percentage
    };
    enum class LevelMode {
        ActiveOnly,
        AllLevels
    };
    enum class ColorMode {
        Color,
        Grayscale
    };

    struct Options {
        ScaleMode scale         = ScaleMode::FitToPage;
        int       scaleDenom    = 10;     // 1:N, used when scale == ActualScale
        int       scalePercent  = 100;    // used when scale == CustomPercent
        LevelMode levels        = LevelMode::ActiveOnly;
        ColorMode color         = ColorMode::Color;
        bool      showGrid      = false;
        bool      showBaseboard = true;
    };

    PrintOptionsDialog(wxWindow* parent, const Options& initial);

    const Options& GetOptions() const { return m_opts; }

private:
    void OnOk(wxCommandEvent&);
    void OnScaleModeChanged(wxCommandEvent&);
    void UpdateEnabledState();

    Options       m_opts;
    wxRadioBox*   m_scaleRadio  = nullptr;
    wxSpinCtrl*   m_denomSpin   = nullptr;
    wxStaticText* m_denomLabel  = nullptr;
    wxSpinCtrl*   m_pctSpin     = nullptr;
    wxStaticText* m_pctLabel    = nullptr;
    wxRadioBox*   m_levelRadio  = nullptr;
    wxRadioBox*   m_colorRadio  = nullptr;
    wxCheckBox*   m_gridChk     = nullptr;
    wxCheckBox*   m_baseChk     = nullptr;

    wxDECLARE_EVENT_TABLE();
};
