Audio plugin host https://kx.studio/carla
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.

107 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. #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. void move(int x, int y);
  45. void move(const Point<int>& pos);
  46. int getWidth() const noexcept;
  47. int getHeight() const noexcept;
  48. const Size<int>& getSize() const noexcept;
  49. // virtual needed by cairo
  50. virtual void setWidth(int width);
  51. virtual void setHeight(int height);
  52. virtual void setSize(const Size<int>& size);
  53. void setSize(int width, int height)
  54. {
  55. setSize(Size<int>(width, height));
  56. }
  57. const Rectangle<int>& getArea() const noexcept;
  58. uint32_t getEventTimestamp();
  59. int getModifiers();
  60. App& getParentApp() const noexcept;
  61. Window& getParentWindow() const noexcept;
  62. void repaint();
  63. protected:
  64. virtual void onDisplay() = 0;
  65. virtual bool onKeyboard(bool press, uint32_t key);
  66. virtual bool onMouse(int button, bool press, int x, int y);
  67. virtual bool onMotion(int x, int y);
  68. virtual bool onScroll(int x, int y, float dx, float dy);
  69. virtual bool onSpecial(bool press, Key key);
  70. virtual void onReshape(int width, int height);
  71. virtual void onClose();
  72. private:
  73. Window& fParent;
  74. bool fVisible;
  75. Rectangle<int> fArea;
  76. friend class CairoWidget;
  77. friend class Window;
  78. };
  79. // -----------------------------------------------------------------------
  80. END_NAMESPACE_DGL
  81. #endif // DGL_WIDGET_HPP_INCLUDED