diff options
-rw-r--r-- | vcl/inc/salvtables.hxx | 43 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 181 |
2 files changed, 128 insertions, 96 deletions
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index 505720629a5e..09186972a3ab 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -31,6 +31,7 @@ #include "calendar.hxx" #include "iconview.hxx" #include "messagedialog.hxx" +#include "verticaltabctrl.hxx" namespace vcl { @@ -2250,4 +2251,46 @@ public: virtual ~SalInstanceFormattedSpinButton() override; }; +class SalInstanceVerticalNotebook : public SalInstanceWidget, public virtual weld::Notebook +{ +private: + VclPtr<VerticalTabControl> m_xNotebook; + mutable std::vector<std::unique_ptr<SalInstanceContainer>> m_aPages; + + DECL_LINK(DeactivatePageHdl, VerticalTabControl*, bool); + DECL_LINK(ActivatePageHdl, VerticalTabControl*, void); + +public: + SalInstanceVerticalNotebook(VerticalTabControl* pNotebook, SalInstanceBuilder* pBuilder, + bool bTakeOwnership); + + virtual int get_current_page() const override; + + virtual OUString get_page_ident(int nPage) const override; + + virtual OUString get_current_page_ident() const override; + + virtual int get_page_index(const OUString& rIdent) const override; + + virtual weld::Container* get_page(const OUString& rIdent) const override; + + virtual void set_current_page(int nPage) override; + + virtual void set_current_page(const OUString& rIdent) override; + + virtual void remove_page(const OUString& rIdent) override; + + virtual void insert_page(const OUString& rIdent, const OUString& rLabel, int nPos) override; + + virtual int get_n_pages() const override; + + virtual void set_tab_label_text(const OUString& rIdent, const OUString& rText) override; + + virtual OUString get_tab_label_text(const OUString& rIdent) const override; + + virtual void set_show_tabs(bool /*bShow*/) override; + + virtual ~SalInstanceVerticalNotebook() override; +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 780c6baae79e..1ace1412ffdc 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -78,7 +78,6 @@ #include <bitmaps.hlst> #include <listbox.hxx> #include <menutogglebutton.hxx> -#include <verticaltabctrl.hxx> #include <window.h> #include <wizdlg.hxx> #include <salvtables.hxx> @@ -2734,120 +2733,110 @@ IMPL_LINK_NOARG(SalInstanceNotebook, ActivatePageHdl, TabControl*, void) m_aEnterPageHdl.Call(get_current_page_ident()); } -namespace -{ -class SalInstanceVerticalNotebook : public SalInstanceWidget, public virtual weld::Notebook +SalInstanceVerticalNotebook::SalInstanceVerticalNotebook(VerticalTabControl* pNotebook, + SalInstanceBuilder* pBuilder, + bool bTakeOwnership) + : SalInstanceWidget(pNotebook, pBuilder, bTakeOwnership) + , m_xNotebook(pNotebook) { -private: - VclPtr<VerticalTabControl> m_xNotebook; - mutable std::vector<std::unique_ptr<SalInstanceContainer>> m_aPages; + m_xNotebook->SetActivatePageHdl(LINK(this, SalInstanceVerticalNotebook, ActivatePageHdl)); + m_xNotebook->SetDeactivatePageHdl(LINK(this, SalInstanceVerticalNotebook, DeactivatePageHdl)); +} - DECL_LINK(DeactivatePageHdl, VerticalTabControl*, bool); - DECL_LINK(ActivatePageHdl, VerticalTabControl*, void); +int SalInstanceVerticalNotebook::get_current_page() const +{ + return m_xNotebook->GetPagePos(m_xNotebook->GetCurPageId()); +} -public: - SalInstanceVerticalNotebook(VerticalTabControl* pNotebook, SalInstanceBuilder* pBuilder, - bool bTakeOwnership) - : SalInstanceWidget(pNotebook, pBuilder, bTakeOwnership) - , m_xNotebook(pNotebook) - { - m_xNotebook->SetActivatePageHdl(LINK(this, SalInstanceVerticalNotebook, ActivatePageHdl)); - m_xNotebook->SetDeactivatePageHdl( - LINK(this, SalInstanceVerticalNotebook, DeactivatePageHdl)); - } +OUString SalInstanceVerticalNotebook::get_page_ident(int nPage) const +{ + return m_xNotebook->GetPageId(nPage); +} - virtual int get_current_page() const override - { - return m_xNotebook->GetPagePos(m_xNotebook->GetCurPageId()); - } +OUString SalInstanceVerticalNotebook::get_current_page_ident() const +{ + return m_xNotebook->GetCurPageId(); +} - virtual OUString get_page_ident(int nPage) const override - { - return m_xNotebook->GetPageId(nPage); - } +int SalInstanceVerticalNotebook::get_page_index(const OUString& rIdent) const +{ + sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(rIdent); + if (nPageIndex == TAB_PAGE_NOTFOUND) + return -1; + return nPageIndex; +} - virtual OUString get_current_page_ident() const override { return m_xNotebook->GetCurPageId(); } +weld::Container* SalInstanceVerticalNotebook::get_page(const OUString& rIdent) const +{ + int nPageIndex = get_page_index(rIdent); + if (nPageIndex == -1) + return nullptr; + auto pChild = m_xNotebook->GetPage(rIdent); + if (m_aPages.size() < nPageIndex + 1U) + m_aPages.resize(nPageIndex + 1U); + if (!m_aPages[nPageIndex]) + m_aPages[nPageIndex].reset(new SalInstanceContainer(pChild, m_pBuilder, false)); + return m_aPages[nPageIndex].get(); +} - virtual int get_page_index(const OUString& rIdent) const override - { - sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(rIdent); - if (nPageIndex == TAB_PAGE_NOTFOUND) - return -1; - return nPageIndex; - } +void SalInstanceVerticalNotebook::set_current_page(int nPage) +{ + m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(nPage)); +} - virtual weld::Container* get_page(const OUString& rIdent) const override - { - int nPageIndex = get_page_index(rIdent); - if (nPageIndex == -1) - return nullptr; - auto pChild = m_xNotebook->GetPage(rIdent); - if (m_aPages.size() < nPageIndex + 1U) - m_aPages.resize(nPageIndex + 1U); - if (!m_aPages[nPageIndex]) - m_aPages[nPageIndex].reset(new SalInstanceContainer(pChild, m_pBuilder, false)); - return m_aPages[nPageIndex].get(); - } +void SalInstanceVerticalNotebook::set_current_page(const OUString& rIdent) +{ + m_xNotebook->SetCurPageId(rIdent); +} - virtual void set_current_page(int nPage) override - { - m_xNotebook->SetCurPageId(m_xNotebook->GetPageId(nPage)); - } +void SalInstanceVerticalNotebook::remove_page(const OUString& rIdent) +{ + sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(rIdent); + if (nPageIndex == TAB_PAGE_NOTFOUND) + return; + m_xNotebook->RemovePage(rIdent); + if (nPageIndex < m_aPages.size()) + m_aPages.erase(m_aPages.begin() + nPageIndex); +} - virtual void set_current_page(const OUString& rIdent) override - { - m_xNotebook->SetCurPageId(rIdent); - } +void SalInstanceVerticalNotebook::insert_page(const OUString& rIdent, const OUString& rLabel, + int nPos) +{ + VclPtrInstance<VclGrid> xGrid(m_xNotebook->GetPageParent()); + xGrid->set_hexpand(true); + xGrid->set_vexpand(true); + m_xNotebook->InsertPage(rIdent, rLabel, Image(), "", xGrid, nPos); - virtual void remove_page(const OUString& rIdent) override + if (nPos != -1) { - sal_uInt16 nPageIndex = m_xNotebook->GetPagePos(rIdent); - if (nPageIndex == TAB_PAGE_NOTFOUND) - return; - m_xNotebook->RemovePage(rIdent); + unsigned int nPageIndex = static_cast<unsigned int>(nPos); if (nPageIndex < m_aPages.size()) - m_aPages.erase(m_aPages.begin() + nPageIndex); - } - - virtual void insert_page(const OUString& rIdent, const OUString& rLabel, int nPos) override - { - VclPtrInstance<VclGrid> xGrid(m_xNotebook->GetPageParent()); - xGrid->set_hexpand(true); - xGrid->set_vexpand(true); - m_xNotebook->InsertPage(rIdent, rLabel, Image(), "", xGrid, nPos); - - if (nPos != -1) - { - unsigned int nPageIndex = static_cast<unsigned int>(nPos); - if (nPageIndex < m_aPages.size()) - m_aPages.insert(m_aPages.begin() + nPageIndex, nullptr); - } + m_aPages.insert(m_aPages.begin() + nPageIndex, nullptr); } +} - virtual int get_n_pages() const override { return m_xNotebook->GetPageCount(); } +int SalInstanceVerticalNotebook::get_n_pages() const { return m_xNotebook->GetPageCount(); } - virtual void set_tab_label_text(const OUString& rIdent, const OUString& rText) override - { - return m_xNotebook->SetPageText(rIdent, rText); - } +void SalInstanceVerticalNotebook::set_tab_label_text(const OUString& rIdent, const OUString& rText) +{ + return m_xNotebook->SetPageText(rIdent, rText); +} - virtual OUString get_tab_label_text(const OUString& rIdent) const override - { - return m_xNotebook->GetPageText(rIdent); - } +OUString SalInstanceVerticalNotebook::get_tab_label_text(const OUString& rIdent) const +{ + return m_xNotebook->GetPageText(rIdent); +} - virtual void set_show_tabs(bool /*bShow*/) override - { - // if someone needs this they will have to implement it in VerticalTabControl - assert(false && "not implemented"); - } +void SalInstanceVerticalNotebook::set_show_tabs(bool /*bShow*/) +{ + // if someone needs this they will have to implement it in VerticalTabControl + assert(false && "not implemented"); +} - virtual ~SalInstanceVerticalNotebook() override - { - m_xNotebook->SetActivatePageHdl(Link<VerticalTabControl*, void>()); - m_xNotebook->SetDeactivatePageHdl(Link<VerticalTabControl*, bool>()); - } -}; +SalInstanceVerticalNotebook::~SalInstanceVerticalNotebook() +{ + m_xNotebook->SetActivatePageHdl(Link<VerticalTabControl*, void>()); + m_xNotebook->SetDeactivatePageHdl(Link<VerticalTabControl*, bool>()); } IMPL_LINK_NOARG(SalInstanceVerticalNotebook, DeactivatePageHdl, VerticalTabControl*, bool) |