Update list of wide characters
[centerim5.git] / cppconsui / Window.h
blob769181b8e83d4b518e69ac53f7e4564e860cae34
1 // Copyright (C) 2010-2015 Petr Pavlu <setup@dagobah.cz>
2 //
3 // This file is part of CenterIM.
4 //
5 // CenterIM 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 // CenterIM 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.
15 // You should have received a copy of the GNU General Public License
16 // along with CenterIM. If not, see <http://www.gnu.org/licenses/>.
18 /// @file
19 /// Window class.
20 ///
21 /// @ingroup cppconsui
23 #ifndef WINDOW_H
24 #define WINDOW_H
26 #include "Container.h"
27 #include "Panel.h"
29 namespace CppConsUI {
31 class Window : public Container {
32 public:
33 enum Type {
34 TYPE_NON_FOCUSABLE,
35 TYPE_NORMAL,
36 TYPE_TOP,
39 Window(
40 int x, int y, int w, int h, Type t = TYPE_NORMAL, bool decorated_ = true);
41 Window(int x, int y, int w, int h, const char *title, Type t = TYPE_NORMAL,
42 bool decorated_ = true);
43 virtual ~Window() override;
45 // Widget
46 virtual int draw(Curses::ViewPort area, Error &error) override;
47 virtual void setVisibility(bool visible) override;
48 virtual bool isVisibleRecursive() const override { return isVisible(); }
49 virtual Point getAbsolutePosition() const override;
51 // Container
52 virtual bool isWidgetVisible(const Widget &widget) const override;
53 virtual bool setFocusChild(Widget &child) override;
54 virtual Point getAbsolutePosition(const Widget &child) const override;
56 virtual void show();
57 virtual void hide();
58 virtual void close();
60 // virtual void SetType(Type t) { type_ = t; }
61 virtual Type getType() { return type_; }
63 // virtual void setDecorated(bool new_decorated);
64 virtual bool isDecorated() const { return decorated_; }
66 virtual void setClosable(bool new_closable);
67 virtual bool isClosable() const { return closable_; }
69 virtual void setTitle(const char *text) { panel_->setTitle(text); }
70 virtual const char *getTitle() const { return panel_->getTitle(); }
72 /// This function is called when the screen is resized.
73 virtual void onScreenResized() {}
75 sigc::signal<void, Window &> signal_close;
76 sigc::signal<void, Window &> signal_show;
77 sigc::signal<void, Window &> signal_hide;
79 protected:
80 Type type_;
81 bool decorated_;
83 /// Flag indicating if it is allowed to close the window by the close-window
84 /// action, this usually means if it is possible to close the window by
85 /// pressing the Esc key.
86 bool closable_;
88 Panel *panel_;
90 // Widget
91 virtual void signalMoveResize(
92 const Rect &oldsize, const Rect &newsize) override;
93 virtual void signalWishSizeChange(
94 const Size &oldsize, const Size &newsize) override;
95 virtual void updateArea() override;
96 virtual void redraw() override;
98 virtual void initWindow(int x, int y, const char *title);
100 private:
101 CONSUI_DISABLE_COPY(Window);
103 // Widget
104 // Windows cannot have any parent.
105 using Container::setParent;
107 void actionClose();
109 void declareBindables();
112 } // namespace CppConsUI
114 #endif // WINDOW_H
116 // vim: set tabstop=2 shiftwidth=2 textwidth=80 expandtab: