Allow changing horizontal alignment of numeric cells in wxGrid.
wxGridCellAttr didn't provide any way to query its alignment attributes without falling back to the (always defined) default alignment so the code in wxGridCellNumberRenderer and similar classes simply always used right alignment, Add a new wxGridCellAttr::GetNonDefaultAlignment() function which allows to retrieve the alignment defined in the attribute and use it to use right alignment by default but allow overriding it. Add a test to the sample showing a non right-aligned numeric cell. Incidentally fix a long-standing bug in wxGridCell{DateTime,Enum}Renderers which used wxRIGHT instead of wxALIGN_RIGHT and so were not aligned properly even by default. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62728 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -145,9 +145,9 @@ void wxGridCellDateTimeRenderer::Draw(wxGrid& grid,
|
||||
SetTextColoursAndFont(grid, attr, dc, isSelected);
|
||||
|
||||
// draw the text right aligned by default
|
||||
int hAlign, vAlign;
|
||||
attr.GetAlignment(&hAlign, &vAlign);
|
||||
hAlign = wxRIGHT;
|
||||
int hAlign = wxALIGN_RIGHT,
|
||||
vAlign = wxALIGN_INVALID;
|
||||
attr.GetNonDefaultAlignment(&hAlign, &vAlign);
|
||||
|
||||
wxRect rect = rectCell;
|
||||
rect.Inflate(-1);
|
||||
@@ -222,9 +222,9 @@ void wxGridCellEnumRenderer::Draw(wxGrid& grid,
|
||||
SetTextColoursAndFont(grid, attr, dc, isSelected);
|
||||
|
||||
// draw the text right aligned by default
|
||||
int hAlign, vAlign;
|
||||
attr.GetAlignment(&hAlign, &vAlign);
|
||||
hAlign = wxRIGHT;
|
||||
int hAlign = wxALIGN_RIGHT,
|
||||
vAlign = wxALIGN_INVALID;
|
||||
attr.GetNonDefaultAlignment(&hAlign, &vAlign);
|
||||
|
||||
wxRect rect = rectCell;
|
||||
rect.Inflate(-1);
|
||||
@@ -576,9 +576,9 @@ void wxGridCellNumberRenderer::Draw(wxGrid& grid,
|
||||
SetTextColoursAndFont(grid, attr, dc, isSelected);
|
||||
|
||||
// draw the text right aligned by default
|
||||
int hAlign, vAlign;
|
||||
attr.GetAlignment(&hAlign, &vAlign);
|
||||
hAlign = wxALIGN_RIGHT;
|
||||
int hAlign = wxALIGN_RIGHT,
|
||||
vAlign = wxALIGN_INVALID;
|
||||
attr.GetNonDefaultAlignment(&hAlign, &vAlign);
|
||||
|
||||
wxRect rect = rectCell;
|
||||
rect.Inflate(-1);
|
||||
@@ -679,9 +679,9 @@ void wxGridCellFloatRenderer::Draw(wxGrid& grid,
|
||||
SetTextColoursAndFont(grid, attr, dc, isSelected);
|
||||
|
||||
// draw the text right aligned by default
|
||||
int hAlign, vAlign;
|
||||
attr.GetAlignment(&hAlign, &vAlign);
|
||||
hAlign = wxALIGN_RIGHT;
|
||||
int hAlign = wxALIGN_RIGHT,
|
||||
vAlign = wxALIGN_INVALID;
|
||||
attr.GetNonDefaultAlignment(&hAlign, &vAlign);
|
||||
|
||||
wxRect rect = rectCell;
|
||||
rect.Inflate(-1);
|
||||
|
Reference in New Issue
Block a user