ncmpc  0.31
ProxyPage.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 NCMPC_PROXY_PAGE_HXX
21 #define NCMPC_PROXY_PAGE_HXX
22 
23 #include "Page.hxx"
24 
25 class ProxyPage : public Page {
26  WINDOW *const w;
27 
28  Page *current_page = nullptr;
29 
30  bool is_open = false;
31 
32 public:
33  explicit ProxyPage(WINDOW *_w):w(_w) {}
34 
35  const Page *GetCurrentPage() const {
36  return current_page;
37  }
38 
40  return current_page;
41  }
42 
43  void SetCurrentPage(struct mpdclient &c, Page *new_page);
44 
45 private:
46  void MoveDirty() {
47  if (current_page != nullptr && current_page->IsDirty()) {
48  current_page->SetDirty(false);
49  SetDirty();
50  }
51  }
52 
53 public:
54  /* virtual methods from Page */
55  void OnOpen(struct mpdclient &c) override;
56  void OnClose() override;
57  void OnResize(Size size) override;
58  void Paint() const override;
59  void Update(struct mpdclient &c, unsigned events) override;
60  bool OnCommand(struct mpdclient &c, Command cmd) override;
61 
62 #ifdef HAVE_GETMOUSE
63  bool OnMouse(struct mpdclient &c, Point p, mmask_t bstate) override;
64 #endif
65 
66  const char *GetTitle(char *s, size_t size) const override;
67 };
68 
69 #endif
void OnOpen(struct mpdclient &c) override
Command
Definition: Command.hxx:29
bool IsDirty() const
Definition: Page.hxx:53
ProxyPage(WINDOW *_w)
Definition: ProxyPage.hxx:33
Definition: ProxyPage.hxx:25
void OnResize(Size size) override
void OnClose() override
void SetDirty(bool _dirty=true)
Definition: Page.hxx:57
void Paint() const override
Definition: mpdclient.hxx:17
const Page * GetCurrentPage() const
Definition: ProxyPage.hxx:35
Definition: Size.hxx:26
bool OnCommand(struct mpdclient &c, Command cmd) override
Page * GetCurrentPage()
Definition: ProxyPage.hxx:39
const char * GetTitle(char *s, size_t size) const override
Definition: Point.hxx:28
void SetCurrentPage(struct mpdclient &c, Page *new_page)
void Update(struct mpdclient &c, unsigned events) override
Definition: Page.hxx:36