1 // -*- mode: c++ -*-
2 //
3 // This file is part of libyacurs.
4 // Copyright (C) 2013  Rafael Ostertag
5 //
6 // This program is free software: you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License as
8 // published by the Free Software Foundation, either version 3 of the
9 // License, or (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // 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, see
18 // <http://www.gnu.org/licenses/>.
19 //
20 //
21 // $Id$
22 
23 #ifndef STATUSBAR_H
24 #define STATUSBAR_H 1
25 
26 #include <stack>
27 
28 #include "lineobject.h"
29 
30 namespace YACURS {
31 /**
32  * Status Line.
33  *
34  * Maintains a stack of messages, where the top most message will
35  * be displayed.
36  */
37 class StatusBar : public LineObject {
38    private:
39     std::stack<std::string> _messages;
40 
41     void show_top_msg();
42 
43    public:
44     StatusBar();
45 
46     StatusBar& operator=(const StatusBar&) = delete;
47     StatusBar& operator=(StatusBar&&) = delete;
48     StatusBar(const StatusBar&) = delete;
49     StatusBar(StatusBar&&) = delete;
50 
51     virtual ~StatusBar();
52     /**
53      * Push a message on the stack.
54      *
55      * Push a message on the stack. The message will be
56      * visible immediately.
57      *
58      * @param m message
59      */
60     void push(const std::string& m);
61 
62     /**
63      * Set the top most message.
64      *
65      * Set the top most message without growing the stack.
66      *
67      * @param m message
68      */
69     void set(const std::string& m);
70 
71     /**
72      * Remove the top most message.
73      *
74      * Remove the top most message from the stack and display
75      * the new top most message, if any.
76      */
77     void pop();
78 };
79 }  // namespace YACURS
80 
81 #endif
82