Пример #1
0
std::string CRectangle::ToString() const
{
	std::string output = "Rectangle ";
	output += "\n";
	output += "pos: ";
	output += m_upperLeftCorner.ToString();
	output += "\n";
	output += "S: " + std::to_string(GetArea());
	output += "\n";
	output += "P: ";
	output += std::to_string(GetPerimeter());
	output += "\n";
	output += "Border Color: ";
	output += std::to_string(GetBorderColor().r);
	output += " ";
	output += std::to_string(GetBorderColor().g);
	output += " ";
	output += std::to_string(GetBorderColor().b);
	output += "\n";
	output += "Fill Color: ";
	output += std::to_string(GetFillColor().r);
	output += " ";
	output += std::to_string(GetFillColor().g);
	output += " ";
	output += std::to_string(GetFillColor().b);
	output += "\n";
	output += "=============================";
	return output;
}
void CReportEntityLine::Draw( CDC* dc, CRect rect )
/* ============================================================
	Function :		CReportEntityLine::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".

   ============================================================*/
{
	CPen pen;
	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 );

	dc->MoveTo( rect.TopLeft() );
	dc->LineTo( rect.BottomRight() );

	dc->SelectStockObject( BLACK_PEN );

}
Пример #3
0
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;

}
Пример #5
0
void OpenGLRect::DrawMyBothRect(const float& fLineWidth /*= 1.0f*/)
{
	GetVert(m_fRectVert);
	GetColor(m_fRectColor);
	DrawMyRect(1.0f, GL_QUADS);

	GetBorderVert(m_fRectVert);
	GetBorderColor(m_fRectColor);
	DrawMyRect(fLineWidth);
}
Пример #6
0
void MultiTabs::DrawHeader(const Point2i &mousePosition) const
{
  if (tabs.empty())
    return;

  // Draw the buttons to change tab
  if (nb_visible_tabs < tabs.size()) {
#if !CIRCULAR_TABS
    if (first_tab != 0)
#endif
      prev_tab_bt->Draw(mousePosition);

#if !CIRCULAR_TABS
    if (first_tab + nb_visible_tabs != tabs.size())
#endif
      next_tab_bt->Draw(mousePosition);
  }

  for (uint i = first_tab; i < first_tab + nb_visible_tabs; i++) {
    // Draw the title
    uint pos_x = prev_tab_bt->GetPositionX() + prev_tab_bt->GetSizeX()
               + MARGIN + (i-first_tab)*tab_header_width;

    bool is_current = i == current_tab;
    Text tab_title(tabs[i].GetTitle(), is_current ? primary_red_color : dark_gray_color,
                   Font::FONT_MEDIUM, Font::FONT_BOLD, is_current);

    tab_title.DrawCenter(Point2i(pos_x + tab_header_width/2,
                                 position.y + tab_header_height/2));
  }

  if (nb_visible_tabs > 1) {
    uint end_y = position.y + tab_header_height - 2;
    uint current_tab_pos_x = prev_tab_bt->GetPositionX() + prev_tab_bt->GetSizeX()
                           + MARGIN + (current_tab-first_tab)*tab_header_width;

    GetMainWindow().VlineColor(current_tab_pos_x, position.y +1, end_y, GetBorderColor());
    GetMainWindow().VlineColor(current_tab_pos_x + tab_header_width, position.y +1, end_y, GetBorderColor());
    GetMainWindow().HlineColor(position.x, current_tab_pos_x, end_y, GetBorderColor());
    GetMainWindow().HlineColor(current_tab_pos_x + tab_header_width, position.x + size.x - 2, end_y, GetBorderColor());
  }
}
Пример #7
0
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 );

	}
}
Пример #8
0
        void    Widget::LoadStyle(const std::string& style)
        {
            ResourceManager* rm = ResourceManager::Get();

            StyleProperties& properties = rm->GetStyle(style);

            if (properties["from"] != "")
                LoadStyle(properties["from"]);

            SetX(rm->GetValue(properties["x"], GetPosition().x));
            SetY(rm->GetValue(properties["y"], GetPosition().y));

            mAlignOffset.x = rm->GetValue(properties["x"], mAlignOffset.x);
            mAlignOffset.y = rm->GetValue(properties["y"], mAlignOffset.y);

            SetWidth(rm->GetValue(properties["width"], GetWidth()));
            SetHeight(rm->GetValue(properties["height"], GetHeight()));

            // Detect alignement
            if (properties["align"] != "")
            {
                std::string strA = properties["align"];

                if (strA == "top_left")
                    mAlign = Align::TOP_LEFT;
                else if (strA == "top_center")
                    mAlign = Align::TOP_CENTER;
                else if (strA == "top_right")
                    mAlign = Align::TOP_RIGHT;
                else if (strA == "left")
                    mAlign = Align::LEFT;
                else if (strA == "center")
                    mAlign = Align::CENTER;
                else if (strA == "right")
                    mAlign = Align::RIGHT;
                else if (strA == "bottom_left")
                    mAlign = Align::BOTTOM_LEFT;
                else if (strA == "bottom_center")
                    mAlign = Align::BOTTOM_CENTER;
                else if (strA == "bottom_right")
                    mAlign = Align::BOTTOM_RIGHT;
                else
                    mAlign = Align::NONE;
            }

            SetColor(rm->GetColorValue(properties["color"], GetColor()));
            SetBorderColor(rm->GetColorValue(properties["borderColor"], GetBorderColor()));

            SetEnabled(rm->GetValue(properties["enabled"], IsEnabled()));
            SetVisible(rm->GetValue(properties["visible"], IsVisible()));
            SetFocusable(rm->GetValue(properties["focusable"], IsFocusable()));

            UpdatePosition();
        }
