1 /* 2 * Copyright (c) 2012-2016, Bruno Levy 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * * Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above copyright notice, 11 * this list of conditions and the following disclaimer in the documentation 12 * and/or other materials provided with the distribution. 13 * * Neither the name of the ALICE Project-Team nor the names of its 14 * contributors may be used to endorse or promote products derived from this 15 * software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 * POSSIBILITY OF SUCH DAMAGE. 28 * 29 * If you modify this software, you should include a notice giving the 30 * name of the person performing the modification, the date of modification, 31 * and the reason for such modification. 32 * 33 * Contact: Bruno Levy 34 * 35 * Bruno.Levy@inria.fr 36 * http://www.loria.fr/~levy 37 * 38 * ALICE Project 39 * LORIA, INRIA Lorraine, 40 * Campus Scientifique, BP 239 41 * 54506 VANDOEUVRE LES NANCY CEDEX 42 * FRANCE 43 * 44 */ 45 46 #ifndef H_GEOGRAM_GFX_GUI_STATUS_BAR_H 47 #define H_GEOGRAM_GFX_GUI_STATUS_BAR_H 48 49 #include <geogram_gfx/basic/common.h> 50 #include <geogram/basic/progress.h> 51 52 /** 53 * \file geogram_gfx/gui/status_bar.h 54 * \brief Implementation of the status bar. 55 */ 56 57 namespace GEO { 58 59 /** 60 * \brief StatusBar displays the progress bar. 61 */ 62 class GEOGRAM_GFX_API StatusBar : public GEO::ProgressClient { 63 public: 64 65 /** 66 * \brief StatusBar constructor. 67 */ 68 StatusBar(); 69 70 /** 71 * \copydoc GEO::ProgressClient::begin() 72 */ 73 virtual void begin(); 74 75 /** 76 * \copydoc GEO::ProgressClient::progress() 77 */ 78 virtual void progress(GEO::index_t step, GEO::index_t percent); 79 80 /** 81 * \copydoc GEO::ProgressClient::end() 82 */ 83 virtual void end(bool canceled); 84 85 /** 86 * \brief Draws the status bar and handles the GUI. 87 */ 88 void draw(); 89 90 /** 91 * \brief Tests whether this status bar should be displayed. 92 * \details The status bar is displayed whenever there is an 93 * active progress bar. 94 */ active()95 bool active() const { 96 return (nb_active_ > 0); 97 } 98 99 /** 100 * \brief Redraws the GUI. 101 */ 102 virtual void update(); 103 104 /** 105 * \brief Gets the height of the status bar window. 106 * \return the height of the window. 107 * \details Needs to have drawn the window at least once, 108 * else it returns 0. 109 */ get_window_height()110 float get_window_height() const { 111 return height_; 112 } 113 114 private: 115 bool progress_; 116 index_t step_; 117 index_t percent_; 118 bool canceled_; 119 index_t nb_active_; 120 float height_; 121 }; 122 123 typedef SmartPointer<StatusBar> StatusBar_var; 124 } 125 126 #endif 127