Kaydet (Commit) 3e978fc2 authored tarafından Caolán McNamara's avatar Caolán McNamara

convert print progress dialog to .ui

use an actual ProgressBar rather than direct drawing
into the dialog window

Change-Id: I13a17970055980e0e248f60058cd4d5ef91f1d7d
üst 3b80c1ac
......@@ -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:
......@@ -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& );
};
}
......
......@@ -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
......
......@@ -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] =
......
......@@ -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: */
<?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>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment