Skip to content

Commit

Permalink
Require wxWidgets >= 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
vslavik committed Jan 30, 2024
1 parent de55b80 commit 174d66b
Show file tree
Hide file tree
Showing 18 changed files with 21 additions and 189 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Most Linux distributions also include native Poedit packages.
Requirements:

* Boost
* Unicode build of [wxWidgets](http://www.wxwidgets.org) library, version >= 3.0.4
* Unicode build of [wxWidgets](http://www.wxwidgets.org) library, version >= 3.2
* ICU
* LucenePlusPlus
* If on Unix, GtkSpell for spell checking support
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ AM_CONDITIONAL([HAVE_CPPREST], [test "x$have_cpprest" != "xno"])

AC_CHECK_HEADERS([nlohmann/json.hpp])

WX_CONFIG_CHECK([3.0.3], [WXFOUND=1], [WXFOUND=0], [$WXLIBS_USED], [--unicode])
WX_CONFIG_CHECK([3.2.4], [WXFOUND=1], [WXFOUND=0], [$WXLIBS_USED], [--unicode])

if test "$WXFOUND" != 1; then
AC_MSG_ERROR([
Expand Down
15 changes: 1 addition & 14 deletions src/cloud_accounts_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@
#include <wx/generic/private/markuptext.h>
#endif

#if !wxCHECK_VERSION(3,1,0)
#define CenterVertical() Center()
#endif

namespace
{

Expand Down Expand Up @@ -98,7 +94,7 @@ void ServiceSelectionPanel::AddService(AccountDetailPanel *account)

m_sizer->Insert(pos, content, wxSizerFlags(1).Expand());
if (!isFirst)
m_sizer->Insert(posLine, new StaticLine(this, wxID_ANY), wxSizerFlags().Expand().Border(wxTOP|wxBOTTOM, PX(24)));
m_sizer->Insert(posLine, new wxStaticLine(this, wxID_ANY), wxSizerFlags().Expand().Border(wxTOP|wxBOTTOM, PX(24)));
}


Expand Down Expand Up @@ -330,9 +326,7 @@ class CloudFileList : public wxDataViewListCtrl
: wxDataViewListCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxDV_NO_HEADER | MSW_OR_OTHER(wxBORDER_SIMPLE, wxBORDER_SUNKEN))
{
#if wxCHECK_VERSION(3,1,1)
SetRowHeight(PX(36));
#endif
SetMinSize(wxSize(PX(500), PX(200)));
#ifdef __WXOSX__
if (@available(macOS 11.0, *))
Expand Down Expand Up @@ -375,18 +369,13 @@ class CloudFileList : public wxDataViewListCtrl

for (auto& f : m_files)
{
#if wxCHECK_VERSION(3,1,1)
wxString text = wxString::Format
(
"%s\n<small><span %s>%s</span></small>",
EscapeMarkup(f.title),
secondaryFormatting,
EscapeMarkup(f.description)
);
#else
wxString text(f.title);
#endif

wxVector<wxVariant> data;
data.push_back({text});
AppendItem(data);
Expand All @@ -398,9 +387,7 @@ class CloudFileList : public wxDataViewListCtrl
public:
MultilineTextRenderer() : wxDataViewTextRenderer()
{
#if wxCHECK_VERSION(3,1,1)
EnableMarkup();
#endif
}

#ifdef __WXMSW__
Expand Down
12 changes: 0 additions & 12 deletions src/colorscheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,7 @@ wxColour ColorScheme::DoGet(Color color, Mode mode)
return mode == Dark ? sRGB(180, 222, 254) : sRGB(70, 109, 137);
case Color::ItemContextBg:
if (mode == Dark)
#if wxCHECK_VERSION(3,1,0)
return sRGB(67, 94, 147, 0.6);
#else // see /~https://github.com/vslavik/poedit/issues/524
return sRGB(67, 94, 147);
#endif
else
return sRGB(217, 232, 242);
case Color::ItemContextBgHighlighted:
Expand Down Expand Up @@ -260,12 +256,8 @@ ColorScheme::Mode ColorScheme::GetAppMode()
s_appMode = IsDarkAppearance(NSApp.effectiveAppearance) ? Dark : Light;
#else
auto colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
#if wxCHECK_VERSION(3,1,3)
auto colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
s_appMode = (colFg.GetLuminance() > colBg.GetLuminance()) ? Dark : Light;
#else
s_appMode = (colBg.Red() < 0x60 && colBg.Green() < 0x60 && colBg.Blue() < 0x60) ? Dark : Light;
#endif
#endif
s_appModeDetermined = true;
}
Expand All @@ -282,12 +274,8 @@ ColorScheme::Mode ColorScheme::GetWindowMode(wxWindow *win)
#else
// Use dark scheme for very dark backgrounds:
auto colBg = win->GetDefaultAttributes().colBg;
#if wxCHECK_VERSION(3,1,3)
auto colFg = win->GetDefaultAttributes().colFg;
return (colFg.GetLuminance() > colBg.GetLuminance()) ? Dark : Light;
#else
return (colBg.Red() < 0x60 && colBg.Green() < 0x60 && colBg.Blue() < 0x60) ? Dark : Light;
#endif
#endif
}

Expand Down
2 changes: 0 additions & 2 deletions src/custom_notebook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,6 @@ int SegmentedNotebook::DoSetSelection(size_t n, int flags)
SegmentedNotebook::SegmentedNotebook(wxWindow *parent, SegmentStyle style)
: wxNotebook(parent, -1, wxDefaultPosition, wxDefaultSize, wxNB_NOPAGETHEME)
{
#if wxCHECK_VERSION(3,1,0)
wxFont font = GetFont();
double size = font.GetFractionalPointSize();

Expand All @@ -516,7 +515,6 @@ SegmentedNotebook::SegmentedNotebook(wxWindow *parent, SegmentStyle style)

font.SetFractionalPointSize(size);
SetOwnFont(font);
#endif
}

#endif // !HAS_SEGMENTED_NOTEBOOK
33 changes: 2 additions & 31 deletions src/customcontrols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,8 @@ SelectableAutoWrappingText::SelectableAutoWrappingText(wxWindow *parent, const w
ExplanationLabel::ExplanationLabel(wxWindow *parent, const wxString& label)
: AutoWrappingText(parent, label)
{
#if defined(__WXOSX__)
#if defined(__WXOSX__) || defined(__WXGTK__)
SetWindowVariant(wxWINDOW_VARIANT_SMALL);
#elif defined(__WXGTK__)
#if wxCHECK_VERSION(3,1,0)
SetWindowVariant(wxWINDOW_VARIANT_SMALL);
#else
SetFont(GetFont().Smaller());
#endif
#endif
#ifndef __WXGTK__
ColorScheme::SetupWindowColors(this, [=]
Expand All @@ -302,14 +296,8 @@ ExplanationLabel::ExplanationLabel(wxWindow *parent, const wxString& label)
SecondaryLabel::SecondaryLabel(wxWindow *parent, const wxString& label)
: wxStaticText(parent, wxID_ANY, label)
{
#if defined(__WXOSX__)
#if defined(__WXOSX__) || defined(__WXGTK__)
SetWindowVariant(wxWINDOW_VARIANT_SMALL);
#elif defined(__WXGTK__)
#if wxCHECK_VERSION(3,1,0)
SetWindowVariant(wxWINDOW_VARIANT_SMALL);
#else
SetFont(GetFont().Smaller());
#endif
#endif
#ifndef __WXGTK__
ColorScheme::SetupWindowColors(this, [=]
Expand Down Expand Up @@ -607,9 +595,7 @@ class IconAndSubtitleListCtrl::MultilineTextRenderer : public wxDataViewTextRend
public:
MultilineTextRenderer() : wxDataViewTextRenderer()
{
#if wxCHECK_VERSION(3,1,1)
EnableMarkup();
#endif
}

#ifdef __WXMSW__
Expand Down Expand Up @@ -659,9 +645,7 @@ IconAndSubtitleListCtrl::IconAndSubtitleListCtrl(wxWindow *parent, const wxStrin
const int icon_column_width = wxSystemSettings::GetMetric(wxSYS_ICON_X) + PX(12);
#endif

#if wxCHECK_VERSION(3,1,1)
SetRowHeight(GetDefaultRowHeight());
#endif

AppendBitmapColumn("", 0, wxDATAVIEW_CELL_INERT, icon_column_width);
auto renderer = new MultilineTextRenderer();
Expand All @@ -686,17 +670,13 @@ wxString IconAndSubtitleListCtrl::FormatItemText(const wxString& title, const wx
auto secondaryFormatting = GetSecondaryFormatting();
#endif

#if wxCHECK_VERSION(3,1,1)
return wxString::Format
(
"%s\n<small><span %s>%s</span></small>",
EscapeMarkup(title),
secondaryFormatting,
EscapeMarkup(description)
);
#else
return title;
#endif
}

#ifndef __WXGTK__
Expand Down Expand Up @@ -736,12 +716,3 @@ void IconAndSubtitleListCtrl::UpdateFormattedItem(unsigned row, const wxString&
{
SetTextValue(FormatItemText(title, description), row, 1);
}


#if defined(__WXOSX__) && !wxCHECK_VERSION(3,2,3)
StaticLine::StaticLine(wxWindow *parent, wxWindowID id) : wxStaticLine(parent, id)
{
NSBox *box = (NSBox*)GetHandle();
box.boxType = NSBoxSeparator;
}
#endif
13 changes: 0 additions & 13 deletions src/customcontrols.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,4 @@ class IconAndSubtitleListCtrl : public wxDataViewListCtrl
class MultilineTextRenderer;
};


/// Fix for a wxStaticLine bug on macOS Ventura
#if defined(__WXOSX__) && !wxCHECK_VERSION(3,2,3)
class StaticLine : public wxStaticLine
{
public:
StaticLine(wxWindow *parent, wxWindowID id);
};
#else
typedef wxStaticLine StaticLine;
#endif


#endif // Poedit_customcontrols_h
2 changes: 0 additions & 2 deletions src/edframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2676,7 +2676,6 @@ void PoeditFrame::UpdateTitle()
if (subtitle == "PROJECT VERSION")
subtitle.clear();

#if wxCHECK_VERSION(3,1,5)
if (m_catalog->GetLanguage().IsValid())
{
// add language to the subtitle, but only if not part of the filename already
Expand All @@ -2692,7 +2691,6 @@ void PoeditFrame::UpdateTitle()
}
}
}
#endif

#ifdef __WXOSX__
if (@available(macOS 11.0, *))
Expand Down
37 changes: 1 addition & 36 deletions src/editing_area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
#include <wx/statbmp.h>
#include <wx/stattext.h>

#if !wxCHECK_VERSION(3,1,0)
#define CenterVertical() Center()
#endif

#include <algorithm>


Expand Down Expand Up @@ -114,14 +110,12 @@ class ShrinkableBoxSizer : public wxBoxSizer
public:
ShrinkableBoxSizer(int orient) : wxBoxSizer(orient) {}

#if wxCHECK_VERSION(3,1,1)
void SetShrinkableWindow(wxWindow *win)
{
m_shrinkable = win ? GetItem(win) : nullptr;
}

#if wxCHECK_VERSION(3,1,3)
virtual void RepositionChildren(const wxSize& minSize) override
void RepositionChildren(const wxSize& minSize) override
{
if (m_shrinkable)
{
Expand All @@ -134,32 +128,9 @@ class ShrinkableBoxSizer : public wxBoxSizer

wxBoxSizer::RepositionChildren(minSize);
}
#else
void RecalcSizes() override
{
if (m_shrinkable)
{
const wxCoord totalSize = GetSizeInMajorDir(m_size);
const wxCoord minSize = GetSizeInMajorDir(m_calculatedMinSize);
// If there's not enough space, make shrinkable item proportional,
// it will be resized under its minimal size then.
m_shrinkable->SetProportion(totalSize > 20 && totalSize < minSize ? 10000 : 0);
}

wxBoxSizer::RecalcSizes();
}
#endif

private:
wxSizerItem *m_shrinkable;
#else
void SetShrinkableWindow(wxWindow *win)
{
auto item = win ? GetItem(win) : nullptr;
if (item)
item->SetProportion(10000);
}
#endif
};


Expand Down Expand Up @@ -287,13 +258,11 @@ class EditingArea::TagLabel : public wxWindow
#endif
}

#if wxCHECK_VERSION(3,1,1)
void DoSetToolTipText(const wxString &tip) override
{
wxWindow::DoSetToolTipText(tip);
m_label->SetToolTip(tip);
}
#endif

#ifdef __WXOSX__
wxSize DoGetBestSize() const override
Expand All @@ -315,11 +284,7 @@ class EditingArea::TagLabel : public wxWindow
auto rect = GetClientRect();
if (!rect.IsEmpty())
{
#if wxCHECK_VERSION(3,1,1)
gc->DrawRoundedRectangle(rect.x, rect.y, rect.width, rect.height, PX(2));
#else
gc->DrawRectangle(rect.x, rect.y, rect.width, rect.height);
#endif
}
}

Expand Down
Loading

0 comments on commit 174d66b

Please sign in to comment.