Merge branch 'dvc-bmpbundle'

Use wxBitmapBundle in wxDVC-related classes.

See #22051.
This commit is contained in:
Vadim Zeitlin 2022-01-27 14:10:29 +01:00
commit 311aa370de
10 changed files with 185 additions and 192 deletions

View File

@ -1235,17 +1235,21 @@ class WXDLLIMPEXP_CORE wxDataViewTreeStoreNode
{
public:
wxDataViewTreeStoreNode( wxDataViewTreeStoreNode *parent,
const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
const wxString &text,
const wxBitmapBundle &icon = wxBitmapBundle(),
wxClientData *data = NULL );
virtual ~wxDataViewTreeStoreNode();
void SetText( const wxString &text )
{ m_text = text; }
wxString GetText() const
{ return m_text; }
void SetIcon( const wxIcon &icon )
void SetIcon( const wxBitmapBundle &icon )
{ m_icon = icon; }
const wxIcon &GetIcon() const
const wxBitmapBundle& GetBitmapBundle() const
{ return m_icon; }
wxIcon GetIcon() const
{ return m_icon.GetIcon(wxDefaultSize); }
void SetData( wxClientData *data )
{ delete m_data; m_data = data; }
wxClientData *GetData() const
@ -1263,7 +1267,7 @@ public:
private:
wxDataViewTreeStoreNode *m_parent;
wxString m_text;
wxIcon m_icon;
wxBitmapBundle m_icon;
wxClientData *m_data;
};
@ -1273,7 +1277,9 @@ class WXDLLIMPEXP_CORE wxDataViewTreeStoreContainerNode: public wxDataViewTreeSt
{
public:
wxDataViewTreeStoreContainerNode( wxDataViewTreeStoreNode *parent,
const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
const wxString &text,
const wxBitmapBundle &icon = wxBitmapBundle(),
const wxBitmapBundle &expanded = wxBitmapBundle(),
wxClientData *data = NULL );
virtual ~wxDataViewTreeStoreContainerNode();
@ -1284,10 +1290,12 @@ public:
wxDataViewTreeStoreNodes::iterator FindChild(wxDataViewTreeStoreNode* node);
void SetExpandedIcon( const wxIcon &icon )
void SetExpandedIcon( const wxBitmapBundle &icon )
{ m_iconExpanded = icon; }
const wxIcon &GetExpandedIcon() const
const wxBitmapBundle& GetExpandedBitmapBundle() const
{ return m_iconExpanded; }
wxIcon GetExpandedIcon() const
{ return m_iconExpanded.GetIcon(wxDefaultSize); }
void SetExpanded( bool expanded = true )
{ m_isExpanded = expanded; }
@ -1301,7 +1309,7 @@ public:
private:
wxDataViewTreeStoreNodes m_children;
wxIcon m_iconExpanded;
wxBitmapBundle m_iconExpanded;
bool m_isExpanded;
};
@ -1314,20 +1322,32 @@ public:
~wxDataViewTreeStore();
wxDataViewItem AppendItem( const wxDataViewItem& parent,
const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
const wxString &text,
const wxBitmapBundle &icon = wxBitmapBundle(),
wxClientData *data = NULL );
wxDataViewItem PrependItem( const wxDataViewItem& parent,
const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
const wxString &text,
const wxBitmapBundle &icon = wxBitmapBundle(),
wxClientData *data = NULL );
wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
const wxString &text, const wxIcon &icon = wxNullIcon, wxClientData *data = NULL );
const wxString &text,
const wxBitmapBundle &icon = wxBitmapBundle(),
wxClientData *data = NULL );
wxDataViewItem PrependContainer( const wxDataViewItem& parent,
const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
const wxString &text,
const wxBitmapBundle &icon = wxBitmapBundle(),
const wxBitmapBundle &expanded = wxBitmapBundle(),
wxClientData *data = NULL );
wxDataViewItem AppendContainer( const wxDataViewItem& parent,
const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
const wxString &text,
const wxBitmapBundle &icon = wxBitmapBundle(),
const wxBitmapBundle &expanded = wxBitmapBundle(),
wxClientData *data = NULL );
wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
const wxString &text, const wxIcon &icon = wxNullIcon, const wxIcon &expanded = wxNullIcon,
const wxString &text,
const wxBitmapBundle &icon = wxBitmapBundle(),
const wxBitmapBundle &expanded = wxBitmapBundle(),
wxClientData *data = NULL );
wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const;
@ -1335,10 +1355,12 @@ public:
void SetItemText( const wxDataViewItem& item, const wxString &text );
wxString GetItemText( const wxDataViewItem& item ) const;
void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon );
const wxIcon &GetItemIcon( const wxDataViewItem& item ) const;
void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon );
const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const;
void SetItemIcon( const wxDataViewItem& item, const wxBitmapBundle &icon );
wxBitmapBundle GetItemBitmapBundle( const wxDataViewItem& item ) const;
wxIcon GetItemIcon( const wxDataViewItem& item ) const;
void SetItemExpandedIcon( const wxDataViewItem& item, const wxBitmapBundle &icon );
wxBitmapBundle GetItemExpandedBitmapBundle( const wxDataViewItem& item ) const;
wxIcon GetItemExpandedIcon( const wxDataViewItem& item ) const;
void SetItemData( const wxDataViewItem& item, wxClientData *data );
wxClientData *GetItemData( const wxDataViewItem& item ) const;
@ -1433,11 +1455,11 @@ public:
void SetItemText( const wxDataViewItem& item, const wxString &text );
wxString GetItemText( const wxDataViewItem& item ) const
{ return GetStore()->GetItemText(item); }
void SetItemIcon( const wxDataViewItem& item, const wxIcon &icon );
const wxIcon &GetItemIcon( const wxDataViewItem& item ) const
void SetItemIcon( const wxDataViewItem& item, const wxBitmapBundle &icon );
wxIcon GetItemIcon( const wxDataViewItem& item ) const
{ return GetStore()->GetItemIcon(item); }
void SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon );
const wxIcon &GetItemExpandedIcon( const wxDataViewItem& item ) const
void SetItemExpandedIcon( const wxDataViewItem& item, const wxBitmapBundle &icon );
wxIcon GetItemExpandedIcon( const wxDataViewItem& item ) const
{ return GetStore()->GetItemExpandedIcon(item); }
void SetItemData( const wxDataViewItem& item, wxClientData *data )
{ GetStore()->SetItemData(item,data); }
@ -1452,6 +1474,9 @@ public:
void OnCollapsed( wxDataViewEvent &event );
void OnSize( wxSizeEvent &event );
protected:
virtual void OnImagesChanged() wxOVERRIDE;
private:
wxDECLARE_EVENT_TABLE();
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl);

