1 // ----------------------------------------------------------------------------
2 //
3 //  Copyright (C) 2008-2015 Fons Adriaensen <fons@linuxaudio.org>
4 //
5 //  This program is free software; you can redistribute it and/or modify
6 //  it under the terms of the GNU General Public License as published by
7 //  the Free Software Foundation; either version 3 of the License, or
8 //  (at your option) any later version.
9 //
10 //  This program is distributed in the hope that it will be useful,
11 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //  GNU General Public License for more details.
14 //
15 //  You should have received a copy of the GNU General Public License
16 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 //
18 // ----------------------------------------------------------------------------
19 
20 
21 #ifndef __BUTTON_H
22 #define	__BUTTON_H
23 
24 
25 #include <clxclient.h>
26 
27 
28 class PushButton : public X_window
29 {
30 public:
31 
32     PushButton (X_window    *parent,
33                 X_callback  *cbobj,
34                 int          cbind,
35 		XImage      *image,
36 	        int xp,
37                 int yp,
38 		int xs,
39 		int ys);
40 
41     virtual ~PushButton (void);
42 
43     enum { NOP = 100, PRESS, RELSE, DRAG };
44 
cbind(void)45     int    cbind (void) { return _cbind; }
state(void)46     int    state (void) { return _state; }
47 
48     virtual void set_state (int s);
49 
keymod(void)50     static int keymod (void) { return _keymod; }
button(void)51     static int button (void) { return _button; }
52 
53     static void init (X_display *disp);
54     static void fini (void);
55 
56 protected:
57 
58     X_callback  *_cbobj;
59     int          _cbind;
60     XImage      *_image;
61     int          _state;
62     int          _xs;
63     int          _ys;
64 
65     void render (void);
callback(int k)66     void callback (int k) { _cbobj->handle_callb (k, this, 0); }
67 
68 private:
69 
70     void handle_event (XEvent *E);
71     void bpress (XButtonEvent *E);
72     void brelse (XButtonEvent *E);
73 
74     virtual int handle_press (void) = 0;
75     virtual int handle_relse (void) = 0;
76 
77     static int _keymod;
78     static int _button;
79 };
80 
81 
82 #endif
83