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.

102 lines
2.7KB

  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. #ifdef PROPER_CPP11_SUPPORT
  20. # include <cstdint>
  21. #else
  22. # include <stdint.h>
  23. #endif
  24. START_NAMESPACE_DGL
  25. // -----------------------------------------------------------------------
  26. class App;
  27. class Window;
  28. class Widget
  29. {
  30. public:
  31. Widget(Window& parent);
  32. virtual ~Widget();
  33. bool isVisible() const noexcept;
  34. void setVisible(bool yesNo);
  35. void show();
  36. void hide();
  37. int getX() const noexcept;
  38. int getY() const noexcept;
  39. const Point<int>& getPos() const noexcept;
  40. void setX(int x);
  41. void setY(int y);
  42. void setPos(int x, int y);
  43. void setPos(const Point<int>& pos);
  44. int getWidth() const noexcept;
  45. int getHeight() const noexcept;
  46. const Size<int>& getSize() const noexcept;
  47. // virtual needed by cairo
  48. virtual void setWidth(int width);
  49. virtual void setHeight(int height);
  50. virtual void setSize(int width, int height);
  51. virtual void setSize(const Size<int>& size);
  52. const Rectangle<int>& getArea() const noexcept;
  53. uint32_t getEventTimestamp();
  54. int getModifiers();
  55. App& getParentApp() const noexcept;
  56. Window& getParentWindow() const noexcept;
  57. void repaint();
  58. protected:
  59. virtual void onDisplay() = 0;
  60. virtual bool onKeyboard(bool press, uint32_t key);
  61. virtual bool onMouse(int button, bool press, int x, int y);
  62. virtual bool onMotion(int x, int y);
  63. virtual bool onScroll(int x, int y, float dx, float dy);
  64. virtual bool onSpecial(bool press, Key key);
  65. virtual void onReshape(int width, int height);
  66. virtual void onClose();
  67. private:
  68. Window& fParent;
  69. bool fVisible;
  70. Rectangle<int> fArea;
  71. friend class CairoWidget;
  72. friend class Window;
  73. DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Widget)
  74. };
  75. // -----------------------------------------------------------------------
  76. END_NAMESPACE_DGL
  77. #endif // DGL_WIDGET_HPP_INCLUDED