mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-17 16:36:59 +00:00
UI: fix TextListCtrl to work with wxWindows 3.3.0
This commit is contained in:
parent
d076f3c1d7
commit
64c7489c08
2 changed files with 24 additions and 37 deletions
|
|
@ -18,13 +18,14 @@ TextList::~TextList()
|
||||||
this->Unbind(wxEVT_ERASE_BACKGROUND, &TextList::OnEraseBackground, this);
|
this->Unbind(wxEVT_ERASE_BACKGROUND, &TextList::OnEraseBackground, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextList::TextList(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
|
TextList::TextList(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) : wxScrolled<wxControl>(parent, id, pos, size, style)
|
||||||
: wxControl(parent, id, pos, size, style), wxScrollHelper(this)
|
|
||||||
{
|
{
|
||||||
m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
|
||||||
wxWindowBase::SetBackgroundStyle(wxBG_STYLE_PAINT);
|
this->wxWindowBase::SetBackgroundStyle(wxBG_STYLE_PAINT);
|
||||||
|
|
||||||
wxClientDC dc(this);
|
wxInfoDC dc(this);
|
||||||
|
this->wxScrolled::DoPrepareReadOnlyDC(dc);
|
||||||
|
dc.SetFont(m_font);
|
||||||
m_line_height = dc.GetCharHeight();
|
m_line_height = dc.GetCharHeight();
|
||||||
m_char_width = dc.GetCharWidth();
|
m_char_width = dc.GetCharWidth();
|
||||||
|
|
||||||
|
|
@ -76,7 +77,7 @@ void TextList::RefreshLine(uint32 line)
|
||||||
|
|
||||||
wxSize TextList::DoGetVirtualSize() const
|
wxSize TextList::DoGetVirtualSize() const
|
||||||
{
|
{
|
||||||
return {wxDefaultCoord, (int)(m_element_count + 1) * m_line_height};
|
return {wxDefaultCoord, (int)m_element_count * m_line_height};
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextList::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
void TextList::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||||
|
|
@ -252,7 +253,6 @@ void TextList::OnContextMenu(wxContextMenuEvent& event)
|
||||||
OnContextMenu(clientPosition, line);
|
OnContextMenu(clientPosition, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TextList::OnTooltipTimer(wxTimerEvent& event)
|
void TextList::OnTooltipTimer(wxTimerEvent& event)
|
||||||
{
|
{
|
||||||
m_tooltip_window->Hide();
|
m_tooltip_window->Hide();
|
||||||
|
|
@ -278,40 +278,27 @@ void TextList::OnTooltipTimer(wxTimerEvent& event)
|
||||||
|
|
||||||
void TextList::OnPaintEvent(wxPaintEvent& event)
|
void TextList::OnPaintEvent(wxPaintEvent& event)
|
||||||
{
|
{
|
||||||
wxBufferedPaintDC dc(m_targetWindow, wxBUFFER_VIRTUAL_AREA);
|
wxAutoBufferedPaintDC dc(m_targetWindow);
|
||||||
|
|
||||||
dc.SetFont(m_font);
|
dc.SetFont(m_font);
|
||||||
|
dc.SetBrush(GetBackgroundColour());
|
||||||
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
|
dc.DrawRectangle(GetUpdateRegion().GetBox());
|
||||||
|
|
||||||
// get window position
|
// calculate the number of elements visible in the current view
|
||||||
auto position = GetPosition();
|
auto rect_update = GetClientRect();
|
||||||
|
sint32 start = GetViewStart().y;
|
||||||
|
m_elements_visible = std::min(rect_update.height + m_line_height - 1, (sint32)m_element_count - start);
|
||||||
|
|
||||||
// get current real position
|
// add constraints
|
||||||
wxRect rect_update = GetUpdateRegion().GetBox();
|
if (m_elements_visible < 0)
|
||||||
const auto count = (uint32)std::ceil((float)rect_update.GetHeight() / m_line_height);
|
m_elements_visible = 0;
|
||||||
|
else if (m_elements_visible > m_element_count - start)
|
||||||
|
m_elements_visible = m_element_count - start;
|
||||||
|
|
||||||
position.y = (rect_update.y / m_line_height) * m_line_height;
|
m_scrolled_to_end = (start + m_elements_visible >= m_element_count);
|
||||||
|
|
||||||
// paint background
|
OnDraw(dc, GetViewStart().y, m_elements_visible, wxPoint(rect_update.x, rect_update.y));
|
||||||
const wxColour window_colour = COLOR_WHITE;
|
|
||||||
dc.SetBrush(window_colour);
|
|
||||||
dc.SetPen(window_colour);
|
|
||||||
dc.DrawRectangle(rect_update);
|
|
||||||
|
|
||||||
//// paint selection
|
// removed Update() here since all text is white
|
||||||
//if (!m_selected_text.eof())
|
|
||||||
//{
|
|
||||||
// dc.SetBrush(*wxBLUE_BRUSH);
|
|
||||||
// dc.SetPen(*wxBLUE_PEN);
|
|
||||||
// dc.DrawRectangle(m_selection);
|
|
||||||
//}
|
|
||||||
|
|
||||||
sint32 start;
|
|
||||||
CalcUnscrolledPosition(rect_update.x, rect_update.y, nullptr, &start);
|
|
||||||
|
|
||||||
start /= m_line_height;
|
|
||||||
m_scrolled_to_end = (start + count) >= m_element_count;
|
|
||||||
|
|
||||||
OnDraw(dc, start, count, position);
|
|
||||||
|
|
||||||
|
|
||||||
this->Update();
|
|
||||||
}
|
}
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
#define COLOR_RED 0xFF0000FF
|
#define COLOR_RED 0xFF0000FF
|
||||||
|
|
||||||
|
|
||||||
class TextList : public wxControl, public wxScrollHelper
|
class TextList : public wxScrolled<wxControl>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~TextList();
|
virtual ~TextList();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue