Minsky: 3.17.0
eventInterface.h
Go to the documentation of this file.
1 /*
2  @copyright Steve Keen 2021
3  @author Russell Standish
4  This file is part of Minsky.
5 
6  Minsky is free software: you can redistribute it and/or modify it
7  under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Minsky 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 Minsky. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef EVENTINTERFACE_H
21 #define EVENTINTERFACE_H
22 #include "item.h"
23 #include "wire.h"
24 
25 #include <string>
26 
27 namespace minsky
28 {
29  // enforces a uniform mouse and keyboard event handling interface
31  {
32  virtual void mouseDown(float x, float y) {}
33  virtual void controlMouseDown(float x, float y) {mouseDown(x,y);}
34  virtual void mouseUp(float x, float y) {}
35  virtual void mouseMove(float x, float y) {}
36  virtual void zoom(double x, double y, double z) {}
38  virtual void moveTo(float x, float y) {}
40  virtual std::vector<float> position() const {return {0,0};}
41  virtual double zoomFactor() const {return 1;}
42 
43  struct KeyPressArgs
44  {
45  int keySym;
46  std::string utf8;
47  int state;
48  float x;
49  float y;
50  };
57  virtual bool keyPress(const KeyPressArgs&)
58  {return false;}
59 
63  virtual bool getItemAt(float x, float y) {return false;}
64  virtual bool getWireAt(float x, float y) {return false;}
65 
66 
67  };
68 }
69 
70 #include "eventInterface.cd"
71 #include "eventInterface.xcd"
72 #endif
virtual bool keyPress(const KeyPressArgs &)
handle key press over current itemFocus,
virtual bool getWireAt(float x, float y)
item or wire obtained by get*At() calls
virtual std::vector< float > position() const
current centre coordinates
virtual void moveTo(float x, float y)
move this so that (x,y) is centred
virtual double zoomFactor() const
std::shared_ptr< Item > ItemPtr
Definition: item.h:55
std::shared_ptr< Wire > WirePtr
Definition: wire.h:98
virtual bool getItemAt(float x, float y)
item or wire obtained by get*At() calls
virtual void mouseUp(float x, float y)
virtual void mouseMove(float x, float y)
virtual void zoom(double x, double y, double z)
virtual void controlMouseDown(float x, float y)
virtual void mouseDown(float x, float y)
ItemPtr item
item or wire obtained by get*At() calls
WirePtr wire
item or wire obtained by get*At() calls