include/vcl/prgsbar.hxx                |    3 
 vcl/UIConfig_vcl.mk                    |    3 
 vcl/inc/printdlg.hxx                   |   15 +---
 vcl/inc/svids.hrc                      |    4 -
 vcl/source/control/prgsbar.cxx         |    7 +-
 vcl/source/src/print.src               |   25 -------
 vcl/source/window/printdlg.cxx         |  108 +++++++--------------------------
 vcl/uiconfig/ui/printprogressdialog.ui |   87 ++++++++++++++++++++++++++
 8 files changed, 127 insertions(+), 125 deletions(-)

New commits:
commit 3e978fc21f2d924dab3d714956944a27e70d606f
Author: Caolán McNamara <caol...@redhat.com>
Date:   Mon Dec 23 19:25:30 2013 +0000

    convert print progress dialog to .ui
    
    use an actual ProgressBar rather than direct drawing
    into the dialog window
    
    Change-Id: I13a17970055980e0e248f60058cd4d5ef91f1d7d

diff --git a/vcl/UIConfig_vcl.mk b/vcl/UIConfig_vcl.mk
index d3e901e..d37c985 100644
--- a/vcl/UIConfig_vcl.mk
+++ b/vcl/UIConfig_vcl.mk
@@ -10,9 +10,10 @@
 $(eval $(call gb_UIConfig_UIConfig,vcl))
 
 $(eval $(call gb_UIConfig_add_uifiles,vcl,\
-       vcl/uiconfig/ui/printdialog \
        vcl/uiconfig/ui/errornocontentdialog \
        vcl/uiconfig/ui/errornoprinterdialog \
+       vcl/uiconfig/ui/printdialog \
+       vcl/uiconfig/ui/printprogressdialog \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx
index 3b07b6b..e142f0a 100644
--- a/vcl/inc/printdlg.hxx
+++ b/vcl/inc/printdlg.hxx
@@ -30,6 +30,7 @@
 #include "vcl/button.hxx"
 #include "vcl/gdimtf.hxx"
 #include "vcl/lstbox.hxx"
+#include "vcl/prgsbar.hxx"
 #include "vcl/field.hxx"
 #include "vcl/tabctrl.hxx"
 #include "vcl/tabpage.hxx"
@@ -271,29 +272,23 @@ namespace vcl
     class PrintProgressDialog : public ModelessDialog
     {
         OUString            maStr;
-        FixedText           maText;
-        CancelButton        maButton;
+        FixedText*          mpText;
+        ProgressBar*        mpProgress;
+        CancelButton*       mpButton;
 
         bool                mbCanceled;
         sal_Int32           mnCur;
         sal_Int32           mnMax;
-        long                mnProgressHeight;
-        Rectangle           maProgressRect;
-        bool                mbNativeProgress;
 
         DECL_LINK( ClickHdl, Button* );
 
-        void implCalcProgressRect();
     public:
-        PrintProgressDialog( Window* i_pParent, int i_nMax );
-        ~PrintProgressDialog();
+        PrintProgressDialog(Window* i_pParent, int i_nMax);
 
         bool isCanceled() const { return mbCanceled; }
         void setProgress( int i_nCurrent, int i_nMax = -1 );
         void tick();
         void reset();
-
-        virtual void Paint( const Rectangle& );
     };
 }
 
diff --git a/vcl/inc/svids.hrc b/vcl/inc/svids.hrc
index eb16740..f3c3f4d 100644
--- a/vcl/inc/svids.hrc
+++ b/vcl/inc/svids.hrc
@@ -115,10 +115,6 @@
 #define SV_PRINT_OPT_TOFILE                 2
 #define SV_PRINT_OPT_SINGLEJOBS             3
 
-#define SV_DLG_PRINT_PROGRESS             2049
-#define SV_PRINT_PROGRESS_CANCEL            1
-#define SV_PRINT_PROGRESS_TEXT              2
-
 #define SV_PRINT_NATIVE_STRINGS           2050
 
 #define SV_HELPTEXT_CLOSE                   10000
diff --git a/vcl/source/src/print.src b/vcl/source/src/print.src
index 0d2f9c1..4bfa750 100644
--- a/vcl/source/src/print.src
+++ b/vcl/source/src/print.src
@@ -19,31 +19,6 @@
 
 #include "svids.hrc"
 
-ModelessDialog SV_DLG_PRINT_PROGRESS
-{
-    HelpID = "vcl:ModelessDialog:SV_DLG_PRINT_PROGRESS";
-    Text [en-US] = "Printing";
-    Closeable = FALSE;
-    Sizeable = FALSE;
-    Moveable = TRUE;
-    SVLook = TRUE;
-
-    Size = MAP_APPFONT( 120, 70 );
-
-    CancelButton SV_PRINT_PROGRESS_CANCEL
-    {
-        Pos = MAP_APPFONT( 35, 50 );
-        Size = MAP_APPFONT( 50, 15 );
-    };
-    FixedText SV_PRINT_PROGRESS_TEXT
-    {
-        Pos = MAP_APPFONT( 5,10 );
-        Size = MAP_APPFONT( 110, 10 );
-        Text [ en-US ] = "Page %p of %n";
-        Center = TRUE;
-    };
-};
-
 StringArray SV_PRINT_NATIVE_STRINGS
 {
     ItemList [en-US] =
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index 21941ca..c44dee7 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -1842,63 +1842,46 @@ void PrintDialog::previewBackward()
 //
 // 
-----------------------------------------------------------------------------
 
-PrintProgressDialog::PrintProgressDialog( Window* i_pParent, int i_nMax ) :
-    ModelessDialog( i_pParent, VclResId( SV_DLG_PRINT_PROGRESS ) ),
-    maText( this, VclResId( SV_PRINT_PROGRESS_TEXT ) ),
-    maButton( this, VclResId( SV_PRINT_PROGRESS_CANCEL ) ),
-    mbCanceled( false ),
-    mnCur( 0 ),
-    mnMax( i_nMax ),
-    mnProgressHeight( 15 ),
-    mbNativeProgress( false )
-{
-    FreeResource();
+PrintProgressDialog::PrintProgressDialog(Window* i_pParent, int i_nMax)
+    : ModelessDialog(i_pParent, "PrintProgressDialog",
+        "vcl/ui/printprogressdialog.ui")
+    , mbCanceled(false)
+    , mnCur(0)
+    , mnMax(i_nMax)
+{
+    get(mpButton, "cancel");
+    get(mpProgress, "progressbar");
+    get(mpText, "label");
 
     if( mnMax < 1 )
         mnMax = 1;
 
-    maStr = maText.GetText();
+    maStr = mpText->GetText();
 
-    maButton.SetClickHdl( LINK( this, PrintProgressDialog, ClickHdl ) );
+    //just multiply largest value by 10 and take the width of that string as
+    //the max size we will want
+    OUString aNewText( searchAndReplace( maStr, "%p", 2, OUString::number( 
mnMax * 10 ) ) );
+    aNewText = searchAndReplace( aNewText, "%n", 2, OUString::number( mnMax * 
10 ) );
+    mpText->SetText( aNewText );
+    mpText->set_width_request(mpText->get_preferred_size().Width());
 
-}
+    //Pick a useful max width
+    mpProgress->set_width_request(mpProgress->LogicToPixel(Size(100, 0), 
MapMode(MAP_APPFONT)).Width());
+
+    mpButton->SetClickHdl( LINK( this, PrintProgressDialog, ClickHdl ) );
 
-PrintProgressDialog::~PrintProgressDialog()
-{
 }
 
 IMPL_LINK( PrintProgressDialog, ClickHdl, Button*, pButton )
 {
-    if( pButton == &maButton )
+    if( pButton == mpButton )
         mbCanceled = true;
 
     return 0;
 }
 
-void PrintProgressDialog::implCalcProgressRect()
-{
-    if( IsNativeControlSupported( CTRL_PROGRESS, PART_ENTIRE_CONTROL ) )
-    {
-        ImplControlValue aValue;
-        Rectangle aControlRegion( Point(), Size( 100, mnProgressHeight ) );
-        Rectangle aNativeControlRegion, aNativeContentRegion;
-        if( GetNativeControlRegion( CTRL_PROGRESS, PART_ENTIRE_CONTROL, 
aControlRegion,
-                                    CTRL_STATE_ENABLED, aValue, OUString(),
-                                    aNativeControlRegion, aNativeContentRegion 
) )
-        {
-            mnProgressHeight = aNativeControlRegion.GetHeight();
-        }
-        mbNativeProgress = true;
-    }
-    maProgressRect = Rectangle( Point( 10, maText.GetPosPixel().Y() + 
maText.GetSizePixel().Height() + 8 ),
-                                Size( GetSizePixel().Width() - 20, 
mnProgressHeight ) );
-}
-
 void PrintProgressDialog::setProgress( int i_nCurrent, int i_nMax )
 {
-    if( maProgressRect.IsEmpty() )
-        implCalcProgressRect();
-
     mnCur = i_nCurrent;
     if( i_nMax != -1 )
         mnMax = i_nMax;
@@ -1906,12 +1889,11 @@ void PrintProgressDialog::setProgress( int i_nCurrent, 
int i_nMax )
     if( mnMax < 1 )
         mnMax = 1;
 
+    mpProgress->SetValue(mnCur*100/mnMax);
+
     OUString aNewText( searchAndReplace( maStr, "%p", 2, OUString::number( 
mnCur ) ) );
     aNewText = searchAndReplace( aNewText, "%n", 2, OUString::number( mnMax ) 
);
-    maText.SetText( aNewText );
-
-    // update progress
-    Invalidate( maProgressRect, INVALIDATE_UPDATE );
+    mpText->SetText( aNewText );
 }
 
 void PrintProgressDialog::tick()
@@ -1926,44 +1908,4 @@ void PrintProgressDialog::reset()
     setProgress( 0 );
 }
 
-void PrintProgressDialog::Paint( const Rectangle& )
-{
-    if( maProgressRect.IsEmpty() )
-        implCalcProgressRect();
-
-    Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
-    const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
-    Color aPrgsColor = rStyleSettings.GetHighlightColor();
-    if ( aPrgsColor == rStyleSettings.GetFaceColor() )
-        aPrgsColor = rStyleSettings.GetDarkShadowColor();
-    SetLineColor();
-    SetFillColor( aPrgsColor );
-
-    const long nOffset = 3;
-    const long nWidth = 3*mnProgressHeight/2;
-    const long nFullWidth = nWidth + nOffset;
-    const long nMaxCount = maProgressRect.GetWidth() / nFullWidth;
-    DrawProgress( this, maProgressRect.TopLeft(),
-                        nOffset,
-                        nWidth,
-                        mnProgressHeight,
-                        static_cast<sal_uInt16>(0),
-                        static_cast<sal_uInt16>(10000*mnCur/mnMax),
-                        static_cast<sal_uInt16>(10000/nMaxCount),
-                        maProgressRect
-                        );
-    Pop();
-
-    if( ! mbNativeProgress )
-    {
-        DecorationView aDecoView( this );
-        Rectangle aFrameRect( maProgressRect );
-        aFrameRect.Left() -= nOffset;
-        aFrameRect.Right() += nOffset;
-        aFrameRect.Top() -= nOffset;
-        aFrameRect.Bottom() += nOffset;
-        aDecoView.DrawFrame( aFrameRect );
-    }
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/uiconfig/ui/printprogressdialog.ui 
b/vcl/uiconfig/ui/printprogressdialog.ui
new file mode 100644
index 0000000..508441d
--- /dev/null
+++ b/vcl/uiconfig/ui/printprogressdialog.ui
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkDialog" id="PrintProgressDialog">
+    <property name="can_focus">False</property>
+    <property name="border_width">6</property>
+    <property name="title" translatable="yes">Printing</property>
+    <property name="type_hint">dialog</property>
+    <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="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="cancel">
+                <property name="label">gtk-cancel</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</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="GtkGrid" id="grid1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="hexpand">True</property>
+            <property name="row_spacing">6</property>
+            <child>
+              <object class="GtkLabel" id="label">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Page %p of 
%n</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkProgressBar" id="progressbar">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="hexpand">True</property>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">1</property>
+                <property name="width">1</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="0">cancel</action-widget>
+    </action-widgets>
+  </object>
+</interface>
commit 3b80c1ac1351ae7f2bf102e23928cd64133de7b3
Author: Caolán McNamara <caol...@redhat.com>
Date:   Mon Dec 23 23:39:01 2013 +0000

    add a basic GetOptimalSize to progress bar
    
    Change-Id: I34b98d4c98b3f9af062473f254ffeadb05130471

diff --git a/include/vcl/prgsbar.hxx b/include/vcl/prgsbar.hxx
index cbe598c..03b1790 100644
--- a/include/vcl/prgsbar.hxx
+++ b/include/vcl/prgsbar.hxx
@@ -79,9 +79,10 @@ public:
     virtual void        Resize();
     virtual void        StateChanged( StateChangedType nStateChange );
     virtual void        DataChanged( const DataChangedEvent& rDCEvt );
+    virtual Size        GetOptimalSize() const;
 
     void                SetValue( sal_uInt16 nNewPercent );
-    sal_uInt16              GetValue() const { return mnPercent; }
+    sal_uInt16          GetValue() const { return mnPercent; }
 };
 
 #endif // INCLUDED_VCL_PRGSBAR_HXX
diff --git a/vcl/source/control/prgsbar.cxx b/vcl/source/control/prgsbar.cxx
index 000d821..4a46388 100644
--- a/vcl/source/control/prgsbar.cxx
+++ b/vcl/source/control/prgsbar.cxx
@@ -43,10 +43,15 @@ static WinBits clearProgressBarBorder( Window* pParent, 
WinBits nOrgStyle )
     return nOutStyle;
 }
 
+Size ProgressBar::GetOptimalSize() const
+{
+    return Size(150, 20);
+}
+
 ProgressBar::ProgressBar( Window* pParent, WinBits nWinStyle ) :
     Window( pParent, clearProgressBarBorder( pParent, nWinStyle ) )
 {
-    SetOutputSizePixel( Size( 150, 20 ) );
+    SetOutputSizePixel( GetOptimalSize() );
     ImplInit();
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to