diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-12-03 12:35:24 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-12-04 09:51:20 +0100 |
commit | 57d706b1d1f6d9c7797c816a30879c237a443c51 (patch) | |
tree | f8c1b131574596a6d75233d8359b51de6d2f40f1 /vcl | |
parent | 043c2f39bfd5f70885dede547cb3c3b78ed8c5b9 (diff) |
weld OfaSwAutoFmtOptionsPage
Change-Id: Ia88fe2562dd87b33fdec0081a3adf27c8d10f407
Reviewed-on: https://gerrit.libreoffice.org/64474
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/app/salvtables.cxx | 88 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 22 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 59 |
3 files changed, 156 insertions, 13 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 431ee544d32f..c47745b99dcf 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -1822,6 +1822,7 @@ private: // owner for UserData std::vector<std::unique_ptr<OUString>> m_aUserData; VclPtr<SvTabListBox> m_xTreeView; + SvLBoxButtonData m_aCheckButtonData; DECL_LINK(SelectHdl, SvTreeListBox*, void); DECL_LINK(DoubleClickHdl, SvTreeListBox*, bool); @@ -1832,6 +1833,7 @@ public: SalInstanceTreeView(SvTabListBox* pTreeView, bool bTakeOwnership) : SalInstanceContainer(pTreeView, bTakeOwnership) , m_xTreeView(pTreeView) + , m_aCheckButtonData(pTreeView) { m_xTreeView->SetNodeDefaultImages(); m_xTreeView->SetSelectHdl(LINK(this, SalInstanceTreeView, SelectHdl)); @@ -1875,7 +1877,7 @@ public: return OUString(); } - virtual void insert(weld::TreeIter* pParent, int pos, const OUString& rStr, const OUString* pId, + virtual void insert(weld::TreeIter* pParent, int pos, const OUString* pStr, const OUString* pId, const OUString* pIconName, VirtualDevice* pImageSurface, const OUString* pExpanderName, bool bChildrenOnDemand) override { @@ -1891,15 +1893,25 @@ public: else pUserData = nullptr; + bool bSimple = !pIconName && !pImageSurface && pStr; SvTreeListEntry* pResult; - if (!pIconName && !pImageSurface) - pResult = m_xTreeView->InsertEntry(rStr, iter, false, nInsertPos, pUserData); + if (bSimple) + pResult = m_xTreeView->InsertEntry(*pStr, iter, false, nInsertPos, pUserData); else { SvTreeListEntry* pEntry = new SvTreeListEntry; - Image aImage(pIconName ? createImage(*pIconName) : createImage(*pImageSurface)); - pEntry->AddItem(o3tl::make_unique<SvLBoxContextBmp>(aImage, aImage, false)); - pEntry->AddItem(o3tl::make_unique<SvLBoxString>(rStr)); + if (pIconName || pImageSurface) + { + Image aImage(pIconName ? createImage(*pIconName) : createImage(*pImageSurface)); + pEntry->AddItem(o3tl::make_unique<SvLBoxContextBmp>(aImage, aImage, false)); + } + else + { + Image aDummy; + pEntry->AddItem(o3tl::make_unique<SvLBoxContextBmp>(aDummy, aDummy, false)); + } + if (pStr) + pEntry->AddItem(o3tl::make_unique<SvLBoxString>(*pStr)); pEntry->SetUserData(pUserData); m_xTreeView->Insert(pEntry, iter, nInsertPos); pResult = pEntry; @@ -2058,9 +2070,15 @@ public: ++col; //skip dummy/expander column + // blank out missing entries + for (int i = pEntry->ItemCount(); i < col ; ++i) + pEntry->AddItem(o3tl::make_unique<SvLBoxString>("")); + if (static_cast<size_t>(col) == pEntry->ItemCount()) { pEntry->AddItem(o3tl::make_unique<SvLBoxString>(rText)); + SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pEntry); + m_xTreeView->InitViewData(pViewData, pEntry); } else { @@ -2072,6 +2090,57 @@ public: m_xTreeView->ModelHasEntryInvalidated(pEntry); } + virtual bool get_toggle(int pos, int col) const override + { + SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); + if (col == -1) + return m_xTreeView->GetCheckButtonState(pEntry) == SvButtonState::Checked; + + ++col; //skip dummy/expander column + + if (static_cast<size_t>(col) == pEntry->ItemCount()) + return false; + + assert(col >= 0 && static_cast<size_t>(col) < pEntry->ItemCount()); + SvLBoxItem& rItem = pEntry->GetItem(col); + assert(dynamic_cast<SvLBoxButton*>(&rItem)); + return static_cast<SvLBoxButton&>(rItem).IsStateChecked(); + } + + virtual void set_toggle(int pos, bool bOn, int col) override + { + SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); + if (col == -1) + { + m_xTreeView->SetCheckButtonState(pEntry, bOn ? SvButtonState::Checked : SvButtonState::Unchecked); + return; + } + + ++col; //skip dummy/expander column + + // blank out missing entries + for (int i = pEntry->ItemCount(); i < col ; ++i) + pEntry->AddItem(o3tl::make_unique<SvLBoxString>("")); + + if (static_cast<size_t>(col) == pEntry->ItemCount()) + { + pEntry->AddItem(o3tl::make_unique<SvLBoxButton>(SvLBoxButtonKind::EnabledCheckbox, + &m_aCheckButtonData)); + SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pEntry); + m_xTreeView->InitViewData(pViewData, pEntry); + } + + assert(col >= 0 && static_cast<size_t>(col) < pEntry->ItemCount()); + SvLBoxItem& rItem = pEntry->GetItem(col); + assert(dynamic_cast<SvLBoxButton*>(&rItem)); + if (bOn) + static_cast<SvLBoxButton&>(rItem).SetStateChecked(); + else + static_cast<SvLBoxButton&>(rItem).SetStateUnchecked(); + + m_xTreeView->ModelHasEntryInvalidated(pEntry); + } + const OUString* getEntryData(int index) const { SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, index); @@ -2086,6 +2155,13 @@ public: return *pRet; } + virtual void set_id(int pos, const OUString& rId) override + { + SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); + m_aUserData.emplace_back(o3tl::make_unique<OUString>(rId)); + pEntry->SetUserData(m_aUserData.back().get()); + } + virtual int get_selected_index() const override { assert(m_xTreeView->IsUpdateMode() && "don't request selection when frozen"); diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index c76abc3a1f1f..91f5cd915baa 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -1111,6 +1111,18 @@ namespace return sTooltipText; } + float extractAlignment(VclBuilder::stringmap &rMap) + { + float f = 0.0; + VclBuilder::stringmap::iterator aFind = rMap.find(OString("alignment")); + if (aFind != rMap.end()) + { + f = aFind->second.toFloat(); + rMap.erase(aFind); + } + return f; + } + OUString extractTitle(VclBuilder::stringmap &rMap) { OUString sTitle; @@ -1966,8 +1978,16 @@ VclPtr<vcl::Window> VclBuilder::makeObject(vcl::Window *pParent, const OString & if (HeaderBar* pHeaderBar = pTreeView ? pTreeView->GetHeaderBar() : nullptr) { OUString sTitle(extractTitle(rMap)); + HeaderBarItemBits nBits = (HeaderBarItemBits::LEFTIMAGE | HeaderBarItemBits::CLICKABLE); + float fAlign = extractAlignment(rMap); + if (fAlign == 0.0) + nBits |= HeaderBarItemBits::LEFT; + else if (fAlign == 1.0) + nBits |= HeaderBarItemBits::RIGHT; + else if (fAlign == 0.5) + nBits |= HeaderBarItemBits::CENTER; auto nItemId = pHeaderBar->GetItemCount() + 1; - pHeaderBar->InsertItem(nItemId, sTitle, 100); + pHeaderBar->InsertItem(nItemId, sTitle, 100, nBits); } } } diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 265cc49fd982..19ad71bfc4b4 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -4360,6 +4360,7 @@ private: GtkTreeStore* m_pTreeStore; std::unique_ptr<comphelper::string::NaturalStringSorter> m_xSorter; gint m_nTextCol; + gint m_nToggleCol; gint m_nImageCol; gint m_nExpanderImageCol; gint m_nIdCol; @@ -4388,11 +4389,11 @@ private: pThis->signal_row_activated(); } - void insert_row(GtkTreeIter& iter, GtkTreeIter* parent, int pos, const OUString* pId, const OUString& rText, + void insert_row(GtkTreeIter& iter, GtkTreeIter* parent, int pos, const OUString* pId, const OUString* pText, const OUString* pIconName, VirtualDevice* pDevice, const OUString* pExpanderName) { gtk_tree_store_insert_with_values(m_pTreeStore, &iter, parent, pos, - m_nTextCol, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(), + m_nTextCol, !pText ? nullptr : OUStringToOString(*pText, RTL_TEXTENCODING_UTF8).getStr(), m_nIdCol, !pId ? nullptr : OUStringToOString(*pId, RTL_TEXTENCODING_UTF8).getStr(), -1); if (pIconName) @@ -4445,6 +4446,18 @@ private: return sRet; } + bool get_bool(int pos, int col) const + { + gboolean bRet(false); + GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore); + GtkTreeIter iter; + if (gtk_tree_model_iter_nth_child(pModel, &iter, nullptr, pos)) + { + gtk_tree_model_get(pModel, &iter, col, &bRet, -1); + } + return bRet; + } + void set(int pos, int col, const OUString& rText) { GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore); @@ -4456,6 +4469,16 @@ private: } } + void set(int pos, int col, bool bOn) + { + GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore); + GtkTreeIter iter; + if (gtk_tree_model_iter_nth_child(pModel, &iter, nullptr, pos)) + { + gtk_tree_store_set(m_pTreeStore, &iter, col, bOn, -1); + } + } + static gboolean signalTestExpandRow(GtkTreeView*, GtkTreeIter* iter, GtkTreePath*, gpointer widget) { GtkInstanceTreeView* pThis = static_cast<GtkInstanceTreeView*>(widget); @@ -4488,7 +4511,8 @@ private: if (!bRet && bPlaceHolder) { GtkTreeIter subiter; - insert_row(subiter, &iter, -1, nullptr, "<dummy>", nullptr, nullptr, nullptr); + OUString sDummy("<dummy>"); + insert_row(subiter, &iter, -1, nullptr, &sDummy, nullptr, nullptr, nullptr); } return bRet; @@ -4500,6 +4524,7 @@ public: , m_pTreeView(pTreeView) , m_pTreeStore(GTK_TREE_STORE(gtk_tree_view_get_model(m_pTreeView))) , m_nTextCol(-1) + , m_nToggleCol(-1) , m_nImageCol(-1) , m_nExpanderImageCol(-1) , m_nChangedSignalId(g_signal_connect(gtk_tree_view_get_selection(pTreeView), "changed", @@ -4518,6 +4543,8 @@ public: GtkCellRenderer* pCellRenderer = GTK_CELL_RENDERER(pRenderer->data); if (m_nTextCol == -1 && GTK_IS_CELL_RENDERER_TEXT(pCellRenderer)) m_nTextCol = nIndex; + else if (m_nToggleCol == -1 && GTK_IS_CELL_RENDERER_TOGGLE(pCellRenderer)) + m_nToggleCol = nIndex; else if (GTK_IS_CELL_RENDERER_PIXBUF(pCellRenderer)) { const bool bExpander = g_list_next(pRenderer) != nullptr; @@ -4559,17 +4586,18 @@ public: return sRet; } - virtual void insert(weld::TreeIter* pParent, int pos, const OUString& rText, const OUString* pId, const OUString* pIconName, + virtual void insert(weld::TreeIter* pParent, int pos, const OUString* pText, const OUString* pId, const OUString* pIconName, VirtualDevice* pImageSurface, const OUString* pExpanderName, bool bChildrenOnDemand) override { disable_notify_events(); GtkTreeIter iter; GtkInstanceTreeIter* pGtkIter = static_cast<GtkInstanceTreeIter*>(pParent); - insert_row(iter, pGtkIter ? &pGtkIter->iter : nullptr, pos, pId, rText, pIconName, pImageSurface, pExpanderName); + insert_row(iter, pGtkIter ? &pGtkIter->iter : nullptr, pos, pId, pText, pIconName, pImageSurface, pExpanderName); if (bChildrenOnDemand) { GtkTreeIter subiter; - insert_row(subiter, &iter, -1, nullptr, "<dummy>", nullptr, nullptr, nullptr); + OUString sDummy("<dummy>"); + insert_row(subiter, &iter, -1, nullptr, &sDummy, nullptr, nullptr, nullptr); } enable_notify_events(); } @@ -4734,11 +4762,30 @@ public: return set(pos, col, rText); } + virtual bool get_toggle(int pos, int col) const override + { + if (col == -1) + return get_bool(pos, m_nToggleCol); + return get_bool(pos, col); + } + + virtual void set_toggle(int pos, bool bOn, int col) override + { + if (col == -1) + return set(pos, m_nToggleCol, bOn); + return set(pos, col, bOn); + } + virtual OUString get_id(int pos) const override { return get(pos, m_nIdCol); } + virtual void set_id(int pos, const OUString& rId) override + { + return set(pos, m_nIdCol, rId); + } + virtual int get_selected_index() const override { assert(gtk_tree_view_get_model(m_pTreeView) && "don't request selection when frozen"); |