// ZoneData.cpp : implementation file // #include "stdafx.h" #include "ocrutil.h" #include "ZoneData.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CZoneData dialog CZoneData::CZoneData(pZONEDATA pZone, CWnd* pParent /*=NULL*/) : CDialog(CZoneData::IDD, pParent) { //{{AFX_DATA_INIT(CZoneData) m_nHeight = 0; m_nLeft = 0; m_nTop = 0; m_nWidth = 0; m_csSectionName = _T(""); //}}AFX_DATA_INIT m_pZoneData = pZone; } void CZoneData::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CZoneData) DDX_Control(pDX, IDOK, m_btnOK); DDX_Control(pDX, IDC_EDIT_SECTION_NAME, m_edtSectionName); DDX_Control(pDX, IDC_EDIT_ZONE_AREA_WIDTH, m_edtWidth); DDX_Control(pDX, IDC_EDIT_ZONE_AREA_TOP, m_edtTop); DDX_Control(pDX, IDC_EDIT_ZONE_AREA_LEFT, m_edtLeft); DDX_Control(pDX, IDC_EDIT_ZONE_AREA_HEIGHT, m_edtHeight); DDX_Control(pDX, IDC_COMBO_ZONE_TYPE, m_cmbZoneType); DDX_Control(pDX, IDC_COMBO_RECOGNIZE_MODULE, m_cmbRecognizeModule); DDX_Control(pDX, IDC_COMBO_FILL_METHOD, m_cmbFillMethod); DDX_Control(pDX, IDC_COMBO_CHARACTER_FILTER, m_cmbCharFilter); DDX_Text(pDX, IDC_EDIT_ZONE_AREA_HEIGHT, m_nHeight); DDX_Text(pDX, IDC_EDIT_ZONE_AREA_LEFT, m_nLeft); DDX_Text(pDX, IDC_EDIT_ZONE_AREA_TOP, m_nTop); DDX_Text(pDX, IDC_EDIT_ZONE_AREA_WIDTH, m_nWidth); DDX_Text(pDX, IDC_EDIT_SECTION_NAME, m_csSectionName); DDV_MaxChars(pDX, m_csSectionName, 17); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CZoneData, CDialog) //{{AFX_MSG_MAP(CZoneData) ON_EN_CHANGE(IDC_EDIT_ZONE_AREA_HEIGHT, OnChangeEditZoneAreaHeight) ON_EN_CHANGE(IDC_EDIT_ZONE_AREA_LEFT, OnChangeEditZoneAreaLeft) ON_EN_CHANGE(IDC_EDIT_ZONE_AREA_TOP, OnChangeEditZoneAreaTop) ON_EN_CHANGE(IDC_EDIT_ZONE_AREA_WIDTH, OnChangeEditZoneAreaWidth) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CZoneData message handlers BOOL CZoneData::OnInitDialog() { CDialog::OnInitDialog(); m_cmbFillMethod.AddString(TEXT("Default")); m_cmbFillMethod.AddString(TEXT("Omni Font")); m_cmbFillMethod.AddString(TEXT("Draft Dot9")); m_cmbFillMethod.AddString(TEXT("OMR")); m_cmbFillMethod.AddString(TEXT("Hand Print")); m_cmbFillMethod.AddString(TEXT("Draft Dot24")); m_cmbFillMethod.AddString(TEXT("OCR A")); m_cmbFillMethod.AddString(TEXT("OCR B")); m_cmbFillMethod.AddString(TEXT("MICR")); m_cmbFillMethod.AddString(TEXT("Dot Digit")); m_cmbFillMethod.AddString(TEXT("Dash Digit")); m_cmbFillMethod.AddString(TEXT("No OCR")); m_cmbFillMethod.SetItemData(0, FILL_DEFAULT); m_cmbFillMethod.SetItemData(1, FILL_OMNIFONT); m_cmbFillMethod.SetItemData(2, FILL_DRAFTDOT9); m_cmbFillMethod.SetItemData(3, FILL_OMR); m_cmbFillMethod.SetItemData(4, FILL_HANDPRINT); m_cmbFillMethod.SetItemData(5, FILL_DRAFTDOT24); m_cmbFillMethod.SetItemData(6, FILL_OCRA); m_cmbFillMethod.SetItemData(7, FILL_OCRB); m_cmbFillMethod.SetItemData(8, FILL_MICR); m_cmbFillMethod.SetItemData(9, FILL_DOTDIGIT); m_cmbFillMethod.SetItemData(10,FILL_DASHDIGIT); m_cmbFillMethod.SetItemData(11,FILL_NO_OCR); m_cmbFillMethod.SetCurSel(m_pZoneData->FillMethod); m_cmbRecognizeModule.AddString(TEXT("Auto")); m_cmbRecognizeModule.AddString(TEXT("MText Omni Font")); m_cmbRecognizeModule.AddString(TEXT("Multi Lingual Omni Font")); m_cmbRecognizeModule.AddString(TEXT("Dot Matrix")); m_cmbRecognizeModule.AddString(TEXT("OMR")); m_cmbRecognizeModule.AddString(TEXT("Hand Printed Numeral")); m_cmbRecognizeModule.AddString(TEXT("RER Printed")); m_cmbRecognizeModule.AddString(TEXT("Matrix")); m_cmbRecognizeModule.AddString(TEXT("Omni Font PLUS2W")); m_cmbRecognizeModule.AddString(TEXT("Omni Font FRX")); m_cmbRecognizeModule.AddString(TEXT("Omni Font PLUS3W")); m_cmbRecognizeModule.SetItemData(0, RECOGMODULE_AUTO); m_cmbRecognizeModule.SetItemData(1, RECOGMODULE_MTEXT_OMNIFONT); m_cmbRecognizeModule.SetItemData(2, RECOGMODULE_MULTI_LINGUAL_OMNIFONT); m_cmbRecognizeModule.SetItemData(3, RECOGMODULE_DOT_MATRIX); m_cmbRecognizeModule.SetItemData(4, RECOGMODULE_OMR); m_cmbRecognizeModule.SetItemData(5, RECOGMODULE_HAND_PRINTED_NUMERAL); m_cmbRecognizeModule.SetItemData(6, RECOGMODULE_RER_PRINTED); m_cmbRecognizeModule.SetItemData(7, RECOGMODULE_MATRIX); m_cmbRecognizeModule.SetItemData(8, RECOGMODULE_OMNIFONT_PLUS2W); m_cmbRecognizeModule.SetItemData(9, RECOGMODULE_OMNIFONT_FRX); m_cmbRecognizeModule.SetItemData(10,RECOGMODULE_OMNIFONT_PLUS3W); m_cmbRecognizeModule.SetCurSel(m_pZoneData->RecogModule); m_cmbCharFilter.AddString(TEXT("Default")); m_cmbCharFilter.AddString(TEXT("Digit")); m_cmbCharFilter.AddString(TEXT("Uppercase")); m_cmbCharFilter.AddString(TEXT("Lowercase")); m_cmbCharFilter.AddString(TEXT("Punctuation")); m_cmbCharFilter.AddString(TEXT("Misc")); m_cmbCharFilter.AddString(TEXT("Plus")); m_cmbCharFilter.AddString(TEXT("All")); m_cmbCharFilter.AddString(TEXT("Alpha")); m_cmbCharFilter.AddString(TEXT("Numbers")); m_cmbCharFilter.SetItemData(0, ZONE_CHAR_FILTER_DEFAULT); m_cmbCharFilter.SetItemData(1, ZONE_CHAR_FILTER_DIGIT); m_cmbCharFilter.SetItemData(2, ZONE_CHAR_FILTER_UPPERCASE); m_cmbCharFilter.SetItemData(3, ZONE_CHAR_FILTER_LOWERCASE); m_cmbCharFilter.SetItemData(4, ZONE_CHAR_FILTER_PUNCTUATION); m_cmbCharFilter.SetItemData(5, ZONE_CHAR_FILTER_MISCELLANEOUS); m_cmbCharFilter.SetItemData(6, ZONE_CHAR_FILTER_PLUS); m_cmbCharFilter.SetItemData(7, ZONE_CHAR_FILTER_ALL); m_cmbCharFilter.SetItemData(8, ZONE_CHAR_FILTER_ALPHA); m_cmbCharFilter.SetItemData(9, ZONE_CHAR_FILTER_NUMBERS); m_cmbCharFilter.SetCurSel(m_pZoneData->CharFilter); m_cmbZoneType.AddString(TEXT("Flow Text")); m_cmbZoneType.AddString(TEXT("Table")); m_cmbZoneType.AddString(TEXT("Graphic")); m_cmbZoneType.AddString(TEXT("Column")); m_cmbZoneType.AddString(TEXT("Header")); m_cmbZoneType.AddString(TEXT("Footer")); m_cmbZoneType.AddString(TEXT("Caption")); m_cmbZoneType.AddString(TEXT("Title")); m_cmbZoneType.AddString(TEXT("Other")); m_cmbZoneType.AddString(TEXT("SGraphic")); m_cmbZoneType.SetItemData(0, ZONE_FLOWTEXT); m_cmbZoneType.SetItemData(1, ZONE_TABLE); m_cmbZoneType.SetItemData(2, ZONE_GRAPHIC); m_cmbZoneType.SetItemData(3, ZONE_COLUMN); m_cmbZoneType.SetItemData(4, ZONE_HEADER); m_cmbZoneType.SetItemData(5, ZONE_FOOTER); m_cmbZoneType.SetItemData(6, ZONE_CAPTION); m_cmbZoneType.SetItemData(7, ZONE_TITLE); m_cmbZoneType.SetItemData(8, ZONE_OTHER); m_cmbZoneType.SetItemData(9, ZONE_SGRAPHIC); m_cmbZoneType.SetCurSel(m_pZoneData->Type); CString csText; csText.Format(TEXT("%d"), m_pZoneData->rcArea.left); m_edtLeft.SetWindowText(csText); csText.Format(TEXT("%d"), m_pZoneData->rcArea.top); m_edtTop.SetWindowText(csText); csText.Format(TEXT("%d"), m_pZoneData->rcArea.right - m_pZoneData->rcArea.left); m_edtWidth.SetWindowText(csText); csText.Format(TEXT("%d"), m_pZoneData->rcArea.bottom - m_pZoneData->rcArea.top); m_edtHeight.SetWindowText(csText); ::SetWindowTextA ( m_edtSectionName.GetSafeHwnd(), m_pZoneData->szSection); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CZoneData::OnChangeEditZoneAreaHeight() { CheckOKButton(); } void CZoneData::OnChangeEditZoneAreaLeft() { CheckOKButton(); } void CZoneData::OnChangeEditZoneAreaTop() { CheckOKButton(); } void CZoneData::OnChangeEditZoneAreaWidth() { CheckOKButton(); } void CZoneData::CheckOKButton() { CString csLeft, csTop, csWidth, csHeight; m_edtLeft.GetWindowText(csLeft); m_edtTop.GetWindowText(csTop); m_edtWidth.GetWindowText(csWidth); m_edtHeight.GetWindowText(csHeight); m_btnOK.EnableWindow(!csLeft.IsEmpty() && !csTop.IsEmpty() && !csWidth.IsEmpty() && !csHeight.IsEmpty()); } void CZoneData::OnOK() { UpdateData(); m_pZoneData->rcArea.left = m_nLeft; m_pZoneData->rcArea.top = m_nTop; m_pZoneData->rcArea.right = m_nWidth + m_nLeft; m_pZoneData->rcArea.bottom = m_nHeight + m_nTop; m_pZoneData->FillMethod = (FILLMETHOD)m_cmbFillMethod.GetItemData(m_cmbFillMethod.GetCurSel()); m_pZoneData->RecogModule = (RECOGMODULE)m_cmbRecognizeModule.GetItemData(m_cmbRecognizeModule.GetCurSel()); m_pZoneData->CharFilter = (CHAR_FILTER)m_cmbCharFilter.GetItemData(m_cmbCharFilter.GetCurSel()); m_pZoneData->Type = (ZONETYPE)m_cmbZoneType.GetItemData(m_cmbZoneType.GetCurSel()); #ifdef UNICODE wcstombs ( m_pZoneData->szSection, m_csSectionName, MAX_SECTION_NAME_LENGTH); #else lstrcpy ( m_pZoneData->szSection, m_csSectionName ); #endif CDialog::OnOK(); }