LayoutSize MultiColumnFragmentainerGroup::flowThreadTranslationAtOffset(LayoutUnit offsetInFlowThread) const { LayoutMultiColumnFlowThread* flowThread = m_columnSet.multiColumnFlowThread(); unsigned columnIndex = columnIndexAtOffset(offsetInFlowThread); LayoutRect portionRect(flowThreadPortionRectAt(columnIndex)); flowThread->flipForWritingMode(portionRect); LayoutRect columnRect(columnRectAt(columnIndex)); m_columnSet.flipForWritingMode(columnRect); LayoutSize translationRelativeToGroup = columnRect.location() - portionRect.location(); LayoutSize enclosingTranslation; if (LayoutMultiColumnFlowThread* enclosingFlowThread = flowThread->enclosingFlowThread()) { // Translation that would map points in the coordinate space of the outermost flow thread to // visual points in the first column in the first fragmentainer group (row) in our multicol // container. LayoutSize enclosingTranslationOrigin = enclosingFlowThread->flowThreadTranslationAtOffset(flowThread->blockOffsetInEnclosingFragmentationContext()); // Translation that would map points in the coordinate space of the outermost flow thread to // visual points in the first column in this fragmentainer group. enclosingTranslation = enclosingFlowThread->flowThreadTranslationAtOffset(blockOffsetInEnclosingFragmentationContext()); // What we ultimately return from this method is a translation that maps points in the // coordinate space of our flow thread to a visual point in a certain column in this // fragmentainer group. We had to go all the way up to the outermost flow thread, since this // fragmentainer group may be in a different outer column than the first outer column that // this multicol container lives in. It's the visual distance between the first // fragmentainer group and this fragmentainer group that we need to add to the translation. enclosingTranslation -= enclosingTranslationOrigin; } return enclosingTranslation + translationRelativeToGroup + offsetFromColumnSet() + m_columnSet.topLeftLocationOffset() - flowThread->topLeftLocationOffset(); }
LayoutRect MultiColumnFragmentainerGroup::columnRectAt(unsigned columnIndex) const { LayoutUnit columnLogicalWidth = m_columnSet.pageLogicalWidth(); LayoutUnit columnLogicalHeight = m_columnHeight; LayoutUnit columnLogicalTop; LayoutUnit columnLogicalLeft; LayoutUnit columnGap = m_columnSet.columnGap(); LayoutUnit portionOutsideFlowThread = logicalTopInFlowThread() + (columnIndex + 1) * columnLogicalHeight - logicalBottomInFlowThread(); if (portionOutsideFlowThread > 0) { // The last column may not be using all available space. ASSERT(columnIndex + 1 == actualColumnCount()); columnLogicalHeight -= portionOutsideFlowThread; ASSERT(columnLogicalHeight >= 0); } if (m_columnSet.multiColumnFlowThread()->progressionIsInline()) { if (m_columnSet.style()->isLeftToRightDirection()) columnLogicalLeft += columnIndex * (columnLogicalWidth + columnGap); else columnLogicalLeft += m_columnSet.contentLogicalWidth() - columnLogicalWidth - columnIndex * (columnLogicalWidth + columnGap); } else { columnLogicalTop += columnIndex * (m_columnHeight + columnGap); } LayoutRect columnRect(columnLogicalLeft, columnLogicalTop, columnLogicalWidth, columnLogicalHeight); if (!m_columnSet.isHorizontalWritingMode()) return columnRect.transposedRect(); return columnRect; }
void ObxTreeHeaderBar::paintEvent(QPaintEvent *) { if (model_ == 0) { return; } QPainter p(this); for(int i = 0; i < model_->columnCount(); ++i) { QRect rc(columnRect(i)); QPainterPath path; path.addRoundedRect(rc, 4, 4, Qt::AbsoluteSize); p.fillPath(path, QBrush(QColor(193, 193, 193))); QString title = model_->headerData(i, Qt::Horizontal).toString(); ui::drawSingleLineText(p, tree_font, title, Qt::AlignLeft|Qt::AlignVCenter, rc.adjusted(MARGIN * 4, MARGIN, MARGIN,MARGIN)); } // Draw the lines. int x1 = 0; int y1 = height() - 4; int x2 = width(); p.setPen(QColor(124, 124, 124)); p.drawLine(x1, y1, x2, y1); p.setPen(QColor(147, 147, 147)); p.drawLine(x1, y1 + 1, x2, y1 + 1); p.setPen(QColor(185, 185, 185)); p.drawLine(x1, y1 + 2, x2, y1 + 2); }
LayoutSize RenderMultiColumnSet::flowThreadTranslationAtOffset(LayoutUnit blockOffset) const { unsigned columnIndex = columnIndexAtOffset(blockOffset); LayoutRect portionRect(flowThreadPortionRectAt(columnIndex)); flipForWritingMode(portionRect); LayoutRect columnRect(columnRectAt(columnIndex)); flipForWritingMode(columnRect); return contentBoxRect().location() + columnRect.location() - portionRect.location(); }
/*! Draw a histogram in Lines style() \param painter Painter \param xMap Maps x-values into pixel coordinates. \param yMap Maps y-values into pixel coordinates. \param from Index of the first sample to be painted \param to Index of the last sample to be painted. If to < 0 the histogram will be painted to its last point. \sa setStyle(), style(), setPen() */ void QwtPlotHistogram::drawLines( QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to ) const { const bool doAlign = QwtPainter::roundingAlignment( painter ); painter->setPen( d_data->pen ); painter->setBrush( Qt::NoBrush ); for ( int i = from; i <= to; i++ ) { const QwtIntervalSample sample = d_series->sample( i ); if ( !sample.interval.isNull() ) { const QwtColumnRect rect = columnRect( sample, xMap, yMap ); QRectF r = rect.toRect(); if ( doAlign ) { r.setLeft( qRound( r.left() ) ); r.setRight( qRound( r.right() ) ); r.setTop( qRound( r.top() ) ); r.setBottom( qRound( r.bottom() ) ); } switch ( rect.direction ) { case QwtColumnRect::LeftToRight: { QwtPainter::drawLine( painter, r.topRight(), r.bottomRight() ); break; } case QwtColumnRect::RightToLeft: { QwtPainter::drawLine( painter, r.topLeft(), r.bottomLeft() ); break; } case QwtColumnRect::TopToBottom: { QwtPainter::drawLine( painter, r.bottomRight(), r.bottomLeft() ); break; } case QwtColumnRect::BottomToTop: { QwtPainter::drawLine( painter, r.topRight(), r.topLeft() ); break; } } } } }
LayoutSize MultiColumnFragmentainerGroup::flowThreadTranslationAtOffset(LayoutUnit offsetInFlowThread) const { LayoutFlowThread* flowThread = m_columnSet.flowThread(); unsigned columnIndex = columnIndexAtOffset(offsetInFlowThread); LayoutRect portionRect(flowThreadPortionRectAt(columnIndex)); flowThread->flipForWritingMode(portionRect); LayoutRect columnRect(columnRectAt(columnIndex)); m_columnSet.flipForWritingMode(columnRect); LayoutSize translationRelativeToGroup = columnRect.location() - portionRect.location(); return translationRelativeToGroup + offsetFromColumnSet() + m_columnSet.topLeftLocationOffset() - flowThread->topLeftLocationOffset(); }
/*! Draw a histogram in Columns style() \param painter Painter \param xMap Maps x-values into pixel coordinates. \param yMap Maps y-values into pixel coordinates. \param from Index of the first sample to be painted \param to Index of the last sample to be painted. If to < 0 the histogram will be painted to its last point. \sa setStyle(), style(), setSymbol(), drawColumn() */ void QwtPlotHistogram::drawColumns( QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to ) const { painter->setPen( d_data->pen ); painter->setBrush( d_data->brush ); for ( int i = from; i <= to; i++ ) { const QwtIntervalSample sample = d_series->sample( i ); if ( !sample.interval.isNull() ) { const QwtColumnRect rect = columnRect( sample, xMap, yMap ); drawColumn( painter, rect, sample ); } } }
void RenderDataGrid::paintColumnHeaders(PaintInfo& paintInfo, int tx, int ty) { DataGridColumnList* columns = gridElement()->columns(); unsigned length = columns->length(); for (unsigned i = 0; i < length; ++i) { DataGridColumn* column = columns->item(i); RenderStyle* columnStyle = headerStyle(column); // Don't render invisible columns. if (!columnStyle || columnStyle->display() == NONE || columnStyle->visibility() != VISIBLE) continue; // Paint the column header if it intersects the dirty rect. IntRect columnRect(column->rect()); columnRect.move(tx, ty); if (columnRect.intersects(paintInfo.rect)) paintColumnHeader(column, paintInfo, tx, ty); } }
void uwHexCtrl::OnPaint(wxPaintEvent& event) { // Setup DC wxBufferedPaintDC dc(this); PrepareDC(dc); dc.BeginDrawing(); dc.SetFont(Font); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); // Get native renderer wxRendererNative& renderer = wxRendererNative::Get(); // Get client rectangle wxRect rectClient(wxPoint(0,0), GetClientSize()); wxRect rectUnscrolled(rectClient); CalcUnscrolledPosition(rectClient.x, rectClient.y, &rectUnscrolled.x, &rectUnscrolled.y); // Paint headers background wxRect columnRect(rectClient); columnRect.y = 0; columnRect.height = ColumnHeight+1; CalcUnscrolledPosition(columnRect.x, columnRect.y, &columnRect.x, &columnRect.y); PaintRectangle( dc, wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE), columnRect ); // Paint items background wxRect windowRect(rectClient); windowRect.y = columnRect.height; windowRect.height -= windowRect.y; CalcUnscrolledPosition(windowRect.x, windowRect.y, &windowRect.x, &windowRect.y); PaintRectangle( dc, GetBackgroundColour(), windowRect ); // return if no columns if( Columns.empty() ) return; // Ignore first event, client size is equal virtual size if( ++PaintCount == 1 ) return; // Paint headers for( dword column=0; column!=Columns.size(); ++column ) { wxRect rbox(Columns.at(column).BoxRect); wxRect rtext(Columns.at(column).TextRect); CalcUnscrolledPosition(rbox.x-rectUnscrolled.x, rbox.y, &rbox.x, &rbox.y); CalcUnscrolledPosition(rtext.x-rectUnscrolled.x, rtext.y, &rtext.x, &rtext.y); renderer.DrawHeaderButton( this, dc, rbox, 0 ); dc.DrawText( Columns.at(column).Caption, rtext.x, rtext.y ); } // Paint header filler wxCoord cwidth = Columns.back().BoxRect.x + Columns.back().BoxRect.width-rectUnscrolled.x; wxRect rbox( cwidth, 0, rectClient.width-cwidth-1, ColumnHeight ); if( rbox.width > 0 ) { CalcUnscrolledPosition(rbox.x, rbox.y, &rbox.x, &rbox.y); renderer.DrawHeaderButton( this, dc, rbox, 0 ); } // Get potential line numbers size_t lineFrom = (rectUnscrolled.y+ColumnHeight) / ItemHeight; size_t lineTo = (rectUnscrolled.GetBottom()) / ItemHeight; // Cap line numbers if( lineTo > HexLines - 1) lineTo = HexLines - 1; // Get first item pos wxCoord y = ColumnHeight + (lineFrom * ItemHeight) + ItemMarginY; wxCoord x = 0; for( size_t line = lineFrom; line <= lineTo; ++line ) { //wxCoord yPhys; //CalcScrolledPosition(0, y, NULL, &yPhys); //wxLogMessage("[%d] lineFrom=%d lineTo=%d y=%d yPhys=%d upd=%d,%d uns=%d,%d" // ,line,lineFrom,lineTo,y,yPhys,rectClient.y,rectClient.height,rectUnscrolled.y,rectUnscrolled.height); for( dword column=0; column!=Columns.size(); ++column ) { const uwHexCtrlColumn& it = Columns.at(column); if( column == 0 ) { dword pos = (line * HexWidth) + DataOffset; wxString item = wxString::Format( FmtOffset, pos ); dc.DrawText( item, it.BoxRect.x+ColumnMarginX, y ); } else if ( column == 1 ) { dword pos = (line * HexWidth); wxString item = wxString::Format( FmtOffset, pos ); dc.DrawText( item, it.BoxRect.x+ColumnMarginX, y ); } else if( column >= ColHexBegin && column < ColHexEnd ) { dword pos = (line * HexWidth) + (column - ColHexBegin); if( pos < DataCache.size() ) { if( HighlightBegin != -1 && pos >= HighlightBegin && pos < HighlightEnd ) { wxRect hlrect = it.BoxRect; hlrect.y = y; PaintRectangle( dc, wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW), hlrect ); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); dc.DrawText( HexStrings.at(DataCache.at(pos)), it.BoxRect.x+ColumnMarginX, y ); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); } else { dc.DrawText( HexStrings.at(DataCache.at(pos)), it.BoxRect.x+ColumnMarginX, y ); } } } else if( column >= ColAsciiBegin && column < ColAsciiEnd ) { dword pos = (line * HexWidth) + column - ColAsciiBegin; if( pos < DataCache.size() ) { if( HighlightBegin != -1 && pos >= HighlightBegin && pos < HighlightEnd ) { wxRect hlrect = it.BoxRect; hlrect.y = y; PaintRectangle( dc, wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW), hlrect ); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); dc.DrawText( AsciiStrings.at(DataCache.at(pos)), it.BoxRect.x+ColumnMarginX, y ); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); } else { dc.DrawText( AsciiStrings.at(DataCache.at(pos)), it.BoxRect.x+ColumnMarginX, y ); } } } } y += HexCharHeight + ItemMarginY + ItemMarginY; } dc.EndDrawing(); }
void CSharedFilesCtrl::OnDrawItem( int item, wxDC* dc, const wxRect& rect, const wxRect& rectHL, bool highlighted ) { CKnownFile *file = (CKnownFile*)GetItemData(item); wxASSERT( file ); if ( highlighted ) { CMuleColour newcol(GetFocus() ? wxSYS_COLOUR_HIGHLIGHT : wxSYS_COLOUR_BTNSHADOW); dc->SetBackground(newcol.Blend(125).GetBrush()); dc->SetTextForeground( CMuleColour(wxSYS_COLOUR_HIGHLIGHTTEXT)); // The second blending goes over the first one. dc->SetPen(newcol.Blend(65).GetPen()); } else { dc->SetBackground( CMuleColour(wxSYS_COLOUR_LISTBOX).GetBrush() ); dc->SetTextForeground(CMuleColour(wxSYS_COLOUR_WINDOWTEXT)); dc->SetPen(*wxTRANSPARENT_PEN); } dc->SetBrush(dc->GetBackground()); dc->DrawRectangle(rectHL); dc->SetPen(*wxTRANSPARENT_PEN); // Offset based on the height of the fonts const int textVOffset = ( rect.GetHeight() - dc->GetCharHeight() ) / 2; // Empty space to each side of a column const int SPARE_PIXELS_HORZ = 4; // The leftmost position of the current column int columnLeft = 0; for ( int i = 0; i < GetColumnCount(); ++i ) { const int columnWidth = GetColumnWidth(i); if (columnWidth > 2*SPARE_PIXELS_HORZ) { wxRect columnRect( columnLeft + SPARE_PIXELS_HORZ, rect.y, columnWidth - 2 * SPARE_PIXELS_HORZ, rect.height); wxDCClipper clipper(*dc, columnRect); wxString textBuffer; switch ( i ) { case ID_SHARED_COL_NAME: textBuffer = file->GetFileName().GetPrintable(); if (file->GetFileRating() || file->GetFileComment().Length()) { int image = Client_CommentOnly_Smiley; if (file->GetFileRating()) { image = Client_InvalidRating_Smiley + file->GetFileRating() - 1; } wxASSERT(image >= Client_InvalidRating_Smiley); wxASSERT(image <= Client_CommentOnly_Smiley); int imgWidth = 16; theApp->amuledlg->m_imagelist.Draw(image, *dc, columnRect.x, columnRect.y + 1, wxIMAGELIST_DRAW_TRANSPARENT); // Move the text to the right columnRect.x += (imgWidth + 4); } break; case ID_SHARED_COL_SIZE: textBuffer = CastItoXBytes(file->GetFileSize()); break; case ID_SHARED_COL_TYPE: textBuffer = GetFiletypeByName(file->GetFileName()); break; case ID_SHARED_COL_PRIO: textBuffer = PriorityToStr(file->GetUpPriority(), file->IsAutoUpPriority()); break; case ID_SHARED_COL_ID: textBuffer = file->GetFileHash().Encode(); break; case ID_SHARED_COL_REQ: textBuffer = CFormat(wxT("%u (%u)")) % file->statistic.GetRequests() % file->statistic.GetAllTimeRequests(); break; case ID_SHARED_COL_AREQ: textBuffer = CFormat(wxT("%u (%u)")) % file->statistic.GetAccepts() % file->statistic.GetAllTimeAccepts(); break; case ID_SHARED_COL_TRA: textBuffer = CastItoXBytes(file->statistic.GetTransferred()) + wxT(" (") + CastItoXBytes(file->statistic.GetAllTimeTransferred()) + wxT(")"); break; case ID_SHARED_COL_RTIO: textBuffer = CFormat(wxT("%.2f")) % ((double)file->statistic.GetAllTimeTransferred() / file->GetFileSize()); break; case ID_SHARED_COL_PART: if ( file->GetPartCount() ) { wxRect barRect(columnRect.x, columnRect. y + 1, columnRect.width, columnRect.height - 2); DrawAvailabilityBar(file, dc, barRect); } break; case ID_SHARED_COL_CMPL: if ( file->m_nCompleteSourcesCountLo == 0 ) { if ( file->m_nCompleteSourcesCountHi ) { textBuffer = CFormat(wxT("< %u")) % file->m_nCompleteSourcesCountHi; } else { textBuffer = wxT("0"); } } else if (file->m_nCompleteSourcesCountLo == file->m_nCompleteSourcesCountHi) { textBuffer = CFormat(wxT("%u")) % file->m_nCompleteSourcesCountLo; } else { textBuffer = CFormat(wxT("%u - %u")) % file->m_nCompleteSourcesCountLo % file->m_nCompleteSourcesCountHi; } break; case ID_SHARED_COL_PATH: if ( file->IsPartFile() ) { textBuffer = _("[PartFile]"); } else { textBuffer = file->GetFilePath().GetPrintable(); } } if (!textBuffer.IsEmpty()) { dc->DrawText(textBuffer, columnRect.x, columnRect.y + textVOffset); } } // Move to the next column columnLeft += columnWidth; } }
LayoutSize MultiColumnFragmentainerGroup::flowThreadTranslationAtOffset( LayoutUnit offsetInFlowThread, LayoutBox::PageBoundaryRule rule, CoordinateSpaceConversion mode) const { LayoutMultiColumnFlowThread* flowThread = m_columnSet.multiColumnFlowThread(); // A column out of range doesn't have a flow thread portion, so we need to // clamp to make sure that we stay within the actual columns. This means that // content in the overflow area will be mapped to the last actual column, // instead of being mapped to an imaginary column further ahead. unsigned columnIndex = offsetInFlowThread >= logicalBottomInFlowThread() ? actualColumnCount() - 1 : columnIndexAtOffset(offsetInFlowThread, rule); LayoutRect portionRect(flowThreadPortionRectAt(columnIndex)); flowThread->flipForWritingMode(portionRect); portionRect.moveBy(flowThread->topLeftLocation()); LayoutRect columnRect(columnRectAt(columnIndex)); columnRect.move(offsetFromColumnSet()); m_columnSet.flipForWritingMode(columnRect); columnRect.moveBy(m_columnSet.topLeftLocation()); LayoutSize translationRelativeToFlowThread = columnRect.location() - portionRect.location(); if (mode == CoordinateSpaceConversion::Containing) return translationRelativeToFlowThread; LayoutSize enclosingTranslation; if (LayoutMultiColumnFlowThread* enclosingFlowThread = flowThread->enclosingFlowThread()) { const MultiColumnFragmentainerGroup& firstRow = flowThread->firstMultiColumnSet()->firstFragmentainerGroup(); // Translation that would map points in the coordinate space of the // outermost flow thread to visual points in the first column in the first // fragmentainer group (row) in our multicol container. LayoutSize enclosingTranslationOrigin = enclosingFlowThread->flowThreadTranslationAtOffset( firstRow.blockOffsetInEnclosingFragmentationContext(), LayoutBox::AssociateWithLatterPage, mode); // Translation that would map points in the coordinate space of the // outermost flow thread to visual points in the first column in this // fragmentainer group. enclosingTranslation = enclosingFlowThread->flowThreadTranslationAtOffset( blockOffsetInEnclosingFragmentationContext(), LayoutBox::AssociateWithLatterPage, mode); // What we ultimately return from this method is a translation that maps // points in the coordinate space of our flow thread to a visual point in a // certain column in this fragmentainer group. We had to go all the way up // to the outermost flow thread, since this fragmentainer group may be in a // different outer column than the first outer column that this multicol // container lives in. It's the visual distance between the first // fragmentainer group and this fragmentainer group that we need to add to // the translation. enclosingTranslation -= enclosingTranslationOrigin; } return enclosingTranslation + translationRelativeToFlowThread; }