]> git.tdb.fi Git - libs/gltk.git/blob - source/connector.cpp
Pass coordinates relative to the receiving widget's geometry
[libs/gltk.git] / source / connector.cpp
1 /* $Id$
2
3 This file is part of libmspgltk
4 Copyright © 2007  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #include "connector.h"
9 #include "logic.h"
10
11 using namespace std;
12
13 namespace Msp {
14 namespace GLtk {
15
16 Connector::~Connector()
17 {
18         for(map<string, ConnAction *>::iterator i=actions.begin(); i!=actions.end(); ++i)
19                 delete i->second;
20 }
21
22 void Connector::connect(const Logic &logic)
23 {
24         const list<Logic::WidgetAction> &logic_acts=logic.get_actions();
25
26         for(list<Logic::WidgetAction>::const_iterator i=logic_acts.begin(); i!=logic_acts.end(); ++i)
27         {
28                 map<string, ConnAction *>::const_iterator j=actions.find(i->type);
29                 if(j!=actions.end())
30                         j->second->connect(*this, *i->wdg, i->data);
31         }
32 }
33
34 void Connector::add(const string &type, ConnAction *act)
35 {
36         map<string, ConnAction *>::iterator i=actions.find(type);
37         if(i!=actions.end())
38         {
39                 delete i->second;
40                 i->second=act;
41         }
42         else
43                 actions[type]=act;
44 }
45
46 } // namespace GLtk
47 } // namespace Msp