[Libreoffice-commits] core.git: extensions/inc extensions/source extensions/uiconfig extras/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Jul 25 07:28:33 UTC 2019


 extensions/inc/bitmaps.hlst                    |    1 
 extensions/source/scanner/grid.cxx             |  107 ++++++++------------
 extensions/source/scanner/grid.hxx             |   26 +----
 extensions/source/scanner/sanedlg.cxx          |   10 -
 extensions/uiconfig/scanner/ui/griddialog.ui   |  129 +++++++++++++++----------
 extras/source/glade/libreoffice-catalog.xml.in |    4 
 6 files changed, 142 insertions(+), 135 deletions(-)

New commits:
commit f696e535872e76f0854d475354fed11fbce4bb54
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Jul 24 14:36:45 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Jul 25 09:27:48 2019 +0200

    weld GridWindow
    
    Change-Id: I3281abffbc7f14cb3ebcc80b4f52b52ed5efa781
    Reviewed-on: https://gerrit.libreoffice.org/76268
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/extensions/inc/bitmaps.hlst b/extensions/inc/bitmaps.hlst
index c8b48c245ab7..60a388e0c7b4 100644
--- a/extensions/inc/bitmaps.hlst
+++ b/extensions/inc/bitmaps.hlst
@@ -40,6 +40,7 @@
 #define RID_EXTBMP_NAVIGATIONBAR            "res/sx10607.png"
 #define RID_UPDATE_AVAILABLE_16             "extensions/res/update/ui/onlineupdate_16.png"
 #define RID_UPDATE_AVAILABLE_26             "extensions/res/update/ui/onlineupdate_26.png"
+#define RID_SCANNER_HANDLE                  "extensions/res/scanner/handle.png"
 #define BMP_TABLE                           "res/sx03188.png"
 #define BMP_QUERY                           "res/sx03202.png"
 #define RID_EXTBMP_AUTOFILTER_SC            "res/sc10716.png"
diff --git a/extensions/source/scanner/grid.cxx b/extensions/source/scanner/grid.cxx
index 08d7cf57e130..89ea65898d01 100644
--- a/extensions/source/scanner/grid.cxx
+++ b/extensions/source/scanner/grid.cxx
@@ -23,17 +23,21 @@
 #include <math.h>
 #include <boost/math/special_functions/expm1.hpp>
 
+#include <bitmaps.hlst>
 #include <cmath>
 
 #include "grid.hxx"
-#include <vcl/builderfactory.hxx>
+#include <vcl/bitmapex.hxx>
+#include <vcl/customweld.hxx>
 #include <vcl/event.hxx>
+#include <vcl/settings.hxx>
+#include <vcl/svapp.hxx>
 
 #include <algorithm>
 #include <limits>
 #include <memory>
 
-class GridWindow : public vcl::Window
+class GridWindow : public weld::CustomWidgetController
 {
     // helper class for handles
     struct impHandle
@@ -58,7 +62,7 @@ class GridWindow : public vcl::Window
             rRenderContext.DrawBitmapEx(maPos - aOffset, rBitmapEx);
         }
 
-        bool isHit(vcl::Window const & rWin, const Point& rPos)
+        bool isHit(OutputDevice const & rWin, const Point& rPos)
         {
             const Point aOffset(rWin.PixelToLogic(Point(mnOffX, mnOffY)));
             const tools::Rectangle aTarget(maPos - aOffset, maPos + aOffset);
@@ -114,18 +118,17 @@ class GridWindow : public vcl::Window
     void computeNew();
     static double interpolate( double x, double const * pNodeX, double const * pNodeY, int nNodes );
 
-    virtual void MouseMove( const MouseEvent& ) override;
-    virtual void MouseButtonDown( const MouseEvent& ) override;
-    virtual void MouseButtonUp( const MouseEvent& ) override;
+    virtual bool MouseMove( const MouseEvent& ) override;
+    virtual bool MouseButtonDown( const MouseEvent& ) override;
+    virtual bool MouseButtonUp( const MouseEvent& ) override;
     void onResize();
     virtual void Resize() override;
-    virtual Size GetOptimalSize() const override;
+    virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
     void drawLine(vcl::RenderContext& rRenderContext, double x1, double y1, double x2, double y2);
 public:
-    explicit GridWindow(vcl::Window* pParent);
+    GridWindow();
     void Init(double* pXValues, double* pYValues, int nValues, bool bCutValues, const BitmapEx &rMarkerBitmap);
     virtual ~GridWindow() override;
-    virtual void dispose() override;
 
     void setBoundings( double fMinX, double fMinY, double fMaxX, double fMaxY );
 
@@ -136,9 +139,8 @@ public:
     virtual void Paint( vcl::RenderContext& /*rRenderContext*/, const tools::Rectangle& rRect ) override;
 };
 
-GridWindow::GridWindow(vcl::Window* pParent)
-    : Window(pParent, 0)
-    , m_aGridArea(50, 15, 100, 100)
+GridWindow::GridWindow()
+    : m_aGridArea(50, 15, 100, 100)
     , m_fMinX(0.0)
     , m_fMinY(0.0)
     , m_fMaxX(0.0)
@@ -156,7 +158,6 @@ GridWindow::GridWindow(vcl::Window* pParent)
     , m_aHandles()
     , m_nDragIndex(npos)
 {
-    SetMapMode(MapMode(MapUnit::MapPixel));
 }
 
 void GridWindow::Init(double* pXValues, double* pYValues, int nValues, bool bCutValues, const BitmapEx &rMarkerBitmap)
@@ -167,7 +168,6 @@ void GridWindow::Init(double* pXValues, double* pYValues, int nValues, bool bCut
     m_nValues = nValues;
     m_bCutValues = bCutValues;
 
-    SetSizePixel(GetOptimalSize());
     onResize();
 
     if (m_pOrigYValues && m_nValues)
@@ -193,53 +193,39 @@ void GridWindow::Resize()
 
 void GridWindow::onResize()
 {
-    Size aSize = GetSizePixel();
+    Size aSize = GetOutputSizePixel();
     m_aGridArea.setWidth( aSize.Width() - 80 );
     m_aGridArea.setHeight( aSize.Height() - 40 );
 }
 
-Size GridWindow::GetOptimalSize() const
+void GridWindow::SetDrawingArea(weld::DrawingArea* pDrawingArea)
 {
-    return LogicToPixel(Size(240, 200), MapMode(MapUnit::MapAppFont));
+    Size aSize(pDrawingArea->get_ref_device().LogicToPixel(Size(240, 200), MapMode(MapUnit::MapAppFont)));
+    pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
+    CustomWidgetController::SetDrawingArea(pDrawingArea);
+    SetOutputSizePixel(aSize);
 }
 
-GridDialog::GridDialog(double* pXValues, double* pYValues, int nValues, vcl::Window* pParent )
-    : ModalDialog(pParent, "GridDialog", "modules/scanner/ui/griddialog.ui")
+GridDialog::GridDialog(weld::Window* pParent, double* pXValues, double* pYValues, int nValues)
+    : GenericDialogController(pParent, "modules/scanner/ui/griddialog.ui", "GridDialog")
+    , m_xOKButton(m_xBuilder->weld_button("ok"))
+    , m_xResetTypeBox(m_xBuilder->weld_combo_box("resetTypeCombobox"))
+    , m_xResetButton(m_xBuilder->weld_button("resetButton"))
+    , m_xGridWindow(new GridWindow)
+    , m_xGridWindowWND(new weld::CustomWeld(*m_xBuilder, "gridwindow", *m_xGridWindow))
 {
-    get(m_pOKButton, "ok");
-    get(m_pResetTypeBox, "resetTypeCombobox");
-    get(m_pResetButton, "resetButton");
-    get(m_pGridWindow, "gridwindow");
-    m_pGridWindow->Init(pXValues, pYValues, nValues, true/*bCutValues*/, get<FixedImage>("handle")->GetImage().GetBitmapEx());
-
-    m_pResetTypeBox->SelectEntryPos( 0 );
-
-    m_pResetButton->SetClickHdl( LINK( this, GridDialog, ClickButtonHdl ) );
+    m_xGridWindow->Init(pXValues, pYValues, nValues, true/*bCutValues*/, BitmapEx(RID_SCANNER_HANDLE));
+    m_xResetTypeBox->set_active(0);
+    m_xResetButton->connect_clicked( LINK( this, GridDialog, ClickButtonHdl ) );
 }
 
 GridDialog::~GridDialog()
 {
-    disposeOnce();
-}
-
-void GridDialog::dispose()
-{
-    m_pOKButton.clear();
-    m_pResetTypeBox.clear();
-    m_pResetButton.clear();
-    m_pGridWindow.clear();
-    ModalDialog::dispose();
 }
 
 GridWindow::~GridWindow()
 {
-    disposeOnce();
-}
-
-void GridWindow::dispose()
-{
     m_pNewYValues.reset();
-    vcl::Window::dispose();
 }
 
 double GridWindow::findMinX()
@@ -438,7 +424,7 @@ double GridWindow::interpolate(
 
 void GridDialog::setBoundings(double fMinX, double fMinY, double fMaxX, double fMaxY)
 {
-    m_pGridWindow->setBoundings(fMinX, fMinY, fMaxX, fMaxY);
+    m_xGridWindow->setBoundings(fMinX, fMinY, fMaxX, fMaxY);
 }
 
 void GridWindow::setBoundings(double fMinX, double fMinY, double fMaxX, double fMaxY)
@@ -528,16 +514,16 @@ void GridWindow::drawHandles(vcl::RenderContext& rRenderContext)
     }
 }
 
