void ChessboardFrame::drawBomb(void) { wxPaintDC dc(drawPane); int k = GetVirtualSize().GetWidth()/2 - myCB->getNumCells()/2*CELL_WIDTH; int k1 = GetVirtualSize().GetHeight()/2 - myCB->getNumCells()/2*CELL_HEIGHT; Cell* bombCell = myCB->getBombCell(); dc.SetPen( wxPen( wxColor(255,0,0), 4 ) ); dc.SetBrush( *wxTRANSPARENT_BRUSH ); dc.DrawCircle( wxPoint( bombCell->getX() * CELL_WIDTH+CELL_WIDTH/2+k, bombCell->getY() * CELL_HEIGHT+CELL_HEIGHT/2+k1 ), CELL_WIDTH/3 ); }
void CDEditor::DrawGrid( CDC* dc, CRect /*rect*/, double zoom ) const { COLORREF gridcol = GetGridColor(); dc->SelectStockObject( BLACK_PEN ); int stepx = GetVirtualSize().cx / GetGridSize().cx; int stepy = GetVirtualSize().cy / GetGridSize().cy; for( int x = 0 ; x <= stepx ; x++ ) for( int y = 0; y <= stepy ; y++ ) dc->SetPixel( round( ( double ) ( GetGridSize().cx * x ) * zoom ), round( ( double ) ( GetGridSize().cy * y ) * zoom ), gridcol ); }
void ExplainCanvas::SaveAsImage(const wxString &fileName, wxBitmapType imageType) { if (GetDiagram()->GetCount() == 0) { wxMessageBox(_("Nothing to be saved!"), _("Save As an image"), wxOK | wxICON_INFORMATION); return; } int width = 0, height = 0; GetVirtualSize(&width, &height); /* * Create the bitmap from the Explain window */ wxMemoryDC memDC; wxBitmap tempBitmap(width, height); memDC.SelectObject(tempBitmap); memDC.Clear(); // Draw the diagram on the bitmap (Memory Device Context) GetDiagram()->Redraw(memDC); memDC.SelectObject(wxNullBitmap); if (!tempBitmap.SaveFile(fileName, imageType)) { wxLogError(_("Could not write file \"%s\": error code %d."), fileName.c_str(), wxSysErrorCode()); } }
hsa_status_t MemoryRegion::AssignAgent(void* ptr, size_t size, const core::Agent& agent, hsa_access_permission_t access) const { if (fine_grain()) { return HSA_STATUS_SUCCESS; } if (std::find(agent.regions().begin(), agent.regions().end(), this) == agent.regions().end()) { return HSA_STATUS_ERROR_INVALID_AGENT; } if (IsLocalMemory()) { HSAuint64 u_ptr = reinterpret_cast<HSAuint64>(ptr); if (u_ptr >= GetBaseAddress() && u_ptr < (GetBaseAddress() + GetVirtualSize())) { // TODO: only support agent allocation buffer. // TODO: commented until API to explicitly unpin memory is available. // if (!MakeKfdMemoryResident(ptr, size)) { // return HSA_STATUS_ERROR_OUT_OF_RESOURCES; //} return HSA_STATUS_SUCCESS; } else { return HSA_STATUS_ERROR_OUT_OF_RESOURCES; } } return HSA_STATUS_SUCCESS; }
bool CDEditor::AdjustRect(CRect& rect) { CRect rcOld=rect; CPoint point = rect.TopLeft(); CSize size = rect.Size(); CSize sizeVt = GetVirtualSize(); int restraint = GetRestraints(); if (RESTRAINT_NONE != restraint) { int left=0,top=0,right=sizeVt.cx,bottom=sizeVt.cy; // m_restraint == RESTRAINT_VIRTUAL if (restraint == RESTRAINT_MARGIN) { GetMargins(left,top,right,bottom); right = sizeVt.cx - right; bottom = sizeVt.cy - bottom; } point.x = min(max(left,point.x),right-size.cx); point.y = min(max(top,point.y),bottom-size.cy); } if (GetSnapToGrid()) { point.x = SnapX(point.x); point.y = SnapY(point.y); } rect.SetRect(point,point+size); return rcOld==rect; }
void InstanceCtrl::EnsureRectVisible ( wxRect rect ) { int ppuX, ppuY; GetScrollPixelsPerUnit(& ppuX, & ppuY); if (ppuY == 0) return; int startX, startY; GetViewStart(& startX, & startY); startX = 0; startY = startY * ppuY; int sx, sy; GetVirtualSize(& sx, & sy); sx = 0; if (ppuY != 0) sy = sy / ppuY; wxSize clientSize = GetClientSize(); if ((rect.y + rect.height) > (clientSize.y + startY)) { // Make it scroll so this item is at the bottom // of the window int y = rect.y - (clientSize.y - rect.height - m_spacing) ; SetScrollbars(ppuX, ppuY, sx, sy, 0, (int)(0.5 + y / ppuY)); } else if (rect.y < startY) { // Make it scroll so this item is at the top // of the window int y = rect.y ; SetScrollbars(ppuX, ppuY, sx, sy, 0, (int)(0.5 + y / ppuY)); } }
hdMultiPosRect hdDrawingView::getVirtualSize() { int w, h; GetVirtualSize(&w, &h); hdMultiPosRect virtualSize(0, 0, w, h); return virtualSize; }
void gqbView::SaveAsImage(const wxString &fileName, wxBitmapType imgType) { updateModelSize(NULL, true); if (modelSize.GetWidth() == 0 || modelSize.GetHeight() == 0) { wxMessageBox(_("Nothing to be saved!"), _("Save As an image"), wxOK | wxICON_INFORMATION); return; } int width = 0, height = 0; GetVirtualSize(&width, &height); /* * Create the bitmap from the Explain window */ wxMemoryDC memDC; wxBitmap tempBitmap(width, height); memDC.SelectObject(tempBitmap); memDC.Clear(); // Draw the diagram on the bitmap (Memory Device Context) drawAll(memDC, false); memDC.SelectObject(wxNullBitmap); if (!tempBitmap.SaveFile(fileName, imgType)) { wxLogError(_("Could not write the file %s: Errcode=%d."), fileName.c_str(), wxSysErrorCode()); } }
/***************************************************** ** ** SheetWidget --- init ** ******************************************************/ void SheetWidget::init() { assert( sheet ); //sheet->clear(); wxSize widgetsize = GetVirtualSize(); wxSize clientsize = GetSize(); writer->pageSize = MPoint( clientsize.x, clientsize.y ); //printf( "CLIENT %d %d\n", clientsize.x, clientsize.y ); xviewport = widgetsize.x;// - sb_ysize; yviewport = widgetsize.y;// - sb_xsize; //assert( sheetcfg ); // TODO das kann man sicherlich an den Writer delegieren writer->contentRect.x = SCROLLABLE_PAGE_WIDGET_PAGE_BORDER_X; writer->contentRect.y = SCROLLABLE_PAGE_WIDGET_PAGE_BORDER_Y; writer->contentRect.width = 0; writer->contentRect.height = 0; dirty = true; lastMarkedItem = (SheetItem*)NULL; }
void BrushIconBox::EnsureVisible(BrushButton* btn) { int windowSizeX, windowSizeY; GetVirtualSize(&windowSizeX, &windowSizeY); int scrollUnitX; int scrollUnitY; GetScrollPixelsPerUnit(&scrollUnitX, &scrollUnitY); wxRect rect = btn->GetRect(); int y; CalcUnscrolledPosition(0, rect.y, nullptr, &y); int maxScrollPos = windowSizeY / scrollUnitY; int scrollPosY = std::min(maxScrollPos, (y / scrollUnitY)); int startScrollPosY; GetViewStart(nullptr, &startScrollPosY); int clientSizeX, clientSizeY; GetClientSize(&clientSizeX, &clientSizeY); int endScrollPosY = startScrollPosY + clientSizeY / scrollUnitY; if(scrollPosY < startScrollPosY || scrollPosY > endScrollPosY){ //only scroll if the button isnt visible Scroll(-1, scrollPosY); } }
wxlCan::wxlCan( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ): wxScrolledWindow( parent, id, pos, size, style ) { m_luastate = NULL; int w,h; GetVirtualSize( &w, &h ); m_buffer = wxBitmap( size.GetWidth(), size.GetHeight() ); m_pendingObjects = false; //set one to one mapping as default m_xpp = 1; m_ypp = 1; m_virt_minX = 0; m_virt_minY = 0; m_transx = 0; m_transy = 0; m_scalex = 1; m_scaley = 1; m_rootobject.SetCanvas( this ); m_hit = NULL; m_cmdh = new wxlLuaCanCmd( this ); }
void VisualEditor::UpdateVirtualSize() { int w, h, panelW, panelH; GetVirtualSize(&w, &h); m_back->GetSize(&panelW, &panelH); panelW += 20; panelH += 20; if (panelW != w || panelH != h) SetVirtualSize(panelW, panelH); }
void ChessboardFrame::paintNIGGER(void) { wxPaintDC dc(drawPane); dc.SetPen( wxPen( wxColor(0,0,0), 1 ) ); int k = GetVirtualSize().GetWidth()/2 - myCB->getNumCells()/2*CELL_WIDTH; int k1 = GetVirtualSize().GetHeight()/2 - myCB->getNumCells()/2*CELL_HEIGHT; ButtonSetBomb->SetPosition( wxPoint(GetVirtualSize().GetWidth()/2 + myCB->getNumCells()/2*CELL_WIDTH + CELL_WIDTH*2, GetVirtualSize().GetHeight()/2 - myCB->getNumCells()/2*CELL_HEIGHT) ); ButtonShowBomb->SetPosition( wxPoint(GetVirtualSize().GetWidth()/2 + myCB->getNumCells()/2*CELL_WIDTH + CELL_WIDTH*2, GetVirtualSize().GetHeight()/2 - myCB->getNumCells()/2*CELL_HEIGHT+30) ); ButtonHideBomb->SetPosition( wxPoint(GetVirtualSize().GetWidth()/2 + myCB->getNumCells()/2*CELL_WIDTH + CELL_WIDTH*2, GetVirtualSize().GetHeight()/2 - myCB->getNumCells()/2*CELL_HEIGHT+60) ); ButtonChangeColors->SetPosition( wxPoint(GetVirtualSize().GetWidth()/2 + myCB->getNumCells()/2*CELL_WIDTH + CELL_WIDTH*2, GetVirtualSize().GetHeight()/2 - myCB->getNumCells()/2*CELL_HEIGHT+90 ) ); ButtonTimer->SetPosition( wxPoint(GetVirtualSize().GetWidth()/2 + myCB->getNumCells()/2*CELL_WIDTH + CELL_WIDTH*2, GetVirtualSize().GetHeight()/2 - myCB->getNumCells()/2*CELL_HEIGHT+120 ) ); ButtonSetBomb->Show(); ButtonShowBomb->Show(); ButtonHideBomb->Show(); ButtonChangeColors->Show(); ButtonTimer->Show(); Colors color; for (unsigned int i = 0; i < myCB->getNumCells(); i++) { for (unsigned int j = 0; j < myCB->getNumCells(); j++) { color = myCB->getCellColor(i,j); dc.SetBrush( *getBrushColor(color) ); dc.DrawRectangle(i*CELL_WIDTH+k, j*CELL_HEIGHT+k1, CELL_WIDTH, CELL_HEIGHT); if(!myCB->isBombHidden()) { drawBomb(); } } } }
MemoryRegion::MemoryRegion(bool fine_grain, const core::Agent& owner, const HsaMemoryProperties& mem_props) : core::MemoryRegion(fine_grain), owner_(&owner), mem_props_(mem_props), max_single_alloc_size_(0), virtual_size_(0) { virtual_size_ = GetPhysicalSize(); mem_flag_.Value = 0; if (IsLocalMemory()) { mem_flag_.ui32.PageSize = HSA_PAGE_SIZE_4KB; mem_flag_.ui32.NoSubstitute = 1; mem_flag_.ui32.HostAccess = 0; mem_flag_.ui32.NonPaged = 1; char* char_end = NULL; HSAuint64 max_alloc_size = static_cast<HSAuint64>(strtoull( os::GetEnvVar("HSA_LOCAL_MEMORY_MAX_ALLOC").c_str(), &char_end, 10)); max_alloc_size = std::max(max_alloc_size, GetPhysicalSize() / 4); max_alloc_size = std::min(max_alloc_size, GetPhysicalSize()); max_single_alloc_size_ = AlignDown(static_cast<size_t>(max_alloc_size), kPageSize_); static const HSAuint64 kGpuVmSize = (1ULL << 40); virtual_size_ = kGpuVmSize; } else if (IsSystem()) { mem_flag_.ui32.PageSize = HSA_PAGE_SIZE_4KB; mem_flag_.ui32.NoSubstitute = 1; mem_flag_.ui32.HostAccess = 1; mem_flag_.ui32.CachePolicy = HSA_CACHING_CACHED; max_single_alloc_size_ = AlignDown(static_cast<size_t>(GetPhysicalSize()), kPageSize_); virtual_size_ = os::GetUserModeVirtualMemorySize(); } assert(GetVirtualSize() != 0); assert(GetPhysicalSize() <= GetVirtualSize()); assert(IsMultipleOf(max_single_alloc_size_, kPageSize_)); }
void CDiagramEntityContainer::Snapshot() /* ============================================================ Function : CDiagramEntityContainer::Snapshot Description : Copies the current state of the data to the undo-stack. Return : void Parameters : none Usage : Call to add the current state to the undo-stack. If the undo stack has a maximum size and the stack will grow above the stack limit, the first undo array will be removed. ============================================================*/ { if( m_maxstacksize > 0 && m_undo.GetSize() == m_maxstacksize ) { delete m_undo.GetAt( 0 ); m_undo.RemoveAt( 0 ); } CUndoItem* undo = new CUndoItem; while( !undo && m_undo.GetSize() ) { // We seem - however unlikely - // to be out of memory. // Remove first element in // undo-stack and try again delete m_undo.GetAt( 0 ); m_undo.RemoveAt( 0 ); undo = new CUndoItem; } if( undo ) { // Save current virtual size *( undo->pt ) = GetVirtualSize(); // Save all objects int count = m_objs.GetSize(); for( int t = 0 ; t < count ; t++ ) ( undo->arr )->Add( GetAt( t )->Clone() ); // Add to undo stack m_undo.Add( undo ); } }
void FancyTextPanel::OnPaint(wxPaintEvent& event) { wxPaintDC dc(this); PrepareDC(dc); wxSize virtSize = GetVirtualSize(); dc.Clear(); dc.DrawRectangle(wxRect(wxPoint(0, 0), virtSize)); DrawCont(dc, m_print_continuity, wxRect(wxPoint(0, 0), virtSize), m_landscape); }
CString CDiagramEntityContainer::GetString() const /* ============================================================ Function : CDiagramEntityContainer::GetString Description : Returns a string representation of the virtual paper size Return : CString - Resulting string Parameters : none Usage : Call to get a string representing the paper size of the container. The format is "paper:[x],[y];" where [x] and [y] are the horisintal and vertical sizes. ============================================================*/ { CString str; str.Format( _T( "paper:%i,%i;" ), GetVirtualSize().cx, GetVirtualSize().cy ); return str; }
/***************************************************** ** ** SheetWidget --- initViewPort ** ******************************************************/ void SheetWidget::initViewPort() { wxSize oldViewport = GetVirtualSize(); xviewport = writer->xSizeContents + 2 * SCROLLABLE_PAGE_WIDGET_PAGE_BORDER_X; yviewport = writer->ycursor + 2 * SCROLLABLE_PAGE_WIDGET_PAGE_BORDER_Y; if ( xviewport != oldViewport.x || yviewport != oldViewport.y ) { //printf( "SET VIEWPORT %d ---- %d\n", xviewport, yviewport ); SetVirtualSize( xviewport, yviewport ); } }
void EDA_DRAW_PANEL::OnPan( wxCommandEvent& event ) { int x, y; int ppux, ppuy; int unitsX, unitsY; int maxX, maxY; GetViewStart( &x, &y ); GetScrollPixelsPerUnit( &ppux, &ppuy ); GetVirtualSize( &unitsX, &unitsY ); maxX = unitsX; maxY = unitsY; unitsX /= ppux; unitsY /= ppuy; switch( event.GetId() ) { case ID_PAN_UP: y -= m_scrollIncrementY; break; case ID_PAN_DOWN: y += m_scrollIncrementY; break; case ID_PAN_LEFT: x -= m_scrollIncrementX; break; case ID_PAN_RIGHT: x += m_scrollIncrementX; break; default: wxLogDebug( wxT( "Unknown ID %d in EDA_DRAW_PANEL::OnPan()." ), event.GetId() ); } if( x < 0 ) x = 0; if( y < 0 ) y = 0; if( x > maxX ) x = maxX; if( y > maxY ) y = maxY; Scroll( x/ppux, y/ppuy ); }
/***************************************************** ** ** SheetWidget --- HandleMouseWheelEvent ** ******************************************************/ void SheetWidget::HandleMouseWheelEvent( wxMouseEvent &event ) { const bool modpressed = event.m_controlDown; const bool shiftpressed = event.m_shiftDown; //printf( "SheetWidget::HandleMouseWheelEvent rotation is %d modpressed %d shiftpressed %d\n", event.GetWheelRotation(), modpressed, shiftpressed ); if ( modpressed || shiftpressed ) { event.ResumePropagation( wxEVENT_PROPAGATE_MAX ); event.Skip(); } else { int x, y, x0, y0, xs, ys; const int offset = 60; GetViewStart( &x, &y ); // scroll position GetSize( &xs, &ys ); // size of visible widget only GetVirtualSize( &x0, &y0 ); // complete size of widget //printf( "SheetWidget::HandleMouseWheelEvent x %d y %d xs %d ys %d x0 %d y0 %d\n", x, y, xs, ys, x0, y0 ); // Wheel scolls in vertical direction, but horizontal if nothing left to scroll if ( event.GetWheelRotation() < 0 ) { if ( y + ys >= y0 ) x = Min( x0, x + offset ); else { y += offset; mousePosition.y += offset; } } else { if ( y > 0 ) { y = Max ( 0, y - offset ); if ( mousePosition.y > offset ) mousePosition.y -= offset; else mousePosition.y = 0; } else x -= offset; } Scroll( x, y ); // marked cols (if any) must move, too mouseHasMoved( false ); } }
void wxlCan::Render( wxDC& dc ) { int w,h; GetVirtualSize( &w, &h ); dc.SetBackground( GetBackgroundColour() ); dc.Clear(); dc.SetBrush(m_backbrush); dc.SetPen( *wxTRANSPARENT_PEN ); dc.DrawRectangle( 0, 0, w, h ); //draw objects m_rootobject.Draw( dc, 0, 0 ); }
bool wxScrolledWindow::Layout() { if (GetSizer() && m_targetWindow == this) { // If we're the scroll target, take into account the // virtual size and scrolled position of the window. int x, y, w, h; CalcScrolledPosition(0,0, &x,&y); GetVirtualSize(&w, &h); GetSizer()->SetDimension(x, y, w, h); return TRUE; } else return wxPanel::Layout(); // fall back to default for LayoutConstraints }
void wxlCan::OnSize(wxSizeEvent& WXUNUSED(event) ) { int dx,dy; GetClientSize(&dx,&dy); int w,h; GetVirtualSize( &w, &h ); if ( w < dx ) w = dx; if ( h < dy ) h = dy; m_buffer = wxBitmap( w, h ); m_pendingObjects = true; }
void wxsDrawingWindow::AfterContentChanged() { if ( !--m_DuringChangeCnt ) { m_WasContentChanged = true; wxSize Size = GetVirtualSize(); // Generating new bitmap delete m_Bitmap; m_Bitmap = new wxBitmap(Size.GetWidth(),Size.GetHeight()); // Resizing panel to cover whole window int X, Y; CalcScrolledPosition(0,0,&X,&Y); StartFetchingSequence(); } }
void wxsToolSpace::OnPaint(wxPaintEvent& event) { wxPaintDC DC(this); if ( m_Unstable ) return; DoPrepareDC(DC); wxSize VirtualSize = GetVirtualSize(); DC.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); DC.SetPen(*wxBLACK); DC.DrawRectangle(0,0,VirtualSize.GetWidth(),VirtualSize.GetHeight()); int i = 0; for ( Entry* Tool = m_First; Tool; Tool = Tool->m_Next, i++ ) { wxsTool* Item = Tool->m_Tool; int BeginX = i*(ExtraBorderSize+IconSize) + ExtraBorderSize; int BeginY = ExtraBorderSize; int EndX = BeginX + IconSize; int EndY = BeginY + IconSize; DC.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); DC.DrawRectangle(BeginX-1,BeginY-1,EndX-BeginX+2,EndY-BeginY+2); DC.DrawBitmap(Item->GetInfo().Icon32,BeginX,BeginY,true); if ( Item->GetIsSelected() ) { // Drawing fout drag boxes if ( m_Data->GetRootSelection() != Item ) { DC.SetPen(*wxGREY_PEN); DC.SetBrush(*wxGREY_BRUSH); } else { DC.SetPen(*wxBLACK_PEN); DC.SetBrush(*wxBLACK_BRUSH); } DC.DrawRectangle(BeginX-DragBoxSize/2,BeginY-DragBoxSize/2,DragBoxSize,DragBoxSize); DC.DrawRectangle(BeginX-DragBoxSize/2,EndY-DragBoxSize/2,DragBoxSize,DragBoxSize); DC.DrawRectangle(EndX-DragBoxSize/2,BeginY-DragBoxSize/2,DragBoxSize,DragBoxSize); DC.DrawRectangle(EndX-DragBoxSize/2,EndY-DragBoxSize/2,DragBoxSize,DragBoxSize); } } }
void SetViewSize(int viewWidth, int viewHeight) { wxRect oldImageRect = GetImageRect(); m_viewSize = wxSize(viewWidth, viewHeight); wxSize zoomedSize((int)(viewWidth * m_zoomFactor), (int)(viewHeight * m_zoomFactor)); wxSize virtualSize = GetVirtualSize(); if (virtualSize.x != zoomedSize.GetWidth() + 10 || virtualSize.y != zoomedSize.GetHeight() + 10) { SetVirtualSize(zoomedSize.GetWidth() + 10, zoomedSize.GetHeight() + 10); } wxRect imageRect = GetImageRect(); imageRect = imageRect.Union(oldImageRect); Refresh(false, &imageRect); }
bool wxVScrolledWindow::Layout() { if ( GetSizer() ) { // adjust the sizer dimensions/position taking into account the // virtual size and scrolled position of the window. int w = 0, h = 0; GetVirtualSize(&w, &h); // x is always 0 so no variable needed int y = -GetLinesHeight(0, GetFirstVisibleLine()); GetSizer()->SetDimension(0, y, w, h); return true; } // fall back to default for LayoutConstraints return wxPanel::Layout(); }
// kbd handling: notice that we use OnChar() and not OnKeyDown() for // compatibility here - if we used OnKeyDown(), the programs which process // arrows themselves in their OnChar() would never get the message and like // this they always have the priority void wxScrolledWindow::OnChar(wxKeyEvent& event) { int stx, sty, // view origin szx, szy, // view size (total) clix, cliy; // view size (on screen) GetViewStart(&stx, &sty); GetClientSize(&clix, &cliy); GetVirtualSize(&szx, &szy); if( m_xScrollPixelsPerLine ) { clix /= m_xScrollPixelsPerLine; szx /= m_xScrollPixelsPerLine; } else { clix = 0; szx = -1; } if( m_yScrollPixelsPerLine ) { cliy /= m_yScrollPixelsPerLine; szy /= m_yScrollPixelsPerLine; } else { cliy = 0; szy = -1; } int xScrollOld = GetScrollPos(wxHORIZONTAL), yScrollOld = GetScrollPos(wxVERTICAL); int dsty; switch ( event.GetKeyCode() ) { case WXK_PAGEUP: case WXK_PRIOR: dsty = sty - (5 * cliy / 6); Scroll(-1, (dsty == -1) ? 0 : dsty); break; case WXK_PAGEDOWN: case WXK_NEXT: Scroll(-1, sty + (5 * cliy / 6)); break; case WXK_HOME: Scroll(0, event.ControlDown() ? 0 : -1); break; case WXK_END: Scroll(szx - clix, event.ControlDown() ? szy - cliy : -1); break; case WXK_UP: Scroll(-1, sty - 1); break; case WXK_DOWN: Scroll(-1, sty + 1); break; case WXK_LEFT: Scroll(stx - 1, -1); break; case WXK_RIGHT: Scroll(stx + 1, -1); break; default: // not for us event.Skip(); return; } int xScroll = GetScrollPos(wxHORIZONTAL); if ( xScroll != xScrollOld ) { wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBTRACK, xScroll, wxHORIZONTAL); event.SetEventObject(this); GetEventHandler()->ProcessEvent(event); } int yScroll = GetScrollPos(wxVERTICAL); if ( yScroll != yScrollOld ) { wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBTRACK, yScroll, wxVERTICAL); event.SetEventObject(this); GetEventHandler()->ProcessEvent(event); } }
void EDA_DRAW_PANEL::OnPan( wxCommandEvent& event ) { int x, y; int ppux, ppuy; int unitsX, unitsY; int maxX, maxY; int tmpX, tmpY; GetViewStart( &x, &y ); GetScrollPixelsPerUnit( &ppux, &ppuy ); GetVirtualSize( &unitsX, &unitsY ); tmpX = x; tmpY = y; maxX = unitsX; maxY = unitsY; unitsX /= ppux; unitsY /= ppuy; wxLogTrace( kicadTraceCoords, wxT( "Scroll center position before pan: (%d, %d)" ), tmpX, tmpY ); switch( event.GetId() ) { case ID_PAN_UP: y -= m_scrollIncrementY; break; case ID_PAN_DOWN: y += m_scrollIncrementY; break; case ID_PAN_LEFT: x -= m_scrollIncrementX; break; case ID_PAN_RIGHT: x += m_scrollIncrementX; break; default: wxLogDebug( wxT( "Unknown ID %d in EDA_DRAW_PANEL::OnPan()." ), event.GetId() ); } bool updateCenterScrollPos = true; if( x < 0 ) { x = 0; updateCenterScrollPos = false; } if( y < 0 ) { y = 0; updateCenterScrollPos = false; } if( x > maxX ) { x = maxX; updateCenterScrollPos = false; } if( y > maxY ) { y = maxY; updateCenterScrollPos = false; } // Don't update the scroll position beyond the scroll limits. if( updateCenterScrollPos ) { double scale = GetParent()->GetScreen()->GetScalingFactor(); wxPoint center = GetParent()->GetScrollCenterPosition(); center.x += KiROUND( (double) ( x - tmpX ) / scale ); center.y += KiROUND( (double) ( y - tmpY ) / scale ); GetParent()->SetScrollCenterPosition( center ); wxLogTrace( kicadTraceCoords, wxT( "Scroll center position after pan: (%d, %d)" ), center.x, center.y ); } Scroll( x/ppux, y/ppuy ); }
void EDA_DRAW_PANEL::OnScroll( wxScrollWinEvent& event ) { int id = event.GetEventType(); int x, y; int ppux, ppuy; int csizeX, csizeY; int unitsX, unitsY; GetViewStart( &x, &y ); GetScrollPixelsPerUnit( &ppux, &ppuy ); GetClientSize( &csizeX, &csizeY ); GetVirtualSize( &unitsX, &unitsY ); int tmpX = x; int tmpY = y; csizeX /= ppux; csizeY /= ppuy; unitsX /= ppux; unitsY /= ppuy; int dir = event.GetOrientation(); // wxHORIZONTAL or wxVERTICAL // On windows and on wxWidgets >= 2.9.5 and < 3.1, // there is a bug in mousewheel event which always generates 2 scroll events // (should be the case only for the default mousewheel event) // with id = wxEVT_SCROLLWIN_LINEUP or wxEVT_SCROLLWIN_LINEDOWN // so we skip these events. // Note they are here just in case, because they are not actually used // in Kicad #if wxCHECK_VERSION( 3, 1, 0 ) || !wxCHECK_VERSION( 2, 9, 5 ) || ( !defined (__WINDOWS__) && !defined (__WXMAC__) ) int maxX = unitsX - csizeX; int maxY = unitsY - csizeY; if( id == wxEVT_SCROLLWIN_LINEUP ) { if( dir == wxHORIZONTAL ) { x -= m_scrollIncrementX; if( x < 0 ) x = 0; } else { y -= m_scrollIncrementY; if( y < 0 ) y = 0; } } else if( id == wxEVT_SCROLLWIN_LINEDOWN ) { if( dir == wxHORIZONTAL ) { x += m_scrollIncrementX; if( x > maxX ) x = maxX; } else { y += m_scrollIncrementY; if( y > maxY ) y = maxY; } } else #endif if( id == wxEVT_SCROLLWIN_THUMBTRACK ) { if( dir == wxHORIZONTAL ) x = event.GetPosition(); else y = event.GetPosition(); } else { event.Skip(); return; } wxLogTrace( kicadTraceCoords, wxT( "Setting scroll bars ppuX=%d, ppuY=%d, unitsX=%d, unitsY=%d, posX=%d, posY=%d" ), ppux, ppuy, unitsX, unitsY, x, y ); double scale = GetParent()->GetScreen()->GetScalingFactor(); wxPoint center = GetParent()->GetScrollCenterPosition(); center.x += KiROUND( (double) ( x - tmpX ) / scale ); center.y += KiROUND( (double) ( y - tmpY ) / scale ); GetParent()->SetScrollCenterPosition( center ); Scroll( x, y ); event.Skip(); }