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:
@@ -140,9 +140,11 @@ public:
|
|||||||
void AddPageHighlight(size_t page, bool highlight = true);
|
void AddPageHighlight(size_t page, bool highlight = true);
|
||||||
void RemovePageHighlight(size_t page) { AddPageHighlight(page, false); }
|
void RemovePageHighlight(size_t page) { AddPageHighlight(page, false); }
|
||||||
|
|
||||||
|
void ShowPanels(wxRibbonDisplayMode mode);
|
||||||
void ShowPanels(bool show = true);
|
void ShowPanels(bool show = true);
|
||||||
void HidePanels() { ShowPanels(false); }
|
void HidePanels() { ShowPanels(wxRIBBON_BAR_MINIMIZED); }
|
||||||
bool ArePanelsShown() const { return m_arePanelsShown; }
|
bool ArePanelsShown() const { return m_arePanelsShown; }
|
||||||
|
wxRibbonDisplayMode GetDisplayMode() const { return m_ribbon_state; }
|
||||||
|
|
||||||
virtual bool HasMultiplePages() const wxOVERRIDE { return true; }
|
virtual bool HasMultiplePages() const wxOVERRIDE { return true; }
|
||||||
|
|
||||||
|
@@ -348,6 +348,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
void RemovePageHighlight(size_t page);
|
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.
|
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
|
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.
|
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
|
@since 2.9.2
|
||||||
*/
|
*/
|
||||||
void ShowPanels(bool show = true);
|
void ShowPanels(bool show = true);
|
||||||
@@ -362,7 +374,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
Hides the panel area of the ribbon bar.
|
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
|
@since 2.9.2
|
||||||
*/
|
*/
|
||||||
@@ -377,6 +389,16 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool ArePanelsShown() const;
|
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
|
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
|
children. This must be called after all of the bar's children have been
|
||||||
|
@@ -115,12 +115,32 @@ bool wxRibbonBar::DismissExpandedPanel()
|
|||||||
return m_pages.Item(m_current_page).page->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()));
|
SetMinSize(wxSize(GetSize().GetWidth(), DoGetBestSize().GetHeight()));
|
||||||
Realise();
|
Realise();
|
||||||
GetParent()->Layout();
|
GetParent()->Layout();
|
||||||
|
|
||||||
|
m_ribbon_state = mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wxRibbonBar::ShowPanels(bool show)
|
||||||
|
{
|
||||||
|
ShowPanels( show ? wxRIBBON_BAR_PINNED : wxRIBBON_BAR_MINIMIZED );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRibbonBar::SetWindowStyleFlag(long style)
|
void wxRibbonBar::SetWindowStyleFlag(long style)
|
||||||
@@ -974,13 +994,11 @@ void wxRibbonBar::OnMouseLeftDown(wxMouseEvent& evt)
|
|||||||
{
|
{
|
||||||
if ( m_ribbon_state == wxRIBBON_BAR_MINIMIZED )
|
if ( m_ribbon_state == wxRIBBON_BAR_MINIMIZED )
|
||||||
{
|
{
|
||||||
ShowPanels();
|
ShowPanels(wxRIBBON_BAR_EXPANDED);
|
||||||
m_ribbon_state = wxRIBBON_BAR_EXPANDED;
|
|
||||||
}
|
}
|
||||||
else if ( (tab == &m_pages.Item(m_current_page)) && (m_ribbon_state == wxRIBBON_BAR_EXPANDED) )
|
else if ( (tab == &m_pages.Item(m_current_page)) && (m_ribbon_state == wxRIBBON_BAR_EXPANDED) )
|
||||||
{
|
{
|
||||||
HidePanels();
|
HidePanels();
|
||||||
m_ribbon_state = wxRIBBON_BAR_MINIMIZED;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -988,7 +1006,6 @@ void wxRibbonBar::OnMouseLeftDown(wxMouseEvent& evt)
|
|||||||
if ( m_ribbon_state == wxRIBBON_BAR_EXPANDED )
|
if ( m_ribbon_state == wxRIBBON_BAR_EXPANDED )
|
||||||
{
|
{
|
||||||
HidePanels();
|
HidePanels();
|
||||||
m_ribbon_state = wxRIBBON_BAR_MINIMIZED;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(tab && tab != &m_pages.Item(m_current_page))
|
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))
|
if(m_toggle_button_rect.Contains(position))
|
||||||
{
|
{
|
||||||
bool pshown = ArePanelsShown();
|
ShowPanels(ArePanelsShown() ? wxRIBBON_BAR_MINIMIZED : wxRIBBON_BAR_PINNED);
|
||||||
ShowPanels(!pshown);
|
|
||||||
if ( pshown )
|
|
||||||
m_ribbon_state = wxRIBBON_BAR_MINIMIZED;
|
|
||||||
else
|
|
||||||
m_ribbon_state = wxRIBBON_BAR_PINNED;
|
|
||||||
wxRibbonBarEvent event(wxEVT_RIBBONBAR_TOGGLED, GetId());
|
wxRibbonBarEvent event(wxEVT_RIBBONBAR_TOGGLED, GetId());
|
||||||
event.SetEventObject(this);
|
event.SetEventObject(this);
|
||||||
ProcessWindowEvent(event);
|
ProcessWindowEvent(event);
|
||||||
@@ -1168,13 +1180,11 @@ void wxRibbonBar::OnMouseDoubleClick(wxMouseEvent& evt)
|
|||||||
{
|
{
|
||||||
if ( m_ribbon_state == wxRIBBON_BAR_PINNED )
|
if ( m_ribbon_state == wxRIBBON_BAR_PINNED )
|
||||||
{
|
{
|
||||||
m_ribbon_state = wxRIBBON_BAR_MINIMIZED;
|
|
||||||
HidePanels();
|
HidePanels();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_ribbon_state = wxRIBBON_BAR_PINNED;
|
ShowPanels(wxRIBBON_BAR_PINNED);
|
||||||
ShowPanels();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1269,20 +1279,8 @@ void wxRibbonBar::HitTestRibbonButton(const wxRect& rect, const wxPoint& positio
|
|||||||
|
|
||||||
void wxRibbonBar::HideIfExpanded()
|
void wxRibbonBar::HideIfExpanded()
|
||||||
{
|
{
|
||||||
switch ( m_ribbon_state )
|
if ( m_ribbon_state == wxRIBBON_BAR_EXPANDED)
|
||||||
{
|
HidePanels();
|
||||||
case wxRIBBON_BAR_EXPANDED:
|
|
||||||
m_ribbon_state = wxRIBBON_BAR_MINIMIZED;
|
|
||||||
// Fall through
|
|
||||||
|
|
||||||
case wxRIBBON_BAR_MINIMIZED:
|
|
||||||
HidePanels();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxRIBBON_BAR_PINNED:
|
|
||||||
ShowPanels();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRibbonBar::OnKillFocus(wxFocusEvent& WXUNUSED(evt))
|
void wxRibbonBar::OnKillFocus(wxFocusEvent& WXUNUSED(evt))
|
||||||
|
Reference in New Issue
Block a user