-void GridWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
+void GridWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
 {
-    Window::Paint(rRenderContext, rRect);
+    rRenderContext.SetBackground(Wallpaper(Application::GetSettings().GetStyleSettings().GetDialogColor()));
     drawGrid(rRenderContext);
     drawOriginal(rRenderContext);
     drawNew(rRenderContext);
     drawHandles(rRenderContext);
 }
 
-void GridWindow::MouseMove( const MouseEvent& rEvt )
+bool GridWindow::MouseMove( const MouseEvent& rEvt )
 {
     if( rEvt.GetButtons() == MOUSE_LEFT && m_nDragIndex != npos )
     {
@@ -567,10 +553,10 @@ void GridWindow::MouseMove( const MouseEvent& rEvt )
         }
     }
 
-    Window::MouseMove( rEvt );
+    return false;
 }
 
-void GridWindow::MouseButtonUp( const MouseEvent& rEvt )
+bool GridWindow::MouseButtonUp( const MouseEvent& rEvt )
 {
     if( rEvt.GetButtons() == MOUSE_LEFT )
     {
@@ -582,17 +568,17 @@ void GridWindow::MouseButtonUp( const MouseEvent& rEvt )
         }
     }
 
-    Window::MouseButtonUp( rEvt );
+    return false;
 }
 
-void GridWindow::MouseButtonDown( const MouseEvent& rEvt )
+bool GridWindow::MouseButtonDown( const MouseEvent& rEvt )
 {
     Point aPoint( rEvt.GetPosPixel() );
     Handles::size_type nMarkerIndex = npos;
 
     for(Handles::size_type a(0); nMarkerIndex == npos && a < m_aHandles.size(); a++)
     {
-        if(m_aHandles[a].isHit(*this, aPoint))
+        if(m_aHandles[a].isHit(GetDrawingArea()->get_ref_device(), aPoint))
         {
             nMarkerIndex = a;
         }
@@ -631,7 +617,7 @@ void GridWindow::MouseButtonDown( const MouseEvent& rEvt )
         Invalidate(m_aGridArea);
     }
 
-    Window::MouseButtonDown( rEvt );
+    return false;
 }
 
 void GridWindow::ChangeMode(ResetType nType)
@@ -702,20 +688,15 @@ void GridWindow::ChangeMode(ResetType nType)
     Invalidate();
 }
 
-IMPL_LINK( GridDialog, ClickButtonHdl, Button*, pButton, void )
+IMPL_LINK_NOARG(GridDialog, ClickButtonHdl, weld::Button&, void)
 {
-    if (pButton == m_pResetButton)
-    {
-        int nType = m_pResetTypeBox->GetSelectedEntryPos();
-        m_pGridWindow->ChangeMode(static_cast<ResetType>(nType));
-    }
+    int nType = m_xResetTypeBox->get_active();
+    m_xGridWindow->ChangeMode(static_cast<ResetType>(nType));
 }
 
 double* GridDialog::getNewYValues()
 {
-    return m_pGridWindow->getNewYValues();
+    return m_xGridWindow->getNewYValues();
 }
 
