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.

98 lines
2.2KB

  1. // ----------------------------------------------------------------------
  2. //
  3. // Copyright (C) 2010 Fons Adriaensen <fons@linuxaudio.org>
  4. // Modified by falkTX on Jan 2015 for inclusion in Carla
  5. //
  6. // This program is free software; you can redistribute it and/or modify
  7. // it under the terms of the GNU General Public License as published by
  8. // the Free Software Foundation; either version 2 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // This program is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. // GNU General Public License for more details.
  15. //
  16. // You should have received a copy of the GNU General Public License
  17. // along with this program; if not, write to the Free Software
  18. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. //
  20. // ----------------------------------------------------------------------
  21. #ifndef __BUTTON_H
  22. #define __BUTTON_H
  23. #include <cairo/cairo.h>
  24. #include <cairo/cairo-xlib.h>
  25. #include <clxclient.h>
  26. namespace AT1 {
  27. class ButtonImg
  28. {
  29. public:
  30. XftColor *_backg;
  31. XImage *_ximage;
  32. int _x0;
  33. int _y0;
  34. int _dx;
  35. int _dy;
  36. };
  37. class PushButton : public X_window
  38. {
  39. public:
  40. PushButton (X_window *parent,
  41. X_callback *cbobj,
  42. ButtonImg *image,
  43. int xp,
  44. int yp,
  45. int cbind = 0);
  46. virtual ~PushButton (void);
  47. enum { NOP = 100, PRESS, RELSE };
  48. int cbind (void) { return _cbind; }
  49. int state (void) { return _state; }
  50. virtual void set_state (int s);
  51. static void init (X_display *disp);
  52. static void fini (void);
  53. protected:
  54. X_callback *_cbobj;
  55. int _cbind;
  56. ButtonImg *_image;
  57. int _state;
  58. void render (void);
  59. void callback (int k) { _cbobj->handle_callb (k, this, 0); }
  60. private:
  61. void handle_event (XEvent *E);
  62. void bpress (XButtonEvent *E);
  63. void brelse (XButtonEvent *E);
  64. virtual int handle_press (void) = 0;
  65. virtual int handle_relse (void) = 0;
  66. static int _keymod;
  67. static int _button;
  68. };
  69. }
  70. #endif