/// Gets a rectangle from within another image, INCLUDING the alpha channel
/// \bug in wxWidgets, wxImage::GetSubImage should do this itself.
wxImage GetSubImageWithAlpha( const wxImage & Src,  const wxRect &rect )
{
   //First part of this code is lifted from wxImage::GetSubImage() source code.
   wxImage image;

   wxCHECK_MSG( Src.Ok(), image, wxT("invalid image") );

   wxCHECK_MSG( (rect.GetLeft()>=0) && (rect.GetTop()>=0) && (
      rect.GetRight()<=Src.GetWidth()) && (rect.GetBottom()<=Src.GetHeight()),
      image, wxT("invalid subimage size") );

   int subwidth=rect.GetWidth();
   const int subheight=rect.GetHeight();

   image.Create( subwidth, subheight, false );

   unsigned char *subdata = image.GetData(), *data=Src.GetData();

   wxCHECK_MSG( subdata, image, wxT("unable to create image") );

   // JKC: Quick hack - don't deal with masks - need to understand macro M_IMGDATA first.
//   if (Src.M_IMGDATA->m_hasMask)
//      image.SetMaskColour( Src.M_IMGDATA->m_maskRed, Src.M_IMGDATA->m_maskGreen, Src.M_IMGDATA->m_maskBlue );

   int subleft=3*rect.GetLeft();
   int width=3*Src.GetWidth();
   subwidth*=3;

   data+=rect.GetTop()*width+subleft;

   for (long j = 0; j < subheight; ++j)
   {
      memcpy( subdata, data, subwidth);
      subdata+=subwidth;
      data+=width;
   }

   // OK, so we've copied the RGB data.
   // Now do the Alpha channel.
   wxASSERT( Src.HasAlpha() );
   image.InitAlpha();

   subleft/=3;
   width/=3;
   subwidth/=3;

   data =Src.GetAlpha();
   subdata =image.GetAlpha();

   data+=rect.GetTop()*width+subleft;

   for (long j = 0; j < subheight; ++j)
   {
      memcpy( subdata, data, subwidth);
      subdata+=subwidth;
      data+=width;
   }
   return image;
}
//---------------------------------------------------------
wxRect CVIEW_ScatterPlot::_Draw_Get_rDiagram(wxRect r)
{
	return(	wxRect(
		wxPoint(r.GetLeft () + 45, r.GetTop   () + 20),
		wxPoint(r.GetRight() - 20, r.GetBottom() - 40)
	));
}
示例#3
0
static void GetStats(double *mean, double *stdev, const FloatImg& img, const wxRect& win)
{
    // Determine the mean and standard deviation
    double sum = 0.0;
    double a = 0.0;
    double q = 0.0;
    double k = 1.0;
    double km1 = 0.0;

    const int width = img.Size.GetWidth();
    const float *p0 = &img.px[win.GetTop() * width + win.GetLeft()];
    for (int y = 0; y < win.GetHeight(); y++)
    {
        const float *end = p0 + win.GetWidth();
        for (const float *p = p0; p < end; p++)
        {
            double const x = (double) *p;
            sum += x;
            double const a0 = a;
            a += (x - a) / k;
            q += (x - a0) * (x - a);
            km1 = k;
            k += 1.0;
        }
        p0 += width;
    }

    *mean = sum / km1;
    *stdev = sqrt(q / km1);
}
示例#4
0
//
// Draws a focus rectangle (Taken directly from wxWidgets source)
//
void AColor::DrawFocus(wxDC & dc, wxRect & rect)
{
   // draw the pixels manually: note that to behave in the same manner as
   // DrawRect(), we must exclude the bottom and right borders from the
   // rectangle
   wxCoord x1 = rect.GetLeft(),
         y1 = rect.GetTop(),
         x2 = rect.GetRight(),
         y2 = rect.GetBottom();

   dc.SetPen(wxPen(wxT("MEDIUM GREY"), 0, wxSOLID));

   // this seems to be closer than what Windows does than wxINVERT although
   // I'm still not sure if it's correct
   dc.SetLogicalFunction(wxAND_REVERSE);

   wxCoord z;
   for ( z = x1 + 1; z < x2; z += 2 )
      dc.DrawPoint(z, y1);

   wxCoord shift = z == x2 ? 0 : 1;
   for ( z = y1 + shift; z < y2; z += 2 )
      dc.DrawPoint(x2, z);

   shift = z == y2 ? 0 : 1;
   for ( z = x2 - shift; z > x1; z -= 2 )
      dc.DrawPoint(z, y2);

   shift = z == x1 ? 0 : 1;
   for ( z = y2 - shift; z > y1; z -= 2 )
      dc.DrawPoint(x1, z);

   dc.SetLogicalFunction(wxCOPY);
}
示例#5
0
// Returns the rectangle for this object (id = 0) or a child element (id > 0).
wxAccStatus CProjectListCtrlAccessible::GetLocation(wxRect& rect, int elementId)
{
    CProjectListCtrl* pCtrl = wxDynamicCast(GetWindow(), CProjectListCtrl);
    if (pCtrl && (0 == elementId))
    {
        // List control
        rect.SetPosition(pCtrl->GetScreenPosition());
        rect.SetWidth(pCtrl->GetSize().GetWidth());
        rect.SetHeight(pCtrl->GetSize().GetHeight());
        return wxACC_OK;
    }
    else if (pCtrl && (0 != elementId))
    {
        // List item
        wxSize cCtrlSize = pCtrl->GetClientSize();

        // Set the initial control postition to the absolute coords of the upper
        //   left hand position of the control
        rect.SetPosition(pCtrl->GetScreenPosition());
        rect.width = cCtrlSize.GetWidth() - 1;
        rect.height = pCtrl->GetItemHeight(elementId - 1) - 1;

        // Items can have different heights
        int    firstVisibleItem = (int)pCtrl->GetFirstVisibleLine();
        int    yOffset = 0;
        for (int i=firstVisibleItem; i<(elementId - 1); ++i) {
            yOffset += pCtrl->GetItemHeight((size_t)i);
        }
        rect.SetTop(rect.GetTop() + yOffset);
        rect.height -= 1;
        return wxACC_OK;
    }
    // Let the framework handle the other cases.
    return wxACC_FALSE;
}
示例#6
0
void PaddingStyle::FromRect(const wxRect& rect) {
  Left = rect.GetLeft();
  Top = rect.GetTop();
  Bottom = rect.GetHeight();
  Right = rect.GetWidth();
  Width = Left + Right;
  Height = Top + Bottom;
}
示例#7
0
bool MathCell::InUpdateRegion(wxRect rect)
{
  return
    (rect.GetRight()  >= m_updateRegion.GetLeft()  ) &&
    (rect.GetLeft()   <= m_updateRegion.GetRight() ) &&
    (rect.GetBottom() >= m_updateRegion.GetTop()   ) &&
    (rect.GetTop()    <= m_updateRegion.GetBottom());
}
示例#8
0
void wxStdRenderer::DrawFrameWithoutLabel(wxDC& dc,
                                          const wxRect& rectFrame,
                                          const wxRect& rectLabel)
{
    // draw left, bottom and right lines entirely
    DrawVerticalLine(dc, rectFrame.GetLeft(),
                     rectFrame.GetTop(), rectFrame.GetBottom() - 2);
    DrawHorizontalLine(dc, rectFrame.GetBottom() - 1,
                       rectFrame.GetLeft(), rectFrame.GetRight());
    DrawVerticalLine(dc, rectFrame.GetRight() - 1,
                     rectFrame.GetTop(), rectFrame.GetBottom() - 1);

    // and 2 parts of the top line
    DrawHorizontalLine(dc, rectFrame.GetTop(),
                       rectFrame.GetLeft() + 1, rectLabel.GetLeft());
    DrawHorizontalLine(dc, rectFrame.GetTop(),
                       rectLabel.GetRight(), rectFrame.GetRight() - 2);
}
 void configuration_visitor::set_bbox(const wxRect& r) {
     boost::shared_ptr<vector_layer_ghost> ghost = m_panel->vectorlayerghost();
     if(!ghost) return;
     ghost->reset<vector_layer_ghost::Rectangle>();
     ghost->add_point(wxRealPoint(r.GetLeft (),r.GetTop   ()));
     ghost->add_point(wxRealPoint(r.GetRight(),r.GetBottom()));
     ghost->m_penRectangle = wxPen(*wxRED, 2, wxDOT);
     ghost->m_brushRectangle = wxBrush(*wxRED, wxTRANSPARENT);
 }
