1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <widgettestdlg.hxx>
11 #include <bitmaps.hlst>
13 WidgetTestDialog::WidgetTestDialog(weld::Window
* pParent
)
14 : GenericDialogController(pParent
, "cui/ui/widgettestdialog.ui", "WidgetTestDialog")
16 m_xOKButton
= m_xBuilder
->weld_button("ok_btn");
17 m_xCancelButton
= m_xBuilder
->weld_button("cancel_btn");
18 m_xTreeView
= m_xBuilder
->weld_tree_view("contenttree");
19 m_xTreeView2
= m_xBuilder
->weld_tree_view("contenttree2");
21 m_xOKButton
->connect_clicked(LINK(this, WidgetTestDialog
, OkHdl
));
22 m_xCancelButton
->connect_clicked(LINK(this, WidgetTestDialog
, CancelHdl
));
27 WidgetTestDialog::~WidgetTestDialog() {}
29 IMPL_LINK_NOARG(WidgetTestDialog
, OkHdl
, weld::Button
&, void) { m_xDialog
->response(RET_OK
); }
31 IMPL_LINK_NOARG(WidgetTestDialog
, CancelHdl
, weld::Button
&, void)
33 m_xDialog
->response(RET_CANCEL
);
36 void WidgetTestDialog::FillTreeView()
38 OUString
aImage1(RID_SVXBMP_CELL_LR
);
39 OUString
aImage2(RID_SVXBMP_SHADOW_BOT_LEFT
);
41 for (size_t nCount
= 0; nCount
< 4; nCount
++)
43 OUString sText
= OUString::Concat("Test ") + OUString::Concat(OUString::number(nCount
));
44 std::unique_ptr
<weld::TreeIter
> xEntry
= m_xTreeView
->make_iterator();
45 m_xTreeView
->insert(nullptr, -1, &sText
, &sText
, nullptr, nullptr, false, xEntry
.get());
46 m_xTreeView
->set_image(*xEntry
, (nCount
% 2 == 0) ? aImage1
: aImage2
);
48 m_xTreeView2
->append();
49 m_xTreeView2
->set_image(nCount
, (nCount
% 2 == 0) ? aImage1
: aImage2
);
50 m_xTreeView2
->set_text(nCount
, "First Column", 0);
51 m_xTreeView2
->set_text(
52 nCount
, OUString::Concat("Row ") + OUString::Concat(OUString::number(nCount
)), 1);
53 m_xTreeView2
->set_id(nCount
, OUString::number(nCount
));
57 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */