Modernize ribbon code

The only real change in this commit is the use of wxRound() instead of
truncating cast to int when rescaling icons.

The rest consists of just some cleanup:

- Initialize (mostly) pointer member variables in their declaration.
- Remove wxT() from strings.
- Replace checks for __WXMAC__ with checks for __WXOSX__.
- Replace macros with lambda functions.
- Add "explicit"
- Replace wxString::IsEmpty() with empty().
- Use wxNOT_FOUND instead of -1.
- Use static_cast<> instead of C-style casts.

Closes #24261.
This commit is contained in:
Blake Madden 2024-01-27 20:59:12 -05:00 committed by Vadim Zeitlin
parent 8eb3729fec
commit 7555bba1bf
12 changed files with 94 additions and 93 deletions

View file

@ -68,7 +68,7 @@ public:
void SetPage(wxRibbonPage* page) {m_page = page;}
protected:
wxRibbonPage* m_page;
wxRibbonPage* m_page = nullptr;
#ifndef SWIG
private:
@ -80,7 +80,7 @@ class WXDLLIMPEXP_RIBBON wxRibbonPageTabInfo
{
public:
wxRect rect;
wxRibbonPage *page;
wxRibbonPage* page = nullptr;
int ideal_width;
int small_begin_need_separator_width;
int small_must_have_separator_width;

View file

@ -197,8 +197,8 @@ protected:
wxArrayRibbonButtonBarLayout m_layouts;
wxArrayRibbonButtonBarButtonBase m_buttons;
wxRibbonButtonBarButtonInstance* m_hovered_button;
wxRibbonButtonBarButtonInstance* m_active_button;
wxRibbonButtonBarButtonInstance* m_hovered_button = nullptr;
wxRibbonButtonBarButtonInstance* m_active_button = nullptr;
wxPoint m_layout_offset;
wxSize m_bitmap_size_large;
@ -209,7 +209,7 @@ protected:
bool m_show_tooltips_for_disabled;
private:
wxRibbonBar* m_ribbonBar;
wxRibbonBar* m_ribbonBar = nullptr;
#ifndef SWIG
wxDECLARE_CLASS(wxRibbonButtonBar);
@ -237,8 +237,8 @@ public:
bool PopupMenu(wxMenu* menu);
protected:
wxRibbonButtonBar* m_bar;
wxRibbonButtonBarButtonBase *m_button;
wxRibbonButtonBar* m_bar = nullptr;
wxRibbonButtonBarButtonBase* m_button = nullptr;
#ifndef SWIG
private:

View file

@ -105,7 +105,7 @@ protected:
wxRect m_scroll_up_button_rect;
wxRect m_scroll_down_button_rect;
wxRect m_extension_button_rect;
const wxRect* m_mouse_active_rect;
const wxRect* m_mouse_active_rect = nullptr;
int m_item_separation_x;
int m_item_separation_y;
int m_scroll_amount;
@ -147,8 +147,8 @@ public:
void SetGalleryItem(wxRibbonGalleryItem* item) {m_item = item;}
protected:
wxRibbonGallery* m_gallery;
wxRibbonGalleryItem* m_item;
wxRibbonGallery* m_gallery = nullptr;
wxRibbonGalleryItem* m_item = nullptr;
#ifndef SWIG
private:

View file

@ -84,9 +84,9 @@ protected:
wxBitmap m_icon;
wxSize m_old_size;
// NB: Scroll button windows are siblings rather than children (to get correct clipping of children)
wxRibbonPageScrollButton* m_scroll_left_btn;
wxRibbonPageScrollButton* m_scroll_right_btn;
wxSize* m_size_calc_array;
wxRibbonPageScrollButton* m_scroll_left_btn = nullptr;
wxRibbonPageScrollButton* m_scroll_right_btn = nullptr;
wxSize* m_size_calc_array = nullptr;
size_t m_size_calc_array_size;
int m_scroll_amount;
int m_scroll_amount_limit;