示例#10
0
文件: aqua.cpp 项目: sqba/floopy
void DrawAquaRect(wxDC& dc, wxRect& rc, int radius)
{
	int left	= rc.GetX();
	int top		= rc.GetTop();
	int height	= rc.GetHeight();
	int width	= rc.GetWidth();
	int right	= left+width;

	if(width <= radius*2)
		return;

	wxPen oldpen = dc.GetPen();

	int border	= 2;//(IsSelected() ? 2 : 1);

	int edge = radius;
	int endEdge = top+radius;
	float rstep = 60.f / ((float)height / 3.f);
	float gstep = 20.f / ((float)height / 3.f);
	float r=180.f, g=190.f, b=225.f;
	for(int y=top+1; y<top+height/3; y++)
	{
		r -= rstep;
		g -= gstep;
		dc.SetPen( wxPen(wxColor(r, g, b), border) );
		if(y<endEdge)
		{
			dc.DrawLine(left+edge, y, right-edge*2, y);
			edge--;
		}
		else
			dc.DrawLine(left, y, right, y);
	}

	edge = 1;
	int startEdge = top+height-radius;
	rstep = 75.f / (((float)height / 3.f) * 2.f);
	gstep = 51.f / (((float)height / 3.f) * 2.f);
	r=111.f, g=161.f, b=225.f;
	for(int y=top+height/3; y<top+height-1; y++)
	{
		r += rstep;
		g += gstep;
		dc.SetPen( wxPen(wxColor(r, g, b), border) );
		if(y>=startEdge)
		{
			dc.DrawLine(left+edge, y, right-edge*2, y);
			edge++;
		}
		else
			dc.DrawLine(left, y, right, y);
	}

	dc.SetPen( oldpen );
}
示例#11
0
wxDCOverlay::wxDCOverlay(wxOverlay &overlay, wxDC *dc) :
    m_overlay(overlay)
{
    const wxRect device(wxPoint(0, 0), dc->GetSize());

    Init(dc,
         dc->DeviceToLogicalX(device.GetLeft()),
         dc->DeviceToLogicalY(device.GetTop()),
         dc->DeviceToLogicalX(device.GetRight()),
         dc->DeviceToLogicalY(device.GetBottom()));
}
//---------------------------------------------------------
void CVIEW_ScatterPlot::_Draw_Regression(wxDC &dc, wxRect r)
{
	wxPen	oldPen	= dc.GetPen();

	dc.SetPen(wxPen(
		m_Options("REG_COLOR")->asColor(),
		m_Options("REG_SIZE" )->asInt()
	));

	//-----------------------------------------------------
	double	dx	= (r.GetWidth () - 1.) / m_Trend.Get_Data_XStats().Get_Range();
	double	dy	= (r.GetHeight() - 1.) / m_Trend.Get_Data_YStats().Get_Range();

	//-----------------------------------------------------
	dc.DrawCircle(
		GET_DC_X(m_Trend.Get_Data_XStats().Get_Mean()),
		GET_DC_Y(m_Trend.Get_Data_YStats().Get_Mean()), 2
	);

	double	ex	= m_Trend.Get_Data_XStats().Get_Range() / (double)r.GetWidth();
	double	x	= m_Trend.Get_Data_XMin();

	for(int ix=0, ay, by=0; ix<r.GetWidth(); ix++, x+=ex)
	{
		double	y	= m_Trend.Get_Value(x);

		ay	= by; by = r.GetBottom() - (int)(dy * (y - m_Trend.Get_Data_YMin()));

		if( ix > 0 && r.GetTop() < ay && ay < r.GetBottom() && r.GetTop() < by && by < r.GetBottom() )
		{
			dc.DrawLine(r.GetLeft() + ix - 1, ay, r.GetLeft() + ix, by);
		}
	}

	dc.SetPen(oldPen);

	//-----------------------------------------------------
	Draw_Text(dc, TEXTALIGN_BOTTOMCENTER, r.GetLeft() + r.GetWidth() / 2, r.GetTop(),
		m_Trend.Get_Formula(SG_TREND_STRING_Compact).c_str()
	);
}
示例#13
0
//-----------------------------------------------------------------------
CEGUI::Imageset* EditorDocument::generateRealImageset(const wxString& pathName)
{
    const String imagesetName ( CEGUIHelper::ToCEGUIString( m_imagesetName ) );
    const String imageFilename ( CEGUIHelper::ToCEGUIString( pathName + m_imageFilename ) );

    ImagesetManager& isMgr = ImagesetManager::getSingleton();

    if ( isMgr.isImagesetPresent( imagesetName ) )
        // TODO: Maybe ask user whether to continue here?
        isMgr.destroyImageset( imagesetName );

    // create the imageset
    Imageset* imageset = isMgr.createImagesetFromImageFile( imagesetName, imageFilename );

    // auto-scale options
    imageset->setAutoScalingEnabled( m_autoScaled );
    imageset->setNativeResolution( CEGUI::Size( m_nativeResolution.x, m_nativeResolution.y ) );

    // iterate over all the elements in the class
    mapNamedRegion::iterator it;
    for( it = m_mapSetRectangles.begin(); it != m_mapSetRectangles.end(); ++it )
    {
        const String imageName = CEGUIHelper::ToCEGUIString( wxString( it->first ) );

        if ( !imageset->isImageDefined( imageName ) )
        {
            const wxRect r( it->second );
            const CEGUI::Rect newDim( ( ( r.GetLeft() > 0 ) ? r.GetLeft() : 0 ),
                               ( ( r.GetTop() > 0 ) ? r.GetTop() : 0 ),
                               ( ( r.GetRight() + 1 > 0 ) ? r.GetRight() + 1 : 0 ),
                               ( ( r.GetBottom() + 1 > 0 ) ? r.GetBottom() + 1 : 0 ) );
            const CEGUI::Point p ( 0.0f, 0.0f );
            imageset->defineImage( imageName, newDim, p );
        }
    }

    if ( imageset->isImageDefined ( "full_image" ) )
        imageset->undefineImage( "full_image" );

    return imageset;
}
bool LfnTech::Copy(
	void* destBase,
	const void* srcBase,
	const wxPoint& destPoint,
	const wxRect& srcRect,
	int destStride,
	int srcStride,
	int bytesPerPixel)
{
	bool result = false;

	if (destBase && srcBase && destStride > 0 && srcStride > 0 && bytesPerPixel > 0)
	{
		const int srcLeft = srcRect.GetLeft();
		const int srcBottom = srcRect.GetBottom();
		const int bytesPerRowCopy = bytesPerPixel * srcRect.GetWidth();
		if (bytesPerRowCopy == destStride && bytesPerRowCopy == srcStride)
		{
			wxASSERT(destPoint.x == 0);
			wxASSERT(srcLeft == 0);
			memcpy(
				GetRowMajorPointer(destBase, destStride, bytesPerPixel, destPoint.x, destPoint.y),
				GetRowMajorPointer(srcBase, srcStride, bytesPerPixel, srcLeft, srcRect.GetTop()),
				bytesPerRowCopy * srcRect.GetHeight());
		}
		else
		{
			for (int srcY = srcRect.GetTop(), destY = destPoint.y; srcY <= srcBottom; ++srcY, ++destY)
			{
				memcpy(
					GetRowMajorPointer(destBase, destStride, bytesPerPixel, destPoint.x, destY),
					GetRowMajorPointer(srcBase, srcStride, bytesPerPixel, srcLeft, srcY),
					bytesPerRowCopy);
			}
		}

		result = true;
	}

	return result;
}
示例#15
0
wxRect MathCell::CropToUpdateRegion(wxRect rect)
{
  int left  =rect.GetLeft();
  int top   =rect.GetTop ();
  int right =rect.GetRight();
  int bottom=rect.GetBottom();
  if (left   < m_updateRegion.GetLeft())   left   = m_updateRegion.GetLeft();
  if (right  > m_updateRegion.GetRight())  right  = m_updateRegion.GetRight();
  if (top    < m_updateRegion.GetTop())    top    = m_updateRegion.GetTop();
  if (bottom > m_updateRegion.GetBottom()) bottom = m_updateRegion.GetBottom();
  return wxRect(wxPoint(left,top),wxPoint(right,bottom));
}
示例#16
0
static bool ASCOM_SetROI(IDispatch *cam, const wxRect& roi, EXCEPINFO *excep)
{
    // returns true on error, false if OK

    VARIANTARG rgvarg[1];
    rgvarg[0].vt = VT_I4;

    DISPID dispidNamed = DISPID_PROPERTYPUT;
    DISPPARAMS dispParms;
    dispParms.cArgs = 1;
    dispParms.rgvarg = rgvarg;
    dispParms.cNamedArgs = 1;                   // PropPut kludge
    dispParms.rgdispidNamedArgs = &dispidNamed;

    Variant vRes;
    HRESULT hr;

    rgvarg[0].lVal = roi.GetLeft();
    if (FAILED(hr = cam->Invoke(dispid_startx, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT,
        &dispParms, &vRes, excep, NULL)))
    {
        LogExcep(hr, "set startx", *excep);
        return true;
    }

    rgvarg[0].lVal = roi.GetTop();
    if (FAILED(hr = cam->Invoke(dispid_starty, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT,
        &dispParms, &vRes, excep, NULL)))
    {
        LogExcep(hr, "set starty", *excep);
        return true;
    }

    rgvarg[0].lVal = roi.GetWidth();
    if (FAILED(hr = cam->Invoke(dispid_numx, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT,
        &dispParms, &vRes, excep, NULL)))
    {
        LogExcep(hr, "set numx", *excep);
        return true;
    }

    rgvarg[0].lVal = roi.GetHeight();
    if (FAILED(hr = cam->Invoke(dispid_numy, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT,
        &dispParms, &vRes, excep, NULL)))
    {
        LogExcep(hr, "set numy", *excep);
        return true;
    }

    return false;
}
示例#17
0
文件: label.cpp 项目: sqba/floopy
wxRect CLabel::getPathRect(wxRect& rc)
{
	int top    = rc.GetTop()+1;
	int height = rc.GetHeight()-2;

	wxRect rcTmp = rc;
	int tmpHeight = height/3;
	if(tmpHeight>25)
		tmpHeight = 25;
	rcTmp.SetY(top+height - tmpHeight);
	rcTmp.SetHeight(tmpHeight);

	return rcTmp;
}
示例#18
0
void
wxStdRenderer::DrawFocusRect(wxWindow* WXUNUSED(win), wxDC& dc, const wxRect& rect, int WXUNUSED(flags))
{
    // draw the pixels manually because the "dots" in wxPen with wxDOT style
    // may be short traits and not really dots
    //
    // note that to behave in the same manner as DrawRect(), we must exclude
    // the bottom and right borders from the rectangle
    wxCoord x1 = rect.GetLeft(),
            y1 = rect.GetTop(),
            x2 = rect.GetRight(),
            y2 = rect.GetBottom();

    dc.SetPen(m_penBlack);

    // this seems to be closer than what Windows does than wxINVERT although
    // I'm still not sure if it's correct
    dc.SetLogicalFunction(wxAND_REVERSE);

    wxCoord z;
    for ( z = x1 + 1; z < x2; z += 2 )
        dc.DrawPoint(z, rect.GetTop());

    wxCoord shift = z == x2 ? 0 : 1;
    for ( z = y1 + shift; z < y2; z += 2 )
        dc.DrawPoint(x2, z);

    shift = z == y2 ? 0 : 1;
    for ( z = x2 - shift; z > x1; z -= 2 )
        dc.DrawPoint(z, y2);

    shift = z == x1 ? 0 : 1;
    for ( z = y2 - shift; z > y1; z -= 2 )
        dc.DrawPoint(x1, z);

    dc.SetLogicalFunction(wxCOPY);
}
示例#19
0
    wxToolInfo(HWND hwndOwner, unsigned int id, const wxRect& rc)
    {
        // initialize all members
        ::ZeroMemory(this, sizeof(TOOLINFO));

        // the structure TOOLINFO has been extended with a 4 byte field in
        // version 4.70 of comctl32.dll and another one in 5.01 but we don't
        // use these extended fields so use the old struct size to ensure that
        // the tooltips work on old (Windows 95) systems too
        cbSize = TTTOOLINFO_V1_SIZE;

        hwnd = hwndOwner;

        if (rc.IsEmpty())
        {
            uFlags = TTF_IDISHWND;
            uId = (UINT_PTR)hwndOwner;
        }
        else
        {
            // this tooltip must be shown only if the mouse hovers a specific rect
            // of the hwnd parameter!
            rect.left = rc.GetLeft();
            rect.right = rc.GetRight();
            rect.top = rc.GetTop();
            rect.bottom = rc.GetBottom();

            // note that not setting TTF_IDISHWND from the uFlags member means that the
            // ti.uId field should not contain the HWND but rather as MSDN says an
            // "Application-defined identifier of the tool"; this is used internally by
            // Windows to distinguish the different tooltips attached to the same window
            uId = id;
        }

        // we use TTF_TRANSPARENT to fix a problem which arises at least with
        // the text controls but may presumably happen with other controls
        // which display the tooltip at mouse position: it can start flashing
        // then as the control gets "focus lost" events and dismisses the
        // tooltip which then reappears because mouse remains hovering over the
        // control, see SF patch 1821229
        if ( wxApp::GetComCtl32Version() >= 470 )
        {
            uFlags |= TTF_TRANSPARENT;
        }
    }
