Implement wxDataViewCtrl::SetIndent() for wxGTK

Use gtk_tree_view_set_level_indentation().
This commit is contained in:
Vadim Zeitlin
2016-02-05 17:00:57 +01:00
parent 4484e1282e
commit 4379f599e8
3 changed files with 30 additions and 0 deletions

View File

@@ -156,6 +156,7 @@ wxGTK:
- Fix setting "pressed" bitmap for wxToggleButton (Kevin B. McCarty). - Fix setting "pressed" bitmap for wxToggleButton (Kevin B. McCarty).
- Fix GTK+ warnings for wxFileDialog with wxFD_MULTIPLE style. - Fix GTK+ warnings for wxFileDialog with wxFD_MULTIPLE style.
- Don't generate wxEVT_LIST_ITEM_RIGHT_CLICK outside of item area (Igor Korot). - Don't generate wxEVT_LIST_ITEM_RIGHT_CLICK outside of item area (Igor Korot).
- Implement wxDataViewCtrl::SetIndent().
wxMSW: wxMSW:

View File

@@ -75,6 +75,9 @@ private:
void OnStyleChange(wxCommandEvent& event); void OnStyleChange(wxCommandEvent& event);
void OnSetBackgroundColour(wxCommandEvent& event); void OnSetBackgroundColour(wxCommandEvent& event);
void OnSetForegroundColour(wxCommandEvent& event); void OnSetForegroundColour(wxCommandEvent& event);
void OnIncIndent(wxCommandEvent& event);
void OnDecIndent(wxCommandEvent& event);
void OnQuit(wxCommandEvent& event); void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event); void OnAbout(wxCommandEvent& event);
@@ -258,6 +261,8 @@ enum
ID_BACKGROUND_COLOUR, ID_BACKGROUND_COLOUR,
ID_FOREGROUND_COLOUR, ID_FOREGROUND_COLOUR,
ID_STYLE_MENU, ID_STYLE_MENU,
ID_INC_INDENT,
ID_DEC_INDENT,
// file menu // file menu
//ID_SINGLE, wxDV_SINGLE==0 so it's always present //ID_SINGLE, wxDV_SINGLE==0 so it's always present
@@ -309,6 +314,8 @@ wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU( ID_FOREGROUND_COLOUR, MyFrame::OnSetForegroundColour ) EVT_MENU( ID_FOREGROUND_COLOUR, MyFrame::OnSetForegroundColour )
EVT_MENU( ID_BACKGROUND_COLOUR, MyFrame::OnSetBackgroundColour ) EVT_MENU( ID_BACKGROUND_COLOUR, MyFrame::OnSetBackgroundColour )
EVT_MENU( ID_INC_INDENT, MyFrame::OnIncIndent )
EVT_MENU( ID_DEC_INDENT, MyFrame::OnDecIndent )
EVT_NOTEBOOK_PAGE_CHANGED( wxID_ANY, MyFrame::OnPageChanged ) EVT_NOTEBOOK_PAGE_CHANGED( wxID_ANY, MyFrame::OnPageChanged )
@@ -395,6 +402,8 @@ 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_FOREGROUND_COLOUR, "Set &foreground colour...\tCtrl-S");
file_menu->Append(ID_BACKGROUND_COLOUR, "Set &background colour...\tCtrl-B"); file_menu->Append(ID_BACKGROUND_COLOUR, "Set &background colour...\tCtrl-B");
file_menu->Append(ID_STYLE_MENU, "&Style", style_menu); 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");
file_menu->AppendSeparator(); file_menu->AppendSeparator();
file_menu->Append(ID_EXIT, "E&xit"); file_menu->Append(ID_EXIT, "E&xit");
@@ -749,6 +758,20 @@ void MyFrame::OnSetBackgroundColour(wxCommandEvent& WXUNUSED(event))
} }
} }
void MyFrame::OnIncIndent(wxCommandEvent& WXUNUSED(event))
{
wxDataViewCtrl * const dvc = m_ctrl[m_notebook->GetSelection()];
dvc->SetIndent(dvc->GetIndent() + 5);
wxLogMessage("Indent is now %d", dvc->GetIndent());
}
void MyFrame::OnDecIndent(wxCommandEvent& WXUNUSED(event))
{
wxDataViewCtrl * const dvc = m_ctrl[m_notebook->GetSelection()];
dvc->SetIndent(wxMax(dvc->GetIndent() - 5, 0));
wxLogMessage("Indent is now %d", dvc->GetIndent());
}
void MyFrame::OnPageChanged( wxBookCtrlEvent& WXUNUSED(event) ) void MyFrame::OnPageChanged( wxBookCtrlEvent& WXUNUSED(event) )
{ {
unsigned int nPanel = m_notebook->GetSelection(); unsigned int nPanel = m_notebook->GetSelection();

View File

@@ -5077,6 +5077,12 @@ void wxDataViewCtrl::DoSetExpanderColumn()
void wxDataViewCtrl::DoSetIndent() void wxDataViewCtrl::DoSetIndent()
{ {
#if GTK_CHECK_VERSION(2, 12, 0)
if ( gtk_check_version(2, 12, 0) == NULL )
{
gtk_tree_view_set_level_indentation(GTK_TREE_VIEW(m_treeview), GetIndent());
}
#endif // GTK+ 2.12+
} }
void wxDataViewCtrl::GtkDisableSelectionEvents() void wxDataViewCtrl::GtkDisableSelectionEvents()