diff --git a/include/wx/dataview.h b/include/wx/dataview.h index e2dec89538..c2db8eef48 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -114,7 +114,7 @@ public: virtual void Resort() = 0; void SetOwner( wxDataViewModel *owner ) { m_owner = owner; } - wxDataViewModel *GetOwner() { return m_owner; } + wxDataViewModel *GetOwner() const { return m_owner; } private: wxDataViewModel *m_owner; @@ -418,7 +418,7 @@ public: { return true; } void SetOwner( wxDataViewColumn *owner ) { m_owner = owner; } - wxDataViewColumn* GetOwner() { return m_owner; } + wxDataViewColumn* GetOwner() const { return m_owner; } // renderer properties: diff --git a/include/wx/generic/dataview.h b/include/wx/generic/dataview.h index d48a6f050e..6b14e807a3 100644 --- a/include/wx/generic/dataview.h +++ b/include/wx/generic/dataview.h @@ -41,10 +41,8 @@ public: virtual bool Render( wxRect cell, wxDC *dc, int state ) = 0; virtual wxSize GetSize() const = 0; - virtual void SetAlignment( int align ) - { m_align=align; } - virtual int GetAlignment() const - { return m_align; } + virtual void SetAlignment( int align ); + virtual int GetAlignment() const; virtual void SetMode( wxDataViewCellMode mode ) { m_mode=mode; } @@ -83,6 +81,9 @@ public: void SetAttr( const wxDataViewItemAttr &attr ) { m_attr = attr; } bool GetWantsAttr() { return m_wantsAttr; } + // implementation + int CalculateAlignment() const; + private: wxDC *m_dc; int m_align; diff --git a/interface/dataview.h b/interface/dataview.h index 1ed5ed5829..e09f63f0ee 100644 --- a/interface/dataview.h +++ b/interface/dataview.h @@ -1026,7 +1026,7 @@ public: /** Get owning wxDataViewModel. */ - wxDataViewModel* GetOwner(); + wxDataViewModel* GetOwner() const; /** Called by owning model. @@ -1159,7 +1159,7 @@ public: /** Returns pointer to the owning wxDataViewColumn. */ - virtual wxDataViewColumn* GetOwner(); + virtual wxDataViewColumn* GetOwner() const; /** This methods retrieves the value from the renderer in order to @@ -1574,7 +1574,7 @@ public: /** Returns the owning wxDataViewCtrl. */ - wxDataViewCtrl* GetOwner(); + wxDataViewCtrl* GetOwner() const; /** Returns the renderer of this wxDataViewColumn. diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index bd6a350ed8..db167505f1 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -641,6 +641,29 @@ wxDC *wxDataViewRenderer::GetDC() return m_dc; } +void wxDataViewRenderer::SetAlignment( int align ) +{ + m_align=align; +} + +int wxDataViewRenderer::GetAlignment() const +{ + return m_align; +} + +int wxDataViewRenderer::CalculateAlignment() const +{ + if (m_align == wxDVR_DEFAULT_ALIGNMENT) + { + if (GetOwner() == NULL) + return wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL; + + return GetOwner()->GetAlignment() | wxALIGN_CENTRE_VERTICAL; + } + + return m_align; +} + // --------------------------------------------------------- // wxDataViewCustomRenderer // --------------------------------------------------------- @@ -2214,7 +2237,7 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) ) size.y = cell_rect.height; wxRect item_rect(cell_rect.GetTopLeft(), size); - int align = cell->GetAlignment(); + int align = cell->CalculateAlignment(); // horizontal alignment: item_rect.x = cell_rect.x;