// FindAdjustBlobDlg.cpp : implementation file
//

#include "stdafx.h"
#include "apl_api.h"
#include "FindAdjustBlobDlg.h"
#include "FindQueryDlg.h"


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

/////////////////////////////////////////////////////////////////////////////
// CFindAdjustBlobDlg dialog


CFindAdjustBlobDlg::CFindAdjustBlobDlg(CWnd* pParent /*=NULL*/)
	: CaplTranslateDialog(CFindAdjustBlobDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CFindAdjustBlobDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_api=0;
	m_el=0;
//	m_is_update=true;
	m_read_only=false;
}


void CFindAdjustBlobDlg::DoDataExchange(CDataExchange* pDX)
{
	CaplTranslateDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFindAdjustBlobDlg)
	DDX_Control(pDX, IDC_CHECK_WHOLE_WORD, m_BtnCheckWhole);
	DDX_Control(pDX, IDC_EDIT_WORD, m_EdtWord);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CFindAdjustBlobDlg, CaplTranslateDialog)
	//{{AFX_MSG_MAP(CFindAdjustBlobDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFindAdjustBlobDlg message handlers

BOOL CFindAdjustBlobDlg::OnInitDialog() 
{
	CaplTranslateDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	if(m_api==0) return FALSE;
	if(m_el!=0)
	{
		m_BtnCheckWhole.SetCheck(m_el->is_equal);
		m_EdtWord.SetWindowText(m_el->word);

	}
	if(m_read_only){
		m_BtnCheckWhole.EnableWindow(FALSE);
		m_EdtWord.EnableWindow(FALSE);
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CFindAdjustBlobDlg::OnOK() 
{
	// TODO: Add extra validation here
	CString str;
	m_EdtWord.GetWindowText(str);
	if(!m_read_only){
		if(str==_T("")){
			AfxMessageBox( APL_T("Нельзя искать по пустому слову"));
			return;
		}
		if(str.FindOneOf(_T(",.;:?!\"'\\/%"))!=-1){
			AfxMessageBox( APL_T("Нельзя использовать в строке знаки препинания"));
			return;
		}
		if(m_el==0){
			m_el=new ElValBLOB();
		}
		m_el->is_equal=m_BtnCheckWhole.GetCheck()>0;
		m_el->word=str;
	}
	CaplTranslateDialog::OnOK();
}
