From ba0185b55709e92abe507a0d51afce518767a51f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 27 Nov 2009 01:47:30 +0000 Subject: [PATCH] Add symbolic constant wxALIGN_INVALID and use it instead of -1 in wxGrid. wxGridCellAttr was using literal -1 to indicate "no alignment" which wasn't immediately obvious, use a new wxALIGN_INVALID (which has the same value) instead. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62727 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/defs.h | 5 +++++ include/wx/generic/grid.h | 12 +++++++----- interface/wx/defs.h | 10 ++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/include/wx/defs.h b/include/wx/defs.h index 1155806e24..0769ee204f 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1466,6 +1466,11 @@ enum wxDirection enum wxAlignment { + // 0 is a valid wxAlignment value (both wxALIGN_LEFT and wxALIGN_TOP use + // it) so define a symbolic name for an invalid alignment value which can + // be assumed to be different from anything else + wxALIGN_INVALID = -1, + wxALIGN_NOT = 0x0000, wxALIGN_CENTER_HORIZONTAL = 0x0100, wxALIGN_CENTRE_HORIZONTAL = wxALIGN_CENTER_HORIZONTAL, diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index f2404fcd9d..32c3f39e53 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -388,8 +388,7 @@ public: { Init(attrDefault); - // MB: args used to be 0,0 here but wxALIGN_LEFT is 0 - SetAlignment(-1, -1); + SetAlignment(wxALIGN_INVALID, wxALIGN_INVALID); } // VZ: considering the number of members wxGridCellAttr has now, this ctor @@ -436,7 +435,10 @@ public: bool HasTextColour() const { return m_colText.Ok(); } bool HasBackgroundColour() const { return m_colBack.Ok(); } bool HasFont() const { return m_font.Ok(); } - bool HasAlignment() const { return (m_hAlign != -1 || m_vAlign != -1); } + bool HasAlignment() const + { + return m_hAlign != wxALIGN_INVALID || m_vAlign != wxALIGN_INVALID; + } bool HasRenderer() const { return m_renderer != NULL; } bool HasEditor() const { return m_editor != NULL; } bool HasReadWriteMode() const { return m_isReadOnly != Unset; } @@ -1675,9 +1677,9 @@ public: void SetLabelAlignment( int orientation, int align ) { if ( orientation == wxHORIZONTAL ) - SetColLabelAlignment( align, -1 ); + SetColLabelAlignment( align, wxALIGN_INVALID ); else - SetRowLabelAlignment( align, -1 ); + SetRowLabelAlignment( align, wxALIGN_INVALID ); } int GetLabelAlignment( int orientation, int WXUNUSED(align) ) const diff --git a/interface/wx/defs.h b/interface/wx/defs.h index 21948b99ff..4c8b47a5d6 100644 --- a/interface/wx/defs.h +++ b/interface/wx/defs.h @@ -66,6 +66,16 @@ enum wxDirection */ enum wxAlignment { + /** + A value different from any valid alignment value. + + Note that you shouldn't use 0 for this as it's the value of (valid) + alignments wxALIGN_LEFT and wxALIGN_TOP. + + @since 2.9.1 + */ + wxALIGN_INVALID = -1, + wxALIGN_NOT = 0x0000, wxALIGN_CENTER_HORIZONTAL = 0x0100, wxALIGN_CENTRE_HORIZONTAL = wxALIGN_CENTER_HORIZONTAL, -- 2.45.2