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:
@@ -527,7 +527,21 @@ public:
|
||||
void DecRef();
|
||||
|
||||
/**
|
||||
See SetAlignment() for the returned values.
|
||||
Get the alignment to use for the cell with the given attribute.
|
||||
|
||||
If this attribute doesn't specify any alignment, the default attribute
|
||||
alignment is used (which can be changed using
|
||||
wxGrid::SetDefaultCellAlignment() but is left and top by default).
|
||||
|
||||
Notice that @a hAlign and @a vAlign values are always overwritten by
|
||||
this function, use GetNonDefaultAlignment() if this is not desirable.
|
||||
|
||||
@param hAlign
|
||||
Horizontal alignment is returned here if this argument is non-@NULL.
|
||||
It is one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT.
|
||||
@param vAlign
|
||||
Vertical alignment is returned here if this argument is non-@NULL.
|
||||
It is one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
|
||||
*/
|
||||
void GetAlignment(int* hAlign, int* vAlign) const;
|
||||
|
||||
@@ -546,6 +560,29 @@ public:
|
||||
*/
|
||||
const wxFont& GetFont() const;
|
||||
|
||||
/**
|
||||
Get the alignment defined by this attribute.
|
||||
|
||||
Unlike GetAlignment() this function only modifies @a hAlign and @a
|
||||
vAlign if this attribute does define a non-default alignment. This
|
||||
means that they must be initialized before calling this function and
|
||||
that their values will be preserved unchanged if they are different
|
||||
from wxALIGN_INVALID.
|
||||
|
||||
For example, the following fragment can be used to use the cell
|
||||
alignment if one is defined but right-align its contents by default
|
||||
(instead of left-aligning it by default) while still using the default
|
||||
vertical alignment:
|
||||
@code
|
||||
int hAlign = wxALIGN_RIGHT,
|
||||
vAlign = wxALIGN_INVALID;
|
||||
attr.GetNonDefaultAlignment(&hAlign, &vAlign);
|
||||
@endcode
|
||||
|
||||
@since 2.9.1
|
||||
*/
|
||||
void GetNonDefaultAlignment(int *hAlign, int *vAlign) const;
|
||||
|
||||
/**
|
||||
Returns the cell renderer.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user