bump product version to 4.1.6.2
[LibreOffice.git] / padmin / source / progress.cxx
bloba87a3d0c70a3f27df8e5d487779b5abf5c8744e7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <ctype.h>
21 #include <stdio.h>
22 #include <tools/string.hxx>
23 #include <tools/stream.hxx>
24 #include <vcl/msgbox.hxx>
25 #include <vcl/svapp.hxx>
26 #include <progress.hxx>
27 #include <helper.hxx>
28 #include <padialog.hrc>
30 using namespace padmin;
32 ProgressDialog::ProgressDialog( Window* pParent,
33 sal_Bool bCancelable,
34 int nMin, int nMax ) :
35 ModelessDialog( pParent, PaResId( RID_PROGRESS_DLG ) ),
36 maOperation( this, PaResId( RID_PROGRESS_OPERATION_TXT ) ),
37 maFilename( this, PaResId( RID_PROGRESS_FILENAME_TXT ) ),
38 maProgressTxt( this, PaResId( RID_PROGRESS_PROGRESS_TXT ) ),
39 maCancelButton( this, PaResId( RID_PROGRESS_BTN_CANCEL ) ),
40 maProgressBar( this, PaResId( RID_PROGRESS_STATUSBAR ) ),
41 mnMax( nMax ),
42 mnMin( nMin ),
43 mbCanceled( false )
45 maFilename.SetStyle( maFilename.GetStyle() | WB_PATHELLIPSIS );
46 if( ! bCancelable )
48 Point aPos = maProgressBar.GetPosPixel();
49 Size aSize = maProgressBar.GetSizePixel();
50 Size aMySize = GetOutputSizePixel();
51 aMySize.Height() = aPos.Y() + aSize.Height() + 5;
52 SetOutputSizePixel( aMySize );
54 else
55 maCancelButton.SetClickHdl( LINK( this, ProgressDialog, ClickBtnHdl ) );
56 FreeResource();
59 ProgressDialog::~ProgressDialog()
63 void ProgressDialog::startOperation( const String& rOperation )
65 maOperation.SetText( rOperation );
66 maProgressBar.SetValue( 0 );
67 mbCanceled = false;
68 if( ! IsVisible() )
69 Show( sal_True );
72 void ProgressDialog::setValue( int nValue )
74 maProgressBar.SetValue( nValue * 100 / ( mnMax - mnMin ) );
75 Application::Reschedule();
78 void ProgressDialog::setFilename( const String& rFilename )
80 maFilename.SetText( rFilename );
81 maFilename.Update();
82 Flush();
85 IMPL_LINK( ProgressDialog, ClickBtnHdl, Button*, pButton )
87 if( pButton == &maCancelButton )
89 mbCanceled = true;
91 return 0;
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */