Add corner label alignment command to grid sample

This commit is contained in:
Pavel Kalugin
2018-09-04 17:51:01 +03:00
parent d473d47e7e
commit ccc93c0cd9
2 changed files with 63 additions and 0 deletions

View File

@@ -172,6 +172,8 @@ wxBEGIN_EVENT_TABLE( GridFrame, wxFrame )
EVT_MENU( ID_ROWLABELVERTALIGN, GridFrame::SetRowLabelVertAlignment ) EVT_MENU( ID_ROWLABELVERTALIGN, GridFrame::SetRowLabelVertAlignment )
EVT_MENU( ID_COLLABELHORIZALIGN, GridFrame::SetColLabelHorizAlignment ) EVT_MENU( ID_COLLABELHORIZALIGN, GridFrame::SetColLabelHorizAlignment )
EVT_MENU( ID_COLLABELVERTALIGN, GridFrame::SetColLabelVertAlignment ) EVT_MENU( ID_COLLABELVERTALIGN, GridFrame::SetColLabelVertAlignment )
EVT_MENU( ID_CORNERLABELHORIZALIGN, GridFrame::SetCornerLabelHorizAlignment )
EVT_MENU( ID_CORNERLABELVERTALIGN, GridFrame::SetCornerLabelVertAlignment )
EVT_MENU( ID_GRIDLINECOLOUR, GridFrame::SetGridLineColour ) EVT_MENU( ID_GRIDLINECOLOUR, GridFrame::SetGridLineColour )
EVT_MENU( ID_INSERTROW, GridFrame::InsertRow ) EVT_MENU( ID_INSERTROW, GridFrame::InsertRow )
EVT_MENU( ID_INSERTCOL, GridFrame::InsertCol ) EVT_MENU( ID_INSERTCOL, GridFrame::InsertCol )
@@ -322,6 +324,14 @@ GridFrame::GridFrame()
colLabelMenu->AppendRadioItem( ID_COLLABELHORIZALIGN, wxT("&Horizontal") ); colLabelMenu->AppendRadioItem( ID_COLLABELHORIZALIGN, wxT("&Horizontal") );
colLabelMenu->AppendRadioItem( ID_COLLABELVERTALIGN, wxT("&Vertical") ); 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") );
wxMenu *colHeaderMenu = new wxMenu; wxMenu *colHeaderMenu = new wxMenu;
viewMenu->Append( ID_ROWLABELALIGN, wxT("Col header style"), viewMenu->Append( ID_ROWLABELALIGN, wxT("Col header style"),
@@ -922,6 +932,54 @@ 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::SetGridLineColour( wxCommandEvent& WXUNUSED(ev) ) void GridFrame::SetGridLineColour( wxCommandEvent& WXUNUSED(ev) )
{ {
wxColourDialog dlg( NULL ); wxColourDialog dlg( NULL );

View File

@@ -54,6 +54,8 @@ class GridFrame : public wxFrame
void SetRowLabelVertAlignment( wxCommandEvent& ); void SetRowLabelVertAlignment( wxCommandEvent& );
void SetColLabelHorizAlignment( wxCommandEvent& ); void SetColLabelHorizAlignment( wxCommandEvent& );
void SetColLabelVertAlignment( wxCommandEvent& ); void SetColLabelVertAlignment( wxCommandEvent& );
void SetCornerLabelHorizAlignment( wxCommandEvent& );
void SetCornerLabelVertAlignment( wxCommandEvent& );
void SetGridLineColour( wxCommandEvent& ); void SetGridLineColour( wxCommandEvent& );
void SetCellFgColour(wxCommandEvent &); void SetCellFgColour(wxCommandEvent &);
@@ -153,6 +155,9 @@ public:
ID_COLLABELALIGN, ID_COLLABELALIGN,
ID_COLLABELHORIZALIGN, ID_COLLABELHORIZALIGN,
ID_COLLABELVERTALIGN, ID_COLLABELVERTALIGN,
ID_CORNERLABELALIGN,
ID_CORNERLABELHORIZALIGN,
ID_CORNERLABELVERTALIGN,
ID_COLDEFAULTHEADER, ID_COLDEFAULTHEADER,
ID_COLNATIVEHEADER, ID_COLNATIVEHEADER,
ID_COLCUSTOMHEADER, ID_COLCUSTOMHEADER,