Пример #9
0
VOID CXElement::On_CXMsg_PaintElement( CXMsg_PaintElement& arg )
{
	arg.msgHandled = TRUE;
	if (!m_memDC)
	{
		return;
	}

	BOOL updated = FALSE;

	CRect rect;
	GetRect(rect);
	rect.OffsetRect(-rect.left,-rect.top);

	COLORREF color;
	if (XSUCCEEDED(GetColor(color)))
	{
		LOGBRUSH brushLog;
		brushLog.lbColor = color;
		brushLog.lbStyle = BS_SOLID;
		brushLog.lbHatch = 0;
		HBRUSH brush = CreateBrushIndirect(&brushLog);
		m_memDC->FillRect(rect,brush);
		DeleteObject(brush);
		updated = TRUE;
	}

	COLORREF borderColor;
	if(XSUCCEEDED(GetBorderColor(borderColor)))
	{
		DWORD borderWidth;
		GetBorderWidth(borderWidth);
		HPEN pen = CreatePen(PS_SOLID,borderWidth,borderColor);
		CGDIHandleSwitcher handleSwitcher(m_memDC->m_hDC,pen);
		m_memDC->Rectangle(rect);
		updated = TRUE;
	}

	if (arg.paintChildren)
	{
		_SendXMsg(arg);
	}

	if (updated)
	{
		CXMsg_Invalidate msg;
		msg.invalidRect = ElementUtil::GetElementRectInClientCoord(this);
		_SendXMsg(msg);
	}
}
Пример #10
0
// 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;
  }
}
Пример #11
0
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());
  }
}
Пример #12
0
void  CReportEntityLine::Serialize(CArchive& ar)
{
	typedef struct
	{
		int a_f;
		int b_f;
	} LINE_RESERVE_FIELDS;

	LINE_RESERVE_FIELDS line_reserve;
	memset(&line_reserve,0,sizeof(LINE_RESERVE_FIELDS));

	CDiagramEntity::Serialize(ar);
	if (ar.IsStoring())
	{
		// —охран¤ем
		double thickness = CUnitConversion::PixelsToInches( GetBorderThickness() );
		ar.Write(&thickness,sizeof(double));
		unsigned int brC = GetBorderColor( );
		ar.Write(&brC,sizeof(unsigned int));

		ar.Write(&line_reserve,sizeof(LINE_RESERVE_FIELDS));
	}
	else
	{
		// „итаем
		double		linethickness;
		ar.Read(&linethickness,sizeof(double));	
		unsigned int	linecolor;
		ar.Read(&linecolor,sizeof(unsigned int));	

		ar.Read(&line_reserve,sizeof(LINE_RESERVE_FIELDS));
		unsigned int lt = CUnitConversion::InchesToPixels( linethickness );
		SetBorderThickness( lt );
		SetBorderColor( linecolor );
	}
}
Пример #13
0
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);
}
Пример #14
0
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();
}
Пример #15
0
 void    Widget::OnPaint(RenderTarget& target, RenderQueue& queue) const
 {
     queue.SetColor(GetColor());
     target.Draw(Shape::Rectangle(0, 0, mSize.x, mSize.y, GetColor(), 1.f, GetBorderColor()));
 }
Пример #16
0
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);
  }
}
Пример #17
0
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;
		}	
	}
}