cui/inc/widgettestdlg.hxx            |   10 +
 cui/source/dialogs/widgettestdlg.cxx |   39 +++++-
 cui/uiconfig/ui/widgettestdialog.ui  |  200 +++++++++++++++++++++++++++++++----
 vcl/source/treelist/svtabbx.cxx      |   10 +
 4 files changed, 226 insertions(+), 33 deletions(-)

New commits:
commit df530f84f451765c4f2a6aabc9b40e327e35e1e5
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Thu Dec 15 13:59:15 2022 +0100
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Wed Jan 4 06:27:50 2023 +0000

    jsdialog: add TreeView to TestWidgetDialog
    
    Change-Id: I5c4f70d98dd8ea03c137cd368a2c097cd866609d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144222
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Rashesh Padia <rashesh.pa...@collabora.com>
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>

diff --git a/cui/inc/widgettestdlg.hxx b/cui/inc/widgettestdlg.hxx
index 15a480d7119d..02ab7f317894 100644
--- a/cui/inc/widgettestdlg.hxx
+++ b/cui/inc/widgettestdlg.hxx
@@ -9,7 +9,7 @@
 
 #pragma once
 
-#include "tools/link.hxx"
+#include <tools/link.hxx>
 #include <vcl/weld.hxx>
 #include <vcl/weldutils.hxx>
 
@@ -18,13 +18,15 @@ class WidgetTestDialog final : public 
weld::GenericDialogController
 private:
     std::unique_ptr<weld::Button> m_xOKButton;
     std::unique_ptr<weld::Button> m_xCancelButton;
+    std::unique_ptr<weld::TreeView> m_xTreeView;
+    std::unique_ptr<weld::TreeView> m_xTreeView2;
 
     DECL_LINK(OkHdl, weld::Button&, void);
     DECL_LINK(CancelHdl, weld::Button&, void);
 
+    void FillTreeView();
+
 public:
-    WidgetTestDialog(weld::Window *pParent);
+    WidgetTestDialog(weld::Window* pParent);
     ~WidgetTestDialog();
 };
-
-
diff --git a/cui/source/dialogs/widgettestdlg.cxx 
b/cui/source/dialogs/widgettestdlg.cxx
index 891d3f542438..0fa6abe49390 100644
--- a/cui/source/dialogs/widgettestdlg.cxx
+++ b/cui/source/dialogs/widgettestdlg.cxx
@@ -8,29 +8,50 @@
 */
 
 #include <widgettestdlg.hxx>
+#include <bitmaps.hlst>
 
-WidgetTestDialog::WidgetTestDialog(weld::Window *pParent)
-      : GenericDialogController(pParent, "cui/ui/widgettestdialog.ui", 
"WidgetTestDialog")
+WidgetTestDialog::WidgetTestDialog(weld::Window* pParent)
+    : GenericDialogController(pParent, "cui/ui/widgettestdialog.ui", 
"WidgetTestDialog")
 {
     m_xOKButton = m_xBuilder->weld_button("ok_btn");
     m_xCancelButton = m_xBuilder->weld_button("cancel_btn");
+    m_xTreeView = m_xBuilder->weld_tree_view("contenttree");
+    m_xTreeView2 = m_xBuilder->weld_tree_view("contenttree2");
 
     m_xOKButton->connect_clicked(LINK(this, WidgetTestDialog, OkHdl));
     m_xCancelButton->connect_clicked(LINK(this, WidgetTestDialog, CancelHdl));
-}
 
-WidgetTestDialog::~WidgetTestDialog()
-{
+    FillTreeView();
 }
 
-IMPL_LINK_NOARG(WidgetTestDialog, OkHdl, weld::Button&, void)
-{
-    m_xDialog->response(RET_OK);
-}
+WidgetTestDialog::~WidgetTestDialog() {}
+
+IMPL_LINK_NOARG(WidgetTestDialog, OkHdl, weld::Button&, void) { 
m_xDialog->response(RET_OK); }
 
 IMPL_LINK_NOARG(WidgetTestDialog, CancelHdl, weld::Button&, void)
 {
     m_xDialog->response(RET_CANCEL);
 }
 
