summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-12-10 11:32:51 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-12-12 13:01:28 +0100
commit6236051a3496278fe2768b40ebf1f4e82a44bb44 (patch)
treee2d83af4598ad8b13e4bda6f269acc4b7554c54f /vcl
parent3911bf8364dae4c855ad37237c114f9007f70657 (diff)
weld SwAddStylesDlg
Change-Id: I1dfdf0cea69585991bc0fa8dc38ebdf78abe97bf Reviewed-on: https://gerrit.libreoffice.org/64976 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.cxx75
-rw-r--r--vcl/source/treelist/svlbitm.cxx15
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx21
3 files changed, 78 insertions, 33 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index d4a2c3464171..3dad05c40df9 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -1825,17 +1825,19 @@ private:
std::vector<std::unique_ptr<OUString>> m_aUserData;
VclPtr<SvTabListBox> m_xTreeView;
SvLBoxButtonData m_aCheckButtonData;
+ SvLBoxButtonData m_aRadioButtonData;
DECL_LINK(SelectHdl, SvTreeListBox*, void);
DECL_LINK(DoubleClickHdl, SvTreeListBox*, bool);
DECL_LINK(ExpandingHdl, SvTreeListBox*, bool);
DECL_LINK(EndDragHdl, HeaderBar*, void);
-
+ DECL_LINK(ToggleHdl, SvLBoxButtonData*, void);
public:
SalInstanceTreeView(SvTabListBox* pTreeView, bool bTakeOwnership)
: SalInstanceContainer(pTreeView, bTakeOwnership)
, m_xTreeView(pTreeView)
- , m_aCheckButtonData(pTreeView)
+ , m_aCheckButtonData(pTreeView, false)
+ , m_aRadioButtonData(pTreeView, true)
{
m_xTreeView->SetNodeDefaultImages();
m_xTreeView->SetSelectHdl(LINK(this, SalInstanceTreeView, SelectHdl));
@@ -1850,6 +1852,7 @@ public:
pHeaderBar->SetItemSize(pHeaderBar->GetItemId(pHeaderBar->GetItemCount() - 1 ), HEADERBAR_FULLSIZE);
pHeaderBar->SetEndDragHdl(LINK(this, SalInstanceTreeView, EndDragHdl));
}
+ m_aRadioButtonData.SetLink(LINK(this, SalInstanceTreeView, ToggleHdl));
}
virtual void set_column_fixed_widths(const std::vector<int>& rWidths) override
@@ -1879,6 +1882,15 @@ public:
return OUString();
}
+ virtual void set_column_title(int nColumn, const OUString& rTitle) override
+ {
+ SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
+ if (HeaderBar* pHeaderBar = pHeaderBox ? pHeaderBox->GetHeaderBar() : nullptr)
+ {
+ return pHeaderBar->SetItemText(pHeaderBar->GetItemId(nColumn), rTitle);
+ }
+ }
+
virtual void show() override
{
SvHeaderTabListBox* pHeaderBox = dynamic_cast<SvHeaderTabListBox*>(m_xTreeView.get());
@@ -1915,40 +1927,32 @@ public:
else
pUserData = nullptr;
- bool bSimple = !pIconName && !pImageSurface && pStr;
- SvTreeListEntry* pResult;
- if (bSimple)
- pResult = m_xTreeView->InsertEntry(*pStr, iter, false, nInsertPos, pUserData);
+ SvTreeListEntry* pEntry = new SvTreeListEntry;
+ if (pIconName || pImageSurface)
+ {
+ Image aImage(pIconName ? createImage(*pIconName) : createImage(*pImageSurface));
+ pEntry->AddItem(o3tl::make_unique<SvLBoxContextBmp>(aImage, aImage, false));
+ }
else
{
- SvTreeListEntry* pEntry = new SvTreeListEntry;
- 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;
+ 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);
if (pExpanderName)
{
Image aImage(createImage(*pExpanderName));
- m_xTreeView->SetExpandedEntryBmp(pResult, aImage);
- m_xTreeView->SetCollapsedEntryBmp(pResult, aImage);
+ m_xTreeView->SetExpandedEntryBmp(pEntry, aImage);
+ m_xTreeView->SetCollapsedEntryBmp(pEntry, aImage);
}
if (bChildrenOnDemand)
{
- m_xTreeView->InsertEntry("<dummy>", pResult, false, 0, nullptr);
+ m_xTreeView->InsertEntry("<dummy>", pEntry, false, 0, nullptr);
}
}
@@ -2138,6 +2142,7 @@ public:
return;
}
+ bool bRadio = std::find(m_aRadioIndexes.begin(), m_aRadioIndexes.end(), col) != m_aRadioIndexes.end();
++col; //skip dummy/expander column
// blank out missing entries
@@ -2147,7 +2152,7 @@ public:
if (static_cast<size_t>(col) == pEntry->ItemCount())
{
pEntry->AddItem(o3tl::make_unique<SvLBoxButton>(SvLBoxButtonKind::EnabledCheckbox,
- &m_aCheckButtonData));
+ bRadio ? &m_aRadioButtonData : &m_aCheckButtonData));
SvViewDataEntry* pViewData = m_xTreeView->GetViewDataEntry(pEntry);
m_xTreeView->InitViewData(pViewData, pEntry);
}
@@ -2403,6 +2408,24 @@ public:
}
};
+IMPL_LINK(SalInstanceTreeView, ToggleHdl, SvLBoxButtonData*, pData, void)
+{
+ SvTreeListEntry* pEntry = pData->GetActEntry();
+ SvLBoxButton* pBox = pData->GetActBox();
+
+ for (int i = 1, nCount = pEntry->ItemCount(); i < nCount; ++i)
+ {
+ SvLBoxItem& rItem = pEntry->GetItem(i);
+ if (&rItem == pBox)
+ {
+ int nRow = m_xTreeView->GetAbsPos(pEntry);
+ int nCol = i - 1; // less dummy/expander column
+ signal_radio_toggled(std::make_pair(nRow, nCol));
+ break;
+ }
+ }
+}
+
IMPL_LINK_NOARG(SalInstanceTreeView, SelectHdl, SvTreeListBox*, void)
{
if (notify_events_disabled())
diff --git a/vcl/source/treelist/svlbitm.cxx b/vcl/source/treelist/svlbitm.cxx
index 530113c18177..7f45fdfa89b3 100644
--- a/vcl/source/treelist/svlbitm.cxx
+++ b/vcl/source/treelist/svlbitm.cxx
@@ -29,10 +29,11 @@
struct SvLBoxButtonData_Impl
{
SvTreeListEntry* pEntry;
+ SvLBoxButton* pBox;
bool bDefaultImages;
bool bShowRadioButton;
- SvLBoxButtonData_Impl() : pEntry( nullptr ), bDefaultImages( false ), bShowRadioButton( false ) {}
+ SvLBoxButtonData_Impl() : pEntry(nullptr), pBox(nullptr), bDefaultImages(false), bShowRadioButton(false) {}
};
void SvLBoxButtonData::InitData( bool _bRadioBtn, const Control* pCtrl )
@@ -97,10 +98,10 @@ void SvLBoxButtonData::SetWidthAndHeight()
bDataOk = true;
}
-
-void SvLBoxButtonData::StoreButtonState( SvTreeListEntry* pActEntry )
+void SvLBoxButtonData::StoreButtonState(SvTreeListEntry* pActEntry, SvLBoxButton* pActBox)
{
pImpl->pEntry = pActEntry;
+ pImpl->pBox = pActBox;
}
SvButtonState SvLBoxButtonData::ConvertToButtonState( SvItemStateFlags nItemFlags )
@@ -127,6 +128,12 @@ SvTreeListEntry* SvLBoxButtonData::GetActEntry() const
return pImpl->pEntry;
}
+SvLBoxButton* SvLBoxButtonData::GetActBox() const
+{
+ assert(pImpl && "-SvLBoxButtonData::GetActBox(): don't use me that way!");
+ return pImpl->pBox;
+}
+
void SvLBoxButtonData::SetDefaultImages( const Control* pCtrl )
{
const AllSettings& rSettings = pCtrl? pCtrl->GetSettings() : Application::GetSettings();
@@ -256,7 +263,7 @@ void SvLBoxButton::ClickHdl( SvTreeListEntry* pEntry )
SetStateUnchecked();
else
SetStateChecked();
- pData->StoreButtonState( pEntry );
+ pData->StoreButtonState(pEntry, this);
pData->CallLink();
}
}
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index d48b1883d820..ca4c8e989511 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -4899,7 +4899,7 @@ private:
pThis->signal_toggled(path, reinterpret_cast<sal_IntPtr>(pData));
}
- void signal_toggled(const gchar *path, int nIndex)
+ void signal_toggled(const gchar *path, int nCol)
{
GtkTreePath *tree_path = gtk_tree_path_new_from_string(path);
@@ -4908,9 +4908,15 @@ private:
gtk_tree_model_get_iter(pModel, &iter, tree_path);
gboolean bRet(false);
- gtk_tree_model_get(pModel, &iter, nIndex, &bRet, -1);
+ gtk_tree_model_get(pModel, &iter, nCol, &bRet, -1);
bRet = !bRet;
- gtk_tree_store_set(m_pTreeStore, &iter, nIndex, bRet, -1);
+ gtk_tree_store_set(m_pTreeStore, &iter, nCol, bRet, -1);
+
+ if (std::find(m_aRadioIndexes.begin(), m_aRadioIndexes.end(), nCol) != m_aRadioIndexes.end())
+ {
+ int nRow = gtk_tree_path_get_indices(tree_path)[0];
+ signal_radio_toggled(std::make_pair(nRow, nCol));
+ }
gtk_tree_path_free(tree_path);
}
@@ -4988,6 +4994,15 @@ public:
return sRet;
}
+ virtual void set_column_title(int nColumn, const OUString& rTitle) override
+ {
+ GList *pColumns = gtk_tree_view_get_columns(m_pTreeView);
+ GtkTreeViewColumn* pColumn = GTK_TREE_VIEW_COLUMN(g_list_nth_data(pColumns, nColumn));
+ assert(pColumn && "wrong count");
+ gtk_tree_view_column_set_title(pColumn, OUStringToOString(rTitle, RTL_TEXTENCODING_UTF8).getStr());
+ g_list_free(pColumns);
+ }
+
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
{