Debian Codegraph @

src/widget/IWidget.cpp

raw
1 /*
2 * Copyright (C) 2004 Ivo Danihelka ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9 #include "IWidget.h"
10
11 #include "MouseStroke.h"
12
13 //-----------------------------------------------------------------
14 /**
15 * Call own_mouseButton when stroke is inside own body.
16 */
17 void
18 IWidget::mouseButton(const MouseStroke &stroke)
19 {
20 if (isInside(stroke.getLoc())) {
21 own_mouseButton(stroke);
22 }
23 }
24 //-----------------------------------------------------------------
25 /**
26 * Returns own_getTip when location is inside own body.
27 */
28 std::string
29 IWidget::getTip(const V2 &loc)
30 {
31 std::string result;
32 if (isInside(loc)) {
33 result = own_getTip(loc);
34 }
35 return result;
36 }
37 //-----------------------------------------------------------------
38 /**
39 * Test whether location is inside this widget.
40 * @param loc world location
41 * @return true when location is inside widget body
42 */
43 bool
44 IWidget::isInside(const V2 &loc)
45 {
46 V2 inside = loc.minus(m_shift);
47 return (inside.getX() >= 0 && inside.getX() < getW()
48 && inside.getY() >= 0 && inside.getY() < getH());
49 }
50