View File

@ -37,19 +37,24 @@ class WXDLLIMPEXP_CORE wxDataViewIconText : public wxObject
{
public:
wxDataViewIconText( const wxString &text = wxEmptyString,
const wxIcon& icon = wxNullIcon )
const wxBitmapBundle& bitmap = wxBitmapBundle() )
: m_text(text),
m_icon(icon)
m_bitmap(bitmap)
{ }
void SetText( const wxString &text ) { m_text = text; }
wxString GetText() const { return m_text; }
void SetIcon( const wxIcon &icon ) { m_icon = icon; }
const wxIcon &GetIcon() const { return m_icon; }
void SetBitmapBundle(const wxBitmapBundle& bitmap) { m_bitmap = bitmap; }
const wxBitmapBundle& GetBitmapBundle() const { return m_bitmap; }
// These methods exist for compatibility, prefer using the methods above.
void SetIcon( const wxIcon &icon ) { m_bitmap = wxBitmapBundle(icon); }
wxIcon GetIcon() const { return m_bitmap.GetIcon(wxDefaultSize); }
bool IsSameAs(const wxDataViewIconText& other) const
{
return m_text == other.m_text && m_icon.IsSameAs(other.m_icon);
return m_text == other.m_text && m_bitmap.IsSameAs(other.m_bitmap);
}
bool operator==(const wxDataViewIconText& other) const
@ -64,7 +69,7 @@ public:
private:
wxString m_text;
wxIcon m_icon;
wxBitmapBundle m_bitmap;
wxDECLARE_DYNAMIC_CLASS(wxDataViewIconText);
};
@ -79,7 +84,7 @@ class WXDLLIMPEXP_CORE wxDataViewCheckIconText : public wxDataViewIconText
{
public:
wxDataViewCheckIconText(const wxString& text = wxString(),
const wxIcon& icon = wxNullIcon,
const wxBitmapBundle& icon = wxBitmapBundle(),
wxCheckBoxState checkedState = wxCHK_UNDETERMINED)
: wxDataViewIconText(text, icon),
m_checkedState(checkedState)

View File

@ -3294,12 +3294,12 @@ public:
/**
Calls the identical method from wxDataViewTreeStore.
*/
const wxIcon& GetItemExpandedIcon(const wxDataViewItem& item) const;
wxIcon GetItemExpandedIcon(const wxDataViewItem& item) const;
/**
Calls the identical method from wxDataViewTreeStore.
*/
const wxIcon& GetItemIcon(const wxDataViewItem& item) const;
wxIcon GetItemIcon(const wxDataViewItem& item) const;
/**
Returns the item's parent.
@ -3386,12 +3386,12 @@ public:
Calls the identical method from wxDataViewTreeStore.
*/
void SetItemExpandedIcon(const wxDataViewItem& item,
const wxIcon& icon);
const wxBitmapBundle& icon);
/**
Calls the identical method from wxDataViewTreeStore.
*/
void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon);
void SetItemIcon(const wxDataViewItem& item, const wxBitmapBundle& icon);
/**
Calls the identical method from wxDataViewTreeStore.
@ -3589,8 +3589,8 @@ public:
*/
wxDataViewItem AppendContainer(const wxDataViewItem& parent,
const wxString& text,
const wxIcon& icon = wxNullIcon,
const wxIcon& expanded = wxNullIcon,
const wxBitmapBundle& icon = wxBitmapBundle(),
const wxBitmapBundle& expanded = wxBitmapBundle(),
wxClientData* data = NULL);
/**
@ -3598,7 +3598,7 @@ public:
*/
wxDataViewItem AppendItem(const wxDataViewItem& parent,
const wxString& text,
const wxIcon& icon = wxNullIcon,
const wxBitmapBundle& icon = wxBitmapBundle(),
wxClientData* data = NULL);
/**
@ -3629,12 +3629,12 @@ public:
/**
Returns the icon to display in expanded containers.
*/
const wxIcon& GetItemExpandedIcon(const wxDataViewItem& item) const;
wxIcon GetItemExpandedIcon(const wxDataViewItem& item) const;
/**
Returns the icon of the item.
*/
const wxIcon& GetItemIcon(const wxDataViewItem& item) const;
wxIcon GetItemIcon(const wxDataViewItem& item) const;
/**
Returns the text of the item.
@ -3653,8 +3653,8 @@ public:
wxDataViewItem InsertContainer(const wxDataViewItem& parent,
const wxDataViewItem& previous,
const wxString& text,
const wxIcon& icon = wxNullIcon,
const wxIcon& expanded = wxNullIcon,
const wxBitmapBundle& icon = wxBitmapBundle(),
const wxBitmapBundle& expanded = wxBitmapBundle(),
wxClientData* data = NULL);
/**
@ -3663,7 +3663,7 @@ public:
wxDataViewItem InsertItem(const wxDataViewItem& parent,
const wxDataViewItem& previous,
const wxString& text,
const wxIcon& icon = wxNullIcon,
const wxBitmapBundle& icon = wxBitmapBundle(),
wxClientData* data = NULL);
/**
@ -3671,8 +3671,8 @@ public:
*/
wxDataViewItem PrependContainer(const wxDataViewItem& parent,
const wxString& text,
const wxIcon& icon = wxNullIcon,
const wxIcon& expanded = wxNullIcon,
const wxBitmapBundle& icon = wxBitmapBundle(),
const wxBitmapBundle& expanded = wxBitmapBundle(),
wxClientData* data = NULL);
/**
@ -3680,7 +3680,7 @@ public:
*/
wxDataViewItem PrependItem(const wxDataViewItem& parent,
const wxString& text,
const wxIcon& icon = wxNullIcon,
const wxBitmapBundle& icon = wxBitmapBundle(),
wxClientData* data = NULL);
/**
@ -3692,12 +3692,12 @@ public:
Sets the expanded icon for the item.
*/
void SetItemExpandedIcon(const wxDataViewItem& item,
const wxIcon& icon);
const wxBitmapBundle& icon);
/**
Sets the icon for the item.
*/
void SetItemIcon(const wxDataViewItem& item, const wxIcon& icon);
void SetItemIcon(const wxDataViewItem& item, const wxBitmapBundle& icon);
};
@ -3718,22 +3718,47 @@ public:
Constructor.
*/
wxDataViewIconText(const wxString& text = wxEmptyString,
const wxIcon& icon = wxNullIcon);
const wxBitmapBundle& bitmap = wxBitmapBundle());
wxDataViewIconText(const wxDataViewIconText& other);
//@}
/**
Gets the associated image.
@since 3.1.6
*/
const wxBitmapBundle& GetBitmapBundle() const;
/**
Gets the icon.
This function can only return the icon in the size appropriate for the
standard 100% DPI scaling, use GetBitmapBundle() to retrieve image
representation suitable for another DPI scaling value.
*/
const wxIcon& GetIcon() const;
wxIcon GetIcon() const;
/**
Gets the text.
*/
wxString GetText() const;
/**
Sets the associated image.
This function allows to provide several representations of the same
image, so that the most appropriate one for the current DPI scaling
could be used, and so should be preferred to SetIcon().
@since 3.1.6
*/
void SetBitmapBundle(const wxBitmapBundle& bitmap);
/**
Set the icon.
Use SetBitmapBundle() instead to allow specifying different image
representations for different DPI scaling values.
*/
void SetIcon(const wxIcon& icon);

