Commit 4cd4feb2 authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

git-svn-id:...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@54353 954022d7-b5bf-4e40-9824-e11837661b57
parent 9a85b70d
......@@ -15,6 +15,8 @@ namespace Aggplus
m_ePageUnits = UnitPixel;
m_bIntegerGrid = false;
#ifdef _WINDOWS_GDIPLUS_USE_
m_pBitmap = NULL;
m_pGraphics = NULL;
......@@ -35,6 +37,8 @@ namespace Aggplus
m_pPixels = NULL;
m_bIntegerGrid = false;
Create(pBuffer, dwWidth, dwHeight, stride, 0);
#ifdef _WINDOW_GDIPLUS_USE_
......@@ -60,6 +64,8 @@ namespace Aggplus
m_pPixels = NULL;
m_bIntegerGrid = false;
Create(pImage->m_pImgData, pImage->GetWidth(), pImage->GetHeight(), pImage->m_nStride, 0);
#ifdef _WINDOW_GDIPLUS_USE_
......
......@@ -296,6 +296,8 @@ public:
agg::svg::frame_buffer_rgba& get_frame_buffer();
agg::svg::rasterizer& get_rasterizer();
bool m_bIntegerGrid;
public:
CGraphics();
......@@ -383,6 +385,9 @@ public:
inline Aggplus::CMatrix* GetFullTransform() { return &m_oFullTransform; }
inline Aggplus::CMatrix* GetCoordTransform() { return &m_oCoordTransform; }
inline double GetPixW() { return m_dWidthPix; }
inline double GetPixH() { return m_dHeightPix; }
protected:
template<class Renderer>
......
......@@ -896,7 +896,7 @@ HRESULT CGraphicsRenderer::DrawImage(IGrObject* pImage, const double& x, const d
m_pRenderer->DrawImage((Aggplus::CImage*)pImage, x, y, w, h);
return S_OK;
}
HRESULT CGraphicsRenderer::DrawImageFromFile(const std::wstring& bstrVal, const double& x, const double& y, const double& w, const double& h)
HRESULT CGraphicsRenderer::DrawImageFromFile(const std::wstring& bstrVal, const double& x, const double& y, const double& w, const double& h, const BYTE& lAlpha)
{
CCacheImage* pCacheImage = NULL;
if (NULL != m_pCache)
......@@ -1141,3 +1141,15 @@ void CGraphicsRenderer::put_GlobalAlphaEnabled(const bool& bEnabled, const doubl
else
m_dGlobalAlpha = 1.0;
}
void CGraphicsRenderer::AddRect(const double& x, const double& y, const double& w, const double& h)
{
if (!CheckValidate())
return;
m_pPath->MoveTo(x, y);
m_pPath->LineTo(x + w, y);
m_pPath->LineTo(x + w, y + h);
m_pPath->LineTo(x, y + h);
m_pPath->CloseFigure();
}
\ No newline at end of file
......@@ -169,7 +169,7 @@ public:
//-------- ---------------------------------------------------
virtual HRESULT DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h);
virtual HRESULT DrawImageFromFile(const std::wstring& sFile, const double& x, const double& y, const double& w, const double& h);
virtual HRESULT DrawImageFromFile(const std::wstring& sFile, const double& x, const double& y, const double& w, const double& h, const BYTE& lAlpha = 255);
// transform --------------------------------------------------------------------------------
virtual HRESULT SetTransform(const double& m1, const double& m2, const double& m3, const double& m4, const double& m5, const double& m6);
......@@ -186,6 +186,19 @@ public:
virtual HRESULT CommandString(const LONG& lType, const std::wstring& sCommand);
void put_GlobalAlphaEnabled(const bool& bEnabled, const double& dVal);
inline void put_IntegerGrid(const bool& bEnabled)
{
if (!m_pRenderer)
return;
m_pRenderer->m_bIntegerGrid = bEnabled;
}
inline bool get_IntegerGrid()
{
if (!m_pRenderer)
return false;
return m_pRenderer->m_bIntegerGrid;
}
void AddRect(const double& x, const double& y, const double& w, const double& h);
protected:
void _SetFont();
......@@ -232,6 +245,316 @@ public:
{
DrawPath(1);
}
inline double GetPixW() { return m_pRenderer->GetPixW(); }
inline double GetPixH() { return m_pRenderer->GetPixH(); }
// smart methods
void drawHorLine(BYTE align, double y, double x, double r, double penW)
{
int pen_w = (int)((m_pRenderer->GetDpiX() * penW / 25.4) + 0.5);
if (0 == pen_w)
pen_w = 1;
double __x = x;
double __y1 = y;
double __r = r;
double __y2 = y;
Aggplus::CMatrix* pMatrix = GetFullTransform();
pMatrix->TransformPoint(__x, __y1);
pMatrix->TransformPoint(__r, __y2);
double _x = (int)__x;
double _r = (int)__r + 1;
m_oPen.Size = pen_w;
switch (align)
{
case 0:
{
double _top = (int)__y1 + 0.5;
_top = _top + pen_w / 2.0 - 0.5;
m_pPath->Reset();
m_pPath->MoveTo(_x, _top);
m_pPath->LineTo(_r, _top);
Stroke();
break;
}
case 1:
{
// center
double _center = (int)__y1 + 0.5;
m_pPath->Reset();
if (0 == (pen_w % 2))
{
m_pPath->MoveTo(_x, _center - 0.5);
m_pPath->LineTo(_r, _center - 0.5);
}
else
{
m_pPath->MoveTo(_x, _center);
m_pPath->LineTo(_r, _center);
}
Stroke();
break;
}
case 2:
{
double _bottom = (int)__y1 + 0.5;
_bottom = _bottom - pen_w / 2.0 + 0.5;
m_pPath->Reset();
m_pPath->MoveTo(_x, _bottom);
m_pPath->LineTo(_r, _bottom);
Stroke();
break;
}
}
}
void drawHorLine2(BYTE align, double y, double x, double r, double penW)
{
int pen_w = (int)((m_pRenderer->GetDpiX() * penW / 25.4) + 0.5);
if (0 == pen_w)
pen_w = 1;
double __x = x;
double __y1 = y;
double __r = r;
double __y2 = y;
Aggplus::CMatrix* pMatrix = GetFullTransform();
pMatrix->TransformPoint(__x, __y1);
pMatrix->TransformPoint(__r, __y2);
double _x = (int)__x;
double _r = (int)__r + 1;
switch (align)
{
case 0:
{
// top
double _top = (int)__y1 + 0.5;
double _pos1 = _top + pen_w / 2.0 - 0.5 - pen_w;
double _pos2 = _pos1 + pen_w * 2.0;
m_pPath->Reset();
m_pPath->MoveTo(_x, _pos1);
m_pPath->LineTo(_r, _pos1);
Stroke();
m_pPath->Reset();
m_pPath->MoveTo(_x, _pos2);
m_pPath->LineTo(_r, _pos2);
Stroke();
break;
}
case 1:
{
// center
// TODO:
break;
}
case 2:
{
// bottom
// TODO:
break;
}
}
}
void drawVerLine(BYTE align, double x, double y, double b, double penW)
{
int pen_w = (int)((m_pRenderer->GetDpiX() * penW / 25.4) + 0.5);
if (0 == pen_w)
pen_w = 1;
double __x1 = x;
double __y = y;
double __x2 = x;
double __b = b;
Aggplus::CMatrix* pMatrix = GetFullTransform();
pMatrix->TransformPoint(__x1, __y);
pMatrix->TransformPoint(__x2, __b);
double _y = (int)__y;
double _b = (int)__b + 1;
m_oPen.Size = pen_w;
switch (align)
{
case 0:
{
// left
double _left = __x1 + 0.5;
_left = _left + pen_w / 2.0 - 0.5;
m_pPath->Reset();
m_pPath->MoveTo(_left, _y);
m_pPath->LineTo(_left, _b);
Stroke();
break;
}
case 1:
{
// center
double _center = __x1 + 0.5;
m_pPath->Reset();
if (0 == (pen_w % 2))
{
m_pPath->MoveTo(_center - 0.5, _y);
m_pPath->LineTo(_center - 0.5, _b);
}
else
{
m_pPath->MoveTo(_center, _y);
m_pPath->LineTo(_center, _b);
}
Stroke();
break;
}
case 2:
{
// right
double _right = __x1 + 0.5;
_right = _right - pen_w / 2.0 + 0.5;
m_pPath->Reset();
m_pPath->MoveTo(_right, _y);
m_pPath->LineTo(_right, _b);
Stroke();
break;
}
}
}
void drawHorLineExt(BYTE align, double y, double x, double r, double penW, double leftMW, double rightMW)
{
int pen_w = (int)((m_pRenderer->GetDpiX() * penW / 25.4) + 0.5);
if (0 == pen_w)
pen_w = 1;
double __x = x;
double __y1 = y;
double __r = r;
double __y2 = y;
Aggplus::CMatrix* pMatrix = GetFullTransform();
pMatrix->TransformPoint(__x, __y1);
pMatrix->TransformPoint(__r, __y2);
double _x = (int)__x + 0.5;
double _r = (int)__r + 0.5;
if (leftMW != 0)
{
double _center = _x;
int pen_mw = (int)((m_pRenderer->GetDpiX() * abs(leftMW) * 2 / 25.4) + 0.5);
if (0 == pen_mw)
pen_mw = 1;
if (leftMW < 0)
{
_x = _center - (pen_mw >> 1);
}
else
{
if ((pen_mw % 2) == 0)
{
_x = _center + ((pen_mw >> 1) - 1.0);
}
else
{
_x = _center + (pen_mw >> 1);
}
}
}
if (rightMW != 0)
{
double _center = _r;
int pen_mw = (int)((m_pRenderer->GetDpiX() * abs(rightMW) * 2 / 25.4) + 0.5);
if (0 == pen_mw)
pen_mw = 1;
if (rightMW < 0)
{
_r = _center - (pen_mw >> 1);
}
else
{
if ((pen_mw % 2) == 0)
{
_r = _center + (pen_mw >> 1) - 1.0;
}
else
{
_r = _center + (pen_mw >> 1);
}
}
}
m_oPen.Size = pen_w;
_x -= 0.5;
_r += 0.5;
switch (align)
{
case 0:
{
// top
double _top = (int)__y1 + 0.5;
_top = _top + pen_w / 2.0 - 0.5;
m_pPath->Reset();
m_pPath->MoveTo(_x, _top);
m_pPath->LineTo(_r, _top);
Stroke();
break;
}
case 1:
{
// center
double _center = (int)__y1 + 0.5;
m_pPath->Reset();
if (0 == (pen_w % 2))
{
m_pPath->MoveTo(_x, _center - 0.5);
m_pPath->LineTo(_r, _center - 0.5);
}
else
{
m_pPath->MoveTo(_x, _center);
m_pPath->LineTo(_r, _center);
}
Stroke();
break;
}
case 2:
{
// bottom
double _bottom = (int)__y1 + 0.5;
_bottom = _bottom - pen_w / 2.0 + 0.5;
m_pPath->Reset();
m_pPath->MoveTo(_x, _bottom);
m_pPath->LineTo(_r, _bottom);
Stroke();
break;
}
}
}
};
#endif // _BUILD_GRAPHICS_RENDERER_H_
\ No newline at end of file
......@@ -218,7 +218,7 @@ public:
//-------- ---------------------------------------------------
virtual HRESULT DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT DrawImageFromFile(const std::wstring&, const double& x, const double& y, const double& w, const double& h) = 0;
virtual HRESULT DrawImageFromFile(const std::wstring&, const double& x, const double& y, const double& w, const double& h, const BYTE& lAlpha = 255) = 0;
// transform --------------------------------------------------------------------------------
virtual HRESULT SetTransform(const double& m1, const double& m2, const double& m3, const double& m4, const double& m5, const double& m6) = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment