wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_DOWN, wxRibbonBarEvent);
wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONBAR_TAB_RIGHT_UP, wxRibbonBarEvent);
wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONBAR_TAB_LEFT_DCLICK, wxRibbonBarEvent);
+wxDEFINE_EVENT(wxEVT_COMMAND_RIBBONBAR_TOGGLED, wxRibbonBarEvent);
IMPLEMENT_CLASS(wxRibbonBar, wxRibbonControl)
IMPLEMENT_DYNAMIC_CLASS(wxRibbonBarEvent, wxNotifyEvent)
info.page = page;
info.active = false;
info.hovered = false;
+ info.highlight = false;
info.shown = true;
// info.rect not set (intentional)
{
RefreshTabBar();
}
+ HitTestToggleButton(evt.GetPosition());
}
void wxRibbonBar::OnMouseLeave(wxMouseEvent& WXUNUSED(evt))
{
RefreshTabBar();
}
+ if(m_toggle_button_hovered)
+ {
+ m_bar_hovered = false;
+ m_toggle_button_hovered = false;
+ Refresh(false);
+ }
}
wxRibbonPage* wxRibbonBar::GetPage(int n)
m_pages.Item(page).shown = show;
}
+bool wxRibbonBar::IsPageHighlighted(size_t page) const
+{
+ if (page >= m_pages.GetCount())
+ return false;
+ return m_pages.Item(page).highlight;
+}
+
+void wxRibbonBar::AddPageHighlight(size_t page, bool highlight)
+{
+ if(page >= m_pages.GetCount())
+ return;
+ m_pages.Item(page).highlight = highlight;
+}
+
void wxRibbonBar::DeletePage(size_t n)
{
if(n < m_pages.GetCount())
SetArtProvider(new wxRibbonDefaultArtProvider);
}
SetBackgroundStyle(wxBG_STYLE_CUSTOM);
+
+ m_toggle_button_hovered = false;
+ m_bar_hovered = false;
}
void wxRibbonBar::SetArtProvider(wxRibbonArtProvider* art)
DoEraseBackground(dc);
+ m_toggle_button_rect = m_art->GetBarToggleButtonArea(dc, this, GetSize());
+
size_t numtabs = m_pages.GetCount();
double sep_visibility = 0.0;
bool draw_sep = false;
m_art->DrawScrollButton(dc, this, m_tab_scroll_right_button_rect, wxRIBBON_SCROLL_BTN_RIGHT | m_tab_scroll_right_button_state | wxRIBBON_SCROLL_BTN_FOR_TABS);
}
}
+ wxRect rect(GetClientSize().GetWidth() - 30, 6, 12, 12);
+ if ( m_flags & wxRIBBON_BAR_SHOW_TOGGLE_BUTTON )
+ m_art->DrawToggleButton(dc, this, rect, ArePanelsShown());
}
void wxRibbonBar::OnEraseBackground(wxEraseEvent& WXUNUSED(evt))
RefreshTabBar();
}
}
+
+ wxPoint position = evt.GetPosition();
+
+ if(position.x >= 0 && position.y >= 0)
+ {
+ wxSize size = GetSize();
+ if(position.x < size.GetWidth() && position.y < size.GetHeight())
+ {
+ if(m_toggle_button_rect.Contains(position))
+ {
+ ShowPanels(!ArePanelsShown());
+ wxRibbonBarEvent event(wxEVT_COMMAND_RIBBONBAR_TOGGLED, GetId());
+ event.SetEventObject(this);
+ ProcessWindowEvent(event);
+ }
+ }
+ }
}
void wxRibbonBar::OnMouseLeftUp(wxMouseEvent& WXUNUSED(evt))
return best;
}
+void wxRibbonBar::HitTestToggleButton(wxPoint position)
+{
+ bool hovered = false, toggle_button_hovered = false;
+ if(position.x >= 0 && position.y >= 0)
+ {
+ wxSize size = GetSize();
+ if(position.x < size.GetWidth() && position.y < size.GetHeight())
+ {
+ hovered = true;
+ }
+ }
+ if(hovered)
+ {
+ toggle_button_hovered = (m_flags & wxRIBBON_BAR_SHOW_TOGGLE_BUTTON) &&
+ m_toggle_button_rect.Contains(position);
+
+ if(hovered != m_bar_hovered || toggle_button_hovered != m_toggle_button_hovered)
+ {
+ m_bar_hovered = hovered;
+ m_toggle_button_hovered = toggle_button_hovered;
+ Refresh(false);
+ }
+ }
+}
+
#endif // wxUSE_RIBBON