Add wxDataViewCtrl::GenericGetHeader() accessor
And show how to use it to increase the header size in the sample.
This commit is contained in:
@@ -35,6 +35,10 @@
|
||||
#include "wx/itemattr.h"
|
||||
#include "wx/notebook.h"
|
||||
|
||||
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
||||
#include "wx/headerctrl.h"
|
||||
#endif // wxHAS_GENERIC_DATAVIEWCTRL
|
||||
|
||||
#include "mymodels.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -76,6 +80,9 @@ private:
|
||||
void OnStyleChange(wxCommandEvent& event);
|
||||
void OnSetBackgroundColour(wxCommandEvent& event);
|
||||
void OnCustomHeaderAttr(wxCommandEvent& event);
|
||||
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
||||
void OnCustomHeaderHeight(wxCommandEvent& event);
|
||||
#endif // wxHAS_GENERIC_DATAVIEWCTRL
|
||||
void OnSetForegroundColour(wxCommandEvent& event);
|
||||
void OnIncIndent(wxCommandEvent& event);
|
||||
void OnDecIndent(wxCommandEvent& event);
|
||||
@@ -293,6 +300,9 @@ enum
|
||||
ID_BACKGROUND_COLOUR,
|
||||
ID_FOREGROUND_COLOUR,
|
||||
ID_CUSTOM_HEADER_ATTR,
|
||||
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
||||
ID_CUSTOM_HEADER_HEIGHT,
|
||||
#endif // wxHAS_GENERIC_DATAVIEWCTRL
|
||||
ID_STYLE_MENU,
|
||||
ID_INC_INDENT,
|
||||
ID_DEC_INDENT,
|
||||
@@ -348,6 +358,9 @@ wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU( ID_FOREGROUND_COLOUR, MyFrame::OnSetForegroundColour )
|
||||
EVT_MENU( ID_BACKGROUND_COLOUR, MyFrame::OnSetBackgroundColour )
|
||||
EVT_MENU( ID_CUSTOM_HEADER_ATTR, MyFrame::OnCustomHeaderAttr )
|
||||
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
||||
EVT_MENU( ID_CUSTOM_HEADER_HEIGHT, MyFrame::OnCustomHeaderHeight )
|
||||
#endif // wxHAS_GENERIC_DATAVIEWCTRL
|
||||
EVT_MENU( ID_INC_INDENT, MyFrame::OnIncIndent )
|
||||
EVT_MENU( ID_DEC_INDENT, MyFrame::OnDecIndent )
|
||||
|
||||
@@ -436,6 +449,9 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
|
||||
file_menu->Append(ID_FOREGROUND_COLOUR, "Set &foreground colour...\tCtrl-S");
|
||||
file_menu->Append(ID_BACKGROUND_COLOUR, "Set &background colour...\tCtrl-B");
|
||||
file_menu->AppendCheckItem(ID_CUSTOM_HEADER_ATTR, "C&ustom header attributes");
|
||||
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
||||
file_menu->AppendCheckItem(ID_CUSTOM_HEADER_HEIGHT, "Custom header &height");
|
||||
#endif // wxHAS_GENERIC_DATAVIEWCTRL
|
||||
file_menu->Append(ID_STYLE_MENU, "&Style", style_menu);
|
||||
file_menu->Append(ID_INC_INDENT, "&Increase indent\tCtrl-I");
|
||||
file_menu->Append(ID_DEC_INDENT, "&Decrease indent\tShift-Ctrl-I");
|
||||
@@ -808,6 +824,26 @@ void MyFrame::OnCustomHeaderAttr(wxCommandEvent& event)
|
||||
wxLogMessage("Sorry, header attributes not supported on this platform");
|
||||
}
|
||||
|
||||
#ifdef wxHAS_GENERIC_DATAVIEWCTRL
|
||||
void MyFrame::OnCustomHeaderHeight(wxCommandEvent& event)
|
||||
{
|
||||
wxDataViewCtrl * const dvc = m_ctrl[m_notebook->GetSelection()];
|
||||
wxHeaderCtrl* const header = dvc->GenericGetHeader();
|
||||
if ( !header )
|
||||
{
|
||||
wxLogMessage("No header");
|
||||
return;
|
||||
}
|
||||
|
||||
// Use a big height to show that this works.
|
||||
wxSize size = event.IsChecked() ? FromDIP(wxSize(0, 80)) : wxDefaultSize;
|
||||
header->SetMinSize(size);
|
||||
header->Refresh();
|
||||
|
||||
dvc->Layout();
|
||||
}
|
||||
#endif // wxHAS_GENERIC_DATAVIEWCTRL
|
||||
|
||||
void MyFrame::OnIncIndent(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxDataViewCtrl * const dvc = m_ctrl[m_notebook->GetSelection()];
|
||||
|
Reference in New Issue
Block a user