Skip to content

Commit

Permalink
Fixes for wxWidgets 3.2 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0w committed Sep 26, 2024
1 parent e26d06a commit 9fc3bd0
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 51 deletions.
4 changes: 2 additions & 2 deletions src/ColorFrameCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ END_EVENT_TABLE()
/////////////////////////////////////////////////////////////////////////////
void CColorFrameCtrl::SetFrameBrushColour(const wxColour& colour)
{
m_brushFrame = *(wxTheBrushList->FindOrCreateBrush(colour, wxSOLID));
m_brushFrame = *(wxTheBrushList->FindOrCreateBrush(colour, wxBRUSHSTYLE_SOLID));

Refresh(FALSE);
} // SetFrameColor
Expand All @@ -70,7 +70,7 @@ void CColorFrameCtrl::SetFrameBrushColour(const wxColour& colour)
/////////////////////////////////////////////////////////////////////////////
void CColorFrameCtrl::SetBackgroundBrushColour(const wxColour& colour)
{
m_brushBack = *(wxTheBrushList->FindOrCreateBrush(colour, wxSOLID));
m_brushBack = *(wxTheBrushList->FindOrCreateBrush(colour, wxBRUSHSTYLE_SOLID));

// clear out the existing garbage, re-start with a clean plot
Refresh(FALSE);
Expand Down
4 changes: 2 additions & 2 deletions src/DownloadListCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ void CDownloadListCtrl::OnDrawItem(
dc->SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
dc->SetPen( colour.Blend(65).GetPen() );
} else {
dc->SetBackground(*(wxTheBrushList->FindOrCreateBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX), wxSOLID)));
dc->SetBackground(*(wxTheBrushList->FindOrCreateBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX), wxBRUSHSTYLE_SOLID)));
dc->SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
dc->SetPen(*wxTRANSPARENT_PEN);
}
Expand Down Expand Up @@ -1413,7 +1413,7 @@ void CDownloadListCtrl::DrawFileStatusBar(
dc->DrawLine( rect.x, rect.y + 2, rect.x + width, rect.y + 2 );

// Draw the green line
dc->SetPen( *(wxThePenList->FindOrCreatePen( crProgress , 1, wxSOLID ) ));
dc->SetPen( *(wxThePenList->FindOrCreatePen( crProgress , 1, wxPENSTYLE_SOLID ) ));
dc->DrawLine( rect.x, rect.y + 1, rect.x + width, rect.y + 1 );
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/GenericClientListCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ void CGenericClientListCtrl::OnDrawItem(
dc->SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
dc->SetPen( colour.Blend(65).GetPen() );
} else {
dc->SetBackground(*(wxTheBrushList->FindOrCreateBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX), wxSOLID)));
dc->SetBackground(*(wxTheBrushList->FindOrCreateBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX), wxBRUSHSTYLE_SOLID)));
dc->SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
dc->SetPen(*wxTRANSPARENT_PEN);
}
Expand Down
4 changes: 2 additions & 2 deletions src/MuleColour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
std::map<uint32_t, wxPen*> wxPenCache;
std::map<uint32_t, wxBrush*> wxBrushCache;

const wxPen& CMuleColour::GetPen(int width, int style) const
const wxPen& CMuleColour::GetPen(int width, wxPenStyle style) const
{
#if USE_MULE_PEN_CACHE
wxPen* result = NULL;
Expand All @@ -61,7 +61,7 @@ const wxPen& CMuleColour::GetPen(int width, int style) const
#endif
}

const wxBrush& CMuleColour::GetBrush(int style) const
const wxBrush& CMuleColour::GetBrush(wxBrushStyle style) const
{
#if USE_MULE_BRUSH_CACHE
wxBrush* result = NULL;
Expand Down
7 changes: 5 additions & 2 deletions src/MuleColour.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/pen.h> // needed for wxPenStyle enum values
#include <wx/brush.h> // needed for wxBrushStyle enum values
#include <wx/font.h> // needed for wxFontStyle enum values
#include "Types.h"

class wxPen;
Expand Down Expand Up @@ -95,8 +98,8 @@ class CMuleColour
return wxColor(m_red, m_green, m_blue);
}

