Replace wxTreeItemAttr and wxListItemAttr with wxItemAttr
The two existing structs were completely identical, just replace them with a single wxItemAttr. Notice that wxDataViewItemAttr is not quite the same, although pretty similar, so it remains separate for now. It would be nice to combine it with this one too in the future, e.g. to make it simpler to make items bold in a wxListCtrl.
This commit is contained in:
parent
c592363e95
commit
246ae58c19
@ -3872,6 +3872,7 @@ COND_USE_GUI_1_ALL_GUI_HEADERS = \
|
||||
wx/systhemectrl.h \
|
||||
wx/collheaderctrl.h \
|
||||
wx/generic/collheaderctrl.h \
|
||||
wx/itemattr.h \
|
||||
$(LOWLEVEL_HDR) \
|
||||
$(GUI_CORE_HEADERS) \
|
||||
$(ADVANCED_HDR) \
|
||||
|
@ -1181,6 +1181,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file!
|
||||
wx/systhemectrl.h
|
||||
wx/collheaderctrl.h
|
||||
wx/generic/collheaderctrl.h
|
||||
wx/itemattr.h
|
||||
</set>
|
||||
|
||||
<!-- ====================================================================== -->
|
||||
|
@ -1039,6 +1039,7 @@ GUI_CMN_HDR =
|
||||
wx/imagtga.h
|
||||
wx/imagtiff.h
|
||||
wx/imagxpm.h
|
||||
wx/itemattr.h
|
||||
wx/listbase.h
|
||||
wx/listbook.h
|
||||
wx/listctrl.h
|
||||
|
@ -1379,6 +1379,7 @@
|
||||
<ClInclude Include="..\..\include\wx\collheaderctrl.h" />
|
||||
<ClInclude Include="..\..\include\wx\generic\collheaderctrl.h" />
|
||||
<ClInclude Include="..\..\include\wx\msw\rt\utils.h" />
|
||||
<ClInclude Include="..\..\include\wx\itemattr.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
@ -690,6 +690,9 @@
|
||||
<ClCompile Include="..\..\src\msw\graphics.cpp">
|
||||
<Filter>MSW Sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\msw\graphicsd2d.cpp">
|
||||
<Filter>MSW Sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\msw\headerctrl.cpp">
|
||||
<Filter>MSW Sources</Filter>
|
||||
</ClCompile>
|
||||
@ -897,9 +900,6 @@
|
||||
<ClCompile Include="..\..\src\xrc\xmlreshandler.cpp">
|
||||
<Filter>Common Sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\msw\graphicsd2d.cpp">
|
||||
<Filter>MSW Sources</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="..\..\src\msw\version.rc">
|
||||
@ -928,6 +928,9 @@
|
||||
<ClInclude Include="..\..\include\wx\anybutton.h">
|
||||
<Filter>Common Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\wx\appprogress.h">
|
||||
<Filter>Common Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\wx\artprov.h">
|
||||
<Filter>Common Headers</Filter>
|
||||
</ClInclude>
|
||||
@ -1312,6 +1315,9 @@
|
||||
<ClInclude Include="..\..\include\wx\infobar.h">
|
||||
<Filter>Common Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\wx\itemattr.h">
|
||||
<Filter>Common Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\wx\itemid.h">
|
||||
<Filter>Common Headers</Filter>
|
||||
</ClInclude>
|
||||
@ -1672,9 +1678,6 @@
|
||||
<ClInclude Include="..\..\include\wx\msw\window.h">
|
||||
<Filter>MSW Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\wx\appprogress.h">
|
||||
<Filter>Common Headers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\wx\nativewin.h">
|
||||
<Filter>Common Headers</Filter>
|
||||
</ClInclude>
|
||||
|
@ -2285,6 +2285,9 @@
|
||||
<File
|
||||
RelativePath="..\..\include\wx\infobar.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\wx\itemattr.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\wx\itemid.h">
|
||||
</File>
|
||||
|
@ -3548,6 +3548,10 @@
|
||||
RelativePath="..\..\include\wx\infobar.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\wx\itemattr.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\wx\itemid.h"
|
||||
>
|
||||
|
@ -3544,6 +3544,10 @@
|
||||
RelativePath="..\..\include\wx\infobar.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\wx\itemattr.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\wx\itemid.h"
|
||||
>
|
||||
|
@ -85,8 +85,8 @@ public:
|
||||
|
||||
void GetItem( wxListItem &info ) const;
|
||||
|
||||
void SetAttr(wxListItemAttr *attr) { m_attr = attr; }
|
||||
wxListItemAttr *GetAttr() const { return m_attr; }
|
||||
void SetAttr(wxItemAttr *attr) { m_attr = attr; }
|
||||
wxItemAttr *GetAttr() const { return m_attr; }
|
||||
|
||||
public:
|
||||
// the item image or -1
|
||||
@ -103,7 +103,7 @@ public:
|
||||
wxListMainWindow *m_owner;
|
||||
|
||||
// custom attributes or NULL
|
||||
wxListItemAttr *m_attr;
|
||||
wxItemAttr *m_attr;
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
@ -263,8 +263,8 @@ public:
|
||||
wxString GetText(int index) const;
|
||||
void SetText( int index, const wxString& s );
|
||||
|
||||
wxListItemAttr *GetAttr() const;
|
||||
void SetAttr(wxListItemAttr *attr);
|
||||
wxItemAttr *GetAttr() const;
|
||||
void SetAttr(wxItemAttr *attr);
|
||||
|
||||
// return true if the highlighting really changed
|
||||
bool Highlight( bool on );
|
||||
|
65
include/wx/itemattr.h
Normal file
65
include/wx/itemattr.h
Normal file
@ -0,0 +1,65 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/itemattr.h
|
||||
// Purpose: wxItemAttr class declaration
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2016-04-16 (extracted from wx/listctrl.h)
|
||||
// Copyright: (c) 2016 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_ITEMATTR_H_
|
||||
#define _WX_ITEMATTR_H_
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxItemAttr: a structure containing the visual attributes of an item
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxItemAttr
|
||||
{
|
||||
public:
|
||||
// ctors
|
||||
wxItemAttr() { }
|
||||
wxItemAttr(const wxColour& colText,
|
||||
const wxColour& colBack,
|
||||
const wxFont& font)
|
||||
: m_colText(colText), m_colBack(colBack), m_font(font)
|
||||
{
|
||||
}
|
||||
|
||||
// default copy ctor, assignment operator and dtor are ok
|
||||
|
||||
|
||||
// setters
|
||||
void SetTextColour(const wxColour& colText) { m_colText = colText; }
|
||||
void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
|
||||
void SetFont(const wxFont& font) { m_font = font; }
|
||||
|
||||
// accessors
|
||||
bool HasTextColour() const { return m_colText.IsOk(); }
|
||||
bool HasBackgroundColour() const { return m_colBack.IsOk(); }
|
||||
bool HasFont() const { return m_font.IsOk(); }
|
||||
|
||||
const wxColour& GetTextColour() const { return m_colText; }
|
||||
const wxColour& GetBackgroundColour() const { return m_colBack; }
|
||||
const wxFont& GetFont() const { return m_font; }
|
||||
|
||||
|
||||
// this is almost like assignment operator except it doesn't overwrite the
|
||||
// fields unset in the source attribute
|
||||
void AssignFrom(const wxItemAttr& source)
|
||||
{
|
||||
if ( source.HasTextColour() )
|
||||
SetTextColour(source.GetTextColour());
|
||||
if ( source.HasBackgroundColour() )
|
||||
SetBackgroundColour(source.GetBackgroundColour());
|
||||
if ( source.HasFont() )
|
||||
SetFont(source.GetFont());
|
||||
}
|
||||
|
||||
private:
|
||||
wxColour m_colText,
|
||||
m_colBack;
|
||||
wxFont m_font;
|
||||
};
|
||||
|
||||
#endif // _WX_ITEMATTR_H_
|
@ -16,6 +16,7 @@
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/event.h"
|
||||
#include "wx/control.h"
|
||||
#include "wx/itemattr.h"
|
||||
#include "wx/systhemectrl.h"
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxImageList;
|
||||
@ -158,60 +159,10 @@ enum
|
||||
wxLIST_FIND_RIGHT
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxListItemAttr: a structure containing the visual attributes of an item
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// TODO: this should be renamed to wxItemAttr or something general like this
|
||||
// and used as base class for wxTextAttr which duplicates this class
|
||||
// entirely currently
|
||||
class WXDLLIMPEXP_CORE wxListItemAttr
|
||||
{
|
||||
public:
|
||||
// ctors
|
||||
wxListItemAttr() { }
|
||||
wxListItemAttr(const wxColour& colText,
|
||||
const wxColour& colBack,
|
||||
const wxFont& font)
|
||||
: m_colText(colText), m_colBack(colBack), m_font(font)
|
||||
{
|
||||
}
|
||||
|
||||
// default copy ctor, assignment operator and dtor are ok
|
||||
|
||||
|
||||
// setters
|
||||
void SetTextColour(const wxColour& colText) { m_colText = colText; }
|
||||
void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
|
||||
void SetFont(const wxFont& font) { m_font = font; }
|
||||
|
||||
// accessors
|
||||
bool HasTextColour() const { return m_colText.IsOk(); }
|
||||
bool HasBackgroundColour() const { return m_colBack.IsOk(); }
|
||||
bool HasFont() const { return m_font.IsOk(); }
|
||||
|
||||
const wxColour& GetTextColour() const { return m_colText; }
|
||||
const wxColour& GetBackgroundColour() const { return m_colBack; }
|
||||
const wxFont& GetFont() const { return m_font; }
|
||||
|
||||
|
||||
// this is almost like assignment operator except it doesn't overwrite the
|
||||
// fields unset in the source attribute
|
||||
void AssignFrom(const wxListItemAttr& source)
|
||||
{
|
||||
if ( source.HasTextColour() )
|
||||
SetTextColour(source.GetTextColour());
|
||||
if ( source.HasBackgroundColour() )
|
||||
SetBackgroundColour(source.GetBackgroundColour());
|
||||
if ( source.HasFont() )
|
||||
SetFont(source.GetFont());
|
||||
}
|
||||
|
||||
private:
|
||||
wxColour m_colText,
|
||||
m_colBack;
|
||||
wxFont m_font;
|
||||
};
|
||||
// For compatibility, define the old name for this class. There is no need to
|
||||
// deprecate it as it doesn't cost us anything to keep this typedef, but the
|
||||
// new code should prefer to use the new wxItemAttr name.
|
||||
typedef wxItemAttr wxListItemAttr;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxListItem: the item or column info, used to exchange data with wxListCtrl
|
||||
@ -237,7 +188,7 @@ public:
|
||||
{
|
||||
// copy list item attributes
|
||||
if ( item.HasAttributes() )
|
||||
m_attr = new wxListItemAttr(*item.GetAttributes());
|
||||
m_attr = new wxItemAttr(*item.GetAttributes());
|
||||
}
|
||||
|
||||
wxListItem& operator=(const wxListItem& item)
|
||||
@ -254,7 +205,7 @@ public:
|
||||
m_data = item.m_data;
|
||||
m_format = item.m_format;
|
||||
m_width = item.m_width;
|
||||
m_attr = item.m_attr ? new wxListItemAttr(*item.m_attr) : NULL;
|
||||
m_attr = item.m_attr ? new wxItemAttr(*item.m_attr) : NULL;
|
||||
}
|
||||
|
||||
return *this;
|
||||
@ -310,7 +261,7 @@ public:
|
||||
int GetWidth() const { return m_width; }
|
||||
wxListColumnFormat GetAlign() const { return (wxListColumnFormat)m_format; }
|
||||
|
||||
wxListItemAttr *GetAttributes() const { return m_attr; }
|
||||
wxItemAttr *GetAttributes() const { return m_attr; }
|
||||
bool HasAttributes() const { return m_attr != NULL; }
|
||||
|
||||
wxColour GetTextColour() const
|
||||
@ -342,10 +293,10 @@ public:
|
||||
|
||||
protected:
|
||||
// creates m_attr if we don't have it yet
|
||||
wxListItemAttr& Attributes()
|
||||
wxItemAttr& Attributes()
|
||||
{
|
||||
if ( !m_attr )
|
||||
m_attr = new wxListItemAttr;
|
||||
m_attr = new wxItemAttr;
|
||||
|
||||
return *m_attr;
|
||||
}
|
||||
@ -364,7 +315,7 @@ protected:
|
||||
m_width = 0;
|
||||
}
|
||||
|
||||
wxListItemAttr *m_attr; // optional pointer to the items style
|
||||
wxItemAttr *m_attr; // optional pointer to the items style
|
||||
|
||||
private:
|
||||
wxDECLARE_DYNAMIC_CLASS(wxListItem);
|
||||
@ -443,7 +394,7 @@ public:
|
||||
virtual bool SetColumnWidth(int col, int width) = 0;
|
||||
|
||||
// return the attribute for the item (may return NULL if none)
|
||||
virtual wxListItemAttr *OnGetItemAttr(long item) const;
|
||||
virtual wxItemAttr *OnGetItemAttr(long item) const;
|
||||
|
||||
// Other miscellaneous accessors.
|
||||
// ------------------------------
|
||||
@ -475,7 +426,7 @@ protected:
|
||||
|
||||
private:
|
||||
// user defined color to draw row lines, may be invalid
|
||||
wxListItemAttr m_alternateRowColour;
|
||||
wxItemAttr m_alternateRowColour;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -402,7 +402,7 @@ protected:
|
||||
|
||||
// get the item attribute, either by quering it for virtual control, or by
|
||||
// returning the one previously set using setter methods for a normal one
|
||||
wxListItemAttr *DoGetItemColumnAttr(long item, long column) const;
|
||||
wxItemAttr *DoGetItemColumnAttr(long item, long column) const;
|
||||
|
||||
|
||||
wxTextCtrl* m_textCtrl; // The control used for editing a label
|
||||
@ -437,7 +437,7 @@ protected:
|
||||
virtual int OnGetItemColumnImage(long item, long column) const;
|
||||
|
||||
// return the attribute for the given item and column (may return NULL if none)
|
||||
virtual wxListItemAttr *OnGetItemColumnAttr(long item, long WXUNUSED(column)) const
|
||||
virtual wxItemAttr *OnGetItemColumnAttr(long item, long WXUNUSED(column)) const
|
||||
{
|
||||
return OnGetItemAttr(item);
|
||||
}
|
||||
|
@ -34,7 +34,8 @@ class WXDLLIMPEXP_FWD_CORE wxDragImage;
|
||||
struct WXDLLIMPEXP_FWD_CORE wxTreeViewItem;
|
||||
|
||||
// hash storing attributes for our items
|
||||
WX_DECLARE_EXPORTED_VOIDPTR_HASH_MAP(wxTreeItemAttr *, wxMapTreeAttr);
|
||||
class wxItemAttr;
|
||||
WX_DECLARE_EXPORTED_VOIDPTR_HASH_MAP(wxItemAttr *, wxMapTreeAttr);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTreeCtrl
|
||||
|
@ -279,7 +279,7 @@ public:
|
||||
virtual int OnGetItemColumnImage(long item, long column) const;
|
||||
|
||||
// return the attribute for the given item and column (may return NULL if none)
|
||||
virtual wxListItemAttr *OnGetItemColumnAttr(long item, long WXUNUSED(column)) const
|
||||
virtual wxItemAttr *OnGetItemColumnAttr(long item, long WXUNUSED(column)) const
|
||||
{
|
||||
return OnGetItemAttr(item);
|
||||
}
|
||||
|
@ -180,40 +180,6 @@ static const int wxTREE_HITTEST_ONITEM = wxTREE_HITTEST_ONITEMICON |
|
||||
// tree ctrl default name
|
||||
extern WXDLLIMPEXP_DATA_CORE(const char) wxTreeCtrlNameStr[];
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTreeItemAttr: a structure containing the visual attributes of an item
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxTreeItemAttr
|
||||
{
|
||||
public:
|
||||
// ctors
|
||||
wxTreeItemAttr() { }
|
||||
wxTreeItemAttr(const wxColour& colText,
|
||||
const wxColour& colBack,
|
||||
const wxFont& font)
|
||||
: m_colText(colText), m_colBack(colBack), m_font(font) { }
|
||||
|
||||
// setters
|
||||
void SetTextColour(const wxColour& colText) { m_colText = colText; }
|
||||
void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; }
|
||||
void SetFont(const wxFont& font) { m_font = font; }
|
||||
|
||||
// accessors
|
||||
bool HasTextColour() const { return m_colText.IsOk(); }
|
||||
bool HasBackgroundColour() const { return m_colBack.IsOk(); }
|
||||
bool HasFont() const { return m_font.IsOk(); }
|
||||
|
||||
const wxColour& GetTextColour() const { return m_colText; }
|
||||
const wxColour& GetBackgroundColour() const { return m_colBack; }
|
||||
const wxFont& GetFont() const { return m_font; }
|
||||
|
||||
private:
|
||||
wxColour m_colText,
|
||||
m_colBack;
|
||||
wxFont m_font;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTreeEvent is a special class for all events associated with tree controls
|
||||
//
|
||||
|
82
interface/wx/itemattr.h
Normal file
82
interface/wx/itemattr.h
Normal file
@ -0,0 +1,82 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/itemattr.h
|
||||
// Purpose: wxItemAttr documentation
|
||||
// Author: Vadim Zeitlin
|
||||
// Copyright: (c) 2016 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
@class wxItemAttr
|
||||
|
||||
Represents the attributes (color, font, ...) of an item of a control with
|
||||
multiple items such as e.g. wxListCtrl.
|
||||
|
||||
@library{wxcore}
|
||||
@category{data}
|
||||
|
||||
@see @ref overview_listctrl
|
||||
|
||||
@since 3.1.1 (previous versions had the identical wxListItemAttr class)
|
||||
*/
|
||||
class wxItemAttr
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Default Constructor.
|
||||
*/
|
||||
wxItemAttr();
|
||||
|
||||
/**
|
||||
Construct a wxItemAttr with the specified foreground and
|
||||
background colors and font.
|
||||
*/
|
||||
wxItemAttr(const wxColour& colText,
|
||||
const wxColour& colBack,
|
||||
const wxFont& font);
|
||||
|
||||
/**
|
||||
Returns the currently set background color.
|
||||
*/
|
||||
const wxColour& GetBackgroundColour() const;
|
||||
|
||||
/**
|
||||
Returns the currently set font.
|
||||
*/
|
||||
const wxFont& GetFont() const;
|
||||
|
||||
/**
|
||||
Returns the currently set text color.
|
||||
*/
|
||||
const wxColour& GetTextColour() const;
|
||||
|
||||
/**
|
||||
Returns @true if the currently set background color is valid.
|
||||
*/
|
||||
bool HasBackgroundColour() const;
|
||||
|
||||
/**
|
||||
Returns @true if the currently set font is valid.
|
||||
*/
|
||||
bool HasFont() const;
|
||||
|
||||
/**
|
||||
Returns @true if the currently set text color is valid.
|
||||
*/
|
||||
bool HasTextColour() const;
|
||||
|
||||
/**
|
||||
Sets a new background color.
|
||||
*/
|
||||
void SetBackgroundColour(const wxColour& colour);
|
||||
|
||||
/**
|
||||
Sets a new font.
|
||||
*/
|
||||
void SetFont(const wxFont& font);
|
||||
|
||||
/**
|
||||
Sets a new text color.
|
||||
*/
|
||||
void SetTextColour(const wxColour& colour);
|
||||
};
|
@ -1278,14 +1278,14 @@ protected:
|
||||
@c item or @NULL to use the default appearance parameters.
|
||||
|
||||
wxListCtrl will not delete the pointer or keep a reference of it.
|
||||
You can return the same wxListItemAttr pointer for every OnGetItemAttr() call.
|
||||
You can return the same wxItemAttr pointer for every OnGetItemAttr() call.
|
||||
|
||||
The base class version always returns @NULL.
|
||||
|
||||
@see OnGetItemImage(), OnGetItemColumnImage(), OnGetItemText(),
|
||||
OnGetItemColumnAttr()
|
||||
*/
|
||||
virtual wxListItemAttr* OnGetItemAttr(long item) const;
|
||||
virtual wxItemAttr* OnGetItemAttr(long item) const;
|
||||
|
||||
/**
|
||||
This function may be overridden in the derived class for a control with
|
||||
@ -1302,7 +1302,7 @@ protected:
|
||||
@see OnGetItemAttr(), OnGetItemText(),
|
||||
OnGetItemImage(), OnGetItemColumnImage(),
|
||||
*/
|
||||
virtual wxListItemAttr* OnGetItemColumnAttr(long item, long column) const;
|
||||
virtual wxItemAttr* OnGetItemColumnAttr(long item, long column) const;
|
||||
|
||||
/**
|
||||
Override this function in the derived class for a control with
|
||||
@ -1513,80 +1513,6 @@ wxEventType wxEVT_LIST_ITEM_CHECKED;
|
||||
wxEventType wxEVT_LIST_ITEM_UNCHECKED;
|
||||
|
||||
|
||||
/**
|
||||
@class wxListItemAttr
|
||||
|
||||
Represents the attributes (color, font, ...) of a wxListCtrl's wxListItem.
|
||||
|
||||
@library{wxcore}
|
||||
@category{data}
|
||||
|
||||
@see @ref overview_listctrl, wxListCtrl, wxListItem
|
||||
*/
|
||||
class wxListItemAttr
|
||||
{
|
||||
public:
|
||||
/**
|
||||
Default Constructor.
|
||||
*/
|
||||
wxListItemAttr();
|
||||
|
||||
/**
|
||||
Construct a wxListItemAttr with the specified foreground and
|
||||
background colors and font.
|
||||
*/
|
||||
wxListItemAttr(const wxColour& colText,
|
||||
const wxColour& colBack,
|
||||
const wxFont& font);
|
||||
|
||||
/**
|
||||
Returns the currently set background color.
|
||||
*/
|
||||
const wxColour& GetBackgroundColour() const;
|
||||
|
||||
/**
|
||||
Returns the currently set font.
|
||||
*/
|
||||
const wxFont& GetFont() const;
|
||||
|
||||
/**
|
||||
Returns the currently set text color.
|
||||
*/
|
||||
const wxColour& GetTextColour() const;
|
||||
|
||||
/**
|
||||
Returns @true if the currently set background color is valid.
|
||||
*/
|
||||
bool HasBackgroundColour() const;
|
||||
|
||||
/**
|
||||
Returns @true if the currently set font is valid.
|
||||
*/
|
||||
bool HasFont() const;
|
||||
|
||||
/**
|
||||
Returns @true if the currently set text color is valid.
|
||||
*/
|
||||
bool HasTextColour() const;
|
||||
|
||||
/**
|
||||
Sets a new background color.
|
||||
*/
|
||||
void SetBackgroundColour(const wxColour& colour);
|
||||
|
||||
/**
|
||||
Sets a new font.
|
||||
*/
|
||||
void SetFont(const wxFont& font);
|
||||
|
||||
/**
|
||||
Sets a new text color.
|
||||
*/
|
||||
void SetTextColour(const wxColour& colour);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@class wxListView
|
||||
|
||||
|
@ -1226,7 +1226,7 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event)
|
||||
|
||||
GetItem(info);
|
||||
|
||||
wxListItemAttr *attr = info.GetAttributes();
|
||||
wxItemAttr *attr = info.GetAttributes();
|
||||
if ( !attr || !attr->HasTextColour() )
|
||||
{
|
||||
info.SetTextColour(*wxCYAN);
|
||||
@ -1416,13 +1416,13 @@ int MyListCtrl::OnGetItemColumnImage(long item, long column) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
wxListItemAttr *MyListCtrl::OnGetItemAttr(long item) const
|
||||
wxItemAttr *MyListCtrl::OnGetItemAttr(long item) const
|
||||
{
|
||||
// test to check that RefreshItem() works correctly: when m_updated is
|
||||
// set to some item and it is refreshed, we highlight the item
|
||||
if ( item == m_updated )
|
||||
{
|
||||
static wxListItemAttr s_attrHighlight(*wxRED, wxNullColour, wxNullFont);
|
||||
static wxItemAttr s_attrHighlight(*wxRED, wxNullColour, wxNullFont);
|
||||
return &s_attrHighlight;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ private:
|
||||
|
||||
virtual wxString OnGetItemText(long item, long column) const wxOVERRIDE;
|
||||
virtual int OnGetItemColumnImage(long item, long column) const wxOVERRIDE;
|
||||
virtual wxListItemAttr *OnGetItemAttr(long item) const wxOVERRIDE;
|
||||
virtual wxItemAttr *OnGetItemAttr(long item) const wxOVERRIDE;
|
||||
|
||||
long m_updated;
|
||||
|
||||
|
@ -244,10 +244,10 @@ void wxListCtrlBase::EnableAlternateRowColours(bool enable)
|
||||
}
|
||||
}
|
||||
|
||||
wxListItemAttr *wxListCtrlBase::OnGetItemAttr(long item) const
|
||||
wxItemAttr *wxListCtrlBase::OnGetItemAttr(long item) const
|
||||
{
|
||||
return (m_alternateRowColour.GetBackgroundColour().IsOk() && (item % 2))
|
||||
? wxConstCast(&m_alternateRowColour, wxListItemAttr)
|
||||
? wxConstCast(&m_alternateRowColour, wxItemAttr)
|
||||
: NULL; // no attributes by default
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ void wxListItemData::SetItem( const wxListItem &info )
|
||||
if ( m_attr )
|
||||
m_attr->AssignFrom(*info.GetAttributes());
|
||||
else
|
||||
m_attr = new wxListItemAttr(*info.GetAttributes());
|
||||
m_attr = new wxItemAttr(*info.GetAttributes());
|
||||
}
|
||||
|
||||
if ( m_rect )
|
||||
@ -654,7 +654,7 @@ int wxListLineData::GetImage( int index ) const
|
||||
return item->GetImage();
|
||||
}
|
||||
|
||||
wxListItemAttr *wxListLineData::GetAttr() const
|
||||
wxItemAttr *wxListLineData::GetAttr() const
|
||||
{
|
||||
wxListItemDataList::compatibility_iterator node = m_items.GetFirst();
|
||||
wxCHECK_MSG( node, NULL, wxT("invalid column index in GetAttr()") );
|
||||
@ -663,7 +663,7 @@ wxListItemAttr *wxListLineData::GetAttr() const
|
||||
return item->GetAttr();
|
||||
}
|
||||
|
||||
void wxListLineData::SetAttr(wxListItemAttr *attr)
|
||||
void wxListLineData::SetAttr(wxItemAttr *attr)
|
||||
{
|
||||
wxListItemDataList::compatibility_iterator node = m_items.GetFirst();
|
||||
wxCHECK_RET( node, wxT("invalid column index in SetAttr()") );
|
||||
@ -677,7 +677,7 @@ void wxListLineData::ApplyAttributes(wxDC *dc,
|
||||
bool highlighted,
|
||||
bool current)
|
||||
{
|
||||
const wxListItemAttr * const attr = GetAttr();
|
||||
const wxItemAttr * const attr = GetAttr();
|
||||
|
||||
wxWindow * const listctrl = m_owner->GetParent();
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
#include "wx/generic/treectlg.h"
|
||||
#include "wx/imaglist.h"
|
||||
#include "wx/itemattr.h"
|
||||
|
||||
#include "wx/renderer.h"
|
||||
|
||||
@ -223,7 +224,7 @@ public:
|
||||
{
|
||||
wxFont font;
|
||||
|
||||
wxTreeItemAttr * const attr = GetAttributes();
|
||||
wxItemAttr * const attr = GetAttributes();
|
||||
if ( attr && attr->HasFont() )
|
||||
font = attr->GetFont();
|
||||
else if ( IsBold() )
|
||||
@ -282,19 +283,19 @@ public:
|
||||
|
||||
// attributes
|
||||
// get them - may be NULL
|
||||
wxTreeItemAttr *GetAttributes() const { return m_attr; }
|
||||
wxItemAttr *GetAttributes() const { return m_attr; }
|
||||
// get them ensuring that the pointer is not NULL
|
||||
wxTreeItemAttr& Attr()
|
||||
wxItemAttr& Attr()
|
||||
{
|
||||
if ( !m_attr )
|
||||
{
|
||||
m_attr = new wxTreeItemAttr;
|
||||
m_attr = new wxItemAttr;
|
||||
m_ownsAttr = true;
|
||||
}
|
||||
return *m_attr;
|
||||
}
|
||||
// set them
|
||||
void SetAttributes(wxTreeItemAttr *attr)
|
||||
void SetAttributes(wxItemAttr *attr)
|
||||
{
|
||||
if ( m_ownsAttr ) delete m_attr;
|
||||
m_attr = attr;
|
||||
@ -303,7 +304,7 @@ public:
|
||||
m_widthText = -1;
|
||||
}
|
||||
// set them and delete when done
|
||||
void AssignAttributes(wxTreeItemAttr *attr)
|
||||
void AssignAttributes(wxItemAttr *attr)
|
||||
{
|
||||
SetAttributes(attr);
|
||||
m_ownsAttr = true;
|
||||
@ -335,7 +336,7 @@ private:
|
||||
wxArrayGenericTreeItems m_children; // list of children
|
||||
wxGenericTreeItem *m_parent; // parent of this item
|
||||
|
||||
wxTreeItemAttr *m_attr; // attributes???
|
||||
wxItemAttr *m_attr; // attributes???
|
||||
|
||||
// tree ctrl images for the normal, selected, expanded and
|
||||
// expanded+selected states
|
||||
@ -2554,7 +2555,7 @@ void wxGenericTreeCtrl::PaintItem(wxGenericTreeItem *item, wxDC& dc)
|
||||
else
|
||||
{
|
||||
wxColour colBg;
|
||||
wxTreeItemAttr * const attr = item->GetAttributes();
|
||||
wxItemAttr * const attr = item->GetAttributes();
|
||||
if ( attr && attr->HasBackgroundColour() )
|
||||
{
|
||||
drawItemBackground =
|
||||
@ -2789,7 +2790,7 @@ wxGenericTreeCtrl::PaintLevel(wxGenericTreeItem *item,
|
||||
}
|
||||
else
|
||||
{
|
||||
wxTreeItemAttr *attr = item->GetAttributes();
|
||||
wxItemAttr *attr = item->GetAttributes();
|
||||
if (attr && attr->HasTextColour())
|
||||
colText = attr->GetTextColour();
|
||||
else
|
||||
|
@ -198,7 +198,7 @@ private:
|
||||
///////////////////////////////////////////////////////
|
||||
// Problem:
|
||||
// The MSW version had problems with SetTextColour() et
|
||||
// al as the wxListItemAttr's were stored keyed on the
|
||||
// al as the wxItemAttr's were stored keyed on the
|
||||
// item index. If a item was inserted anywhere but the end
|
||||
// of the list the text attributes (colour etc) for
|
||||
// the following items were out of sync.
|
||||
@ -223,7 +223,7 @@ public:
|
||||
wxMSWListItemData() : attr(NULL), lParam(0) {}
|
||||
~wxMSWListItemData() { delete attr; }
|
||||
|
||||
wxListItemAttr *attr;
|
||||
wxItemAttr *attr;
|
||||
LPARAM lParam; // real user data
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxMSWListItemData);
|
||||
@ -811,13 +811,13 @@ bool wxListCtrl::SetItem(wxListItem& info)
|
||||
// attributes
|
||||
if ( info.HasAttributes() )
|
||||
{
|
||||
const wxListItemAttr& attrNew = *info.GetAttributes();
|
||||
const wxItemAttr& attrNew = *info.GetAttributes();
|
||||
|
||||
// don't overwrite the already set attributes if we have them
|
||||
if ( data->attr )
|
||||
data->attr->AssignFrom(attrNew);
|
||||
else
|
||||
data->attr = new wxListItemAttr(attrNew);
|
||||
data->attr = new wxItemAttr(attrNew);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1754,7 +1754,7 @@ long wxListCtrl::InsertItem(const wxListItem& info)
|
||||
if ( info.HasAttributes() )
|
||||
{
|
||||
// take copy of attributes
|
||||
data->attr = new wxListItemAttr(*info.GetAttributes());
|
||||
data->attr = new wxItemAttr(*info.GetAttributes());
|
||||
|
||||
// and remember that we have some now...
|
||||
m_hasAnyAttr = true;
|
||||
@ -2858,7 +2858,7 @@ static void HandleItemPaint(LPNMLVCUSTOMDRAW pLVCD, HFONT hfont)
|
||||
|
||||
static WXLPARAM HandleItemPrepaint(wxListCtrl *listctrl,
|
||||
LPNMLVCUSTOMDRAW pLVCD,
|
||||
wxListItemAttr *attr)
|
||||
wxItemAttr *attr)
|
||||
{
|
||||
if ( !attr )
|
||||
{
|
||||
@ -3103,7 +3103,7 @@ int wxListCtrl::OnGetItemColumnImage(long item, long column) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
wxListItemAttr *wxListCtrl::DoGetItemColumnAttr(long item, long column) const
|
||||
wxItemAttr *wxListCtrl::DoGetItemColumnAttr(long item, long column) const
|
||||
{
|
||||
if ( IsVirtual() )
|
||||
return OnGetItemColumnAttr(item, column);
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "wx/msw/private.h"
|
||||
|
||||
#include "wx/imaglist.h"
|
||||
#include "wx/itemattr.h"
|
||||
#include "wx/msw/dragimag.h"
|
||||
#include "wx/msw/uxtheme.h"
|
||||
|
||||
@ -1146,14 +1147,14 @@ void wxTreeCtrl::SetItemTextColour(const wxTreeItemId& item,
|
||||
{
|
||||
wxCHECK_RET( item.IsOk(), wxT("invalid tree item") );
|
||||
|
||||
wxTreeItemAttr *attr;
|
||||
wxItemAttr *attr;
|
||||
wxMapTreeAttr::iterator it = m_attrs.find(item.m_pItem);
|
||||
if ( it == m_attrs.end() )
|
||||
{
|
||||
m_hasAnyAttr = true;
|
||||
|
||||
m_attrs[item.m_pItem] =
|
||||
attr = new wxTreeItemAttr;
|
||||
attr = new wxItemAttr;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1170,14 +1171,14 @@ void wxTreeCtrl::SetItemBackgroundColour(const wxTreeItemId& item,
|
||||
{
|
||||
wxCHECK_RET( item.IsOk(), wxT("invalid tree item") );
|
||||
|
||||
wxTreeItemAttr *attr;
|
||||
wxItemAttr *attr;
|
||||
wxMapTreeAttr::iterator it = m_attrs.find(item.m_pItem);
|
||||
if ( it == m_attrs.end() )
|
||||
{
|
||||
m_hasAnyAttr = true;
|
||||
|
||||
m_attrs[item.m_pItem] =
|
||||
attr = new wxTreeItemAttr;
|
||||
attr = new wxItemAttr;
|
||||
}
|
||||
else // already in the hash
|
||||
{
|
||||
@ -1193,14 +1194,14 @@ void wxTreeCtrl::SetItemFont(const wxTreeItemId& item, const wxFont& font)
|
||||
{
|
||||
wxCHECK_RET( item.IsOk(), wxT("invalid tree item") );
|
||||
|
||||
wxTreeItemAttr *attr;
|
||||
wxItemAttr *attr;
|
||||
wxMapTreeAttr::iterator it = m_attrs.find(item.m_pItem);
|
||||
if ( it == m_attrs.end() )
|
||||
{
|
||||
m_hasAnyAttr = true;
|
||||
|
||||
m_attrs[item.m_pItem] =
|
||||
attr = new wxTreeItemAttr;
|
||||
attr = new wxItemAttr;
|
||||
}
|
||||
else // already in the hash
|
||||
{
|
||||
@ -3550,7 +3551,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
|
||||
break;
|
||||
}
|
||||
|
||||
wxTreeItemAttr * const attr = it->second;
|
||||
wxItemAttr * const attr = it->second;
|
||||
|
||||
wxTreeViewItem tvItem((void *)nmcd.dwItemSpec,
|
||||
TVIF_STATE, TVIS_DROPHILITED);
|
||||
|
Loading…
Reference in New Issue
Block a user