[gme-users] decorator

Kevin Smyth ksmyth at isis.vanderbilt.edu
Mon Apr 29 10:33:12 CDT 2013


Hi Sumit,

There is a Visual Studio 2010 "wizard" for C++ decorators, like there is  
for interpreters.  Run the script at "C:\Program Files  
(x86)\GME\SDK\DecoratorWizard\setup100.js" and the decorator project type  
will show up under New Project in VS2010.

Here's an example DrawBackground method that draws a bitmap at fixed  
(non-scaled) size if m_bStretch is false, and draws a rounded rectangle  
background:

CSize cExtentD = pDC->GetViewportExt();
CSize cExtentL = pDC->GetWindowExt();
if (m_bStretch && m_bmp.get())
{
CRect cRect = TypeableBitmapPart::GetBoxLocation(false);
Gdiplus::Rect grect(cRect.left, cRect.top, cRect.Width(), cRect.Height());
gdip->DrawImage(m_bmp.get(), grect, 0, 0, m_bmp->GetWidth(),  
m_bmp->GetHeight(), Gdiplus::UnitPixel);
}
else
{
CRect cRect = TypeableBitmapPart::GetBoxLocation(false);
cRect.BottomRight() -= CPoint(1, 1);

CRect location = cRect;
if (m_LeftPorts.size() != 0 || m_RightPorts.size() != 0)
{

Gdiplus::Rect rect(cRect.left, cRect.top, cRect.Width(), cRect.Height());
Gdiplus::LinearGradientBrush linearGradientBrush(rect,
Gdiplus::Color(GetRValue(m_crBrush), GetGValue(m_crBrush),  
GetBValue(m_crBrush)),
Gdiplus::Color(GetRValue(m_crGradient), GetGValue(m_crGradient),  
GetBValue(m_crGradient)),
Gdiplus::LinearGradientModeVertical);

Gdiplus::SolidBrush solidBrush(Gdiplus::Color(GetRValue(m_crBrush),  
GetGValue(m_crBrush), GetBValue(m_crBrush)));

Gdiplus::Brush& brush = m_bGradientFill ?  
(Gdiplus::Brush&)linearGradientBrush : (Gdiplus::Brush&)solidBrush;

Gdiplus::GraphicsPath path;
int cornerRadius = 15;
path.AddArc(location.left, location.top, cornerRadius, cornerRadius, 180,  
90);
path.AddArc(location.right - cornerRadius, location.top, cornerRadius,  
cornerRadius, 270, 90);
path.AddArc(location.right - cornerRadius, location.bottom - cornerRadius,  
cornerRadius, cornerRadius, 0, 90);
path.AddArc(location.left, location.bottom - cornerRadius, cornerRadius,  
cornerRadius, 90, 90);
gdip->FillPath(&brush, &path);
}

if (m_bmp.get())
{
int height = m_bmp->GetHeight();
int width = m_bmp->GetWidth();
Gdiplus::Rect grect((int)cRect.left + cRect.Width() / 2 -  
(int)m_bmp->GetWidth() / 2, (int)cRect.top + cRect.Height() / 2 -  
(int)m_bmp->GetHeight() / 2,
width, height);
gdip->DrawImage(m_bmp.get(), grect, 0, 0, (int)m_bmp->GetWidth(),  
(int)m_bmp->GetHeight(), Gdiplus::UnitPixel);
}
}

for (std::vector<Decor::PortPart*>::iterator ii = m_LeftPorts.begin(); ii  
!= m_LeftPorts.end(); ++ii) {
(*ii)->Draw(pDC, gdip);
}
for (std::vector<Decor::PortPart*>::iterator ii = m_RightPorts.begin(); ii  
!= m_RightPorts.end(); ++ii) {
(*ii)->Draw(pDC, gdip);
}

Kevin

On Fri, 26 Apr 2013 09:19:58 -0500, Ray, Sumit (US SSA)  
<sumit.ray at baesystems.com> wrote:

>
> Hi,
>
>
> I’m thinking about writing a decorator module that allows an object to  
> scale based on its ports or other information that we >want on its  
> object display but has a fixed size icon in the center.  What’s the best  
> way to start this activity?
>
>
> Thanks,
>
> Sumit
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.isis.vanderbilt.edu/pipermail/gme-users/attachments/20130429/e13a4c67/attachment.html 


More information about the gme-users mailing list