﻿Attribute VB_Name = "SCStdSettings"
Attribute VB_Base = "0{9BFA587F-4B31-46A3-B6BA-3B04FDEB2A60}{8B0E50EA-63EC-4259-99A6-F1E57D787B98}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = False
Option Explicit

' SquareClick Standard 1.3 - Compact Settings UI
' UserForm: SCStdSettings
' Business logic is unchanged; only size, layout, font and text appearance adjusted.

Public Confirmed As Boolean
Public SelectedMode As String

Private Sub UserForm_Initialize()
    Me.caption = "SquareClick - この文書の設定"
    Confirmed = False
    SelectedMode = vbNullString

    ' VBA editor uses the Windows Japanese code page. Use ChrW for symbols outside CP932.
    optEnable.caption = "有効にする（" & ChrW$(&H2611) & "ボックスを" & ChrW$(&H25A2) & "■に変更" & vbCrLf & _
                        "             + □・■をワンクリック）"
    optDisable.caption = "無効にする（元の操作に戻す）"
    lblInfo.caption = "現在開いている文書にだけ適用します。" & vbCrLf & _
                      "チェック状態と入力規則は維持されます。"
    cmdApply.caption = "設定を保存"
    cmdCancel.caption = "キャンセル"

    SCStd_ApplyCompactLayout
End Sub

Private Sub SCStd_ApplyCompactLayout()
    ' Dimensions are in points (not pixels).  Adjust the two values below if desired.
    Me.Width = 365
    Me.Height = 253
    Me.StartUpPosition = 1  ' CenterOwner
    Me.BackColor = RGB(250, 249, 244)

    With lblCurrent
        .Left = 25
        .Top = 15
        .Width = 315
        .Height = 22
        .WordWrap = False
        .BackStyle = 0  ' Transparent
        .Font.name = "Meiryo UI"
        .Font.Size = 12
        .Font.Bold = True
        .ForeColor = RGB(35, 80, 65)
    End With

    With lblInfo
        .Left = 25
        .Top = 45
        .Width = 318
        .Height = 34
        .WordWrap = True
        .BackStyle = 0
        .Font.name = "Meiryo UI"
        .Font.Size = 10
        .ForeColor = RGB(85, 85, 85)
    End With

    With optEnable
        .Left = 32
        .Top = 87
        .Width = 315
        .Height = 45
        .WordWrap = True
        .Font.name = "Meiryo UI"
        .Font.Size = 11
        .ForeColor = RGB(35, 35, 35)
    End With

    With optDisable
        .Left = 32
        .Top = 143
        .Width = 315
        .Height = 22
        .WordWrap = False
        .Font.name = "Meiryo UI"
        .Font.Size = 11
        .ForeColor = RGB(35, 35, 35)
    End With

    With cmdApply
        .Left = 36
        .Top = 179
        .Width = 140
        .Height = 30
        .Font.name = "Meiryo UI"
        .Font.Size = 11
        .Font.Bold = True
        .BackColor = RGB(255, 239, 176)
        .Default = True
    End With

    With cmdCancel
        .Left = 190
        .Top = 179
        .Width = 140
        .Height = 30
        .Font.name = "Meiryo UI"
        .Font.Size = 11
        .Cancel = True
    End With
End Sub

Public Sub InitFor(ByVal wb As Excel.Workbook)
    Dim st As String
    st = SquareClickStandard.SCStd_GetConsentForUI(wb)
    Select Case st
        Case "yes"
            lblCurrent.caption = "現在の設定：有効"
            lblCurrent.ForeColor = RGB(26, 109, 64)
            optEnable.value = True
        Case "no"
            lblCurrent.caption = "現在の設定：無効"
            lblCurrent.ForeColor = RGB(130, 73, 50)
            optDisable.value = True
        Case Else
            lblCurrent.caption = "現在の設定：未設定"
            lblCurrent.ForeColor = RGB(80, 80, 80)
            optEnable.value = True
    End Select
End Sub

Private Sub cmdApply_Click()
    Confirmed = True
    If optDisable.value Then
        SelectedMode = "no"
    Else
        SelectedMode = "yes"
    End If
    Me.Hide
End Sub

Private Sub cmdCancel_Click()
    Confirmed = False
    Me.Hide
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    If CloseMode = vbFormControlMenu Then
        Confirmed = False
        Cancel = True
        Me.Hide
    End If
End Sub