-VCL_BUILDER_FACTORY(GridWindow)
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/scanner/grid.hxx b/extensions/source/scanner/grid.hxx
index 57e1106c7d16..51345cca5917 100644
--- a/extensions/source/scanner/grid.hxx
+++ b/extensions/source/scanner/grid.hxx
@@ -19,11 +19,8 @@
 #ifndef INCLUDED_EXTENSIONS_SOURCE_SCANNER_GRID_HXX
 #define INCLUDED_EXTENSIONS_SOURCE_SCANNER_GRID_HXX
 
-#include <vcl/window.hxx>
-#include <vcl/button.hxx>
-#include <vcl/lstbox.hxx>
-#include <vcl/dialog.hxx>
-#include <vcl/fixed.hxx>
+#include <vcl/customweld.hxx>
+#include <vcl/weld.hxx>
 
 class GridWindow;
 
@@ -35,22 +32,19 @@ enum class ResetType
     EXPONENTIAL = 3
 };
 
-class GridDialog : public ModalDialog
+class GridDialog : public weld::GenericDialogController
 {
-    VclPtr<OKButton>       m_pOKButton;
+    std::unique_ptr<weld::Button> m_xOKButton;
+    std::unique_ptr<weld::ComboBox> m_xResetTypeBox;
+    std::unique_ptr<weld::Button> m_xResetButton;
+    std::unique_ptr<GridWindow>     m_xGridWindow;
+    std::unique_ptr<weld::CustomWeld> m_xGridWindowWND;
 
-    VclPtr<ListBox>        m_pResetTypeBox;
-    VclPtr<PushButton>     m_pResetButton;
-
-    VclPtr<GridWindow>     m_pGridWindow;
-
-    DECL_LINK( ClickButtonHdl, Button*, void );
+    DECL_LINK( ClickButtonHdl, weld::Button&, void );
 
 public:
-    GridDialog(double* pXValues, double* pYValues, int nValues,
-                vcl::Window* pParent);
+    GridDialog(weld::Window* pParent, double* pXValues, double* pYValues, int nValues);
     virtual ~GridDialog() override;
-    virtual void dispose() override;
     void setBoundings(double fMinX, double fMinY, double fMaxX, double fMaxY);
     double* getNewYValues();
 };
diff --git a/extensions/source/scanner/sanedlg.cxx b/extensions/source/scanner/sanedlg.cxx
index 0a7bdb2565c3..7b5ecf722547 100644
--- a/extensions/source/scanner/sanedlg.cxx
+++ b/extensions/source/scanner/sanedlg.cxx
@@ -642,11 +642,11 @@ IMPL_LINK( SaneDlg, ClickBtnHdl, Button*, pButton, void )
                         x[ i ] = static_cast<double>(i);
                     mrSane.GetOptionValue( mnCurrentOption, y.get() );
 
-                    ScopedVclPtrInstance< GridDialog > aGrid( x.get(), y.get(), nElements, this );
-                    aGrid->SetText( mrSane.GetOptionName( mnCurrentOption ) );
-                    aGrid->setBoundings( 0, mfMin, nElements, mfMax );
-                    if( aGrid->Execute() && aGrid->getNewYValues() )
-                        mrSane.SetOptionValue( mnCurrentOption, aGrid->getNewYValues() );
+                    GridDialog aGrid(GetFrameWeld(), x.get(), y.get(), nElements);
+                    aGrid.set_title( mrSane.GetOptionName( mnCurrentOption ) );
+                    aGrid.setBoundings( 0, mfMin, nElements, mfMax );
+                    if (aGrid.run() && aGrid.getNewYValues())
+                        mrSane.SetOptionValue( mnCurrentOption, aGrid.getNewYValues() );
                 }
                 break;
                 case SANE_TYPE_BOOL:
diff --git a/extensions/uiconfig/scanner/ui/griddialog.ui b/extensions/uiconfig/scanner/ui/griddialog.ui
index 641e511db458..2a7e49555651 100644
--- a/extensions/uiconfig/scanner/ui/griddialog.ui
+++ b/extensions/uiconfig/scanner/ui/griddialog.ui
@@ -1,21 +1,26 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.1 -->
+<!-- Generated with glade 3.22.1 -->
 <interface domain="pcr">
   <requires lib="gtk+" version="3.18"/>
-  <requires lib="LibreOffice" version="1.0"/>
   <object class="GtkDialog" id="GridDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
+    <property name="modal">True</property>
+    <property name="default_width">0</property>
+    <property name="default_height">0</property>
     <property name="type_hint">dialog</property>
+    <child>
+      <placeholder/>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox1">
         <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
         <property name="spacing">12</property>
         <child internal-child="action_area">
           <object class="GtkButtonBox" id="dialog-action_area1">
             <property name="can_focus">False</property>
-            <property name="orientation">vertical</property>
-            <property name="layout_style">start</property>
+            <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="ok">
                 <property name="label">gtk-ok</property>
@@ -46,69 +51,100 @@
                 <property name="position">1</property>
               </packing>
             </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">True</property>
+            <property name="vexpand">True</property>
+            <property name="spacing">12</property>
             <child>
-              <object class="GtkComboBoxText" id="resetTypeCombobox">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <items>
-                  <item translatable="yes" context="griddialog|resetTypeCombobox">Linear ascending</item>
-                  <item translatable="yes" context="griddialog|resetTypeCombobox">Linear descending</item>
-                  <item translatable="yes" context="griddialog|resetTypeCombobox">Original values</item>
-                  <item translatable="yes" context="griddialog|resetTypeCombobox">Exponential increasing</item>
-                </items>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="resetButton">
-                <property name="label" translatable="yes" context="griddialog|resetButton">_Set</property>
+              <object class="GtkScrolledWindow">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
+                <property name="hexpand">True</property>
+                <property name="vexpand">True</property>
+                <property name="hscrollbar_policy">never</property>
+                <property name="vscrollbar_policy">never</property>
+                <property name="shadow_type">in</property>
+                <child>
+                  <object class="GtkViewport">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkDrawingArea" id="gridwindow">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
+                        <property name="hexpand">True</property>
+                        <property name="vexpand">True</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
               </object>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
-                <property name="position">3</property>
+                <property name="position">0</property>
               </packing>
             </child>
             <child>
-              <object class="GtkImage" id="handle">
+              <object class="GtkBox">
+                <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="no_show_all">True</property>
-                <property name="pixbuf">extensions/res/scanner/handle.png</property>
+                <property name="orientation">vertical</property>
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkComboBoxText" id="resetTypeCombobox">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <items>
+                      <item translatable="yes" context="griddialog|resetTypeCombobox">Linear ascending</item>
+                      <item translatable="yes" context="griddialog|resetTypeCombobox">Linear descending</item>
+                      <item translatable="yes" context="griddialog|resetTypeCombobox">Original values</item>
+                      <item translatable="yes" context="griddialog|resetTypeCombobox">Exponential increasing</item>
+                    </items>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="resetButton">
+                    <property name="label" translatable="yes" context="griddialog|resetButton">_Set</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="use_underline">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">3</property>
+                  </packing>
+                </child>
               </object>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">True</property>
-                <property name="position">4</property>
+                <property name="position">1</property>
               </packing>
             </child>
           </object>
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="scnlo-GridWindow" id="gridwindow">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="halign">center</property>
-            <property name="valign">start</property>
-            <property name="hexpand">True</property>
-            <property name="vexpand">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
             <property name="position">1</property>
           </packing>
         </child>
@@ -117,7 +153,6 @@
     <action-widgets>
       <action-widget response="-5">ok</action-widget>
       <action-widget response="-6">cancel</action-widget>
-      <action-widget response="101">resetButton</action-widget>
     </action-widgets>
   </object>
 </interface>
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index cafdd7a258b1..d6fe9714a76e 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -121,10 +121,6 @@
                         generic-name="Scan Preview Window" parent="GtkDrawingArea"
                         icon-name="widget-gtk-drawingarea"/>
 
-    <glade-widget-class title="Gamma Grid" name="scnlo-GridWindow"
-                        generic-name="Gamma Grid Widget" parent="GtkDrawingArea"
-                        icon-name="widget-gtk-drawingarea"/>
-
     <glade-widget-class title="Mark Preview" name="swuilo-SwMarkPreview"
                         generic-name="Mark Preview Window" parent="GtkDrawingArea"
                         icon-name="widget-gtk-drawingarea"/>


More information about the Libreoffice-commits mailing list