Add text alignment and orientation support for corner label
This commit is contained in:
@@ -1223,7 +1223,9 @@ public:
|
|||||||
wxFont GetLabelFont() const { return m_labelFont; }
|
wxFont GetLabelFont() const { return m_labelFont; }
|
||||||
void GetRowLabelAlignment( int *horiz, int *vert ) const;
|
void GetRowLabelAlignment( int *horiz, int *vert ) const;
|
||||||
void GetColLabelAlignment( int *horiz, int *vert ) const;
|
void GetColLabelAlignment( int *horiz, int *vert ) const;
|
||||||
|
void GetCornerLabelAlignment( int *horiz, int *vert ) const;
|
||||||
int GetColLabelTextOrientation() const;
|
int GetColLabelTextOrientation() const;
|
||||||
|
int GetCornerLabelTextOrientation() const;
|
||||||
wxString GetRowLabelValue( int row ) const;
|
wxString GetRowLabelValue( int row ) const;
|
||||||
wxString GetColLabelValue( int col ) const;
|
wxString GetColLabelValue( int col ) const;
|
||||||
wxString GetCornerLabelValue() const;
|
wxString GetCornerLabelValue() const;
|
||||||
@@ -1248,7 +1250,9 @@ public:
|
|||||||
void SetLabelFont( const wxFont& );
|
void SetLabelFont( const wxFont& );
|
||||||
void SetRowLabelAlignment( int horiz, int vert );
|
void SetRowLabelAlignment( int horiz, int vert );
|
||||||
void SetColLabelAlignment( int horiz, int vert );
|
void SetColLabelAlignment( int horiz, int vert );
|
||||||
|
void SetCornerLabelAlignment( int horiz, int vert );
|
||||||
void SetColLabelTextOrientation( int textOrientation );
|
void SetColLabelTextOrientation( int textOrientation );
|
||||||
|
void SetCornerLabelTextOrientation( int textOrientation );
|
||||||
void SetRowLabelValue( int row, const wxString& );
|
void SetRowLabelValue( int row, const wxString& );
|
||||||
void SetColLabelValue( int col, const wxString& );
|
void SetColLabelValue( int col, const wxString& );
|
||||||
void SetCornerLabelValue( const wxString& );
|
void SetCornerLabelValue( const wxString& );
|
||||||
@@ -1972,6 +1976,9 @@ protected:
|
|||||||
int m_colLabelHorizAlign;
|
int m_colLabelHorizAlign;
|
||||||
int m_colLabelVertAlign;
|
int m_colLabelVertAlign;
|
||||||
int m_colLabelTextOrientation;
|
int m_colLabelTextOrientation;
|
||||||
|
int m_cornerLabelHorizAlign;
|
||||||
|
int m_cornerLabelVertAlign;
|
||||||
|
int m_cornerLabelTextOrientation;
|
||||||
|
|
||||||
bool m_defaultRowLabelValues;
|
bool m_defaultRowLabelValues;
|
||||||
bool m_defaultColLabelValues;
|
bool m_defaultColLabelValues;
|
||||||
|
@@ -2454,6 +2454,10 @@ void wxGrid::Init()
|
|||||||
m_colLabelVertAlign = wxALIGN_CENTRE;
|
m_colLabelVertAlign = wxALIGN_CENTRE;
|
||||||
m_colLabelTextOrientation = wxHORIZONTAL;
|
m_colLabelTextOrientation = wxHORIZONTAL;
|
||||||
|
|
||||||
|
m_cornerLabelHorizAlign = wxALIGN_CENTRE;
|
||||||
|
m_cornerLabelVertAlign = wxALIGN_CENTRE;
|
||||||
|
m_cornerLabelTextOrientation = wxHORIZONTAL;
|
||||||
|
|
||||||
m_defaultColWidth = WXGRID_DEFAULT_COL_WIDTH;
|
m_defaultColWidth = WXGRID_DEFAULT_COL_WIDTH;
|
||||||
m_defaultRowHeight = 0; // this will be initialized after creation
|
m_defaultRowHeight = 0; // this will be initialized after creation
|
||||||
|
|
||||||
@@ -5957,10 +5961,9 @@ void wxGrid::DrawCornerLabel(wxDC& dc)
|
|||||||
wxString label = GetCornerLabelValue();
|
wxString label = GetCornerLabelValue();
|
||||||
if( !label.IsEmpty() )
|
if( !label.IsEmpty() )
|
||||||
{
|
{
|
||||||
// TODO: add alignment and orientation support for corner window.
|
|
||||||
int hAlign, vAlign;
|
int hAlign, vAlign;
|
||||||
GetColLabelAlignment(&hAlign, &vAlign);
|
GetCornerLabelAlignment(&hAlign, &vAlign);
|
||||||
const int orient = GetColLabelTextOrientation();
|
const int orient = GetCornerLabelTextOrientation();
|
||||||
|
|
||||||
rend.DrawLabel(*this, dc, label, rect, hAlign, vAlign, orient);
|
rend.DrawLabel(*this, dc, label, rect, hAlign, vAlign, orient);
|
||||||
}
|
}
|
||||||
@@ -7068,6 +7071,19 @@ int wxGrid::GetColLabelTextOrientation() const
|
|||||||
return m_colLabelTextOrientation;
|
return m_colLabelTextOrientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxGrid::GetCornerLabelAlignment( int *horiz, int *vert ) const
|
||||||
|
{
|
||||||
|
if ( horiz )
|
||||||
|
*horiz = m_cornerLabelHorizAlign;
|
||||||
|
if ( vert )
|
||||||
|
*vert = m_cornerLabelVertAlign;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxGrid::GetCornerLabelTextOrientation() const
|
||||||
|
{
|
||||||
|
return m_cornerLabelTextOrientation;
|
||||||
|
}
|
||||||
|
|
||||||
wxString wxGrid::GetRowLabelValue( int row ) const
|
wxString wxGrid::GetRowLabelValue( int row ) const
|
||||||
{
|
{
|
||||||
if ( m_table )
|
if ( m_table )
|
||||||
@@ -7275,6 +7291,39 @@ void wxGrid::SetColLabelAlignment( int horiz, int vert )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxGrid::SetCornerLabelAlignment( int horiz, int vert )
|
||||||
|
{
|
||||||
|
// allow old (incorrect) defs to be used
|
||||||
|
switch ( horiz )
|
||||||
|
{
|
||||||
|
case wxLEFT: horiz = wxALIGN_LEFT; break;
|
||||||
|
case wxRIGHT: horiz = wxALIGN_RIGHT; break;
|
||||||
|
case wxCENTRE: horiz = wxALIGN_CENTRE; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ( vert )
|
||||||
|
{
|
||||||
|
case wxTOP: vert = wxALIGN_TOP; break;
|
||||||
|
case wxBOTTOM: vert = wxALIGN_BOTTOM; break;
|
||||||
|
case wxCENTRE: vert = wxALIGN_CENTRE; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( horiz == wxALIGN_LEFT || horiz == wxALIGN_CENTRE || horiz == wxALIGN_RIGHT )
|
||||||
|
{
|
||||||
|
m_cornerLabelHorizAlign = horiz;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( vert == wxALIGN_TOP || vert == wxALIGN_CENTRE || vert == wxALIGN_BOTTOM )
|
||||||
|
{
|
||||||
|
m_cornerLabelVertAlign = vert;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !GetBatchCount() )
|
||||||
|
{
|
||||||
|
m_cornerLabelWin->Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Note: under MSW, the default column label font must be changed because it
|
// Note: under MSW, the default column label font must be changed because it
|
||||||
// does not support vertical printing
|
// does not support vertical printing
|
||||||
//
|
//
|
||||||
@@ -7291,6 +7340,15 @@ void wxGrid::SetColLabelTextOrientation( int textOrientation )
|
|||||||
m_colWindow->Refresh();
|
m_colWindow->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxGrid::SetCornerLabelTextOrientation( int textOrientation )
|
||||||
|
{
|
||||||
|
if ( textOrientation == wxHORIZONTAL || textOrientation == wxVERTICAL )
|
||||||
|
m_cornerLabelTextOrientation = textOrientation;
|
||||||
|
|
||||||
|
if ( !GetBatchCount() )
|
||||||
|
m_cornerLabelWin->Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
void wxGrid::SetRowLabelValue( int row, const wxString& s )
|
void wxGrid::SetRowLabelValue( int row, const wxString& s )
|
||||||
{
|
{
|
||||||
if ( m_table )
|
if ( m_table )
|
||||||
|
Reference in New Issue
Block a user