View File

@ -47,8 +47,6 @@
#include "../sample.xpm"
#endif
#include "wx_small.xpm"
// ----------------------------------------------------------------------------
// MyApp
// ----------------------------------------------------------------------------
@ -992,13 +990,13 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel,
wxDefaultSize, style | wxDV_NO_HEADER );
m_ctrl[Page_TreeStore] = tc;
const bool useDefaultSize = !HasModelFlag(MODEL_USE_TALL_ROWS)
|| HasModelFlag(MODEL_KEEP_LOGO_SMALL);
const int imageSize = useDefaultSize ? 16 : 32;
wxImageList *ilist = new wxImageList( imageSize, imageSize );
const wxSize size = GetIconSizeFromModelFlags(m_modelFlags[nPanel]);
ilist->Add( wxIcon(wx_small_xpm) );
tc->AssignImageList( ilist );
wxDataViewTreeCtrl::Images images;
images.push_back(
wxArtProvider::GetBitmapBundle(wxART_WX_LOGO, wxART_LIST, size)
);
tc->SetImages(images);
const wxDataViewItem root =
tc->AppendContainer( wxDataViewItem(0), "The Root", 0 );
@ -1106,7 +1104,7 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel,
}
if ( HasModelFlag(MODEL_USE_TALL_ROWS) )
m_ctrl[nPanel]->SetRowHeight(32);
m_ctrl[nPanel]->SetRowHeight(FromDIP(32));
}

