1 /* pisa_progress_window.h -*- C++ -*- 2 Copyright (C) 2001, 2004 SEIKO EPSON Corporation 3 4 This file is part of the `iscan' program. 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 20 As a special exception, the copyright holders give permission 21 to link the code of this program with the esmod library and 22 distribute linked combinations including the two. You must obey 23 the GNU General Public License in all respects for all of the 24 code used other then esmod. 25 */ 26 27 #ifndef ___PISA_PROGRESS_WINDOW_H 28 #define ___PISA_PROGRESS_WINDOW_H 29 30 #ifdef HAVE_CONFIG_H 31 #include <config.h> 32 #endif 33 34 #include <gtk/gtk.h> 35 36 //! A progress feedback dialog 37 /*! A progress_window provides the user visual feedback about what is 38 going on. It has space for a short to medium length message at the 39 top, a progress indicator in the middle and a control button at the 40 the bottom of the window. 41 42 The message may be changed to anything at any convenient time, but 43 there are also several "canned" messages available. These messages 44 carry some additional logic with them as well. 45 46 The control button can be used to flag cancellation of the action(s) 47 that the dialog is reporting on. However, it is the responsibility 48 of the application to check for and honour such requests. 49 */ 50 class progress_window 51 { 52 public: 53 progress_window (GtkWidget *parent = 0); 54 ~progress_window (void); 55 56 //! Makes the progress window visible. 57 void show (void); 58 //! Makes the progress window invisible. 59 void hide (void); 60 61 //! Updates the progress indicator. 62 void set_progress (double progress, double estimated_total); 63 64 //! IDs for "canned" message texts. 65 enum message { 66 /*! This message can be shown whenever it takes a while before the 67 device is ready to carry out an action. Setting this message 68 will disable the control button because things like warming up 69 typically should not be interrupted. 70 */ 71 WARMING_UP, 72 /*! This message can be shown during a preview scan. The control 73 button is enabled during a preview. 74 */ 75 PREVIEWING, 76 /*! This message can be shown during a normal scan. Just as with 77 a preview scan, the control button is enabled. 78 */ 79 SCANNING, 80 /*! This message can be shown when the application is waiting for 81 the user to press a scanner button. The control button will be 82 enabled. Note that it may labelled differently from the other 83 cases. 84 */ 85 WAITING 86 }; 87 88 //! Updates the message indicating the stage of progress. 89 void set_text (const char *message); 90 //! Sets a "canned" message indicating the stage of progress. 91 void set_text (message id); 92 93 //! Indicates whether the user requested cancellation. 94 bool is_cancelled (void) const; 95 96 //! Flags a cancellation request. 97 void cancel (void); 98 99 private: 100 //! Changes the text on the control button. 101 void flip_label (GtkWidget *from, GtkWidget *to); 102 103 private: 104 GtkDialog *_box; 105 GtkLabel *_txt; //!< message area 106 GtkProgress *_bar; //!< progress indicator 107 GtkButton *_btn; //!< control button 108 GtkWidget *_btn_cancel; 109 GtkWidget *_btn_finish; 110 111 int _msg; 112 bool _can; 113 }; 114 115 #endif // ___PISA_PROGRESS_WINDOW_H 116