update dev300-m58
[ooovba.git] / padmin / source / progress.cxx
blob0179aad2acb3c30c22ccf6a048630648a2af1b3e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: progress.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include <ctype.h>
32 #include <stdio.h>
33 #include <tools/string.hxx>
34 #include <tools/stream.hxx>
35 #include <tools/list.hxx>
36 #include <vcl/msgbox.hxx>
37 #include <vcl/svapp.hxx>
38 #include <progress.hxx>
39 #include <helper.hxx>
40 #ifndef _PAD_PADIALOG_HRC_
41 #include <padialog.hrc>
42 #endif
44 using namespace padmin;
46 ProgressDialog::ProgressDialog( Window* pParent,
47 BOOL bCancelable,
48 int nMin, int nMax ) :
49 ModelessDialog( pParent, PaResId( RID_PROGRESS_DLG ) ),
50 maOperation( this, PaResId( RID_PROGRESS_OPERATION_TXT ) ),
51 maFilename( this, PaResId( RID_PROGRESS_FILENAME_TXT ) ),
52 maProgressTxt( this, PaResId( RID_PROGRESS_PROGRESS_TXT ) ),
53 maCancelButton( this, PaResId( RID_PROGRESS_BTN_CANCEL ) ),
54 maProgressBar( this, PaResId( RID_PROGRESS_STATUSBAR ) ),
55 mnMax( nMax ),
56 mnMin( nMin ),
57 mbCanceled( FALSE )
59 maFilename.SetStyle( maFilename.GetStyle() | WB_PATHELLIPSIS );
60 if( ! bCancelable )
62 Point aPos = maProgressBar.GetPosPixel();
63 Size aSize = maProgressBar.GetSizePixel();
64 Size aMySize = GetOutputSizePixel();
65 aMySize.Height() = aPos.Y() + aSize.Height() + 5;
66 SetOutputSizePixel( aMySize );
68 else
69 maCancelButton.SetClickHdl( LINK( this, ProgressDialog, ClickBtnHdl ) );
70 FreeResource();
73 ProgressDialog::~ProgressDialog()
77 void ProgressDialog::startOperation( const String& rOperation )
79 maOperation.SetText( rOperation );
80 maProgressBar.SetValue( 0 );
81 mbCanceled = FALSE;
82 if( ! IsVisible() )
83 Show( TRUE );
86 void ProgressDialog::setValue( int nValue )
88 maProgressBar.SetValue( nValue * 100 / ( mnMax - mnMin ) );
89 Application::Reschedule();
92 void ProgressDialog::setFilename( const String& rFilename )
94 maFilename.SetText( rFilename );
95 maFilename.Update();
96 Flush();
99 IMPL_LINK( ProgressDialog, ClickBtnHdl, Button*, pButton )
101 if( pButton == &maCancelButton )
103 mbCanceled = TRUE;
105 return 0;