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:
parent
8eb3729fec
commit
7555bba1bf
12 changed files with 94 additions and 93 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -26,14 +26,14 @@
|
|||
|
||||
#ifdef __WXMSW__
|
||||
#include "wx/msw/private.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#elif defined(__WXOSX__)
|
||||
#include "wx/osx/private.h"
|
||||
#endif
|
||||
|
||||
wxRibbonAUIArtProvider::wxRibbonAUIArtProvider()
|
||||
: wxRibbonMSWArtProvider(false)
|
||||
{
|
||||
#if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
|
||||
#ifdef __WXOSX__
|
||||
wxColor base_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
|
||||
#else
|
||||
wxColor base_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
|
||||
|
|
@ -233,19 +233,23 @@ void wxRibbonAUIArtProvider::SetColourScheme(
|
|||
// TODO: Remove next line once this provider stops piggybacking MSW
|
||||
wxRibbonMSWArtProvider::SetColourScheme(primary, secondary, tertiary);
|
||||
|
||||
#define LikePrimary(luminance) \
|
||||
wxRibbonShiftLuminance(primary_hsl, luminance ## f).ToRGB()
|
||||
#define LikeSecondary(luminance) \
|
||||
wxRibbonShiftLuminance(secondary_hsl, luminance ## f).ToRGB()
|
||||
const auto LikePrimary = [primary_hsl](double luminance)
|
||||
{
|
||||
return wxRibbonShiftLuminance(primary_hsl, luminance).ToRGB();
|
||||
};
|
||||
const auto LikeSecondary = [secondary_hsl](double luminance)
|
||||
{
|
||||
return wxRibbonShiftLuminance(secondary_hsl, luminance).ToRGB();
|
||||
};
|
||||
|
||||
m_tab_ctrl_background_colour = LikePrimary(0.9);
|
||||
#ifdef __WXMAC__
|
||||
#ifdef __WXOSX__
|
||||
m_tab_ctrl_background_gradient_colour = m_tab_ctrl_background_colour;
|
||||
#else
|
||||
m_tab_ctrl_background_gradient_colour = LikePrimary(1.7);
|
||||
#endif
|
||||
m_tab_border_pen = LikePrimary(0.75);
|
||||
#ifdef __WXMAC__
|
||||
#ifdef __WXOSX__
|
||||
m_tab_label_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_CAPTIONTEXT);
|
||||
#else
|
||||
m_tab_label_colour = LikePrimary(0.1);
|
||||
|
|
@ -253,14 +257,14 @@ void wxRibbonAUIArtProvider::SetColourScheme(
|
|||
m_tab_active_label_colour = m_tab_label_colour;
|
||||
m_tab_hover_label_colour = m_tab_label_colour;
|
||||
m_tab_hover_background_top_colour = primary_hsl.ToRGB();
|
||||
#ifdef __WXMAC__
|
||||
#ifdef __WXOSX__
|
||||
m_tab_hover_background_top_gradient_colour = m_tab_hover_background_top_colour;
|
||||
#else
|
||||
m_tab_hover_background_top_gradient_colour = LikePrimary(1.6);
|
||||
#endif
|
||||
m_tab_hover_background_brush = m_tab_hover_background_top_colour;
|
||||
m_tab_active_background_colour = m_tab_ctrl_background_gradient_colour;
|
||||
#ifdef __WXMAC__
|
||||
#ifdef __WXOSX__
|
||||
m_tab_active_background_gradient_colour = m_tab_active_background_colour;
|
||||
#else
|
||||
m_tab_active_background_gradient_colour = primary_hsl.ToRGB();
|
||||
|
|
@ -282,7 +286,7 @@ void wxRibbonAUIArtProvider::SetColourScheme(
|
|||
m_button_bar_hover_background_brush = LikeSecondary(1.7);
|
||||
m_button_bar_active_background_brush = LikeSecondary(1.4);
|
||||
m_button_bar_label_colour = m_tab_label_colour;
|
||||
#ifdef __WXMAC__
|
||||
#ifdef __WXOSX__
|
||||
m_button_bar_label_disabled_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_INACTIVECAPTIONTEXT);
|
||||
#else
|
||||
m_button_bar_label_disabled_colour = m_tab_label_colour;
|
||||
|
|
@ -321,9 +325,6 @@ void wxRibbonAUIArtProvider::SetColourScheme(
|
|||
|
||||
m_tab_highlight_colour = top_colour1;
|
||||
m_tab_highlight_gradient_colour = bottom_colour1;
|
||||
|
||||
#undef LikeSecondary
|
||||
#undef LikePrimary
|
||||
}
|
||||
|
||||
void wxRibbonAUIArtProvider::DrawTabCtrlBackground(
|
||||
|
|
@ -357,7 +358,7 @@ int wxRibbonAUIArtProvider::GetTabCtrlHeight(
|
|||
if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS)
|
||||
{
|
||||
dc.SetFont(m_tab_active_label_font);
|
||||
text_height = dc.GetTextExtent(wxT("ABCDEFXj")).GetHeight();
|
||||
text_height = dc.GetTextExtent("ABCDEFXj").GetHeight();
|
||||
}
|
||||
if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS)
|
||||
{
|
||||
|
|
@ -463,7 +464,7 @@ void wxRibbonAUIArtProvider::DrawTab(wxDC& dc,
|
|||
if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS)
|
||||
{
|
||||
wxString label = tab.page->GetLabel();
|
||||
if(!label.IsEmpty())
|
||||
if(!label.empty())
|
||||
{
|
||||
if (tab.active)
|
||||
{
|
||||
|
|
@ -530,7 +531,7 @@ void wxRibbonAUIArtProvider::GetBarTabWidth(
|
|||
{
|
||||
int width = 0;
|
||||
int min = 0;
|
||||
if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) && !label.IsEmpty())
|
||||
if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) && !label.empty())
|
||||
{
|
||||
dc.SetFont(m_tab_active_label_font);
|
||||
width += dc.GetTextExtent(label).GetWidth();
|
||||
|
|
@ -664,9 +665,8 @@ void wxRibbonAUIArtProvider::DrawScrollButton(
|
|||
}
|
||||
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
wxBrush B(m_tab_label_colour);
|
||||
dc.SetBrush(B);
|
||||
dc.DrawPolygon(sizeof(arrow_points)/sizeof(wxPoint), arrow_points, x, y);
|
||||
dc.SetBrush(wxBrush(m_tab_label_colour));
|
||||
dc.DrawPolygon(WXSIZEOF(arrow_points), arrow_points, x, y);
|
||||
}
|
||||
|
||||
wxSize wxRibbonAUIArtProvider::GetPanelSize(
|
||||
|
|
@ -781,7 +781,7 @@ void wxRibbonAUIArtProvider::DrawPanelBackground(
|
|||
dc.SetTextForeground(m_panel_label_colour);
|
||||
}
|
||||
dc.GradientFillLinear(label_rect,
|
||||
#ifdef __WXMAC__
|
||||
#ifdef __WXOSX__
|
||||
label_bg_grad_colour, label_bg_colour, wxSOUTH);
|
||||
#else
|
||||
label_bg_colour, label_bg_grad_colour, wxSOUTH);
|
||||
|
|
@ -794,7 +794,7 @@ void wxRibbonAUIArtProvider::DrawPanelBackground(
|
|||
wxRect gradient_rect(true_rect);
|
||||
gradient_rect.y += label_rect.height + 1;
|
||||
gradient_rect.height = true_rect.height - label_rect.height - 3;
|
||||
#ifdef __WXMAC__
|
||||
#ifdef __WXOSX__
|
||||
wxColour colour = m_page_hover_background_gradient_colour;
|
||||
wxColour gradient = m_page_hover_background_colour;
|
||||
#else
|
||||
|
|
@ -840,7 +840,7 @@ void wxRibbonAUIArtProvider::DrawMinimisedPanel(
|
|||
{
|
||||
wxColour colour = m_page_hover_background_colour;
|
||||
wxColour gradient = m_page_hover_background_gradient_colour;
|
||||
#ifdef __WXMAC__
|
||||
#ifdef __WXOSX__
|
||||
if(!wnd->GetExpandedPanel())
|
||||
#else
|
||||
if(wnd->GetExpandedPanel())
|
||||
|
|
@ -864,7 +864,7 @@ void wxRibbonAUIArtProvider::DrawMinimisedPanel(
|
|||
preview_caption_rect.height = 7;
|
||||
preview.y += preview_caption_rect.height;
|
||||
preview.height -= preview_caption_rect.height;
|
||||
#ifdef __WXMAC__
|
||||
#ifdef __WXOSX__
|
||||
dc.GradientFillLinear(preview_caption_rect,
|
||||
m_panel_hover_label_background_gradient_colour,
|
||||
m_panel_hover_label_background_colour, wxSOUTH);
|
||||
|
|
@ -926,7 +926,7 @@ void wxRibbonAUIArtProvider::DrawPartialPanelBackground(wxDC& dc,
|
|||
paint_rect.y += offset.y;
|
||||
|
||||
wxColour bg_clr, bg_grad_clr;
|
||||
#ifdef __WXMAC__
|
||||
#ifdef __WXOSX__
|
||||
bg_grad_clr = m_page_hover_background_colour;
|
||||
bg_clr = m_page_hover_background_gradient_colour;
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -215,9 +215,9 @@ wxColour wxRibbonHSLColour::ToRGB() const
|
|||
blue = tmp1;
|
||||
}
|
||||
return wxColour(
|
||||
(unsigned char)(red * 255.0f),
|
||||
(unsigned char)(green * 255.0f),
|
||||
(unsigned char)(blue * 255.0f));
|
||||
static_cast<unsigned char>(red * 255.0f),
|
||||
static_cast<unsigned char>(green * 255.0f),
|
||||
static_cast<unsigned char>(blue * 255.0f));
|
||||
}
|
||||
|
||||
wxRibbonHSLColour wxRibbonHSLColour::Darker(float delta) const
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ static const char * const ribbon_help_button_xpm[] = {
|
|||
};
|
||||
|
||||
wxRibbonMSWArtProvider::wxRibbonMSWArtProvider(bool set_colour_scheme)
|
||||
#if defined( __WXMAC__ )
|
||||
#if defined( __WXOSX__ )
|
||||
: m_tab_label_font(*wxSMALL_FONT)
|
||||
#else
|
||||
: m_tab_label_font(*wxNORMAL_FONT)
|
||||
|
|
@ -354,12 +354,18 @@ void wxRibbonMSWArtProvider::SetColourScheme(
|
|||
// Map secondary luminance from [0, 1] to [0.1, 0.9]
|
||||
secondary_hsl.luminance = std::cos(secondary_hsl.luminance * float(M_PI)) * -0.4f + 0.5f;
|
||||
|
||||
#define LikePrimary(h, s, l) \
|
||||
primary_hsl.ShiftHue(h ## f).Saturated(primary_is_gray ? 0 : s ## f) \
|
||||
.Lighter(l ## f).ToRGB()
|
||||
#define LikeSecondary(h, s, l) \
|
||||
secondary_hsl.ShiftHue(h ## f).Saturated(secondary_is_gray ? 0 : s ## f) \
|
||||
.Lighter(l ## f).ToRGB()
|
||||
const auto LikePrimary = [primary_hsl, primary_is_gray]
|
||||
(double h, double s, double l)
|
||||
{
|
||||
return primary_hsl.ShiftHue(h).Saturated(primary_is_gray ? 0.0 : s)
|
||||
.Lighter(l).ToRGB();
|
||||
};
|
||||
const auto LikeSecondary = [secondary_hsl, secondary_is_gray]
|
||||
(double h, double s, double l)
|
||||
{
|
||||
return secondary_hsl.ShiftHue(h).Saturated(secondary_is_gray ? 0.0 : s)
|
||||
.Lighter(l).ToRGB();
|
||||
};
|
||||
|
||||
m_page_border_pen = LikePrimary(1.4, 0.00, -0.08);
|
||||
|
||||
|
|
@ -483,9 +489,6 @@ void wxRibbonMSWArtProvider::SetColourScheme(
|
|||
m_tab_highlight_colour = top_colour2;
|
||||
m_tab_highlight_gradient_colour = bottom_colour2;
|
||||
|
||||
#undef LikePrimary
|
||||
#undef LikeSecondary
|
||||
|
||||
// Invalidate cached tab separator
|
||||
m_cached_tab_separator_visibility = -1.0;
|
||||
}
|
||||
|
|
@ -690,7 +693,7 @@ int wxRibbonMSWArtProvider::GetMetric(int id) const
|
|||
case wxRIBBON_ART_GALLERY_BITMAP_PADDING_BOTTOM_SIZE:
|
||||
return m_gallery_bitmap_padding_bottom_size;
|
||||
default:
|
||||
wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
|
||||
wxFAIL_MSG("Invalid Metric Ordinal");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -738,7 +741,7 @@ void wxRibbonMSWArtProvider::SetMetric(int id, int new_val)
|
|||
m_gallery_bitmap_padding_bottom_size = new_val;
|
||||
break;
|
||||
default:
|
||||
wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
|
||||
wxFAIL_MSG("Invalid Metric Ordinal");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -757,7 +760,7 @@ void wxRibbonMSWArtProvider::SetFont(int id, const wxFont& font)
|
|||
m_panel_label_font = font;
|
||||
break;
|
||||
default:
|
||||
wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
|
||||
wxFAIL_MSG("Invalid Metric Ordinal");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -773,7 +776,7 @@ wxFont wxRibbonMSWArtProvider::GetFont(int id) const
|
|||
case wxRIBBON_ART_PANEL_LABEL_FONT:
|
||||
return m_panel_label_font;
|
||||
default:
|
||||
wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
|
||||
wxFAIL_MSG("Invalid Metric Ordinal");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -972,7 +975,7 @@ wxColour wxRibbonMSWArtProvider::GetColour(int id) const
|
|||
case wxRIBBON_ART_TOOL_ACTIVE_BACKGROUND_GRADIENT_COLOUR:
|
||||
return m_tool_active_background_gradient_colour;
|
||||
default:
|
||||
wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
|
||||
wxFAIL_MSG("Invalid Metric Ordinal");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1319,7 +1322,7 @@ void wxRibbonMSWArtProvider::SetColour(int id, const wxColor& colour)
|
|||
m_tool_active_background_gradient_colour = colour;
|
||||
break;
|
||||
default:
|
||||
wxFAIL_MSG(wxT("Invalid Metric Ordinal"));
|
||||
wxFAIL_MSG("Invalid Metric Ordinal");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1451,7 +1454,7 @@ void wxRibbonMSWArtProvider::DrawTab(
|
|||
if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS)
|
||||
{
|
||||
wxString label = tab.page->GetLabel();
|
||||
if(!label.IsEmpty())
|
||||
if(!label.empty())
|
||||
{
|
||||
dc.SetFont(m_tab_label_font);
|
||||
|
||||
|
|
@ -1918,7 +1921,7 @@ void wxRibbonMSWArtProvider::DrawPanelBackground(
|
|||
if(label_size.GetWidth() > label_rect.GetWidth())
|
||||
{
|
||||
// Test if there is enough length for 3 letters and ...
|
||||
wxString new_label = label.Mid(0, 3) + wxT("...");
|
||||
wxString new_label = label.Mid(0, 3) + "...";
|
||||
label_size = dc.GetTextExtent(new_label);
|
||||
if(label_size.GetWidth() > label_rect.GetWidth())
|
||||
{
|
||||
|
|
@ -1932,7 +1935,7 @@ void wxRibbonMSWArtProvider::DrawPanelBackground(
|
|||
// Display as many characters as possible and append ...
|
||||
for(size_t len = label.Len() - 1; len >= 3; --len)
|
||||
{
|
||||
new_label = label.Mid(0, len) + wxT("...");
|
||||
new_label = label.Mid(0, len) + "...";
|
||||
label_size = dc.GetTextExtent(new_label);
|
||||
if(label_size.GetWidth() <= label_rect.GetWidth())
|
||||
{
|
||||
|
|
@ -2879,7 +2882,7 @@ void wxRibbonMSWArtProvider::GetBarTabWidth(
|
|||
{
|
||||
int width = 0;
|
||||
int min = 0;
|
||||
if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) && !label.IsEmpty())
|
||||
if((m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS) && !label.empty())
|
||||
{
|
||||
dc.SetFont(m_tab_label_font);
|
||||
width += dc.GetTextExtent(label).GetWidth();
|
||||
|
|
@ -2933,7 +2936,7 @@ int wxRibbonMSWArtProvider::GetTabCtrlHeight(
|
|||
if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS)
|
||||
{
|
||||
dc.SetFont(m_tab_label_font);
|
||||
text_height = dc.GetTextExtent(wxT("ABCDEFXj")).GetHeight() + 10;
|
||||
text_height = dc.GetTextExtent("ABCDEFXj").GetHeight() + 10;
|
||||
}
|
||||
if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ void wxRibbonBar::AddPage(wxRibbonPage *page)
|
|||
|
||||
bool wxRibbonBar::DismissExpandedPanel()
|
||||
{
|
||||
if(m_current_page == -1)
|
||||
if(m_current_page == wxNOT_FOUND)
|
||||
return false;
|
||||
return m_pages.Item(m_current_page).page->DismissExpandedPanel();
|
||||
}
|
||||
|
|
@ -206,12 +206,12 @@ void wxRibbonBar::OnMouseMove(wxMouseEvent& evt)
|
|||
{
|
||||
int x = evt.GetX();
|
||||
int y = evt.GetY();
|
||||
int hovered_page = -1;
|
||||
int hovered_page = wxNOT_FOUND;
|
||||
bool refresh_tabs = false;
|
||||
if(y < m_tab_height)
|
||||
{
|
||||
// It is quite likely that the mouse moved a small amount and is still over the same tab
|
||||
if(m_current_hovered_page != -1 && m_pages.Item((size_t)m_current_hovered_page).rect.Contains(x, y))
|
||||
if(m_current_hovered_page != wxNOT_FOUND && m_pages.Item((size_t)m_current_hovered_page).rect.Contains(x, y))
|
||||
{
|
||||
hovered_page = m_current_hovered_page;
|
||||
// But be careful, if tabs can be scrolled, then parts of the tab rect may not be valid
|
||||
|
|
@ -219,7 +219,7 @@ void wxRibbonBar::OnMouseMove(wxMouseEvent& evt)
|
|||
{
|
||||
if(x >= m_tab_scroll_right_button_rect.GetX() || x < m_tab_scroll_left_button_rect.GetRight())
|
||||
{
|
||||
hovered_page = -1;
|
||||
hovered_page = wxNOT_FOUND;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -230,12 +230,12 @@ void wxRibbonBar::OnMouseMove(wxMouseEvent& evt)
|
|||
}
|
||||
if(hovered_page != m_current_hovered_page)
|
||||
{
|
||||
if(m_current_hovered_page != -1)
|
||||
if(m_current_hovered_page != wxNOT_FOUND)
|
||||
{
|
||||
m_pages.Item((int)m_current_hovered_page).hovered = false;
|
||||
}
|
||||
m_current_hovered_page = hovered_page;
|
||||
if(m_current_hovered_page != -1)
|
||||
if(m_current_hovered_page != wxNOT_FOUND)
|
||||
{
|
||||
m_pages.Item((int)m_current_hovered_page).hovered = true;
|
||||
}
|
||||
|
|
@ -275,10 +275,10 @@ void wxRibbonBar::OnMouseLeave(wxMouseEvent& WXUNUSED(evt))
|
|||
// The ribbon bar is (usually) at the top of a window, and at least on MSW, the mouse
|
||||
// can leave the window quickly and leave a tab in the hovered state.
|
||||
bool refresh_tabs = false;
|
||||
if(m_current_hovered_page != -1)
|
||||
if(m_current_hovered_page != wxNOT_FOUND)
|
||||
{
|
||||
m_pages.Item((int)m_current_hovered_page).hovered = false;
|
||||
m_current_hovered_page = -1;
|
||||
m_current_hovered_page = wxNOT_FOUND;
|
||||
refresh_tabs = true;
|
||||
}
|
||||
if(m_tab_scroll_left_button_state & wxRIBBON_SCROLL_BTN_HOVERED)
|
||||
|
|
@ -367,7 +367,7 @@ void wxRibbonBar::DeletePage(size_t n)
|
|||
|
||||
// Schedule page object for destruction and not destroying directly
|
||||
// as this function can be called in an event handler and page functions
|
||||
// can be called afeter removing.
|
||||
// can be called after removing.
|
||||
// Like in wxRibbonButtonBar::OnMouseUp
|
||||
if(!wxTheApp->IsScheduledForDestruction(page))
|
||||
{
|
||||
|
|
@ -378,7 +378,7 @@ void wxRibbonBar::DeletePage(size_t n)
|
|||
|
||||
if(m_current_page == static_cast<int>(n))
|
||||
{
|
||||
m_current_page = -1;
|
||||
m_current_page = wxNOT_FOUND;
|
||||
|
||||
if(m_pages.GetCount() > 0)
|
||||
{
|
||||
|
|
@ -407,7 +407,7 @@ void wxRibbonBar::ClearPages()
|
|||
wxRibbonPage *page = m_pages.Item(i).page;
|
||||
// Schedule page object for destruction and not destroying directly
|
||||
// as this function can be called in an event handler and page functions
|
||||
// can be called afeter removing.
|
||||
// can be called after removing.
|
||||
// Like in wxRibbonButtonBar::OnMouseUp
|
||||
if(!wxTheApp->IsScheduledForDestruction(page))
|
||||
{
|
||||
|
|
@ -416,7 +416,7 @@ void wxRibbonBar::ClearPages()
|
|||
}
|
||||
m_pages.Empty();
|
||||
Realize();
|
||||
m_current_page = -1;
|
||||
m_current_page = wxNOT_FOUND;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
|
@ -432,7 +432,7 @@ bool wxRibbonBar::SetActivePage(size_t page)
|
|||
return false;
|
||||
}
|
||||
|
||||
if(m_current_page != -1)
|
||||
if(m_current_page != wxNOT_FOUND)
|
||||
{
|
||||
m_pages.Item((size_t)m_current_page).active = false;
|
||||
m_pages.Item((size_t)m_current_page).page->Hide();
|
||||
|
|
@ -732,8 +732,8 @@ wxRibbonBar::wxRibbonBar()
|
|||
m_tab_margin_right = 0;
|
||||
m_tab_height = 0;
|
||||
m_tab_scroll_amount = 0;
|
||||
m_current_page = -1;
|
||||
m_current_hovered_page = -1;
|
||||
m_current_page = wxNOT_FOUND;
|
||||
m_current_hovered_page = wxNOT_FOUND;
|
||||
m_tab_scroll_left_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
|
||||
m_tab_scroll_right_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
|
||||
m_tab_scroll_buttons_shown = false;
|
||||
|
|
@ -778,7 +778,7 @@ bool wxRibbonBar::Create(wxWindow* parent,
|
|||
|
||||
void wxRibbonBar::CommonInit(long style)
|
||||
{
|
||||
SetName(wxT("wxRibbonBar"));
|
||||
SetName("wxRibbonBar");
|
||||
|
||||
m_flags = style;
|
||||
m_tabs_total_width_ideal = 0;
|
||||
|
|
@ -791,8 +791,8 @@ void wxRibbonBar::CommonInit(long style)
|
|||
m_tab_margin_right += 20;
|
||||
m_tab_height = 20; // initial guess
|
||||
m_tab_scroll_amount = 0;
|
||||
m_current_page = -1;
|
||||
m_current_hovered_page = -1;
|
||||
m_current_page = wxNOT_FOUND;
|
||||
m_current_hovered_page = wxNOT_FOUND;
|
||||
m_tab_scroll_left_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
|
||||
m_tab_scroll_right_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
|
||||
m_tab_scroll_buttons_shown = false;
|
||||
|
|
@ -964,7 +964,7 @@ void wxRibbonBar::DoEraseBackground(wxDC& dc)
|
|||
void wxRibbonBar::OnSize(wxSizeEvent& evt)
|
||||
{
|
||||
RecalculateTabSizes();
|
||||
if(m_current_page != -1)
|
||||
if(m_current_page != wxNOT_FOUND)
|
||||
{
|
||||
RepositionPage(m_pages.Item(m_current_page).page);
|
||||
}
|
||||
|
|
@ -1262,7 +1262,7 @@ void wxRibbonBar::RecalculateMinSize()
|
|||
wxSize wxRibbonBar::DoGetBestSize() const
|
||||
{
|
||||
wxSize best(0, 0);
|
||||
if(m_current_page != -1)
|
||||
if(m_current_page != wxNOT_FOUND)
|
||||
{
|
||||
best = m_pages.Item(m_current_page).page->GetBestSize();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,11 +35,7 @@ wxIMPLEMENT_CLASS(wxRibbonGallery, wxRibbonControl);
|
|||
class wxRibbonGalleryItem
|
||||
{
|
||||
public:
|
||||
wxRibbonGalleryItem()
|
||||
{
|
||||
m_id = 0;
|
||||
m_is_visible = false;
|
||||
}
|
||||
wxRibbonGalleryItem() = default;
|
||||
|
||||
void SetId(int id) {m_id = id;}
|
||||
void SetBitmap(const wxBitmap& bitmap) {m_bitmap = bitmap;}
|
||||
|
|
@ -61,8 +57,8 @@ protected:
|
|||
wxBitmap m_bitmap;
|
||||
wxClientDataContainer m_client_data;
|
||||
wxRect m_position;
|
||||
int m_id;
|
||||
bool m_is_visible;
|
||||
int m_id = 0;
|
||||
bool m_is_visible = false;
|
||||
};
|
||||
|
||||
wxBEGIN_EVENT_TABLE(wxRibbonGallery, wxRibbonControl)
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ static int GetSizeInOrientation(wxSize size, wxOrientation orientation);
|
|||
class wxRibbonPageScrollButton : public wxRibbonControl
|
||||
{
|
||||
public:
|
||||
wxRibbonPageScrollButton(wxRibbonPage* sibling,
|
||||
explicit wxRibbonPageScrollButton(wxRibbonPage* sibling,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
|
|
@ -54,7 +54,7 @@ protected:
|
|||
void OnMouseDown(wxMouseEvent& evt);
|
||||
void OnMouseUp(wxMouseEvent& evt);
|
||||
|
||||
wxRibbonPage* m_sibling;
|
||||
wxRibbonPage* m_sibling = nullptr;
|
||||
long m_flags;
|
||||
|
||||
wxDECLARE_CLASS(wxRibbonPageScrollButton);
|
||||
|
|
|
|||
|
|
@ -711,7 +711,9 @@ bool wxRibbonPanel::Realize()
|
|||
scale = 2.0;
|
||||
|
||||
wxImage img(m_minimised_icon.ConvertToImage());
|
||||
img.Rescale(int(scale * bitmap_size.GetWidth()), int(scale * bitmap_size.GetHeight()), wxIMAGE_QUALITY_HIGH);
|
||||
img.Rescale(wxRound(scale * bitmap_size.GetWidth()),
|
||||
wxRound(scale * bitmap_size.GetHeight()),
|
||||
wxIMAGE_QUALITY_HIGH);
|
||||
m_minimised_icon_resized = wxBitmap(img, -1, scale);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public:
|
|||
wxRect dropdown;
|
||||
wxPoint position;
|
||||
wxSize size;
|
||||
wxObject* client_data;
|
||||
wxObject* client_data = nullptr;
|
||||
int id;
|
||||
wxRibbonButtonKind kind;
|
||||
long state;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue