diff options
-rw-r--r-- | vcl/UIConfig_vcl.mk | 3 | ||||
-rw-r--r-- | vcl/inc/printdlg.hxx | 15 | ||||
-rw-r--r-- | vcl/inc/svids.hrc | 4 | ||||
-rw-r--r-- | vcl/source/src/print.src | 25 | ||||
-rw-r--r-- | vcl/source/window/printdlg.cxx | 108 | ||||
-rw-r--r-- | vcl/uiconfig/ui/printprogressdialog.ui | 87 |
6 files changed, 119 insertions, 123 deletions
diff --git a/vcl/UIConfig_vcl.mk b/vcl/UIConfig_vcl.mk index d3e901ea3ff5..d37c985dd8ff 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 3b07b6b38828..e142f0ab0101 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 eb16740cd38e..f3c3f4d43678 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 0d2f9c130a31..4bfa750bf9c4 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 21941cacb8ce..c44dee71a369 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 000000000000..508441d0ada8 --- /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> |