void wxSheetCellStringRendererRefData::SetTextColoursAndFont(wxSheet& sheet, const wxSheetCellAttr& attr, wxDC& dc, bool isSelected) { dc.SetBackgroundMode( wxTRANSPARENT ); // TODO some special colours for attr.IsReadOnly() case? // different coloured text when the sheet is disabled if ( sheet.IsEnabled() ) { if ( isSelected ) { dc.SetTextBackground( sheet.GetSelectionBackground() ); dc.SetTextForeground( sheet.GetSelectionForeground() ); } else { dc.SetTextBackground( attr.GetBackgroundColour() ); dc.SetTextForeground( attr.GetForegroundColour() ); } } else { dc.SetTextBackground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT)); } dc.SetFont( attr.GetFont() ); }
void wxSheetCellRendererRefData::Draw( wxSheet& sheet, const wxSheetCellAttr& attr, wxDC& dc, const wxRect& rect, const wxSheetCoords& UNUSE(coords), bool isSelected ) { dc.SetBackgroundMode( wxSOLID ); // grey out fields if the sheet is disabled if ( sheet.IsEnabled() ) { if ( isSelected ) dc.SetBrush( wxBrush(sheet.GetSelectionBackground(), wxSOLID) ); else dc.SetBrush( wxBrush(attr.GetBackgroundColour(), wxSOLID) ); } else dc.SetBrush(wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE), wxSOLID)); dc.SetPen( *wxTRANSPARENT_PEN ); dc.DrawRectangle(rect); #ifdef TEST_SELECTION_BLOCKS // colouring for identifying different blocks if (isSelected) { int i = sheet.GetSelection()->Index(coords); wxColour c(GetRainbow(i*10)); dc.SetBrush( wxBrush(c, wxSOLID) ); dc.DrawRectangle(rect); wxFont font = dc.GetFont(); dc.SetFont(*wxSMALL_FONT); dc.DrawText(wxString::Format(wxT("%d"), i), rect.x, rect.y); } #endif // TEST_SELECTION_BLOCKS //FIXME - border drawing code, maybe it goes here? //dc.SetPen( wxPen(sheet.GetGridLineColour(), 1, wxSOLID) ); //dc.DrawRectangle(rect.x-1, rect.y-1, rect.width+2, rect.height+2); }
bool wxSheetCellAttr::MergeWith(const wxSheetCellAttr &other) { wxCHECK_MSG(Ok() && other.Ok(), false, wxT("this or Attr to MergeWith from is not created")); if ( !HasForegoundColour() && other.HasForegoundColour() ) SetForegroundColour(other.GetForegroundColour()); if ( !HasBackgroundColour() && other.HasBackgroundColour() ) SetBackgroundColour(other.GetBackgroundColour()); if ( !HasFont() && other.HasFont() ) SetFont(other.GetFont()); if ( !HasAlignment() && other.HasAlignment() ) SetAlignment(other.GetAlignment()); if ( !HasOrientation() && other.HasOrientation() ) SetOrientation(other.GetOrientation()); if ( !HasLevel() && other.HasLevel() ) SetLevel(other.GetLevel()); if ( !HasReadWriteMode() && other.HasReadWriteMode() ) SetReadOnly(other.GetReadOnly()); if ( !HasOverflowMode() && other.HasOverflowMode() ) SetOverflow(other.GetOverflow()); if ( !HasOverflowMarkerMode() && other.HasOverflowMarkerMode() ) SetOverflowMarker(other.GetOverflowMarker()); if ( !HasShowEditorMode() && other.HasShowEditorMode() ) SetShowEditor(other.GetShowEditor()); // Directly access m_renderer/m_editor as GetRender/Editor may return different one // Maybe add support for merge of Render and Editor? if ( !HasRenderer() && other.HasRenderer() ) SetRenderer(((wxSheetCellAttrRefData*)other.m_refData)->m_renderer->Clone()); if ( !HasEditor() && other.HasEditor() ) SetEditor(((wxSheetCellAttrRefData*)other.m_refData)->m_editor->Clone()); if ( !HasDefaultAttr() && other.HasDefaultAttr() ) SetDefaultAttr(other.GetDefaultAttr()); return true; }