const wxPen& GetPen(int width = 1, int style = wxSOLID) const;
const wxBrush& GetBrush(int style = wxSOLID) const;
const wxPen& GetPen(int width = 1, wxPenStyle style = wxPENSTYLE_SOLID) const;
const wxBrush& GetBrush(wxBrushStyle style = wxBRUSHSTYLE_SOLID) const;

private:
uint8_t m_red;
Expand Down
2 changes: 1 addition & 1 deletion src/MuleGifCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void MuleGifCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
int x = (clientsize.GetWidth()-gifsize.GetWidth())/2;
int y = (clientsize.GetHeight()-gifsize.GetHeight())/2;

dc.SetBackground(*(wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID)));
dc.SetBackground(*(wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID)));
dc.Clear();
dc.DrawBitmap(m_frame, x, y, true);
}
Expand Down
12 changes: 6 additions & 6 deletions src/OScopeCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ COScopeCtrl::COScopeCtrl(int cntTrends, int nDecimals, StatsGraphType type, wxWi
PlotData_t* ppds = pdsTrends;
for(unsigned i=0; i<nTrends; ++i, ++ppds){
ppds->crPlot = (i<15 ? crPreset[i] : *wxWHITE);
ppds->penPlot=*(wxThePenList->FindOrCreatePen(ppds->crPlot, 1, wxSOLID));
ppds->penPlot=*(wxThePenList->FindOrCreatePen(ppds->crPlot, 1, wxPENSTYLE_SOLID));
ppds->fPrev = ppds->fLowerLimit = ppds->fUpperLimit = 0.0;
}

Expand Down Expand Up @@ -166,7 +166,7 @@ void COScopeCtrl::SetPlotColor(const wxColour& cr, unsigned iTrend)
if (ppds->crPlot == cr)
return;
ppds->crPlot = cr;
ppds->penPlot=*(wxThePenList->FindOrCreatePen(ppds->crPlot, 1, wxSOLID));
ppds->penPlot=*(wxThePenList->FindOrCreatePen(ppds->crPlot, 1, wxPENSTYLE_SOLID));
InvalidateGraph();
}

Expand All @@ -179,7 +179,7 @@ void COScopeCtrl::SetBackgroundColor(const wxColour& cr)
}

m_bgColour = cr;
brushBack= *(wxTheBrushList->FindOrCreateBrush(cr, wxSOLID));
brushBack= *(wxTheBrushList->FindOrCreateBrush(cr, wxBRUSHSTYLE_SOLID));
InvalidateCtrl() ;
}

Expand All @@ -196,7 +196,7 @@ void COScopeCtrl::RecreateGrid()

wxMemoryDC dcGrid(m_bmapGrid);

wxPen solidPen = *(wxThePenList->FindOrCreatePen(m_gridColour, 1, wxSOLID));
wxPen solidPen = *(wxThePenList->FindOrCreatePen(m_gridColour, 1, wxPENSTYLE_SOLID));
wxString strTemp;

// fill the grid background
Expand All @@ -213,7 +213,7 @@ void COScopeCtrl::RecreateGrid()
dcGrid.SetPen(wxNullPen);

// create some fonts (horizontal and vertical)
wxFont axisFont(10, wxSWISS, wxNORMAL, wxNORMAL, false);
wxFont axisFont(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false);
dcGrid.SetFont(axisFont);

// y max
Expand Down Expand Up @@ -320,7 +320,7 @@ void COScopeCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt))
// operation, preventing us from simply blitting the plot on top of
// the grid bitmap.

