DISTRHO Plugin Framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.8KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2014 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef DGL_WIDGET_HPP_INCLUDED
  17. #define DGL_WIDGET_HPP_INCLUDED
  18. #include "Geometry.hpp"
  19. START_NAMESPACE_DGL
  20. // -----------------------------------------------------------------------
  21. class App;
  22. class Window;
  23. class Widget
  24. {
  25. public:
  26. explicit Widget(Window& parent);
  27. virtual ~Widget();
  28. bool isVisible() const noexcept;
  29. void setVisible(bool yesNo);
  30. void show();
  31. void hide();
  32. int getX() const noexcept;
  33. int getY() const noexcept;
  34. const Point<int>& getPos() const noexcept;
  35. void setX(int x) noexcept;
  36. void setY(int y) noexcept;
  37. void setPos(int x, int y) noexcept;
  38. void setPos(const Point<int>& pos) noexcept;
  39. int getWidth() const noexcept;
  40. int getHeight() const noexcept;
  41. const Size<int>& getSize() const noexcept;
  42. // virtual needed by cairo
  43. virtual void setWidth(int width) noexcept;
  44. virtual void setHeight(int height) noexcept;
  45. virtual void setSize(int width, int height) noexcept;
  46. virtual void setSize(const Size<int>& size) noexcept;
  47. const Rectangle<int>& getArea() const noexcept;
  48. uint getEventTimestamp() const noexcept;
  49. int getModifiers() const noexcept;
  50. App& getParentApp() const noexcept;
  51. Window& getParentWindow() const noexcept;
  52. void repaint() noexcept;
  53. protected:
  54. virtual void onDisplay() = 0;
  55. virtual bool onKeyboard(bool press, uint key);
  56. virtual bool onMouse(int button, bool press, int x, int y);
  57. virtual bool onMotion(int x, int y);
  58. virtual bool onScroll(int x, int y, float dx, float dy);
  59. virtual bool onSpecial(bool press, Key key);
  60. virtual void onReshape(int width, int height);
  61. private:
  62. Window& fParent;
  63. bool fVisible;
  64. Rectangle<int> fArea;
  65. friend class CairoWidget;
  66. friend class Window;
  67. friend class StandaloneWindow;
  68. DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Widget)
  69. };
  70. // -----------------------------------------------------------------------
  71. END_NAMESPACE_DGL
  72. #endif // DGL_WIDGET_HPP_INCLUDED