//---------------------------------------------------------
void CVIEW_ScatterPlot::_Draw_Legend(wxDC &dc, wxRect r)
{
	CSG_Colors	Colors(*m_Options("DENSITY_PAL")->asColors());

	Colors.Set_Count(r.GetHeight());

	for(int i=0, y=r.GetBottom(); i<Colors.Get_Count(); i++, y--)
	{
		Draw_FillRect(dc, Get_Color_asWX(Colors.Get_Color(i)), r.GetLeft(), y, r.GetRight(), y + 1);
	}

//	r.Offset(0, -r.GetHeight());

	Draw_Edge(dc, EDGE_STYLE_SIMPLE, r);

	Draw_Text(dc, TEXTALIGN_BOTTOMLEFT, 2 + r.GetRight(), r.GetBottom(), "0");
	Draw_Text(dc, TEXTALIGN_TOPLEFT   , 2 + r.GetRight(), r.GetTop   (), wxString::Format("%d", (int)m_Count.Get_Max()));
}
示例#21
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 );
}
示例#22
0
vector< wxRect > GetCoverage( const wxRect& viewport, const wxRect& canvas, const wxSize& gridSize )
{
    const wxRect clippedViewport( canvas.Intersect( viewport ) );

    vector< wxRect > coverage;
    const int top    = clippedViewport.GetTop()    / gridSize.y;
    const int bottom = clippedViewport.GetBottom() / gridSize.y;
    const int left   = clippedViewport.GetLeft()   / gridSize.x;
    const int right  = clippedViewport.GetRight()  / gridSize.x;
    for( int y = top; y <= bottom; ++y )
    {
        for( int x = left; x <= right; ++x )
        {
            const wxRect candidate( x * gridSize.x, y * gridSize.y, gridSize.x, gridSize.y );
            const wxRect clipped( canvas.Intersect( candidate ) );
            coverage.push_back( clipped );
        }
    }
    return coverage;
}
示例#23
0
BOOL FontDropDown::DrawIcon(void * ItemData, wxDC& dc, wxRect& IconRect, BOOL Disabled, INT32 flags)
{
	ResourceID BitmapID = 0;
	FontClass Type;

	if ((ItemData==&TheTopItem) || !ItemData)
		Type = TheTopItem.Type;
	else
		Type = ((FontDropItem *)ItemData)->Type;

	switch(Type)
	{
		case FC_TRUETYPE:
			BitmapID = _R(IDB_TTF_SYMBOL);
			break;

		case FC_ATM:
			BitmapID = _R(IDB_ATM_SYMBOL);
			break;

		case FC_UNDEFINED:
			BitmapID = _R(IDB_UNKNOWNFONT_SYMBOL);
			break;

		default:
			BitmapID = 0;
			break;
	}

	if(BitmapID == 0)
		return FALSE;

	wxBitmap * pBitmap = CamArtProvider::Get()->FindBitmap(BitmapID, (CamArtFlags)(CAF_DEFAULT|(Disabled?CAF_GREYED:0)));
	if (!pBitmap)
		return FALSE;

	dc.DrawBitmap(*pBitmap, IconRect.GetLeft(), IconRect.GetTop(), TRUE);

	return TRUE;
}
示例#24
0
void SkinGradient::GenRects(wxGraphicsContext* gc, const wxRect& therect)
{
    if (0 && therect == oldRect) {
        // use already cached rectangles.
        //
        // TODO: this caching falls down with scrolling, since the position of each
        // incoming rectangle is different.
        return;
    }

    float x   = therect.x, y = therect.y;
    float w   = therect.width;
    float h   = therect.height;
    bool vert = direction == wxVERTICAL;

    float p1  = vert? therect.GetTop() : therect.GetLeft();

    size_t lc = colors.size() - 1;
    float dx  = (vert ? h : w) / float(lc);

    rects.clear();
    for (size_t i = 0; i < lc; ++i) {
        wxColour c1(colors[i]);
        wxColour c2(colors[i+1]);

        float delta = i == 0 || i == lc ? 1.0 : 0.0;
        if (vert)
            rects.push_back(BrushRect(
                                gc->CreateLinearGradientBrush(x, p1 - delta, x, p1 + dx + delta*2, c1, c2),
                                wxRect2DDouble(x, p1, w, dx + delta - 1)));
        else
            rects.push_back(BrushRect(
                                gc->CreateLinearGradientBrush(p1 - delta, y, p1 + dx + delta*2, y, c1, c2),
                                wxRect2DDouble(p1, y, dx + delta, h)));
        p1 += dx;
    }

    oldRect = therect;
}
示例#25
0
文件: label.cpp 项目: sqba/floopy
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 );
}
示例#26
0
文件: dropdown.cpp 项目: vata/xarino
wxSize DropDown::HandleDrawItemInternal(wxDC& dc, const wxRect& Rect, INT32 item, INT32 flags, BOOL Draw)
{
	const INT32 border = 2;

	if (CCamApp::IsDisabled())			// Inside an error handler
		return(wxDefaultSize);

	wxOwnerDrawnComboBox * pGadget = GetBox();

//	if ((INT32)pInfo->itemID == -1 || (INT32)pInfo->itemData == -1)	// Draw item -1: just exit
//		return(FALSE);

	void * ItemData = GetItemData(item);
		// Determine if it is a divider item
	if (!ItemData)
	{
		// It's a divider, so draw it specially - it is a simple black line across the center of the rectangle
		wxCoord midpoint = Rect.GetTop()+Rect.GetHeight()/2;
		if (Draw)
		{
			wxPen OldPen=dc.GetPen();
			dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)));
			dc.DrawLine(Rect.GetLeft(), midpoint, Rect.GetRight()+1, midpoint);
			dc.SetPen(OldPen);
		}
		return(wxSize(-1,5));
	}

	// If we aren't drawing, we should get the size of the text and return that appopriately modified
	if (!Draw)
	{
		// Call the derived class
		wxRect def(-1,-1,-1,-1);
		wxSize TextSize = DrawText(ItemData, dc, def, item, flags, FALSE); // Rect is unused here as Draw is FALSE
		TextSize.x+=2*border;
		TextSize.y+=2*border; // This gives us the bounding rect as we leave some space around it
		if (HasIcon(ItemData))
		{
			// There is an icon. It's width is equal to the text height less 2 (deflated in both
			// directions. There is also a 6 pixel space
			TextSize.x += (TextSize.y-2)+6;
		}
		return TextSize;
	}
	
	wxRect rect=Rect;
	rect.Deflate(border);

	// Calculate where the colour splodge (if any) will go (also used to shift text to the right later)
	wxRect IconRect=rect;
	IconRect.Deflate(1);
	IconRect.SetWidth(IconRect.GetHeight());

	wxRect TextRect=rect;

	wxPalette * OldPal = NULL;

	// If it's a special item with a colour splodge, or a normal colour item, draw the colour splodge
	if (HasIcon(ItemData))
	{
		if (PaletteManager::UsePalette())
			OldPal = PaletteManager::StartPaintPalette(&dc);

		// Call the derived class to draw the icon
		if (Draw)
			DrawIcon(ItemData, dc, IconRect, !pGadget->IsEnabled(), flags);

		// Shift the text to the right of the icon
		INT32 shift=IconRect.GetWidth()+6;
		TextRect.Offset(shift,0);
		INT32 NewWidth=TextRect.GetWidth()-shift;
		TextRect.SetWidth(NewWidth<1?1:NewWidth);
	}
	
	if (TextRect.GetWidth()>1)		// if there's room to draw any text, draw it
	{
		// Call derived class to draw the text
		if (Draw)
			DrawText(ItemData, dc, TextRect, item, flags, TRUE);
	}

	// Restore the DC's previous palette if we selected our one in
	if (OldPal)
		PaletteManager::StopPaintPalette(&dc, OldPal);

	return(wxDefaultSize);
}
示例#27
0
文件: toplvcmn.cpp 项目: mark711/Cafu
void wxTopLevelWindowBase::DoCentre(int dir)
{
    // on some platforms centering top level windows is impossible
    // because they are always maximized by guidelines or limitations
    //
    // and centering a maximized window doesn't make sense as its position
    // can't change
    if ( IsAlwaysMaximized() || IsMaximized() )
        return;

    // we need the display rect anyhow so store it first: notice that we should
    // be centered on the same display as our parent window, the display of
    // this window itself is not really defined yet
    int nDisplay = wxDisplay::GetFromWindow(GetParent() ? GetParent() : this);
    wxDisplay dpy(nDisplay == wxNOT_FOUND ? 0 : nDisplay);
    const wxRect rectDisplay(dpy.GetClientArea());

    // what should we centre this window on?
    wxRect rectParent;
    if ( !(dir & wxCENTRE_ON_SCREEN) && GetParent() )
    {
        // centre on parent window: notice that we need screen coordinates for
        // positioning this TLW
        rectParent = GetParent()->GetScreenRect();

        // if the parent is entirely off screen (happens at least with MDI
        // parent frame under Mac but could happen elsewhere too if the frame
        // was hidden/moved away for some reason), don't use it as otherwise
        // this window wouldn't be visible at all
        if ( !rectParent.Intersects(rectDisplay) )
        {
            // just centre on screen then
            rectParent = rectDisplay;
        }
    }
    else
    {
        // we were explicitly asked to centre this window on the entire screen
        // or if we have no parent anyhow and so can't centre on it
        rectParent = rectDisplay;
    }

    if ( !(dir & wxBOTH) )
        dir |= wxBOTH; // if neither is specified, center in both directions

    // the new window rect candidate
    wxRect rect = GetRect().CentreIn(rectParent, dir & ~wxCENTRE_ON_SCREEN);

    // we don't want to place the window off screen if Centre() is called as
    // this is (almost?) never wanted and it would be very difficult to prevent
    // it from happening from the user code if we didn't check for it here
    if ( !rectDisplay.Contains(rect.GetTopLeft()) )
    {
        // move the window just enough to make the corner visible
        int dx = rectDisplay.GetLeft() - rect.GetLeft();
        int dy = rectDisplay.GetTop() - rect.GetTop();
        rect.Offset(dx > 0 ? dx : 0, dy > 0 ? dy : 0);
    }

    if ( !rectDisplay.Contains(rect.GetBottomRight()) )
    {
        // do the same for this corner too
        int dx = rectDisplay.GetRight() - rect.GetRight();
        int dy = rectDisplay.GetBottom() - rect.GetBottom();
        rect.Offset(dx < 0 ? dx : 0, dy < 0 ? dy : 0);
    }

    // the window top left and bottom right corner are both visible now and
    // although the window might still be not entirely on screen (with 2
    // staggered displays for example) we wouldn't be able to improve the
    // layout much in such case, so we stop here

    // -1 could be valid coordinate here if there are several displays
    SetSize(rect, wxSIZE_ALLOW_MINUS_ONE);
}
示例#28
0
文件: parameter.cpp 项目: sqba/floopy
void CParameter::DrawFore(wxDC& dc, wxRect& rc)
{
	m_iSamplesPerPixel = m_pTracks->GetSamplesPerPixel();

	if(m_fMax == 0.f)
		return;

	m_fScale	= (float)rc.GetHeight() / (float)(m_fMax - m_fMin);
	int start	= m_pRegion->GetStartPos();
	int end		= m_pRegion->GetEndPos();
	int offset	= m_pRegion->GetStartOffset();
	int top		= rc.GetTop();
	int bottom	= rc.GetTop() + rc.GetHeight();
	int left	= rc.GetX() + 1;
	int right	= left + rc.GetWidth() - 1;
	float value = 0.f;
	int prevX	= left;
	int prevY	= bottom;
	int pos	= m_bAfterTrack ? 0 : start;
	bool bLoaded = false;

	bool bDrawCircle = true;

	if(!m_pInput->GetParamAt(pos, m_index, &value))
	{
		pos = m_pInput->GetPrevOffset(pos);
		bDrawCircle = false;
	}
	else
		bLoaded = true;

	wxPen oldpen = dc.GetPen();
	wxColor color = m_color;
	if( IsSelected() )
		color.Set(255-color.Red(), 255-color.Green(), 255-color.Blue());
	dc.SetPen( wxPen(color) );

	do {
		if(m_pInput->GetParamAt(pos, m_index, &value))
		{
			bLoaded = true;

			int x = pos;
			int y = (int)((float)bottom - (value * m_fScale));

			if(y>top && y<bottom)
			{
				if(m_bAfterTrack && offset>=0)
					x += start - offset;

				x /= m_iSamplesPerPixel;

				if(x <= left)
					prevX = left;
				else if(x >= right)
					y = prevY;
				else
				{
					dc.DrawLine(prevX, prevY, x, prevY);	// Horizontal line
					dc.DrawLine(x, prevY, x, y);			// Vertical line

					if( bDrawCircle )
					{
						if(m_pSelectedPoint &&
							m_pSelectedPoint->m_offset==pos &&
							m_pSelectedPoint->m_value==value)
						{
							dc.DrawRectangle(x-3, y-3, 6, 6);	// Selected parameter
						}
						else
							dc.DrawCircle(x, y, 3);				// Parameter
					}

					prevX = x;
				}

				bDrawCircle = true;

				prevY = y;
			}
		}
		pos = m_pInput->GetNextOffset(pos);
	} while ( pos>0 && pos<end && prevX<right );

	if(bLoaded && prevX<right) // there have been parameters!
		dc.DrawLine(prevX, prevY, right, prevY);

	dc.SetPen(oldpen);
}
示例#29
0
void wxSFGridShape::FitShapeToRect(wxSFShapeBase *shape, const wxRect& rct)
{
    wxRect shapeBB = shape->GetBoundingBox();
    wxRealPoint prevPos = shape->GetRelativePosition();

    // do vertical alignment
    switch( shape->GetVAlign() )
    {
        case valignTOP:
            shape->SetRelativePosition( prevPos.x, rct.GetTop() + shape->GetVBorder() );
            break;

        case valignMIDDLE:
            shape->SetRelativePosition( prevPos.x, rct.GetTop() + (rct.GetHeight()/2 - shapeBB.GetHeight()/2) );
            break;

        case valignBOTTOM:
            shape->SetRelativePosition( prevPos.x, rct.GetBottom() - shapeBB.GetHeight() - shape->GetVBorder() );
            break;

        case valignEXPAND:
            if( shape->ContainsStyle( sfsSIZE_CHANGE ) )
            {
                shape->SetRelativePosition( prevPos.x, rct.GetTop() + shape->GetVBorder() );
                shape->Scale( 1.f, double(rct.GetHeight() - 2*shape->GetVBorder())/shapeBB.GetHeight() );
            }
            break;

        default:
            shape->SetRelativePosition( prevPos.x, rct.GetTop() );
            break;
    }

    prevPos = shape->GetRelativePosition();

    // do horizontal alignment
    switch( shape->GetHAlign() )
    {
        case halignLEFT:
            shape->SetRelativePosition( rct.GetLeft() + shape->GetHBorder(), prevPos.y );
            break;

        case halignCENTER:
            shape->SetRelativePosition( rct.GetLeft() + (rct.GetWidth()/2 - shapeBB.GetWidth()/2), prevPos.y );
            break;

        case halignRIGHT:
            shape->SetRelativePosition( rct.GetRight() - shapeBB.GetWidth() - shape->GetHBorder(), prevPos.y );
            break;

        case halignEXPAND:
            if( shape->ContainsStyle( sfsSIZE_CHANGE ) )
            {
                shape->SetRelativePosition( rct.GetLeft() + shape->GetHBorder(), prevPos.y );
                shape->Scale( double(rct.GetWidth() - 2*shape->GetHBorder())/shapeBB.GetWidth(), 1.f );
            }
            break;

        default:
            shape->SetRelativePosition( rct.GetLeft(), prevPos.y );
            break;
    }
}
示例#30
0
void ImageButton::SetGrid(const wxRect& rect) {
  SetGrid(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight());
}