CEBL  2.1
CursorPie.cpp
Go to the documentation of this file.
1 #include <sstream>
2 
3 #include "CursorPie.hpp"
4 #include "../X11Controller.hpp"
5 #include "../../TextUtils.hpp"
6 
8 {
9  for(int i=0;i<10;i++)
10  {
11  xmove.push_back(5);
12  ymove.push_back(5);
13  }
14 }
15 
16 
18 {
19  if(c == -1)
21  else
22  {
25  selectPie(c);
26  }
27 }
28 
29 void CursorPie::selectPie(int c)
30 {
31  X11Controller x;
32 
33  if(!x.displayIsOpen())
34  return;
35 
36  if(xmove.size() > unsigned(c)
37  && ymove.size() > unsigned(c))
38  {
39  x.moveCursorRelative(xmove[c],ymove[c]);
40  }
41 }
42 
43 //------------------------------------------------------------
44 
45 
46 std::map<std::string,CEBL::Param> CursorPie::getParamsList()
47 {
48  std::map<std::string,CEBL::Param> params;
49  for(int i=0;i<num_classes;i++)
50  {
51  int current = 0;
52  if(xmove.size() > unsigned(i))
53  current = this->xmove[i];
54 
55  CEBL::Param temp("Class " + TextUtils::IntToString(i) + " X:",
56  " Amount to move cursor in X direction.",
57  current);
58  std::stringstream ss1;
59  ss1 << "x" << i;
60  params[ss1.str()] = temp;
61 
62  //----------------------------------------
63  //y
64  current = 0;
65  if(ymove.size() > unsigned(i))
66  current = this->ymove[i];
67 
68  CEBL::Param temp2("Class " + TextUtils::IntToString(i) + " Y: ",
69  " Amount to move cursor in Y direction.",
70  current);
71  std::stringstream ss2;
72  ss2 << "x" << i;
73  params[ss2.str()] = temp2;
74 
75 
76  }
77  return params;
78 }
79 void CursorPie::setParamsList( std::map<std::string,CEBL::Param> p)
80 {
81  this->xmove.resize(0);
82  this->ymove.resize(0);
83  map<std::string, CEBL::Param>::iterator it;
84  for(it = p.begin(); it!=p.end(); ++it)
85  {
86  this->xmove.push_back(it->second.getInt());
87  ++it;
88  this->ymove.push_back(it->second.getInt());
89  }
90 
91 }