Ejemplo n.º 1
0
ILayout* FindLayoutNamed(const ParsedMui& muiInfo, const char* name) {
    for (size_t i = 0; i < muiInfo.layouts.size(); i++) {
        ILayout* l = muiInfo.layouts.at(i);
        if (l->IsNamed(name))
            return l;
    }
    return nullptr;
}
Ejemplo n.º 2
0
ILayout *FindLayoutNamed(const ParsedMui& muiInfo, const char *name)
{
    for (size_t i = 0; i < muiInfo.layouts.Count(); i++) {
        ILayout *l = muiInfo.layouts.At(i);
        if (l->IsNamed(name))
            return l;
    }
    return NULL;
}
Ejemplo n.º 3
0
void HwndWrapper::Arrange(const Rect finalRect) {
    if (layout) {
        // might over-write position if our layout knows about us
        layout->Arrange(finalRect);
    } else {
        if (children.size() == 1) {
            ILayout* l = children.at(0);
            l->Arrange(finalRect);
        }
    }
}
Ejemplo n.º 4
0
Size HwndWrapper::Measure(const Size availableSize) {
    if (layout) {
        return layout->Measure(availableSize);
    }
    if (children.size() == 1) {
        ILayout* l = children.at(0);
        return l->Measure(availableSize);
    }
    desiredSize = Size();
    return desiredSize;
}
Ejemplo n.º 5
0
Size Control::Measure(const Size availableSize)
{
    if (layout) {
        return layout->Measure(availableSize);
    }
    if (children.Count() == 1) {
        ILayout *l = children.At(0);
        return l->Measure(availableSize);
    }
    desiredSize = Size();
    return desiredSize;
}
Ejemplo n.º 6
0
tagSIZE ILayoutItem::GetRootOffset()
{
    CSize szOffset(0, 0);
    ILayout* pLayout = GetLayout();
    while (pLayout != NULL) {
        CRect rc = pLayout->GetRect();
        szOffset.cx += rc.left;
        szOffset.cy += rc.top;
    }

    return szOffset;
}
Ejemplo n.º 7
0
void Control::Arrange(const Rect finalRect)
{
    SetPosition(finalRect);
    if (layout) {
        // might over-write position if our layout knows about us
        layout->Arrange(finalRect);
    } else {
        if (children.Count() == 1) {
            ILayout *l = children.At(0);
            l->Arrange(finalRect);
        }
    }
}
Ejemplo n.º 8
0
void ocr(LPCTSTR pszName)
{
	USES_CONVERSION;

  HRESULT hr = NULL;
	IDocument  *pDoc = NULL;
	IImages *pImages = NULL;
	IImage *pImage = NULL;
	ILayout *pLayout = NULL;
	IWords *pWords = NULL;
	IWord *pWord = NULL;
	IMiRects *pRects = NULL;
	IMiRect *pRect = NULL;
  long iCount = 0, wCount = 0, rCount = 0, count = 0;
	long left, top, right, bottom, minTop = 0, maxBottom = 0, savedMaxBottom = 0;
	short conf = 0;
	double tConf = 0.0;

	CComBSTR bstrName;
	BSTR bstrText;
	CString strText;

#if _OCR_DEBUG > 0
	CString strDebug;
	strDebug.Format("OCR %s!", pszName);
	MessageBox(NULL, strDebug, "OCR.DLL", MB_ICONINFORMATION);
#endif

	hr = CoInitialize(0);
	// hr = CoInitializeEx(pReserved, COINIT_MULTITHREADED);
	// hr = CoInitializeEx(pReserved, COINIT_APARTMENTTHREADED);
#if _OCR_DEBUG > 0
	strDebug.Format("CoInitialize result = 0x%08X!", hr);
	MessageBox(NULL, strDebug, "OCR.DLL", MB_ICONINFORMATION);
#endif
	if (!SUCCEEDED(hr)) return;

	hr = CoCreateInstance(CLSID_Document, NULL, CLSCTX_INPROC_SERVER, IID_IDocument, (void**) &pDoc);
	// hr = CoCreateInstance(CLSID_Document, NULL, CLSCTX_INPROC_SERVER, IID_IDocument, (void**) &pDisp);
	// hr = pDisp->QueryInterface(IID_IDocument, (void**) &pDoc);
	// hr = pDoc.CoCreateInstance(CLSID_Document);
	// hr = CoGetClassObject(CLSID_Document, CLSCTX_INPROC_SERVER, NULL, IID_IDocument, (void**) &pDoc);
#if _OCR_DEBUG > 0
	strDebug.Format("CoCreateInstance result = 0x%08X!", hr);
	MessageBox(NULL, strDebug, "OCR.DLL", MB_ICONINFORMATION);
#endif
	if (!SUCCEEDED(hr)) return;

	bstrName = pszName;
	hr = pDoc->Create(bstrName);
#if _OCR_DEBUG > 0
	strDebug.Format("IDocument created, result = 0x%08X!", hr);
	MessageBox(NULL, strDebug, "OCR.DLL", MB_ICONINFORMATION);
#endif
	if (!SUCCEEDED(hr)) return;

	hr = pDoc->OCR(miLANG_CHINESE_SIMPLIFIED, FALSE, FALSE);
#if _OCR_DEBUG > 0
	strDebug.Format("IDocument OCR result = 0x%08X!", hr);
	MessageBox(NULL, strDebug, "OCR.DLL", MB_ICONINFORMATION);
#endif
	if (!SUCCEEDED(hr)) return;

	pDoc->get_Images(&pImages);
	pImages->get_Count(&iCount);
  for (long i = 0; i < iCount; i++ )
  {
		pImages->get_Item(i, (IDispatch**)&pImage);
    pImage->get_Layout(&pLayout);
		pLayout->get_Words(&pWords);
		pWords->get_Count(&wCount);

		for (long j = 0; j < wCount; j++)
		{
			pWords->get_Item(j, (IDispatch**)&pWord);
			pWord->get_Rects(&pRects);
			pRects->get_Count(&rCount);
			minTop = maxBottom = 0;
			for (long k = 0; k < rCount; k++)
			{
				pRects->get_Item(k, (IDispatch**)&pRect);
				pRect->get_Left(&left);
				pRect->get_Top(&top);
				pRect->get_Right(&right);
				pRect->get_Bottom(&bottom);
				if (minTop == 0) minTop = top;
				if (minTop > top) minTop = top;
				if (maxBottom < bottom) maxBottom = bottom;
				if (pRect) pRect->Release();
			}
			if (pRects) pRects->Release();
			if (savedMaxBottom == 0) savedMaxBottom = maxBottom;
			if (minTop >= savedMaxBottom)
			{
				tConf /= count;
				savedMaxBottom = maxBottom;
				strText = "";
				tConf = 0.0;
				count = 0;
			}
			pWord->get_Text(&bstrText);
			pWord->get_RecognitionConfidence(&conf);
			tConf += conf;
			count++;
			strText += bstrText ? OLE2CT(bstrText) : _T("");
			if (pWord) pWord->Release();
		}
		if (strText.GetLength() > 0)
		{
				tConf /= count;
				strText = "";
				tConf = 0.0;
				count = 0;
		}
		if (pWords) pWords->Release();
		if (pLayout) pLayout->Release();
		if (pImage) pImage->Release();
  }
	if (pImages) pImages->Release();
  pDoc->Close(0);
  pDoc->Release();
	CoUninitialize();
	return pItems;
}