Esempio n. 1
0
int main(void)
{
    Avoid::Router *router = new Avoid::Router(Avoid::PolyLineRouting);
    
    Avoid::Point srcPt(1.2, 0.5);
    Avoid::Point dstPt(1.5, 4);
    Avoid::ConnRef *connRef = new Avoid::ConnRef(router, srcPt, dstPt);
    connRef->setCallback(connCallback, connRef);
    // Force inital callback:
    router->processTransaction();

    printf("\nAdding a shape.\n");
    // Create the ShapeRef:
    Avoid::Polygon shapePoly(3);
    shapePoly.ps[0] = Avoid::Point(1, 1);
    shapePoly.ps[1] = Avoid::Point(2.5, 1.5);
    shapePoly.ps[2] = Avoid::Point(1.5, 2.5);
    Avoid::ShapeRef *shapeRef = new Avoid::ShapeRef(router, shapePoly);
    router->processTransaction();

    printf("\nShifting endpoint.\n");
    Avoid::Point dstPt2(6, 4.5);
    connRef->setDestEndpoint(dstPt2);
    // It's expected you know the connector needs rerouting, so the callback
    // isn't called.  You can force it to be called though, via:
    router->processTransaction();

    printf("\nMoving shape right by 0.5.\n");
    router->moveShape(shapeRef, 0.5, 0);
    router->processTransaction();

    router->outputDiagram("output/example");
    delete router;
    return 0;
}
Esempio n. 2
0
int main(void)
{
    Avoid::Router *router = new Avoid::Router(Avoid::OrthogonalRouting);
    
    Avoid::Point srcPt(0,400);
    Avoid::Point dstPt(775,400);
    Avoid::ConnRef *connRef = new Avoid::ConnRef(router, srcPt, dstPt);
    connRef->setCallback(connCallback, connRef);

    Avoid::Point srcPt2(775,625);
    Avoid::Point dstPt2(350,475);
    Avoid::ConnRef *connRef2 = new Avoid::ConnRef(router, srcPt2, dstPt2);
    connRef2->setCallback(connCallback, connRef2);
    
    router->processTransaction();

    printf("\nShifting endpoint.\n");
    connRef->setEndpoints(Avoid::Point(0,375), Avoid::Point(775,400));
    connRef2->setEndpoints(Avoid::Point(775,625), Avoid::Point(350,450));
    router->processTransaction();

    printf("\nShifting endpoint.\n");
    connRef->setEndpoints(Avoid::Point(0,400), Avoid::Point(775,400));
    connRef2->setEndpoints(Avoid::Point(775,625), Avoid::Point(350,475));
    router->processTransaction();

    delete router;
    return 0;
}
Esempio n. 3
0
int main(void)
{
    Avoid::Router *router = new Avoid::Router(Avoid::OrthogonalRouting);
    
    // Create the ShapeRef:
    Avoid::Rectangle shapeRect1(Avoid::Point(0, 0), Avoid::Point(10, 10));
    Avoid::ShapeRef *shapeRef1 = new Avoid::ShapeRef(router, shapeRect1);
    const unsigned int CENTRE = 1;
    new Avoid::ShapeConnectionPin(shapeRef1, CENTRE, 
            Avoid::ATTACH_POS_CENTRE, Avoid::ATTACH_POS_CENTRE, true, 0.0, Avoid::ConnDirNone);
    
    Avoid::Rectangle shapeRect2(Avoid::Point(0, 0), Avoid::Point(10, 10));
    Avoid::ShapeRef *shapeRef2 = new Avoid::ShapeRef(router, shapeRect1);

    Avoid::ConnEnd dstPt(shapeRef1, CENTRE); 
    Avoid::Point srcPt(1.5, 4);
    Avoid::ConnRef *connRef = new Avoid::ConnRef(router, srcPt, dstPt);
    // Force inital callback:
    router->processTransaction();
    router->outputDiagram("output/connendmove-1");

    Avoid::Point dstPt2(20, 20);
    connRef->setDestEndpoint(dstPt2);
    router->moveShape(shapeRef1, 0.5, 0);

    router->processTransaction();
    router->outputDiagram("output/connendmove-2");

    srcPt.x += 0.5;
    connRef->setSourceEndpoint(srcPt);
    router->moveShape(shapeRef1, 0.5, 0);
    router->moveShape(shapeRef2, 0, 0.5);
    
    srcPt.x += 0.5;
    connRef->setSourceEndpoint(srcPt);
    router->moveShape(shapeRef1, 0.5, 0);
    router->moveShape(shapeRef2, 0, 0.5);
    
    srcPt.x += 0.5;
    connRef->setSourceEndpoint(srcPt);
    router->moveShape(shapeRef1, 0.5, 0);
    router->moveShape(shapeRef2, 0, 0.5);
    
    srcPt.x += 0.5;
    connRef->setSourceEndpoint(srcPt);
    router->moveShape(shapeRef1, 0.5, 0);
    router->moveShape(shapeRef2, 0, 0.5);
    
    router->processTransaction();
    router->outputDiagram("output/connendmove-3");

    delete router;
    return 0;
}
Esempio n. 4
0
void CLrcMask::DrawBkMask()
{
	HDC hTempDc = GetDC(m_hWnd);
	HDC hMenDc = CreateCompatibleDC(hTempDc);

	DuiLib::CDuiRect rc;
	GetClientRect(&rc);

	HBITMAP hbmp;
	BITMAPINFO bitmapinfo;
	bitmapinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
	bitmapinfo.bmiHeader.biBitCount = 32;
	bitmapinfo.bmiHeader.biHeight = rc.GetHeight();
	bitmapinfo.bmiHeader.biWidth = rc.GetWidth();
	bitmapinfo.bmiHeader.biPlanes = 1;
	bitmapinfo.bmiHeader.biCompression=BI_RGB;
	bitmapinfo.bmiHeader.biXPelsPerMeter=0;
	bitmapinfo.bmiHeader.biYPelsPerMeter=0;
	bitmapinfo.bmiHeader.biClrUsed=0;
	bitmapinfo.bmiHeader.biClrImportant=0;
	bitmapinfo.bmiHeader.biSizeImage = bitmapinfo.bmiHeader.biWidth * bitmapinfo.bmiHeader.biHeight * bitmapinfo.bmiHeader.biBitCount / 8;

	hbmp = CreateDIBSection(hMenDc,&bitmapinfo,0,NULL,0,0);
	SelectBitmap(hMenDc,hbmp);

	Graphics graphics(hMenDc);

	graphics.SetSmoothingMode(SmoothingModeAntiAlias);
	graphics.SetInterpolationMode(InterpolationModeHighQualityBicubic);
	SolidBrush brush(Color(50,200,200,200));
	Pen pen1(Color(155,223,223,223));
	Pen pen2(Color(55,223,223,223));
	LPRECT lpRect = &rc;
	RectF rect((Gdiplus::REAL)lpRect->left,(Gdiplus::REAL)lpRect->top,(Gdiplus::REAL)(lpRect->right-lpRect->left),(Gdiplus::REAL)(lpRect->bottom-lpRect->top));

	graphics.FillRectangle(&brush,rect);
	graphics.DrawRectangle(&pen1,rect.GetLeft()+2,rect.GetTop()+2,rect.Width - 4,rect.Height -4);
	graphics.DrawRectangle(&pen2,rect.GetLeft()+1,rect.GetTop()+1,rect.Width - 2,rect.Height -2);

	DuiLib::CDuiRect rtWnd;
	GetWindowRect(&rtWnd);

	DuiLib::CPoint dstPt(0,0);
	DuiLib::CPoint winPt(rtWnd.left,rtWnd.top);
	DuiLib::CSize size(rc.GetWidth(),rc.GetHeight());
	BLENDFUNCTION blend = {AC_SRC_OVER,0,255,AC_SRC_ALPHA};
	BOOL bret = ::UpdateLayeredWindow(m_hWnd,hTempDc,&winPt,&size,hMenDc,&dstPt,0,&blend,ULW_ALPHA);
	DeleteDC(hMenDc);
	ReleaseDC(m_hWnd,hTempDc);	

//	assert(bret);
}
Esempio n. 5
0
//
/// Paint the text gadget by painting gadget borders, & then painting text in
/// the InnerRect. Empty or 0 text blanks the gadget.
//
/// Calls TGadget::PaintBorder to paint the border. Calls TGadget::GetInnerRect to
/// calculate the area of the text gadget's rectangle. If the text is left-aligned,
/// Paint calls dc.GetTextExtent to compute the width and height of a line of the
/// text. To set the background color, Paint calls dc.GetSysColor and sets the
/// default background color to face shading (COLOR_BTNFACE). To set the button text
/// color, Paint calls dc.SetTextColor and sets the default button text color to
/// COLOR_BTNTEXT. To draw the text, Paint calls dc.ExtTextOut and passes the
/// parameters ETO_CLIPPED (so the text is clipped to fit the rectangle) and
/// ETO_OPAQUE (so the rectangle is filled with the current background color).
//
void
TTextGadget::Paint(TDC& dc)
{
  PaintBorder(dc);

  TRect  innerRect;
  GetInnerRect(innerRect);

  if (!Font)
    dc.SelectObject(GetGadgetWindow()->GetFont());
  else
    dc.SelectObject(*Font);

  TColor textColor = GetEnabledColor();
  if(!GetEnabled())
    textColor = TColor::Sys3dHilight;

  bool transparent = GetGadgetWindow()->GetFlatStyle() & TGadgetWindow::FlatXPTheme;
  if(!Text){
    if (!transparent)
    {
    TColor color = dc.SetBkColor(TColor::Sys3dFace);
    dc.ExtTextOut(0,0, ETO_OPAQUE, &innerRect, _T(""), 0);
    dc.SetBkColor(color);
  }
  }
  else
  {
    // Create a UI Face object for this button & let it paint the button face
    //
    uint align[] = {DT_LEFT, DT_CENTER, DT_RIGHT};
    uint format =  DT_SINGLELINE | DT_VCENTER | align[Align];
            TUIFace face(innerRect, Text, BkgndColor, format);

     TPoint  dstPt(innerRect.TopLeft());

      dc.SetBkColor(BkgndColor);

     TColor oldTxColor  = dc.SetTextColor(textColor);
    if (!GetEnabled())
      face.Paint(dc, dstPt, TUIFace::Disabled, false, !transparent);
    else
      face.Paint(dc, dstPt, TUIFace::Normal, false, !transparent);
    dc.SetTextColor(oldTxColor);
  }
  dc.RestoreFont();
}
Esempio n. 6
0
//
/// Paint Text
//
void
TButtonTextGadget::PaintText(TDC& dc, TRect& rect, const tstring& text)
{
  dc.SelectObject(GetFont());

  TColor textColor = TColor::SysBtnText;
  if(!GetEnabled())
    textColor = TColor::Sys3dHilight;
  else if((GetGadgetWindow()->GetFlatStyle()&TGadgetWindow::FlatHotText) && IsHaveMouse())
     textColor = TColor::LtBlue;

   TColor oldTxColor  = dc.SetTextColor(textColor);

  uint format =  DT_SINGLELINE|DT_NOCLIP|DT_END_ELLIPSIS;
  switch(Align){
    case aLeft:
      format |= DT_LEFT;
      break;
    case aRight:
      format |= DT_RIGHT;
      break;
    case aCenter:
      format |= DT_CENTER;
      break;
  }
  switch(LayoutStyle){
    case lTextLeft:
    case lTextRight:
      format |= DT_VCENTER;
      break;
    case lTextTop:
      format |= DT_VCENTER;//DT_BOTTOM;
      break;
    case lTextBottom:
      format |= DT_VCENTER;//DT_TOP;
      break;
  }

  // Create a UI Face object for this button & let it paint the button face
  //
  TPoint  dstPt(rect.TopLeft());

  if (GetButtonState() == Down && GetEnabled() &&
      GetGadgetWindow()->GetFlatStyle()&TGadgetWindow::FlatStandard)
  {
    if(IsHaveMouse())
    {
      if(IsPressed())
      {
        const int dx = (format & DT_CENTER) ? 2 : 1;
        const int dy = (format & DT_VCENTER) ? 2 : 1;
        rect.Offset(dx, dy);
      }
      TUIFace(rect, text, TColor::Sys3dFace,format).Paint(dc, dstPt,
                TUIFace::Normal, true, true);
    }
    else
    {
      TUIFace face(rect, text, TColor::Sys3dFace,format);
      if(GetGadgetWindow()->GadgetGetCaptured()==this)
        face.Paint(dc, dstPt, TUIFace::Normal, true);
      else
        face.Paint(dc, dstPt, TUIFace::Down, IsPressed(), false);
    }
  }
  else
  {
    TUIFace face(rect, text, TColor::Sys3dFace,format);
    if (!GetEnabled())
      face.Paint(dc, dstPt, TUIFace::Disabled, false, false);
    else if (GetButtonState() == Indeterminate)
      face.Paint(dc, dstPt, TUIFace::Indeterm, IsPressed(), false);
    else if (GetButtonState() == Down) // Down and not flat
      face.Paint(dc, dstPt, TUIFace::Down, IsPressed(), false);
    else
      face.Paint(dc, dstPt, TUIFace::Normal, IsPressed(), false);
  }

  dc.SetTextColor(oldTxColor);

  dc.RestoreFont();
}