Add more precise wxRibbonBar::ShowPanels() overload.

The existing overload taking bool didn't allow to specify whether the panel
should be just expanded or expanded and pinned, add a new one supporting this.

Also fix a bug with not updating the ribbon state in the old method.

Closes #16133.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76277 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-04-04 15:28:51 +00:00
parent c87dd9ceb0
commit 4c76ae6707
3 changed files with 53 additions and 31 deletions

View File

@@ -140,9 +140,11 @@ public:
void AddPageHighlight(size_t page, bool highlight = true);
void RemovePageHighlight(size_t page) { AddPageHighlight(page, false); }
void ShowPanels(wxRibbonDisplayMode mode);
void ShowPanels(bool show = true);
void HidePanels() { ShowPanels(false); }
void HidePanels() { ShowPanels(wxRIBBON_BAR_MINIMIZED); }
bool ArePanelsShown() const { return m_arePanelsShown; }
wxRibbonDisplayMode GetDisplayMode() const { return m_ribbon_state; }
virtual bool HasMultiplePages() const wxOVERRIDE { return true; }

View File

@@ -348,6 +348,14 @@ public:
*/
void RemovePageHighlight(size_t page);
/**
Shows or hide the panel area of the ribbon bar according to the
given display mode.
@since 3.1.0
*/
void ShowPanels(wxRibbonDisplayMode mode);
/**
Shows or hides the panel area of the ribbon bar.
@@ -355,6 +363,10 @@ public:
be shown. This is useful for giving the user more screen space to work
with when he/she doesn't need to see the ribbon's options.
If the panel is currently shown, this method pins it, use the other
overload of this method to specify the exact panel display mode to
avoid it.
@since 2.9.2
*/
void ShowPanels(bool show = true);
@@ -362,7 +374,7 @@ public:
/**
Hides the panel area of the ribbon bar.
This method simply calls ShowPanels() with @false argument.
This method behaves like ShowPanels() with @false argument.
@since 2.9.2
*/
@@ -377,6 +389,16 @@ public:
*/
bool ArePanelsShown() const;
/**
Returns the current display mode of the panel area.
@see ShowPanels()
@since 3.1.0
*/
wxRibbonDisplayMode GetDisplayMode() const;
/**
Perform initial layout and size calculations of the bar and its
children. This must be called after all of the bar's children have been

View File

@@ -115,12 +115,32 @@ bool wxRibbonBar::DismissExpandedPanel()
return m_pages.Item(m_current_page).page->DismissExpandedPanel();
}
void wxRibbonBar::ShowPanels(bool show)
void wxRibbonBar::ShowPanels(wxRibbonDisplayMode mode)
{
m_arePanelsShown = show;
switch ( mode )
{
case wxRIBBON_BAR_PINNED:
case wxRIBBON_BAR_EXPANDED:
m_arePanelsShown = true;
break;
case wxRIBBON_BAR_MINIMIZED:
m_arePanelsShown = false;
break;
}
SetMinSize(wxSize(GetSize().GetWidth(), DoGetBestSize().GetHeight()));
Realise();
GetParent()->Layout();
m_ribbon_state = mode;
}
void wxRibbonBar::ShowPanels(bool show)
{
ShowPanels( show ? wxRIBBON_BAR_PINNED : wxRIBBON_BAR_MINIMIZED );
}
void wxRibbonBar::SetWindowStyleFlag(long style)
@@ -974,13 +994,11 @@ void wxRibbonBar::OnMouseLeftDown(wxMouseEvent& evt)
{
if ( m_ribbon_state == wxRIBBON_BAR_MINIMIZED )
{
ShowPanels();
m_ribbon_state = wxRIBBON_BAR_EXPANDED;
ShowPanels(wxRIBBON_BAR_EXPANDED);
}
else if ( (tab == &m_pages.Item(m_current_page)) && (m_ribbon_state == wxRIBBON_BAR_EXPANDED) )
{
HidePanels();
m_ribbon_state = wxRIBBON_BAR_MINIMIZED;
}
}
else
@@ -988,7 +1006,6 @@ void wxRibbonBar::OnMouseLeftDown(wxMouseEvent& evt)
if ( m_ribbon_state == wxRIBBON_BAR_EXPANDED )
{
HidePanels();
m_ribbon_state = wxRIBBON_BAR_MINIMIZED;
}
}
if(tab && tab != &m_pages.Item(m_current_page))
@@ -1028,12 +1045,7 @@ void wxRibbonBar::OnMouseLeftDown(wxMouseEvent& evt)
{
if(m_toggle_button_rect.Contains(position))
{
bool pshown = ArePanelsShown();
ShowPanels(!pshown);
if ( pshown )
m_ribbon_state = wxRIBBON_BAR_MINIMIZED;
else
m_ribbon_state = wxRIBBON_BAR_PINNED;
ShowPanels(ArePanelsShown() ? wxRIBBON_BAR_MINIMIZED : wxRIBBON_BAR_PINNED);
wxRibbonBarEvent event(wxEVT_RIBBONBAR_TOGGLED, GetId());
event.SetEventObject(this);
ProcessWindowEvent(event);
@@ -1168,13 +1180,11 @@ void wxRibbonBar::OnMouseDoubleClick(wxMouseEvent& evt)
{
if ( m_ribbon_state == wxRIBBON_BAR_PINNED )
{
m_ribbon_state = wxRIBBON_BAR_MINIMIZED;
HidePanels();
}
else
{
m_ribbon_state = wxRIBBON_BAR_PINNED;
ShowPanels();
ShowPanels(wxRIBBON_BAR_PINNED);
}
}
}
@@ -1269,20 +1279,8 @@ void wxRibbonBar::HitTestRibbonButton(const wxRect& rect, const wxPoint& positio
void wxRibbonBar::HideIfExpanded()
{
switch ( m_ribbon_state )
{
case wxRIBBON_BAR_EXPANDED:
m_ribbon_state = wxRIBBON_BAR_MINIMIZED;
// Fall through
case wxRIBBON_BAR_MINIMIZED:
HidePanels();
break;
case wxRIBBON_BAR_PINNED:
ShowPanels();
break;
}
if ( m_ribbon_state == wxRIBBON_BAR_EXPANDED)
HidePanels();
}
void wxRibbonBar::OnKillFocus(wxFocusEvent& WXUNUSED(evt))