+void WidgetTestDialog::FillTreeView()
+{
+    OUString aImage1(RID_SVXBMP_CELL_LR);
+    OUString aImage2(RID_SVXBMP_SHADOW_BOT_LEFT);
+
+    for (size_t nCount = 0; nCount < 4; nCount++)
+    {
+        OUString sText = OUString("Test ") + 
OUString::Concat(OUString::number(nCount));
+        std::unique_ptr<weld::TreeIter> xEntry = m_xTreeView->make_iterator();
+        m_xTreeView->insert(nullptr, -1, &sText, &sText, nullptr, nullptr, 
false, xEntry.get());
+        m_xTreeView->set_image(*xEntry, (nCount % 2 == 0) ? aImage1 : aImage2);
+
+        m_xTreeView2->append();
+        m_xTreeView2->set_image(nCount, (nCount % 2 == 0) ? aImage1 : aImage2);
+        m_xTreeView2->set_text(nCount, "First Column", 0);
+        m_xTreeView2->set_text(nCount,
+                               OUString("Row ") + 
OUString::Concat(OUString::number(nCount)), 1);
+        m_xTreeView2->set_id(nCount, OUString::number(nCount));
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/uiconfig/ui/widgettestdialog.ui 
b/cui/uiconfig/ui/widgettestdialog.ui
index 787deda37171..4f4b3cfc23b9 100644
--- a/cui/uiconfig/ui/widgettestdialog.ui
+++ b/cui/uiconfig/ui/widgettestdialog.ui
@@ -8,11 +8,8 @@
     <property name="type-hint">dialog</property>
     <child internal-child="vbox">
       <object class="GtkBox">
-        <property name="visible">True</property>
-        <property name="can-focus">False</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">5</property>
-        <child internal-child="action_area">
+      <property name="orientation">vertical</property>
+      <child internal-child="action_area">
           <object class="GtkButtonBox">
             <property name="can-focus">False</property>
             <property name="layout-style">end</property>
@@ -46,9 +43,16 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">False</property>
-            <property name="position">0</property>
+            <property name="position">1</property>
           </packing>
         </child>
+      <child>
+      <!-- n-columns=2 n-rows=2 -->
+      <object class="GtkGrid">
+        <property name="visible">True</property>
+        <property name="can-focus">False</property>
+        <property name="row-spacing">5</property>
+        <property name="column-spacing">5</property>
         <child>
           <!-- n-columns=2 n-rows=7 -->
           <object class="GtkGrid">
@@ -286,18 +290,8 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkSeparator">
-            <property name="visible">True</property>
-            <property name="can-focus">False</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
+            <property name="left-attach">0</property>
+            <property name="top-attach">0</property>
           </packing>
         </child>
         <child>
@@ -455,11 +449,151 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">2</property>
+            <property name="left-attach">0</property>
+            <property name="top-attach">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="contentbox">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkScrolledWindow">
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="hexpand">True</property>
+                <property name="vexpand">True</property>
+                <property name="shadow-type">in</property>
+                <child>
+                  <object class="GtkTreeView" id="contenttree">
+                    <property name="width-request">-1</property>
+                    <property name="visible">True</property>
+                    <property name="can-focus">True</property>
+                    <property name="receives-default">True</property>
+                    <property name="has-tooltip">True</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                    <property name="model">liststore2</property>
+                    <property name="headers-visible">False</property>
+                    <property name="reorderable">True</property>
+                    <property name="search-column">1</property>
+                    <property name="enable-tree-lines">True</property>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn0">
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkCellRendererPixbuf" 
id="cellrendererpixbuf0"/>
+                          <attributes>
+                            <attribute name="sensitive">4</attribute>
+                            <attribute name="pixbuf">0</attribute>
+                          </attributes>
+                        </child>
+                        <child>
+                          <object class="GtkCellRendererText" 
id="cellrenderertext0">
+                            <property name="xalign">0</property>
+                          </object>
+                          <attributes>
+                            <attribute name="xpad">5</attribute>
+                            <attribute name="sensitive">4</attribute>
+                            <attribute name="text">1</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="left-attach">1</property>
+            <property name="top-attach">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="contentbox2">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkScrolledWindow">
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="hexpand">True</property>
+                <property name="vexpand">True</property>
+                <property name="shadow-type">in</property>
+                <child>
+                  <object class="GtkTreeView" id="contenttree2">
+                    <property name="width-request">-1</property>
+                    <property name="visible">True</property>
+                    <property name="can-focus">True</property>
+                    <property name="receives-default">True</property>
+                    <property name="has-tooltip">True</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                    <property name="model">liststore3</property>
+                    <property name="headers-visible">True</property>
+                    <property name="reorderable">True</property>
+                    <property name="search-column">1</property>
+                    <property name="enable-tree-lines">True</property>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+                        <property name="resizable">True</property>
+                        <property name="spacing">6</property>
+                        <property name="title" translatable="no">Column 
1</property>
+                        <child>
+                          <object class="GtkCellRendererText" 
id="cellrenderer1"/>
+                          <attributes>
+                            <attribute name="text">0</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+                        <property name="resizable">True</property>
+                        <property name="spacing">6</property>
+                        <property name="title" translatable="no">Column 
2</property>
+                        <child>
+                          <object class="GtkCellRendererText" 
id="cellrenderer2"/>
+                          <attributes>
+                            <attribute name="text">1</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="left-attach">1</property>
+            <property name="top-attach">1</property>
           </packing>
         </child>
       </object>
     </child>
+    </object>
+    <packing>
+      <property name="position">0</property>
+    </packing>
+    </child>
   </object>
   <object class="GtkTextBuffer" id="textbuffer1">
     <property name="text" translatable="no">Lorem Ipsum is simply dummy text 
of the printing and typesetting industry. Lorem Ipsum has been the industry's 
standard dummy tex
@@ -471,7 +605,7 @@ t ever since the 1500s, when an unknown printer took a 
galley of type and scramb
  Ipsum passages, and more recently with desktop publishing
  software like Aldus PageMaker including versions of Lorem Ipsum.</property>
   </object>
-    <object class="GtkListStore" id="liststore1">
+  <object class="GtkListStore" id="liststore1">
     <columns>
       <!-- column-name gchararray1 -->
       <column type="gchararray"/>
@@ -494,4 +628,30 @@ t ever since the 1500s, when an unknown printer took a 
galley of type and scramb
       </row>
     </data>
   </object>
+  <object class="GtkTreeStore" id="liststore2">
+    <columns>
+      <!-- column-name expander -->
+      <column type="GdkPixbuf"/>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+      <!-- column-name weight -->
+      <column type="gint"/>
+      <!-- column-name sensitive -->
+      <column type="gboolean"/>
+      <!-- column-name extraindent -->
+      <column type="gint"/>
+    </columns>
+  </object>
+    <object class="GtkTreeStore" id="liststore3">
+    <columns>
+      <!-- column-name text -->
+      <column type="gchararray"/>
+      <!-- column-name text1 -->
+      <column type="gchararray"/>
+      <!-- column-name id -->
+      <column type="gchararray"/>
+    </columns>
+  </object>
 </interface>
commit 49b3ef3cfc352762606ca495a67c50f69474f895
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Thu Dec 15 14:22:37 2022 +0100
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Wed Jan 4 06:27:40 2023 +0000

    jsdialog: dump stock images id in TreeView
    
    Change-Id: I11342e1d7963a7e4d1ef139f504fc44dd6c89d90
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144223
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Rashesh Padia <rashesh.pa...@collabora.com>
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>

diff --git a/vcl/source/treelist/svtabbx.cxx b/vcl/source/treelist/svtabbx.cxx
index 1b4721af0bda..9d989eb8382d 100644
--- a/vcl/source/treelist/svtabbx.cxx
+++ b/vcl/source/treelist/svtabbx.cxx
@@ -70,6 +70,16 @@ static void lcl_DumpEntryAndSiblings(tools::JsonWriter& 
rJsonWriter,
                         rJsonWriter.put("text", pStringItem->GetText());
                     }
                 }
+                else if (rItem.GetType() == SvLBoxItemType::ContextBmp)
+                {
+                    const SvLBoxContextBmp* pBmpItem = dynamic_cast<const 
SvLBoxContextBmp*>(&rItem);
+                    if (pBmpItem)
+                    {
+                        auto aColumn = rJsonWriter.startStruct();
+                        rJsonWriter.put("collapsed", 
pBmpItem->GetBitmap1().GetStock());
+                        rJsonWriter.put("expanded", 
pBmpItem->GetBitmap2().GetStock());
+                    }
+                }
             }
         }
 

Reply via email to