summaryrefslogtreecommitdiff
path: root/elementaryxx/src/Object.cpp
blob: f6f9937edb2c64633818c53c59e18f2ac7eb5b2f (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#ifdef HAVE_CONFIG_H
  #include <config.h>
#endif

#include "elementaryxx/Object.h"
#include "elementaryxx/Theme.h"

/* STD */
#include <cassert>

using namespace std;

namespace Elmxx {

Object::Object () {}

Object::~Object () {}  

void Object::elmInit ()
{
  // check if there was a problem with object creation
  assert (o);
  
  init (); // call init() from Evasxx::Object
  
  signalHandleFree.connect (sigc::mem_fun (this, &Object::freeSignalHandler));
}

void Object::destroy ()
{
  evas_object_del (o);
  cout << "Object::destroy ()" << endl;
}

void Object::freeSignalHandler ()
{
  cout << "freeSignalHandler()" << endl;
  delete (this);
  // !!!ATTENTION!!!
  // suicide for a C++ object is dangerous, but allowed
  // the simple rule is that no member functions or member variables are allowed to access after this point!
}

void Object::setScale (double scale)
{
  elm_object_scale_set (o, scale);
}

double Object::getScale ()
{
  return elm_object_scale_get (o);
}

void Object::setStyle (const std::string &style)
{
  elm_object_style_set (o, style.c_str ());
}

const std::string Object::getStyle ()
{
  const char *tmp = elm_object_style_get (o);
  return tmp ? tmp : string ();
}

void Object::setDisabled (bool disabled)
{
  elm_object_disabled_set (o, disabled);
}

bool Object::getDisabled ()
{
  return elm_object_disabled_get (o);
}

void Object::focus ()
{
  elm_object_focus_set (o, EINA_TRUE);
}

bool Object::checkWidget ()
{
  return elm_object_widget_check (o);
}

Eflxx::CountedPtr <Evasxx::Object> Object::getParentWidget ()
{
  Evas_Object *eo = elm_object_parent_widget_get (o);
 
  Evasxx::Object *ret_o = Evasxx::Object::wrap (eo);

  return Eflxx::CountedPtr <Evasxx::Object> (ret_o);
}

Eflxx::CountedPtr <Evasxx::Object> Object::getTopWidget ()
{
  Evas_Object *eo = elm_object_top_widget_get (o);
 
  Evasxx::Object *ret_o = Evasxx::Object::wrap (eo);

  return Eflxx::CountedPtr <Evasxx::Object> (ret_o);
}

const std::string Object::getWidgetType ()
{
  return elm_object_widget_type_get (o);
}

void Object::setText (const std::string &label)
{
  elm_object_part_text_set(o, NULL, label.c_str());
}

void Object::setText (const std::string &part, const std::string &label)
{
  elm_object_part_text_set(o, part.c_str(), label.c_str());
}

const std::string Object::getText ()
{
  return elm_object_part_text_get(o, NULL);
}

const std::string Object::getText (const std::string &part)
{
  return elm_object_part_text_get(o, part.c_str());
}

void Object::setContent (const Evasxx::Object &content)
{
  elm_object_part_content_set(o, NULL, content.obj());
}

void Object::setContent (const std::string &part, const Evasxx::Object &content)
{
  elm_object_part_content_set(o, part.c_str(), content.obj());
}

Eflxx::CountedPtr <Evasxx::Object> Object::getContent ()
{
  Evas_Object *eo = elm_object_part_content_get(o, NULL);
 
  Evasxx::Object *ret_o = Evasxx::Object::wrap (eo);

  return Eflxx::CountedPtr <Evasxx::Object> (ret_o);
}

Eflxx::CountedPtr <Evasxx::Object> Object::getContent (const std::string &part)
{
  Evas_Object *eo = elm_object_part_content_get(o, part.c_str());
 
  Evasxx::Object *ret_o = Evasxx::Object::wrap (eo);

  return Eflxx::CountedPtr <Evasxx::Object> (ret_o);
}

void Object::setTheme(const Theme *th)
{
  // calling th->mTheme is allowed because Object is a friend of Theme...
  elm_object_theme_set(o, th->mTheme);
}

Eflxx::CountedPtr <Theme> Object::getTheme()
{
  Elm_Theme *theme = elm_object_theme_get(o);

#warning "Not yet implemented!!"
  Theme *ret_t = NULL;//Theme::wrap (theme);

  return Eflxx::CountedPtr <Theme> (ret_t);
}

void Object::unsetContent()
{
  /* ignore return */ elm_object_part_content_unset(o, NULL);
}

void Object::unsetContent(const std::string &part)
{
 /* ignore return */ elm_object_part_content_unset(o, part.c_str());
}

Eflxx::CountedPtr <Evasxx::Object> Object::findName(const std::string &name, int recurse)
{
  Evas_Object *eo = elm_object_name_find(o, name.c_str(), recurse);
 
  Evasxx::Object *ret_o = Evasxx::Object::wrap (eo);

  return Eflxx::CountedPtr <Evasxx::Object> (ret_o);
}

void Object::setInfoAccess(const std::string &txt)
{
  elm_object_access_info_set(o, txt.c_str());
}

} // end namespace Elmxx