Move wxTipWindow members used only by wxTipWindowView there
No real changes, just move m_textLines and m_heightLine from wxTipWindow to wxTipWindowView as they were only used by the latter and so can just as well be its members. Also use this as an opportunity to replace wxArrayString with wxVector.
This commit is contained in:
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
#include "wx/popupwin.h"
|
#include "wx/popupwin.h"
|
||||||
|
|
||||||
#include "wx/arrstr.h"
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_FWD_CORE wxTipWindowView;
|
class WXDLLIMPEXP_FWD_CORE wxTipWindowView;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -65,9 +63,6 @@ protected:
|
|||||||
virtual void OnDismiss() wxOVERRIDE;
|
virtual void OnDismiss() wxOVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxArrayString m_textLines;
|
|
||||||
wxCoord m_heightLine;
|
|
||||||
|
|
||||||
wxTipWindowView *m_view;
|
wxTipWindowView *m_view;
|
||||||
|
|
||||||
wxTipWindow** m_windowPtr;
|
wxTipWindow** m_windowPtr;
|
||||||
|
@@ -33,6 +33,8 @@
|
|||||||
#include "wx/settings.h"
|
#include "wx/settings.h"
|
||||||
#endif // WX_PRECOMP
|
#endif // WX_PRECOMP
|
||||||
|
|
||||||
|
#include "wx/vector.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// constants
|
// constants
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -61,6 +63,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
wxTipWindow* m_parent;
|
wxTipWindow* m_parent;
|
||||||
|
|
||||||
|
wxVector<wxString> m_textLines;
|
||||||
|
wxCoord m_heightLine;
|
||||||
|
|
||||||
|
|
||||||
wxDECLARE_EVENT_TABLE();
|
wxDECLARE_EVENT_TABLE();
|
||||||
wxDECLARE_NO_COPY_CLASS(wxTipWindowView);
|
wxDECLARE_NO_COPY_CLASS(wxTipWindowView);
|
||||||
};
|
};
|
||||||
@@ -192,6 +198,8 @@ wxTipWindowView::wxTipWindowView(wxWindow *parent)
|
|||||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_INFOBK));
|
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_INFOBK));
|
||||||
|
|
||||||
m_parent = (wxTipWindow*)parent;
|
m_parent = (wxTipWindow*)parent;
|
||||||
|
|
||||||
|
m_heightLine = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTipWindowView::Adjust(const wxString& text, wxCoord maxLength)
|
void wxTipWindowView::Adjust(const wxString& text, wxCoord maxLength)
|
||||||
@@ -204,7 +212,6 @@ void wxTipWindowView::Adjust(const wxString& text, wxCoord maxLength)
|
|||||||
wxString current;
|
wxString current;
|
||||||
wxCoord height, width,
|
wxCoord height, width,
|
||||||
widthMax = 0;
|
widthMax = 0;
|
||||||
m_parent->m_heightLine = 0;
|
|
||||||
|
|
||||||
bool breakLine = false;
|
bool breakLine = false;
|
||||||
for ( const wxChar *p = text.c_str(); ; p++ )
|
for ( const wxChar *p = text.c_str(); ; p++ )
|
||||||
@@ -215,10 +222,10 @@ void wxTipWindowView::Adjust(const wxString& text, wxCoord maxLength)
|
|||||||
if ( width > widthMax )
|
if ( width > widthMax )
|
||||||
widthMax = width;
|
widthMax = width;
|
||||||
|
|
||||||
if ( height > m_parent->m_heightLine )
|
if ( height > m_heightLine )
|
||||||
m_parent->m_heightLine = height;
|
m_heightLine = height;
|
||||||
|
|
||||||
m_parent->m_textLines.Add(current);
|
m_textLines.push_back(current);
|
||||||
|
|
||||||
if ( !*p )
|
if ( !*p )
|
||||||
{
|
{
|
||||||
@@ -232,7 +239,7 @@ void wxTipWindowView::Adjust(const wxString& text, wxCoord maxLength)
|
|||||||
else if ( breakLine && (*p == wxT(' ') || *p == wxT('\t')) )
|
else if ( breakLine && (*p == wxT(' ') || *p == wxT('\t')) )
|
||||||
{
|
{
|
||||||
// word boundary - break the line here
|
// word boundary - break the line here
|
||||||
m_parent->m_textLines.Add(current);
|
m_textLines.push_back(current);
|
||||||
current.clear();
|
current.clear();
|
||||||
breakLine = false;
|
breakLine = false;
|
||||||
}
|
}
|
||||||
@@ -246,14 +253,14 @@ void wxTipWindowView::Adjust(const wxString& text, wxCoord maxLength)
|
|||||||
if ( width > widthMax )
|
if ( width > widthMax )
|
||||||
widthMax = width;
|
widthMax = width;
|
||||||
|
|
||||||
if ( height > m_parent->m_heightLine )
|
if ( height > m_heightLine )
|
||||||
m_parent->m_heightLine = height;
|
m_heightLine = height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// take into account the border size and the margins
|
// take into account the border size and the margins
|
||||||
width = 2*(TEXT_MARGIN_X + 1) + widthMax;
|
width = 2*(TEXT_MARGIN_X + 1) + widthMax;
|
||||||
height = 2*(TEXT_MARGIN_Y + 1) + wx_truncate_cast(wxCoord, m_parent->m_textLines.GetCount())*m_parent->m_heightLine;
|
height = 2*(TEXT_MARGIN_Y + 1) + wx_truncate_cast(wxCoord, m_textLines.size())*m_heightLine;
|
||||||
m_parent->SetClientSize(width, height);
|
m_parent->SetClientSize(width, height);
|
||||||
SetSize(0, 0, width, height);
|
SetSize(0, 0, width, height);
|
||||||
}
|
}
|
||||||
@@ -280,12 +287,12 @@ void wxTipWindowView::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|||||||
wxPoint pt;
|
wxPoint pt;
|
||||||
pt.x = TEXT_MARGIN_X;
|
pt.x = TEXT_MARGIN_X;
|
||||||
pt.y = TEXT_MARGIN_Y;
|
pt.y = TEXT_MARGIN_Y;
|
||||||
size_t count = m_parent->m_textLines.GetCount();
|
const size_t count = m_textLines.size();
|
||||||
for ( size_t n = 0; n < count; n++ )
|
for ( size_t n = 0; n < count; n++ )
|
||||||
{
|
{
|
||||||
dc.DrawText(m_parent->m_textLines[n], pt);
|
dc.DrawText(m_textLines[n], pt);
|
||||||
|
|
||||||
pt.y += m_parent->m_heightLine;
|
pt.y += m_heightLine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user