Fixed compiler warnings
[AXE.git] / src / button.h
1
2 /**************************************************************************
3 **  (c) Copyright 1998, Andromeda Technology & Automation
4 ***************************************************************************
5 ** MODULE INFORMATION *
6 ***********************
7 **      FILE NAME      : button.h
8 **      SYSTEM NAME    : AXE - Andromeda X-windows Encapsulation
9 **      VERSION NUMBER : $Revision: 1.1 $
10 **
11 **  DESCRIPTION      :  Definition of button classes
12 **
13 **  EXPORTED OBJECTS : 
14 **  LOCAL    OBJECTS : 
15 **  MODULES  USED    :
16 ***************************************************************************
17 **  ADMINISTRATIVE INFORMATION *
18 ********************************
19 **      ORIGINAL AUTHOR : Arjen Baart - arjen@andromeda.nl
20 **      CREATION DATE   : Mar 07, 1998
21 **      LAST UPDATE     : Mar 13, 1998
22 **      MODIFICATIONS   : 
23 **************************************************************************/
24
25 /*****************************
26    $Log: button.h,v $
27    Revision 1.1  2002-07-25 08:01:26  arjen
28    First checkin, AXE release 0.2
29
30 *****************************/
31
32 /* static const char *RCSID = "$Id: button.h,v 1.1 2002-07-25 08:01:26 arjen Exp $"; */
33
34 #include "frame.h"
35
36 /*
37 ///////////////////////////////////////////////////////////////////////////
38 //  NAME           : button
39 //  BASECLASS      : frame
40 //  MEMBERS        :
41 //  OPERATORS      :
42 //  METHODS        :
43 //
44 //  DESCRIPTION    :
45 //
46 //  RELATIONS      :
47 //  SEE ALSO       :
48 //  LAST MODIFIED  :
49 ///////////////////////////////////////////////////////////////////////////
50 */
51
52 class button : public frame
53 {
54
55 public:
56
57    button(window &par, int x, int y, const char label[]) : frame(par, x, y, label)
58    {
59       SelectInput(ButtonReleaseMask|ButtonPressMask, 1);
60    }
61
62    virtual int EV_ButtonPress(XButtonEvent ev)
63    {
64       Strength(-Strength());
65       return 1;
66    }
67
68    virtual int EV_ButtonRelease(XButtonEvent ev)
69    {
70       Strength(-Strength());
71       return 1;
72    }
73 };
74
75 class touch_button : public button
76 {
77
78 public:
79
80    touch_button(window &par, int x, int y, const char label[])
81           : button(par, x, y, label)
82    {
83    }
84
85
86    virtual int EV_ButtonPress(XButtonEvent ev);
87
88    virtual void click(void);
89 };
90
91
92 class toggle_button : public touch_button
93 {
94    enum { State_Off, State_On }  state;
95
96 public:
97
98    toggle_button(window &par, int x, int y, const char label[])
99           : touch_button(par, x, y, label)
100    {
101       state = State_Off;
102    }
103
104    virtual void click(void);
105
106    virtual void redraw(void);
107 };
108
109 class command_button : public button
110 {
111    int command_code;
112
113 public:
114
115    command_button(window &par, int x, int y, const char label[], int cc = 0)
116                    : button(par, x, y, label)
117    {
118       command_code = cc;
119    }
120
121    virtual int EV_ButtonPress(XButtonEvent ev)
122    {
123       Strength(-Strength());
124       return 1;
125    }
126
127    virtual int EV_ButtonRelease(XButtonEvent ev)
128    {
129       Strength(-Strength());
130
131       return XApp->SendCommand(command_code);
132    }
133 };
134