Example #1
0
void wxlCanObj::Draw( wxDC& dc, double absx, double absy )
{
    if ( m_brush.Ok() )
        dc.SetBrush( m_brush );
    if ( m_pen.Ok() )
        dc.SetPen( m_pen );

    wxBrush currentBrush = dc.GetBrush();
    wxPen currentPen = dc.GetPen();

    absx += m_x;
    absy += m_y;

    DoDraw( dc, absx, absy );

    // iterate over the child list
    for ( wxlCanObjList::Node *node = m_objects.GetFirst(); node; node = node->GetNext() )
    {
        wxlCanObj *drawobj = node->GetData();
        // restore brush and pen
        dc.SetBrush( currentBrush );
        dc.SetPen( currentPen );
        drawobj->Draw( dc , absx, absy );
    }
}
bool RedHatchDrawlet::Draw(wxDC &dc)
{
#if wxCHECK_VERSION(2, 9, 0)
    wxRasterOperationMode old_lf = dc.GetLogicalFunction();
#else
    int old_lf = dc.GetLogicalFunction();
#endif
    dc.SetLogicalFunction(wxXOR);

    wxPen old_pen = dc.GetPen();
    wxBrush old_brush = dc.GetBrush();

    wxColor red = wxColor( ~wxRED->Red(), ~wxRED->Green(), ~wxRED->Blue());
#if wxCHECK_VERSION(2,9,0)
    wxBrush brush = wxBrush(red, wxHATCHSTYLE_CROSSDIAG );
#else
    wxBrush brush = wxBrush(red, wxCROSSDIAG_HATCH );
#endif

    dc.SetPen(*wxTRANSPARENT_PEN);
    dc.SetBrush(brush);

    dc.DrawRectangle(m_rect);

    dc.SetLogicalFunction(old_lf);
    dc.SetPen(old_pen);
    dc.SetBrush(old_brush);

    return true;
}
Example #3
0
// For some reason, drawing a rectangle on a memory DC has problems.
// Use this substitute if we can.
static void wxDrawRectangle(wxDC& dc, wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
    wxBrush brush(dc.GetBrush());
    wxPen pen(dc.GetPen());
    if (brush.Ok() && brush.GetStyle() != wxTRANSPARENT)
    {
        HBRUSH hBrush = (HBRUSH) brush.GetResourceHandle() ;
        if (hBrush)
        {
            RECT rect;
            rect.left = x;
            rect.top = y;
            rect.right = x + width - 1;
            rect.bottom = y + height - 1;
            ::FillRect((HDC) dc.GetHDC(), &rect, hBrush);
        }
    }
    width --;
    height --;
    if (pen.Ok() && pen.GetStyle() != wxTRANSPARENT)
    {
        dc.DrawLine(x, y, x + width, y);
        dc.DrawLine(x, y, x, y + height);
        dc.DrawLine(x, y+height, x+width, y + height);
        dc.DrawLine(x+width, y+height, x+width, y);
    }
}
/* paints the progress bar */
void CBOINCGridCellProgressRenderer::DoProgressDrawing(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rectCell, int row, int col, bool isSelected) {
    wxRect rect = rectCell;
    rect.Inflate(-1);

    // erase only this cells background, overflow cells should have been erased
	this->DrawBackground(grid, dc, rectCell, row, isSelected);
	// set text attributes
    int hAlign, vAlign;
	attr.GetAlignment(&hAlign, &vAlign);
    SetTextColoursAndFont(grid, attr, dc, isSelected);

	//calculate the two parts of the progress rect
    //
	double dv = 0.0;
	wxString strValue = grid.GetCellValue(row,col);
	if(m_bDoPercentAppending) {
		strValue = strValue + wxT(" %");
	}

    // Project view uses the format:  %0.0f (%0.2f%%)
    // Everyone else uses: %.3f%%
    if (strValue.Find(wxT("(")) != wxNOT_FOUND) {
        strValue.SubString(strValue.Find(wxT("(")) + 1, strValue.Find(wxT(")")) - 1).ToDouble( &dv );
    } else {
    	strValue.ToDouble ( &dv );	 // NOTE: we should do error-checking/reporting here!!
    }


	wxRect p1(rect);
	wxRect p2(rect);
	int r = (int)((rect.GetRight()-rect.GetLeft())*dv / 100.0);
	p1.SetRight(rect.GetLeft()+r);
	p2.SetLeft(rect.GetLeft()+r+1);
	p2.SetRight(rect.GetRight()-1);
	//start drawing
	dc.SetClippingRegion(rect);
	wxBrush old = dc.GetBrush();
	wxColour progressColour = wxTheColourDatabase->Find(wxT("LIGHT BLUE"));
	wxBrush* progressBrush = wxTheBrushList->FindOrCreateBrush(progressColour);
	wxPen* progressPen = wxThePenList->FindOrCreatePen(progressColour,1,wxSOLID);
	//draw the outline rectangle
	dc.SetBrush(*wxTRANSPARENT_BRUSH);
	dc.SetPen(*progressPen);
	dc.DrawRectangle(rect);
	// Draw the left part
	dc.SetBrush(*progressBrush);
	dc.DrawRectangle(p1);
	//draw the right part
	dc.SetBrush(old);
	dc.DrawRectangle(p2);
	//
	dc.DestroyClippingRegion();
	// draw the text
	grid.DrawTextRectangle(dc, strValue, rect, hAlign, vAlign);
}
Example #5
0
void CPathItem::DrawBG(wxDC &dc, wxRect &rc)
{
	wxPen oldpen = dc.GetPen();
	wxPen pen( IsSelected() ? *wxBLACK_PEN : *wxMEDIUM_GREY_PEN );
	pen.SetWidth(IsSelected() ? 2 : 1);
	dc.SetPen( pen );

	wxBrush oldBrush = dc.GetBrush();
	wxBrush brush(m_color, NULL!=m_pInput ? wxSOLID : wxTRANSPARENT);
	dc.SetBrush(brush);

	int x = rc.GetX();
	int y = rc.GetY();
	int w = rc.GetWidth();
	int h = rc.GetHeight();
	int n = 0;

	wxPoint points[6];

	if(NULL != m_pInput)
	{
		points[0] = wxPoint(x,								y);
		points[1] = wxPoint(x+w-GAP_LENGTH,					y);
		points[2] = wxPoint(x+w+CORNER_LENGTH-GAP_LENGTH,	y+h/2);
		points[3] = wxPoint(x+w-GAP_LENGTH,					y+h);
		points[4] = wxPoint(x,								y+h);
		points[5] = wxPoint(x+CORNER_LENGTH,				y+h/2);

		n = m_bFirst ? 5 : 6;
	}
	else
	{
		// Last component: mixer
		points[0] = wxPoint(x,					y);
		points[1] = wxPoint(x+w,				y);
		points[2] = wxPoint(x+w,				y+h);
		points[3] = wxPoint(x,					y+h);
		points[4] = wxPoint(x+CORNER_LENGTH,	y+h/2);

		n = 5;
	}

	if(m_pRegion)
		delete m_pRegion;
	m_pRegion = new wxRegion(n, points);

	dc.DrawPolygon(n, points);

	dc.SetBrush( oldBrush );
	dc.SetPen(oldpen);
}
Example #6
0
void FloorTruss::draw(wxDC &dc, unsigned left, unsigned top, unsigned right,
        unsigned bottom) {
        
    // Trusses should be drawn 6" from the left side.
    float six_inches = (right-left) / (60.0f*2);
    
    float one_inch = (right-left) / 60.0f / 12.0f;
    
    unsigned px_width = one_inch * width;
    unsigned px_height = one_inch * height;
    
    const wxBrush &old_brush = dc.GetBrush();
    dc.SetBrush(*wxGREY_BRUSH);
    dc.DrawRectangle(left + six_inches, bottom - px_height, px_width+1,
        px_height+1);
    dc.SetBrush(old_brush);
}
Example #7
0
void CFloopyControl::DrawBG(wxDC& dc, wxRect& rc)
{
	wxBrush oldBrush = dc.GetBrush();
	wxPen oldpen = dc.GetPen();

	wxPen pen( *wxLIGHT_GREY );
	pen.SetWidth(1);
	dc.SetPen( pen );

	wxBrush brush(GetParent()->GetColor(), wxSOLID);
	dc.SetBrush(brush);

	dc.DrawRoundedRectangle(rc.GetX(), rc.GetTop(),
		rc.GetWidth(), rc.GetHeight(), 2);

	dc.SetPen(oldpen);
	dc.SetBrush( oldBrush );
}
Example #8
0
//---------------------------------------------------------
inline void CWKSP_Layer_Legend::_Draw_Box(wxDC &dc, int y, int dy, wxColour Color)
{
	wxPen	Pen;
	wxBrush	Brush;

	//-----------------------------------------------------
	_Set_Size(0, dy);

	dy	-= BOX_SPACE;

	//-----------------------------------------------------
	if( m_Box_bOutline == false )
	{
		Pen		= dc.GetPen();
		Pen.SetColour(Color);
		dc.SetPen(Pen);
	}

	if( m_Box_bFill )
	{
		Brush	= dc.GetBrush();
		Brush.SetColour(Color);
		dc.SetBrush(Brush);
	}

	//-----------------------------------------------------
	switch( m_BoxStyle )
	{
	case BOXSTYLE_LINE:
		dc.DrawLine(m_xBox                  , y + dy / 2, m_xBox +     m_dxBox / 4, y);
		dc.DrawLine(m_xBox +     m_dxBox / 4, y         , m_xBox + 3 * m_dxBox / 4, y + dy);
		dc.DrawLine(m_xBox + 3 * m_dxBox / 4, y + dy    , m_xBox +     m_dxBox    , y + dy / 2);
		break;

	case BOXSTYLE_CIRCLE:
		dc.DrawCircle(m_xBox + m_dxBox / 2, y + dy / 2, dy / 2);
		break;

	case BOXSTYLE_RECT:	default:
		dc.DrawRectangle(m_xBox, y, m_dxBox, dy);
		break;
	}
}
Example #9
0
void StateEvaluationTreePanel::drawIndicatorAtArea(wxDC &DC,
                                                   IndicatorStyle const &Style,
                                                   wxCoord X, wxCoord Y,
                                                   wxCoord W, wxCoord H)
{
  auto const Kind = Style.GetKind();
  auto const FG   = Style.GetForeground();
  
  wxPen const PrevPen = DC.GetPen();
  wxBrush const PrevBrush = DC.GetBrush();
  
  switch (Kind) {
    case IndicatorStyle::EKind::Plain:
      DC.SetPen(wxPen{FG, Settings.PenWidth});
      DC.DrawLine(X, Y+H, X+W, Y+H);
      break;
    case IndicatorStyle::EKind::Box:
      DC.SetPen(wxPen{FG, Settings.PenWidth});
      DC.DrawRectangle(X, Y, W, H);
      break;
    case IndicatorStyle::EKind::StraightBox:
      // Many DCs don't support alpha at all, so manually calculate an alpha
      // against the background colour.
      auto const BG = PrevBrush.GetColour();
      double const Alpha        = (double)Style.GetAlpha() / 255;
      double const OutlineAlpha = (double)Style.GetOutlineAlpha() / 255;
      DC.SetPen(wxPen{
        wxColour(wxColour::AlphaBlend(FG.Red(), BG.Red(), OutlineAlpha),
                 wxColour::AlphaBlend(FG.Green(), BG.Green(), OutlineAlpha),
                 wxColour::AlphaBlend(FG.Blue(), BG.Blue(), OutlineAlpha)),
        Settings.PenWidth});
      DC.SetBrush(wxBrush{
        wxColour(wxColour::AlphaBlend(FG.Red(), BG.Red(), Alpha),
                 wxColour::AlphaBlend(FG.Green(), BG.Green(), Alpha),
                 wxColour::AlphaBlend(FG.Blue(), BG.Blue(), Alpha))});
      DC.DrawRectangle(X, Y, W, H);
      break;
  }
  
  DC.SetPen(PrevPen);
  DC.SetBrush(PrevBrush);
}
Example #10
0
void DrawingUtils::PaintStraightGradientBox(wxDC& dc,
        const wxRect& rect,
        const wxColour& startColor,
        const wxColour& endColor,
        bool  vertical)
{
    int rd, gd, bd, high = 0;
    rd = endColor.Red() - startColor.Red();
    gd = endColor.Green() - startColor.Green();
    bd = endColor.Blue() - startColor.Blue();

    /// Save the current pen and brush
    wxPen savedPen = dc.GetPen();
    wxBrush savedBrush = dc.GetBrush();

    if ( vertical )
        high = rect.GetHeight()-1;
    else
        high = rect.GetWidth()-1;

    if ( high < 1 )
        return;

    for (int i = 0; i <= high; ++i) {
        int r = startColor.Red() +  ((i*rd*100)/high)/100;
        int g = startColor.Green() + ((i*gd*100)/high)/100;
        int b = startColor.Blue() + ((i*bd*100)/high)/100;

        wxPen p(wxColor(r, g, b));
        dc.SetPen(p);

        if ( vertical )
            dc.DrawLine(rect.x, rect.y+i, rect.x+rect.width, rect.y+i);
        else
            dc.DrawLine(rect.x+i, rect.y, rect.x+i, rect.y+rect.height);
    }

    /// Restore the pen and brush
    dc.SetPen( savedPen );
    dc.SetBrush( savedBrush );
}
void ColourGridCellRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect, int row, int col, bool isSelected)
{
  //Call base class to clear the full drawing area and render the string
  OffsetStringGridCellRenderer::Draw(grid, attr, dc, rect, row, col, isSelected);

  //Get the old state
  wxBrush oldBrush = dc.GetBrush();
  wxPen   oldPen   = dc.GetPen();

  //Set the new state
  dc.SetBrush(wxBrush(renderColour));
  dc.SetPen(wxPen(*wxBLACK));

  //Render the color box
  wxRect renderRect = wxRect(rect.x + 5,rect.y + 1, 17, 14).Intersect(rect);
  dc.DrawRectangle(renderRect);

  //Restore the old state
  dc.SetBrush(oldBrush);
  dc.SetPen(oldPen);
}
Example #12
0
void SkinColor::Fill(wxDC& dc, const wxRect& rect)
{
    if (IsOpaque()) {
        if (rounded)
            dc.DrawRoundedRectangle(rect.x, rect.y, rect.width, rect.height, rounded);
        else
            dc.DrawRectangle(rect);
    } else {
#if __WXMSW__
        wxGraphicsContext* gc = wxGraphicsContext::Create(dc);
        gc->SetBrush(dc.GetBrush());
        gc->SetPen(*wxTRANSPARENT_PEN);
        if (rounded)
            gc->DrawRoundedRectangle(rect.x, rect.y, rect.width, rect.height, rounded);
        else
            gc->DrawRectangle(rect.x, rect.y, rect.width, rect.height);

        delete gc;
#endif
    }

}
Example #13
0
void TLView::SetBrushColour( wxDC& dc, wxColour colour )
{
	wxBrush brush1 = dc.GetBrush();
	brush1.SetColour( colour );
	dc.SetBrush( brush1 );
}
Example #14
0
void CLabel::DrawBG(wxDC& dc, wxRect& rc)
{
	CTrack *track = getTrack();
	m_rcLabel = rc;

	wxBrush oldBrush = dc.GetBrush();
	wxPen oldpen = dc.GetPen();

	wxPen pen( *wxMEDIUM_GREY_PEN );
	pen.SetWidth(1);
	dc.SetPen( pen );

	//wxBrush brush(m_color, (IsSelected() ? wxCROSSDIAG_HATCH : wxSOLID));
	wxBrush brush(track->GetBGColor(), wxSOLID);
	dc.SetBrush(brush);

	int left, top, width, height;

	if(m_bDrawAquaBG)
	{
		// Draw aqua background
		left   = 0;
		top    = rc.GetTop();
		width  = rc.GetWidth()-left;
		height = rc.GetHeight();
		//dc.DrawRectangle(left, top, width, height);
		wxRect rc(left+1, top+1, width-2, height-2);
		DrawAquaRect(dc, rc, 4);
	}
	else
	{
		// Draw background
		left   = 1;//m_nLevel*4+2;
		top    = rc.GetTop()+1;
		width  = rc.GetWidth()-1;//left-3;
		height = rc.GetHeight()-2;
		//dc.DrawRoundedRectangle(left, top, width, height, 4);
		//DrawRect3D(dc, wxRect(left, top, width, height));
		DrawRect3D(dc, rc);
	}

	dc.SetTextForeground( track->GetForeColor() );
	wxFont oldFont = dc.GetFont();
	wxFont font(9, wxSWISS, wxNORMAL, wxBOLD);
	//wxFont font = oldFont;
	//font.SetWeight(IsSelected() ? wxBOLD : wxNORMAL);
	//font.SetPointSize(GetHeight() / 4);
	font.SetPointSize( 9 );
	dc.SetFont(font);
	//wxFont font(12, wxDEFAULT, wxITALIC, (IsSelected() ? wxBOLD : wxNORMAL));
	//dc.SetFont(font);
	////dc.SetFont((IsSelected() ? *wxITALIC_FONT : *wxNORMAL_FONT));

	// Get text dimensions
	wxCoord w=0, h=0;
	wxString csName;
	track->GetName(csName);
	dc.GetTextExtent(csName, &w, &h);

	/*int ptSize = GetHeight() / 2;
	// Get text dimensions
	wxCoord w=0, h=0;
	do {
		font.SetPointSize(ptSize);
		dc.GetTextExtent(m_name, &w, &h);
		ptSize--;
	} while (w>width && ptSize > 5);*/


	// Draw text
	int x = left + 5;//width/2 - w/2;
	int y = (rc.GetTop() + (rc.GetHeight()/4) - h/2);
	dc.DrawText( csName, x, y );
	m_rcLabel.SetHeight(rc.GetHeight());

/*
	int n = rc.GetHeight()/2-2;
	if(n > 20)
		n = 20;
	drawLoopSign(dc,  wxRect(5, top+height-n-2, n, n));
	drawCacheSign(dc, wxRect(n+5+1, top+height-n-2, n, n));
*/
	wxRect rcTmp = getPathRect(rc);
	m_pPathCtrl->DrawBG(dc, rcTmp);


	dc.SetFont(oldFont);
	dc.SetPen(oldpen);
	dc.SetBrush( oldBrush );
}
Example #15
0
//---------------------------------------------------------
void CWKSP_Layer_Legend::_Draw_Point(wxDC &dc, CWKSP_Shapes_Point *pLayer)
{
	bool		bSize;
	int			min_Size, max_Size;
	double		min_Value, d_Value;
	wxString	Name, Name_Size;
	wxPen		Pen;
	wxBrush		Brush;

	//-----------------------------------------------------
	m_BoxStyle		= BOXSTYLE_CIRCLE;
	m_Box_bFill		= true;

	//-----------------------------------------------------
	bSize	= pLayer->Get_Style_Size(min_Size, max_Size, min_Value, d_Value, &Name_Size);

	pLayer->Get_Style(Pen, Brush, m_Box_bOutline, &Name);

	if( m_pClassify->Get_Mode() != CLASSIFY_UNIQUE || !bSize )
	{
		dc.SetBrush(Brush);
		dc.SetPen(Pen);

		if( Name.Length() > 0 )
		{
			_Draw_Title(dc, FONT_SUBTITLE, Name);
		}

	//	_Draw_Boxes(dc, m_Position.y);
		for(int i=m_pClassify->Get_Class_Count()-1, y=m_Position.y; i>=0; i--, y+=BOX_HEIGHT)
		{
	//		_Draw_Box	(dc, y, BOX_HEIGHT, Get_Color_asWX(m_pClassify->Get_Class_Color(i)));
			_Set_Size(0, BOX_HEIGHT);

			if( m_Box_bOutline == false )
			{
				Pen		= dc.GetPen();
				Pen.SetColour(Get_Color_asWX(m_pClassify->Get_Class_Color(i)));
				dc.SetPen(Pen);
			}

			if( m_Box_bFill )
			{
				Brush	= dc.GetBrush();
				Brush.SetColour(Get_Color_asWX(m_pClassify->Get_Class_Color(i)));
				dc.SetBrush(Brush);
			}

			pLayer->Draw_Symbol(dc, m_xBox + m_dxBox / 2, y + (BOX_HEIGHT - BOX_SPACE) / 2, (BOX_HEIGHT - BOX_SPACE) / 2);

			_Draw_Label(dc, y, m_pClassify->Get_Class_Name(i), TEXTALIGN_TOP);
		}
	}

	//-----------------------------------------------------
	if( bSize )
	{
		dc.SetBrush(Brush);
		dc.SetPen(Pen);

		_Draw_Title(dc, FONT_SUBTITLE, Name_Size);
		_Draw_Point_Sizes(dc, pLayer, min_Size, max_Size, min_Value, d_Value);
		_Set_Size(0, SIZE_HEIGHT + dc.GetFont().GetPointSize());
	}
}
Example #16
0
void DataLayer::renderDC(wxDC& dc, PixelWorld& px)
{
    Series& xdata = *(xdata_);
    Series& ydata = *(ydata_);
    auto savepen = dc.GetPen();


    wxPen colpen(symbolBorder_);

    dc.SetPen(colpen);


    auto savefill = dc.GetBrush();
    wxBrush fill(symbolFill_);
    dc.SetBrush(fill);
    const double& xscale = px.xScale_.scale_;
    const double& yscale = px.yScale_.scale_;
    const double& xoffset = px.xScale_.offset_;
    const double& yoffset = px.yScale_.offset_;

    const int radius = (this->symbolSize_)*2 + 1;

    // draw lines first
    wxPenStyle linepen = indexToPenStyle(lineStyle_);

    wxRect clip(px.left_,px.top_, px.xspan_, px.yspan_);

    {


        if ((lineWidth_ > 0) && (linepen != wxPENSTYLE_TRANSPARENT))
        {
            wxPen linePen(lineColor_, lineWidth_, linepen);

            auto savePen = dc.GetPen();
            dc.SetPen(linePen);
            dc.SetClippingRegion(clip);

            int xprev = 0;
            int yprev = 0;
            for(size_t i = 0; i < xdata.size(); i++)
            {
                auto x = xdata[i];
                auto y = ydata[i];
                if (std::isnan(x) || std::isnan(y))
                    continue;
                auto xpt = (int)( (x-xoffset)* xscale ) + px.left_;
                auto ypt = (int)( (y-yoffset)* yscale ) + px.top_;

                if (i > 0)
                {
                    dc.DrawLine(xprev,yprev,xpt,ypt);
                }
                xprev = xpt;
                yprev = ypt;
            }

            dc.SetPen(savePen);
        }

        auto sdraw = SymbolDraw::MakeSymbolDraw((PlotShape)symbolShape_, radius, dc);
        wxPen sympen(this->symbolBorder_, 1, wxPENSTYLE_SOLID);

        dc.SetPen(sympen);
        dc.SetClippingRegion(clip);
        auto errors = errorbar_;
        for(size_t i = 0; i < xdata.size(); i++)
        {
            auto x = xdata[i];
            auto y = ydata[i];
            if (std::isnan(x) || std::isnan(y))
                continue;
            auto xpt = (int)( (x-xoffset)* xscale ) + px.left_;
            auto ypt = (int)( (y-yoffset)* yscale ) + px.top_;

            sdraw->draw(xpt,ypt);

            if (errors != nullptr)
            {
                auto errorSize = (*errors)[i];
                auto ept = (int)( errorSize*yscale);
                dc.DrawLine(xpt,ypt-ept,xpt,ypt+ept);
                dc.DrawLine(xpt-radius,ypt-ept,xpt+radius, ypt-ept);
                dc.DrawLine(xpt-radius,ypt+ept,xpt+radius, ypt+ept);
            }
        }
    }
    dc.SetBrush(savefill);
    dc.SetPen(savepen);
    dc.DestroyClippingRegion();
}
Example #17
0
//---------------------------------------------------------
void CWKSP_Layer_Legend::Draw(wxDC &dc, double Zoom, double Zoom_Map, wxPoint Position, wxSize *pSize, bool bVertical)
{
	//-----------------------------------------------------
	m_Zoom		= Zoom > 0.0 ? Zoom : 1.0;
	m_Position	= Position;
	m_Size		= wxSize(BOX_WIDTH, 0);

	m_Zoom_Map	= Zoom_Map;
	m_bVertical	= bVertical;

	//-----------------------------------------------------
	m_oldPen	= dc.GetPen();
	m_oldBrush	= dc.GetBrush();
	m_oldFont	= dc.GetFont();

	//-----------------------------------------------------
	m_xBox		= m_Position.x;
	m_dxBox		= BOX_WIDTH;
	m_xTick		= m_xBox	+ m_dxBox;
	m_dxTick	= TICK_WIDTH;
	m_xText		= m_xTick	+ m_dxTick;

	//-----------------------------------------------------
	_Draw_Title(dc, FONT_TITLE, m_pLayer->Get_Object()->Get_Name());

	//-----------------------------------------------------
	switch( m_pLayer->Get_Type() )
	{
	case WKSP_ITEM_Shapes:
		switch( ((CWKSP_Shapes *)m_pLayer)->Get_Shapes()->Get_Type() )
		{
		case SHAPE_TYPE_Point:
		case SHAPE_TYPE_Points:
			_Draw_Point		(dc, (CWKSP_Shapes_Point   *)m_pLayer);
			break;

		case SHAPE_TYPE_Line:
			_Draw_Line		(dc, (CWKSP_Shapes_Line    *)m_pLayer);
			break;

		case SHAPE_TYPE_Polygon:
			_Draw_Polygon	(dc, (CWKSP_Shapes_Polygon *)m_pLayer);
			break;

		default:
			break;
		}
		break;

	case WKSP_ITEM_TIN:
		_Draw_TIN	(dc, (CWKSP_TIN        *)m_pLayer);
		break;

	case WKSP_ITEM_PointCloud:
//		_Draw_TIN	(dc, (CWKSP_PointCloud *)m_pLayer);
		break;

	case WKSP_ITEM_Grid:
		_Draw_Grid	(dc, (CWKSP_Grid       *)m_pLayer);
		break;

	default:
		break;
	}

	//-----------------------------------------------------
	dc.SetPen	(m_oldPen);
	dc.SetBrush	(m_oldBrush);
	dc.SetFont	(m_oldFont);

	//-----------------------------------------------------
	if( pSize )
	{
		*pSize	= m_Size;
	}
}
Example #18
0
void StateEvaluationTreePanel::drawNode(wxDC &DC,
                                        ColourScheme const &Scheme,
                                        NodeInfo const &Node,
                                        NodeDecoration const Decoration)
{
  auto const CharWidth  = DC.GetCharWidth();
  auto const CharHeight = DC.GetCharHeight();
  
  wxCoord const PageBorderV = CharHeight * Settings.PageBorderVertical;
  
  // Determine the indicator (if any).
  IndicatorStyle const *Indicator = nullptr;
  switch (Decoration) {
    case NodeDecoration::None:
      break;
    case NodeDecoration::Active:
      Indicator = &(Scheme.getActiveCode());
      break;
    case NodeDecoration::Highlighted:
      Indicator = &(Scheme.getHighlightCode());
      break;
  }
  
  // Set the background colour.
  DC.SetPen(wxPen{Scheme.getDefault().GetForeground(), Settings.PenWidth});
  DC.SetBrush(wxBrush{Scheme.getDefault().GetBackground()});
  DC.SetTextForeground(Scheme.getDefault().GetForeground());
  
  // Also highlight this node's area in the pretty-printed Stmt.
  if (Indicator) {
    drawIndicatorAtArea(DC, *Indicator,
                        Node.XStart, PageBorderV,
                        Node.XEnd - Node.XStart, CharHeight);
  }
  
  // Draw the background.
  wxPen const PrevPen = DC.GetPen();
  DC.SetPen(wxPen{DC.GetBrush().GetColour()});
  DC.DrawRectangle(Node.XStart, Node.YStart,
                   Node.XEnd - Node.XStart, Node.YEnd - Node.YStart);
  DC.SetPen(PrevPen);

  // Draw the line over the node.
  DC.DrawLine(Node.XStart, Node.YStart, Node.XEnd + 1, Node.YStart);
  
  // Draw the base indicator on the node (if any).
  if (Indicator) {
    drawIndicatorAtArea(DC, *Indicator,
                        Node.XStart, Node.YStart,
                        Node.XEnd - Node.XStart, Node.YEnd - Node.YStart);
  }
  
  // Draw the error indicator if the node has an error.
  if (Node.Error == NodeError::Error) {
    drawIndicatorAtArea(DC, Scheme.getErrorCode(),
                        Node.XStart, Node.YStart,
                        Node.XEnd - Node.XStart, Node.YEnd - Node.YStart);
  }

  // Draw the node's value string.
  if (Node.Value) {
    auto const ValText = Node.ValueStringShort;
    auto const TextWidth = CharWidth * ValText.size();
    auto const NodeWidth = CharWidth * Node.RangeLength;
    auto const Offset = (NodeWidth - TextWidth) / 2;
    DC.DrawText(ValText, Node.XStart + Offset, Node.YStart);
  }
}