ncmpc  0.31
TextPage.hxx
Go to the documentation of this file.
1 /* ncmpc (Ncurses MPD Client)
2  * (c) 2004-2018 The Music Player Daemon Project
3  * Project homepage: http://musicpd.org
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef TEXT_PAGE_HXX
21 #define TEXT_PAGE_HXX
22 
23 #include "ListPage.hxx"
24 #include "ListText.hxx"
25 
26 #include <vector>
27 #include <string>
28 
29 struct mpdclient;
30 class ScreenManager;
31 
32 class TextPage : public ListPage, ListText {
33 protected:
35 
36  std::vector<std::string> lines;
37 
38 public:
40  WINDOW *w, Size size)
41  :ListPage(w, size), screen(_screen) {
42  lw.hide_cursor = true;
43  }
44 
45 protected:
46  bool IsEmpty() const {
47  return lines.empty();
48  }
49 
50  void Clear();
51 
52  void Append(const char *str);
53 
54  void Set(const char *str) {
55  Clear();
56  Append(str);
57  }
58 
62  void Repaint() {
63  Paint();
64  wrefresh(lw.w);
65  }
66 
67 public:
68  /* virtual methods from class Page */
69  void Paint() const override;
70  bool OnCommand(struct mpdclient &c, Command cmd) override;
71 
72 private:
73  /* virtual methods from class ListText */
74  const char *GetListItemText(char *buffer, size_t size,
75  unsigned i) const override;
76 };
77 
78 #endif
Command
Definition: Command.hxx:29
Definition: TextPage.hxx:32
Definition: screen.hxx:44
Definition: ListPage.hxx:29
WINDOW * w
Definition: ListWindow.hxx:87
void Set(const char *str)
Definition: TextPage.hxx:54
TextPage(ScreenManager &_screen, WINDOW *w, Size size)
Definition: TextPage.hxx:39
ListWindow lw
Definition: ListPage.hxx:31
bool hide_cursor
Definition: ListWindow.hxx:108
bool IsEmpty() const
Definition: TextPage.hxx:46
Definition: mpdclient.hxx:17
ScreenManager & screen
Definition: TextPage.hxx:34
Definition: Size.hxx:26
std::vector< std::string > lines
Definition: TextPage.hxx:36
void Clear()
void Append(const char *str)
Definition: ListText.hxx:25
bool OnCommand(struct mpdclient &c, Command cmd) override
void Repaint()
Definition: TextPage.hxx:62
void Paint() const override