#15498 closed defect (fixed)

Generic wxDataViewCtrl - Bitmap columns ignore alignment parameter

Reported by: ericj Owned by:
Priority: normal Milestone:
Component: GUI-generic Version: stable-latest
Keywords: wxDataViewCtrl alignment Cc:
Blocked By: Blocking:
Patch: yes

Description

Bitmap columns in wxDataViewCtrl ignore the alignment parameter, the bitmap is always drawn in the upper left corner of the cell.

I'm not 100% sure about the provided fix, the code line was taken from wxDataViewCustomRendererBase::RenderText().

Attachments (3)

dataview_sample_bitmap_alignment_problem.patch download (1.6 KB) - added by ericj 13 months ago.
Patch to the "dataview" sample to demonstrate the problem
dataviewctrl_bitmap_alignment_fix.patch download (576 bytes) - added by ericj 13 months ago.
Potential fix
wxDataViewRendererBase_GetEffectiveAlignment.patch download (1.4 KB) - added by ericj 13 months ago.

Download all attachments as: .zip

Change History (8)

Changed 13 months ago by ericj

Patch to the "dataview" sample to demonstrate the problem

Changed 13 months ago by ericj

Potential fix

comment:1 follow-up: Changed 13 months ago by vadz

I think the fix is correct but I wonder if it wouldn't make sense to change wxDataViewRenderer::GetAlignment() itself to use the column alignment. Do you see any problems with doing it there?

It just seems wrong to always have to implement this fallback in each derived class... But maybe I'm missing some reason for which this wouldn't be a good idea?

comment:2 in reply to: ↑ 1 Changed 13 months ago by ericj

Replying to vadz:

I think the fix is correct but I wonder if it wouldn't make sense to change wxDataViewRenderer::GetAlignment() itself to use the column alignment. Do you see any problems with doing it there?

I have to admit that i didn't try to fully understand the code. I just traced through it a few times till i saw the difference between the text renderer and the bitmap renderer. Maybe we could ask the original author of the code if he's still around.

But as GetAlignment() is the general accessor to the internal variable, maybe it would be safer to have a private GetEffectiveAlignment() or similar that returns the alignment from the owner if needed?

comment:3 Changed 13 months ago by vadz

I like GetEffectiveAlignment(), this should be totally safe.

comment:4 Changed 13 months ago by ericj

Added new patch with new method wxDataViewRendererBase::GetEffectiveAlignment()

comment:5 Changed 13 months ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [74825]) Add wxDataViewRendererBase::GetEffectiveAlignment() and use it.

This helper method falls back on the alignment of the column if the renderer
alignment is not specified. This is almost always what should be used instead
of GetAlignment() to determine the alignment that really should be used in the
drawing code.

In particular, using GetEffectiveAlignment() in wxDataViewCustomRenderer fixes
the problem with bitmap columns ignoring column alignment for their bitmaps.

Closes #15498.

Note: See TracTickets for help on using tickets.