Skip to content

Commit

Permalink
Require C++17
Browse files Browse the repository at this point in the history
  • Loading branch information
Blake-Madden committed Dec 23, 2024
1 parent dec3e9b commit 4136cac
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ Dependencies
=============================

- [wxWidgets](https://github.com/wxWidgets/wxWidgets) 3.2 or higher
- A C++14 compatible compiler
- A C++17 compatible compiler
4 changes: 2 additions & 2 deletions demo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# Purpose: Demonstration project for wxStartPage
# Author: Blake Madden
# Created: 2023-03-25
# Copyright: (c) 2023 Blake Madden
# Copyright: (c) 2025 Blake Madden
# Licence: BSD-3-Clause
#############################################################################

# Declare the minimum required CMake version
CMAKE_MINIMUM_REQUIRED(VERSION 3.14)
SET(CMAKE_CXX_STANDARD 14)
SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX_STANDARD_REQUIRED True)

ADD_COMPILE_OPTIONS("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
Expand Down
48 changes: 22 additions & 26 deletions startpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
#include <algorithm>
#include <cassert>

#ifndef wxNODISCARD
#define wxNODISCARD
#endif

wxDECLARE_EVENT(wxEVT_STARTPAGE_CLICKED, wxCommandEvent);

#define EVT_STARTPAGE_CLICKED(winid, fn) \
Expand Down Expand Up @@ -166,7 +162,7 @@ class wxStartPage final : public wxWindow
/// @returns The ID of the given index into the custom button list,
/// or @c wxNOT_FOUND if an invalid index is given.
/// @param buttonIndex The index into the custom button list.
wxNODISCARD
[[nodiscard]]
wxWindowID GetButtonID(const size_t buttonIndex) const noexcept
{
return buttonIndex > m_buttons.size() ?
Expand All @@ -176,7 +172,7 @@ class wxStartPage final : public wxWindow
/// @returns @c true if @c Id is and ID for one of the custom buttons on the left.
/// @param Id The ID from a @c wxEVT_STARTPAGE_CLICKED event after a
/// user clicks a button on the start page.
wxNODISCARD
[[nodiscard]]
bool IsCustomButtonId(const wxWindowID Id) const noexcept
{
return (Id >= ID_BUTTON_ID_START &&
Expand All @@ -185,13 +181,13 @@ class wxStartPage final : public wxWindow
/// @returns @c true if @c Id is an ID within the MRU list.
/// @param Id The ID from a @c wxEVT_STARTPAGE_CLICKED event after a
/// user clicks a button on the start page.
wxNODISCARD
[[nodiscard]]
constexpr bool IsFileId(const wxWindowID Id) const noexcept
{ return (Id >= ID_FILE_ID_START && Id < START_PAGE_FILE_LIST_CLEAR); }
/// @returns @c true if @c Id is the "Clear file list" button.
/// @param Id The ID from a @c wxEVT_STARTPAGE_CLICKED event after a
/// user clicks a button on the start page.
wxNODISCARD
[[nodiscard]]
constexpr bool IsFileListClearId(const wxWindowID Id) const noexcept
{ return (Id == START_PAGE_FILE_LIST_CLEAR); }
/// @}
Expand Down Expand Up @@ -226,7 +222,7 @@ class wxStartPage final : public wxWindow
void SetAppHeaderStyle(const wxStartPageAppHeaderStyle style) noexcept
{ m_appHeaderStyle = style; }
/// @returns The color of the left side of the start page.
wxNODISCARD
[[nodiscard]]
wxColour GetButtonAreaBackgroundColor() const noexcept
{ return m_buttonAreaBackgroundColor; }
/// @brief Sets the color of the left side of the start page.
Expand All @@ -237,7 +233,7 @@ class wxStartPage final : public wxWindow
{ m_buttonAreaBackgroundColor = color; }
}
/// @returns The color of the right side of the start page.
wxNODISCARD
[[nodiscard]]
wxColour GetMRUBackgroundColor() const noexcept
{ return m_MRUBackgroundColor; }
/// @brief Sets the color of the right side of the start page.
Expand All @@ -255,7 +251,7 @@ class wxStartPage final : public wxWindow
m_icon(icon), m_label(label)
{}
wxStartPageButton() = default;
wxNODISCARD
[[nodiscard]]
bool IsOk() const
{ return m_label.length() > 0; }
wxRect m_rect;
Expand All @@ -275,7 +271,7 @@ class wxStartPage final : public wxWindow
/// @returns The number of items in the MRU list.
/// @note This is the number of files in the list,
/// not including the "clear file list" button.
wxNODISCARD
[[nodiscard]]
size_t GetMRUFileCount() const noexcept
{
// the last item is the "clear file list" button, so don't count that
Expand Down Expand Up @@ -304,52 +300,52 @@ class wxStartPage final : public wxWindow

/// @returns The number of items in the MRU list
/// (including the "clear file list" button).
wxNODISCARD
[[nodiscard]]
size_t GetMRUFileAndClearButtonCount() const noexcept
{ return m_fileButtons.size(); }
/// @returns The padding height around the labels.
wxNODISCARD
[[nodiscard]]
wxCoord GetLabelPaddingHeight() const
{ return wxSizerFlags::GetDefaultBorder(); }
/// @returns The padding width around the labels.
wxNODISCARD
[[nodiscard]]
wxCoord GetLabelPaddingWidth() const
{ return wxSizerFlags::GetDefaultBorder(); }
/// @returns The padding at the top of the control.
wxNODISCARD
[[nodiscard]]
wxCoord GetTopBorder() const
{ return wxSizerFlags::GetDefaultBorder() * 4; }
/// @returns The left border around the icons/labels.
wxNODISCARD
[[nodiscard]]
wxCoord GetLeftBorder() const
{ return wxSizerFlags::GetDefaultBorder() * 4; }
/// @returns The size for the app logo
wxNODISCARD
[[nodiscard]]
wxSize GetAppLogoSize() const
{ return FromDIP(wxSize(64, 64)); }
/// @returns The button size, which will be smaller if there
/// are numerous buttons.
wxNODISCARD
[[nodiscard]]
wxSize GetButtonSize() const
{
return FromDIP(m_buttons.size() > MAX_BUTTONS_SMALL_SIZE ?
wxSize(16, 16) : wxSize(32, 32));
}
/// @returns The size of an icon scaled to 16x16,
/// with label padding above and below it.
wxNODISCARD
[[nodiscard]]
wxCoord GetMRUButtonHeight() const noexcept
{ return m_mruButtonHeight; }
wxNODISCARD
[[nodiscard]]
wxString GetClearFileListLabel() const
{ return _(L"\u267B Clear file list..."); }
wxNODISCARD
[[nodiscard]]
wxString GetRecentLabel() const
{ return _(L"Recent"); }
void DrawHighlight(wxDC& dc, const wxRect rect, const wxColour color) const;
void CalcButtonStart(wxDC& dc);
void CalcMRUColumnHeaderHeight(wxDC& dc);
wxNODISCARD
[[nodiscard]]
wxString FormatGreeting() const;
/// @brief Determines whether a color is dark.
/// @details "Dark" is defined as luminance being less than 50% and
Expand All @@ -359,7 +355,7 @@ class wxStartPage final : public wxWindow
/// be considered not dark.
/// @param color The color to review.
/// @returns @c true if the color is dark.
wxNODISCARD
[[nodiscard]]
static bool IsDark(const wxColour& color)
{
assert(color.IsOk() && L"Invalid color passed to IsDark()!");
Expand All @@ -375,7 +371,7 @@ class wxStartPage final : public wxWindow
/// @param shadeOrTintValue How much to lighten or darken a color
/// (should be between @c 0.0 to @c 1.0.)
/// @returns The shaded or tinted color.
wxNODISCARD
[[nodiscard]]
static wxColour ShadeOrTint(const wxColour& color,
const double shadeOrTintValue = 0.2)
{
Expand All @@ -387,7 +383,7 @@ class wxStartPage final : public wxWindow
/// against the specified color.
/// @param color The color to contrast against to see if white or black should go on it.
/// @returns Black or white; whichever contrasts better against @c color.
wxNODISCARD
[[nodiscard]]
static wxColour BlackOrWhiteContrast(const wxColour& color)
{ return (IsDark(color) ? *wxWHITE : *wxBLACK); }

Expand Down

0 comments on commit 4136cac

Please sign in to comment.