Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
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>
29 :
30 : using namespace padmin;
31 :
32 0 : 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 0 : mbCanceled( false )
44 : {
45 0 : maFilename.SetStyle( maFilename.GetStyle() | WB_PATHELLIPSIS );
46 0 : if( ! bCancelable )
47 : {
48 0 : Point aPos = maProgressBar.GetPosPixel();
49 0 : Size aSize = maProgressBar.GetSizePixel();
50 0 : Size aMySize = GetOutputSizePixel();
51 0 : aMySize.Height() = aPos.Y() + aSize.Height() + 5;
52 0 : SetOutputSizePixel( aMySize );
53 : }
54 : else
55 0 : maCancelButton.SetClickHdl( LINK( this, ProgressDialog, ClickBtnHdl ) );
56 0 : FreeResource();
57 0 : }
58 :
59 0 : ProgressDialog::~ProgressDialog()
60 : {
61 0 : }
62 :
63 0 : void ProgressDialog::startOperation( const String& rOperation )
64 : {
65 0 : maOperation.SetText( rOperation );
66 0 : maProgressBar.SetValue( 0 );
67 0 : mbCanceled = false;
68 0 : if( ! IsVisible() )
69 0 : Show( sal_True );
70 0 : }
71 :
72 0 : void ProgressDialog::setValue( int nValue )
73 : {
74 0 : maProgressBar.SetValue( nValue * 100 / ( mnMax - mnMin ) );
75 0 : Application::Reschedule();
76 0 : }
77 :
78 0 : void ProgressDialog::setFilename( const String& rFilename )
79 : {
80 0 : maFilename.SetText( rFilename );
81 0 : maFilename.Update();
82 0 : Flush();
83 0 : }
84 :
85 0 : IMPL_LINK( ProgressDialog, ClickBtnHdl, Button*, pButton )
86 : {
87 0 : if( pButton == &maCancelButton )
88 : {
89 0 : mbCanceled = true;
90 : }
91 0 : return 0;
92 : }
93 :
94 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|