Add possibility to hide panels in wxRibbon.
Add wxRibbonBar::{Show,Hide}Panels() and ArePanelsShown() accessor. Also add a toggle button to the sample to test the new functionality (unfortunately it couldn't be done by a control in the ribbon itself as there would be no way to show the panels back then). Closes #12707. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66612 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -437,6 +437,7 @@ All (GUI):
|
|||||||
- Added possibility to disable individual wxDataViewCtrl items (Neno Ganchev).
|
- Added possibility to disable individual wxDataViewCtrl items (Neno Ganchev).
|
||||||
- wxHTML: render in RTL order inside RTL window (Richard Bullington-McGuire).
|
- wxHTML: render in RTL order inside RTL window (Richard Bullington-McGuire).
|
||||||
- wxRibbon: added EVT_RIBBONGALLERY_CLICKED event (John Roberts).
|
- wxRibbon: added EVT_RIBBONGALLERY_CLICKED event (John Roberts).
|
||||||
|
- wxRibbon: allow hiding the panels and showing tabs only (snowleopard).
|
||||||
- Add support for CP-866 encoding to wxEncodingConverter (madnut).
|
- Add support for CP-866 encoding to wxEncodingConverter (madnut).
|
||||||
- Consistency fixes for keyboard events across all major ports.
|
- Consistency fixes for keyboard events across all major ports.
|
||||||
- Added EVT_RIBBONBAR_TAB_LEFT_DCLICK event (snowleopard).
|
- Added EVT_RIBBONBAR_TAB_LEFT_DCLICK event (snowleopard).
|
||||||
|
@@ -115,6 +115,10 @@ public:
|
|||||||
wxRibbonPage* GetPage(int n);
|
wxRibbonPage* GetPage(int n);
|
||||||
bool DismissExpandedPanel();
|
bool DismissExpandedPanel();
|
||||||
|
|
||||||
|
void ShowPanels(bool show = true);
|
||||||
|
void HidePanels() { ShowPanels(false); }
|
||||||
|
bool ArePanelsShown() const { return m_arePanelsShown; }
|
||||||
|
|
||||||
virtual bool HasMultiplePages() const { return true; }
|
virtual bool HasMultiplePages() const { return true; }
|
||||||
|
|
||||||
void SetWindowStyleFlag(long style);
|
void SetWindowStyleFlag(long style);
|
||||||
@@ -166,6 +170,7 @@ protected:
|
|||||||
int m_tab_scroll_left_button_state;
|
int m_tab_scroll_left_button_state;
|
||||||
int m_tab_scroll_right_button_state;
|
int m_tab_scroll_right_button_state;
|
||||||
bool m_tab_scroll_buttons_shown;
|
bool m_tab_scroll_buttons_shown;
|
||||||
|
bool m_arePanelsShown;
|
||||||
|
|
||||||
#ifndef SWIG
|
#ifndef SWIG
|
||||||
DECLARE_CLASS(wxRibbonBar)
|
DECLARE_CLASS(wxRibbonBar)
|
||||||
|
@@ -214,6 +214,35 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool DismissExpandedPanel();
|
bool DismissExpandedPanel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Shows or hides the panel area of the ribbon bar.
|
||||||
|
|
||||||
|
If the panel area is hidden, then only the tab of the ribbon bar will
|
||||||
|
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.
|
||||||
|
|
||||||
|
@since 2.9.2
|
||||||
|
*/
|
||||||
|
void ShowPanels(bool show = true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Hides the panel area of the ribbon bar.
|
||||||
|
|
||||||
|
This method simply calls ShowPanels() with @false argument.
|
||||||
|
|
||||||
|
@since 2.9.2
|
||||||
|
*/
|
||||||
|
void HidePanels();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Indicates whether the panel area of the ribbon bar is shown.
|
||||||
|
|
||||||
|
@see ShowPanels()
|
||||||
|
|
||||||
|
@since 2.9.2
|
||||||
|
*/
|
||||||
|
bool ArePanelsShown() 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
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include "wx/colordlg.h"
|
#include "wx/colordlg.h"
|
||||||
#include "wx/artprov.h"
|
#include "wx/artprov.h"
|
||||||
#include "wx/combobox.h"
|
#include "wx/combobox.h"
|
||||||
|
#include "wx/tglbtn.h"
|
||||||
#include "wx/wrapsizer.h"
|
#include "wx/wrapsizer.h"
|
||||||
|
|
||||||
// -- application --
|
// -- application --
|
||||||
@@ -71,6 +72,7 @@ public:
|
|||||||
ID_POSITION_LEFT,
|
ID_POSITION_LEFT,
|
||||||
ID_POSITION_LEFT_LABELS,
|
ID_POSITION_LEFT_LABELS,
|
||||||
ID_POSITION_LEFT_BOTH,
|
ID_POSITION_LEFT_BOTH,
|
||||||
|
ID_TOGGLE_PANELS
|
||||||
};
|
};
|
||||||
|
|
||||||
void OnCircleButton(wxRibbonButtonBarEvent& evt);
|
void OnCircleButton(wxRibbonButtonBarEvent& evt);
|
||||||
@@ -106,6 +108,8 @@ public:
|
|||||||
void OnPositionLeftBoth(wxCommandEvent& evt);
|
void OnPositionLeftBoth(wxCommandEvent& evt);
|
||||||
void OnPositionLeftDropdown(wxRibbonToolBarEvent& evt);
|
void OnPositionLeftDropdown(wxRibbonToolBarEvent& evt);
|
||||||
|
|
||||||
|
void OnTogglePanels(wxCommandEvent& evt);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxRibbonGallery* PopulateColoursPanel(wxWindow* panel, wxColour def,
|
wxRibbonGallery* PopulateColoursPanel(wxWindow* panel, wxColour def,
|
||||||
int gallery_id);
|
int gallery_id);
|
||||||
@@ -122,6 +126,8 @@ protected:
|
|||||||
wxRibbonGallery* m_primary_gallery;
|
wxRibbonGallery* m_primary_gallery;
|
||||||
wxRibbonGallery* m_secondary_gallery;
|
wxRibbonGallery* m_secondary_gallery;
|
||||||
wxTextCtrl* m_logwindow;
|
wxTextCtrl* m_logwindow;
|
||||||
|
wxToggleButton* m_togglePanels;
|
||||||
|
|
||||||
wxColourData m_colour_data;
|
wxColourData m_colour_data;
|
||||||
wxColour m_default_primary;
|
wxColour m_default_primary;
|
||||||
wxColour m_default_secondary;
|
wxColour m_default_secondary;
|
||||||
@@ -179,6 +185,7 @@ EVT_MENU(ID_POSITION_LEFT_BOTH, MyFrame::OnPositionLeftBoth)
|
|||||||
EVT_MENU(ID_POSITION_TOP, MyFrame::OnPositionTopLabels)
|
EVT_MENU(ID_POSITION_TOP, MyFrame::OnPositionTopLabels)
|
||||||
EVT_MENU(ID_POSITION_TOP_ICONS, MyFrame::OnPositionTopIcons)
|
EVT_MENU(ID_POSITION_TOP_ICONS, MyFrame::OnPositionTopIcons)
|
||||||
EVT_MENU(ID_POSITION_TOP_BOTH, MyFrame::OnPositionTopBoth)
|
EVT_MENU(ID_POSITION_TOP_BOTH, MyFrame::OnPositionTopBoth)
|
||||||
|
EVT_TOGGLEBUTTON(ID_TOGGLE_PANELS, MyFrame::OnTogglePanels)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
#include "align_center.xpm"
|
#include "align_center.xpm"
|
||||||
@@ -317,10 +324,14 @@ MyFrame::MyFrame()
|
|||||||
wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY |
|
wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY |
|
||||||
wxTE_LEFT | wxTE_BESTWRAP | wxBORDER_NONE);
|
wxTE_LEFT | wxTE_BESTWRAP | wxBORDER_NONE);
|
||||||
|
|
||||||
|
m_togglePanels = new wxToggleButton(this, ID_TOGGLE_PANELS, "&Toggle panels");
|
||||||
|
m_togglePanels->SetValue(true);
|
||||||
|
|
||||||
wxSizer *s = new wxBoxSizer(wxVERTICAL);
|
wxSizer *s = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
s->Add(m_ribbon, 0, wxEXPAND);
|
s->Add(m_ribbon, 0, wxEXPAND);
|
||||||
s->Add(m_logwindow, 1, wxEXPAND);
|
s->Add(m_logwindow, 1, wxEXPAND);
|
||||||
|
s->Add(m_togglePanels, wxSizerFlags().Border());
|
||||||
|
|
||||||
SetSizer(s);
|
SetSizer(s);
|
||||||
}
|
}
|
||||||
@@ -665,6 +676,11 @@ void MyFrame::OnPositionLeftDropdown(wxRibbonToolBarEvent& evt)
|
|||||||
evt.PopupMenu(&menu);
|
evt.PopupMenu(&menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnTogglePanels(wxCommandEvent& WXUNUSED(evt))
|
||||||
|
{
|
||||||
|
m_ribbon->ShowPanels(m_togglePanels->GetValue());
|
||||||
|
}
|
||||||
|
|
||||||
void MyFrame::AddText(wxString msg)
|
void MyFrame::AddText(wxString msg)
|
||||||
{
|
{
|
||||||
m_logwindow->AppendText(msg);
|
m_logwindow->AppendText(msg);
|
||||||
|
@@ -109,6 +109,14 @@ bool wxRibbonBar::DismissExpandedPanel()
|
|||||||
return m_pages.Item(m_current_page).page->DismissExpandedPanel();
|
return m_pages.Item(m_current_page).page->DismissExpandedPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxRibbonBar::ShowPanels(const bool show)
|
||||||
|
{
|
||||||
|
m_arePanelsShown = show;
|
||||||
|
SetMinSize(wxSize(GetSize().GetWidth(), DoGetBestSize().GetHeight()));
|
||||||
|
Realise();
|
||||||
|
GetParent()->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
void wxRibbonBar::SetWindowStyleFlag(long style)
|
void wxRibbonBar::SetWindowStyleFlag(long style)
|
||||||
{
|
{
|
||||||
m_flags = style;
|
m_flags = style;
|
||||||
@@ -538,6 +546,7 @@ wxRibbonBar::wxRibbonBar()
|
|||||||
m_tab_scroll_left_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
|
m_tab_scroll_left_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
|
||||||
m_tab_scroll_right_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
|
m_tab_scroll_right_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
|
||||||
m_tab_scroll_buttons_shown = false;
|
m_tab_scroll_buttons_shown = false;
|
||||||
|
m_arePanelsShown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxRibbonBar::wxRibbonBar(wxWindow* parent,
|
wxRibbonBar::wxRibbonBar(wxWindow* parent,
|
||||||
@@ -585,6 +594,7 @@ void wxRibbonBar::CommonInit(long style)
|
|||||||
m_tab_scroll_left_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
|
m_tab_scroll_left_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
|
||||||
m_tab_scroll_right_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
|
m_tab_scroll_right_button_state = wxRIBBON_SCROLL_BTN_NORMAL;
|
||||||
m_tab_scroll_buttons_shown = false;
|
m_tab_scroll_buttons_shown = false;
|
||||||
|
m_arePanelsShown = true;
|
||||||
|
|
||||||
if(m_art == NULL)
|
if(m_art == NULL)
|
||||||
{
|
{
|
||||||
@@ -946,7 +956,7 @@ void wxRibbonBar::RecalculateMinSize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_minWidth = min_size.GetWidth();
|
m_minWidth = min_size.GetWidth();
|
||||||
m_minHeight = min_size.GetHeight();
|
m_minHeight = m_arePanelsShown ? min_size.GetHeight() : m_tab_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxRibbonBar::DoGetBestSize() const
|
wxSize wxRibbonBar::DoGetBestSize() const
|
||||||
@@ -964,6 +974,10 @@ wxSize wxRibbonBar::DoGetBestSize() const
|
|||||||
{
|
{
|
||||||
best.IncBy(0, m_tab_height);
|
best.IncBy(0, m_tab_height);
|
||||||
}
|
}
|
||||||
|
if(!m_arePanelsShown)
|
||||||
|
{
|
||||||
|
best.SetHeight(m_tab_height);
|
||||||
|
}
|
||||||
return best;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user