//--------------------------------------------------------- void CVIEW_ScatterPlot::_Draw_Frame(wxDC &dc, wxRect r) { //----------------------------------------------------- Draw_Edge(dc, EDGE_STYLE_SIMPLE, r); //------------------------------------------------- Draw_Scale(dc, wxRect(r.GetLeft(), r.GetBottom(), r.GetWidth(), 20), m_Trend.Get_Data_XMin(), m_Trend.Get_Data_XMax(), true , true , true ); Draw_Scale(dc, wxRect(r.GetLeft() - 20, r.GetTop(), 20, r.GetHeight()), m_Trend.Get_Data_YMin(), m_Trend.Get_Data_YMax(), false, false, false ); Draw_Text(dc, TEXTALIGN_BOTTOMCENTER, r.GetLeft() - 25, r.GetTop() + r.GetHeight() / 2, 90.0, m_sY.c_str() ); Draw_Text(dc, TEXTALIGN_TOPCENTER, r.GetLeft() + r.GetWidth() / 2, r.GetBottom() + 20, m_sX.c_str() ); //------------------------------------------------- if( m_Options("REG_SHOW")->asBool() ) { _Draw_Regression(dc, r); } }
void MyHtmlListBox::OnDrawSeparator(wxDC& dc, wxRect& rect, size_t) const { if ( ((MyFrame *)GetParent())-> GetMenuBar()->IsChecked(HtmlLbox_DrawSeparator) ) { dc.SetPen(*wxBLACK_DASHED_PEN); dc.DrawLine(rect.x, rect.y, rect.GetRight(), rect.y); dc.DrawLine(rect.x, rect.GetBottom(), rect.GetRight(), rect.GetBottom()); } }
void wxRibbonAUIArtProvider::DrawTabCtrlBackground( wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRect& rect) { wxRect gradient_rect(rect); gradient_rect.height--; dc.GradientFillLinear(gradient_rect, m_tab_ctrl_background_colour, m_tab_ctrl_background_gradient_colour, wxSOUTH); dc.SetPen(m_tab_border_pen); dc.DrawLine(rect.x, rect.GetBottom(), rect.GetRight()+1, rect.GetBottom()); }
void wxRibbonAUIArtProvider::DrawPageBackground( wxDC& dc, wxWindow* WXUNUSED(wnd), const wxRect& rect) { dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(m_background_brush); dc.DrawRectangle(rect.x + 1, rect.y, rect.width - 2, rect.height - 1); dc.SetPen(m_page_border_pen); dc.DrawLine(rect.x, rect.y, rect.x, rect.y + rect.height); dc.DrawLine(rect.GetRight(), rect.y, rect.GetRight(), rect.y +rect.height); dc.DrawLine(rect.x, rect.GetBottom(), rect.GetRight()+1, rect.GetBottom()); }
//--------------------------------------------------------- wxRect CVIEW_ScatterPlot::_Draw_Get_rDiagram(wxRect r) { return( wxRect( wxPoint(r.GetLeft () + 45, r.GetTop () + 20), wxPoint(r.GetRight() - 20, r.GetBottom() - 40) )); }
void wxWindowDFB::DoRefreshRect(const wxRect& rect) { wxWindow *parent = GetParent(); wxCHECK_RET( parent, "no parent" ); // don't overlap outside of the window (NB: 'rect' is in window coords): wxRect r(rect); r.Intersect(wxRect(GetSize())); if ( r.IsEmpty() ) return; wxLogTrace(TRACE_PAINT, "%p ('%s'): refresh rect [%i,%i,%i,%i]", this, GetName().c_str(), rect.x, rect.y, rect.GetRight(), rect.GetBottom()); // convert the refresh rectangle to parent's coordinates and // recursively refresh the parent: r.Offset(GetPosition()); r.Offset(parent->GetClientAreaOrigin()); // normal windows cannot extend out of its parent's client area, so don't // refresh any hidden parts: if ( !CanBeOutsideClientArea() ) r.Intersect(parent->GetClientRect()); parent->DoRefreshRect(r); }
void Stage::InvalidateRect(const wxRect &inRect) { wxLogTrace(TRACE_STAGE_DRAWING, wxT("Invalidating: %d %d %d %d"), inRect.x, inRect.y, inRect.GetRight(), inRect.GetBottom()); // We want to make sure that we never try to do any drawing off // the edges of the screen. Certain platforms, (like wxMac) get // very upset when you try to draw from or to rects that lie off // the screen. Since this is how all of the dirty regions enter // the system, we clip our dirty rect to the screen and make sure // we have something left before continuing. wxRect r(inRect.Intersect(wxRect(wxPoint(0, 0), GetSize()))); if (r.IsEmpty()) return; // It's a little bit inelegant to maintain two different dirty lists, // but they get cleared by different actions. mRectsToComposite.MergeRect(r); // Trigger screen repaint events--and update our manual refresh // list--but only if Quake 2 is not being displayed. (Quake 2 covers // the entire stage, and if we repaint the screen, it will flicker.) // The entire screen will automatically be refreshed when Quake 2 // is hidden. if (!GameEngineIsDisplayed()) { mRectsToRefresh.MergeRect(r); Refresh(FALSE, &r); } }
// // 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); }
/// 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; }
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()); }
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); }
int TGraphScale::GetRealCoord ( float f , wxRect &inner ) { float m2 = horizontal ? inner.width : inner.height ; // The pixel "width" float f2 = top - bottom ; // The internal "width" float ret = m2 * ( f - bottom ) / f2 ; if ( horizontal ) ret += (float ) inner.x ; else ret = (float) ( inner.GetBottom() ) - ret ; return (int) ret ; }
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); }
// Calculate the area that contains both rectangles static wxRect CombineRectangles(const wxRect& rect1, const wxRect& rect2) { wxRect rect; int right1 = rect1.GetRight(); int bottom1 = rect1.GetBottom(); int right2 = rect2.GetRight(); int bottom2 = rect2.GetBottom(); wxPoint topLeft = wxPoint(wxMin(rect1.x, rect2.x), wxMin(rect1.y, rect2.y)); wxPoint bottomRight = wxPoint(wxMax(right1, right2), wxMax(bottom1, bottom2)); rect.x = topLeft.x; rect.y = topLeft.y; rect.SetRight(bottomRight.x); rect.SetBottom(bottomRight.y); return rect; }
//--------------------------------------------------------- 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())); }
bool EditorPrintout::OnPrintPage(int pageNum) { wxASSERT(m_line && m_lineList); if (m_pages.empty()) return true; unsigned int page_ndx = pageNum-1; // page numbers start from one const unsigned int lastline = m_pages[page_ndx]; unsigned int line_id = page_ndx ? m_pages[page_ndx-1]+1 : 0; // Make page size scale with screen resolution MapScreenSizeToPage(); const wxRect rect = GetLogicalPageRect(); unsigned int ypos = rect.y; // We may have gotten a new dc, so we need a new line wxDC& dc = *GetDC(); const wxFont& font = m_theme.font; dc.SetFont(font); FixedLine line(dc, m_printDoc.GetDocument(), s_sel, s_brackets, s_lastpos, s_isShadow, m_theme); line.SetPrintMode(); line.Init(); line.SetWordWrap(cxWRAP_SMART); line.SetWidth(rect.width - m_gutter_width); // Draw gutter separator const unsigned int sep_xpos = m_gutter_width - 5; const unsigned int number_right = m_gutter_width - 8; dc.DrawLine(sep_xpos, rect.y, sep_xpos, rect.y + m_page_height); // Draw lines while (line_id <= lastline) { // Draw line number const wxString linenumber = wxString::Format(wxT("%u"), line_id+1); const wxSize ln_ext = dc.GetTextExtent(linenumber); dc.DrawText(linenumber, number_right - ln_ext.x, ypos); // Draw line line.SetLine(m_lineList->offset(line_id), m_lineList->end(line_id)); line.DrawLine(rect.x + m_gutter_width, ypos, rect, false); ypos += line.GetHeight(); ++line_id; } // Draw footer title ypos = rect.GetBottom() - m_line->GetCharHeight(); dc.DrawText(m_printDoc.GetName(), 0, ypos); // Draw footer pagenum const wxString pagefooter = wxString::Format(wxT("%d / %d"), pageNum, m_pages.size()); const wxSize extent = dc.GetTextExtent(pagefooter); dc.DrawText(pagefooter, rect.GetRight() - extent.x, ypos); return true; }
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())); }
//----------------------------------------------------------------------- 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; }
//--------------------------------------------------------- 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() ); }
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)); }
void TGraphScale::DrawMark ( wxDC &dc , float p , wxRect &ir , wxString text , bool big ) { int x , y , z ; if ( horizontal ) { x = GetRealCoord ( p , ir ) ; y = ir.y + ir.height / 2 ; z = big ? 0 : ir.height / 4 ; if ( x < ir.x || x > ir.GetRight() ) return ; } else { x = ir.x + ir.width / 2 ; y = GetRealCoord ( p , ir ) ; z = big ? 0 : ir.width / 4 ; if ( y < ir.y || y > ir.GetBottom() ) return ; } while ( text.Last() == '0' ) text = text.Left ( text.length() - 1 ) ; while ( text.Last() == '.' ) text = text.Left ( text.length() - 1 ) ; int tw , th ; dc.GetTextExtent ( text , &tw , &th ) ; if ( horizontal ) { if ( left ) dc.DrawLine ( x , y-z , x , ir.y ) ; else dc.DrawLine ( x , y+z , x , ir.GetBottom() ) ; x -= tw / 2 ; y = left ? ir.GetBottom() - th : ir.y ; } else { if ( left ) dc.DrawLine ( ir.x , y , x-z , y ) ; else dc.DrawLine ( x+z , y , ir.GetRight() , y ) ; y -= th / 2 ; x = left ? ir.GetRight() - tw : ir.x ; } if ( big ) dc.DrawText ( text , x , y ) ; }
void wxNonOwnedWindow::DoRefreshRect(const wxRect& rect) { // don't overlap outside of the window (NB: 'rect' is in window coords): wxRect r(rect); r.Intersect(wxRect(GetSize())); if ( r.IsEmpty() ) return; wxLogTrace(TRACE_PAINT, "%p ('%s'): [TLW] refresh rect [%i,%i,%i,%i]", this, GetName().c_str(), rect.x, rect.y, rect.GetRight(), rect.GetBottom()); // defer painting until idle time or until Update() is called: m_toPaint->Add(rect); }
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; } }
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; }
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; }
void DummyMaterialT::Draw(wxDC& dc, const wxRect& DestRect, int NameBoxHeight, bool DrawNameBox) const { // Start with drawing the name box. wxRect NameBoxRect=DestRect; NameBoxRect.y =DestRect.GetBottom()-NameBoxHeight; NameBoxRect.height=NameBoxHeight; dc.SetPen(*wxRED_PEN); dc.SetBrush(*wxRED_BRUSH); dc.DrawRectangle(NameBoxRect); dc.DrawText(m_Name, NameBoxRect.x+4, NameBoxRect.y+1); static wxBrush DummyBrush(wxColour(64, 64, 64), wxCROSSDIAG_HATCH); dc.SetPen(*wxBLACK_PEN); dc.SetBrush(DummyBrush); dc.DrawRectangle(DestRect.x, DestRect.y, DestRect.width, DestRect.height-NameBoxHeight); dc.DrawText("No Material!", DestRect.x+8, DestRect.y+6); }
void CView::Arrange(wxWindow* child, wxRect& clientRect, bool top) { if (child && child->IsShown()) { int const childHeight = child->GetSize().GetHeight(); wxRect childRect = clientRect; childRect.SetHeight(childHeight); if (!top) { childRect.SetTop(clientRect.GetBottom() - childHeight + 1); } else { clientRect.SetTop(childHeight); } clientRect.SetHeight(std::max(0, (clientRect.GetHeight() - childHeight))); child->SetSize(childRect); #ifdef __WXMSW__ child->Refresh(); #endif } }
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); }
void wxWindowDFB::PaintWindow(const wxRect& rect) { wxCHECK_RET( !IsFrozen() && IsShown(), "shouldn't be called" ); wxLogTrace(TRACE_PAINT, "%p ('%s'): painting region [%i,%i,%i,%i]", this, GetName().c_str(), rect.x, rect.y, rect.GetRight(), rect.GetBottom()); m_updateRegion = rect; // FIXME_DFB: don't waste time rendering the area if it's fully covered // by some children, go directly to rendering the children // (unless some child has HasTransparentBackground()=true!) // NB: unconditionally send wxEraseEvent, because our implementation of // wxWindow::Refresh() ignores the eraseBack argument wxWindowDC dc((wxWindow*)this); wxEraseEvent eventEr(m_windowId, &dc); eventEr.SetEventObject(this); HandleWindowEvent(eventEr); wxRect clientRect(GetClientRect()); // only send wxNcPaintEvent if drawing at least part of nonclient area: if ( !clientRect.Contains(rect) ) { wxNcPaintEvent eventNc(GetId()); eventNc.SetEventObject(this); HandleWindowEvent(eventNc); } else { wxLogTrace(TRACE_PAINT, "%p ('%s'): not sending wxNcPaintEvent", this, GetName().c_str()); } // only send wxPaintEvent if drawing at least part of client area: if ( rect.Intersects(clientRect) ) { wxPaintEvent eventPt(GetId()); eventPt.SetEventObject(this); HandleWindowEvent(eventPt); } else { wxLogTrace(TRACE_PAINT, "%p ('%s'): not sending wxPaintEvent", this, GetName().c_str()); } // draw window's overlays on top of the painted window, if we have any: PaintOverlays(rect); m_updateRegion.Clear(); // client area portion of 'rect': wxRect rectClientOnly(rect); rectClientOnly.Intersect(clientRect); // paint the children: wxPoint origin = GetClientAreaOrigin(); wxWindowList& children = GetChildren(); for ( wxWindowList::iterator i = children.begin(); i != children.end(); ++i ) { wxWindow *child = *i; if ( child->IsFrozen() || !child->IsShown() ) continue; // don't paint anything if the window is frozen or hidden // compute child's area to repaint wxRect childrect(child->GetRect()); childrect.Offset(origin); if ( child->CanBeOutsideClientArea() ) childrect.Intersect(rect); else childrect.Intersect(rectClientOnly); if ( childrect.IsEmpty() ) continue; // and repaint it: childrect.Offset(-child->GetPosition()); childrect.Offset(-origin); child->PaintWindow(childrect); } }
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); }