View File

@ -17,17 +17,10 @@
#include "wx/wx.h"
#endif
#include "wx/artprov.h"
#include "wx/dataview.h"
#include "mymodels.h"
// ----------------------------------------------------------------------------
// resources
// ----------------------------------------------------------------------------
#include "null.xpm"
#include "wx_small.xpm"
// ----------------------------------------------------------------------------
// MyMusicTreeModel
// ----------------------------------------------------------------------------
@ -378,20 +371,10 @@ MyListModel::MyListModel(int modelFlags) :
m_iconColValues.assign(NUMBER_REAL_ITEMS,
useMultiLine ? multiLineText : wxString("test"));
m_icon[0] = wxIcon( null_xpm );
const wxSize size = GetIconSizeFromModelFlags(modelFlags);
const int newSize = m_icon[0].GetWidth() * 2;
const bool useTallRows = (modelFlags & MODEL_USE_TALL_ROWS) != 0;
if ( useTallRows )
m_icon[0].CopyFromBitmap(
wxImage(null_xpm).Rescale(newSize, newSize));
if ( !useTallRows || (modelFlags & MODEL_KEEP_LOGO_SMALL) )
m_icon[1] = wxIcon( wx_small_xpm );
else
m_icon[1].CopyFromBitmap(
wxImage(wx_small_xpm).Rescale(newSize, newSize));
m_icon[0] = wxArtProvider::GetBitmapBundle(wxART_QUESTION, wxART_LIST, size);
m_icon[1] = wxArtProvider::GetBitmapBundle(wxART_WX_LOGO, wxART_LIST, size);
}
void MyListModel::Prepend( const wxString &text )

View File

@ -253,7 +253,7 @@ private:
wxArrayString m_textColValues;
wxArrayString m_iconColValues;
IntToStringMap m_customColValues;
wxIcon m_icon[2];
wxBitmapBundle m_icon[2];
};
// ----------------------------------------------------------------------------
@ -317,3 +317,12 @@ enum ModelFlags
MODEL_KEEP_LOGO_SMALL = 1 << 1,
MODEL_USE_MULTI_LINE_TEXT = 1 << 2
};
inline wxSize GetIconSizeFromModelFlags(int modelFlags)
{
wxSize size(16, 16);
if ( (modelFlags & MODEL_USE_TALL_ROWS) && !(modelFlags & MODEL_KEEP_LOGO_SMALL) )
size *= 2;
return size;
}

View File

