WindowFrame.h
1 /* Copyright (C) 2015 Marc Boris Duerner
2 
3  This library is free software; you can redistribute it and/or
4  modify it under the terms of the GNU Lesser General Public
5  License as published by the Free Software Foundation; either
6  version 2.1 of the License, or (at your option) any later version.
7 
8  As a special exception, you may use this file as part of a free
9  software library without restriction. Specifically, if other files
10  instantiate templates or use macros or inline functions from this
11  file, or you compile this file and link it with other files to
12  produce an executable, this file does not by itself cause the
13  resulting executable to be covered by the GNU General Public
14  License. This exception does not however invalidate any other
15  reasons why the executable file might be covered by the GNU Library
16  General Public License.
17 
18  This library is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  Lesser General Public License for more details.
22 
23  You should have received a copy of the GNU Lesser General Public
24  License along with this library; if not, write to the Free Software
25  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26  02110-1301 USA
27 */
28 
29 #ifndef PT_FORMS_WINDOWFRAME_H
30 #define PT_FORMS_WINDOWFRAME_H
31 
32 #include <Pt/Forms/Api.h>
33 #include <Pt/Forms/Widget.h>
34 #include <Pt/Forms/View.h>
35 #include <Pt/Forms/WindowType.h>
36 #include <Pt/Forms/Pixmap.h>
37 #include <Pt/Gfx/Bitmap.h>
38 
39 namespace Pt {
40 
41 namespace Forms {
42 
43 class WindowManager;
44 class Window;
45 
48 class WindowFrame : public Widget
49 {
50  typedef Widget Base;
51 
52  friend class Window;
53  friend class WindowManager;
54 
55  public:
56  WindowFrame(WindowManager& wm, Window& window);
57 
58  virtual ~WindowFrame();
59 
60  Window& window();
61 
62  const Window& window() const;
63 
64  Pixmap& pixmap();
65 
66  const Pixmap& pixmap() const;
67 
68  PaintSurface& surface();
69 
70  void getBitmap(Gfx::Bitmap& bitmap);
71 
72  protected:
73  virtual void onConnect(Screen& screen);
74 
75  virtual void onDisconnect();
76 
77 
78  virtual void onProcessPaintEvent(const PaintEvent& ev);
79 
80  virtual void onPaintEvent(const PaintEvent& ev);
81 
82 
83  virtual void onProcessRescaleEvent(const RescaleEvent& ev);
84 
85  virtual void onRescaleEvent(const RescaleEvent& ev);
86 
87 
88  virtual void onProcessResizeEvent(const ResizeEvent& ev);
89 
90  virtual void onResizeEvent(const ResizeEvent& ev);
91 
92 
93  virtual void onProcessActivateEvent(const ActivateEvent& ev);
94 
95  virtual void onActivateEvent(const ActivateEvent& ev);
96 
97 
98  virtual void onProcessWindowStateEvent(const WindowStateEvent& ev);
99 
100  virtual void onWindowStateEvent(const WindowStateEvent& ev);
101 
102 
103  virtual void onProcessCloseEvent(const CloseEvent& ev);
104 
105  virtual void onCloseEvent(const CloseEvent& ev);
106 
107  protected:
108  virtual void onInit(Window& w) = 0;
109 
110  virtual void onRelease(Window& w) = 0;
111 
112  virtual Gfx::PointF onToWindow(const Window& w,
113  const Gfx::PointF& pos) const = 0;
114 
115  virtual Gfx::PointF onFromWindow(const Window& w,
116  const Gfx::PointF& pos) const = 0;
117 
118  virtual void onSetTitle(Window& w, const std::string& text) = 0;
119 
120  virtual void onSetIcon(Window& w, const Gfx::Image& icon) = 0;
121 
122  virtual void onSetState(Window& w, const WindowState& state) = 0;
123 
124  virtual void onSetAbove(Window& w, bool above) = 0;
125 
126  virtual void onSetSizeLimits(Window& w, const Gfx::SizeF& minSize,
127  const Gfx::SizeF& maxSize) = 0;
128 
129  virtual void onAutoCenter(Window& w, const Gfx::SizeF* size) = 0;
130 
131  virtual void onRepaint(Window& w, const Gfx::RectF& rect) = 0;
132 
133  virtual void onShow(Window& w, bool visible) = 0;
134 
135  virtual void onActivate(Window& w, bool active) = 0;
136 
137  virtual void onEnable(Window& w, bool enable) = 0;
138 
139  virtual void onMove(Window& w, const Gfx::PointF& to) = 0;
140 
141  virtual Gfx::SizeF onResize(Window& w, const Gfx::SizeF& s) = 0;
142 
143  virtual void onClose(Window& w) = 0;
144 
145  // TODO: name clash with Widget base class
146  using Base::onSetSizeLimits;
147  using Base::onShow;
148  using Base::onEnable;
149 
150  private:
151  WindowManager& _wm;
152  Window& _window;
153  PixmapSurface _pixmap;
154  class ViewSurface* _surface;
155 };
156 
157 } // namespace
158 
159 } // namespace
160 
161 #endif // include guard