diff --git a/docs/changes.txt b/docs/changes.txt index 92c8605984..1da8b51357 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -116,6 +116,7 @@ All (GUI): - Support strike-through in wxDataViewItem attributes (approach, Igor Korot). - Allow distinguishing between user- and script-opened windows in wxWebView. - Allow binding to events generated by their items in submenus too. +- Add wxGrid::SetCornerLabelValue() (Pavel Kalugin). wxGTK: diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index 61b0605bcd..84e283154d 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -325,28 +325,17 @@ protected: // wxGridHeaderRenderer and company: like wxGridCellRenderer but for headers // ---------------------------------------------------------------------------- -// Base class for corner window renderer: it is the simplest of all renderers -// and only has a single function -class WXDLLIMPEXP_CORE wxGridCornerHeaderRenderer +// Base class for header cells renderers. +class WXDLLIMPEXP_CORE wxGridHeaderLabelsRenderer { public: - // Draw the border around the corner window. + virtual ~wxGridHeaderLabelsRenderer() {} + + // Draw the border around cell window. virtual void DrawBorder(const wxGrid& grid, wxDC& dc, wxRect& rect) const = 0; - // make the dtor of a class with virtual functions virtual to avoid g++ - // warnings, even though this class is not supposed to be used - // polymorphically - virtual ~wxGridCornerHeaderRenderer() { } -}; - - -// Base class for the row/column header cells renderers -class WXDLLIMPEXP_CORE wxGridHeaderLabelsRenderer - : public wxGridCornerHeaderRenderer -{ -public: // Draw header cell label virtual void DrawLabel(const wxGrid& grid, wxDC& dc, @@ -371,6 +360,11 @@ class WXDLLIMPEXP_CORE wxGridColumnHeaderRenderer { }; +class WXDLLIMPEXP_CORE wxGridCornerHeaderRenderer + : public wxGridHeaderLabelsRenderer +{ +}; + // Also define the default renderers which are used by wxGridCellAttrProvider // by default class WXDLLIMPEXP_CORE wxGridRowHeaderRendererDefault @@ -745,8 +739,10 @@ public: virtual wxString GetRowLabelValue( int row ); virtual wxString GetColLabelValue( int col ); + virtual wxString GetCornerLabelValue() const; virtual void SetRowLabelValue( int WXUNUSED(row), const wxString& ) {} virtual void SetColLabelValue( int WXUNUSED(col), const wxString& ) {} + virtual void SetCornerLabelValue( const wxString& ) {} // Attribute handling // @@ -870,8 +866,10 @@ public: void SetRowLabelValue( int row, const wxString& ) wxOVERRIDE; void SetColLabelValue( int col, const wxString& ) wxOVERRIDE; + void SetCornerLabelValue( const wxString& ) wxOVERRIDE; wxString GetRowLabelValue( int row ) wxOVERRIDE; wxString GetColLabelValue( int col ) wxOVERRIDE; + wxString GetCornerLabelValue() const wxOVERRIDE; private: wxGridStringArray m_data; @@ -888,6 +886,8 @@ private: wxArrayString m_rowLabels; wxArrayString m_colLabels; + wxString m_cornerLabel; + wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxGridStringTable); }; @@ -1223,9 +1223,12 @@ public: wxFont GetLabelFont() const { return m_labelFont; } void GetRowLabelAlignment( int *horiz, int *vert ) const; void GetColLabelAlignment( int *horiz, int *vert ) const; + void GetCornerLabelAlignment( int *horiz, int *vert ) const; int GetColLabelTextOrientation() const; + int GetCornerLabelTextOrientation() const; wxString GetRowLabelValue( int row ) const; wxString GetColLabelValue( int col ) const; + wxString GetCornerLabelValue() const; wxColour GetCellHighlightColour() const { return m_cellHighlightColour; } int GetCellHighlightPenWidth() const { return m_cellHighlightPenWidth; } @@ -1247,9 +1250,12 @@ public: void SetLabelFont( const wxFont& ); void SetRowLabelAlignment( int horiz, int vert ); void SetColLabelAlignment( int horiz, int vert ); + void SetCornerLabelAlignment( int horiz, int vert ); void SetColLabelTextOrientation( int textOrientation ); + void SetCornerLabelTextOrientation( int textOrientation ); void SetRowLabelValue( int row, const wxString& ); void SetColLabelValue( int col, const wxString& ); + void SetCornerLabelValue( const wxString& ); void SetCellHighlightColour( const wxColour& ); void SetCellHighlightPenWidth(int width); void SetCellHighlightROPenWidth(int width); @@ -1970,6 +1976,9 @@ protected: int m_colLabelHorizAlign; int m_colLabelVertAlign; int m_colLabelTextOrientation; + int m_cornerLabelHorizAlign; + int m_cornerLabelVertAlign; + int m_cornerLabelTextOrientation; bool m_defaultRowLabelValues; bool m_defaultColLabelValues; diff --git a/interface/wx/grid.h b/interface/wx/grid.h index 5db6d6149c..1546607b5d 100644 --- a/interface/wx/grid.h +++ b/interface/wx/grid.h @@ -1012,20 +1012,18 @@ protected: }; /** - Base class for corner window renderer. + Base class for header cells renderers. - This is the simplest of all header renderers and only has a single - function. - - @see wxGridCellAttrProvider::GetCornerRenderer() + A cell renderer can be used to draw the text of a cell's label, and/or + the border around it. @since 2.9.1 */ -class wxGridCornerHeaderRenderer +class wxGridHeaderLabelsRenderer { public: /** - Called by the grid to draw the corner window border. + Called by the grid to draw the border around the cell header. This method is responsible for drawing the border inside the given @a rect and adjusting the rectangle size to correspond to the area inside @@ -1033,7 +1031,7 @@ public: border width. @param grid - The grid whose corner window is being drawn. + The grid whose header cell window is being drawn. @param dc The device context to use for drawing. @param rect @@ -1044,23 +1042,11 @@ public: virtual void DrawBorder(const wxGrid& grid, wxDC& dc, wxRect& rect) const = 0; -}; -/** - Common base class for row and column headers renderers. - - @see wxGridColumnHeaderRenderer, wxGridRowHeaderRenderer - - @since 2.9.1 - */ -class wxGridHeaderLabelsRenderer : public wxGridCornerHeaderRenderer -{ -public: /** Called by the grid to draw the specified label. - Notice that the base class DrawBorder() method is called before this - one. + Notice that the DrawBorder() method is called before this one. The default implementation uses wxGrid::GetLabelTextColour() and wxGrid::GetLabelFont() to draw the label. @@ -1078,7 +1064,8 @@ public: Base class for row headers renderer. This is the same as wxGridHeaderLabelsRenderer currently but we still use a - separate class for it to distinguish it from wxGridColumnHeaderRenderer. + separate class for it to distinguish it from wxGridColumnHeaderRenderer + and wxGridCornerHeaderRenderer. @see wxGridRowHeaderRendererDefault @@ -1094,7 +1081,8 @@ class wxGridRowHeaderRenderer : public wxGridHeaderLabelsRenderer Base class for column headers renderer. This is the same as wxGridHeaderLabelsRenderer currently but we still use a - separate class for it to distinguish it from wxGridRowHeaderRenderer. + separate class for it to distinguish it from wxGridRowHeaderRenderer and + wxGridCornerHeaderRenderer. @see wxGridColumnHeaderRendererDefault @@ -1106,6 +1094,23 @@ class wxGridColumnHeaderRenderer : public wxGridHeaderLabelsRenderer { }; +/** + Base class for corner header renderer. + + This is the same as wxGridHeaderLabelsRenderer currently but we still use a + separate class for it to distinguish it from wxGridRowHeaderRenderer and + wxGridColumnHeaderRenderer. + + @see wxGridCornerHeaderRendererDefault + + @see wxGridCellAttrProvider::GetCornerRenderer() + + @since 2.9.1 + */ +class wxGridCornerHeaderRenderer : public wxGridHeaderLabelsRenderer +{ +}; + /** Default row header renderer. @@ -1113,7 +1118,7 @@ class wxGridColumnHeaderRenderer : public wxGridHeaderLabelsRenderer methods (i.e. either DrawLabel() or DrawBorder()) but continue to use the default implementation for the other one. - @see wxGridColumnHeaderRendererDefault + @see wxGridColumnHeaderRendererDefault, wxGridCornerHeaderRendererDefault @since 2.9.1 */ @@ -1129,7 +1134,7 @@ public: /** Default column header renderer. - @see wxGridRowHeaderRendererDefault + @see wxGridRowHeaderRendererDefault, wxGridCornerHeaderRendererDefault @since 2.9.1 */ @@ -1393,8 +1398,10 @@ public: void SetRowLabelValue( int row, const wxString& ); void SetColLabelValue( int col, const wxString& ); + void SetCornerLabelValue( const wxString& ); wxString GetRowLabelValue( int row ); wxString GetColLabelValue( int col ); + wxString GetCornerLabelValue() const; }; /** @@ -1769,13 +1776,19 @@ public: //@} /*! - @name Table Row and Column Labels + @name Table Row, Column and Corner Labels By default the numbers are used for labelling rows and Latin letters for labelling columns. If the table has more than 26 columns, the pairs of letters are used starting from the 27-th one and so on, i.e. the sequence of labels is A, B, ..., Z, AA, AB, ..., AZ, BA, ..., ..., ZZ, AAA, ... + + A cell in the top-left corner of a grid can also have a label. It is + empty by default. Use wxGrid::SetCornerLabelValue() to set it and + wxGrid::GetCornerLabelValue() to get its' current value. + + @see wxGridTableBase::GetCornerLabelValue, wxGridTableBase::SetCornerLabelValue */ //@{ @@ -1789,6 +1802,13 @@ public: */ virtual wxString GetColLabelValue(int col); + /** + Return the label of the grid's corner. + + @since 3.1.2 + */ + virtual wxString GetCornerLabelValue() const; + /** Set the given label for the specified row. @@ -1803,6 +1823,17 @@ public: */ virtual void SetColLabelValue(int col, const wxString& label); + /** + Set the given label for the grid's corner. + + The default version does nothing, i.e. the label is not stored. You + must override this method in your derived class if you wish + wxGrid::GetCornerLabelValue() to work. + + @since 3.1.2 + */ + virtual void SetCornerLabelValue( const wxString& ); + //@} @@ -2341,6 +2372,34 @@ public: */ wxString GetColLabelValue(int col) const; + /** + Sets the arguments to the current corner label alignment values. + + Horizontal alignment will be one of @c wxALIGN_LEFT, @c wxALIGN_CENTRE + or @c wxALIGN_RIGHT. + + Vertical alignment will be one of @c wxALIGN_TOP, @c wxALIGN_CENTRE or + @c wxALIGN_BOTTOM. + + @since 3.1.2 + */ + void GetCornerLabelAlignment( int *horiz, int *vert ) const; + + /** + Returns the orientation of the corner label (either @c wxHORIZONTAL or + @c wxVERTICAL). + + @since 3.1.2 + */ + int GetCornerLabelTextOrientation() const; + + /** + Returns the (top-left) corner label. + + @since 3.1.2 + */ + wxString GetCornerLabelValue() const; + /** Returns the colour used for the background of row and column labels. */ @@ -2413,6 +2472,35 @@ public: */ void SetColLabelValue(int col, const wxString& value); + /** + Sets the horizontal and vertical alignment of the (top-left) corner label text. + + Horizontal alignment should be one of @c wxALIGN_LEFT, + @c wxALIGN_CENTRE or @c wxALIGN_RIGHT. Vertical alignment should be one + of @c wxALIGN_TOP, @c wxALIGN_CENTRE or @c wxALIGN_BOTTOM. + + @since 3.1.2 + */ + void SetCornerLabelAlignment( int horiz, int vert ); + + /** + Sets the orientation of the (top-left) corner label (either @c wxHORIZONTAL or + @c wxVERTICAL). + + @since 3.1.2 + */ + void SetCornerLabelTextOrientation( int textOrientation ); + + /** + Set the value for the (top-left) corner label. + + If you are using a custom grid table you must override + wxGridTableBase::SetCornerLabelValue() for this to have any effect. + + @since 3.1.2 + */ + void SetCornerLabelValue( const wxString& ); + /** Sets the background colour for row and column labels. */ diff --git a/samples/grid/griddemo.cpp b/samples/grid/griddemo.cpp index 774efad4b3..52fac38477 100644 --- a/samples/grid/griddemo.cpp +++ b/samples/grid/griddemo.cpp @@ -172,12 +172,16 @@ wxBEGIN_EVENT_TABLE( GridFrame, wxFrame ) EVT_MENU( ID_ROWLABELVERTALIGN, GridFrame::SetRowLabelVertAlignment ) EVT_MENU( ID_COLLABELHORIZALIGN, GridFrame::SetColLabelHorizAlignment ) EVT_MENU( ID_COLLABELVERTALIGN, GridFrame::SetColLabelVertAlignment ) + EVT_MENU( ID_CORNERLABELHORIZALIGN, GridFrame::SetCornerLabelHorizAlignment ) + EVT_MENU( ID_CORNERLABELVERTALIGN, GridFrame::SetCornerLabelVertAlignment ) + EVT_MENU( ID_CORNERLABELORIENTATION, GridFrame::ToggleCornerLabelOrientation ) EVT_MENU( ID_GRIDLINECOLOUR, GridFrame::SetGridLineColour ) EVT_MENU( ID_INSERTROW, GridFrame::InsertRow ) EVT_MENU( ID_INSERTCOL, GridFrame::InsertCol ) EVT_MENU( ID_DELETEROW, GridFrame::DeleteSelectedRows ) EVT_MENU( ID_DELETECOL, GridFrame::DeleteSelectedCols ) EVT_MENU( ID_CLEARGRID, GridFrame::ClearGrid ) + EVT_MENU( ID_SETCORNERLABEL, GridFrame::SetCornerLabelValue ) EVT_MENU( ID_SHOWSEL, GridFrame::ShowSelection ) EVT_MENU( ID_SELCELLS, GridFrame::SelectCells ) EVT_MENU( ID_SELROWS, GridFrame::SelectRows ) @@ -321,6 +325,16 @@ GridFrame::GridFrame() colLabelMenu->AppendRadioItem( ID_COLLABELHORIZALIGN, wxT("&Horizontal") ); colLabelMenu->AppendRadioItem( ID_COLLABELVERTALIGN, wxT("&Vertical") ); + wxMenu *cornerLabelMenu = new wxMenu; + viewMenu->Append( ID_CORNERLABELALIGN, wxT("Corner label alignment"), + cornerLabelMenu, + wxT("Change alignment of corner label") ); + + cornerLabelMenu->AppendRadioItem( ID_CORNERLABELHORIZALIGN, wxT("&Horizontal") ); + cornerLabelMenu->AppendRadioItem( ID_CORNERLABELVERTALIGN, wxT("&Vertical") ); + + viewMenu->Append( ID_CORNERLABELORIENTATION, wxT("Toggle corner label orientation") ); + wxMenu *colHeaderMenu = new wxMenu; viewMenu->Append( ID_ROWLABELALIGN, wxT("Col header style"), @@ -352,6 +366,7 @@ GridFrame::GridFrame() editMenu->Append( ID_DELETEROW, wxT("Delete selected ro&ws") ); editMenu->Append( ID_DELETECOL, wxT("Delete selected co&ls") ); editMenu->Append( ID_CLEARGRID, wxT("Cl&ear grid cell contents") ); + editMenu->Append( ID_SETCORNERLABEL, wxT("&Set corner label...") ); wxMenu *selectMenu = new wxMenu; selectMenu->Append( ID_SELECT_UNSELECT, wxT("Add new cells to the selection"), @@ -920,6 +935,73 @@ void GridFrame::SetColLabelVertAlignment( wxCommandEvent& WXUNUSED(ev) ) } +void GridFrame::SetCornerLabelHorizAlignment( wxCommandEvent& WXUNUSED(ev) ) +{ + int horiz, vert; + grid->GetCornerLabelAlignment( &horiz, &vert ); + + switch ( horiz ) + { + case wxALIGN_LEFT: + horiz = wxALIGN_CENTRE; + break; + + case wxALIGN_CENTRE: + horiz = wxALIGN_RIGHT; + break; + + case wxALIGN_RIGHT: + horiz = wxALIGN_LEFT; + break; + } + + grid->SetCornerLabelAlignment( horiz, vert ); +} + + +void GridFrame::SetCornerLabelVertAlignment( wxCommandEvent& WXUNUSED(ev) ) +{ + int horiz, vert; + grid->GetCornerLabelAlignment( &horiz, &vert ); + + switch ( vert ) + { + case wxALIGN_TOP: + vert = wxALIGN_CENTRE; + break; + + case wxALIGN_CENTRE: + vert = wxALIGN_BOTTOM; + break; + + case wxALIGN_BOTTOM: + vert = wxALIGN_TOP; + break; + } + + grid->SetCornerLabelAlignment( horiz, vert ); +} + + +void GridFrame::ToggleCornerLabelOrientation( wxCommandEvent& WXUNUSED(ev) ) +{ + int orientation = grid->GetCornerLabelTextOrientation(); + + switch(orientation) + { + case wxHORIZONTAL: + orientation = wxVERTICAL; + break; + + case wxVERTICAL: + orientation = wxHORIZONTAL; + break; + } + + grid->SetCornerLabelTextOrientation(orientation); +} + + void GridFrame::SetGridLineColour( wxCommandEvent& WXUNUSED(ev) ) { wxColourDialog dlg( NULL ); @@ -1040,6 +1122,20 @@ void GridFrame::ClearGrid( wxCommandEvent& WXUNUSED(ev) ) grid->ClearGrid(); } +void GridFrame::SetCornerLabelValue( wxCommandEvent& WXUNUSED(ev) ) +{ + wxTextEntryDialog dialog(this, + "Please enter corner label:", + "Please enter a string", + grid->GetCornerLabelValue(), + wxOK | wxCANCEL); + + if (dialog.ShowModal() == wxID_OK) + { + grid->SetCornerLabelValue(dialog.GetValue()); + } +} + void GridFrame::ShowSelection( wxCommandEvent& WXUNUSED(ev) ) { switch ( grid->GetSelectionMode() ) diff --git a/samples/grid/griddemo.h b/samples/grid/griddemo.h index 30c1a85150..c9ce9b924e 100644 --- a/samples/grid/griddemo.h +++ b/samples/grid/griddemo.h @@ -54,6 +54,9 @@ class GridFrame : public wxFrame void SetRowLabelVertAlignment( wxCommandEvent& ); void SetColLabelHorizAlignment( wxCommandEvent& ); void SetColLabelVertAlignment( wxCommandEvent& ); + void SetCornerLabelHorizAlignment( wxCommandEvent& ); + void SetCornerLabelVertAlignment( wxCommandEvent& ); + void ToggleCornerLabelOrientation( wxCommandEvent& ); void SetGridLineColour( wxCommandEvent& ); void SetCellFgColour(wxCommandEvent &); @@ -64,6 +67,7 @@ class GridFrame : public wxFrame void DeleteSelectedRows( wxCommandEvent& ); void DeleteSelectedCols( wxCommandEvent& ); void ClearGrid( wxCommandEvent& ); + void SetCornerLabelValue( wxCommandEvent& ); void ShowSelection( wxCommandEvent& ); void SelectCells( wxCommandEvent& ); void SelectRows( wxCommandEvent& ); @@ -152,6 +156,10 @@ public: ID_COLLABELALIGN, ID_COLLABELHORIZALIGN, ID_COLLABELVERTALIGN, + ID_CORNERLABELALIGN, + ID_CORNERLABELHORIZALIGN, + ID_CORNERLABELVERTALIGN, + ID_CORNERLABELORIENTATION, ID_COLDEFAULTHEADER, ID_COLNATIVEHEADER, ID_COLCUSTOMHEADER, @@ -165,6 +173,7 @@ public: ID_DELETEROW, ID_DELETECOL, ID_CLEARGRID, + ID_SETCORNERLABEL, ID_SHOWSEL, ID_CHANGESEL, ID_SELCELLS, diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 2f01b2f667..f6993de388 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -220,12 +220,12 @@ wxGridCellWorker::~wxGridCellWorker() // ---------------------------------------------------------------------------- void wxGridHeaderLabelsRenderer::DrawLabel(const wxGrid& grid, - wxDC& dc, - const wxString& value, - const wxRect& rect, - int horizAlign, - int vertAlign, - int textOrientation) const + wxDC& dc, + const wxString& value, + const wxRect& rect, + int horizAlign, + int vertAlign, + int textOrientation) const { dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT); dc.SetTextForeground(grid.GetLabelTextColour()); @@ -1167,6 +1167,11 @@ wxString wxGridTableBase::GetColLabelValue( int col ) return s2; } +wxString wxGridTableBase::GetCornerLabelValue() const +{ + return wxString(); +} + wxString wxGridTableBase::GetTypeName( int WXUNUSED(row), int WXUNUSED(col) ) { return wxGRID_VALUE_STRING; @@ -1600,6 +1605,15 @@ void wxGridStringTable::SetColLabelValue( int col, const wxString& value ) m_colLabels[col] = value; } +void wxGridStringTable::SetCornerLabelValue( const wxString& value ) +{ + m_cornerLabel = value; +} + +wxString wxGridStringTable::GetCornerLabelValue() const +{ + return m_cornerLabel; +} ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// @@ -2440,6 +2454,10 @@ void wxGrid::Init() m_colLabelVertAlign = wxALIGN_CENTRE; m_colLabelTextOrientation = wxHORIZONTAL; + m_cornerLabelHorizAlign = wxALIGN_CENTRE; + m_cornerLabelVertAlign = wxALIGN_CENTRE; + m_cornerLabelTextOrientation = wxHORIZONTAL; + m_defaultColWidth = WXGRID_DEFAULT_COL_WIDTH; m_defaultRowHeight = 0; // this will be initialized after creation @@ -5919,6 +5937,13 @@ void wxGrid::DrawCornerLabel(wxDC& dc) { wxRect rect(wxSize(m_rowLabelWidth, m_colLabelHeight)); + wxGridCellAttrProvider * const + attrProvider = m_table ? m_table->GetAttrProvider() : NULL; + const wxGridCornerHeaderRenderer& + rend = attrProvider ? attrProvider->GetCornerRenderer() + : static_cast + (gs_defaultHeaderRenderers.cornerRenderer); + if ( m_nativeColumnLabels ) { rect.Deflate(1); @@ -5930,15 +5955,18 @@ void wxGrid::DrawCornerLabel(wxDC& dc) rect.width++; rect.height++; - wxGridCellAttrProvider * const - attrProvider = m_table ? m_table->GetAttrProvider() : NULL; - const wxGridCornerHeaderRenderer& - rend = attrProvider ? attrProvider->GetCornerRenderer() - : static_cast - (gs_defaultHeaderRenderers.cornerRenderer); - rend.DrawBorder(*this, dc, rect); } + + wxString label = GetCornerLabelValue(); + if( !label.IsEmpty() ) + { + int hAlign, vAlign; + GetCornerLabelAlignment(&hAlign, &vAlign); + const int orient = GetCornerLabelTextOrientation(); + + rend.DrawLabel(*this, dc, label, rect, hAlign, vAlign, orient); + } } void wxGrid::DrawColLabel(wxDC& dc, int col) @@ -7043,6 +7071,19 @@ int wxGrid::GetColLabelTextOrientation() const 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 { if ( m_table ) @@ -7071,6 +7112,18 @@ wxString wxGrid::GetColLabelValue( int col ) const } } +wxString wxGrid::GetCornerLabelValue() const +{ + if ( m_table ) + { + return m_table->GetCornerLabelValue(); + } + else + { + return wxString(); + } +} + void wxGrid::SetRowLabelSize( int width ) { wxASSERT( width >= 0 || width == wxGRID_AUTOSIZE ); @@ -7238,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 // does not support vertical printing // @@ -7254,6 +7340,15 @@ void wxGrid::SetColLabelTextOrientation( int textOrientation ) 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 ) { if ( m_table ) @@ -7299,6 +7394,19 @@ void wxGrid::SetColLabelValue( int col, const wxString& s ) } } +void wxGrid::SetCornerLabelValue( const wxString& s ) +{ + if ( m_table ) + { + m_table->SetCornerLabelValue( s ); + if ( !GetBatchCount() ) + { + wxRect rect = m_cornerLabelWin->GetRect(); + m_cornerLabelWin->Refresh(true, &rect); + } + } +} + void wxGrid::SetGridLineColour( const wxColour& colour ) { if ( m_gridLineColour != colour )