void SpectDisplay::OnDraw(wxDC& dc) {//================================ wxRegion region; dc.SetUserScale(zoomx,zoomy); int f1 = 0x7fffffff, f2 = -1; int x1,x2,y1,y2; int vX,vY,vW,vH; // Dimensions of client area in pixels wxRegionIterator upd(GetUpdateRegion()); // get the update rect list while (upd) { vX = upd.GetX(); vY = upd.GetY(); vW = upd.GetW(); vH = upd.GetH(); CalcUnscrolledPosition(vX,vY,&x1,&y1); CalcUnscrolledPosition(vX+vW,vY+vH,&x2,&y2); // Repaint this rectangle if(y1 < f1) f1 = int(y1/zoomy); if(y2 > f2) f2 = int(y2/zoomy); upd ++ ; } if(spectseq != NULL) spectseq->Draw(dc,f1,f2); }
void FieldBrowser::OnUpdate() { auto size_of_one = SizeOfOneCell(); SetVirtualSize(size_of_one.x, size_of_one.y * mDoc->GetNumSheets()); SetScrollRate(0, size_of_one.y / 5); auto get_size = GetSize(); auto scrolled_top = CalcUnscrolledPosition({ 0, 0 }); auto scrolled_bottom = CalcUnscrolledPosition({ 0, get_size.y }); // figure out what the view of cells would be. // let's print out where the current cell would be. // // if the upper part is above the view, move the view to contain it. if (size_of_one.y * mDoc->GetCurrentSheetNum() < scrolled_top.y) { Scroll(0, size_of_one.y * mDoc->GetCurrentSheetNum()); } // if the lower part is below the view, move the view to contain it. if ((size_of_one.y * (mDoc->GetCurrentSheetNum() + 1)) > scrolled_bottom.y) { // we want to move to a place where the top amount we are over is the current top. auto how_much_we_are_over = (size_of_one.y * (mDoc->GetCurrentSheetNum() + 1)) - scrolled_bottom.y; Scroll(0, scrolled_top.y + how_much_we_are_over); } }
void wxListBox::DoDraw(wxControlRenderer *renderer) { // adjust the DC to account for scrolling wxDC& dc = renderer->GetDC(); PrepareDC(dc); dc.SetFont(GetFont()); // get the update rect wxRect rectUpdate = GetUpdateClientRect(); int yTop, yBottom; CalcUnscrolledPosition(0, rectUpdate.GetTop(), NULL, &yTop); CalcUnscrolledPosition(0, rectUpdate.GetBottom(), NULL, &yBottom); // get the items which must be redrawn wxCoord lineHeight = GetLineHeight(); size_t itemFirst = yTop / lineHeight, itemLast = (yBottom + lineHeight - 1) / lineHeight, itemMax = m_strings->GetCount(); if ( itemFirst >= itemMax ) return; if ( itemLast > itemMax ) itemLast = itemMax; // do draw them wxLogTrace(_T("listbox"), _T("Repainting items %d..%d"), itemFirst, itemLast); DoDrawRange(renderer, itemFirst, itemLast); }
void CTreeCanvas::Render(bool just_for_calculation) { render_just_for_calculation = just_for_calculation; if(!just_for_calculation) { #ifdef WIN32 // draw a white background rectangle int w, h; GetClientSize(&w, &h); wxPoint pTopLeft = CalcUnscrolledPosition(wxPoint(0, 0)); wxPoint pBottomRight = CalcUnscrolledPosition(wxPoint(w, h)); m_dc->SetBrush(wxBrush(wxT("white"))); m_dc->SetPen(wxPen(wxT("white"))); m_dc->DrawRectangle(wxRect(pTopLeft, pBottomRight)); #endif // set background m_dc->SetBackgroundMode(wxSOLID); m_dc->SetBackground(wxBrush(wxT("white"), wxSOLID)); m_dc->Clear(); m_tree_buttons.clear(); } m_xpos = 0; // start at the left m_ypos = 0;//-scroll_y_pos; // start at the top m_max_xpos = 0; HeeksObj* prev_object = NULL; bool prev_object_expanded = NULL; HeeksObj* object = wxGetApp().GetFirstChild(); while(object) { HeeksObj* next_object = wxGetApp().GetNextChild(); bool expanded = IsExpanded(object); RenderObject(expanded, prev_object, prev_object_expanded, object, next_object, 0); prev_object = object; prev_object_expanded = expanded; object = next_object; } // draw the dragged objects if(m_dragging) { wxSize drag_size = GetDraggedListSize(); m_dc->SetBrush(wxBrush(wxT("orange"))); m_dc->SetPen(wxPen(wxT("blue"))); m_dc->DrawRectangle(m_drag_position, drag_size); RenderDraggedList(); if(m_drag_paste_rect.width > 0) { m_dc->SetPen(wxPen(wxT("black"))); m_dc->SetBrush(wxBrush(wxT("black"))); m_dc->DrawRectangle(m_drag_paste_rect); } } }
void ProsodyDisplay::OnDraw(wxDC& dc) {//================================ int x1,y1; int vX,vY,vW,vH; // Dimensions of client area in pixels int line, start, end; GetClientSize(&x1, &y1); if(x1 != linewidth) { LayoutData(NULL, 0); } wxRegionIterator upd(GetUpdateRegion()); // get the update rect list while (upd) { vX = upd.GetX(); vY = upd.GetY(); vW = upd.GetW(); vH = upd.GetH(); CalcUnscrolledPosition(vX,vY,&x1,&y1); // Repaint this rectangle, find which lines to redraw start = y1/FRAMEHEIGHT; end = (y1+vH)/FRAMEHEIGHT; for(line=start; line<=end && line<num_lines; line++) DrawPitchline(dc,line,x1,x1+vW); upd ++ ; } } // end of ProsodyDisplay::OnDraw
void MemoryGrid::OnMotion(wxMouseEvent& event) { int x, y; CalcUnscrolledPosition(event.GetX(), event.GetY(), &x, &y); int row = YToRow(y); int col = XToCol(x); if (col == wxNOT_FOUND || row == wxNOT_FOUND) { timer.Stop(); event.Skip(); if (tipWindow != NULL) { delete tipWindow; tipWindow = NULL; } return; } if (col == MemoryInstruction && tipWindow == NULL) { toolTipLastRow = row; timer.Start(500, wxTIMER_ONE_SHOT); } event.Skip(); }
/*pdf_document * pdoc = pdf_specifics(doc); //pdf_page * pg = pdf_load_page(pdoc,0); pdf_obj * form,*field; form = pdf_dict_getp(pdf_trailer(pdoc), "Root/AcroForm/Fields"); field = pdf_lookup_field(form,"name"); pdf_field_set_value(pdoc,field,"DDDD"); char * mes = pdf_field_value(pdoc,field); pdf_update_page(pdoc, (pdf_page *)page); wxMessageBox(mes); // pdf_close_document(pdoc); // Calculate a transform to use when rendering. This transform // contains the scale and rotation. Convert zoom percentage to a // scaling factor. Without scaling the resolution is 72 dpi. fz_matrix transform,tran; fz_rotate(&transform, rotation); fz_pre_scale(&transform, zoom / 100.0f, zoom / 100.0f); fz_translate(&tran,100,350); // pdf_field_set_display(pdoc,wid->obj,3); // Take the page bounds and transform them by the same matrix that // we will use to render the page. fz_rect bounds; fz_bound_page(doc, page, &bounds); // pdf_bound_widget((pdf_widget*)wid1,&bounds); fz_transform_rect(&bounds, &transform); pdf_text_widget_set_text(pdoc,(pdf_widget*)wid1,"FFFFFFFFFFFFFFFFFFFFFFFFFF"); pdf_update_appearance(pdoc,wid1); // Create a blank pixmap to hold the result of rendering. The // pixmap bounds used here are the same as the transformed page // bounds, so it will contain the entire page. The page coordinate // space has the origin at the top left corner and the x axis // extends to the right and the y axis extends down. fz_irect bbox; fz_round_rect(&bbox, &bounds); fz_pixmap *pix = fz_new_pixmap_with_bbox(ctx, fz_device_rgb(ctx), &bbox); fz_clear_pixmap_with_value(ctx, pix, 0xff); // A page consists of a series of objects (text, line art, images, // gradients). These objects are passed to a device when the // interpreter runs the page. There are several devices, used for // different purposes: // // draw device -- renders objects to a target pixmap. // // text device -- extracts the text in reading order with styling // information. This text can be used to provide text search. // // list device -- records the graphic objects in a list that can // be played back through another device. This is useful if you // need to run the same page through multiple devices, without // the overhead of parsing the page each time. // Create a draw device with the pixmap as its target. // Run the page with the transform. fz_device *dev = fz_new_draw_device(ctx, pix); pdf_run_annot(pdoc,(pdf_page*)page,wid1,dev,&tran,NULL); fz_run_page(doc, page, dev, &transform, NULL); fz_free_device(dev); unsigned char * data; bitmap = RGBAtoBitmap(pix->samples,pix->w,pix->h); w = bitmap->GetWidth(); h = bitmap->GetHeight(); SetScrollbars(1,1,w,h,0,0); //bitmap = wxBitmap((const char*)data,pix->w,pix->h,32); // Clean up. pdf_page_write(pdoc,(pdf_page*)page); fz_drop_pixmap(ctx, pix); fz_free_page(doc, page); fz_close_document(doc); fz_free_context(ctx); Refresh(); } */ void PDFPanel::OnClick(wxMouseEvent &event) { //Selected Fields cannot be more than 50 at a page if(selectedItems.size() > 50) { wxMessageBox(wxT("No more fields can be selected")); return; } wxPoint pt1,pt; pt1 = CalcUnscrolledPosition(event.GetPosition()); pt1.x *= scale; pt1.y *= scale; Field f = doc32->SelectField(pt1); it = selectedItems.begin(); while(it!=selectedItems.end()) { if(it->id == f.id) return; it++; } if(strcmp(f.name,"empty")) { int x0 = f.xPos/scale; int y0 = f.yPos/scale; int width = f.width/scale; int height = f.height/scale; selectedItems.push_back(SelectedItem(wxRect(x0,y0,width,height),f.id)); } else { selectedItems.clear(); } Refresh(); }
void PDFPanel::DropField(wxCoord x,wxCoord y,wxString data) { selectedItems.clear(); wxBusyCursor wait; wxPoint pt,pt1; pt = wxPoint(x,y); pt1 = CalcUnscrolledPosition(pt); x = pt1.x; y = pt1.y; Field f; f.height = 20; f.width = 100; f.pageNo = 0; f.xPos = x*scale; f.yPos = y*scale; f.value = "IAMAWESOME"; char * temp = "D"; f.name = temp; doc32->AddField(f); doc32->LoadPage(doc32->getCurPage()); bitmap = doc32->renderPDF(); // w = bitmap->GetWidth(); // h = bitmap->GetHeight(); Refresh(); }
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); } }
void wxsItemEditorContent::OnMouse(wxMouseEvent& event) { // Anti-recursion lock static bool IsRunning = false; if ( IsRunning ) return; IsRunning = true; if ( event.ButtonDown() ) { SetFocus(); } else if ( m_MouseState == msWaitForIdle ) { m_MouseState = msIdle; } int NewX = event.m_x; int NewY = event.m_y; CalcUnscrolledPosition(NewX,NewY,&NewX,&NewY); event.m_x = NewX; event.m_y = NewY; switch ( m_MouseState ) { case msDraggingPointInit: OnMouseDraggingPointInit (event); break; case msDraggingPoint: OnMouseDraggingPoint (event); break; case msDraggingItemInit: OnMouseDraggingItemInit (event); break; case msDraggingItem: OnMouseDraggingItem (event); break; case msTargetSearch: OnMouseTargetSearch (event); break; case msWaitForIdle: break; default: OnMouseIdle (event); break; } IsRunning = false; }
void wxBitmapComboPopupChild::OnMouse( wxMouseEvent &event ) { wxPoint mouse = event.GetPosition(); CalcUnscrolledPosition(mouse.x, mouse.y, &mouse.x, &mouse.y); //wxPrintf(wxT("bmpcombo mouse %d %d\n"), mouse.x, mouse.y); fflush(stdout); // Get selection from mouse pos, force valid int sel = m_bmpCombo->GetItemSize().y != 0 ? mouse.y/m_bmpCombo->GetItemSize().y : -1; if (sel < 0) sel = 0; else if (sel >= m_bmpCombo->GetCount()) sel = m_bmpCombo->GetCount()-1; if (event.LeftDown()) { // quickly show user what they selected before hiding it if (sel != m_last_selection) { wxClientDC dc(this); PrepareDC(dc); if (m_last_selection >= 0) DrawSelection(m_last_selection, dc); if (sel >= 0) DrawSelection(sel, dc); m_last_selection = sel; } m_bmpCombo->SetSelection(sel, true); m_bmpCombo->HidePopup(); return; } }
void wxlCan::OnPaint(wxPaintEvent& WXUNUSED(event) ) { wxPaintDC dc(this); wxRegionIterator it( GetUpdateRegion() ); while (it) { int x = it.GetX(); int y = it.GetY(); int w = it.GetWidth(); int h = it.GetHeight(); int xx; int yy; CalcUnscrolledPosition( x, y, &xx, &yy); wxMemoryDC mdc; mdc.SelectObject( m_buffer ); dc.Blit( x, y, w, h, &mdc, xx, yy, wxCOPY, false ); mdc.SelectObject( wxNullBitmap ); it++; } }
void wxCustomHeightListCtrl::OnMouseEvent(wxMouseEvent& event) { bool changed = false; if (event.ButtonDown() && m_allow_selection) { wxPoint pos = event.GetPosition(); int x, y; CalcUnscrolledPosition(pos.x, pos.y, &x, &y); if (y < 0 || y > static_cast<int>(m_lineHeight * m_rows.size())) { m_focusedLine = npos; m_selectedLines.clear(); changed = true; } else { size_t line = static_cast<size_t>(y / m_lineHeight); if (event.ShiftDown()) { if (m_focusedLine == npos) { changed |= m_selectedLines.insert(line).second; } else if (line < m_focusedLine) { for (size_t i = line; i <= m_focusedLine; ++i) { changed |= m_selectedLines.insert(i).second; } } else { for (size_t i = line; i >= m_focusedLine && i != npos; --i) { changed |= m_selectedLines.insert(i).second; } } } else if (event.ControlDown()) { if (m_selectedLines.find(line) == m_selectedLines.end()) { m_selectedLines.insert(line); } else { m_selectedLines.erase(line); } changed = true; } else { m_selectedLines.clear(); m_selectedLines.insert(line); changed = true; } m_focusedLine = line; } Refresh(); } event.Skip(); if (changed) { wxCommandEvent evt(wxEVT_COMMAND_LISTBOX_SELECTED, GetId()); ProcessEvent(evt); } }
void TTYScroll::OnDraw( wxDC& dc ) { // update region is always in device coords, translate to logical ones wxRect rectUpdate = GetUpdateRegion().GetBox(); CalcUnscrolledPosition( rectUpdate.x, rectUpdate.y, &rectUpdate.x, &rectUpdate.y ); size_t lineFrom = rectUpdate.y / m_hLine, lineTo = rectUpdate.GetBottom() / m_hLine; if( lineTo > m_nLines - 1 ) lineTo = m_nLines - 1; wxCoord y = lineFrom * m_hLine; wxString lss; for( size_t line = lineFrom; line <= lineTo; line++ ) { wxCoord yPhys; CalcScrolledPosition( 0, y, NULL, &yPhys ); wxString ls = m_plineArray->Item( line ); if(ls.Mid(0, 7) == _T("<GREEN>") ){ dc.SetTextForeground( wxColour(_T("DARK GREEN")) ); lss = ls.Mid(7); } else if(ls.Mid(0, 7) == _T("<GOLD>") ){ dc.SetTextForeground( wxColour(_T("GOLD")) ); lss = ls.Mid(7); } else if(ls.Mid(0, 6) == _T("<BLUE>") ){ dc.SetTextForeground( wxColour(_T("BLUE")) ); lss = ls.Mid(6); } else if(ls.Mid(0, 5) == _T("<RED>") ){ dc.SetTextForeground( wxColour(_T("RED")) ); lss = ls.Mid(5); } else if(ls.Mid(0, 7) == _T("<BROWN>") ){ dc.SetTextForeground( wxColour(_T("BROWN")) ); lss = ls.Mid(7); } else if(ls.Mid(0, 8) == _T("<SIENNA>") ){ dc.SetTextForeground( wxColour(_T("SIENNA")) ); lss = ls.Mid(8); } else if(ls.Mid(0, 8) == _T("<MAROON>") ){ dc.SetTextForeground( wxColour(_T("MAROON")) ); lss = ls.Mid(8); } else if(ls.Mid(0, 8) == _T("<CORAL>") ){ dc.SetTextForeground( wxColour(_T("CORAL")) ); lss = ls.Mid(8); } dc.DrawText( lss, 0, y ); y += m_hLine; } }
void wxsDrawingWindow::FetchScreen() { if ( !m_Bitmap ) return; wxClientDC DC(this); wxMemoryDC DestDC; int X = 0, Y = 0; int DX = 0, DY = 0; CalcUnscrolledPosition(0,0,&DX,&DY); DestDC.SelectObject(*m_Bitmap); DestDC.Blit(DX,DY,GetSize().GetWidth(),GetSize().GetHeight(),&DC,X,Y); DestDC.SelectObject(wxNullBitmap); }
wxDragResult NassiDiagramWindow::OnDrop(const wxPoint &pt, NassiBrick *brick, wxString strc, wxString strs, wxDragResult def ) { wxClientDC dc(this); DoPrepareDC(dc); wxCoord xx, yy; CalcUnscrolledPosition( pt.x, pt.y, &xx, &yy); wxPoint pos(xx, yy); RemoveDrawlet(dc); return m_view->OnDrop(pos, brick, strc, strs, def); }
void NassiDiagramWindow::PaintBackground(wxDC &dc) { wxColour backgroundColour = GetBackgroundColour(); if ( !backgroundColour.Ok()) backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); dc.SetBrush(wxBrush(backgroundColour)); dc.SetPen(wxPen(backgroundColour, 1)); wxRect windowRect(wxPoint(0,0), GetClientSize()); CalcUnscrolledPosition(windowRect.x, windowRect.y, &windowRect.x, &windowRect.y); dc.DrawRectangle(windowRect); dc.SetBrush(wxNullBrush); dc.SetPen(wxNullPen); }
/// Paint the background void InstanceCtrl::PaintBackground(wxDC& dc) { wxColour backgroundColour = GetBackgroundColour(); if (!backgroundColour.Ok()) backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); // Clear the background dc.SetBrush(wxBrush(backgroundColour)); dc.SetPen(*wxTRANSPARENT_PEN); wxRect windowRect(wxPoint(0, 0), GetClientSize()); // We need to shift the rectangle to take into account // scrolling. Converting device to logical coordinates. CalcUnscrolledPosition(windowRect.x, windowRect.y, & windowRect.x, & windowRect.y); dc.DrawRectangle(windowRect); }
void wxlCan::OnMouseEvent(wxMouseEvent& event) { wxPoint pos = event.GetPosition(); int xx, yy; CalcUnscrolledPosition( pos.x, pos.y, &xx, &yy ); double mouse_worldx = DeviceToWorldX( xx ); double mouse_worldy = DeviceToWorldY( yy ); wxString str; str.Printf( _T("%6.3f,%6.3f"), mouse_worldx, mouse_worldy ); ((wxFrame*)m_parent)->SetStatusText( str ); if ( event.Moving() && !m_hit ) { wxlCanObj* hit = m_rootobject.WhichIsHit( mouse_worldx, mouse_worldy ); if ( hit ) SetCursor( wxCURSOR_HAND ); else SetCursor( wxCURSOR_ARROW ); } if ( event.LeftDown() ) { m_hit = m_rootobject.WhichIsHit( mouse_worldx, mouse_worldy ); if ( m_hit ) { CaptureMouse(); m_startMouseX = mouse_worldx; m_startMouseY = mouse_worldy; m_startObjX = m_hit->GetX(); m_startObjY = m_hit->GetY(); } } else if ( event.Dragging() && m_hit ) { m_hit->SetPos( m_startObjX + mouse_worldx - m_startMouseX, m_startObjY + mouse_worldy - m_startMouseY ); } else if (event.LeftUp() && m_hit ) { m_hit->SetPos( m_startObjX, m_startObjY); m_cmdh->Submit( new wxlMoveObjectCmd( m_hit, m_startObjX + mouse_worldx - m_startMouseX, m_startObjY + mouse_worldy - m_startMouseY ) ); ReleaseMouse(); m_hit = NULL; } }
void StateEvaluationTreePanel::OnMouseMoved(wxMouseEvent &Ev) { ClickUnmoved = false; auto const Pos = CalcUnscrolledPosition(Ev.GetPosition()); // TODO: Find if the Pos is over the pretty-printed Stmt. // Find if the Pos is over a node's rectangle. auto const NewHoverNodeIt = std::find_if(Nodes.begin(), Nodes.end(), [&Pos] (NodeInfo const &Node) -> bool { return Node.XStart <= Pos.x && Pos.x <= Node.XEnd && Node.YStart <= Pos.y && Pos.y <= Node.YEnd; }); if (setHoverNode(NewHoverNodeIt)) redraw(); }
void EDA_DRAW_PANEL::SetClipBox( wxDC& aDC, const wxRect* aRect ) { wxRect clipBox; // Use the entire visible device area if no clip area was defined. if( aRect == NULL ) { BASE_SCREEN* Screen = GetScreen(); if( !Screen ) return; Screen->m_StartVisu = CalcUnscrolledPosition( wxPoint( 0, 0 ) ); clipBox.SetSize( GetClientSize() ); int scrollX, scrollY; double scalar = Screen->GetScalingFactor(); scrollX = KiROUND( Screen->GetGridSize().x * scalar ); scrollY = KiROUND( Screen->GetGridSize().y * scalar ); m_scrollIncrementX = std::max( GetClientSize().x / 8, scrollX ); m_scrollIncrementY = std::max( GetClientSize().y / 8, scrollY ); Screen->m_ScrollbarPos.x = GetScrollPos( wxHORIZONTAL ); Screen->m_ScrollbarPos.y = GetScrollPos( wxVERTICAL ); } else { clipBox = *aRect; } // Pad clip box in device units. clipBox.Inflate( CLIP_BOX_PADDING ); // Convert from device units to drawing units. m_ClipBox.SetOrigin( wxPoint( aDC.DeviceToLogicalX( clipBox.x ), aDC.DeviceToLogicalY( clipBox.y ) ) ); m_ClipBox.SetSize( wxSize( aDC.DeviceToLogicalXRel( clipBox.width ), aDC.DeviceToLogicalYRel( clipBox.height ) ) ); wxLogTrace( kicadTraceCoords, wxT( "Device clip box=(%d, %d, %d, %d), Logical clip box=(%d, %d, %d, %d)" ), clipBox.x, clipBox.y, clipBox.width, clipBox.height, m_ClipBox.GetX(), m_ClipBox.GetY(), m_ClipBox.GetWidth(), m_ClipBox.GetHeight() ); }
void EDA_DRAW_PANEL::MoveCursor( const wxPoint& aPosition ) { if( GetParent()->IsGalCanvasActive() ) return; int x, y, xPpu, yPpu; wxPoint screenPos, drawingPos; wxRect clientRect( wxPoint( 0, 0 ), GetClientSize() ); INSTALL_UNBUFFERED_DC( dc, this ); screenPos.x = dc.LogicalToDeviceX( aPosition.x ); screenPos.y = dc.LogicalToDeviceY( aPosition.y ); // Scroll if the requested mouse position cursor is outside the drawing area. if( !clientRect.Contains( screenPos ) ) { GetViewStart( &x, &y ); GetScrollPixelsPerUnit( &xPpu, &yPpu ); CalcUnscrolledPosition( screenPos.x, screenPos.y, &drawingPos.x, &drawingPos.y ); wxLogTrace( kicadTraceCoords, wxT( "MoveCursor() initial screen position(%d, %d) " ) \ wxT( "rectangle(%d, %d, %d, %d) view(%d, %d)" ), screenPos.x, screenPos.y, clientRect.x, clientRect.y, clientRect.width, clientRect.height, x, y ); if( screenPos.y < clientRect.GetTop() ) y -= m_scrollIncrementY * yPpu; else if( screenPos.y > clientRect.GetBottom() ) y += m_scrollIncrementY * yPpu; else if( clientRect.GetRight() < screenPos.x ) x += m_scrollIncrementX * xPpu; else x -= m_scrollIncrementX * xPpu; Scroll( x, y ); CalcScrolledPosition( drawingPos.x, drawingPos.y, &screenPos.x, &screenPos.y ); wxLogTrace( kicadTraceCoords, wxT( "MoveCursor() scrolled screen position(%d, %d) view(%d, %d)" ), screenPos.x, screenPos.y, x, y ); } WarpPointer( screenPos.x, screenPos.y ); }
void MemoryGrid::OnShowToolTip(wxTimerEvent& event) { wxPoint p = ScreenToClient(wxGetMousePosition()); int x, y; CalcUnscrolledPosition(p.x, p.y, &x, &y); int row = YToRow(y); int col = XToCol(x); if (col == MemoryInstruction && tipWindow == NULL) { std::string tooltip = state.comments[(unsigned short)(row-1)]; if (tooltip.empty()) return; tipWindow = new wxTipWindow(this, tooltip); tipWindow->SetTipWindowPtr(&tipWindow); tipWindow->SetBoundingRect(wxRect(x + 30, y + 30, 100, 22)); } }
wxDragResult NassiDiagramWindow::OnDragOver(const wxPoint &pt, wxDragResult def, bool HasNoBricks) { wxClientDC dc(this); DoPrepareDC(dc); wxCoord xx, yy; CalcUnscrolledPosition( pt.x, pt.y, &xx, &yy); wxPoint pos(xx, yy); RemoveDrawlet(dc); m_hd = m_view->OnDragOver(pos, def, HasNoBricks); if ( m_hd && !m_hd->Draw(dc) ) { delete m_hd; m_hd = 0; } return def; }
wxPoint WinEDA_DrawPanel::CalcAbsolutePosition(const wxPoint & rel_pos) /*********************************************************************/ /* retourne la position absolue en pixels de la position rel_pos, donnée en position relative scrollée (en pixel) */ { wxPoint pos; #ifdef WX_ZOOM CalcUnscrolledPosition( rel_pos.x, rel_pos.y, &pos.x, &pos.y ); #else int ii, jj; GetViewStart(&pos.x, &pos.y); GetScrollPixelsPerUnit(&ii, &jj); pos.x *= ii; pos.y *= jj; pos.x += rel_pos.x; pos.y += rel_pos.y; #endif return pos; }
void Canvas::OnPaint( wxPaintEvent & ) { DEBUG("Begin OnPaint"); wxPaintDC dc(this); if ( contents->GetWidth() <= 0 ) return; DEBUG("Continue OnPaint"); wxScrolledWindow::PrepareDC(dc); wxRegion updateRegions = GetUpdateRegion(); for ( wxRegionIterator region( updateRegions ); region; ++region ) { wxRect rect = region.GetRect(); CalcUnscrolledPosition( rect.x, rect.y, &rect.x, &rect.y ); /* Find the actual image part of the update region. */ wxRect image_area = wxRect( wxSize(contents->GetWidth(), contents->GetHeight()) ); rect.Intersect( canvas_coords( image_area ) ); dc.DrawBitmap( zoomed_bitmap_for_canvas_region( rect ), rect.GetTopLeft() ); } DEBUG("End OnPaint"); }
void TileSetPanel::OnLeftButtonPressed(wxMouseEvent& event) { if (!m_tileset || m_tileset->IsDirty()) return; wxPoint mousePos = CalcUnscrolledPosition(event.GetPosition()); //Select the tile int selectedCol, selectedRow; GetTileAt(mousePos, selectedCol, selectedRow); if (selectedCol >= m_tileset->GetColumnsCount() || selectedRow >= m_tileset->GetRowsCount()) return; m_selectedCol = selectedCol; m_selectedRow = selectedRow; //Send the event TileSelectionEvent newEvent(TILE_SELECTION_CHANGED, GetId(), m_tileset->GetTileIDFromCell(m_selectedCol, m_selectedRow)); newEvent.SetEventObject(this); ProcessWindowEvent(newEvent); Refresh(); }
void PrintableHtmlWindow::OnRightUp(wxMouseEvent& event) { wxMenu m; m.Append(wxID_NEW, _("&Open link in a new window")); m.Append(wxID_ADD, _("Open link in a new &tab")); m.Append(wxID_COPY, _("&Copy")); #ifdef _DEBUG m.AppendSeparator(); m.Append(CmdCopyAllHtml, _("Copy &HTML code")); #endif m.AppendSeparator(); m.Append(wxID_SAVE, _("&Save as HTML file...")); m.Append(wxID_PREVIEW, _("Print pre&view...")); m.Append(wxID_PRINT, _("&Print...")); bool isLink = false; if (m_Cell) // taken from wx's htmlwin.cpp { wxPoint pos = CalcUnscrolledPosition(event.GetPosition()); wxHtmlCell *cell = m_Cell->FindCellByPos(pos.x, pos.y); if (cell) { int ix = cell->GetPosX(); int iy = cell->GetPosY(); wxHtmlLinkInfo *i = cell->GetLink(pos.x-ix, pos.y-iy); if (i) { tempLinkM = i->GetHref(); isLink = true; } } } m.Enable(wxID_NEW, isLink); m.Enable(wxID_ADD, isLink); m.Enable(wxID_COPY, !SelectionToText().IsEmpty()); PopupMenu(&m, ScreenToClient(::wxGetMousePosition())); }
int TemplateLegend::GetCategoryClick(wxMouseEvent& event) { wxPoint pt(event.GetPosition()); int x, y; CalcUnscrolledPosition(pt.x, pt.y, &x, &y); int c_ts = template_canvas->GetCurrentCanvasTmStep(); int num_cats = template_canvas->GetNumCategories(c_ts); int cur_y = py; for (int i = 0; i<num_cats; i++) { if ((x > px) && (x < px + m_l) && (y > cur_y - 8) && (y < cur_y + m_w)) { return i; } else if ((x > px + m_l) && (y > cur_y - 8) && (y < cur_y + m_w)) { return -1; } cur_y += d_rect; } return -1; }
void wxsItemEditorContent::RecalculateMapsReq(wxsItem* Item) { if ( Item->GetLastPreview() ) { wxWindow* win = wxDynamicCast(Item->GetLastPreview(),wxWindow); if ( win ) { m_ItemToWindow[Item] = win; if ( win->IsShown() ) { int PosX = 0; int PosY = 0; int SizeX = 0; int SizeY = 0; win->GetPosition(&PosX,&PosY); win->GetParent()->ClientToScreen(&PosX,&PosY); ScreenToClient(&PosX,&PosY); CalcUnscrolledPosition(PosX,PosY,&PosX,&PosY); win->GetSize(&SizeX,&SizeY); m_ItemToRect[Item] = wxRect(PosX,PosY,SizeX,SizeY); wxsParent* Parent = Item->ConvertToParent(); if ( Parent ) { for ( int i=0; i<Parent->GetChildCount(); i++ ) { if ( Parent->IsChildPreviewVisible(Parent->GetChild(i)) ) { RecalculateMapsReq(Parent->GetChild(i)); } } } } } } }