Add changes requested in comments for PR 1906
This commit is contained in:
@@ -2360,8 +2360,7 @@ private:
|
|||||||
|
|
||||||
int m_desiredVisibleRows;
|
int m_desiredVisibleRows;
|
||||||
ImgList m_imgList;
|
ImgList m_imgList;
|
||||||
int m_imageAreaWidth;
|
wxSize m_imgAreaSize;
|
||||||
int m_imageAreaHeight;
|
|
||||||
|
|
||||||
wxColour m_borderColour;
|
wxColour m_borderColour;
|
||||||
wxColour m_bgColour;
|
wxColour m_bgColour;
|
||||||
@@ -2385,8 +2384,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
wxSTCListBoxVisualData::wxSTCListBoxVisualData(int d):m_desiredVisibleRows(d),
|
wxSTCListBoxVisualData::wxSTCListBoxVisualData(int d):m_desiredVisibleRows(d),
|
||||||
m_imageAreaWidth(0), m_imageAreaHeight(0),
|
m_imgAreaSize(0,0), m_useDefaultBgColour(true),
|
||||||
m_useDefaultBgColour(true),
|
|
||||||
m_useDefaultTextColour(true),
|
m_useDefaultTextColour(true),
|
||||||
m_useDefaultHighlightBgColour(true),
|
m_useDefaultHighlightBgColour(true),
|
||||||
m_useDefaultHighlightTextColour(true),
|
m_useDefaultHighlightTextColour(true),
|
||||||
@@ -2419,39 +2417,32 @@ void wxSTCListBoxVisualData::RegisterImage(int type, const wxBitmap& bmp)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ImgList::iterator it=m_imgList.find(type);
|
ImgList::iterator it=m_imgList.find(type);
|
||||||
bool preExisting = false;
|
bool preExistingWithDifferentSize = false;
|
||||||
if ( it != m_imgList.end() )
|
if ( it != m_imgList.end() )
|
||||||
{
|
{
|
||||||
|
if ( it->second.GetSize() != bmp.GetSize() )
|
||||||
|
{
|
||||||
|
preExistingWithDifferentSize = true;
|
||||||
|
}
|
||||||
|
|
||||||
m_imgList.erase(it);
|
m_imgList.erase(it);
|
||||||
preExisting = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_imgList[type] = bmp;
|
m_imgList[type] = bmp;
|
||||||
|
|
||||||
if ( preExisting )
|
if ( preExistingWithDifferentSize )
|
||||||
{
|
{
|
||||||
m_imageAreaWidth = 0;
|
m_imgAreaSize.Set(0,0);
|
||||||
m_imageAreaHeight = 0;
|
|
||||||
|
|
||||||
for ( ImgList::iterator it = m_imgList.begin() ; it != m_imgList.end() ; ++it )
|
for ( ImgList::iterator imgIt = m_imgList.begin() ;
|
||||||
|
imgIt != m_imgList.end() ; ++imgIt )
|
||||||
{
|
{
|
||||||
wxBitmap bmp = it->second;
|
m_imgAreaSize.IncTo(it->second.GetSize());
|
||||||
|
|
||||||
if ( bmp.GetWidth() > m_imageAreaWidth )
|
|
||||||
{
|
|
||||||
m_imageAreaWidth = bmp.GetWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( bmp.GetHeight() > m_imageAreaHeight )
|
|
||||||
{
|
|
||||||
m_imageAreaHeight = bmp.GetHeight();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_imageAreaWidth = wxMax(m_imageAreaWidth, bmp.GetWidth());
|
m_imgAreaSize.IncTo(bmp.GetSize());
|
||||||
m_imageAreaHeight = wxMax(m_imageAreaHeight, bmp.GetHeight());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2486,8 +2477,7 @@ void wxSTCListBoxVisualData::RegisterRGBAImage(int type, int width, int height,
|
|||||||
void wxSTCListBoxVisualData::ClearRegisteredImages()
|
void wxSTCListBoxVisualData::ClearRegisteredImages()
|
||||||
{
|
{
|
||||||
m_imgList.clear();
|
m_imgList.clear();
|
||||||
m_imageAreaWidth = 0;
|
m_imgAreaSize.Set(0,0);
|
||||||
m_imageAreaHeight = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxBitmap* wxSTCListBoxVisualData::GetImage(int i) const
|
const wxBitmap* wxSTCListBoxVisualData::GetImage(int i) const
|
||||||
@@ -2502,12 +2492,12 @@ const wxBitmap* wxSTCListBoxVisualData::GetImage(int i) const
|
|||||||
|
|
||||||
int wxSTCListBoxVisualData::GetImageAreaWidth() const
|
int wxSTCListBoxVisualData::GetImageAreaWidth() const
|
||||||
{
|
{
|
||||||
return m_imageAreaWidth;
|
return m_imgAreaSize.GetWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxSTCListBoxVisualData::GetImageAreaHeight() const
|
int wxSTCListBoxVisualData::GetImageAreaHeight() const
|
||||||
{
|
{
|
||||||
return m_imageAreaHeight;
|
return m_imgAreaSize.GetHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSTCListBoxVisualData::ComputeColours()
|
void wxSTCListBoxVisualData::ComputeColours()
|
||||||
@@ -2729,7 +2719,9 @@ private:
|
|||||||
|
|
||||||
// These are needed when Direct2D is used for drawing.
|
// These are needed when Direct2D is used for drawing.
|
||||||
int m_technology;
|
int m_technology;
|
||||||
void* m_surfaceFontData;
|
#ifdef HAVE_DIRECTWRITE_TECHNOLOGY
|
||||||
|
SurfaceFontDataD2D* m_surfaceFontData;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
wxSTCListBox::wxSTCListBox(wxWindow* parent, wxSTCListBoxVisualData* v,
|
wxSTCListBox::wxSTCListBox(wxWindow* parent, wxSTCListBoxVisualData* v,
|
||||||
@@ -2738,7 +2730,7 @@ wxSTCListBox::wxSTCListBox(wxWindow* parent, wxSTCListBoxVisualData* v,
|
|||||||
m_visualData(v), m_maxStrWidth(0), m_currentRow(wxNOT_FOUND),
|
m_visualData(v), m_maxStrWidth(0), m_currentRow(wxNOT_FOUND),
|
||||||
m_doubleClickAction(NULL), m_doubleClickActionData(NULL),
|
m_doubleClickAction(NULL), m_doubleClickActionData(NULL),
|
||||||
m_aveCharWidth(8), m_textHeight(ht), m_itemHeight(ht),
|
m_aveCharWidth(8), m_textHeight(ht), m_itemHeight(ht),
|
||||||
m_textTopGap(0), m_technology(technology), m_surfaceFontData(NULL)
|
m_textTopGap(0), m_technology(technology)
|
||||||
{
|
{
|
||||||
wxVListBox::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
wxVListBox::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
||||||
wxBORDER_NONE, "AutoCompListBox");
|
wxBORDER_NONE, "AutoCompListBox");
|
||||||
@@ -2767,6 +2759,10 @@ wxSTCListBox::wxSTCListBox(wxWindow* parent, wxSTCListBoxVisualData* v,
|
|||||||
parent->SetOwnBackgroundColour(m_visualData->GetBgColour());
|
parent->SetOwnBackgroundColour(m_visualData->GetBgColour());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_DIRECTWRITE_TECHNOLOGY
|
||||||
|
m_surfaceFontData = NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSTCListBox::~wxSTCListBox()
|
wxSTCListBox::~wxSTCListBox()
|
||||||
@@ -2774,9 +2770,7 @@ wxSTCListBox::~wxSTCListBox()
|
|||||||
#ifdef HAVE_DIRECTWRITE_TECHNOLOGY
|
#ifdef HAVE_DIRECTWRITE_TECHNOLOGY
|
||||||
if ( m_surfaceFontData )
|
if ( m_surfaceFontData )
|
||||||
{
|
{
|
||||||
SurfaceFontDataD2D* fontData =
|
delete m_surfaceFontData;
|
||||||
reinterpret_cast<SurfaceFontDataD2D*>(m_surfaceFontData);
|
|
||||||
delete fontData;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -2798,13 +2792,7 @@ void wxSTCListBox::SetContainerBorderSize(int s)
|
|||||||
|
|
||||||
void wxSTCListBox::SetListBoxFont(Font &font)
|
void wxSTCListBox::SetListBoxFont(Font &font)
|
||||||
{
|
{
|
||||||
if ( m_technology == wxSTC_TECHNOLOGY_DEFAULT )
|
if ( m_technology == wxSTC_TECHNOLOGY_DIRECTWRITE )
|
||||||
{
|
|
||||||
SetFont(*((wxFont*)font.GetID()));
|
|
||||||
int w;
|
|
||||||
GetTextExtent(EXTENT_TEST, &w, &m_textHeight);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DIRECTWRITE_TECHNOLOGY
|
#ifdef HAVE_DIRECTWRITE_TECHNOLOGY
|
||||||
wxFontWithAscent* fwa = wxFontWithAscent::FromFID(font.GetID());
|
wxFontWithAscent* fwa = wxFontWithAscent::FromFID(font.GetID());
|
||||||
@@ -2813,20 +2801,19 @@ void wxSTCListBox::SetListBoxFont(Font &font)
|
|||||||
SurfaceFontDataD2D* d2dft = static_cast<SurfaceFontDataD2D*>(data);
|
SurfaceFontDataD2D* d2dft = static_cast<SurfaceFontDataD2D*>(data);
|
||||||
m_surfaceFontData = new SurfaceFontDataD2D(*d2dft);
|
m_surfaceFontData = new SurfaceFontDataD2D(*d2dft);
|
||||||
|
|
||||||
wxFontWithAscent* fontCopy = new wxFontWithAscent(wxFont());
|
|
||||||
SurfaceFontDataD2D* newSurfaceData = new SurfaceFontDataD2D(*d2dft);
|
|
||||||
fontCopy->SetSurfaceFontData(newSurfaceData);
|
|
||||||
Font tempFont;
|
|
||||||
tempFont.SetID(fontCopy);
|
|
||||||
|
|
||||||
SurfaceD2D surface;
|
SurfaceD2D surface;
|
||||||
wxClientDC dc(this);
|
wxClientDC dc(this);
|
||||||
surface.Init(&dc,GetGrandParent());
|
surface.Init(&dc,GetGrandParent());
|
||||||
m_textHeight = surface.Height(tempFont);
|
m_textHeight = surface.Height(font);
|
||||||
tempFont.Release();
|
|
||||||
surface.Release();
|
surface.Release();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetFont(*((wxFont*)font.GetID()));
|
||||||
|
int w;
|
||||||
|
GetTextExtent(EXTENT_TEST, &w, &m_textHeight);
|
||||||
|
}
|
||||||
|
|
||||||
RecalculateItemHeight();
|
RecalculateItemHeight();
|
||||||
}
|
}
|
||||||
@@ -3097,15 +3084,7 @@ void wxSTCListBox::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const
|
|||||||
else
|
else
|
||||||
textCol = m_visualData->GetTextColour();
|
textCol = m_visualData->GetTextColour();
|
||||||
|
|
||||||
if ( m_technology == wxSTC_TECHNOLOGY_DEFAULT )
|
if ( m_technology == wxSTC_TECHNOLOGY_DIRECTWRITE )
|
||||||
{
|
|
||||||
wxDCTextColourChanger tcc(dc, textCol);
|
|
||||||
|
|
||||||
label = wxControl::Ellipsize(label, dc, wxELLIPSIZE_END,
|
|
||||||
rect.GetWidth() - leftGap);
|
|
||||||
dc.DrawText(label, rect.GetLeft() + leftGap, rect.GetTop() + topGap);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DIRECTWRITE_TECHNOLOGY
|
#ifdef HAVE_DIRECTWRITE_TECHNOLOGY
|
||||||
SurfaceD2D surface;
|
SurfaceD2D surface;
|
||||||
@@ -3113,10 +3092,9 @@ void wxSTCListBox::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const
|
|||||||
|
|
||||||
wxString ellipsizedLabel = label;
|
wxString ellipsizedLabel = label;
|
||||||
|
|
||||||
SurfaceFontDataD2D* fontData =
|
|
||||||
reinterpret_cast<SurfaceFontDataD2D*>(m_surfaceFontData);
|
|
||||||
wxFontWithAscent* fontCopy = new wxFontWithAscent(wxFont());
|
wxFontWithAscent* fontCopy = new wxFontWithAscent(wxFont());
|
||||||
SurfaceFontDataD2D* newSurfaceData = new SurfaceFontDataD2D(*fontData);
|
SurfaceFontDataD2D* newSurfaceData =
|
||||||
|
new SurfaceFontDataD2D(*m_surfaceFontData);
|
||||||
fontCopy->SetSurfaceFontData(newSurfaceData);
|
fontCopy->SetSurfaceFontData(newSurfaceData);
|
||||||
Font tempFont;
|
Font tempFont;
|
||||||
tempFont.SetID(fontCopy);
|
tempFont.SetID(fontCopy);
|
||||||
@@ -3153,7 +3131,7 @@ void wxSTCListBox::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const
|
|||||||
PRectangle prect = PRectangleFromwxRect(rect2);
|
PRectangle prect = PRectangleFromwxRect(rect2);
|
||||||
ColourDesired fore(textCol.Red(), textCol.Green(), textCol.Blue());
|
ColourDesired fore(textCol.Red(), textCol.Green(), textCol.Blue());
|
||||||
|
|
||||||
XYPOSITION ybase = rect2.GetTop() + fontData->GetAscent();
|
XYPOSITION ybase = rect2.GetTop() + m_surfaceFontData->GetAscent();
|
||||||
|
|
||||||
surface.DrawTextTransparent(prect, tempFont, ybase, buffer.data(),
|
surface.DrawTextTransparent(prect, tempFont, ybase, buffer.data(),
|
||||||
wx2stclen(wxString(),buffer), fore);
|
wx2stclen(wxString(),buffer), fore);
|
||||||
@@ -3161,6 +3139,14 @@ void wxSTCListBox::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const
|
|||||||
surface.Release();
|
surface.Release();
|
||||||
#endif // HAVE_DIRECTWRITE_TECHNOLOGY
|
#endif // HAVE_DIRECTWRITE_TECHNOLOGY
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxDCTextColourChanger tcc(dc, textCol);
|
||||||
|
|
||||||
|
label = wxControl::Ellipsize(label, dc, wxELLIPSIZE_END,
|
||||||
|
rect.GetWidth() - leftGap);
|
||||||
|
dc.DrawText(label, rect.GetLeft() + leftGap, rect.GetTop() + topGap);
|
||||||
|
}
|
||||||
|
|
||||||
const wxBitmap* b = m_visualData->GetImage(imageNo);
|
const wxBitmap* b = m_visualData->GetImage(imageNo);
|
||||||
if ( b )
|
if ( b )
|
||||||
|
Reference in New Issue
Block a user