int clRowEntry::CalcItemWidth(wxDC& dc, int rowHeight, size_t col) { wxUnusedVar(col); if(col >= m_cells.size()) { return 0; } clCellValue& cell = GetColumn(col); wxFont f = clScrolledPanel::GetDefaultFont(); if(cell.GetFont().IsOk()) { f = cell.GetFont(); } dc.SetFont(f); int item_width = X_SPACER; if(cell.IsBool()) { // add the checkbox size item_width += rowHeight; item_width += X_SPACER; } else if(cell.IsChoice()) { item_width += rowHeight; item_width += X_SPACER; } wxSize textSize = dc.GetTextExtent(cell.GetValueString()); if((col == 0) && !IsListItem()) { // always make room for the twist button item_width += rowHeight; } int bitmapIndex = cell.GetBitmapIndex(); if(IsExpanded() && HasChildren() && cell.GetBitmapSelectedIndex() != wxNOT_FOUND) { bitmapIndex = cell.GetBitmapSelectedIndex(); } if(bitmapIndex != wxNOT_FOUND) { const wxBitmap& bmp = m_tree->GetBitmap(bitmapIndex); if(bmp.IsOk()) { item_width += X_SPACER; item_width += bmp.GetScaledWidth(); item_width += X_SPACER; } } if((col == 0) && !IsListItem()) { int itemIndent = (GetIndentsCount() * m_tree->GetIndent()); item_width += itemIndent; } item_width += textSize.GetWidth(); item_width += clHeaderItem::X_SPACER; return item_width; }
HRESULT RTFformatting::WriteRedlineML(CComPtr<IXmlWriter>& xmlWriter,XmlWriteContext& context) const { if (GetParfmt() && GetParfmt()->get_bImplicit()) return S_OK; CHECKHR(xmlWriter->WriteStartElement(NULL, L"paraMarker", NULL)); if (IsListItem()) { CWideString wsText; wsText = GetListNumberText(); ASSERT(wsText.GetLength() != 0); CHECKHR(xmlWriter->WriteAttributeString(NULL, L"listNumber", NULL, wsText.GetData())); if (context.IsInsertedListItem()) { CHECKHR(xmlWriter->WriteAttributeString(NULL, L"isInserted", NULL, L"true")); } } return xmlWriter->WriteEndElement(); }
void clRowEntry::Render(wxWindow* win, wxDC& dc, const clColours& c, int row_index, clSearchText* searcher) { wxUnusedVar(searcher); wxRect rowRect = GetItemRect(); bool zebraColouring = (m_tree->HasStyle(wxTR_ROW_LINES) || m_tree->HasStyle(wxDV_ROW_LINES)); bool even_row = ((row_index % 2) == 0); // Define the clipping region bool hasHeader = (m_tree->GetHeader() && !m_tree->GetHeader()->empty()); // Not cell related clColours colours = c; if(zebraColouring) { // Set Zebra colouring, only if no user colour was provided for the given line colours.SetItemBgColour(even_row ? c.GetAlternateColour() : c.GetBgColour()); } // Override default item bg colour with the user's one if(GetBgColour().IsOk()) { colours.SetItemBgColour(GetBgColour()); } wxRect selectionRect = rowRect; wxPoint deviceOrigin = dc.GetDeviceOrigin(); selectionRect.SetX(-deviceOrigin.x); if(IsSelected()) { DrawSimpleSelection(win, dc, selectionRect, colours); } else if(IsHovered()) { dc.SetPen(colours.GetHoverBgColour()); dc.SetBrush(colours.GetHoverBgColour()); dc.DrawRectangle(selectionRect); } else if(colours.GetItemBgColour().IsOk()) { dc.SetBrush(colours.GetItemBgColour()); dc.SetPen(colours.GetItemBgColour()); dc.DrawRectangle(selectionRect); } // Per cell drawings for(size_t i = 0; i < m_cells.size(); ++i) { bool last_cell = (i == (m_cells.size() - 1)); colours = c; // reset the colours wxFont f = clScrolledPanel::GetDefaultFont(); clCellValue& cell = GetColumn(i); if(cell.GetFont().IsOk()) { f = cell.GetFont(); } if(cell.GetTextColour().IsOk()) { colours.SetItemTextColour(cell.GetTextColour()); } if(cell.GetBgColour().IsOk()) { colours.SetItemBgColour(cell.GetBgColour()); } dc.SetFont(f); wxColour buttonColour = IsSelected() ? colours.GetSelbuttonColour() : colours.GetButtonColour(); wxRect cellRect = GetCellRect(i); // We use a helper class to clip the drawings this ensures that if we exit the scope // the clipping region is restored properly clClipperHelper clipper(dc); if(hasHeader) { clipper.Clip(cellRect); } int textXOffset = cellRect.GetX(); if((i == 0) && !IsListItem()) { // The expand button is only make sense for the first cell if(HasChildren()) { wxRect buttonRect = GetButtonRect(); buttonRect.Deflate(1); textXOffset += buttonRect.GetWidth(); if(m_tree->IsNativeTheme() && !IS_OSX) { int flags = wxCONTROL_CURRENT; if(IsExpanded()) { flags |= wxCONTROL_EXPANDED; } int button_width = wxSystemSettings::GetMetric(wxSYS_SMALLICON_X); wxRect modButtonRect = buttonRect; modButtonRect.SetWidth(button_width); modButtonRect.SetHeight(button_width); modButtonRect = modButtonRect.CenterIn(buttonRect); wxRendererNative::Get().DrawTreeItemButton(win, dc, modButtonRect, flags); } else { wxRect buttonRect = GetButtonRect(); if(textXOffset >= cellRect.GetWidth()) { // if we cant draw the button (off screen etc) SetRects(GetItemRect(), wxRect()); continue; } buttonRect.Deflate((buttonRect.GetWidth() / 3), (buttonRect.GetHeight() / 3)); wxRect tribtn = buttonRect; dc.SetPen(wxPen(buttonColour, 2)); if(IsExpanded()) { tribtn.SetHeight(tribtn.GetHeight() - tribtn.GetHeight() / 2); tribtn = tribtn.CenterIn(buttonRect); wxPoint middleLeft = wxPoint((tribtn.GetLeft() + tribtn.GetWidth() / 2), tribtn.GetBottom()); dc.DrawLine(tribtn.GetTopLeft(), middleLeft); dc.DrawLine(tribtn.GetTopRight(), middleLeft); } else { tribtn.SetWidth(tribtn.GetWidth() - tribtn.GetWidth() / 2); tribtn = tribtn.CenterIn(buttonRect); wxPoint middleLeft = wxPoint(tribtn.GetRight(), (tribtn.GetY() + (tribtn.GetHeight() / 2))); wxPoint p1 = tribtn.GetTopLeft(); wxPoint p2 = tribtn.GetBottomLeft(); dc.DrawLine(p1, middleLeft); dc.DrawLine(middleLeft, p2); } } } else { wxRect buttonRect(rowRect); buttonRect.SetWidth(rowRect.GetHeight()); buttonRect.Deflate(1); textXOffset += buttonRect.GetWidth(); if(textXOffset >= cellRect.GetWidth()) { SetRects(GetItemRect(), wxRect()); continue; } } } int itemIndent = IsListItem() ? clHeaderItem::X_SPACER : (GetIndentsCount() * m_tree->GetIndent()); int bitmapIndex = cell.GetBitmapIndex(); if(IsExpanded() && HasChildren() && cell.GetBitmapSelectedIndex() != wxNOT_FOUND) { bitmapIndex = cell.GetBitmapSelectedIndex(); } // Draw checkbox if(cell.IsBool()) { // Render the checkbox textXOffset += X_SPACER; int checkboxSize = GetCheckBoxWidth(win); wxRect checkboxRect = wxRect(textXOffset, rowRect.GetY(), checkboxSize, checkboxSize); checkboxRect = checkboxRect.CenterIn(rowRect, wxVERTICAL); dc.SetPen(colours.GetItemTextColour()); RenderCheckBox(win, dc, colours, checkboxRect, cell.GetValueBool()); cell.SetCheckboxRect(checkboxRect); textXOffset += checkboxRect.GetWidth(); textXOffset += X_SPACER; } else { cell.SetCheckboxRect(wxRect()); // clear the checkbox rect } // Draw the bitmap if(bitmapIndex != wxNOT_FOUND) { const wxBitmap& bmp = m_tree->GetBitmap(bitmapIndex); if(bmp.IsOk()) { textXOffset += IsListItem() ? 0 : X_SPACER; int bitmapY = rowRect.GetY() + ((rowRect.GetHeight() - bmp.GetScaledHeight()) / 2); // if((textXOffset + bmp.GetScaledWidth()) >= cellRect.GetWidth()) { continue; } dc.DrawBitmap(bmp, itemIndent + textXOffset, bitmapY, true); textXOffset += bmp.GetScaledWidth(); textXOffset += X_SPACER; } } // Draw the text wxRect textRect(dc.GetTextExtent(cell.GetValueString())); textRect = textRect.CenterIn(rowRect, wxVERTICAL); int textY = textRect.GetY(); int textX = (i == 0 ? itemIndent : clHeaderItem::X_SPACER) + textXOffset; RenderText(win, dc, colours, cell.GetValueString(), textX, textY, i); textXOffset += textRect.GetWidth(); textXOffset += X_SPACER; if(cell.IsChoice()) { // draw the drop down arrow. Make it aligned to the right wxRect dropDownRect(cellRect.GetTopRight().x - rowRect.GetHeight(), rowRect.GetY(), rowRect.GetHeight(), rowRect.GetHeight()); dropDownRect = dropDownRect.CenterIn(rowRect, wxVERTICAL); DrawingUtils::DrawDropDownArrow(win, dc, dropDownRect, wxNullColour); // Keep the rect to test clicks cell.SetDropDownRect(dropDownRect); textXOffset += dropDownRect.GetWidth(); textXOffset += X_SPACER; // Draw a separator line between the drop down arrow and the rest of the cell content dropDownRect.Deflate(3); dropDownRect = dropDownRect.CenterIn(rowRect, wxVERTICAL); dc.SetPen(wxPen(colours.GetHeaderVBorderColour(), 1, PEN_STYLE)); dc.DrawLine(dropDownRect.GetTopLeft(), dropDownRect.GetBottomLeft()); } else { cell.SetDropDownRect(wxRect()); } if(!last_cell) { cellRect.SetHeight(rowRect.GetHeight()); dc.SetPen(wxPen(colours.GetHeaderVBorderColour(), 1, PEN_STYLE)); dc.DrawLine(cellRect.GetTopRight(), cellRect.GetBottomRight()); } } }