Support bitmaps and text and header columns using wxImageList, minor sizing corrections
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53171 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -823,8 +823,8 @@ MyFrame::MyFrame(wxFrame *frame, const wxString &title, int x, int y, int w, int
|
|||||||
m_listCtrl->AssociateModel( m_list_model.get() );
|
m_listCtrl->AssociateModel( m_list_model.get() );
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
m_listCtrl->AppendTextColumn (wxT("editable string"), 0, wxDATAVIEW_CELL_EDITABLE, 120, wxALIGN_RIGHT );
|
m_listCtrl->AppendTextColumn (wxT("editable string"), 0, wxDATAVIEW_CELL_EDITABLE, 120 );
|
||||||
m_listCtrl->AppendIconTextColumn(wxIcon(small1_xpm), 1, wxDATAVIEW_CELL_INERT )->SetTitle( wxT("icon") );
|
m_listCtrl->AppendIconTextColumn(wxIcon(small1_xpm), 1, wxDATAVIEW_CELL_INERT )->SetTitle( wxT("icon") );
|
||||||
#else
|
#else
|
||||||
m_listCtrl->AppendTextColumn (wxT("editable string"), 0, wxDATAVIEW_CELL_EDITABLE );
|
m_listCtrl->AppendTextColumn (wxT("editable string"), 0, wxDATAVIEW_CELL_EDITABLE );
|
||||||
m_listCtrl->AppendIconTextColumn(wxT("icon"), 1, wxDATAVIEW_CELL_INERT );
|
m_listCtrl->AppendIconTextColumn(wxT("icon"), 1, wxDATAVIEW_CELL_INERT );
|
||||||
|
@@ -44,6 +44,7 @@
|
|||||||
#include "wx/icon.h"
|
#include "wx/icon.h"
|
||||||
#include "wx/list.h"
|
#include "wx/list.h"
|
||||||
#include "wx/listimpl.cpp"
|
#include "wx/listimpl.cpp"
|
||||||
|
#include "wx/imaglist.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// classes
|
// classes
|
||||||
@@ -159,9 +160,10 @@ protected:
|
|||||||
wxDataViewColumn *GetColumnFromHeader(NMHEADER *nmHDR)
|
wxDataViewColumn *GetColumnFromHeader(NMHEADER *nmHDR)
|
||||||
{ return GetColumn(GetColumnIdxFromHeader(nmHDR)); }
|
{ return GetColumn(GetColumnIdxFromHeader(nmHDR)); }
|
||||||
|
|
||||||
int m_scrollOffsetX;
|
int m_scrollOffsetX;
|
||||||
int m_buttonHeight;
|
int m_buttonHeight;
|
||||||
bool m_delayedUpdate;
|
bool m_delayedUpdate;
|
||||||
|
wxImageList *m_imageList;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxDataViewHeaderWindowMSW)
|
DECLARE_DYNAMIC_CLASS(wxDataViewHeaderWindowMSW)
|
||||||
@@ -1185,7 +1187,7 @@ wxDataViewColumn::wxDataViewColumn( const wxBitmap &bitmap, wxDataViewRenderer *
|
|||||||
SetAlignment(align);
|
SetAlignment(align);
|
||||||
SetFlags(flags);
|
SetFlags(flags);
|
||||||
|
|
||||||
Init(width < 0 ? wxDVC_TOGGLE_DEFAULT_WIDTH : width);
|
Init(width < 0 ? wxDVC_DEFAULT_WIDTH : width);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDataViewColumn::~wxDataViewColumn()
|
wxDataViewColumn::~wxDataViewColumn()
|
||||||
@@ -1346,6 +1348,9 @@ bool wxDataViewHeaderWindowMSW::Create( wxDataViewCtrl *parent, wxWindowID id,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_imageList = new wxImageList( 16, 16 );
|
||||||
|
Header_SetImageList( (HWND) m_hWnd, m_imageList->GetHIMAGELIST() );
|
||||||
|
|
||||||
// we need to subclass the m_hWnd to force wxWindow::HandleNotify
|
// we need to subclass the m_hWnd to force wxWindow::HandleNotify
|
||||||
// to call wxDataViewHeaderWindow::MSWOnNotify
|
// to call wxDataViewHeaderWindow::MSWOnNotify
|
||||||
SubclassWin(m_hWnd);
|
SubclassWin(m_hWnd);
|
||||||
@@ -1359,6 +1364,7 @@ bool wxDataViewHeaderWindowMSW::Create( wxDataViewCtrl *parent, wxWindowID id,
|
|||||||
|
|
||||||
wxDataViewHeaderWindowMSW::~wxDataViewHeaderWindow()
|
wxDataViewHeaderWindowMSW::~wxDataViewHeaderWindow()
|
||||||
{
|
{
|
||||||
|
delete m_imageList;
|
||||||
UnsubclassWin();
|
UnsubclassWin();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1382,6 +1388,8 @@ void wxDataViewHeaderWindowMSW::UpdateDisplay()
|
|||||||
for (int j=0, max=Header_GetItemCount((HWND)m_hWnd); j < max; j++)
|
for (int j=0, max=Header_GetItemCount((HWND)m_hWnd); j < max; j++)
|
||||||
Header_DeleteItem((HWND)m_hWnd, 0);
|
Header_DeleteItem((HWND)m_hWnd, 0);
|
||||||
|
|
||||||
|
m_imageList->RemoveAll();
|
||||||
|
|
||||||
// add the updated array of columns to the header control
|
// add the updated array of columns to the header control
|
||||||
unsigned int cols = GetOwner()->GetColumnCount();
|
unsigned int cols = GetOwner()->GetColumnCount();
|
||||||
unsigned int added = 0;
|
unsigned int added = 0;
|
||||||
@@ -1395,15 +1403,16 @@ void wxDataViewHeaderWindowMSW::UpdateDisplay()
|
|||||||
hdi.mask = HDI_TEXT | HDI_FORMAT | HDI_WIDTH;
|
hdi.mask = HDI_TEXT | HDI_FORMAT | HDI_WIDTH;
|
||||||
if (col->GetBitmap().IsOk())
|
if (col->GetBitmap().IsOk())
|
||||||
{
|
{
|
||||||
hdi.mask |= HDI_BITMAP;
|
m_imageList->Add( col->GetBitmap() );
|
||||||
hdi.hbm = (HBITMAP) col->GetBitmap().GetHBITMAP();
|
hdi.mask |= HDI_IMAGE;
|
||||||
|
hdi.iImage = m_imageList->GetImageCount()-1;
|
||||||
}
|
}
|
||||||
hdi.pszText = (wxChar *) col->GetTitle().wx_str();
|
hdi.pszText = (wxChar *) col->GetTitle().wx_str();
|
||||||
hdi.cxy = col->GetWidth();
|
hdi.cxy = col->GetWidth();
|
||||||
hdi.cchTextMax = sizeof(hdi.pszText)/sizeof(hdi.pszText[0]);
|
hdi.cchTextMax = sizeof(hdi.pszText)/sizeof(hdi.pszText[0]);
|
||||||
hdi.fmt = HDF_LEFT | HDF_STRING;
|
hdi.fmt = HDF_LEFT | HDF_STRING;
|
||||||
if (col->GetBitmap().IsOk())
|
if (col->GetBitmap().IsOk())
|
||||||
hdi.fmt |= HDF_BITMAP;
|
hdi.fmt |= HDF_IMAGE;
|
||||||
|
|
||||||
//hdi.fmt &= ~(HDF_SORTDOWN|HDF_SORTUP);
|
//hdi.fmt &= ~(HDF_SORTDOWN|HDF_SORTUP);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user