Ejemplo n.º 1
0
bool wxSheetCellAttr::Copy(const wxSheetCellAttr& other) 
{ 
    wxCHECK_MSG(other.Ok(), false, wxT("Attr to copy from is not created"));
    
    if (!Create())
        return false;
    
    M_CELLATTRDATA->m_foreColour = ((wxSheetCellAttrRefData*)other.GetRefData())->m_foreColour;
    M_CELLATTRDATA->m_backColour = ((wxSheetCellAttrRefData*)other.GetRefData())->m_backColour;
    M_CELLATTRDATA->m_font       = ((wxSheetCellAttrRefData*)other.GetRefData())->m_font;
    M_CELLATTRDATA->m_attrTypes  = ((wxSheetCellAttrRefData*)other.GetRefData())->m_attrTypes;
    if (other.HasEditor())
        SetEditor(((wxSheetCellAttrRefData*)other.m_refData)->m_editor->Clone());
    if (other.HasRenderer())
        SetRenderer(((wxSheetCellAttrRefData*)other.m_refData)->m_renderer->Clone());
    
    SetDefaultAttr(other.GetDefaultAttr());
    return true;
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
void wxSheetCellAttr::SetDefaultAttr(const wxSheetCellAttr& defAttr) 
{ 
    wxCHECK_RET(m_refData, wxT("wxSheetCellAttr not initializied"));    
    if (M_CELLATTRDATA->m_defaultAttr)
    {
        delete M_CELLATTRDATA->m_defaultAttr;
        M_CELLATTRDATA->m_defaultAttr = NULL;
    }
    // don't set defAttr to this, you don't gain anything, but a memory leak
    //if (defAttr.Ok() && (defAttr.m_refData != m_refData))
    //    M_CELLATTRDATA->m_defaultAttr = new wxSheetCellAttr(defAttr);
    
    if (defAttr.Ok())
    {
        wxSheetCellAttr attr(defAttr);
        while (attr.Ok())
        {
            wxCHECK_RET((*this) != attr, wxT("wxSheet attributes are linked recursively"));
            attr = attr.GetDefaultAttr();
        }

        M_CELLATTRDATA->m_defaultAttr = new wxSheetCellAttr(defAttr);
    }
}
Ejemplo n.º 4
0
void wxSheetCellAttrProvider::SetAttr(const wxSheetCoords& coords, 
                                      const wxSheetCellAttr &attr, 
                                      wxSheetAttr_Type type)
{
    switch (wxSheet::GetCellCoordsType(coords))
    {
        case wxSHEET_CELL_GRID :
        {
            switch (type)
            {   
                case wxSHEET_AttrCell :
                {
                    if (attr.Ok()) m_cellAttrs.SetValue(coords, attr);
                    else           m_cellAttrs.RemoveValue(coords);            
                    return;
                } 
                case wxSHEET_AttrRow :
                {
                    if (attr.Ok()) m_rowAttrs.SetValue(coords.m_row, attr);
                    else           m_rowAttrs.RemoveValue(coords.m_row);
                    return;
                }
                case wxSHEET_AttrCol :
                {
                    if (attr.Ok()) m_colAttrs.SetValue(coords.m_col, attr);
                    else           m_colAttrs.RemoveValue(coords.m_col);
                    return;
                }
                default :
                {
                    wxFAIL_MSG(wxT("Unhandled attr type for grid coords"));
                    return;
                }
            }
            break;
        }
        case wxSHEET_CELL_ROWLABEL :
        {
            switch (type)
            {
                case wxSHEET_AttrCell :
                {
                    if (attr.Ok()) m_rowLabelAttrs.SetValue(coords.m_row, attr);
                    else           m_rowLabelAttrs.RemoveValue(coords.m_row);
                    return;
                } 
                default : 
                {
                    wxFAIL_MSG(wxT("Unhandled attr type for row label coords"));
                    return;
                }
            }
            break;
        }
        case wxSHEET_CELL_COLLABEL :
        {
            switch (type)
            {
                case wxSHEET_AttrCell :
                {
                    if (attr.Ok()) m_colLabelAttrs.SetValue(coords.m_col, attr);
                    else           m_colLabelAttrs.RemoveValue(coords.m_col);
                    return;
                } 
                default : 
                {
                    wxFAIL_MSG(wxT("Unhandled attr type for col label coords"));
                    return;
                }
            }
            break;
        }
        default :
            wxFAIL_MSG(wxString::Format(wxT("Unhandled coords (%d, %d) in wxSheetCellAttrProvider::SetAttr"), coords.m_row, coords.m_col));
            break;
    }
}