Add wxDataViewCtrl::SetHeaderAttr() too
This is currently only implemented in the generic version but could be implemented at least for GTK+ native one as well in the future.
This commit is contained in:
parent
5388c7a72e
commit
bed7d9fe74
@ -71,6 +71,7 @@ All (GUI):
|
||||
- Add support for wxSL_MIN_MAX_LABELS and wxSL_VALUE_LABEL to XRC (ousnius).
|
||||
- Update Scintilla to v3.6.3 (Paul Kulchenko).
|
||||
- Make wxDataViewCtrl::Expand() expand ancestors in native ports too.
|
||||
- Add wxDataViewCtrl::SetHeaderAttr().
|
||||
- Add wxListCtrl::SetHeaderAttr().
|
||||
|
||||
wxGTK:
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "wx/systhemectrl.h"
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxImageList;
|
||||
class WXDLLIMPEXP_FWD_CORE wxItemAttr;
|
||||
|
||||
#if !(defined(__WXGTK20__) || defined(__WXOSX__) ) || defined(__WXUNIVERSAL__)
|
||||
// #if !(defined(__WXOSX__)) || defined(__WXUNIVERSAL__)
|
||||
@ -128,7 +129,7 @@ private:
|
||||
// wxDataViewItemAttr: a structure containing the visual attributes of an item
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// TODO: this should be renamed to wxItemAttr or something general like this
|
||||
// TODO: Merge with wxItemAttr somehow.
|
||||
|
||||
class WXDLLIMPEXP_ADV wxDataViewItemAttr
|
||||
{
|
||||
@ -732,6 +733,10 @@ public:
|
||||
// define control visual attributes
|
||||
// --------------------------------
|
||||
|
||||
// Header attributes: only implemented in the generic version currently.
|
||||
virtual bool SetHeaderAttr(const wxItemAttr& WXUNUSED(attr))
|
||||
{ return false; }
|
||||
|
||||
virtual wxVisualAttributes GetDefaultAttributes() const wxOVERRIDE
|
||||
{
|
||||
return GetClassDefaultAttributes(GetWindowVariant());
|
||||
|
@ -256,6 +256,8 @@ public:
|
||||
|
||||
virtual void EditItem(const wxDataViewItem& item, const wxDataViewColumn *column) wxOVERRIDE;
|
||||
|
||||
virtual bool SetHeaderAttr(const wxItemAttr& attr) wxOVERRIDE;
|
||||
|
||||
// These methods are specific to generic wxDataViewCtrl implementation and
|
||||
// should not be used in portable code.
|
||||
wxColour GetAlternateRowColour() const { return m_alternateRowColour; }
|
||||
|
@ -1547,6 +1547,25 @@ public:
|
||||
*/
|
||||
void SetCurrentItem(const wxDataViewItem& item);
|
||||
|
||||
/**
|
||||
Set custom colours and/or font to use for the header.
|
||||
|
||||
This method allows to customize the display of the control header (it
|
||||
does nothing if @c wxDV_NO_HEADER style is used).
|
||||
|
||||
Currently it is only implemented in the generic version and just
|
||||
returns @false without doing anything elsewhere.
|
||||
|
||||
@param attr The attribute defining the colour(s) and font to use. It
|
||||
can be default, in which case the attributes are reset to their
|
||||
default values.
|
||||
@return @true if the attributes were updated, @false if the method is
|
||||
not implemented or failed.
|
||||
|
||||
@since 3.1.1
|
||||
*/
|
||||
bool SetHeaderAttr(const wxItemAttr& attr);
|
||||
|
||||
/**
|
||||
Sets the indentation.
|
||||
*/
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "wx/numdlg.h"
|
||||
#include "wx/spinctrl.h"
|
||||
#include "wx/imaglist.h"
|
||||
#include "wx/itemattr.h"
|
||||
#include "wx/notebook.h"
|
||||
|
||||
#include "mymodels.h"
|
||||
@ -74,6 +75,7 @@ private:
|
||||
// event handlers
|
||||
void OnStyleChange(wxCommandEvent& event);
|
||||
void OnSetBackgroundColour(wxCommandEvent& event);
|
||||
void OnCustomHeaderAttr(wxCommandEvent& event);
|
||||
void OnSetForegroundColour(wxCommandEvent& event);
|
||||
void OnIncIndent(wxCommandEvent& event);
|
||||
void OnDecIndent(wxCommandEvent& event);
|
||||
@ -290,6 +292,7 @@ enum
|
||||
ID_CLEARLOG = wxID_HIGHEST+1,
|
||||
ID_BACKGROUND_COLOUR,
|
||||
ID_FOREGROUND_COLOUR,
|
||||
ID_CUSTOM_HEADER_ATTR,
|
||||
ID_STYLE_MENU,
|
||||
ID_INC_INDENT,
|
||||
ID_DEC_INDENT,
|
||||
@ -344,6 +347,7 @@ 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 )
|
||||
EVT_MENU( ID_INC_INDENT, MyFrame::OnIncIndent )
|
||||
EVT_MENU( ID_DEC_INDENT, MyFrame::OnDecIndent )
|
||||
|
||||
@ -431,6 +435,7 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
|
||||
file_menu->Append(ID_CLEARLOG, "&Clear log\tCtrl-L");
|
||||
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");
|
||||
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");
|
||||
@ -788,6 +793,21 @@ void MyFrame::OnSetBackgroundColour(wxCommandEvent& WXUNUSED(event))
|
||||
}
|
||||
}
|
||||
|
||||
void MyFrame::OnCustomHeaderAttr(wxCommandEvent& event)
|
||||
{
|
||||
wxItemAttr attr;
|
||||
if ( event.IsChecked() )
|
||||
{
|
||||
attr.SetTextColour(*wxRED);
|
||||
attr.SetFont(wxFontInfo(20).Bold());
|
||||
}
|
||||
//else: leave it as default to disable custom header attributes
|
||||
|
||||
wxDataViewCtrl * const dvc = m_ctrl[m_notebook->GetSelection()];
|
||||
if ( !dvc->SetHeaderAttr(attr) )
|
||||
wxLogMessage("Sorry, header attributes not supported on this platform");
|
||||
}
|
||||
|
||||
void MyFrame::OnIncIndent(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxDataViewCtrl * const dvc = m_ctrl[m_notebook->GetSelection()];
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "wx/renderer.h"
|
||||
#include "wx/dcbuffer.h"
|
||||
#include "wx/icon.h"
|
||||
#include "wx/itemattr.h"
|
||||
#include "wx/list.h"
|
||||
#include "wx/listimpl.cpp"
|
||||
#include "wx/imaglist.h"
|
||||
@ -5202,6 +5203,24 @@ bool wxDataViewCtrl::IsSelected( const wxDataViewItem & item ) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxDataViewCtrl::SetHeaderAttr(const wxItemAttr& attr)
|
||||
{
|
||||
if ( !m_headerArea )
|
||||
return false;
|
||||
|
||||
// Call all functions unconditionally to reset the previously set
|
||||
// attributes, if any.
|
||||
m_headerArea->SetForegroundColour(attr.GetTextColour());
|
||||
m_headerArea->SetBackgroundColour(attr.GetBackgroundColour());
|
||||
m_headerArea->SetFont(attr.GetFont());
|
||||
|
||||
// If the font has changed, the size of the header might need to be
|
||||
// updated.
|
||||
Layout();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxDataViewCtrl::SetAlternateRowColour(const wxColour& colour)
|
||||
{
|
||||
m_alternateRowColour = colour;
|
||||
|
Loading…
Reference in New Issue
Block a user