void CReportEntityBox::Draw( CDC* dc, CRect rect ) /* ============================================================ Function : CReportEntityBox::Draw Description : Draws the object. Access : Public Return : void Parameters : CDC* dc - "CDC" to draw to CRect rect - True (zoomed) rectangle to draw to. Usage : Called from "CDiagramEditor::DrawObjects". ============================================================*/ { if( GetFill() ) { const float* table = Drawer::GetColorByIndex(GetFillColor()); COLORREF clr = RGB((int)(table[0]*255.0f),(int)(table[1]*255.0f),(int)(table[2]*255.0f)); dc->FillSolidRect(rect,clr); } CPen pen; if( GetBorderStyle()!=0 ) { const float* table = Drawer::GetColorByIndex(GetBorderColor()); COLORREF clr = RGB((int)(table[0]*255.0f),(int)(table[1]*255.0f),(int)(table[2]*255.0f)); pen.CreatePen( PS_SOLID, GetBorderThickness(), clr ); dc->SelectObject( &pen ); if (GetBorderStyle() & DIAGRAM_FRAME_STYLE_LEFT) { dc->MoveTo(rect.left,rect.bottom); dc->LineTo(rect.left,rect.top); } if (GetBorderStyle() & DIAGRAM_FRAME_STYLE_RIGHT) { dc->MoveTo(rect.right,rect.bottom); dc->LineTo(rect.right,rect.top); } if (GetBorderStyle() & DIAGRAM_FRAME_STYLE_TOP) { dc->MoveTo(rect.left,rect.top); dc->LineTo(rect.right,rect.top); } if (GetBorderStyle() & DIAGRAM_FRAME_STYLE_BOTTOM) { dc->MoveTo(rect.left,rect.bottom); dc->LineTo(rect.right,rect.bottom); } } else dc->SelectStockObject( NULL_PEN ); dc->SelectStockObject( BLACK_PEN ); dc->SelectStockObject( WHITE_BRUSH ); }
CString CReportEntityPicture::GetString() const /* ============================================================ Function : CReportEntityPicture::GetString Description : Creates a string representing this object. Access : Public Return : CString - Resulting string Parameters : none Usage : Call to save this object to file. ============================================================*/ { CRect rect = GetRect(); double oldleft = GetLeft(); double oldright = GetRight(); double oldtop = GetTop(); double oldbottom = GetBottom(); double left = CUnitConversion::PixelsToInches( rect.left ); double right = CUnitConversion::PixelsToInches( rect.right ); double top = CUnitConversion::PixelsToInches( rect.top ); double bottom = CUnitConversion::PixelsToInches( rect.bottom ); CReportEntityPicture* const local = const_cast< CReportEntityPicture* const >( this ); local->SetLeft( left ); local->SetRight( right ); local->SetTop( top ); local->SetBottom( bottom ); CString str; CString filename = GetFilename(); MakeSaveString( filename ); double thickness = CUnitConversion::PixelsToInches( GetBorderThickness() ); str.Format( _T( ",%f,%i,%i,%s" ), thickness, GetBorderStyle( ), GetBorderColor( ), filename ); str += _T( ";" ); str = GetDefaultGetString() + str; local->SetLeft( oldleft ); local->SetRight( oldright ); local->SetTop( oldtop ); local->SetBottom( oldbottom ); return str; }
void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device) { CFX_FloatRect rectWnd = GetWindowRect(); if (!rectWnd.IsEmpty()) { if (HasFlag(PWS_BACKGROUND)) { CFX_FloatRect rcClient = CPWL_Utils::DeflateRect( rectWnd, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient, GetBackgroundColor(), GetTransparency()); } if (HasFlag(PWS_BORDER)) CPWL_Utils::DrawBorder(pDevice, pUser2Device, rectWnd, (FX_FLOAT)GetBorderWidth(), GetBorderColor(), GetBorderLeftTopColor(GetBorderStyle()), GetBorderRightBottomColor(GetBorderStyle()), GetBorderStyle(), GetTransparency()); } }
// if don't set,Get default apperance stream void CPWL_Wnd::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { CFX_FloatRect rectWnd = GetWindowRect(); if (!rectWnd.IsEmpty()) { CFX_ByteTextBuf sThis; if (HasFlag(PWS_BACKGROUND)) sThis << CPWL_Utils::GetRectFillAppStream(rectWnd, GetBackgroundColor()); if (HasFlag(PWS_BORDER)) { sThis << CPWL_Utils::GetBorderAppStream( rectWnd, (FX_FLOAT)GetBorderWidth(), GetBorderColor(), GetBorderLeftTopColor(GetBorderStyle()), GetBorderRightBottomColor(GetBorderStyle()), GetBorderStyle(), GetBorderDash()); } sAppStream << sThis; } }
void CReportEntityBox::Serialize(CArchive& ar) { typedef struct { int a_f; int b_f; } BOX_RESERVE_FIELDS; BOX_RESERVE_FIELDS box_reserve; memset(&box_reserve,0,sizeof(BOX_RESERVE_FIELDS)); CDiagramEntity::Serialize(ar); if (ar.IsStoring()) { // —охран¤ем double thickness = CUnitConversion::PixelsToInches( GetBorderThickness() ); ar.Write(&thickness,sizeof(double)); unsigned int bst = GetBorderStyle( ); ar.Write(&bst,sizeof(unsigned int)); unsigned int brC = GetBorderColor( ); ar.Write(&brC,sizeof(unsigned int)); BOOL gf = GetFill(); ar.Write(&gf, sizeof(BOOL)); brC = GetFillColor(); ar.Write(&brC,sizeof(unsigned int)); ar.Write(&box_reserve,sizeof(BOX_RESERVE_FIELDS)); } else { // „итаем double bordhickness; ar.Read(&bordhickness,sizeof(double)); unsigned int bordst; ar.Read(&bordst,sizeof(unsigned int)); unsigned int linecolor; ar.Read(&linecolor,sizeof(unsigned int)); BOOL fil; ar.Read(&fil,sizeof(BOOL)); unsigned int filcolor; ar.Read(&filcolor,sizeof(unsigned int)); ar.Read(&box_reserve,sizeof(BOX_RESERVE_FIELDS)); int bt = CUnitConversion::InchesToPixels( bordhickness ); SetBorderThickness( bt ); SetBorderStyle( bordst ); SetBorderColor( linecolor ); SetFill( fil ); SetFillColor( filcolor ); } }
void CTesthelpCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& /*rcInvalid*/) { // Drawing code, mostly plagiarized from the Circ MFC sample. // The only thing done here is setting the border and drawing text // specified by our name properties in the control's client area. if(!GetBorderStyle()) //Control will always have a border. SetBorderStyle(TRUE); // Set up variables to use for drawing text background. // Use our current BackColor for the background color. CBrush* pOldBrush; CBrush bkBrush(TranslateColor(GetBackColor())); CPen* pOldPen; CRect rc = rcBounds; CFont* pOldFont; // Set up background mode and text color. Use the // current ForeColor for the text color. pdc->SetTextColor(TranslateColor(GetForeColor())); pdc->SetBkMode(TRANSPARENT); // Fill our window with the current BackColor pdc->FillRect(rcBounds, &bkBrush); // Save off the existing brush and pen so they // can be restored when we're done. pOldBrush = pdc->SelectObject(&bkBrush); pOldPen = (CPen*)pdc->SelectStockObject(BLACK_PEN); // Save off the current font so we can restore it and // select our current stock font into this DC pOldFont = SelectStockFont(pdc); // Draw the text on our window pdc->ExtTextOut(rc.left+10, rc.top +2, ETO_CLIPPED, rc, m_szName1, m_szName1.GetLength(), NULL); pdc->ExtTextOut(rc.left+10, rc.top +22, ETO_CLIPPED, rc, m_szName2, m_szName2.GetLength(), NULL); pdc->ExtTextOut(rc.left+10, rc.top +42, ETO_CLIPPED, rc, m_szName3, m_szName3.GetLength(), NULL); // Restore our DC to it's original state. pdc->SelectObject(pOldFont); pdc->SelectObject(pOldPen); pdc->SelectObject(pOldBrush); }
void QGraph::SaveSettings(QSettings *pSettings) { QFont lgft; QColor clr; int k,s,w; bool ba, bs; double f; pSettings->beginGroup(m_GraphName); { //read variables clr = GetAxisColor(); pSettings->setValue("AxisColorRed", clr.red()); pSettings->setValue("AxisColorGreen",clr.green()); pSettings->setValue("AxisColorBlue", clr.blue()); k = GetAxisStyle(); pSettings->setValue("AxisStyle", k); k = GetAxisWidth(); pSettings->setValue("AxisWidth", k); clr = GetTitleColor(); pSettings->setValue("TitleColorRed", clr.red()); pSettings->setValue("TitleColorGreen",clr.green()); pSettings->setValue("TitleColorBlue", clr.blue()); clr = GetLabelColor(); pSettings->setValue("LabelColorRed", clr.red()); pSettings->setValue("LabelColorGreen",clr.green()); pSettings->setValue("LabelColorBlue", clr.blue()); GetTitleLogFont(&lgft); pSettings->setValue("TitleFontName", lgft.family()); pSettings->setValue("TitleFontSize", lgft.pointSize()); GetLabelLogFont(&lgft); pSettings->setValue("LabelFontName", lgft.family()); pSettings->setValue("LabelFontSize", lgft.pointSize()); GetXMajGrid(bs,clr,s,w); pSettings->setValue("XMajGridColorRed", clr.red()); pSettings->setValue("XMajGridColorGreen",clr.green()); pSettings->setValue("XMajGridColorBlue", clr.blue()); pSettings->setValue("XMajGridShow",bs); pSettings->setValue("XMajGridStyle",s); pSettings->setValue("XMajGridWidth",w); GetYMajGrid(bs,clr,s,w); pSettings->setValue("YMajGridColorRed", clr.red()); pSettings->setValue("YMajGridColorGreen",clr.green()); pSettings->setValue("YMajGridColorBlue", clr.blue()); pSettings->setValue("YMajGridShow",bs); pSettings->setValue("YMajGridStyle",s); pSettings->setValue("YMajGridWidth",w); GetXMinGrid(bs,ba,clr,s,w,f); pSettings->setValue("XMinGridColorRed", clr.red()); pSettings->setValue("XMinGridColorGreen",clr.green()); pSettings->setValue("XMinGridColorBlue", clr.blue()); pSettings->setValue("XMinGridAuto",ba); pSettings->setValue("XMinGridShow",bs); pSettings->setValue("XMinGridStyle",s); pSettings->setValue("XMinGridWidth",w); pSettings->setValue("XMinGridUnit",f); GetYMinGrid(bs,ba,clr,s,w,f); pSettings->setValue("YMinGridColorRed", clr.red()); pSettings->setValue("YMinGridColorGreen",clr.green()); pSettings->setValue("YMinGridColorBlue", clr.blue()); pSettings->setValue("YMinGridAuto",ba); pSettings->setValue("YMinGridShow",bs); pSettings->setValue("YMinGridStyle",s); pSettings->setValue("YMinGridWidth",w); pSettings->setValue("YMinGridUnit",f); clr = GetBorderColor(); s = GetBorderStyle(); w = GetBorderWidth(); pSettings->setValue("BorderColorRed", clr.red()); pSettings->setValue("BorderColorGreen", clr.green()); pSettings->setValue("BorderColorBlue", clr.blue()); pSettings->setValue("BorderStyle", s); pSettings->setValue("BorderWidth", w); pSettings->setValue("BorderShow", m_bBorder); clr = GetBackColor(); pSettings->setValue("BackColorRed", clr.red()); pSettings->setValue("BackColorGreen", clr.green()); pSettings->setValue("BackColorBlue", clr.blue()); pSettings->setValue("Inverted", m_bYInverted); pSettings->setValue("XVariable", m_X); pSettings->setValue("YVariable", m_Y); } pSettings->endGroup(); }
void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device) { CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); CPDF_Rect rcClient = GetClientRect(); CFX_ByteTextBuf sLine; int32_t nCharArray = m_pEdit->GetCharArray(); FX_SAFE_INT32 nCharArraySafe = nCharArray; nCharArraySafe -= 1; nCharArraySafe *= 2; if (nCharArray > 0 && nCharArraySafe.IsValid()) { switch (GetBorderStyle()) { case PBS_SOLID: { CFX_GraphStateData gsd; gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); CFX_PathData path; path.SetPointCount(nCharArraySafe.ValueOrDie()); for (int32_t i = 0; i < nCharArray - 1; i++) { path.SetPoint( i * 2, rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.bottom, FXPT_MOVETO); path.SetPoint( i * 2 + 1, rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.top, FXPT_LINETO); } if (path.GetPointCount() > 0) pDevice->DrawPath( &path, pUser2Device, &gsd, 0, CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), FXFILL_ALTERNATE); } break; case PBS_DASH: { CFX_GraphStateData gsd; gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); gsd.SetDashCount(2); gsd.m_DashArray[0] = (FX_FLOAT)GetBorderDash().nDash; gsd.m_DashArray[1] = (FX_FLOAT)GetBorderDash().nGap; gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPhase; CFX_PathData path; path.SetPointCount(nCharArraySafe.ValueOrDie()); for (int32_t i = 0; i < nCharArray - 1; i++) { path.SetPoint( i * 2, rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.bottom, FXPT_MOVETO); path.SetPoint( i * 2 + 1, rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.top, FXPT_LINETO); } if (path.GetPointCount() > 0) pDevice->DrawPath( &path, pUser2Device, &gsd, 0, CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), FXFILL_ALTERNATE); } break; } } CPDF_Rect rcClip; CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange(); CPVT_WordRange* pRange = NULL; if (!HasFlag(PES_TEXTOVERFLOW)) { rcClip = GetClientRect(); pRange = &wrRange; } IFX_SystemHandler* pSysHandler = GetSystemHandler(); IFX_Edit::DrawEdit( pDevice, pUser2Device, m_pEdit, CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()), rcClip, CPDF_Point(0.0f, 0.0f), pRange, pSysHandler, m_pFormFiller); if (HasFlag(PES_SPELLCHECK)) { CPWL_Utils::DrawEditSpellCheck(pDevice, pUser2Device, m_pEdit, rcClip, CPDF_Point(0.0f, 0.0f), pRange, GetCreationParam().pSpellCheck); } }
void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { CPWL_Wnd::GetThisAppearanceStream(sAppStream); CPDF_Rect rcClient = GetClientRect(); CFX_ByteTextBuf sLine; int32_t nCharArray = m_pEdit->GetCharArray(); if (nCharArray > 0) { switch (GetBorderStyle()) { case PBS_SOLID: { sLine << "q\n" << GetBorderWidth() << " w\n" << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) << " 2 J 0 j\n"; for (int32_t i = 1; i < nCharArray; i++) { sLine << rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * i << " " << rcClient.bottom << " m\n" << rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * i << " " << rcClient.top << " l S\n"; } sLine << "Q\n"; } break; case PBS_DASH: { sLine << "q\n" << GetBorderWidth() << " w\n" << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) << " 2 J 0 j\n" << "[" << GetBorderDash().nDash << " " << GetBorderDash().nGap << "] " << GetBorderDash().nPhase << " d\n"; for (int32_t i = 1; i < nCharArray; i++) { sLine << rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * i << " " << rcClient.bottom << " m\n" << rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * i << " " << rcClient.top << " l S\n"; } sLine << "Q\n"; } break; } } sAppStream << sLine; CFX_ByteTextBuf sText; CPDF_Point ptOffset = CPDF_Point(0.0f, 0.0f); CPVT_WordRange wrWhole = m_pEdit->GetWholeWordRange(); CPVT_WordRange wrSelect = GetSelectWordRange(); CPVT_WordRange wrVisible = (HasFlag(PES_TEXTOVERFLOW) ? wrWhole : m_pEdit->GetVisibleWordRange()); CPVT_WordRange wrSelBefore(wrWhole.BeginPos, wrSelect.BeginPos); CPVT_WordRange wrSelAfter(wrSelect.EndPos, wrWhole.EndPos); CPVT_WordRange wrTemp = CPWL_Utils::OverlapWordRange(GetSelectWordRange(), wrVisible); CFX_ByteString sEditSel = CPWL_Utils::GetEditSelAppStream(m_pEdit, ptOffset, &wrTemp); if (sEditSel.GetLength() > 0) sText << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELBACKCOLOR) << sEditSel; wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelBefore); CFX_ByteString sEditBefore = CPWL_Utils::GetEditAppStream( m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), m_pEdit->GetPasswordChar()); if (sEditBefore.GetLength() > 0) sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEditBefore << "ET\n"; wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelect); CFX_ByteString sEditMid = CPWL_Utils::GetEditAppStream( m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), m_pEdit->GetPasswordChar()); if (sEditMid.GetLength() > 0) sText << "BT\n" << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_GRAY, 1)) << sEditMid << "ET\n"; wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelAfter); CFX_ByteString sEditAfter = CPWL_Utils::GetEditAppStream( m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), m_pEdit->GetPasswordChar()); if (sEditAfter.GetLength() > 0) sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEditAfter << "ET\n"; if (HasFlag(PES_SPELLCHECK)) { CFX_ByteString sSpellCheck = CPWL_Utils::GetSpellCheckAppStream( m_pEdit, m_pSpellCheck, ptOffset, &wrVisible); if (sSpellCheck.GetLength() > 0) sText << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_RGB, 1, 0, 0), FALSE) << sSpellCheck; } if (sText.GetLength() > 0) { CPDF_Rect rcClient = GetClientRect(); sAppStream << "q\n/Tx BMC\n"; if (!HasFlag(PES_TEXTOVERFLOW)) sAppStream << rcClient.left << " " << rcClient.bottom << " " << rcClient.right - rcClient.left << " " << rcClient.top - rcClient.bottom << " re W n\n"; sAppStream << sText; sAppStream << "EMC\nQ\n"; } }
void CReportEntityPicture::Draw( CDC* dc, CRect rect ) /* ============================================================ Function : CReportEntityPicture::Draw Description : Draws the object. Access : Public Return : void Parameters : CDC* dc - "CDC" to draw to CRect rect - True (zoomed) rectangle to draw to. Usage : Called from "CDiagramEditor::DrawObjects". ============================================================*/ { if( m_bitmap ) { if (dc->IsPrinting()) { // get size of printer page (in pixels) int cxPage = dc->GetDeviceCaps(HORZRES); int cyPage = dc->GetDeviceCaps(VERTRES); //int dcbpp = pDC->GetDeviceCaps(BITSPIXEL); //int dcnc = pDC->GetDeviceCaps(NUMCOLORS); //int dcp = pDC->GetDeviceCaps(PLANES); // get printer pixels per inch int cxInch = dc->GetDeviceCaps(LOGPIXELSX); int cyInch = dc->GetDeviceCaps(LOGPIXELSY); // Best Fit case: create a rectangle which preserves the aspect ratio int cx=m_bitmap->GetXDPI()?(m_bitmap->GetWidth()*cxInch)/m_bitmap->GetXDPI(): m_bitmap->GetWidth()*cxInch/96; int cy=m_bitmap->GetYDPI()?(m_bitmap->GetHeight()*cyInch)/m_bitmap->GetYDPI(): m_bitmap->GetHeight()*cyInch/96; cx = rect.Width(); cy = rect.Height(); // print it! /*HDC TmpDC=CreateCompatibleDC(pDC->GetSafeHdc()); HBITMAP bm =::CreateCompatibleBitmap(pDC->GetSafeHdc(), cx, cy); HBITMAP oldbm = (HBITMAP)::SelectObject(TmpDC,bm); BitBlt(TmpDC,0,0,cx,cy,0,0,0,WHITENESS); ima->Draw(TmpDC,CRect(0,0,cx,cy)); BitBlt(pDC->GetSafeHdc(),100,100,cx,cy,TmpDC,0,0,SRCCOPY); DeleteObject(SelectObject(TmpDC,oldbm)); DeleteDC(TmpDC);*/ CxImage tmp; tmp.Copy(*m_bitmap); RGBQUAD c={255,255,255,0}; tmp.SetTransColor(c); tmp.AlphaStrip(); tmp.Stretch(dc->GetSafeHdc(), CRect(rect.left,rect.top,rect.left+cx,rect.top+cy)); } else { rect.InflateRect( -1, -1 ); m_bitmap->Draw(dc->m_hDC,rect); //dc->PlayMetaFile() //m_bitmap->GetType() } } CPen pen; if( GetBorderStyle()!=0 ) { const float* table = Drawer::GetColorByIndex(GetBorderColor()); COLORREF clr = RGB((int)(table[0]*255.0f),(int)(table[1]*255.0f),(int)(table[2]*255.0f)); pen.CreatePen( PS_SOLID, GetBorderThickness(), clr ); dc->SelectObject( &pen ); if (GetBorderStyle() & DIAGRAM_FRAME_STYLE_LEFT) { dc->MoveTo(rect.left,rect.bottom); dc->LineTo(rect.left,rect.top); } if (GetBorderStyle() & DIAGRAM_FRAME_STYLE_RIGHT) { dc->MoveTo(rect.right,rect.bottom); dc->LineTo(rect.right,rect.top); } if (GetBorderStyle() & DIAGRAM_FRAME_STYLE_TOP) { dc->MoveTo(rect.left,rect.top); dc->LineTo(rect.right,rect.top); } if (GetBorderStyle() & DIAGRAM_FRAME_STYLE_BOTTOM) { dc->MoveTo(rect.left,rect.bottom); dc->LineTo(rect.right,rect.bottom); } } dc->SelectStockObject( BLACK_PEN ); dc->SelectStockObject( WHITE_BRUSH ); }
void CReportEntityPicture::Serialize(CArchive& ar) { typedef struct { int a_f; int b_f; int c_f; int d_f; } PIC_RESERVE_FIELDS; PIC_RESERVE_FIELDS pic_reserve; memset(&pic_reserve,0,sizeof(PIC_RESERVE_FIELDS)); CDiagramEntity::Serialize(ar); if (ar.IsStoring()) { // —охран¤ем double thickness = CUnitConversion::PixelsToInches( GetBorderThickness() ); ar.Write(&thickness,sizeof(double)); unsigned int bst = GetBorderStyle( ); ar.Write(&bst,sizeof(unsigned int)); unsigned int brC = GetBorderColor( ); ar.Write(&brC,sizeof(unsigned int )); ar.Write(&pic_reserve,sizeof(PIC_RESERVE_FIELDS)); if (m_image_size>0 && m_image_bits) { ar.Write(&m_image_type,sizeof(int)); ar.Write(&m_image_size,sizeof(unsigned int)); ar.Write(m_image_bits,sizeof(BYTE)*m_image_size); } } else { // „итаем double bordhickness; ar.Read(&bordhickness,sizeof(double)); unsigned int bordst; ar.Read(&bordst,sizeof(unsigned int )); unsigned int linecolor; ar.Read(&linecolor,sizeof(unsigned int )); ar.Read(&pic_reserve,sizeof(PIC_RESERVE_FIELDS)); int bt = CUnitConversion::InchesToPixels( bordhickness ); SetBorderThickness( bt ); SetBorderStyle( bordst ); SetBorderColor( linecolor ); if( m_bitmap ) delete m_bitmap; m_bitmap = NULL; m_image_type = -1; m_image_size = 0; if (m_image_bits) delete[] m_image_bits; m_image_bits = NULL; ar.Read(&m_image_type,sizeof(int)); ar.Read(&m_image_size,sizeof(unsigned int)); if (m_image_size==0) return; try { m_image_bits = new BYTE[m_image_size]; } catch (std::bad_alloc) { AfxMessageBox("bad_alloc exception in Serialize function"); ASSERT(0); return; } if (ar.Read(m_image_bits,m_image_size*sizeof(BYTE))!=m_image_size*sizeof(BYTE)) { delete[] m_image_bits; m_image_bits=NULL; m_image_type = -1; m_image_size = 0; ASSERT(0); return; } m_bitmap = new CxImage(m_image_bits, m_image_size, m_image_type); if (!m_bitmap->IsValid()) { AfxMessageBox(m_bitmap->GetLastError()); delete m_bitmap; m_bitmap = NULL; delete[] m_image_bits; m_image_bits=NULL; m_image_type = -1; m_image_size = 0; ASSERT(0); return; } } }
void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device) { CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); CFX_FloatRect rcClient = GetClientRect(); CFX_ByteTextBuf sLine; int32_t nCharArray = m_pEdit->GetCharArray(); FX_SAFE_INT32 nCharArraySafe = nCharArray; nCharArraySafe -= 1; nCharArraySafe *= 2; if (nCharArray > 0 && nCharArraySafe.IsValid()) { switch (GetBorderStyle()) { case BorderStyle::SOLID: { CFX_GraphStateData gsd; gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); CFX_PathData path; for (int32_t i = 0; i < nCharArray - 1; i++) { path.AppendPoint( CFX_PointF( rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.bottom), FXPT_TYPE::MoveTo, false); path.AppendPoint( CFX_PointF( rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.top), FXPT_TYPE::LineTo, false); } if (!path.GetPoints().empty()) { pDevice->DrawPath(&path, pUser2Device, &gsd, 0, GetBorderColor().ToFXColor(255), FXFILL_ALTERNATE); } break; } case BorderStyle::DASH: { CFX_GraphStateData gsd; gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); gsd.SetDashCount(2); gsd.m_DashArray[0] = (FX_FLOAT)GetBorderDash().nDash; gsd.m_DashArray[1] = (FX_FLOAT)GetBorderDash().nGap; gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPhase; CFX_PathData path; for (int32_t i = 0; i < nCharArray - 1; i++) { path.AppendPoint( CFX_PointF( rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.bottom), FXPT_TYPE::MoveTo, false); path.AppendPoint( CFX_PointF( rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.top), FXPT_TYPE::LineTo, false); } if (!path.GetPoints().empty()) { pDevice->DrawPath(&path, pUser2Device, &gsd, 0, GetBorderColor().ToFXColor(255), FXFILL_ALTERNATE); } break; } default: break; } } CFX_FloatRect rcClip; CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange(); CPVT_WordRange* pRange = nullptr; if (!HasFlag(PES_TEXTOVERFLOW)) { rcClip = GetClientRect(); pRange = &wrRange; } CFX_SystemHandler* pSysHandler = GetSystemHandler(); CFX_Edit::DrawEdit(pDevice, pUser2Device, m_pEdit.get(), GetTextColor().ToFXColor(GetTransparency()), rcClip, CFX_PointF(), pRange, pSysHandler, m_pFormFiller); }