void hdDrawingView::onPaint(wxPaintEvent &event) { // Prepare Context for Buffered Draw wxPaintDC dcc(this); wxBufferedDC dc(&dcc, canvasSize); dc.Clear(); hdIFigure *toDraw = NULL; hdIteratorBase *iterator = drawing->figuresEnumerator(); while(iterator->HasNext()) { toDraw = (hdIFigure *)iterator->Next(); if(toDraw->isSelected(diagramIndex)) toDraw->drawSelected(dc, this); else toDraw->draw(dc, this); } delete iterator; hdIHandle *tmpHandle = NULL; hdIteratorBase *selectionIterator = drawing->selectionFigures();//selection->createIterator(); while(selectionIterator->HasNext()) { toDraw = (hdIFigure *)selectionIterator->Next(); hdIteratorBase *handlesIterator = toDraw->handlesEnumerator()->createIterator(); while(handlesIterator->HasNext()) { tmpHandle = (hdIHandle *)handlesIterator->Next(); tmpHandle->draw(dc, this); } delete handlesIterator; } delete selectionIterator; //Hack to avoid selection rectangle drawing bug if (drawSelRect) { wxPen *pen = wxThePenList->FindOrCreatePen(*wxRED, 1, wxDOT); dc.SetPen(*pen); wxBrush *brush = wxTheBrushList->FindOrCreateBrush(*wxRED, wxTRANSPARENT); dc.SetBackground(*brush); dc.SetBackgroundMode(wxTRANSPARENT); //Adjust points before drawing wxPoint selAjustedPoints[5]; CalcScrolledPosition(selPoints[0].x, selPoints[0].y, &selAjustedPoints[0].x, &selAjustedPoints[0].y); CalcScrolledPosition(selPoints[1].x, selPoints[1].y, &selAjustedPoints[1].x, &selAjustedPoints[1].y); CalcScrolledPosition(selPoints[2].x, selPoints[2].y, &selAjustedPoints[2].x, &selAjustedPoints[2].y); CalcScrolledPosition(selPoints[3].x, selPoints[3].y, &selAjustedPoints[3].x, &selAjustedPoints[3].y); CalcScrolledPosition(selPoints[4].x, selPoints[4].y, &selAjustedPoints[4].x, &selAjustedPoints[4].y); //Draw dc.DrawLines(5, selAjustedPoints, 0, 0); drawSelRect = false; } }
void wxCustomHeightListCtrl::DeleteRow(size_t pos) { assert(pos < m_rows.size()); m_rows[pos]->SetContainingWindow(0); m_rows.erase(m_rows.begin() + pos); std::set<size_t> selectedLines; m_selectedLines.swap(selectedLines); for (auto const& selected : selectedLines) { if (selected < m_rows.size()) { m_selectedLines.insert(selected); } } AdjustView(); if (m_focusedLine >= m_rows.size()) { m_focusedLine = npos; } int left = 0; int top = 0; CalcScrolledPosition(0, 0, &left, &top); int const width = GetClientSize().GetWidth(); // Intentionally update all: if y position changes, by the time OnSize is called in // response to AdjustView, internal state isn't quite correct for (size_t i = 0; i < m_rows.size(); ++i) { m_rows[i]->SetDimension(left, m_lineHeight * i + top, width, m_lineHeight); } Refresh(); }
void ProsodyDisplay::RefreshLine(int line) {//===================================== int x,y; CalcScrolledPosition(0,line*FRAMEHEIGHT,&x,&y); RefreshRect(wxRect(0,y,linewidth,FRAMEHEIGHT)); }
//Hack to avoid event problem with simpleTextTool wxTextCrtl at EVT_TEXT event (when text is set at edit it generate this event not sure ????) void hdDrawingView::simpleTextToolChangeHandler(wxCommandEvent &event) { if(!simpleTextToolEdit->IsModified() && simpleTextFigure) { simpleTextFigure->setText(simpleTextToolEdit->GetValue()); //getFontMetrics int width, height; wxWindowDC dc(this); dc.SetFont(hdFontAttribute::defaultFont); if(simpleTextFigure->getText(true).length() > 5) dc.GetTextExtent(simpleTextFigure->getText(true), &width, &height); else dc.GetTextExtent(wxT("EMPTY"), &width, &height); //recalculateDisplayBox hdGeometry g; simpleTextFigure->displayBox().width = g.max(width, 10) + simpleTextFigure->getPadding(); simpleTextFigure->displayBox().height = g.max(height, 10) + simpleTextFigure->getPadding(); //calculateSizeEntry hdPoint p = simpleTextFigure->displayBox().GetPosition(this->diagramIndex); CalcScrolledPosition(p.x, p.y, &p.x, &p.y); simpleTextToolEdit->SetPosition(p); simpleTextToolEdit->SetSize(simpleTextFigure->displayBox().GetSize()); okTxtButton->SetPosition(wxPoint(p.x + simpleTextToolEdit->GetSize().GetWidth() + 4, p.y)); cancelTxtButton->SetPosition(wxPoint(okTxtButton->GetPosition().x + okTxtButton->GetSize().GetWidth() + 4, p.y)); } else if(!simpleTextFigure) { wxMessageDialog *error = new wxMessageDialog(NULL, wxT("Error locating hdSimpleTextTool figure"), wxT("Error!"), wxOK | wxICON_ERROR); error->ShowModal(); delete error; } event.Skip(); }
void SpectDisplay::OnZoom(int command) {//=============================== static float zoomtab[] = {0.25,0.3536,0.5,0.7071,1,1.14142}; int f1, f2, frame; int x,y; int height,width; GetClientSize(&width,&height); CalcScrolledPosition(0,0,&x,&y); // centre on a visible selected frame, or if none keep the centred frame centred f1 = int(-y/(FRAME_HEIGHT*zoomy)); f2 = int((-y+height)/(FRAME_HEIGHT*zoomy)); for(frame=f1; frame<=f2 && frame<spectseq->numframes; frame++) { if(spectseq->frames[frame]->selected) break; } if(frame > f2) frame = int((-y+height/2)/(FRAME_HEIGHT*zoomy)); // keep centred frame switch(command) { case T_ZOOMIN: if(zoom < 5) zoom++; break; case T_ZOOMOUT: if(zoom > 0) zoom--; break; } zoomx = zoomy = zoomtab[zoom]; SetExtent(); ScrollToFrame(frame,1); Refresh(); } // end of OnZoom
void wxGridCtrl::DrawRowLabel(wxDC& dc, int row) { if (GetRowHeight(row) <= 0 || m_rowLabelWidth <= 0) return; wxRect rect; #ifdef __WXGTK20__ rect.SetX(1); rect.SetY(GetRowTop(row) + 1); rect.SetWidth(m_rowLabelWidth - 2); rect.SetHeight(GetRowHeight(row) - 2); CalcScrolledPosition(0, rect.y, NULL, &rect.y); wxWindowDC *win_dc = (wxWindowDC*)&dc; wxRendererNative::Get().DrawHeaderButton(win_dc->m_owner, dc, rect, 0); #else int rowTop = GetRowTop(row), rowBottom = GetRowBottom(row) - 1; dc.SetPen(wxPen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW), 1, wxSOLID)); dc.DrawLine(m_rowLabelWidth - 1, rowTop, m_rowLabelWidth - 1, rowBottom); dc.DrawLine(0, rowTop, 0, rowBottom); dc.DrawLine(0, rowBottom, m_rowLabelWidth, rowBottom); dc.SetPen(*wxWHITE_PEN); dc.DrawLine(1, rowTop, 1, rowBottom); dc.DrawLine(1, rowTop, m_rowLabelWidth - 1, rowTop); #endif if (row == GetGridCursorRow()) { dc.DrawBitmap(m_pImageList->GetBitmap(4), 0, GetRowTop(row), true); } }
void wxListBox::UpdateItems() { // only refresh the items which must be refreshed if ( m_updateCount == -1 ) { // refresh all wxLogTrace(_T("listbox"), _T("Refreshing all")); Refresh(); } else { wxSize size = GetClientSize(); wxRect rect; rect.width = size.x; rect.height = size.y; rect.y += m_updateFrom*GetLineHeight(); rect.height = m_updateCount*GetLineHeight(); // we don't need to calculate x position as we always refresh the // entire line(s) CalcScrolledPosition(0, rect.y, NULL, &rect.y); wxLogTrace(_T("listbox"), _T("Refreshing items %d..%d (%d-%d)"), m_updateFrom, m_updateFrom + m_updateCount - 1, rect.GetTop(), rect.GetBottom()); Refresh(true, &rect); } }
void SpectDisplay::RefreshFrame(int frame) {//======================================= int frame_x, frame_y; CalcScrolledPosition(0,int(frame*FRAME_HEIGHT*zoomy), &frame_x,&frame_y); RefreshRect(wxRect(0,frame_y,int(1000*zoomx),int(FRAME_HEIGHT*zoomy))); }
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 wxCustomHeightListCtrl::OnSize(wxSizeEvent& event) { event.Skip(); int const width = GetClientSize().GetWidth(); int left = 0; int top = 0; CalcScrolledPosition(0, 0, &left, &top); for (size_t i = 0; i < m_rows.size(); ++i) { m_rows[i]->SetDimension(left, m_lineHeight * i + top, width, m_lineHeight); } }
void WinEDA_DrawPanel::MouseTo(const wxPoint & Mouse) /****************************************************/ /* place le curseur souris sur la position Mouse */ { wxPoint mouse; #ifdef WX_ZOOM CalcScrolledPosition(Mouse.x, Mouse.y, &mouse.x, &mouse.y); #else mouse = Mouse; mouse.x -= GetScreen()->m_StartVisu.x; mouse.y -= GetScreen()->m_StartVisu.y; #endif GRMouseWarp(this, mouse); }
void ExplainCanvas::ShowPopup(ExplainShape *s) { int sx, sy; CalcScrolledPosition((int)s->GetX(), (int)s->GetY(), &sx, &sy); popup->SetShape(s); if (sy > GetClientSize().y * 2 / 3) sy -= popup->GetSize().y; sx -= popup->GetSize().x / 2; if (sx < 0) sx = 0; popup->Popup(); popup->Move(ClientToScreen(wxPoint(sx, sy))); }
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 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 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 nkToolBar::evtRepintar(wxPaintEvent& WXUNUSED(evt)){ wxPaintDC dc(this); int alto = 0, ancho = 0; int ancho_real, alto_real; int xx = 0, yy = 0; CalcScrolledPosition(xx, yy, &xx, &yy); for (nkListaMenu::Node *node = prv_listaMenus.GetFirst(); node; node = node->GetNext() ){ nkMenuTool *contador = node->GetData(); contador->Move(xx, alto + yy); alto = alto + contador->obtenerTamanio().GetHeight(); if (ancho<contador->obtenerTamanio().GetWidth()){ ancho = contador->obtenerTamanio().GetWidth(); } contador->Refresh(); } ancho_real = GetClientSize().GetWidth(); alto_real = GetClientSize().GetHeight(); SetVirtualSize(ancho, alto); SetMaxSize(wxSize(ancho+ALINEACION, alto+ALINEACION)); }
void wxCustomHeightListCtrl::InsertRow(wxSizer* sizer, size_t pos) { assert(sizer); assert(pos <= m_rows.size()); m_rows.insert(m_rows.begin() + pos, sizer); sizer->SetContainingWindow(this); AdjustView(); int left = 0; int top = 0; CalcScrolledPosition(0, 0, &left, &top); int const width = GetClientSize().GetWidth(); for (size_t i = pos; i < m_rows.size(); ++i) { m_rows[i]->SetDimension(left, m_lineHeight * i + top, width, m_lineHeight); } Refresh(); }
void StateEvaluationTreePanel::showHoverTooltip(NodeInfo const &Node) { auto Access = CurrentAccess->getAccess(); if (!Access) return; // TODO: This should appear on the node rather than the mouse. int const XStart = Node.XStart; int const YStart = Node.YStart; int const Width = Node.XEnd - XStart; int const Height = Node.YEnd - YStart; auto const ClientStart = CalcScrolledPosition(wxPoint(XStart, YStart)); auto const ScreenStart = ClientToScreen(ClientStart); wxRect NodeBounds{ScreenStart, wxSize{Width, Height}}; // Determine a good maximum width for the tip window. auto const WindowSize = GetSize(); auto const TipWidth = WindowSize.GetWidth(); makeStmtTooltip(this, *Trace, Node.Statement, *ActiveFn, TipWidth,NodeBounds); }
void CBOINCListCtrl::DrawProgressBars() { long topItem, numItems, numVisibleItems, row; wxRect r, rr; int w = 0, x = 0, xx, yy, ww; int progressColumn = -1; if (m_pParentView->GetProgressColumn() >= 0) { progressColumn = m_pParentView->m_iColumnIDToColumnIndex[m_pParentView->GetProgressColumn()]; } #if USE_NATIVE_LISTCONTROL wxClientDC dc(this); m_bProgressBarEventPending = false; #else wxClientDC dc(GetMainWin()); // Available only in wxGenericListCtrl #endif if (progressColumn < 0) { m_iRowsNeedingProgressBars.Clear(); return; } int n = (int)m_iRowsNeedingProgressBars.GetCount(); if (n <= 0) return; wxColour progressColor = wxTheColourDatabase->Find(wxT("LIGHT BLUE")); wxBrush progressBrush(progressColor); numItems = GetItemCount(); if (numItems) { topItem = GetTopItem(); // Doesn't work properly for Mac Native control in wxMac-2.8.7 numVisibleItems = GetCountPerPage(); ++numVisibleItems; if (numItems <= (topItem + numVisibleItems)) numVisibleItems = numItems - topItem; x = 0; int progressColumnPosition = GetColumnOrder(progressColumn); for (int i=0; i<progressColumnPosition; i++) { x += GetColumnWidth(GetColumnIndexFromOrder(i)); } w = GetColumnWidth(progressColumn); #if USE_NATIVE_LISTCONTROL x -= GetScrollPos(wxHORIZONTAL); #else CalcScrolledPosition(x, 0, &x, &yy); #endif wxFont theFont = GetFont(); dc.SetFont(theFont); for (int i=0; i<n; ++i) { row = m_iRowsNeedingProgressBars[i]; if (row < topItem) continue; if (row > (topItem + numVisibleItems -1)) continue; GetItemRect(row, r); #if ! USE_NATIVE_LISTCONTROL r.y = r.y - GetHeaderHeight() - 1; #endif r.x = x; r.width = w; r.Inflate(-1, -2); rr = r; wxString progressString = m_pParentView->GetProgressText(row); dc.GetTextExtent(progressString, &xx, &yy); r.y += (r.height - yy - 1) / 2; // Adapted from ellipis code in wxRendererGeneric::DrawHeaderButtonContents() if (xx > r.width) { int ellipsisWidth; dc.GetTextExtent( wxT("..."), &ellipsisWidth, NULL); if (ellipsisWidth > r.width) { progressString.Clear(); xx = 0; } else { do { progressString.Truncate( progressString.length() - 1 ); dc.GetTextExtent( progressString, &xx, &yy); } while (xx + ellipsisWidth > r.width && progressString.length() ); progressString.append( wxT("...") ); xx += ellipsisWidth; } } dc.SetLogicalFunction(wxCOPY); dc.SetBackgroundMode(wxSOLID); dc.SetPen(progressColor); dc.SetBrush(progressBrush); dc.DrawRectangle( rr ); rr.Inflate(-2, -1); ww = rr.width * m_pParentView->GetProgressValue(row); rr.x += ww; rr.width -= ww; #if 0 // Show background stripes behind progress bars wxListItemAttr* attr = m_pParentView->FireOnListGetItemAttr(row); wxColour bkgd = attr->GetBackgroundColour(); dc.SetPen(bkgd); dc.SetBrush(bkgd); #else dc.SetPen(*wxWHITE_PEN); dc.SetBrush(*wxWHITE_BRUSH); #endif dc.DrawRectangle( rr ); dc.SetPen(*wxBLACK_PEN); dc.SetBackgroundMode(wxTRANSPARENT); if (xx > (r.width - 7)) { dc.DrawText(progressString, r.x, r.y); } else { dc.DrawText(progressString, r.x + (w - 8 - xx), r.y); } } } m_iRowsNeedingProgressBars.Clear(); }
//--------------------------------------------------------- void CWKSP_Data_Buttons::_Set_Positions(void) { int Size, xSize, ySize, xPos, yPos, xAdd, yAdd; Size = g_pData->Get_Parameter("THUMBNAIL_SIZE")->asInt(); xSize = GetClientSize().x - SCROLL_BAR_DX; if( xSize < Size + THUMBNAIL_DIST ) { xSize = Size + THUMBNAIL_DIST; } xPos = 0; yPos = 0; xAdd = 0; yAdd = 0; //----------------------------------------------------- for(int i=0, x, y; i<m_nItems; i++) { CWKSP_Data_Button *pItem = m_Items[i]; if( pItem->is_Manager() ) { xPos = THUMBNAIL_DIST; yPos += yAdd; if( yPos > 0 ) yPos += THUMBNAIL_DIST; CalcScrolledPosition(0, yPos, &x, &y); pItem->SetSize(x, y, xSize + SCROLL_BAR_DX, -1, wxSIZE_USE_EXISTING); yPos += THUMBNAIL_DIST + pItem->GetSize().y; yAdd = 0; } else { xAdd = Size; if( xPos + xAdd >= xSize ) { xPos = THUMBNAIL_DIST; yPos += yAdd; yAdd = THUMBNAIL_DIST + Size; } yAdd = Size + THUMBNAIL_DIST; CalcScrolledPosition(xPos, yPos, &x, &y); pItem->SetSize(x, y, Size, Size); xPos += THUMBNAIL_DIST + xAdd; } } //----------------------------------------------------- xSize += SCROLL_BAR_DX; ySize = SCROLL_BAR_DY + yPos + yAdd; if( m_xScroll != xSize || m_yScroll != ySize ) { m_xScroll = xSize; m_yScroll = ySize; SetScrollbars(SCROLL_RATE, SCROLL_RATE, m_xScroll / SCROLL_RATE, m_yScroll / SCROLL_RATE); } }