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
39namespace Pt {
40
41namespace Forms {
42
43class WindowManager;
44class Window;
45
48class 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 void getBitmap(Gfx::Bitmap& bitmap, const Gfx::RectF& rect);
73
74 protected:
75 virtual void onConnect(Screen& screen);
76
77 virtual void onDisconnect();
78
79
80 virtual void onProcessPaintEvent(const PaintEvent& ev);
81
82 virtual void onPaintEvent(const PaintEvent& ev);
83
84
85 virtual void onProcessRescaleEvent(const RescaleEvent& ev);
86
87 virtual void onRescaleEvent(const RescaleEvent& ev);
88
89
90 virtual void onProcessResizeEvent(const ResizeEvent& ev);
91
92 virtual void onResizeEvent(const ResizeEvent& ev);
93
94
95 virtual void onProcessActivateEvent(const ActivateEvent& ev);
96
97 virtual void onActivateEvent(const ActivateEvent& ev);
98
99
100 virtual void onProcessWindowStateEvent(const WindowStateEvent& ev);
101
102 virtual void onWindowStateEvent(const WindowStateEvent& ev);
103
104
105 virtual void onProcessCloseEvent(const CloseEvent& ev);
106
107 virtual void onCloseEvent(const CloseEvent& ev);
108
109 protected:
110 virtual void onInit(Window& w) = 0;
111
112 virtual void onRelease(Window& w) = 0;
113
114 virtual Gfx::PointF onToWindow(const Window& w,
115 const Gfx::PointF& pos) const = 0;
116
117 virtual Gfx::PointF onFromWindow(const Window& w,
118 const Gfx::PointF& pos) const = 0;
119
120 virtual void onSetTitle(Window& w, const std::string& text) = 0;
121
122 virtual void onSetIcon(Window& w, const Gfx::Image& icon) = 0;
123
124 virtual void onSetState(Window& w, const WindowState& state) = 0;
125
126 virtual void onSetAbove(Window& w, bool above) = 0;
127
128 virtual void onSetSizeLimits(Window& w, const Gfx::SizeF& minSize,
129 const Gfx::SizeF& maxSize) = 0;
130
131 virtual void onAutoCenter(Window& w, const Gfx::SizeF* size) = 0;
132
133 virtual void onRepaint(Window& w, const Gfx::RectF& rect) = 0;
134
135 virtual void onShow(Window& w, bool visible) = 0;
136
137 virtual void onActivate(Window& w, bool active) = 0;
138
139 virtual void onEnable(Window& w, bool enable) = 0;
140
141 virtual void onMove(Window& w, const Gfx::PointF& to) = 0;
142
143 virtual Gfx::SizeF onResize(Window& w, const Gfx::SizeF& s) = 0;
144
145 virtual void onClose(Window& w) = 0;
146
147 // TODO: name clash with Widget base class
149 using Base::onShow;
150 using Base::onEnable;
151
152 private:
153 WindowManager& _wm;
154 Window& _window;
155 Pixmap _pixmap;
156 class ViewSurface* _surface;
157};
158
159} // namespace
160
161} // namespace
162
163#endif // include guard
Common type of every visual Forms object.
Definition Widget.h:105
virtual void enable(bool isEnable=true)
Requests that the widget be enabled or disabled.
Widget()
Creates and registers a widget with the Forms application.
const Gfx::SizeF & size() const
Returns the size in local logical coordinates.
Screen * screen()
Returns the connected screen, or 0 when disconnected.
virtual void onEnable(bool e)
Performs behavior associated with enabled state e.
virtual void onSetSizeLimits(const Gfx::SizeF &minSize, const Gfx::SizeF &maxSize)
Notifies that locally stored size limits changed.
virtual void onShow(bool visible)
Updates the local visibility state to visible.
Host that attaches windows to a screen or workspace.
Definition WindowManager.h:68
Form presented by a window manager.
Definition Window.h:99
Graphical user interfaces.
Definition ActivateEvent.h:40
Core module.
Definition Allocator.h:33