File: Window.cpp

package info (click to toggle)
sear 0.5.0-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,408 kB
  • ctags: 2,580
  • sloc: cpp: 14,902; sh: 10,890; makefile: 172
file content (54 lines) | stat: -rw-r--r-- 974 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// This file may be redistributed and modified only under the terms of
// the GNU General Public License (See COPYING for details).
// Copyright (C) 2004 Alistair Riddoch

#include "gui/Window.h"

#include <iostream>

namespace Sear {

Window::Window() : m_parent(0) {
}

Window::~Window() {
}

void Window::addChild(Window * w)
{
    m_children.insert(w);
    w->m_parent = this;
}

void Window::setPos(int x, int y)
{
  m_x = x;
  m_y = y;
}

void Window::setSize(int w, int h)
{
  m_w = w;
  m_h = h;
}

void Window::mouseMotion(short x, short y)
{
  if (m_parent != 0) {
    std::cout << "CHILD " << x << " " << y << std::endl << std::flush;
  }
  std::set<Window *>::const_iterator I = m_children.begin();
  for(; I != m_children.end(); ++I) {
    Window & w = **I;
    short rx = x - w.m_x,
          ry = y - w.m_y;
    if ((rx < 0) || (rx >= w.m_w) ||
        (ry < 0) || (ry >= w.m_h)) {
      continue;
    }
    w.mouseMotion(rx, ry);
  }
}


} // namespace Sear