Adapt MSW's renderer's alignment to use column header's alignment by default

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53091 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 2008-04-08 11:17:54 +00:00
parent d081739d4e
commit e51bf69961
4 changed files with 34 additions and 10 deletions

View File

@ -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:

View File

@ -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;

View File

@ -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.

View File

@ -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;