@ -1,30 +0,0 @@
/* XPM */
static const char *const null_xpm[] = {
"16 16 11 1",
" c None",
". c #000000",
"+ c #FFFFFF",
"@ c #FDE4E4",
"# c #F45C5C",
"$ c #EF0B0B",
"% c #F12727",
"& c #F67878",
"* c #FAAEAE",
"= c #FBC9C9",
"- c #F89393",
"................",
".++++++++++++++.",
".++++++++++++++.",
".++++@#$$%&++++.",
".+++@%$$$$$&+++.",
".+++&$$#*%$$+++.",
".+++=-#+@%$%+++.",
".++++++@%$$*+++.",
".++++++%$%@++++.",
".+++++*$$*+++++.",
".+++++@**@+++++.",
".+++++*$$*+++++.",
".+++++*$$*+++++.",
".+++++@**@+++++.",
".++++++++++++++.",
"................"};

View File

@ -1,28 +0,0 @@
/* XPM */
static const char *wx_small_xpm[] = {
/* columns rows colors chars-per-pixel */
"16 16 6 1",
". c Black",
"o c #FFFFFF",
"X c #000080",
"O c #FFFF00",
" c None",
"+ c #FF0000",
/* pixels */
" ",
" ",
" ",
" ....... ",
" .XXXXX. ",
" .oXXXX. ",
" .oXXX.......",
".....oXXX.OOOOO.",
".+++.XXXX.oOOOO.",
".o++......oOOOO.",
".o++++. .oOOOO.",
".o++++. .OOOOO.",
".+++++. .......",
"....... ",
" ",
" "
};

View File

