void saveFlashFile(object wind, char *fname, char *name) { FILE *fp = fopen(fname, "wt"); object ctllist = gGetControls(wind); object seq, ctl, cls; if (!fp) return; setDialogName(name); fprintf(fp, "\nimport com.integra.system.*;\n\n"); fprintf(fp, "import com.integra.services.Service;\n"); fprintf(fp, "import com.integra.services.ServiceResponse;\n\n"); fprintf(fp, "\nvar ScalingFactor = %f;\n\n",SCALE_FACTOR); fprintf(fp, "var dlg%s:Dialog = new Dialog();\n",dialogName); fprintf(fp, "var ctl:Object;\n\n"); if (ctllist) for (seq = gSequence(ctllist) ; ctl = gNext(seq) ; ) { cls = ClassOf(ctl); if (cls == StaticTextControl) staticTextControl(fp, ctl); else if (cls == TextControl) textControl(fp, ctl); else if (cls == NumericControl) numericControl(fp, ctl); else if (cls == DateControl) dateControl(fp, ctl); else if (cls == PushButton) pushButtonControl(fp, ctl); else if (cls == RadioButton) radioButtonControl(fp, ctl); else if (cls == CheckBox) checkboxControl(fp, ctl); else if (cls == ListBox) listboxControl(fp, ctl); else if (cls == ComboBox) comboboxControl(fp, ctl); else if (cls == RectControl) rectControl(fp, ctl); else if (cls == LineControl) lineControl(fp, ctl); } fprintf(fp, "\n#include \"%s_d.as\"\n", name); fprintf(fp, "\n#include \"%s.as\"\n", name); fclose(fp); }
//*********************************************************************************************************** BOOL CBCGPBaseVisualCtrl::DoPrint(CDC* pDCIn, CPrintInfo* pInfo) { CObject* pBaseVisual = GetVisualBaseObject(); if (pBaseVisual == NULL) { return FALSE; } CBCGPBaseVisualObject* pVisualObject = DYNAMIC_DOWNCAST(CBCGPBaseVisualObject, pBaseVisual); CBCGPVisualContainer* pVisualContainer = DYNAMIC_DOWNCAST(CBCGPVisualContainer, pBaseVisual); if (pVisualObject == NULL && pVisualContainer == NULL) { return FALSE; } CBCGPGraphicsManager* pGM = GetGraphicsManager(); if (pGM == NULL) { return FALSE; } ASSERT_VALID(pGM); CDC* pDC = pDCIn; CPrintDialog* pPrintDlg = NULL; if (pDC == NULL) { pPrintDlg = new CPrintDialog(FALSE); if (pPrintDlg->DoModal() == IDCANCEL) { delete pPrintDlg; return FALSE; } pDC = CDC::FromHandle(pPrintDlg->GetPrinterDC()); pDC->m_bPrinting = TRUE; CString strTitle; strTitle.LoadString(AFX_IDS_APP_TITLE); DOCINFO di; ZeroMemory(&di, sizeof (DOCINFO)); di.cbSize = sizeof (DOCINFO); di.lpszDocName = strTitle; if (!pDC->StartDoc(&di)) { pDC->AbortDoc(); delete pPrintDlg; return FALSE; } pInfo = new CPrintInfo(); pInfo->m_rectDraw.SetRect(0,0, pDC->GetDeviceCaps(HORZRES), pDC->GetDeviceCaps(VERTRES)); } CSize size(pInfo->m_rectDraw.Size()); CBCGPRect rect(CBCGPPoint(), size); CBCGPRect rectControl(pVisualObject != NULL ? pVisualObject->GetRect() : pVisualContainer->GetRect()); CBCGPSize sizeScaleRatio((double)size.cx / rectControl.Width(), (double)size.cy / rectControl.Height()); double dAspect = min(sizeScaleRatio.cx, sizeScaleRatio.cy); sizeScaleRatio.cx = sizeScaleRatio.cy = dAspect; size.cx = bcg_clamp((int)(rectControl.Width() * dAspect), 0, size.cx); size.cy = bcg_clamp((int)(rectControl.Height() * dAspect), 0, size.cy); rect.SetSize(size); CDC dcPrint; CBitmap bmpPrint; CBitmap* pBmpPrintOld = NULL; CDC* pDCOut = NULL; CBrush brWhite(RGB(255, 255, 255)); if (DYNAMIC_DOWNCAST(CBCGPGraphicsManagerGDI, pGM) != NULL) { dcPrint.CreateCompatibleDC(NULL); bmpPrint.Attach(CBCGPDrawManager::CreateBitmap_32(size, NULL)); pBmpPrintOld = dcPrint.SelectObject (&bmpPrint); ASSERT(pBmpPrintOld != NULL); pDCOut = &dcPrint; } else { pGM->SetPrintInfo(pInfo); pDCOut = pDC; } pDCOut->FillRect((CRect)rect, &brWhite); pGM->BindDC(pDCOut); if (pGM->IsBindDCFailed()) { pDCOut->FillRect((CRect)rect, &brWhite); pDCOut->TextOut(0, 0, _T("Out of memory")); } else { pGM->BeginDraw(); CBCGPSize sizeScaleRatioOld; if (pVisualObject != NULL) { sizeScaleRatioOld = pVisualObject->GetScaleRatio(); pVisualObject->SetScaleRatio(sizeScaleRatio); pVisualObject->SetRect(rect); } else { sizeScaleRatioOld = pVisualContainer->GetScaleRatio(); pVisualContainer->SetScaleRatio(sizeScaleRatio); pVisualContainer->SetRect(rect); } pGM->Clear(); if (pVisualObject != NULL) { pVisualObject->OnDraw (pGM, rect); } else { pVisualContainer->OnDraw (pGM, rect); } pGM->EndDraw(); pGM->BindDC(NULL); if (pVisualObject != NULL) { pVisualObject->SetScaleRatio(sizeScaleRatioOld); } else { pVisualContainer->SetScaleRatio(sizeScaleRatioOld); } if (dcPrint.GetSafeHdc() != NULL) { CBCGPDrawManager::FillAlpha (rect, (HBITMAP)bmpPrint.GetSafeHandle (), 255); } } if (pVisualObject != NULL) { pVisualObject->SetRect(rectControl); pVisualObject->SetDirty (); } else { pVisualContainer->SetRect(rectControl); pVisualContainer->SetDirty (); } if (dcPrint.GetSafeHdc() != NULL) { BITMAP bmp = {0}; bmpPrint.GetBitmap (&bmp); CRect rectOut(pInfo->m_rectDraw.TopLeft (), CSize(bmp.bmWidth, bmp.bmHeight)); int mode = pDC->SetStretchBltMode(HALFTONE); pDC->BitBlt (rectOut.left, rectOut.top, rectOut.Width(), rectOut.Height(), &dcPrint, 0, 0, SRCCOPY); pDC->SetStretchBltMode(mode); dcPrint.SelectObject(pBmpPrintOld); } else { pGM->SetPrintInfo(NULL); } if (pPrintDlg != NULL) { pDC->EndDoc(); delete pPrintDlg; delete pInfo; } return TRUE; }