// ★コメント未記入
// SettingMargin.cpp : インプリメンテーション ファイル
//

#include "stdafx.h"
#include "shitarabian.h"
#include "SettingMarginDlg.h"
#include "GeneralSetting.h"
#include "Common.h"
#include "SettingPath.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSettingMarginDlg ダイアログ


CSettingMarginDlg::CSettingMarginDlg(CWnd* pParent /*=NULL*/)
	: COwnerTabPage(CSettingMarginDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSettingMarginDlg)
	m_uiWheelMove = 0;
	m_bOneShotBOXSelect = FALSE;
	m_bBlockAlignment = FALSE;
	m_strQuote = _T("");
	m_bRestrainedScroll = FALSE;
	//}}AFX_DATA_INIT
}


void CSettingMarginDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSettingMarginDlg)
	DDX_Text(pDX, IDC_SETTING_WHEELMOVE, m_uiWheelMove);
	DDV_MinMaxUInt(pDX, m_uiWheelMove, 1, 256);
	DDX_Check(pDX, IDC_SETTING_ONESHOTBOXSELECT, m_bOneShotBOXSelect);
	DDX_Check(pDX, IDC_SETTING_BLOCKCENTERING, m_bBlockAlignment);
	DDX_Text(pDX, IDC_SETTING_QUOTE, m_strQuote);
	DDX_Check(pDX, IDC_SETTING_RESTRAINEDSCROLL, m_bRestrainedScroll);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSettingMarginDlg, CDialog)
	//{{AFX_MSG_MAP(CSettingMarginDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSettingMarginDlg メッセージ ハンドラ

void CSettingMarginDlg::Confirm() 
{
	WriteToGeneral();
}

void CSettingMarginDlg::WriteToGeneral()
{
	UpdateData( TRUE );

	CGeneralSetting*	pGeneralSetting	= CGeneralSetting::GetInstance();

	pGeneralSetting->SetOneShotBOXSelect( m_bOneShotBOXSelect );
	pGeneralSetting->SetBlockAlignment( m_bBlockAlignment );
	// ▼ (3330) BGN 2003.12.26 (dincom)
	pGeneralSetting->SetRestrainedScroll( m_bRestrainedScroll );
	// ▲ (3330) END

	if ( ((CButton*)GetDlgItem( IDC_SETTING_VSCROLL_1PIXEL ))->GetCheck() == 1 )
	{
		pGeneralSetting->SetVScrollUnit( Scroll1Pixel );
	}
	if ( ((CButton*)GetDlgItem( IDC_SETTING_VSCROLL_1ROW ))->GetCheck() == 1 )
	{
		pGeneralSetting->SetVScrollUnit( Scroll1Row );
	}
	if ( ((CButton*)GetDlgItem( IDC_SETTING_VSCROLL_2ROW ))->GetCheck() == 1 )
	{
		pGeneralSetting->SetVScrollUnit( Scroll2Row );
	}

	if ( ((CButton*)GetDlgItem( IDC_SETTING_HSCROLL_1PIXEL ))->GetCheck() == 1 )
	{
		pGeneralSetting->SetHScrollUnit( Scroll1Pixel );
	}
	if ( ((CButton*)GetDlgItem( IDC_SETTING_HSCROLL_1CHAR ))->GetCheck() == 1 )
	{
		pGeneralSetting->SetHScrollUnit( Scroll1Char );
	}
	if ( ((CButton*)GetDlgItem( IDC_SETTING_HSCROLL_2CHAR ))->GetCheck() == 1 )
	{
		pGeneralSetting->SetHScrollUnit( Scroll2Char );
	}

	pGeneralSetting->SetWheelMove( m_uiWheelMove );
	pGeneralSetting->SetQuote( m_strQuote );
}

void CSettingMarginDlg::ReadFromGeneral()
{
	CGeneralSetting*	pGeneralSetting	= CGeneralSetting::GetInstance();
	if( pGeneralSetting != NULL )
	{
		m_bOneShotBOXSelect = pGeneralSetting->GetOneShotBOXSelect();
		// ▼ (3330) BGN 2003.12.26 (dincom) 
		m_bRestrainedScroll = pGeneralSetting->GetRestrainedScroll();
		// ▲ (3330) END

		((CButton*)GetDlgItem( IDC_SETTING_HSCROLL_1PIXEL ))->SetCheck( FALSE );
		((CButton*)GetDlgItem( IDC_SETTING_HSCROLL_1CHAR ))->SetCheck( FALSE );
		((CButton*)GetDlgItem( IDC_SETTING_HSCROLL_2CHAR ))->SetCheck( FALSE );
		switch( pGeneralSetting->GetHScrollUnit() )
		{
		case Scroll1Pixel:
			((CButton*)GetDlgItem( IDC_SETTING_HSCROLL_1PIXEL ))->SetCheck( TRUE );
			break;
		case Scroll1Char:
			((CButton*)GetDlgItem( IDC_SETTING_HSCROLL_1CHAR ))->SetCheck( TRUE );
			break;
		case Scroll2Char:
			((CButton*)GetDlgItem( IDC_SETTING_HSCROLL_2CHAR ))->SetCheck( TRUE );
			break;
		default:
			break;
		}

		((CButton*)GetDlgItem( IDC_SETTING_VSCROLL_1PIXEL ))->SetCheck( FALSE );
		((CButton*)GetDlgItem( IDC_SETTING_VSCROLL_1ROW ))->SetCheck( FALSE );
		((CButton*)GetDlgItem( IDC_SETTING_VSCROLL_2ROW ))->SetCheck( FALSE );
		switch( pGeneralSetting->GetVScrollUnit() )
		{
		case Scroll1Pixel:
			((CButton*)GetDlgItem( IDC_SETTING_VSCROLL_1PIXEL ))->SetCheck( TRUE );
			break;
		case Scroll1Row:
			((CButton*)GetDlgItem( IDC_SETTING_VSCROLL_1ROW ))->SetCheck( TRUE );
			break;
		case Scroll2Row:
			((CButton*)GetDlgItem( IDC_SETTING_VSCROLL_2ROW ))->SetCheck( TRUE );
			break;
		default:
			break;
		}
		m_bBlockAlignment = pGeneralSetting->GetBlockAlignment();
		m_uiWheelMove = pGeneralSetting->GetWheelMove();
		m_strQuote = pGeneralSetting->GetQuote();
	}
	else
	{
		m_bOneShotBOXSelect = FALSE;
		m_bBlockAlignment = FALSE;
		m_uiWheelMove = 1;
		m_strQuote = _T(">");
	}

	UpdateData( FALSE );
}

BOOL CSettingMarginDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	ReadFromGeneral();
	
	return TRUE;  // コントロールにフォーカスを設定しないとき、戻り値は TRUE となります
	              // 例外: OCX プロパティ ページの戻り値は FALSE となります
}