@ -2184,11 +2184,7 @@ wxSize wxDataViewCheckIconTextRenderer::GetSize() const
if ( m_value.GetIcon().IsOk() )
{
#ifdef __WXGTK3__
const wxSize sizeIcon = m_value.GetIcon().GetLogicalSize();
#else
const wxSize sizeIcon = m_value.GetIcon().GetSize();
#endif
if ( sizeIcon.y > size.y )
size.y = sizeIcon.y;
@ -2221,15 +2217,11 @@ bool wxDataViewCheckIconTextRenderer::Render(wxRect cell, wxDC* dc, int state)
int xoffset = sizeCheck.x + MARGIN_CHECK_ICON;
wxRect rectIcon;
const wxIcon& icon = m_value.GetIcon();
const bool drawIcon = icon.IsOk();
const wxBitmapBundle& bb = m_value.GetBitmapBundle();
const bool drawIcon = bb.IsOk();
if ( drawIcon )
{
#ifdef __WXGTK3__
const wxSize sizeIcon = icon.GetLogicalSize();
#else
const wxSize sizeIcon = icon.GetSize();
#endif
const wxSize sizeIcon = bb.GetPreferredSizeFor(GetView());
rectIcon = wxRect(cell.GetPosition(), sizeIcon);
rectIcon.x += xoffset;
rectIcon = rectIcon.CentreIn(cell, wxVERTICAL);
@ -2268,7 +2260,7 @@ bool wxDataViewCheckIconTextRenderer::Render(wxRect cell, wxDC* dc, int state)
// Finally draw the icon, if any.
if ( drawIcon )
dc->DrawIcon(icon, rectIcon.GetPosition());
dc->DrawIcon(bb.GetIconFor(GetView()), rectIcon.GetPosition());
return true;
}
@ -2591,7 +2583,7 @@ wxDataViewColumn *wxDataViewListCtrl::AppendIconTextColumn( const wxString &labe
wxDataViewTreeStoreNode::wxDataViewTreeStoreNode(
wxDataViewTreeStoreNode *parent,
const wxString &text, const wxIcon &icon, wxClientData *data )
const wxString &text, const wxBitmapBundle &icon, wxClientData *data )
: m_text(text)
, m_icon(icon)
{
@ -2606,7 +2598,7 @@ wxDataViewTreeStoreNode::~wxDataViewTreeStoreNode()
wxDataViewTreeStoreContainerNode::wxDataViewTreeStoreContainerNode(
wxDataViewTreeStoreNode *parent, const wxString &text,
const wxIcon &icon, const wxIcon &expanded, wxClientData *data )
const wxBitmapBundle &icon, const wxBitmapBundle &expanded, wxClientData *data )
: wxDataViewTreeStoreNode( parent, text, icon, data )
, m_iconExpanded(expanded)
{
@ -2655,7 +2647,7 @@ wxDataViewTreeStore::~wxDataViewTreeStore()
}
wxDataViewItem wxDataViewTreeStore::AppendItem( const wxDataViewItem& parent,
const wxString &text, const wxIcon &icon, wxClientData *data )
const wxString &text, const wxBitmapBundle &icon, wxClientData *data )
{
wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent );
if (!parent_node) return wxDataViewItem(0);
@ -2668,7 +2660,7 @@ wxDataViewItem wxDataViewTreeStore::AppendItem( const wxDataViewItem& parent,
}
wxDataViewItem wxDataViewTreeStore::PrependItem( const wxDataViewItem& parent,
const wxString &text, const wxIcon &icon, wxClientData *data )
const wxString &text, const wxBitmapBundle &icon, wxClientData *data )
{
wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent );
if (!parent_node) return wxDataViewItem(0);
@ -2685,7 +2677,7 @@ wxDataViewItem
wxDataViewTreeStore::InsertItem(const wxDataViewItem& parent,
const wxDataViewItem& previous,
const wxString& text,
const wxIcon& icon,
const wxBitmapBundle& icon,
wxClientData *data)
{
wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent );
@ -2704,7 +2696,7 @@ wxDataViewTreeStore::InsertItem(const wxDataViewItem& parent,
}
wxDataViewItem wxDataViewTreeStore::PrependContainer( const wxDataViewItem& parent,
const wxString &text, const wxIcon &icon, const wxIcon &expanded,
const wxString &text, const wxBitmapBundle &icon, const wxBitmapBundle &expanded,
wxClientData *data )
{
wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent );
@ -2721,8 +2713,8 @@ wxDataViewItem wxDataViewTreeStore::PrependContainer( const wxDataViewItem& pare
wxDataViewItem
wxDataViewTreeStore::AppendContainer(const wxDataViewItem& parent,
const wxString &text,
const wxIcon& icon,
const wxIcon& expanded,
const wxBitmapBundle& icon,
const wxBitmapBundle& expanded,
wxClientData * data)
{
wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent );
@ -2739,8 +2731,8 @@ wxDataViewItem
wxDataViewTreeStore::InsertContainer(const wxDataViewItem& parent,
const wxDataViewItem& previous,
const wxString& text,
const wxIcon& icon,
const wxIcon& expanded,
const wxBitmapBundle& icon,
const wxBitmapBundle& expanded,
wxClientData * data)
{
wxDataViewTreeStoreContainerNode *parent_node = FindContainerNode( parent );
@ -2806,7 +2798,7 @@ wxString wxDataViewTreeStore::GetItemText( const wxDataViewItem& item ) const
return node->GetText();
}
void wxDataViewTreeStore::SetItemIcon( const wxDataViewItem& item, const wxIcon &icon )
void wxDataViewTreeStore::SetItemIcon( const wxDataViewItem& item, const wxBitmapBundle &icon )
{
wxDataViewTreeStoreNode *node = FindNode( item );
if (!node) return;
@ -2814,7 +2806,7 @@ void wxDataViewTreeStore::SetItemIcon( const wxDataViewItem& item, const wxIcon
node->SetIcon( icon );
}
const wxIcon &wxDataViewTreeStore::GetItemIcon( const wxDataViewItem& item ) const
wxIcon wxDataViewTreeStore::GetItemIcon( const wxDataViewItem& item ) const
{
wxDataViewTreeStoreNode *node = FindNode( item );
if (!node) return wxNullIcon;
@ -2822,7 +2814,7 @@ const wxIcon &wxDataViewTreeStore::GetItemIcon( const wxDataViewItem& item ) con
return node->GetIcon();
}
void wxDataViewTreeStore::SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon )
void wxDataViewTreeStore::SetItemExpandedIcon( const wxDataViewItem& item, const wxBitmapBundle &icon )
{
wxDataViewTreeStoreContainerNode *node = FindContainerNode( item );
if (!node) return;
@ -2830,7 +2822,7 @@ void wxDataViewTreeStore::SetItemExpandedIcon( const wxDataViewItem& item, const
node->SetExpandedIcon( icon );
}
const wxIcon &wxDataViewTreeStore::GetItemExpandedIcon( const wxDataViewItem& item ) const
wxIcon wxDataViewTreeStore::GetItemExpandedIcon( const wxDataViewItem& item ) const
{
wxDataViewTreeStoreContainerNode *node = FindContainerNode( item );
if (!node) return wxNullIcon;
@ -2895,15 +2887,18 @@ wxDataViewTreeStore::GetValue(wxVariant &variant,
wxDataViewTreeStoreNode *node = FindNode( item );
if (!node) return;
wxIcon icon( node->GetIcon());
wxBitmapBundle bb;
if (node->IsContainer())
{
wxDataViewTreeStoreContainerNode *container = (wxDataViewTreeStoreContainerNode*) node;
if (container->IsExpanded() && container->GetExpandedIcon().IsOk())
icon = container->GetExpandedIcon();
if (container->IsExpanded())
bb = container->GetExpandedBitmapBundle();
}
wxDataViewIconText data( node->GetText(), icon );
if (!bb.IsOk())
bb = node->GetBitmapBundle();
wxDataViewIconText data( node->GetText(), bb );
variant << data;
}
@ -3053,7 +3048,7 @@ wxDataViewItem wxDataViewTreeCtrl::AppendItem( const wxDataViewItem& parent,
const wxString &text, int iconIndex, wxClientData *data )
{
wxDataViewItem res = GetStore()->
AppendItem( parent, text, GetImage(iconIndex), data );
AppendItem( parent, text, GetBitmapBundle(iconIndex), data );
GetStore()->ItemAdded( parent, res );
@ -3064,7 +3059,7 @@ wxDataViewItem wxDataViewTreeCtrl::PrependItem( const wxDataViewItem& parent,
const wxString &text, int iconIndex, wxClientData *data )
{
wxDataViewItem res = GetStore()->
PrependItem( parent, text, GetImage(iconIndex), data );
PrependItem( parent, text, GetBitmapBundle(iconIndex), data );
GetStore()->ItemAdded( parent, res );
@ -3075,7 +3070,7 @@ wxDataViewItem wxDataViewTreeCtrl::InsertItem( const wxDataViewItem& parent, con
const wxString &text, int iconIndex, wxClientData *data )
{
wxDataViewItem res = GetStore()->
InsertItem( parent, previous, text, GetImage(iconIndex), data );
InsertItem( parent, previous, text, GetBitmapBundle(iconIndex), data );
GetStore()->ItemAdded( parent, res );
@ -3087,7 +3082,7 @@ wxDataViewItem wxDataViewTreeCtrl::PrependContainer( const wxDataViewItem& paren
{
wxDataViewItem res = GetStore()->
PrependContainer( parent, text,
GetImage(iconIndex), GetImage(expandedIndex), data );
GetBitmapBundle(iconIndex), GetBitmapBundle(expandedIndex), data );
GetStore()->ItemAdded( parent, res );
@ -3099,7 +3094,7 @@ wxDataViewItem wxDataViewTreeCtrl::AppendContainer( const wxDataViewItem& parent
{
wxDataViewItem res = GetStore()->
AppendContainer( parent, text,
GetImage(iconIndex), GetImage(expandedIndex), data );
GetBitmapBundle(iconIndex), GetBitmapBundle(expandedIndex), data );
GetStore()->ItemAdded( parent, res );
@ -3111,7 +3106,7 @@ wxDataViewItem wxDataViewTreeCtrl::InsertContainer( const wxDataViewItem& parent
{
wxDataViewItem res = GetStore()->
InsertContainer( parent, previous, text,
GetImage(iconIndex), GetImage(expandedIndex), data );
GetBitmapBundle(iconIndex), GetBitmapBundle(expandedIndex), data );
GetStore()->ItemAdded( parent, res );
@ -3126,7 +3121,7 @@ void wxDataViewTreeCtrl::SetItemText( const wxDataViewItem& item, const wxString
GetStore()->ValueChanged( item, 0 );
}
void wxDataViewTreeCtrl::SetItemIcon( const wxDataViewItem& item, const wxIcon &icon )
void wxDataViewTreeCtrl::SetItemIcon( const wxDataViewItem& item, const wxBitmapBundle &icon )
{
GetStore()->SetItemIcon(item,icon);
@ -3134,7 +3129,7 @@ void wxDataViewTreeCtrl::SetItemIcon( const wxDataViewItem& item, const wxIcon &
GetStore()->ValueChanged( item, 0 );
}
void wxDataViewTreeCtrl::SetItemExpandedIcon( const wxDataViewItem& item, const wxIcon &icon )
void wxDataViewTreeCtrl::SetItemExpandedIcon( const wxDataViewItem& item, const wxBitmapBundle &icon )
{
GetStore()->SetItemExpandedIcon(item,icon);
@ -3180,8 +3175,6 @@ void wxDataViewTreeCtrl::DeleteAllItems()
void wxDataViewTreeCtrl::OnExpanded( wxDataViewEvent &event )
{
if (!HasImageList()) return;
wxDataViewTreeStoreContainerNode* container = GetStore()->FindContainerNode( event.GetItem() );
if (!container) return;
@ -3192,8 +3185,6 @@ void wxDataViewTreeCtrl::OnExpanded( wxDataViewEvent &event )
void wxDataViewTreeCtrl::OnCollapsed( wxDataViewEvent &event )
{
if (!HasImageList()) return;
wxDataViewTreeStoreContainerNode* container = GetStore()->FindContainerNode( event.GetItem() );
if (!container) return;
@ -3215,4 +3206,9 @@ void wxDataViewTreeCtrl::OnSize( wxSizeEvent &event )
event.Skip( true );
}
void wxDataViewTreeCtrl::OnImagesChanged()
{
Refresh();
}
#endif // wxUSE_DATAVIEWCTRL

View File

@ -1514,7 +1514,7 @@ wxSize wxDataViewProgressRenderer::GetSize() const
// renderers, it doesn't have a "good" width for the content. This makes it
// grow to the whole column, which is pretty much always the desired
// behaviour. Keep the height fixed so that the progress bar isn't too fat.
return wxSize(-1, 12);
return GetView()->FromDIP(wxSize(-1, 12));
}
// ---------------------------------------------------------
@ -1553,11 +1553,13 @@ bool wxDataViewIconTextRenderer::Render(wxRect rect, wxDC *dc, int state)
{
int xoffset = 0;
const wxIcon& icon = m_value.GetIcon();
if ( icon.IsOk() )
const wxBitmapBundle& bb = m_value.GetBitmapBundle();
if ( bb.IsOk() )
{
dc->DrawIcon(icon, rect.x, rect.y + (rect.height - icon.GetHeight())/2);
xoffset = icon.GetWidth()+4;
wxWindow* const dvc = GetView();
const wxIcon& icon = bb.GetIconFor(dvc);
dc->DrawIcon(icon, rect.x, rect.y + (rect.height - icon.GetLogicalHeight())/2);
xoffset = icon.GetLogicalWidth() + dvc->FromDIP(4);
}
RenderText(m_value.GetText(), xoffset, rect, dc, state);
@ -1567,15 +1569,18 @@ bool wxDataViewIconTextRenderer::Render(wxRect rect, wxDC *dc, int state)
wxSize wxDataViewIconTextRenderer::GetSize() const
{
wxWindow* const dvc = GetView();
if (!m_value.GetText().empty())
{
wxSize size = GetTextExtent(m_value.GetText());
if (m_value.GetIcon().IsOk())
size.x += m_value.GetIcon().GetWidth() + 4;
const wxBitmapBundle& bb = m_value.GetBitmapBundle();
if (bb.IsOk())
size.x += bb.GetPreferredSizeFor(dvc).x + dvc->FromDIP(4);
return size;
}
return wxSize(80,20);
return dvc->FromDIP(wxSize(80,20));
}
wxWindow* wxDataViewIconTextRenderer::CreateEditorCtrl(wxWindow *parent, wxRect labelRect, const wxVariant& value)
@ -1586,9 +1591,12 @@ wxWindow* wxDataViewIconTextRenderer::CreateEditorCtrl(wxWindow *parent, wxRect
wxString text = iconText.GetText();
// adjust the label rect to take the width of the icon into account
if (iconText.GetIcon().IsOk())
const wxBitmapBundle& bb = iconText.GetBitmapBundle();
if (bb.IsOk())
{
int w = iconText.GetIcon().GetWidth() + 4;
wxWindow* const dvc = GetView();
int w = bb.GetPreferredSizeFor(dvc).x + dvc->FromDIP(4);
labelRect.x += w;
labelRect.width -= w;
}
@ -2113,14 +2121,16 @@ wxDataViewMainWindow::~wxDataViewMainWindow()
int wxDataViewMainWindow::GetDefaultRowHeight() const
{
const int SMALL_ICON_HEIGHT = FromDIP(16);
#ifdef __WXMSW__
// We would like to use the same line height that Explorer uses. This is
// different from standard ListView control since Vista.
if ( wxGetWinVersion() >= wxWinVersion_Vista )
return wxMax(16, GetCharHeight()) + 6; // 16 = mini icon height
return wxMax(SMALL_ICON_HEIGHT, GetCharHeight()) + FromDIP(6);
else
#endif // __WXMSW__
return wxMax(16, GetCharHeight()) + 1; // 16 = mini icon height
return wxMax(SMALL_ICON_HEIGHT, GetCharHeight()) + FromDIP(1);
}
@ -3381,7 +3391,7 @@ void wxDataViewMainWindow::RecalculateDisplay()
int height = GetLineStart( GetRowCount() );
SetVirtualSize( width, height );
GetOwner()->SetScrollRate( 10, m_lineHeight );
GetOwner()->SetScrollRate( FromDIP(10), m_lineHeight );
UpdateColumnSizes();
Refresh();