From 44fa03c1bf8eb60d38256b48720f9958c735aadc Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 20 Nov 2015 21:45:41 +0100 Subject: Refactored Window. --- plugingui/window.h | 101 +++++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 50 deletions(-) (limited to 'plugingui/window.h') diff --git a/plugingui/window.h b/plugingui/window.h index 23d91e0..7701ad9 100644 --- a/plugingui/window.h +++ b/plugingui/window.h @@ -24,8 +24,7 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef __DRUMGIZMO_WINDOW_H__ -#define __DRUMGIZMO_WINDOW_H__ +#pragma once #include "widget.h" @@ -38,68 +37,70 @@ namespace GUI { class Window : public Widget { public: - Window(); - ~Window(); + Window(); + ~Window(); - void show(); - void hide(); + void setFixedSize(int width, int height); + void setCaption(const std::string& caption); - void setFixedSize(int width, int height); - void resize(int width, int height); - void move(size_t x, size_t y); + // From Widget: + void resize(int width, int height) override; + void move(size_t x, size_t y) override; + size_t x() override; + size_t y() override; + size_t width() override; + size_t height() override; + size_t windowX() override; + size_t windowY() override; + void show() override; + void hide() override; + Window* window() override; - size_t x(); - size_t y(); - size_t windowX(); - size_t windowY(); - size_t width(); - size_t height(); + EventHandler* eventHandler(); - void setCaption(std::string caption); + Widget* keyboardFocus(); + void setKeyboardFocus(Widget* widget); - void addChild(Widget *widget); + Widget* buttonDownFocus(); + void setButtonDownFocus(Widget* widget); - void repaintEvent(GUI::RepaintEvent* repaintEvent); + Widget* mouseFocus(); + void setMouseFocus(Widget* widget); - void beginPaint(); - void endPaint(); - - Window *window(); - - EventHandler *eventHandler(); - - // handlers - virtual void redraw(); - void resized(size_t w, size_t h); - - Widget *keyboardFocus(); - void setKeyboardFocus(Widget *widget); - - Widget *buttonDownFocus(); - void setButtonDownFocus(Widget *widget); +protected: + // For the EventHandler + friend class EventHandler; + void redraw(); + void resized(size_t w, size_t h); + void updateBuffer(); - Widget *mouseFocus(); - void setMouseFocus(Widget *widget); + // For the Painter + friend class Painter; + void beginPaint(); + void endPaint(); - PixelBuffer wpixbuf; - void updateBuffer(); + // From Widget: + void repaintEvent(RepaintEvent* repaintEvent) override; -protected: - size_t refcount; + // For the NativweWindow + friend class NativeWindowX11; + friend class NativeWindowWin32; + friend class NativeWindowPugl; + PixelBuffer wpixbuf; - Widget *_keyboardFocus; - Widget *_buttonDownFocus; - Widget *_mouseFocus; + size_t refcount{0}; - NativeWindow *native; - EventHandler *eventhandler; + Widget* _keyboardFocus{nullptr}; + Widget* _buttonDownFocus{nullptr}; + Widget* _mouseFocus{nullptr}; - Image back; - Image logo; + NativeWindow* native{nullptr}; + EventHandler* eventhandler{nullptr}; - size_t max_refcount; -}; + Image back{":bg.png"}; + Image logo{":logo.png"}; + size_t maxRefcount{0}; }; -#endif/*__DRUMGIZMO_WINDOW_H__*/ +} // GUI:: -- cgit v1.2.3