dc.SetPen(*(wxThePenList->FindOrCreatePen(m_gridColour, 1, wxLONG_DASH)));
dc.SetPen(*(wxThePenList->FindOrCreatePen(m_gridColour, 1, wxPENSTYLE_LONG_DASH)));
for (unsigned j = 1; j < (nYGrids + 1); ++j) {
unsigned GridPos = (m_rectPlot.GetHeight())*j/( nYGrids + 1 ) + m_rectPlot.GetTop();

Expand Down
4 changes: 2 additions & 2 deletions src/SearchListCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ void CSearchListCtrl::OnDrawItem(

// Define the border of the drawn area
if (highlighted) {
dc->SetPen(*(wxThePenList->FindOrCreatePen(CMuleColour(dc->GetBackground().GetColour()).Blend(65), 1, wxSOLID)));
dc->SetPen(*(wxThePenList->FindOrCreatePen(CMuleColour(dc->GetBackground().GetColour()).Blend(65), 1, wxPENSTYLE_SOLID)));
} else {
dc->SetPen(*wxTRANSPARENT_PEN);
dc->SetTextForeground(GetItemTextColour(item));
Expand Down Expand Up @@ -912,7 +912,7 @@ void CSearchListCtrl::OnDrawItem(
const int middle = cur_rec.y + ( cur_rec.height + 1 ) / 2;

// Set up a new pen for drawing the tree
dc->SetPen( *(wxThePenList->FindOrCreatePen(dc->GetTextForeground(), 1, wxSOLID)) );
dc->SetPen( *(wxThePenList->FindOrCreatePen(dc->GetTextForeground(), 1, wxPENSTYLE_SOLID)) );

if (file->GetParent()) {
// Draw the line to the filename
Expand Down
2 changes: 1 addition & 1 deletion src/ServerListCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ void CServerListCtrl::HighlightServer( const CServer* server, bool highlight )
wxFont font = GetFont();

if ( highlight ) {
font.SetWeight( wxBOLD );
font.SetWeight( wxFONTWEIGHT_BOLD );

m_connected = server;
}
Expand Down
6 changes: 6 additions & 0 deletions src/amule-gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <common/ClientVersion.h>

#include <wx/clipbrd.h> // Needed for wxClipBoard
#include <wx/sizer.h>
#include <wx/tokenzr.h> // Needed for wxStringTokenizer

#include "SharedFilesWnd.h" // Needed for CSharedFilesWnd
Expand Down Expand Up @@ -98,6 +99,11 @@ IMPLEMENT_APP(CamuleGuiApp)

CamuleGuiBase::CamuleGuiBase()
{
// Disable these checks for now. The code really needs updating to
// eliminate these inconsistent flag uses, but these checks are new
// since wx3.0, and this should just return us to what 3.0 did.
wxSizerFlags::DisableConsistencyChecks();

amuledlg = NULL;
}

Expand Down
9 changes: 2 additions & 7 deletions src/amuleDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ void CamuleDlg::ShowConnectionState(bool skinChanged)
if ( (true == skinChanged) || (currentState != s_oldState) ) {
wxWindowUpdateLocker freezer(m_wndToolbar);

wxToolBarToolBase* toolbarTool = m_wndToolbar->RemoveTool(ID_BUTTONCONNECT);
wxToolBarToolBase* toolbarTool = m_wndToolbar->FindById(ID_BUTTONCONNECT);

switch (currentState) {
case ECS_Connecting:
Expand All @@ -784,8 +784,6 @@ void CamuleDlg::ShowConnectionState(bool skinChanged)
toolbarTool->SetNormalBitmap(m_tblist.GetBitmap(0));
}

m_wndToolbar->InsertTool(0, toolbarTool);
m_wndToolbar->Realize();
m_wndToolbar->EnableTool(ID_BUTTONCONNECT, (thePrefs::GetNetworkED2K() || thePrefs::GetNetworkKademlia()) && theApp->ipfilter->IsReady());

s_oldState = currentState;
Expand Down Expand Up @@ -1416,7 +1414,7 @@ void CamuleDlg::DoNetworkRearrange()
wxWindowUpdateLocker freezer(this);
#endif

wxToolBarToolBase* toolbarTool = m_wndToolbar->RemoveTool(ID_BUTTONNETWORKS);
wxToolBarToolBase* toolbarTool = m_wndToolbar->FindById(ID_BUTTONNETWORKS);

// set the log windows
wxNotebook* logs_notebook = CastChild( ID_SRVLOG_NOTEBOOK, wxNotebook);
Expand Down Expand Up @@ -1507,12 +1505,9 @@ void CamuleDlg::DoNetworkRearrange()

// Tool bar

m_wndToolbar->InsertTool(2, toolbarTool);
m_wndToolbar->EnableTool(ID_BUTTONNETWORKS, (thePrefs::GetNetworkED2K() || thePrefs::GetNetworkKademlia()));
m_wndToolbar->EnableTool(ID_BUTTONCONNECT, (thePrefs::GetNetworkED2K() || thePrefs::GetNetworkKademlia()) && theApp->ipfilter->IsReady());

m_wndToolbar->Realize();

ShowConnectionState(); // status in the bottom right
m_searchwnd->FixSearchTypes();
}
Expand Down
23 changes: 13 additions & 10 deletions src/extern/wxWidgets/listctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,7 @@ bool wxListLineData::SetAttributes(wxDC *dc,
if ( highlighted )
dc->SetBrush( m_owner->GetHighlightBrush() );
else
dc->SetBrush(*(wxTheBrushList->FindOrCreateBrush(attr->GetBackgroundColour(), wxSOLID)));
dc->SetBrush(*(wxTheBrushList->FindOrCreateBrush(attr->GetBackgroundColour(), wxBRUSHSTYLE_SOLID)));

dc->SetPen( *wxTRANSPARENT_PEN );

Expand Down Expand Up @@ -2325,15 +2325,15 @@ wxListMainWindow::wxListMainWindow( wxWindow *parent,
(
wxSYS_COLOUR_HIGHLIGHT
),
wxSOLID
wxBRUSHSTYLE_SOLID
));

m_highlightUnfocusedBrush = *(wxTheBrushList->FindOrCreateBrush(
wxSystemSettings::GetColour
(
wxSYS_COLOUR_BTNSHADOW
),
wxSOLID
wxBRUSHSTYLE_SOLID
));

SetScrollbars( 0, 0, 0, 0, 0, 0 );
Expand Down Expand Up @@ -2734,7 +2734,7 @@ void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )

// Ensure an uniform background color, as to avoid differences between
// the automatically cleared parts and the rest of the canvas.
dc.SetBackground(*(wxTheBrushList->FindOrCreateBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX), wxSOLID)));
dc.SetBackground(*(wxTheBrushList->FindOrCreateBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX), wxBRUSHSTYLE_SOLID)));

// We need to clear the DC manually, since we intercept BG-erase events.
// Clearing must be done first thing because caching of the double-buffering causes artifacts otherwise.
Expand Down Expand Up @@ -2805,7 +2805,7 @@ void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )

if ( HasFlag(wxLC_HRULES) )
{
wxPen pen = *(wxThePenList->FindOrCreatePen(GetRuleColour(), 1, wxSOLID));
wxPen pen = *(wxThePenList->FindOrCreatePen(GetRuleColour(), 1, wxPENSTYLE_SOLID));
wxSize clientSize = GetClientSize();

size_t i = visibleFrom;
Expand All @@ -2831,7 +2831,7 @@ void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
// Draw vertical rules if required
if ( HasFlag(wxLC_VRULES) && !IsEmpty() )
{
wxPen pen = *(wxThePenList->FindOrCreatePen(GetRuleColour(), 1, wxSOLID));
wxPen pen = *(wxThePenList->FindOrCreatePen(GetRuleColour(), 1, wxPENSTYLE_SOLID));
wxRect firstItemRect, lastItemRect;

GetItemRect(visibleFrom, firstItemRect);
Expand Down Expand Up @@ -4859,12 +4859,15 @@ void wxListMainWindow::SortItems( MuleListCtrlCompare fn, long data )

void wxListMainWindow::OnScroll(wxScrollWinEvent& event)
{
// wxScrolledWindows::OnScroll is deprecated in wx 3.0.0 and it does not exist anymore in 3.1.0.
// Please also notice that call to
// - wxScrolledWindow::OnScroll
// - HandleOnScroll
// have been removed in code present in
// src/generic/listctrl.cpp, wxListMainWindow::OnScroll
// of wxWidgets 3.0
// FIXME
#if ( defined(__WXGTK__) || defined(__WXMAC__) ) && !defined(__WXUNIVERSAL__)
wxScrolledWindow::OnScroll(event);
#else
HandleOnScroll( event );
#endif

// update our idea of which lines are shown when we redraw the window the
// next time
Expand Down
1 change: 0 additions & 1 deletion src/extern/wxWidgets/listctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <wx/textctrl.h>

#define wxLC_OWNERDRAW 0x10000
#define WXWIN_COMPATIBILITY_2_8 1

#include <wx/imaglist.h>

Expand Down
Loading

0 comments on commit 9fc3bd0

Please sign in to comment.