summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2008-09-30 06:58:56 +0000
committerCarsten Haitzler <raster@rasterman.com>2008-09-30 06:58:56 +0000
commit707657b49ca52860fde30c6b59c4453af7809d9d (patch)
tree9e7dba5578d2ea0ba1c933a496029c17c90e2866 /src
elementary becomes its own tree/lib/test binary
SVN revision: 36343
Diffstat (limited to 'src')
-rw-r--r--src/.cvsignore2
-rw-r--r--src/Makefile.am4
-rw-r--r--src/bin/.cvsignore7
-rw-r--r--src/bin/Makefile.am17
-rw-r--r--src/bin/test.c999
-rw-r--r--src/lib/Elementary.h553
-rw-r--r--src/lib/Makefile.am54
-rw-r--r--src/lib/elm_bg.c99
-rw-r--r--src/lib/elm_box.c131
-rw-r--r--src/lib/elm_button.c170
-rw-r--r--src/lib/elm_callback.c58
-rw-r--r--src/lib/elm_clock.c393
-rw-r--r--src/lib/elm_frame.c138
-rw-r--r--src/lib/elm_icon.c103
-rw-r--r--src/lib/elm_label.c68
-rw-r--r--src/lib/elm_main.c79
-rw-r--r--src/lib/elm_obj.c177
-rw-r--r--src/lib/elm_pad.c116
-rw-r--r--src/lib/elm_priv.h64
-rw-r--r--src/lib/elm_scroller.c99
-rw-r--r--src/lib/elm_table.c104
-rw-r--r--src/lib/elm_theme.c13
-rw-r--r--src/lib/elm_toggle.c210
-rw-r--r--src/lib/elm_widget.c137
-rw-r--r--src/lib/elm_win.c307
-rw-r--r--src/lib/els_box.c712
-rw-r--r--src/lib/els_box.h14
-rw-r--r--src/lib/els_icon.c364
-rw-r--r--src/lib/els_icon.h10
-rw-r--r--src/lib/els_pan.c270
-rw-r--r--src/lib/els_pan.h7
-rw-r--r--src/lib/els_scroller.c1052
-rw-r--r--src/lib/els_scroller.h25
-rw-r--r--src/lib/els_table.c953
-rw-r--r--src/lib/els_table.h10
35 files changed, 7519 insertions, 0 deletions
diff --git a/src/.cvsignore b/src/.cvsignore
new file mode 100644
index 000000000..282522db0
--- /dev/null
+++ b/src/.cvsignore
@@ -0,0 +1,2 @@
1Makefile
2Makefile.in
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 000000000..62f6d80e5
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,4 @@
1AUTOMAKE_OPTIONS = 1.4 foreign
2MAINTAINERCLEANFILES = Makefile.in
3
4SUBDIRS = lib bin
diff --git a/src/bin/.cvsignore b/src/bin/.cvsignore
new file mode 100644
index 000000000..a25cf7742
--- /dev/null
+++ b/src/bin/.cvsignore
@@ -0,0 +1,7 @@
1.deps
2.libs
3Makefile
4Makefile.in
5rage
6raged
7rage_thumb
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
new file mode 100644
index 000000000..db3e761d6
--- /dev/null
+++ b/src/bin/Makefile.am
@@ -0,0 +1,17 @@
1AUTOMAKE_OPTIONS = 1.4 foreign
2
3MAINTAINERCLEANFILES = Makefile.in
4
5AM_CPPFLAGS = \
6-I$(top_srcdir) \
7-I$(top_srcdir)/src/lib \
8-I$(top_srcdir)/src/bin \
9-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
10@ELEMENTARY_CFLAGS@
11
12bin_PROGRAMS = elementary_test
13
14elementary_test_SOURCES = test.c
15elementary_test_LDADD = $(top_builddir)/src/lib/libelementary.la
16elementary_test_LDFLAGS =
17elementary_test_DEPENDENCIES = $(top_builddir)/src/lib/libelementary.la
diff --git a/src/bin/test.c b/src/bin/test.c
new file mode 100644
index 000000000..3d85be552
--- /dev/null
+++ b/src/bin/test.c
@@ -0,0 +1,999 @@
1#include <Elementary.h>
2
3/* This is a test app (that is also functional) to test the api and serve
4 * as an example
5 */
6
7static void
8on_win_resize(void *data, Elm_Win *win, Elm_Cb_Type type, void *info)
9{
10 /* window is resized */
11 printf("resize to: %ix%i\n", win->w, win->h);
12}
13
14static void
15on_win_del_req(void *data, Elm_Win *win, Elm_Cb_Type type, void *info)
16{
17 /* because autodel is on - after this callback the window will be deleted */
18 /* but to be explicit - exit the app when window is closed */
19 elm_exit();
20}
21
22static void
23win_bg_simple(void)
24{
25 Elm_Win *win;
26 Elm_Bg *bg;
27
28 win = elm_win_new(); /* create a window */
29 win->name_set(win, "win_simple"); /* set the window name - used by window
30 * manager. make it uniqie for windows
31 * with in this application */
32 win->title_set(win, "Simple Window with default Bg"); /* set the title */
33 win->autodel = 0; /* dont auto delete the window if someone closes it.
34 * this means the del+req handler has to delete it. by
35 * default it is on */
36 /* add a callback that is called when the user tries to close the window */
37 win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
38 /* add a callback that gets called when the window is resized */
39 win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);
40
41 /* our window needs a baground, so ask for one - it will be set with a
42 * default bg */
43 bg = elm_bg_new(win);
44 bg->show(bg); /* show the bg */
45
46 win->size_req(win, NULL, 240, 320); /* request that the window is 240x240
47 * no min/max size enforced */
48 win->show(win); /* show the window */
49}
50
51static void
52win_bg_image(void)
53{
54 Elm_Win *win;
55 Elm_Bg *bg;
56 char buf[PATH_MAX];
57
58 win = elm_win_new();
59 win->name_set(win, "win_bg");
60 win->title_set(win, "Simple Window with and image Bg");
61 win->autodel = 0;
62 win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
63 win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);
64
65 bg = elm_bg_new(win);
66 /* this is a test - shows how to have your own custom wallpaper in
67 * your app - don't use this unless you have a very good reason! there
68 * is a default and all apps look nicer sharing the default, but if
69 * you insist... */
70 snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", PACKAGE_DATA_DIR);
71 bg->file_set(bg, buf, NULL); /* set the bg - the NULL is for special
72 * files that contain multiple images
73 * inside 1 file. not normally used but
74 * might be if you have archive files with
75 * multiple images in them */
76 bg->show(bg);
77
78 win->size_req(win, NULL, 240, 240);
79 win->show(win);
80}
81
82static void
83win_scrollable_label(void)
84{
85 Elm_Win *win;
86 Elm_Bg *bg;
87 Elm_Scroller *scroller;
88 Elm_Label *label;
89
90 win = elm_win_new();
91 win->name_set(win, "win_bg");
92 win->title_set(win, "Simple Window with scroller and label inside");
93 win->autodel = 0;
94 win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
95 win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);
96
97 bg = elm_bg_new(win);
98 bg->show(bg);
99
100 scroller = elm_scroller_new(win);
101
102 label = elm_label_new(win);
103 label->text_set(label,
104 "Hello world<br>"
105 "<br>"
106 "I am a label. I come here to temonstrate how to put<br>"
107 "text into a label, with newlines, even markup to test<br>"
108 "things like <b>bold text</b> where markup can be custom<br>"
109 "and extensible, defined by the theme's textbloxk style<br>"
110 "for the label.<br>"
111 "<br>"
112 "Note that the markup is html-like and things like newline<br>"
113 "chars and tab chars like stdout text are not valid text<br>"
114 "markup mechanisms. Use markup tags instead.<br>"
115 "<br>"
116 "Now we shall borrow some text from another test program<br>"
117 "(Expedite) to put some more tests in here<br>"
118 "<br>"
119 "<style=outline color=#fff outline_color=#000>Styled</> "
120 "<style=shadow shadow_color=#fff8>text</> "
121 "<style=soft_shadow shadow_color=#0002>should</> "
122 "<style=glow color=#fff glow2_color=#fe87 glow_color=#f214 >go here</> "
123 "<style=far_shadow shadow_color=#0005>as it is</> "
124 "<style=outline_shadow color=#fff outline_color=#8228 shadow_color=#005>within</> "
125 "<style=outline_soft_shadow color=#fff outline_color=#8228 shadow_color=#0002>right tags</> "
126 "<style=far_soft_shadow color=#fff shadow_color=#0002>to make it align to the</> "
127 "<underline=on underline_color=#00f>right hand</> "
128 "<backing=on backing_color=#fff8>side </><backing_color=#ff08>of</><backing_color=#0f08> </>"
129 "<strikethrough=on strikethrough_color=#f0f8>the textblock</>."
130 "<br>"
131 "<underline=double underline_color=#f00 underline2_color=#00f>now we need</> "
132 "to test some <color=#f00 font_size=8>C</><color=#0f0 font_size=10>O</>"
133 "<color=#00f font_size=12>L</><color=#fff font_size=14>O</>"
134 "<color=#ff0 font_size=16>R</><color=#0ff font_size=18> Bla Rai</>"
135 "<color=#f0f font_size=20> Stuff</>."
136 "<br>"
137 "<style=outline color=#fff outline_color=#000>Round about the cauldron go;</> "
138 "In the poison'd entrails throw.<br>"
139 "<style=shadow shadow_color=#fff8>Toad, that under cold stone</> "
140 "Days and nights has thirty-one<br>"
141 "<style=soft_shadow shadow_color=#0002>Swelter'd venom sleeping got,</> "
142 "<style=glow color=#fff glow2_color=#fe87 glow_color=#f214 >Boil thou first i' the charmed pot.</><br>"
143 "Double, double toil and trouble; "
144 "Fire burn, and cauldron bubble.<br>"
145 "<style=far_shadow shadow_color=#0005>Fillet of a fenny snake,</> "
146 "In the cauldron boil and bake;<br>"
147 "<style=outline_shadow color=#fff outline_color=#8228 shadow_color=#005>Eye of newt and toe of frog,</> "
148 "<underline=on underline_color=#00f>Wool of bat and tongue of dog,</><br>"
149 "<backing=on backing_color=#fff8>Adder's fork and blind-worm's sting,</> "
150 "<underline=double underline_color=#f00 underline2_color=#00f>Lizard's leg and owlet's wing,</><br>"
151 "<color=#808 font_size=20>For a charm of powerful trouble, "
152 "Like a hell-broth boil and bubble.<br>"
153 "Double, double toil and trouble;</> "
154 "Fire burn and cauldron bubble.<br>"
155 "Scale of dragon, tooth of wolf, "
156 "Witches' mummy, maw and gulf<br>"
157 "Of the ravin'd salt-sea shark, "
158 "Root of hemlock digg'd i' the dark,<br>"
159 "Liver of blaspheming Jew, "
160 "Gall of goat, and slips of yew<br>"
161 "Silver'd in the moon's eclipse, "
162 "Nose of Turk and Tartar's lips,<br>"
163 "Finger of birth-strangled babe "
164 "Ditch-deliver'd by a drab,<br>"
165 "Make the gruel thick and slab: "
166 "Add thereto a tiger's chaudron,<br>"
167 "For the ingredients of our cauldron. "
168 "Double, double toil and trouble;<br>"
169 "Fire burn and cauldron bubble. "
170 "Cool it with a baboon's blood,<br>"
171 "Then the charm is firm and good.<br>"
172 "<br>"
173 "Heizölrückstoßabdämpfung fløde pingüino kilómetros cœur déçu l'âme<br>"
174 "plutôt naïve Louÿs rêva crapaüter Íosa Úrmhac Óighe pór Éava Ádhaim<br>"
175 );
176 scroller->child_add(scroller, label);
177 label->show(label);
178 scroller->show(scroller);
179
180 win->size_req(win, NULL, 240, 480);
181 win->show(win);
182}
183
184static void
185win_label_determines_min_size(void)
186{
187 Elm_Win *win;
188 Elm_Bg *bg;
189 Elm_Label *label;
190
191 win = elm_win_new();
192 win->name_set(win, "win_bg");
193 win->title_set(win, "Simple Window with label setting minimum size");
194 win->autodel = 0;
195 win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
196 win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);
197
198 bg = elm_bg_new(win);
199 bg->expand_x = 0; /* allows the window to grow in the y axis because */
200 bg->expand_y = 1; /* its only child can expand in y */
201 bg->show(bg);
202
203 label = elm_label_new(win);
204 label->text_set(label,
205 "Hello world<br>"
206 "<br>"
207 "I am a label. I come here to temonstrate how to put<br>"
208 "text into a label, with newlines, even markup to test<br>"
209 "things like <b>bold text</b> where markup can be custom<br>"
210 "and extensible, defined by the theme's textbloxk style<br>"
211 "for the label.<br>"
212 "<br>"
213 "Note that the markup is html-like and things like newline<br>"
214 "chars and tab chars like stdout text are not valid text<br>"
215 "markup mechanisms. Use markup tags instead.<br>"
216 );
217 label->show(label);
218 label->expand_x = 0; /* allows the window to grow in the y axis because */
219 label->expand_y = 1; /* its only child can expand in y */
220 /* why do i change expand on both bg and label? both are children of the
221 * window widget and thus both affect the window sizing. if any expands
222 * in an axis then window expanding is allowed always */
223 elm_widget_sizing_update(label); /* make sure that the lable knows about its
224 * sizing changes like expand above */
225 win->show(win);
226}
227
228static void
229win_box_vert_of_labels(void)
230{
231 Elm_Win *win;
232 Elm_Bg *bg;
233 Elm_Box *box;
234 Elm_Label *label;
235
236 win = elm_win_new();
237 win->name_set(win, "win_bg");
238 win->title_set(win, "Simple Window with box + labels setting minimum size");
239 win->autodel = 0;
240 win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
241 win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);
242
243 bg = elm_bg_new(win);
244 bg->expand_x = 1;
245 bg->expand_y = 1;
246 bg->show(bg);
247
248 box = elm_box_new(win);
249 box->expand_x = 1;
250 box->expand_y = 1;
251
252 label = elm_label_new(win);
253 label->text_set(label, "Expand X/Y 0/0, Fill X/Y 0/0, Align: 0.5 0.5");
254 box->pack_end(box, label);
255 label->show(label);
256 label->align_x = 0.5;
257 label->align_y = 0.5;
258 label->expand_x = 0;
259 label->expand_y = 0;
260 label->fill_x = 0;
261 label->fill_y = 0;
262 elm_widget_sizing_update(label);
263
264 label = elm_label_new(win);
265 label->text_set(label, "Expand X/Y 1/1, Fill X/Y 0/0, Align: 0.5 0.5");
266 box->pack_end(box, label);
267 label->show(label);
268 label->align_x = 0.5;
269 label->align_y = 0.5;
270 label->expand_x = 1;
271 label->expand_y = 1;
272 label->fill_x = 0;
273 label->fill_y = 0;
274 elm_widget_sizing_update(label);
275
276 label = elm_label_new(win);
277 label->text_set(label, "Expand X/Y 1/1, Fill X/Y 1/1, Align: 0.5 0.5");
278 box->pack_end(box, label);
279 label->show(label);
280 label->align_x = 0.5;
281 label->align_y = 0.5;
282 label->expand_x = 1;
283 label->expand_y = 1;
284 label->fill_x = 1;
285 label->fill_y = 1;
286 elm_widget_sizing_update(label);
287
288 label = elm_label_new(win);
289 label->text_set(label, "Expand X/Y 0/0, Fill X/Y 1/1, Align: 0.5 0.5");
290 box->pack_end(box, label);
291 label->show(label);
292 label->align_x = 0.5;
293 label->align_y = 0.5;
294 label->expand_x = 0;
295 label->expand_y = 0;
296 label->fill_x = 1;
297 label->fill_y = 1;
298 elm_widget_sizing_update(label);
299
300 label = elm_label_new(win);
301 label->text_set(label, "Expand X/Y 0/0, Fill X/Y 1/1, Align: 0.0 0.5");
302 box->pack_end(box, label);
303 label->show(label);
304 label->align_x = 0.0;
305 label->align_y = 0.5;
306 label->expand_x = 0;
307 label->expand_y = 0;
308 label->fill_x = 1;
309 label->fill_y = 1;
310 elm_widget_sizing_update(label);
311
312 label = elm_label_new(win);
313 label->text_set(label, "Expand X/Y 0/0, Fill X/Y 1/1, Align: 1.0 0.5");
314 box->pack_end(box, label);
315 label->show(label);
316 label->align_x = 1.0;
317 label->align_y = 0.5;
318 label->expand_x = 0;
319 label->expand_y = 0;
320 label->fill_x = 1;
321 label->fill_y = 1;
322 elm_widget_sizing_update(label);
323
324 label = elm_label_new(win);
325 label->text_set(label, "Expand X/Y 0/0, Fill X/Y 1/1, Align: 0.5 0.0");
326 box->pack_end(box, label);
327 label->show(label);
328 label->align_x = 0.5;
329 label->align_y = 0.0;
330 label->expand_x = 0;
331 label->expand_y = 0;
332 label->fill_x = 1;
333 label->fill_y = 1;
334 elm_widget_sizing_update(label);
335
336 label = elm_label_new(win);
337 label->text_set(label, "Expand X/Y 0/0, Fill X/Y 1/1, Align: 0.5 1.0");
338 box->pack_end(box, label);
339 label->show(label);
340 label->align_x = 0.5;
341 label->align_y = 1.0;
342 label->expand_x = 0;
343 label->expand_y = 0;
344 label->fill_x = 1;
345 label->fill_y = 1;
346 elm_widget_sizing_update(label);
347
348 elm_widget_sizing_update(box);
349 box->show(box);
350
351 win->show(win);
352}
353
354static void
355win_scrollable_box_vert_of_labels(void)
356{
357 Elm_Win *win;
358 Elm_Bg *bg;
359 Elm_Scroller *scroller;
360 Elm_Box *box;
361 Elm_Label *label;
362 int i;
363
364 win = elm_win_new();
365 win->name_set(win, "win_bg");
366 win->title_set(win, "Simple Window with scroller and box + labels inside");
367 win->autodel = 0;
368 win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
369 win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);
370
371 bg = elm_bg_new(win);
372 bg->expand_x = 1;
373 bg->expand_y = 1;
374 bg->show(bg);
375
376 scroller = elm_scroller_new(win);
377
378 box = elm_box_new(win);
379 box->expand_x = 1;
380 box->expand_y = 1;
381
382 for (i = 0; i < 40; i++)
383 {
384 char buf[200];
385
386 snprintf(buf, sizeof(buf), "This is a Label in a box, #%i", i);
387 label = elm_label_new(win);
388 label->text_set(label, buf);
389 box->pack_end(box, label);
390 label->show(label);
391 label->expand_x = 0;
392 label->expand_y = 0;
393 elm_widget_sizing_update(label);
394 label->show(label);
395 }
396
397 scroller->child_add(scroller, box);
398
399 elm_widget_sizing_update(box);
400 box->show(box);
401
402 scroller->show(scroller);
403
404 win->size_req(win, NULL, 240, 240);
405 win->show(win);
406}
407
408static void
409win_table_of_labels(void)
410{
411 Elm_Win *win;
412 Elm_Bg *bg;
413 Elm_Table *table;
414 Elm_Label *label;
415
416 win = elm_win_new();
417 win->name_set(win, "win_bg");
418 win->title_set(win, "Simple Window with table + labels setting minimum size");
419 win->autodel = 0;
420 win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
421 win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);
422
423 bg = elm_bg_new(win);
424 bg->expand_x = 1;
425 bg->expand_y = 1;
426 bg->show(bg);
427
428 table = elm_table_new(win);
429 table->expand_x = 1;
430 table->expand_y = 1;
431
432 label = elm_label_new(win);
433 label->text_set(label, "X");
434 table->pack(table, label, 0, 0, 1, 1);
435 label->fill_x = 0;
436 label->fill_y = 0;
437 label->show(label);
438 elm_widget_sizing_update(label);
439
440 label = elm_label_new(win);
441 label->text_set(label, "Y");
442 table->pack(table, label, 1, 0, 1, 1);
443 label->fill_x = 0;
444 label->fill_y = 0;
445 label->show(label);
446 elm_widget_sizing_update(label);
447
448 label = elm_label_new(win);
449 label->text_set(label, "Z");
450 table->pack(table, label, 2, 0, 1, 1);
451 label->fill_x = 0;
452 label->fill_y = 0;
453 label->show(label);
454 elm_widget_sizing_update(label);
455
456 label = elm_label_new(win);
457 label->text_set(label, "A");
458 table->pack(table, label, 0, 1, 1, 1);
459 label->fill_x = 0;
460 label->fill_y = 0;
461 label->show(label);
462 elm_widget_sizing_update(label);
463
464 label = elm_label_new(win);
465 label->text_set(label, "BB");
466 table->pack(table, label, 1, 1, 2, 1);
467 label->fill_x = 0;
468 label->fill_y = 0;
469 label->show(label);
470 elm_widget_sizing_update(label);
471
472 label = elm_label_new(win);
473 label->text_set(label, "CCC");
474 table->pack(table, label, 0, 2, 3, 1);
475 label->fill_x = 0;
476 label->fill_y = 0;
477 label->show(label);
478 elm_widget_sizing_update(label);
479
480 elm_widget_sizing_update(table);
481 table->show(table);
482
483 win->show(win);
484}
485
486static void
487on_button_activate(void *data, Elm_Button *bt, Elm_Cb_Type type, void *info)
488{
489 printf("Button %p activate\n", bt);
490}
491
492static void
493win_table_of_buttons(void)
494{
495 Elm_Win *win;
496 Elm_Bg *bg;
497 Elm_Icon *icon;
498 Elm_Table *table;
499 Elm_Button *button;
500 char buf[PATH_MAX];
501
502 win = elm_win_new();
503 win->name_set(win, "win_bg");
504 win->title_set(win, "Simple Window with table + buttons setting minimum size");
505 win->autodel = 0;
506 win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
507 win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);
508
509 bg = elm_bg_new(win);
510 bg->expand_x = 1;
511 bg->expand_y = 1;
512 bg->show(bg);
513
514 table = elm_table_new(win);
515 table->expand_x = 1;
516 table->expand_y = 1;
517
518 button = elm_button_new(win);
519 button->text_set(button, "Button 1");
520 table->pack(table, button, 0, 0, 1, 1);
521 button->fill_x = 0;
522 button->fill_y = 0;
523 button->show(button);
524 elm_widget_sizing_update(button);
525 button->cb_add(button, ELM_CB_ACTIVATED, on_button_activate, NULL);
526
527 button = elm_button_new(win);
528 button->text_set(button, "Button 2");
529 table->pack(table, button, 1, 0, 1, 1);
530 button->fill_x = 0;
531 button->fill_y = 0;
532 button->show(button);
533 elm_widget_sizing_update(button);
534 button->cb_add(button, ELM_CB_ACTIVATED, on_button_activate, NULL);
535
536 button = elm_button_new(win);
537 button->text_set(button, "Button 3");
538 table->pack(table, button, 2, 0, 1, 1);
539 button->fill_x = 0;
540 button->fill_y = 0;
541 button->show(button);
542 elm_widget_sizing_update(button);
543 button->cb_add(button, ELM_CB_ACTIVATED, on_button_activate, NULL);
544
545 button = elm_button_new(win);
546 button->text_set(button, "Button 4");
547 table->pack(table, button, 0, 1, 1, 1);
548 button->fill_x = 1;
549 button->fill_y = 0;
550 button->show(button);
551 elm_widget_sizing_update(button);
552 button->cb_add(button, ELM_CB_ACTIVATED, on_button_activate, NULL);
553
554 button = elm_button_new(win);
555 icon = elm_icon_new(win);
556 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
557 icon->file_set(icon, buf, NULL);
558 icon->scale_up = 0;
559 icon->layout_update(icon);
560 button->child_add(button, icon);
561 table->pack(table, button, 1, 1, 2, 1);
562 button->fill_x = 1;
563 button->fill_y = 1;
564 button->show(button);
565 elm_widget_sizing_update(button);
566 button->cb_add(button, ELM_CB_ACTIVATED, on_button_activate, NULL);
567
568 button = elm_button_new(win);
569 button->text_set(button, "Button 6");
570 icon = elm_icon_new(win);
571 snprintf(buf, sizeof(buf), "%s/images/logo.png", PACKAGE_DATA_DIR);
572 icon->file_set(icon, buf, NULL);
573 button->child_add(button, icon);
574 table->pack(table, button, 0, 2, 3, 1);
575 button->fill_x = 1;
576 button->fill_y = 1;
577 button->show(button);
578 elm_widget_sizing_update(button);
579 button->cb_add(button, ELM_CB_ACTIVATED, on_button_activate, NULL);
580
581 elm_widget_sizing_update(table);
582 table->show(table);
583
584 win->show(win);
585}
586
587static void
588on_toggle_changed(void *data, Elm_Toggle *tg, Elm_Cb_Type type, void *info)
589{
590 printf("toggle: %i\n", tg->state);
591}
592
593static void
594win_box_vert_of_toggles(void)
595{
596 Elm_Win *win;
597 Elm_Bg *bg;
598 Elm_Box *box;
599 Elm_Toggle *toggle;
600 Elm_Icon *icon;
601 char buf[PATH_MAX];
602
603 win = elm_win_new();
604 win->name_set(win, "win_bg");
605 win->title_set(win, "Simple Window with box + toggles setting min size");
606 win->autodel = 0;
607 win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
608 win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);
609
610 bg = elm_bg_new(win);
611 bg->expand_x = 0;
612 bg->expand_y = 0;
613 bg->show(bg);
614
615 box = elm_box_new(win);
616 box->expand_x = 0;
617 box->expand_y = 0;
618
619 toggle = elm_toggle_new(win);
620 toggle->text_set(toggle, "Label ON/OFF");
621 toggle->state = 1;
622 toggle->layout_update(toggle);
623 toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
624 box->pack_end(box, toggle);
625 toggle->show(toggle);
626 toggle->expand_y = 0;
627 toggle->fill_y = 0;
628 elm_widget_sizing_update(toggle);
629
630 toggle = elm_toggle_new(win);
631 toggle->text_set(toggle, "Icon + Label ON/OFF");
632 icon = elm_icon_new(win);
633 snprintf(buf, sizeof(buf), "%s/images/logo.png", PACKAGE_DATA_DIR);
634 icon->file_set(icon, buf, NULL);
635 toggle->child_add(toggle, icon);
636 toggle->state = 1;
637 toggle->layout_update(toggle);
638 toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
639 box->pack_end(box, toggle);
640 toggle->show(toggle);
641 toggle->expand_y = 0;
642 toggle->fill_y = 0;
643 elm_widget_sizing_update(toggle);
644
645 toggle = elm_toggle_new(win);
646 toggle->text_set(toggle, NULL);
647 icon = elm_icon_new(win);
648 snprintf(buf, sizeof(buf), "%s/images/logo.png", PACKAGE_DATA_DIR);
649 icon->file_set(icon, buf, NULL);
650 toggle->child_add(toggle, icon);
651 toggle->state = 1;
652 toggle->layout_update(toggle);
653 toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
654 box->pack_end(box, toggle);
655 toggle->show(toggle);
656 toggle->expand_y = 0;
657 toggle->fill_y = 0;
658 elm_widget_sizing_update(toggle);
659
660 toggle = elm_toggle_new(win);
661 toggle->text_set(toggle, "Label Yes/No");
662 toggle->states_text_set(toggle, "Yes", "No");
663 toggle->state = 1;
664 toggle->layout_update(toggle);
665 toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
666 box->pack_end(box, toggle);
667 toggle->show(toggle);
668 toggle->expand_y = 0;
669 toggle->fill_y = 0;
670 elm_widget_sizing_update(toggle);
671
672 elm_widget_sizing_update(box);
673 box->show(box);
674
675 win->show(win);
676}
677
678static void
679win_scrollable_box_vert_of_toggles_and_buttons(void)
680{
681 Elm_Win *win;
682 Elm_Bg *bg;
683 Elm_Box *box;
684 Elm_Scroller *scroller;
685 Elm_Toggle *toggle;
686 Elm_Icon *icon;
687 Elm_Button *button;
688 Elm_Label *label;
689 char buf[PATH_MAX];
690
691 win = elm_win_new();
692 win->name_set(win, "win_bg");
693 win->title_set(win, "Simple Window with scroller + box + toggles + buttons");
694 win->autodel = 0;
695 win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
696 win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);
697
698 bg = elm_bg_new(win);
699 bg->expand_x = 1;
700 bg->expand_y = 1;
701 bg->show(bg);
702
703 scroller = elm_scroller_new(win);
704
705 box = elm_box_new(win);
706
707 toggle = elm_toggle_new(win);
708 toggle->text_set(toggle, "Label ON/OFF");
709 toggle->state = 1;
710 toggle->layout_update(toggle);
711 toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
712 box->pack_end(box, toggle);
713 toggle->show(toggle);
714 toggle->expand_y = 0;
715 toggle->fill_y = 0;
716 elm_widget_sizing_update(toggle);
717
718 toggle = elm_toggle_new(win);
719 toggle->text_set(toggle, "Icon + Label ON/OFF");
720 icon = elm_icon_new(win);
721 snprintf(buf, sizeof(buf), "%s/images/logo.png", PACKAGE_DATA_DIR);
722 icon->file_set(icon, buf, NULL);
723 toggle->child_add(toggle, icon);
724 toggle->state = 1;
725 toggle->layout_update(toggle);
726 toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
727 box->pack_end(box, toggle);
728 toggle->show(toggle);
729 toggle->expand_y = 0;
730 toggle->fill_y = 0;
731 elm_widget_sizing_update(toggle);
732
733 toggle = elm_toggle_new(win);
734 toggle->text_set(toggle, NULL);
735 icon = elm_icon_new(win);
736 snprintf(buf, sizeof(buf), "%s/images/logo.png", PACKAGE_DATA_DIR);
737 icon->file_set(icon, buf, NULL);
738 toggle->child_add(toggle, icon);
739 toggle->state = 1;
740 toggle->layout_update(toggle);
741 toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
742 box->pack_end(box, toggle);
743 toggle->show(toggle);
744 toggle->expand_y = 0;
745 toggle->fill_y = 0;
746 elm_widget_sizing_update(toggle);
747
748 toggle = elm_toggle_new(win);
749 toggle->text_set(toggle, "Label Yes/No");
750 toggle->states_text_set(toggle, "Yes", "No");
751 toggle->state = 1;
752 toggle->layout_update(toggle);
753 toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
754 box->pack_end(box, toggle);
755 toggle->show(toggle);
756 toggle->expand_y = 0;
757 toggle->fill_y = 0;
758 elm_widget_sizing_update(toggle);
759
760 toggle = elm_toggle_new(win);
761 toggle->text_set(toggle, "Toggle ");
762 toggle->states_text_set(toggle, "Up", "Down");
763 toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
764 box->pack_end(box, toggle);
765 toggle->show(toggle);
766 toggle->expand_y = 0;
767 toggle->fill_y = 0;
768 elm_widget_sizing_update(toggle);
769
770 toggle = elm_toggle_new(win);
771 toggle->text_set(toggle, "Toggle ");
772 toggle->states_text_set(toggle, "In", "Out");
773 toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
774 box->pack_end(box, toggle);
775 toggle->show(toggle);
776 toggle->expand_y = 0;
777 toggle->fill_y = 0;
778 elm_widget_sizing_update(toggle);
779
780 toggle = elm_toggle_new(win);
781 toggle->text_set(toggle, "Toggle ");
782 toggle->states_text_set(toggle, "Up", "Down");
783 toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
784 box->pack_end(box, toggle);
785 toggle->show(toggle);
786 toggle->expand_y = 0;
787 toggle->fill_y = 0;
788 elm_widget_sizing_update(toggle);
789
790 label = elm_label_new(win);
791 label->text_set(label,
792 "Hello world<br>"
793 "<br>"
794 "I am a label. I come here to temonstrate how to put<br>"
795 "text into a label, with newlines, even markup to test<br>"
796 "things like <b>bold text</b> where markup can be custom<br>"
797 "and extensible, defined by the theme's textbloxk style<br>"
798 "for the label.<br>"
799 "<br>"
800 "Note that the markup is html-like and things like newline<br>"
801 "chars and tab chars like stdout text are not valid text<br>"
802 "markup mechanisms. Use markup tags instead.<br>"
803 );
804 box->pack_end(box, label);
805 label->expand_y = 0;
806 label->fill_y = 0;
807 elm_widget_sizing_update(label);
808 label->show(label);
809
810 button = elm_button_new(win);
811 button->text_set(button, "Button 1");
812 box->pack_end(box, button);
813 button->expand_y = 0;
814 button->fill_y = 0;
815 button->show(button);
816 elm_widget_sizing_update(button);
817 button->cb_add(button, ELM_CB_ACTIVATED, on_button_activate, NULL);
818
819 button = elm_button_new(win);
820 button->text_set(button, "Button 2");
821 box->pack_end(box, button);
822 button->expand_y = 0;
823 button->fill_y = 0;
824 button->show(button);
825 elm_widget_sizing_update(button);
826 button->cb_add(button, ELM_CB_ACTIVATED, on_button_activate, NULL);
827
828 button = elm_button_new(win);
829 button->text_set(button, "Button 3");
830 box->pack_end(box, button);
831 button->expand_y = 0;
832 button->fill_y = 0;
833 button->show(button);
834 elm_widget_sizing_update(button);
835 button->cb_add(button, ELM_CB_ACTIVATED, on_button_activate, NULL);
836
837 scroller->child_add(scroller, box);
838
839 elm_widget_sizing_update(box);
840 box->show(box);
841
842 scroller->show(scroller);
843
844 win->size_req(win, NULL, 400, 320);
845
846 win->show(win);
847}
848
849static void
850on_clock_changed(void *data, Elm_Clock *cloc, Elm_Cb_Type type, void *info)
851{
852 printf("clock: %i:%i:%i\n", cloc->hrs, cloc->min, cloc->sec);
853}
854
855static void
856win_box_vert_of_clock_and_toggles(void)
857{
858 Elm_Win *win;
859 Elm_Bg *bg;
860 Elm_Box *box;
861 Elm_Toggle *toggle;
862 Elm_Clock *cloc;
863 Elm_Pad *pad;
864 Elm_Frame *frame;
865 char buf[PATH_MAX];
866
867 win = elm_win_new();
868 win->name_set(win, "win_bg");
869 win->title_set(win, "Simple Window with box + toggles setting min size");
870 win->autodel = 0;
871 win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
872 win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);
873
874 bg = elm_bg_new(win);
875 snprintf(buf, sizeof(buf), "%s/images/sky_04.jpg", PACKAGE_DATA_DIR);
876 bg->file_set(bg, buf, NULL);
877 bg->expand_x = 0;
878 bg->expand_y = 0;
879 bg->show(bg);
880
881 pad = elm_pad_new(win);
882 pad->expand_x = 0;
883 pad->expand_y = 0;
884 pad->show(pad);
885
886 frame = elm_frame_new(win);
887 pad->child_add(pad, frame);
888 frame->text_set(frame, "Time");
889 frame->expand_x = 0;
890 frame->expand_y = 0;
891 frame->show(frame);
892/*
893 pad = elm_pad_new(win);
894 frame->child_add(frame, pad);
895 pad->expand_x = 0;
896 pad->expand_y = 0;
897 pad->show(pad);
898*/
899 box = elm_box_new(win);
900// pad->child_add(pad, box);
901 frame->child_add(frame, box);
902 box->expand_x = 0;
903 box->expand_y = 0;
904
905 toggle = elm_toggle_new(win);
906 toggle->text_set(toggle, "Alarm");
907 toggle->states_text_set(toggle, "ON", "OFF");
908 toggle->state = 0;
909 toggle->layout_update(toggle);
910 toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
911 box->pack_end(box, toggle);
912 toggle->show(toggle);
913 toggle->expand_y = 0;
914 toggle->fill_y = 0;
915 elm_widget_sizing_update(toggle);
916
917 cloc = elm_clock_new(win);
918 cloc->expand_x = 0;
919 cloc->fill_x = 0;
920 cloc->edit = 1;
921 cloc->hrs = 6;
922 cloc->min = 54;
923 cloc->sec = 32;
924 cloc->time_update(cloc);
925 cloc->cb_add(cloc, ELM_CB_CHANGED, on_clock_changed, NULL);
926 box->pack_end(box, cloc);
927 elm_widget_sizing_update(cloc);
928 cloc->show(cloc);
929
930 cloc = elm_clock_new(win);
931 cloc->expand_x = 0;
932 cloc->fill_x = 0;
933 box->pack_end(box, cloc);
934 elm_widget_sizing_update(cloc);
935 cloc->show(cloc);
936
937 cloc = elm_clock_new(win);
938 cloc->am_pm = 0;
939 cloc->seconds = 1;
940 cloc->time_update(cloc);
941 cloc->expand_x = 0;
942 cloc->fill_x = 0;
943 box->pack_end(box, cloc);
944 elm_widget_sizing_update(cloc);
945 cloc->show(cloc);
946
947 cloc = elm_clock_new(win);
948 cloc->am_pm = 0;
949 cloc->seconds = 0;
950 cloc->time_update(cloc);
951 cloc->expand_x = 0;
952 cloc->fill_x = 0;
953 box->pack_end(box, cloc);
954 elm_widget_sizing_update(cloc);
955 cloc->show(cloc);
956
957/*
958 cloc = elm_clock_new(win);
959 cloc->am_pm = 1;
960 cloc->seconds = 0;
961 cloc->time_update(cloc);
962 cloc->expand_x = 0;
963 cloc->fill_x = 0;
964 box->pack_end(box, cloc);
965 elm_widget_sizing_update(cloc);
966 cloc->show(cloc);
967 */
968
969 elm_widget_sizing_update(box);
970 box->show(box);
971
972 win->show(win);
973}
974
975int
976main(int argc, char **argv)
977{
978 /* init Elementary (all Elementary calls begin with elm_ and all data
979 * types, enums and macros will be Elm_ and ELM_ etc.) */
980 elm_init(argc, argv);
981
982 /* setup some windows with test widgets in them */
983 win_bg_simple();
984 win_bg_image();
985 win_scrollable_label();
986 win_label_determines_min_size();
987 win_box_vert_of_labels();
988 win_scrollable_box_vert_of_labels();
989 win_table_of_labels();
990 win_table_of_buttons();
991 win_box_vert_of_toggles();
992 win_scrollable_box_vert_of_toggles_and_buttons();
993 win_box_vert_of_clock_and_toggles();
994
995 elm_run(); /* and run the program now and handle all events etc. */
996
997 elm_shutdown(); /* clean up and shut down */
998 return 0;
999}
diff --git a/src/lib/Elementary.h b/src/lib/Elementary.h
new file mode 100644
index 000000000..ae11da749
--- /dev/null
+++ b/src/lib/Elementary.h
@@ -0,0 +1,553 @@
1/*
2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3 */
4#ifndef ELEMENTARY_H
5#define ELEMENTARY_H
6
7/* What is this?
8 *
9 * This is a VERY SIMPLE toolkit - VERY SIMPLE. It is not meant for writing
10 * extensive applications. Small simple ones with simple needs. It is meant
11 * to make the programmers work almost brainless.
12 *
13 * I'm toying with backing this with etk or ewl - or not. right now I am
14 * unsure as some of the widgets will be faily complex edje creations. Do
15 * not consider any choices permanent - but the API should stay unbroken.
16 *
17 */
18
19#include "elementary_config.h"
20
21/* Standard headers for standard system calls etc. */
22#include <stdio.h>
23#include <stdlib.h>
24#include <unistd.h>
25#include <string.h>
26#include <sys/types.h>
27#include <sys/stat.h>
28#include <sys/time.h>
29#include <sys/param.h>
30#include <dlfcn.h>
31#include <math.h>
32#include <fnmatch.h>
33#include <limits.h>
34#include <ctype.h>
35#include <time.h>
36#include <dirent.h>
37#include <pwd.h>
38#include <grp.h>
39#include <glob.h>
40#include <locale.h>
41#include <libintl.h>
42#include <errno.h>
43#include <signal.h>
44#ifdef HAVE_ALLOCA_H
45#include <alloca.h>
46#endif
47
48/* EFL headers */
49#include <Evas.h>
50#include <Ecore.h>
51#include <Ecore_X.h>
52#include <Ecore_Evas.h>
53#include <Ecore_Job.h>
54#include <Ecore_Txt.h>
55#include <Ecore_File.h>
56#include <Eet.h>
57#include <Edje.h>
58
59/* allow usage from c++ */
60#ifdef __cplusplus
61extern "C" {
62#endif
63
64// FIXME: need to be able to enable/disable widgets
65// FIXME: need to determine scale from dpi
66 /* Types here */
67 typedef enum _Elm_Obj_Type
68 {
69 ELM_OBJ_OBJ,
70 ELM_OBJ_CB,
71 ELM_OBJ_WIDGET,
72 ELM_OBJ_WIN,
73 ELM_OBJ_BG,
74 ELM_OBJ_SCROLLER,
75 ELM_OBJ_LABEL,
76 ELM_OBJ_BOX,
77 ELM_OBJ_TABLE,
78 ELM_OBJ_BUTTON,
79 ELM_OBJ_ICON,
80 ELM_OBJ_TOGGLE,
81 ELM_OBJ_CLOCK,
82 ELM_OBJ_FRAME,
83 ELM_OBJ_PAD
84// ELM_OBJ_CHECK, // FIXME: do
85// ELM_OBJ_RADIO, // FIXME: do
86// ELM_OBJ_SEP, // FIXME: do (separator horiz or vert)
87// ELM_OBJ_EXPANDER // FIXME: do (like a paned but slides open/closed)
88// ELM_OBJ_SPIN, // FIXME: do
89// ELM_OBJ_SLIDER, // FIXME: do
90// ELM_OBJ_ENTRY, // FIXME: do
91// ELM_OBJ_EDITOR, // FIXME: do
92// ELM_OBJ_LISTITEM, // FIXME: do
93// ELM_OBJ_BUSY, // FIXME: do
94// // FIXME: list more widgets to do here like:
95// // CONTACT, SELECTOR, FILES, PREVIEW, SIGNALINFO, CALLINFO,
96// // CELLEDIT (csv - maybe later xls or some other cell format),
97// // COLORSEL, TACHO ...
98//
99// wrap other basic ecore things:
100// ELM_OBJ_TIMER,
101// ELM_OBJ_ANIMATOR,
102// ELM_OBJ_JOB,
103 } Elm_Obj_Type;
104
105 typedef enum _Elm_Cb_Type
106 {
107 ELM_CB_DEL,
108 ELM_CB_CHILD_ADD,
109 ELM_CB_CHILD_DEL,
110 ELM_CB_UNPARENT,
111 ELM_CB_PARENT,
112 ELM_CB_DEL_REQ,
113 ELM_CB_RESIZE,
114 ELM_CB_CHANGED,
115 ELM_CB_ACTIVATED
116 } Elm_Cb_Type;
117
118 typedef enum _Elm_Win_Type
119 {
120 ELM_WIN_BASIC,
121 ELM_WIN_DIALOG_BASIC
122 } Elm_Win_Type;
123
124 typedef struct _Elm_Obj_Class Elm_Obj_Class;
125 typedef struct _Elm_Obj Elm_Obj;
126 typedef struct _Elm_Cb_Class Elm_Cb_Class;
127 typedef struct _Elm_Cb Elm_Cb;
128 typedef struct _Elm_Win_Class Elm_Win_Class;
129 typedef struct _Elm_Win Elm_Win;
130 typedef struct _Elm_Widget_Class Elm_Widget_Class;
131 typedef struct _Elm_Widget Elm_Widget;
132 typedef struct _Elm_Bg_Class Elm_Bg_Class;
133 typedef struct _Elm_Bg Elm_Bg;
134 typedef struct _Elm_Scroller_Class Elm_Scroller_Class;
135 typedef struct _Elm_Scroller Elm_Scroller;
136 typedef struct _Elm_Label_Class Elm_Label_Class;
137 typedef struct _Elm_Label Elm_Label;
138 typedef struct _Elm_Box_Class Elm_Box_Class;
139 typedef struct _Elm_Box Elm_Box;
140 typedef struct _Elm_Table_Class Elm_Table_Class;
141 typedef struct _Elm_Table Elm_Table;
142 typedef struct _Elm_Button_Class Elm_Button_Class;
143 typedef struct _Elm_Button Elm_Button;
144 typedef struct _Elm_Icon_Class Elm_Icon_Class;
145 typedef struct _Elm_Icon Elm_Icon;
146 typedef struct _Elm_Toggle_Class Elm_Toggle_Class;
147 typedef struct _Elm_Toggle Elm_Toggle;
148 typedef struct _Elm_Clock_Class Elm_Clock_Class;
149 typedef struct _Elm_Clock Elm_Clock;
150 typedef struct _Elm_Frame_Class Elm_Frame_Class;
151 typedef struct _Elm_Frame Elm_Frame;
152 typedef struct _Elm_Pad_Class Elm_Pad_Class;
153 typedef struct _Elm_Pad Elm_Pad;
154
155 typedef void (*Elm_Cb_Func) (void *data, Elm_Obj *obj, Elm_Cb_Type type, void *info);
156
157 /* API calls here */
158
159/**************************************************************************/
160 /* General calls */
161 EAPI void elm_init(int argc, char **argv);
162 EAPI void elm_shutdown(void);
163 EAPI void elm_run(void);
164 EAPI void elm_exit(void);
165
166/**************************************************************************/
167 /* Generic Elm Object */
168#define Elm_Obj_Class_Methods \
169 void (*del) (Elm_Obj *obj); \
170 void (*ref) (Elm_Obj *obj); \
171 void (*unref) (Elm_Obj *obj); \
172 Elm_Cb *(*cb_add) (Elm_Obj *obj, Elm_Cb_Type type, Elm_Cb_Func func, void *data); \
173 void (*child_add) (Elm_Obj *obj, Elm_Obj *child); \
174 void (*unparent) (Elm_Obj *obj); \
175 int (*hastype) (Elm_Obj *obj, Elm_Obj_Type type)
176#define Elm_Obj_Class_All Elm_Obj_Class_Methods; \
177 Elm_Obj_Type type; \
178 void *clas; /* the obj class and parent classes */ \
179 Elm_Obj *parent; \
180 Evas_List *children; \
181 Evas_List *cbs; \
182 int refs; \
183 unsigned char delete_me : 1; \
184 unsigned char delete_deferred : 1
185
186 struct _Elm_Obj_Class
187 {
188 void *parent;
189 Elm_Obj_Type type;
190 Elm_Obj_Class_Methods;
191 };
192 struct _Elm_Obj
193 {
194 Elm_Obj_Class_All;
195 };
196#define ELM_OBJ(o) ((Elm_Obj *)o)
197
198/**************************************************************************/
199 /* Callback Object */
200#define Elm_Cb_Class_Methods
201#define Elm_Cb_Class_All Elm_Obj_Class_All; Elm_Cb_Class_Methods; \
202 Elm_Cb_Class_Methods; \
203 Elm_Cb_Type cb_type; \
204 Elm_Cb_Func func; \
205 void *data;
206 struct _Elm_Cb_Class
207 {
208 void *parent;
209 Elm_Obj_Type type;
210 Elm_Cb_Class_Methods;
211 };
212 struct _Elm_Cb
213 {
214 Elm_Cb_Class_All;
215 };
216
217/**************************************************************************/
218 /* Widget Object */
219#define Elm_Widget_Class_Methods \
220 void (*geom_set) (Elm_Widget *wid, int x, int y, int w, int h); \
221 void (*show) (Elm_Widget *wid); \
222 void (*hide) (Elm_Widget *wid); \
223 void (*size_alloc) (Elm_Widget *wid, int w, int h); \
224 void (*size_req) (Elm_Widget *wid, Elm_Widget *child, int w, int h); \
225 void (*above) (Elm_Widget *wid, Elm_Widget *above); \
226 void (*below) (Elm_Widget *wid, Elm_Widget *below)
227
228#define Elm_Widget_Class_All Elm_Obj_Class_All; Elm_Widget_Class_Methods; \
229 int x, y, w, h; \
230 struct { int w, h; } req; \
231 Evas_Object *base; \
232 double align_x, align_y; \
233 unsigned char expand_x : 1; \
234 unsigned char expand_y : 1; \
235 unsigned char fill_x : 1; \
236 unsigned char fill_y : 1
237
238 /* Object specific ones */
239 // FIXME: should this be a function or widget method call?
240 EAPI void elm_widget_sizing_update(Elm_Widget *wid);
241 struct _Elm_Widget_Class
242 {
243 void *parent;
244 Elm_Obj_Type type;
245 Elm_Widget_Class_Methods;
246 };
247 struct _Elm_Widget
248 {
249 Elm_Widget_Class_All;
250 };
251
252#ifdef __cplusplus
253}
254#endif
255
256/**************************************************************************/
257 /* Window Object */
258#define Elm_Win_Class_Methods \
259 void (*name_set) (Elm_Win *win, const char *name); \
260 void (*title_set) (Elm_Win *win, const char *title)
261// FIXME:
262// cover methods & state for:
263// type, fullscreen, icon, activate, shaped, alpha, borderless, iconified,
264// setting parent window (for dialogs)
265#define Elm_Win_Class_All Elm_Widget_Class_All; Elm_Win_Class_Methods; \
266 Elm_Win_Type win_type; \
267 const char *name; \
268 const char *title; \
269 unsigned char autodel : 1
270
271 /* Object specific ones */
272 EAPI Elm_Win *elm_win_new(void);
273 struct _Elm_Win_Class
274 {
275 void *parent;
276 Elm_Obj_Type type;
277 Elm_Win_Class_Methods;
278 };
279 struct _Elm_Win
280 {
281 Elm_Win_Class_All;
282
283 Ecore_Evas *ee; /* private */
284 Evas *evas; /* private */
285 Ecore_X_Window xwin; /* private */
286 Ecore_Job *deferred_resize_job; /* private */
287 Ecore_Job *deferred_child_eval_job; /* private */
288 unsigned char showme : 1; /* private */
289 };
290
291/**************************************************************************/
292 /* Background Object */
293#define Elm_Bg_Class_Methods \
294 void (*file_set) (Elm_Bg *bg, const char *file, const char *group);
295#define Elm_Bg_Class_All Elm_Widget_Class_All; Elm_Bg_Class_Methods; \
296 const char *file; \
297 const char *group
298
299 /* Object specific ones */
300 EAPI Elm_Bg *elm_bg_new(Elm_Win *win);
301 struct _Elm_Bg_Class
302 {
303 void *parent;
304 Elm_Obj_Type type;
305 Elm_Bg_Class_Methods;
306 };
307 struct _Elm_Bg
308 {
309 Elm_Bg_Class_All;
310
311 Evas_Object *custom_bg;
312 };
313
314/**************************************************************************/
315 /* Scroller (scrollframe/scrolledview) Object */
316#define Elm_Scroller_Class_Methods \
317 void (*file_set) (Elm_Scroller *scroller, const char *file, const char *group);
318#define Elm_Scroller_Class_All Elm_Widget_Class_All; Elm_Scroller_Class_Methods; \
319 const char *file; \
320 const char *group
321
322 /* Object specific ones */
323 EAPI Elm_Scroller *elm_scroller_new(Elm_Win *win);
324 struct _Elm_Scroller_Class
325 {
326 void *parent;
327 Elm_Obj_Type type;
328 Elm_Scroller_Class_Methods;
329 };
330 struct _Elm_Scroller
331 {
332 Elm_Scroller_Class_All;
333
334 Evas_Object *scroller_pan;
335 };
336
337/**************************************************************************/
338 /* Label Object */
339#define Elm_Label_Class_Methods \
340 void (*text_set) (Elm_Label *lb, const char *text)
341#define Elm_Label_Class_All Elm_Widget_Class_All; Elm_Label_Class_Methods; \
342 const char *text; \
343 int minw, minh
344
345 /* Object specific ones */
346 EAPI Elm_Label *elm_label_new(Elm_Win *win);
347 struct _Elm_Label_Class
348 {
349 void *parent;
350 Elm_Obj_Type type;
351 Elm_Label_Class_Methods;
352 };
353 struct _Elm_Label
354 {
355 Elm_Label_Class_All;
356 };
357
358/**************************************************************************/
359 /* Box Object */
360#define Elm_Box_Class_Methods \
361 void (*layout_update) (Elm_Box *bx); \
362 void (*pack_start) (Elm_Box *bx, Elm_Widget *wid); \
363 void (*pack_end) (Elm_Box *bx, Elm_Widget *wid); \
364 void (*pack_before) (Elm_Box *bx, Elm_Widget *wid, Elm_Widget *wid_before); \
365 void (*pack_after) (Elm_Box *bx, Elm_Widget *wid, Elm_Widget *wid_after);
366
367#define Elm_Box_Class_All Elm_Widget_Class_All; Elm_Box_Class_Methods; \
368 unsigned char horizontal : 1; \
369 unsigned char homogenous : 1
370
371 /* Object specific ones */
372 EAPI Elm_Box *elm_box_new(Elm_Win *win);
373 struct _Elm_Box_Class
374 {
375 void *parent;
376 Elm_Obj_Type type;
377 Elm_Box_Class_Methods;
378 };
379 struct _Elm_Box
380 {
381 Elm_Box_Class_All;
382 };
383
384/**************************************************************************/
385 /* Table Object */
386#define Elm_Table_Class_Methods \
387 void (*layout_update) (Elm_Table *tb); \
388 void (*pack) (Elm_Table *tb, Elm_Widget *wid, int x, int y, int w, int h)
389#define Elm_Table_Class_All Elm_Widget_Class_All; Elm_Table_Class_Methods; \
390 unsigned char homogenous : 1
391
392 /* Object specific ones */
393 EAPI Elm_Table *elm_table_new(Elm_Win *win);
394 struct _Elm_Table_Class
395 {
396 void *parent;
397 Elm_Obj_Type type;
398 Elm_Table_Class_Methods;
399 };
400 struct _Elm_Table
401 {
402 Elm_Table_Class_All;
403 };
404
405/**************************************************************************/
406 /* Button Object */
407#define Elm_Button_Class_Methods \
408 void (*text_set) (Elm_Button *bt, const char *text)
409#define Elm_Button_Class_All Elm_Widget_Class_All; Elm_Button_Class_Methods; \
410 const char *text; \
411 int minw, minh
412
413 /* Object specific ones */
414 EAPI Elm_Button *elm_button_new(Elm_Win *win);
415 struct _Elm_Button_Class
416 {
417 void *parent;
418 Elm_Obj_Type type;
419 Elm_Button_Class_Methods;
420 };
421 struct _Elm_Button
422 {
423 Elm_Button_Class_All;
424 };
425
426/**************************************************************************/
427 /* Icon Object */
428#define Elm_Icon_Class_Methods \
429 void (*file_set) (Elm_Icon *icon, const char *file, const char *group); \
430 void (*layout_update) (Elm_Icon *icon)
431#define Elm_Icon_Class_All Elm_Widget_Class_All; Elm_Icon_Class_Methods; \
432 unsigned char scale_up : 1; \
433 unsigned char scale_down : 1; \
434 unsigned char fill_outside : 1; \
435 unsigned char smooth : 1; \
436 unsigned char no_scale : 1; \
437 const char *file; \
438 const char *group
439
440 /* Object specific ones */
441 EAPI Elm_Icon *elm_icon_new(Elm_Win *win);
442 struct _Elm_Icon_Class
443 {
444 void *parent;
445 Elm_Obj_Type type;
446 Elm_Icon_Class_Methods;
447 };
448 struct _Elm_Icon
449 {
450 Elm_Icon_Class_All;
451 };
452
453/**************************************************************************/
454 /* Toggle Object */
455#define Elm_Toggle_Class_Methods \
456 void (*text_set) (Elm_Toggle *tg, const char *text); \
457 void (*layout_update) (Elm_Toggle *tg); \
458 void (*states_text_set) (Elm_Toggle *tg, const char *ontext, const char *offtext)
459#define Elm_Toggle_Class_All Elm_Widget_Class_All; Elm_Toggle_Class_Methods; \
460 const char *text; \
461 int minw, minh; \
462 int state; \
463 int *state_ptr
464
465 /* Object specific ones */
466 EAPI Elm_Toggle *elm_toggle_new(Elm_Win *win);
467 struct _Elm_Toggle_Class
468 {
469 void *parent;
470 Elm_Obj_Type type;
471 Elm_Toggle_Class_Methods;
472 };
473 struct _Elm_Toggle
474 {
475 Elm_Toggle_Class_All;
476 };
477
478/**************************************************************************/
479 /* Clock Object */
480#define Elm_Clock_Class_Methods \
481 void (*time_update) (Elm_Clock *ck)
482#define Elm_Clock_Class_All Elm_Widget_Class_All; Elm_Clock_Class_Methods; \
483 int hrs, min, sec; \
484 int minw, minh; \
485 unsigned char seconds : 1; \
486 unsigned char am_pm : 1; \
487 unsigned char edit : 1
488
489 /* Object specific ones */
490 EAPI Elm_Clock *elm_clock_new(Elm_Win *win);
491 struct _Elm_Clock_Class
492 {
493 void *parent;
494 Elm_Obj_Type type;
495 Elm_Clock_Class_Methods;
496 };
497 struct _Elm_Clock
498 {
499 Elm_Clock_Class_All;
500
501 Evas_Object *digit[6];
502 Evas_Object *ampm;
503 Ecore_Timer *ticker;
504 struct {
505 int hrs, min, sec;
506 char ampm;
507 char seconds;
508 char am_pm;
509 char edit;
510 } cur;
511 };
512
513/**************************************************************************/
514 /* Frame Object */
515#define Elm_Frame_Class_Methods \
516 void (*text_set) (Elm_Frame *fr, const char *text)
517#define Elm_Frame_Class_All Elm_Widget_Class_All; Elm_Frame_Class_Methods; \
518 const char *text; \
519 int minw, minh
520
521 /* Object specific ones */
522 EAPI Elm_Frame *elm_frame_new(Elm_Win *win);
523 struct _Elm_Frame_Class
524 {
525 void *parent;
526 Elm_Obj_Type type;
527 Elm_Frame_Class_Methods;
528 };
529 struct _Elm_Frame
530 {
531 Elm_Frame_Class_All;
532 };
533
534/**************************************************************************/
535 /* Pad Object */
536#define Elm_Pad_Class_Methods
537#define Elm_Pad_Class_All Elm_Widget_Class_All; Elm_Pad_Class_Methods; \
538 int minw, minh
539
540 /* Object specific ones */
541 EAPI Elm_Pad *elm_pad_new(Elm_Win *win);
542 struct _Elm_Pad_Class
543 {
544 void *parent;
545 Elm_Obj_Type type;
546 Elm_Pad_Class_Methods;
547 };
548 struct _Elm_Pad
549 {
550 Elm_Pad_Class_All;
551 };
552
553#endif
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
new file mode 100644
index 000000000..a420573ae
--- /dev/null
+++ b/src/lib/Makefile.am
@@ -0,0 +1,54 @@
1AUTOMAKE_OPTIONS = 1.4 foreign
2MAINTAINERCLEANFILES = Makefile.in
3
4AM_CPPFLAGS = \
5-I. \
6-I$(top_builddir) \
7-I$(top_srcdir) \
8-I$(top_srcdir)/src/lib \
9-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
10@ELEMENTARY_CFLAGS@
11
12lib_LTLIBRARIES = libelementary.la
13
14include_HEADERS = Elementary.h
15
16libelementary_la_SOURCES = \
17elm_priv.h \
18elm_main.c \
19elm_obj.c \
20elm_callback.c \
21elm_win.c \
22elm_theme.c \
23elm_widget.c \
24elm_bg.c \
25elm_scroller.c \
26elm_label.c \
27elm_box.c \
28elm_table.c \
29elm_button.c \
30elm_icon.c \
31elm_toggle.c \
32elm_clock.c \
33elm_frame.c \
34elm_pad.c \
35\
36els_pan.c \
37els_pan.h \
38els_scroller.c \
39els_scroller.h \
40els_box.c \
41els_box.h \
42els_table.c \
43els_table.h \
44els_icon.c \
45els_icon.h
46
47libelementary_la_CFLAGS =
48libelementary_la_LIBADD = @my_libs@ @ELEMENTARY_LIBS@
49libelementary_la_LDFLAGS = -version-info @version_info@
50libelementary_la_DEPENDENCIES = $(top_builddir)/elementary_config.h
51
52clean-local:
53 @rm -rf *.gcno
54
diff --git a/src/lib/elm_bg.c b/src/lib/elm_bg.c
new file mode 100644
index 000000000..0fef5fdd6
--- /dev/null
+++ b/src/lib/elm_bg.c
@@ -0,0 +1,99 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4static void _elm_bg_file_set(Elm_Bg *bg, const char *file, const char *group);
5static void _elm_bg_del(Elm_Bg *bg);
6
7Elm_Bg_Class _elm_bg_class =
8{
9 &_elm_widget_class,
10 ELM_OBJ_BG,
11 _elm_bg_file_set
12};
13
14static void
15_elm_bg_custom_resize(void *data, Evas *a, Evas_Object *obj, void *event_info)
16{
17 Elm_Bg *bg = data;
18 int iw = 0, ih = 0;
19 Evas_Coord x, y, w, h, ow = 0, oh = 0;
20
21 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
22 evas_object_image_size_get(obj, &iw, &ih);
23
24 if ((iw < 1) || (ih < 1)) return;
25 w = ow;
26 h = (ih * w) / iw;
27 if (h < oh)
28 {
29 h = oh;
30 w = (iw * h) / ih;
31 }
32 x = (ow - w) / 2;
33 y = (oh - h) / 2;
34 evas_object_image_fill_set(obj, x, y, w, h);
35}
36
37static void
38_elm_bg_file_set(Elm_Bg *bg, const char *file, const char *group)
39{
40 const char *p;
41
42 if (bg->custom_bg)
43 {
44 evas_object_del(bg->custom_bg);
45 bg->custom_bg = NULL;
46 }
47 if (!file) return;
48 if (bg->file) evas_stringshare_del(bg->file);
49 if (file) bg->file = evas_stringshare_add(file);
50 else bg->file = NULL;
51 if (bg->group) evas_stringshare_del(bg->group);
52 if (group) bg->group = evas_stringshare_add(group);
53 else bg->group = NULL;
54 if (((p = strrchr(file, '.'))) && (!strcasecmp(p, ".edj")))
55 {
56 bg->custom_bg = edje_object_add(evas_object_evas_get(bg->base));
57 edje_object_file_set(bg->custom_bg, file, group);
58 }
59 else
60 {
61 bg->custom_bg = evas_object_image_add(evas_object_evas_get(bg->base));
62 evas_object_event_callback_add(bg->custom_bg, EVAS_CALLBACK_RESIZE, _elm_bg_custom_resize, bg);
63 evas_object_image_file_set(bg->custom_bg, file, group);
64 }
65 evas_object_repeat_events_set(bg->custom_bg, 1);
66 edje_object_part_swallow(bg->base, "elm.swallow.background", bg->custom_bg);
67 evas_object_show(bg->custom_bg);
68}
69
70static void
71_elm_bg_del(Elm_Bg *bg)
72{
73 if (bg->custom_bg) evas_object_del(bg->custom_bg);
74 if (bg->group) evas_stringshare_del(bg->group);
75 if (bg->file) evas_stringshare_del(bg->file);
76 ((Elm_Obj_Class *)(((Elm_Bg_Class *)(bg->clas))->parent))->del(ELM_OBJ(bg));
77}
78
79EAPI Elm_Bg *
80elm_bg_new(Elm_Win *win)
81{
82 Elm_Bg *bg;
83
84 bg = ELM_NEW(Elm_Bg);
85
86 _elm_widget_init(bg);
87 bg->clas = &_elm_bg_class;
88 bg->type = ELM_OBJ_BG;
89
90 bg->del = _elm_bg_del;
91
92 bg->file_set = _elm_bg_file_set;
93
94 bg->base = edje_object_add(win->evas);
95 _elm_theme_set(bg->base, "bg", "bg");
96 _elm_widget_post_init(bg);
97 win->child_add(win, bg);
98 return bg;
99}
diff --git a/src/lib/elm_box.c b/src/lib/elm_box.c
new file mode 100644
index 000000000..0a3264880
--- /dev/null
+++ b/src/lib/elm_box.c
@@ -0,0 +1,131 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4static void _elm_box_layout_update(Elm_Box *bx);
5static void _elm_box_pack_start(Elm_Box *bx, Elm_Widget *wid);
6static void _elm_box_pack_end(Elm_Box *bx, Elm_Widget *wid);
7static void _elm_box_pack_before(Elm_Box *bx, Elm_Widget *wid, Elm_Widget *wid_before);
8static void _elm_box_pack_after(Elm_Box *bx, Elm_Widget *wid, Elm_Widget *wid_after);
9
10Elm_Box_Class _elm_box_class =
11{
12 &_elm_widget_class,
13 ELM_OBJ_SCROLLER,
14 _elm_box_layout_update,
15 _elm_box_pack_start,
16 _elm_box_pack_end,
17 _elm_box_pack_before,
18 _elm_box_pack_after
19};
20
21static void
22_elm_box_layout_update(Elm_Box *bx)
23{
24 _els_smart_box_orientation_set(bx->base, bx->horizontal);
25 _els_smart_box_homogenous_set(bx->base, bx->homogenous);
26}
27
28static void
29_elm_box_pack_start(Elm_Box *bx, Elm_Widget *wid)
30{
31 bx->child_add(bx, wid);
32 _els_smart_box_pack_start(bx->base, wid->base);
33}
34
35static void
36_elm_box_pack_end(Elm_Box *bx, Elm_Widget *wid)
37{
38 bx->child_add(bx, wid);
39 _els_smart_box_pack_end(bx->base, wid->base);
40}
41
42static void
43_elm_box_pack_before(Elm_Box *bx, Elm_Widget *wid, Elm_Widget *wid_before)
44{
45 bx->child_add(bx, wid);
46 _els_smart_box_pack_before(bx->base, wid->base, wid_before->base);
47}
48
49static void
50_elm_box_pack_after(Elm_Box *bx, Elm_Widget *wid, Elm_Widget *wid_after)
51{
52 bx->child_add(bx, wid);
53 _els_smart_box_pack_after(bx->base, wid->base, wid_after->base);
54}
55
56static void
57_elm_box_size_alloc(Elm_Box *bx, int w, int h)
58{
59 Evas_Coord mw, mh;
60
61 _els_smart_box_min_size_get(bx->base, &mw, &mh);
62 if (w < mw) w = mw;
63 if (h < mh) h = mh;
64 bx->req.w = w;
65 bx->req.h = h;
66}
67
68static void
69_elm_box_size_req(Elm_Box *bx, Elm_Widget *child, int w, int h)
70{
71 Evas_Coord mw, mh;
72
73 if (child)
74 {
75 Evas_Coord maxx, maxy;
76
77 child->size_alloc(child, 0, 0);
78 maxx = child->req.w;
79 maxy = child->req.h;
80 if (child->expand_x) maxx = 32767;
81 if (child->expand_y) maxy = 32767;
82 _els_smart_box_pack_options_set(child->base,
83 child->fill_x, child->fill_y,
84 child->expand_x, child->expand_y,
85 child->align_x, child->align_y,
86 child->req.w, child->req.h,
87 maxx, maxy);
88 }
89 else
90 {
91 // FIXME: handle.
92 }
93 _els_smart_box_min_size_get(bx->base, &mw, &mh);
94 ((Elm_Widget *)(bx->parent))->size_req(bx->parent, bx, mw, mh);
95 bx->geom_set(bx, bx->x, bx->y, mw, mh);
96}
97
98static void
99_elm_on_child_del(void *data, Elm_Box *bx, Elm_Cb_Type type, Elm_Obj *obj)
100{
101 if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
102 _els_smart_box_unpack(((Elm_Widget *)(obj))->base);
103}
104
105EAPI Elm_Box *
106elm_box_new(Elm_Win *win)
107{
108 Elm_Box *bx;
109
110 bx = ELM_NEW(Elm_Box);
111 _elm_widget_init(bx);
112
113 bx->clas = &_elm_box_class;
114 bx->type = ELM_OBJ_BOX;
115
116 bx->layout_update = _elm_box_layout_update;
117 bx->pack_start = _elm_box_pack_start;
118 bx->pack_end = _elm_box_pack_end;
119 bx->pack_before = _elm_box_pack_before;
120 bx->pack_after = _elm_box_pack_after;
121
122 bx->size_alloc = _elm_box_size_alloc;
123 bx->size_req = _elm_box_size_req;
124
125 bx->base = _els_smart_box_add(win->evas);
126
127 bx->cb_add(bx, ELM_CB_CHILD_DEL, _elm_on_child_del, NULL);
128 _elm_widget_post_init(bx);
129 win->child_add(win, bx);
130 return bx;
131}
diff --git a/src/lib/elm_button.c b/src/lib/elm_button.c
new file mode 100644
index 000000000..a63f5649f
--- /dev/null
+++ b/src/lib/elm_button.c
@@ -0,0 +1,170 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4static void _elm_button_text_set(Elm_Button *bt, const char *text);
5
6Elm_Button_Class _elm_button_class =
7{
8 &_elm_widget_class,
9 ELM_OBJ_BUTTON,
10 _elm_button_text_set
11};
12
13static void
14_elm_button_text_set(Elm_Button *bt, const char *text)
15{
16 Evas_Coord mw, mh;
17
18 if (text)
19 {
20 edje_object_signal_emit(bt->base, "elm,state,text,visible", "elm");
21 edje_object_message_signal_process(bt->base);
22 }
23 else
24 {
25 edje_object_signal_emit(bt->base, "elm,state,text,hidden", "elm");
26 edje_object_message_signal_process(bt->base);
27 }
28 edje_object_part_text_set(bt->base, "elm.text", text);
29 edje_object_size_min_calc(bt->base, &mw, &mh);
30 if ((bt->minw != mw) || (bt->minh != mh))
31 {
32 bt->minw = mw;
33 bt->minh = mh;
34 ((Elm_Widget *)(bt->parent))->size_req(bt->parent, bt, bt->minw, bt->minh);
35 bt->geom_set(bt, bt->x, bt->y, bt->minw, bt->minh);
36 }
37}
38
39static void
40_elm_button_size_alloc(Elm_Button *bt, int w, int h)
41{
42 if (w < bt->minw) w = bt->minw;
43 if (h < bt->minh) h = bt->minh;
44 bt->req.w = w;
45 bt->req.h = h;
46}
47
48static void
49_elm_button_size_req(Elm_Button *bt, Elm_Widget *child, int w, int h)
50{
51 Evas_Coord mw, mh;
52
53 if (child)
54 {
55 Evas_Coord maxx, maxy;
56
57 child->size_alloc(child, 0, 0);
58 maxx = child->req.w;
59 maxy = child->req.h;
60 if (child->expand_x) maxx = 32767;
61 if (child->expand_y) maxy = 32767;
62 edje_extern_object_min_size_set(child->base,
63 child->req.w,
64 child->req.h);
65 edje_object_part_swallow(bt->base , "elm.swallow.contents",
66 child->base);
67 edje_object_size_min_calc(bt->base, &mw, &mh);
68 if ((bt->minw != mw) || (bt->minh != mh))
69 {
70 bt->minw = mw;
71 bt->minh = mh;
72 ((Elm_Widget *)(bt->parent))->size_req(bt->parent, bt, mw, mh);
73 bt->geom_set(bt, bt->x, bt->y, mw, mh);
74 }
75 }
76 else
77 {
78 // FIXME: handle
79 }
80}
81
82static void
83_elm_on_child_add(void *data, Elm_Button *bt, Elm_Cb_Type type, Elm_Obj *obj)
84{
85 Evas_Coord mw, mh;
86
87 if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
88 edje_object_signal_emit(bt->base, "elm,state,icon,visible", "elm");
89 edje_object_message_signal_process(bt->base);
90 ((Elm_Widget *)(obj))->size_alloc(obj, 0, 0);
91 ((Elm_Widget *)(obj))->geom_set(obj,
92 ((Elm_Widget *)(obj))->x,
93 ((Elm_Widget *)(obj))->y,
94 ((Elm_Widget *)(obj))->req.w,
95 ((Elm_Widget *)(obj))->req.h);
96 edje_extern_object_min_size_set(((Elm_Widget *)(obj))->base,
97 ((Elm_Widget *)(obj))->req.w,
98 ((Elm_Widget *)(obj))->req.h);
99 edje_object_part_swallow(bt->base , "elm.swallow.contents",
100 ((Elm_Widget *)(obj))->base);
101 edje_object_size_min_calc(bt->base, &mw, &mh);
102 if ((bt->minw != mw) || (bt->minh != mh))
103 {
104 bt->minw = mw;
105 bt->minh = mh;
106 ((Elm_Widget *)(bt->parent))->size_req(bt->parent, bt, mw, mh);
107 bt->geom_set(bt, bt->x, bt->y, mw, mh);
108 }
109}
110
111static void
112_elm_on_child_del(void *data, Elm_Button *bt, Elm_Cb_Type type, Elm_Obj *obj)
113{
114 if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
115 // FIXME: allow for removal of child - size down
116 edje_object_signal_emit(bt->base, "elm,state,icon,hidden", "elm");
117 edje_object_message_signal_process(bt->base);
118}
119
120static void
121_elm_button_activate(Elm_Button *bt)
122{
123 _elm_obj_nest_push();
124 _elm_cb_call(ELM_OBJ(bt), ELM_CB_ACTIVATED, NULL);
125 _elm_obj_nest_pop();
126}
127
128static void
129_elm_signal_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
130{
131 Elm_Button *bt = data;
132
133 _elm_button_activate(bt);
134}
135
136static void
137_elm_button_del(Elm_Button *bt)
138{
139 if (bt->text) evas_stringshare_del(bt->text);
140 ((Elm_Obj_Class *)(((Elm_Button_Class *)(bt->clas))->parent))->del(ELM_OBJ(bt));
141}
142
143EAPI Elm_Button *
144elm_button_new(Elm_Win *win)
145{
146 Elm_Button *bt;
147
148 bt = ELM_NEW(Elm_Button);
149
150 _elm_widget_init(bt);
151 bt->clas = &_elm_button_class;
152 bt->type = ELM_OBJ_BUTTON;
153
154 bt->del = _elm_button_del;
155
156 bt->size_alloc = _elm_button_size_alloc;
157 bt->size_req = _elm_button_size_req;
158
159 bt->text_set = _elm_button_text_set;
160
161 bt->base = edje_object_add(win->evas);
162 _elm_theme_set(bt->base, "button", "button");
163 edje_object_signal_callback_add(bt->base, "elm,action,click", "",
164 _elm_signal_clicked, bt);
165 bt->cb_add(bt, ELM_CB_CHILD_ADD, _elm_on_child_add, NULL);
166 bt->cb_add(bt, ELM_CB_CHILD_DEL, _elm_on_child_del, NULL);
167 _elm_widget_post_init(bt);
168 win->child_add(win, bt);
169 return bt;
170}
diff --git a/src/lib/elm_callback.c b/src/lib/elm_callback.c
new file mode 100644
index 000000000..fb0137f12
--- /dev/null
+++ b/src/lib/elm_callback.c
@@ -0,0 +1,58 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4Elm_Cb_Class _elm_cb_class =
5{
6 &_elm_obj_class,
7 ELM_OBJ_CB
8};
9
10
11
12static void
13_elm_cb_del(Elm_Cb *cb)
14{
15 if (_elm_obj_del_defer(ELM_OBJ(cb))) return;
16 if (cb->parent) /* callbacks are special children */
17 {
18 cb->parent->cbs = evas_list_remove(cb->parent->cbs, cb);
19 cb->parent = NULL;
20 }
21 ((Elm_Obj_Class *)(((Elm_Cb_Class *)(cb->clas))->parent))->del(ELM_OBJ(cb));
22}
23
24Elm_Cb *
25_elm_cb_new(void)
26{
27 Elm_Cb *cb;
28
29 cb = ELM_NEW(Elm_Cb);
30 _elm_obj_init(ELM_OBJ(cb));
31 cb->clas = &_elm_cb_class;
32 cb->type = ELM_OBJ_CB;
33
34 cb->del = _elm_cb_del;
35
36 return cb;
37}
38
39void
40_elm_cb_call(Elm_Obj *obj, Elm_Cb_Type type, void *info)
41{
42 Evas_List *l;
43
44 _elm_obj_nest_push();
45 for (l = obj->cbs; l; l = l->next)
46 {
47 Elm_Cb *cb;
48
49 cb = l->data;
50 if (cb->delete_me) continue;
51 if (cb->cb_type == type)
52 {
53 if (cb->func) cb->func(cb->data, obj, type, info);
54 if (cb->cbs) _elm_cb_call(cb, type, info);
55 }
56 }
57 _elm_obj_nest_pop();
58}
diff --git a/src/lib/elm_clock.c b/src/lib/elm_clock.c
new file mode 100644
index 000000000..af968316b
--- /dev/null
+++ b/src/lib/elm_clock.c
@@ -0,0 +1,393 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4static void _elm_clock_time_update(Elm_Clock *ck);
5
6Elm_Clock_Class _elm_clock_class =
7{
8 &_elm_widget_class,
9 ELM_OBJ_CLOCK,
10 _elm_clock_time_update
11};
12
13
14static void
15_elm_clock_val_up(void *data, Evas_Object *obj, const char *emission, const char *source)
16{
17 Elm_Clock *ck = data;
18
19 if (!ck->edit) return;
20 if (obj == ck->digit[0])
21 {
22 ck->hrs = ck->hrs + 10;
23 if (ck->hrs >= 24) ck->hrs -= 24;
24 }
25 if (obj == ck->digit[1])
26 {
27 ck->hrs = ck->hrs + 1;
28 if (ck->hrs >= 24) ck->hrs -= 24;
29 }
30 if (obj == ck->digit[2])
31 {
32 ck->min = ck->min + 10;
33 if (ck->min >= 60) ck->min -= 60;
34 }
35 if (obj == ck->digit[3])
36 {
37 ck->min = ck->min + 1;
38 if (ck->min >= 60) ck->min -= 60;
39 }
40 if (obj == ck->digit[4])
41 {
42 ck->sec = ck->sec + 10;
43 if (ck->sec >= 60) ck->sec -= 60;
44 }
45 if (obj == ck->digit[5])
46 {
47 ck->sec = ck->sec + 1;
48 if (ck->sec >= 60) ck->sec -= 60;
49 }
50 if (obj == ck->ampm)
51 {
52 ck->hrs = ck->hrs + 12;
53 if (ck->hrs > 23) ck->hrs -= 24;
54 }
55 ck->time_update(ck);
56 _elm_obj_nest_push();
57 _elm_cb_call(ELM_OBJ(ck), ELM_CB_CHANGED, NULL);
58 _elm_obj_nest_pop();
59}
60
61static void
62_elm_clock_val_down(void *data, Evas_Object *obj, const char *emission, const char *source)
63{
64 Elm_Clock *ck = data;
65 if (!ck->edit) return;
66 if (obj == ck->digit[0])
67 {
68 ck->hrs = ck->hrs - 10;
69 if (ck->hrs < 0) ck->hrs += 24;
70 }
71 if (obj == ck->digit[1])
72 {
73 ck->hrs = ck->hrs - 1;
74 if (ck->hrs < 0) ck->hrs += 24;
75 }
76 if (obj == ck->digit[2])
77 {
78 ck->min = ck->min - 10;
79 if (ck->min < 0) ck->min += 60;
80 }
81 if (obj == ck->digit[3])
82 {
83 ck->min = ck->min - 1;
84 if (ck->min < 0) ck->min += 60;
85 }
86 if (obj == ck->digit[4])
87 {
88 ck->sec = ck->sec - 10;
89 if (ck->sec < 0) ck->sec += 60;
90 }
91 if (obj == ck->digit[5])
92 {
93 ck->sec = ck->sec - 1;
94 if (ck->sec < 0) ck->sec += 60;
95 }
96 if (obj == ck->ampm)
97 {
98 ck->hrs = ck->hrs - 12;
99 if (ck->hrs < 0) ck->hrs += 24;
100 }
101 ck->time_update(ck);
102 _elm_obj_nest_push();
103 _elm_cb_call(ELM_OBJ(ck), ELM_CB_CHANGED, NULL);
104 _elm_obj_nest_pop();
105}
106
107static void
108_elm_clock_time_update(Elm_Clock *ck)
109{
110 Edje_Message_Int msg;
111 int ampm = 0;
112
113 if ((ck->cur.seconds != ck->seconds) || (ck->cur.am_pm != ck->am_pm) ||
114 (ck->cur.edit != ck->edit))
115 {
116 int i;
117 Evas_Coord mw, mh;
118
119 for (i = 0; i < 6; i++)
120 {
121 if (ck->digit[i])
122 {
123 evas_object_del(ck->digit[i]);
124 ck->digit[i] = NULL;
125 }
126 }
127 if (ck->ampm)
128 {
129 evas_object_del(ck->ampm);
130 ck->ampm = NULL;
131 }
132
133 if ((ck->seconds) && (ck->am_pm))
134 _elm_theme_set(ck->base, "clock", "clock/all");
135 else if (ck->seconds)
136 _elm_theme_set(ck->base, "clock", "clock/seconds");
137 else if (ck->am_pm)
138 _elm_theme_set(ck->base, "clock", "clock/am_pm");
139 else
140 _elm_theme_set(ck->base, "clock", "clock");
141
142 for (i = 0; i < 6; i++)
143 {
144 char buf[16];
145
146 if ((!ck->seconds) && (i >= 4)) break;
147 ck->digit[i] = edje_object_add(evas_object_evas_get(ck->base));
148 _elm_theme_set(ck->digit[i], "clock", "flipdigit");
149 if (ck->edit)
150 edje_object_signal_emit(ck->digit[i], "elm,state,edit,on", "elm");
151 edje_object_signal_callback_add(ck->digit[i], "elm,action,up", "",
152 _elm_clock_val_up, ck);
153 edje_object_signal_callback_add(ck->digit[i], "elm,action,down", "",
154 _elm_clock_val_down, ck);
155 edje_object_size_min_calc(ck->digit[i], &mw, &mh);
156 edje_extern_object_min_size_set(ck->digit[i], mw, mh);
157 snprintf(buf, sizeof(buf), "d%i", i);
158 edje_object_part_swallow(ck->base , buf, ck->digit[i]);
159 evas_object_show(ck->digit[i]);
160 }
161 if (ck->am_pm)
162 {
163 ck->ampm = edje_object_add(evas_object_evas_get(ck->base));
164 _elm_theme_set(ck->ampm, "clock", "flipampm");
165 if (ck->edit)
166 edje_object_signal_emit(ck->ampm, "elm,state,edit,on", "elm");
167 edje_object_signal_callback_add(ck->ampm, "elm,action,up", "",
168 _elm_clock_val_up, ck);
169 edje_object_signal_callback_add(ck->ampm, "elm,action,down", "",
170 _elm_clock_val_down, ck);
171 edje_object_size_min_calc(ck->ampm, &mw, &mh);
172 edje_extern_object_min_size_set(ck->ampm, mw, mh);
173 edje_object_part_swallow(ck->base , "ampm", ck->ampm);
174 evas_object_show(ck->ampm);
175 }
176
177 edje_object_size_min_calc(ck->base, &mw, &mh);
178 ck->minw = mw;
179 ck->minh = mh;
180
181 ck->cur.hrs = 0;
182 ck->cur.min = 0;
183 ck->cur.sec = 0;
184 ck->cur.ampm = -1;
185 ck->cur.seconds = ck->seconds;
186 ck->cur.am_pm = ck->am_pm;
187 ck->cur.edit = ck->edit;
188 }
189 if (ck->hrs != ck->cur.hrs)
190 {
191 int hrs;
192 int d1, d2, dc1, dc2;
193
194 hrs = ck->hrs;
195 if (ck->am_pm)
196 {
197 if (hrs >= 12)
198 {
199 if (hrs > 12) hrs -= 12;
200 ampm = 1;
201 }
202 else if (hrs == 0) hrs = 12;
203 }
204 d1 = hrs / 10;
205 d2 = hrs % 10;
206 dc1 = ck->cur.hrs / 10;
207 dc2 = ck->cur.hrs % 10;
208 if (d1 != dc1)
209 {
210 msg.val = d1;
211 edje_object_message_send(ck->digit[0], EDJE_MESSAGE_INT, 1, &msg);
212 }
213 if (d2 != dc2)
214 {
215 msg.val = d2;
216 edje_object_message_send(ck->digit[1], EDJE_MESSAGE_INT, 1, &msg);
217 }
218 ck->cur.hrs = hrs;
219 }
220 if (ck->min != ck->cur.min)
221 {
222 int d1, d2, dc1, dc2;
223
224 d1 = ck->min / 10;
225 d2 = ck->min % 10;
226 dc1 = ck->cur.min / 10;
227 dc2 = ck->cur.min % 10;
228 if (d1 != dc1)
229 {
230 msg.val = d1;
231 edje_object_message_send(ck->digit[2], EDJE_MESSAGE_INT, 1, &msg);
232 }
233 if (d2 != dc2)
234 {
235 msg.val = d2;
236 edje_object_message_send(ck->digit[3], EDJE_MESSAGE_INT, 1, &msg);
237 }
238 ck->cur.min = ck->min;
239 }
240 if (ck->seconds)
241 {
242 if (ck->sec != ck->cur.sec)
243 {
244 int d1, d2, dc1, dc2;
245
246 d1 = ck->sec / 10;
247 d2 = ck->sec % 10;
248 dc1 = ck->cur.sec / 10;
249 dc2 = ck->cur.sec % 10;
250 if (d1 != dc1)
251 {
252 msg.val = d1;
253 edje_object_message_send(ck->digit[4], EDJE_MESSAGE_INT, 1, &msg);
254 }
255 if (d2 != dc2)
256 {
257 msg.val = d2;
258 edje_object_message_send(ck->digit[5], EDJE_MESSAGE_INT, 1, &msg);
259 }
260 ck->cur.sec = ck->sec;
261 }
262 }
263 else
264 ck->cur.sec = -1;
265
266 if (ck->am_pm)
267 {
268 if (ck->hrs >= 12) ampm = 1;
269 if (ampm != ck->cur.ampm)
270 {
271 int d1, d2, dc1, dc2;
272
273 if (ck->cur.ampm != ampm)
274 {
275 msg.val = ampm;
276 edje_object_message_send(ck->ampm, EDJE_MESSAGE_INT, 1, &msg);
277 }
278 ck->cur.ampm = ampm;
279 }
280 }
281 else
282 ck->cur.ampm = -1;
283}
284
285static void
286_elm_clock_size_alloc(Elm_Clock *ck, int w, int h)
287{
288 Evas_Coord mw, mh;
289
290 if (w < ck->minw) w = ck->minw;
291 if (h < ck->minh) h = ck->minh;
292 ck->req.w = w;
293 ck->req.h = h;
294}
295
296static void
297_elm_clock_size_req(Elm_Clock *ck, Elm_Widget *child, int w, int h)
298{
299 if (child)
300 {
301 }
302 else
303 {
304 // FIXME: handle
305 }
306}
307
308static void
309_elm_clock_activate(Elm_Clock *ck)
310{
311 _elm_obj_nest_push();
312 _elm_cb_call(ELM_OBJ(ck), ELM_CB_ACTIVATED, NULL);
313 _elm_obj_nest_pop();
314}
315
316static void
317_elm_clock_del(Elm_Clock *ck)
318{
319 int i;
320
321 for (i = 0; i < 6; i++)
322 {
323 if (ck->digit[i]) evas_object_del(ck->digit[i]);
324 }
325 if (ck->ampm) evas_object_del(ck->ampm);
326 if (ck->ticker) ecore_timer_del(ck->ticker);
327 ((Elm_Obj_Class *)(((Elm_Clock_Class *)(ck->clas))->parent))->del(ELM_OBJ(ck));
328}
329
330static int
331_elm_clock_ticker(Elm_Clock *ck)
332{
333 double t;
334 struct timeval timev;
335 struct tm *tm;
336 time_t tt;
337
338 gettimeofday(&timev, NULL);
339 t = ((double)(1000000 - timev.tv_usec)) / 1000000.0;
340 ck->ticker = ecore_timer_add(t, _elm_clock_ticker, ck);
341 if (!ck->edit)
342 {
343 tt = (time_t)(timev.tv_sec);
344 tzset();
345 tm = localtime(&tt);
346 if (tm)
347 {
348 ck->hrs = tm->tm_hour;
349 ck->min = tm->tm_min;
350 ck->sec = tm->tm_sec;
351 ck->time_update(ck);
352 }
353 }
354 return 0;
355}
356
357EAPI Elm_Clock *
358elm_clock_new(Elm_Win *win)
359{
360 Elm_Clock *ck;
361
362 ck = ELM_NEW(Elm_Clock);
363
364 _elm_widget_init(ck);
365 ck->clas = &_elm_clock_class;
366 ck->type = ELM_OBJ_CLOCK;
367
368 ck->del = _elm_clock_del;
369
370 ck->size_alloc = _elm_clock_size_alloc;
371 ck->size_req = _elm_clock_size_req;
372
373 ck->time_update = _elm_clock_time_update;
374
375 ck->seconds = 1;
376 ck->am_pm = 1;
377
378 ck->cur.hrs = 0;
379 ck->cur.min = 0;
380 ck->cur.sec = 0;
381 ck->cur.ampm = -1;
382 ck->cur.seconds = -1;
383 ck->cur.am_pm = -1;
384 ck->cur.edit = -1;
385
386 ck->base = edje_object_add(win->evas);
387
388 _elm_clock_ticker(ck);
389
390 _elm_widget_post_init(ck);
391 win->child_add(win, ck);
392 return ck;
393}
diff --git a/src/lib/elm_frame.c b/src/lib/elm_frame.c
new file mode 100644
index 000000000..458573d36
--- /dev/null
+++ b/src/lib/elm_frame.c
@@ -0,0 +1,138 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4static void _elm_frame_text_set(Elm_Frame *fr, const char *text);
5
6Elm_Frame_Class _elm_frame_class =
7{
8 &_elm_widget_class,
9 ELM_OBJ_FRAME,
10 _elm_frame_text_set
11};
12
13static void
14_elm_frame_text_set(Elm_Frame *fr, const char *text)
15{
16 Evas_Coord mw, mh;
17
18 edje_object_part_text_set(fr->base, "elm.text", text);
19 edje_object_size_min_calc(fr->base, &mw, &mh);
20 if ((fr->minw != mw) || (fr->minh != mh))
21 {
22 fr->minw = mw;
23 fr->minh = mh;
24 ((Elm_Widget *)(fr->parent))->size_req(fr->parent, fr, fr->minw, fr->minh);
25 fr->geom_set(fr, fr->x, fr->y, fr->minw, fr->minh);
26 }
27}
28
29static void
30_elm_frame_size_alloc(Elm_Frame *fr, int w, int h)
31{
32 if (w < fr->minw) w = fr->minw;
33 if (h < fr->minh) h = fr->minh;
34 fr->req.w = w;
35 fr->req.h = h;
36}
37
38static void
39_elm_frame_size_req(Elm_Frame *fr, Elm_Widget *child, int w, int h)
40{
41 Evas_Coord mw, mh;
42
43 if (child)
44 {
45 Evas_Coord maxx, maxy;
46
47 child->size_alloc(child, 0, 0);
48 maxx = child->req.w;
49 maxy = child->req.h;
50 if (child->expand_x) maxx = 32767;
51 if (child->expand_y) maxy = 32767;
52 edje_extern_object_min_size_set(child->base,
53 child->req.w,
54 child->req.h);
55 edje_object_part_swallow(fr->base , "elm.swallow.content",
56 child->base);
57 edje_object_size_min_calc(fr->base, &mw, &mh);
58 if ((fr->minw != mw) || (fr->minh != mh))
59 {
60 fr->minw = mw;
61 fr->minh = mh;
62 ((Elm_Widget *)(fr->parent))->size_req(fr->parent, fr, mw, mh);
63 fr->geom_set(fr, fr->x, fr->y, mw, mh);
64 }
65 }
66 else
67 {
68 // FIXME: handle
69 }
70}
71
72static void
73_elm_on_child_add(void *data, Elm_Frame *fr, Elm_Cb_Type type, Elm_Obj *obj)
74{
75 Evas_Coord mw, mh;
76
77 if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
78 ((Elm_Widget *)(obj))->size_alloc(obj, 0, 0);
79 ((Elm_Widget *)(obj))->geom_set(obj,
80 ((Elm_Widget *)(obj))->x,
81 ((Elm_Widget *)(obj))->y,
82 ((Elm_Widget *)(obj))->req.w,
83 ((Elm_Widget *)(obj))->req.h);
84 edje_extern_object_min_size_set(((Elm_Widget *)(obj))->base,
85 ((Elm_Widget *)(obj))->req.w,
86 ((Elm_Widget *)(obj))->req.h);
87 edje_object_part_swallow(fr->base , "elm.swallow.content",
88 ((Elm_Widget *)(obj))->base);
89 edje_object_size_min_calc(fr->base, &mw, &mh);
90 if ((fr->minw != mw) || (fr->minh != mh))
91 {
92 fr->minw = mw;
93 fr->minh = mh;
94 ((Elm_Widget *)(fr->parent))->size_req(fr->parent, fr, mw, mh);
95 fr->geom_set(fr, fr->x, fr->y, mw, mh);
96 }
97}
98
99static void
100_elm_on_child_del(void *data, Elm_Frame *fr, Elm_Cb_Type type, Elm_Obj *obj)
101{
102 if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
103 // FIXME: allow for removal of child - size down
104}
105
106static void
107_elm_frame_del(Elm_Frame *fr)
108{
109 if (fr->text) evas_stringshare_del(fr->text);
110 ((Elm_Obj_Class *)(((Elm_Frame_Class *)(fr->clas))->parent))->del(ELM_OBJ(fr));
111}
112
113EAPI Elm_Frame *
114elm_frame_new(Elm_Win *win)
115{
116 Elm_Frame *fr;
117
118 fr = ELM_NEW(Elm_Frame);
119
120 _elm_widget_init(fr);
121 fr->clas = &_elm_frame_class;
122 fr->type = ELM_OBJ_FRAME;
123
124 fr->del = _elm_frame_del;
125
126 fr->size_alloc = _elm_frame_size_alloc;
127 fr->size_req = _elm_frame_size_req;
128
129 fr->text_set = _elm_frame_text_set;
130
131 fr->base = edje_object_add(win->evas);
132 _elm_theme_set(fr->base, "frame", "frame");
133 fr->cb_add(fr, ELM_CB_CHILD_ADD, _elm_on_child_add, NULL);
134 fr->cb_add(fr, ELM_CB_CHILD_DEL, _elm_on_child_del, NULL);
135 _elm_widget_post_init(fr);
136 win->child_add(win, fr);
137 return fr;
138}
diff --git a/src/lib/elm_icon.c b/src/lib/elm_icon.c
new file mode 100644
index 000000000..37c5ea11e
--- /dev/null
+++ b/src/lib/elm_icon.c
@@ -0,0 +1,103 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4static void _elm_icon_file_set(Elm_Icon *icon, const char *file, const char *group);
5static void _elm_icon_layout_update(Elm_Icon *icon);
6
7Elm_Icon_Class _elm_icon_class =
8{
9 &_elm_widget_class,
10 ELM_OBJ_ICON,
11 _elm_icon_file_set,
12 _elm_icon_layout_update
13};
14
15static void
16_elm_icon_file_set(Elm_Icon *icon, const char *file, const char *group)
17{
18 const char *p;
19
20 if (!file) return;
21 if (icon->file) evas_stringshare_del(icon->file);
22 if (file) icon->file = evas_stringshare_add(file);
23 else icon->file = NULL;
24 if (icon->group) evas_stringshare_del(icon->group);
25 if (group) icon->group = evas_stringshare_add(group);
26 else icon->group = NULL;
27 if (((p = strrchr(file, '.'))) && (!strcasecmp(p, ".edj")))
28 _els_smart_icon_file_edje_set(icon->base, file, group);
29 else
30 _els_smart_icon_file_key_set(icon->base, file, group);
31 icon->layout_update(icon);
32}
33
34static void
35_elm_icon_layout_update(Elm_Icon *icon)
36{
37 _els_smart_icon_scale_up_set(icon->base, icon->scale_up);
38 _els_smart_icon_scale_down_set(icon->base, icon->scale_down);
39 _els_smart_icon_smooth_scale_set(icon->base, icon->smooth);
40 _els_smart_icon_fill_inside_set(icon->base, !(icon->fill_outside));
41 if (icon->no_scale) _els_smart_icon_scale_set(icon->base, 1.0);
42 else _els_smart_icon_scale_set(icon->base, _elm_config->scale);
43 if ((!icon->scale_down) || (!icon->scale_up))
44 ((Elm_Widget *)(icon->parent))->size_req(icon->parent, icon, 0, 0);
45}
46
47static void
48_elm_icon_size_alloc(Elm_Icon *icon, int w, int h)
49{
50 int tw, th;
51
52 _els_smart_icon_size_get(icon->base, &tw, &th);
53 if (!icon->scale_down)
54 {
55 if (w < tw) w = tw;
56 if (h < th) h = th;
57 }
58 if (!icon->scale_up)
59 {
60 if (w > tw) w = tw;
61 if (h > th) h = th;
62 }
63 icon->req.w = w;
64 icon->req.h = h;
65}
66
67static void
68_elm_icon_del(Elm_Icon *icon)
69{
70 if (icon->group) evas_stringshare_del(icon->group);
71 if (icon->file) evas_stringshare_del(icon->file);
72 ((Elm_Obj_Class *)(((Elm_Icon_Class *)(icon->clas))->parent))->del(ELM_OBJ(icon));
73}
74
75EAPI Elm_Icon *
76elm_icon_new(Elm_Win *win)
77{
78 Elm_Icon *icon;
79
80 icon = ELM_NEW(Elm_Icon);
81
82 _elm_widget_init(icon);
83 icon->clas = &_elm_icon_class;
84 icon->type = ELM_OBJ_ICON;
85
86 icon->del = _elm_icon_del;
87
88 icon->size_alloc = _elm_icon_size_alloc;
89
90 icon->file_set = _elm_icon_file_set;
91 icon->layout_update = _elm_icon_layout_update;
92
93 icon->smooth = 1;
94 icon->scale_up = 1;
95 icon->scale_down = 1;
96
97 icon->base = _els_smart_icon_add(win->evas);
98 evas_object_repeat_events_set(icon->base, 1);
99
100 _elm_widget_post_init(icon);
101 win->child_add(win, icon);
102 return icon;
103}
diff --git a/src/lib/elm_label.c b/src/lib/elm_label.c
new file mode 100644
index 000000000..67bd64134
--- /dev/null
+++ b/src/lib/elm_label.c
@@ -0,0 +1,68 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4static void _elm_label_text_set(Elm_Label *lb, const char *text);
5
6Elm_Label_Class _elm_label_class =
7{
8 &_elm_widget_class,
9 ELM_OBJ_LABEL,
10 _elm_label_text_set
11};
12
13static void
14_elm_label_text_set(Elm_Label *lb, const char *text)
15{
16 Evas_Coord mw, mh;
17
18 if (lb->text) evas_stringshare_del(lb->text);
19 if (text) lb->text = evas_stringshare_add(text);
20 else lb->text = NULL;
21 edje_object_part_text_set(lb->base, "elm.text", text);
22 edje_object_size_min_calc(lb->base, &mw, &mh);
23 if ((lb->minw != mw) || (lb->minh != mh))
24 {
25 lb->minw = mw;
26 lb->minh = mh;
27 ((Elm_Widget *)(lb->parent))->size_req(lb->parent, lb, lb->minw, lb->minh);
28 lb->geom_set(lb, lb->x, lb->y, lb->minw, lb->minh);
29 }
30}
31
32static void
33_elm_label_size_alloc(Elm_Label *lb, int w, int h)
34{
35 lb->req.w = lb->minw;
36 lb->req.h = lb->minh;
37}
38
39static void
40_elm_label_del(Elm_Label *lb)
41{
42 if (lb->text) evas_stringshare_del(lb->text);
43 ((Elm_Obj_Class *)(((Elm_Label_Class *)(lb->clas))->parent))->del(ELM_OBJ(lb));
44}
45
46EAPI Elm_Label *
47elm_label_new(Elm_Win *win)
48{
49 Elm_Label *lb;
50
51 lb = ELM_NEW(Elm_Label);
52
53 _elm_widget_init(lb);
54 lb->clas = &_elm_label_class;
55 lb->type = ELM_OBJ_LABEL;
56
57 lb->del = _elm_label_del;
58
59 lb->size_alloc = _elm_label_size_alloc;
60
61 lb->text_set = _elm_label_text_set;
62
63 lb->base = edje_object_add(win->evas);
64 _elm_theme_set(lb->base, "label", "label");
65 _elm_widget_post_init(lb);
66 win->child_add(win, lb);
67 return lb;
68}
diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c
new file mode 100644
index 000000000..f919f2ad4
--- /dev/null
+++ b/src/lib/elm_main.c
@@ -0,0 +1,79 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4char *_elm_appname = NULL;
5Elm_Config *_elm_config = NULL;
6
7static int
8_elm_signal_exit(void *data, int ev_type, void *ev)
9{
10 elm_exit();
11 return 1;
12}
13
14EAPI void
15elm_init(int argc, char **argv)
16{
17 int i;
18
19 eet_init();
20 ecore_init();
21 ecore_app_args_set(argc, (const char **)argv);
22 ecore_file_init();
23 evas_init();
24 edje_init();
25 ecore_evas_init(); // FIXME: check errors
26
27 ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, _elm_signal_exit, NULL);
28
29 _elm_appname = strdup(ecore_file_file_get(argv[0]));
30
31 // FIXME: actually load config
32 _elm_config = ELM_NEW(Elm_Config);
33 _elm_config->engine = ELM_SOFTWARE_X11;
34 _elm_config->thumbscroll_enable = 1;
35 _elm_config->thumbscroll_threshhold = 24;
36 _elm_config->thumbscroll_momentum_threshhold = 100.0;
37 _elm_config->thumbscroll_friction = 1.0;
38 _elm_config->scale = 1.0;
39
40 if ((_elm_config->engine == ELM_SOFTWARE_X11) ||
41 (_elm_config->engine == ELM_SOFTWARE_16_X11) ||
42 (_elm_config->engine == ELM_XRENDER_X11) ||
43 (_elm_config->engine == ELM_OPENGL_X11))
44 {
45 int val;
46
47 ecore_x_init(NULL);
48 if (ecore_x_window_prop_card32_get(ecore_x_window_root_first_get(),
49 ecore_x_atom_get("ENLIGHTENMENT_SCALE"),
50 &val, 1))
51 _elm_config->scale = (double)val / 1000.0;
52 }
53
54}
55
56EAPI void
57elm_shutdown(void)
58{
59 free(_elm_config);
60 free(_elm_appname);
61 ecore_evas_shutdown();
62 edje_shutdown();
63 evas_shutdown();
64 ecore_file_shutdown();
65 ecore_shutdown();
66 eet_shutdown();
67}
68
69EAPI void
70elm_run(void)
71{
72 ecore_main_loop_begin();
73}
74
75EAPI void
76elm_exit(void)
77{
78 ecore_main_loop_quit();
79}
diff --git a/src/lib/elm_obj.c b/src/lib/elm_obj.c
new file mode 100644
index 000000000..37639a2ae
--- /dev/null
+++ b/src/lib/elm_obj.c
@@ -0,0 +1,177 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4static void _elm_obj_del(Elm_Obj *obj);
5static void _elm_obj_ref(Elm_Obj *obj);
6static void _elm_obj_unref(Elm_Obj *obj);
7static Elm_Cb *_elm_obj_cb_add(Elm_Obj *obj, Elm_Cb_Type type, Elm_Cb_Func func, void *data);
8static void _elm_obj_child_add(Elm_Obj *obj, Elm_Obj *child);
9static int _elm_obj_hastype(Elm_Obj *obj, Elm_Obj_Type type);
10
11Elm_Obj_Class _elm_obj_class =
12{
13 NULL, /* parent */
14 ELM_OBJ_OBJ,
15 _elm_obj_del,
16 _elm_obj_ref,
17 _elm_obj_unref,
18 _elm_obj_cb_add,
19 _elm_obj_child_add,
20
21};
22
23static int deferred_nest = 0;
24static Evas_List *deferred_deletions = NULL;
25
26static void
27_elm_obj_del(Elm_Obj *obj)
28{
29 if (_elm_obj_del_defer(obj)) return;
30 _elm_obj_unref(obj);
31}
32
33static void
34_elm_obj_ref(Elm_Obj *obj)
35{
36 obj->ref++;
37}
38
39static void
40_elm_obj_unref(Elm_Obj *obj)
41{
42 obj->ref--;
43 if (obj->ref > 0) return;
44 if (!obj->delete_me)
45 {
46 obj->del(obj);
47 return;
48 }
49 if (obj->parent)
50 obj->parent->children = evas_list_remove(obj->parent->children, obj);
51 while (obj->cbs)
52 {
53 ((Elm_Obj *)obj->cbs->data)->parent = NULL;
54 ((Elm_Obj *)obj->cbs->data)->del(obj->cbs->data);
55 obj->cbs = evas_list_remove_list(obj->cbs, obj->cbs);
56 }
57 while (obj->children)
58 {
59 _elm_cb_call(obj, ELM_CB_CHILD_DEL, obj->children->data);
60 ((Elm_Obj *)obj->children->data)->parent = NULL;
61 ((Elm_Obj *)obj->children->data)->del(obj->children->data);
62 obj->children = evas_list_remove_list(obj->children, obj->children);
63 }
64 free(obj);
65}
66
67static Elm_Cb *
68_elm_obj_cb_add(Elm_Obj *obj, Elm_Cb_Type type, Elm_Cb_Func func, void *data)
69{
70 Elm_Cb *cb;
71
72 cb = _elm_cb_new();
73 cb->cb_type = type;
74 cb->func = func;
75 cb->data = data;
76 cb->parent = obj;
77 obj->cbs = evas_list_append(obj->cbs, cb);
78}
79
80static void
81_elm_obj_child_add(Elm_Obj *obj, Elm_Obj *child)
82{
83 if (child->parent) child->unparent(child);
84 obj->children = evas_list_prepend(obj->children, child);
85 child->parent = obj;
86 _elm_obj_nest_push();
87 _elm_cb_call(obj, ELM_CB_CHILD_ADD, child);
88 _elm_cb_call(child, ELM_CB_PARENT, NULL);
89 _elm_obj_nest_pop();
90}
91
92static void
93_elm_obj_unparent(Elm_Obj *obj)
94{
95 Elm_Obj *parent;
96
97 parent = obj->parent;
98 obj->parent = NULL;
99 // FIXME: what if we are walking the children when we unparent?
100 parent->children = evas_list_remove(parent->children, obj);
101 _elm_obj_nest_push();
102 _elm_cb_call(parent, ELM_CB_CHILD_DEL, obj);
103 _elm_cb_call(obj, ELM_CB_UNPARENT, NULL);
104 _elm_obj_nest_pop();
105}
106
107static int
108_elm_obj_class_hastype(Elm_Obj_Class *clas, Elm_Obj_Type type)
109{
110 if (clas->type == type) return 1;
111 if (!clas->parent) return 0;
112 return _elm_obj_class_hastype(clas->parent, type);
113}
114
115static int
116_elm_obj_hastype(Elm_Obj *obj, Elm_Obj_Type type)
117{
118 if (obj->type == type) return 1;
119 if (obj->clas) return _elm_obj_class_hastype(obj->clas, type);
120 return 0;
121}
122
123void
124_elm_obj_init(Elm_Obj *obj)
125{
126 obj->del = _elm_obj_del;
127 obj->ref = _elm_obj_ref;
128 obj->unref = _elm_obj_unref;
129 obj->cb_add = _elm_obj_cb_add;
130 obj->child_add = _elm_obj_child_add;
131 obj->unparent = _elm_obj_unparent;
132 obj->hastype = _elm_obj_hastype;
133 obj->type = ELM_OBJ_OBJ;
134 obj->clas = &_elm_obj_class;
135 obj->refs = 1;
136}
137
138void
139_elm_obj_nest_push(void)
140{
141 deferred_nest++;
142}
143
144void
145_elm_obj_nest_pop(void)
146{
147 deferred_nest--;
148 if (deferred_nest > 0) return;
149 while (deferred_deletions)
150 {
151 ((Elm_Obj *)(deferred_deletions->data))->delete_deferred = 0;
152 ((Elm_Obj *)(deferred_deletions->data))->del(ELM_OBJ(deferred_deletions->data));
153 deferred_deletions = evas_list_remove_list(deferred_deletions, deferred_deletions);
154 }
155}
156
157int
158_elm_obj_del_defer(Elm_Obj *obj)
159{
160 if (obj->delete_deferred) return 1;
161 if (!obj->delete_me)
162 {
163 /* will never be called during a deferred delete */
164 obj->delete_me = 1;
165 _elm_obj_nest_push();
166 _elm_cb_call(obj, ELM_CB_DEL, NULL);
167 _elm_obj_nest_pop();
168 }
169 if (deferred_nest > 0)
170 {
171 /* mark to be deleted later */
172 obj->delete_deferred = 1;
173 deferred_deletions = evas_list_append(deferred_deletions, obj);
174 return 1;
175 }
176 return 0;
177}
diff --git a/src/lib/elm_pad.c b/src/lib/elm_pad.c
new file mode 100644
index 000000000..0513f4df5
--- /dev/null
+++ b/src/lib/elm_pad.c
@@ -0,0 +1,116 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4Elm_Pad_Class _elm_pad_class =
5{
6 &_elm_widget_class,
7 ELM_OBJ_PAD
8};
9
10static void
11_elm_pad_size_alloc(Elm_Pad *pd, int w, int h)
12{
13 if (w < pd->minw) w = pd->minw;
14 if (h < pd->minh) h = pd->minh;
15 pd->req.w = w;
16 pd->req.h = h;
17}
18
19static void
20_elm_pad_size_req(Elm_Pad *pd, Elm_Widget *child, int w, int h)
21{
22 Evas_Coord mw, mh;
23
24 if (child)
25 {
26 Evas_Coord maxx, maxy;
27
28 child->size_alloc(child, 0, 0);
29 maxx = child->req.w;
30 maxy = child->req.h;
31 if (child->expand_x) maxx = 32767;
32 if (child->expand_y) maxy = 32767;
33 edje_extern_object_min_size_set(child->base,
34 child->req.w,
35 child->req.h);
36 edje_object_part_swallow(pd->base , "elm.swallow.contents",
37 child->base);
38 edje_object_size_min_calc(pd->base, &mw, &mh);
39 if ((pd->minw != mw) || (pd->minh != mh))
40 {
41 pd->minw = mw;
42 pd->minh = mh;
43 ((Elm_Widget *)(pd->parent))->size_req(pd->parent, pd, mw, mh);
44 pd->geom_set(pd, pd->x, pd->y, mw, mh);
45 }
46 }
47 else
48 {
49 // FIXME: handle
50 }
51}
52
53static void
54_elm_on_child_add(void *data, Elm_Pad *pd, Elm_Cb_Type type, Elm_Obj *obj)
55{
56 Evas_Coord mw, mh;
57
58 if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
59 ((Elm_Widget *)(obj))->size_alloc(obj, 0, 0);
60 ((Elm_Widget *)(obj))->geom_set(obj,
61 ((Elm_Widget *)(obj))->x,
62 ((Elm_Widget *)(obj))->y,
63 ((Elm_Widget *)(obj))->req.w,
64 ((Elm_Widget *)(obj))->req.h);
65 edje_extern_object_min_size_set(((Elm_Widget *)(obj))->base,
66 ((Elm_Widget *)(obj))->req.w,
67 ((Elm_Widget *)(obj))->req.h);
68 edje_object_part_swallow(pd->base , "elm.swallow.content",
69 ((Elm_Widget *)(obj))->base);
70 edje_object_size_min_calc(pd->base, &mw, &mh);
71 if ((pd->minw != mw) || (pd->minh != mh))
72 {
73 pd->minw = mw;
74 pd->minh = mh;
75 ((Elm_Widget *)(pd->parent))->size_req(pd->parent, pd, mw, mh);
76 pd->geom_set(pd, pd->x, pd->y, mw, mh);
77 }
78}
79
80static void
81_elm_on_child_del(void *data, Elm_Pad *pd, Elm_Cb_Type type, Elm_Obj *obj)
82{
83 if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
84 // FIXME: allow for removal of child - size down
85}
86
87static void
88_elm_pad_del(Elm_Pad *pd)
89{
90 ((Elm_Obj_Class *)(((Elm_Pad_Class *)(pd->clas))->parent))->del(ELM_OBJ(pd));
91}
92
93EAPI Elm_Pad *
94elm_pad_new(Elm_Win *win)
95{
96 Elm_Pad *pd;
97
98 pd = ELM_NEW(Elm_Pad);
99
100 _elm_widget_init(pd);
101 pd->clas = &_elm_pad_class;
102 pd->type = ELM_OBJ_PAD;
103
104 pd->del = _elm_pad_del;
105
106 pd->size_alloc = _elm_pad_size_alloc;
107 pd->size_req = _elm_pad_size_req;
108
109 pd->base = edje_object_add(win->evas);
110 _elm_theme_set(pd->base, "pad", "pad");
111 pd->cb_add(pd, ELM_CB_CHILD_ADD, _elm_on_child_add, NULL);
112 pd->cb_add(pd, ELM_CB_CHILD_DEL, _elm_on_child_del, NULL);
113 _elm_widget_post_init(pd);
114 win->child_add(win, pd);
115 return pd;
116}
diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h
new file mode 100644
index 000000000..377847d16
--- /dev/null
+++ b/src/lib/elm_priv.h
@@ -0,0 +1,64 @@
1#ifndef ELM_PRIV_H
2#define ELM_PRIV_H
3
4#include "els_pan.h"
5#include "els_scroller.h"
6#include "els_box.h"
7#include "els_table.h"
8#include "els_icon.h"
9
10// FIXME: totally disorganised. clean this up!
11
12typedef enum _Elm_Engine
13{
14 ELM_SOFTWARE_X11,
15 ELM_SOFTWARE_FB,
16 ELM_SOFTWARE_16_X11,
17 ELM_XRENDER_X11,
18 ELM_OPENGL_X11
19} Elm_Engine;
20
21typedef struct _Elm_Config Elm_Config;
22
23struct _Elm_Config
24{
25 int engine;
26 int thumbscroll_enable;
27 int thumbscroll_threshhold;
28 double thumbscroll_momentum_threshhold;
29 double thumbscroll_friction;
30 double scale;
31};
32
33#define ELM_NEW(t) calloc(1, sizeof(t))
34
35void _elm_obj_init(Elm_Obj *obj);
36void _elm_obj_nest_push(void);
37void _elm_obj_nest_pop(void);
38int _elm_obj_del_defer(Elm_Obj *obj);
39Elm_Cb *_elm_cb_new(void);
40void _elm_cb_call(Elm_Obj *obj, Elm_Cb_Type, void *info);
41int _elm_theme_set(Evas_Object *o, const char *clas, const char *group);
42void _elm_widget_init(Elm_Widget *wid);
43void _elm_widget_post_init(Elm_Widget *wid);
44
45extern char *_elm_appname;
46
47extern Elm_Config *_elm_config;
48
49extern Elm_Obj_Class _elm_obj_class;
50extern Elm_Win_Class _elm_win_class;
51extern Elm_Widget_Class _elm_widget_class;
52extern Elm_Bg_Class _elm_bg_class;
53extern Elm_Scroller_Class _elm_scroller_class;
54extern Elm_Label_Class _elm_label_class;
55extern Elm_Box_Class _elm_box_class;
56extern Elm_Table_Class _elm_table_class;
57extern Elm_Button_Class _elm_button_class;
58extern Elm_Icon_Class _elm_icon_class;
59extern Elm_Toggle_Class _elm_toggle_class;
60extern Elm_Clock_Class _elm_clock_class;
61extern Elm_Frame_Class _elm_frame_class;
62extern Elm_Pad_Class _elm_pad_class;
63
64#endif
diff --git a/src/lib/elm_scroller.c b/src/lib/elm_scroller.c
new file mode 100644
index 000000000..ce1c567ab
--- /dev/null
+++ b/src/lib/elm_scroller.c
@@ -0,0 +1,99 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4static void _elm_scroller_del(Elm_Scroller *sc);
5
6Elm_Scroller_Class _elm_scroller_class =
7{
8 &_elm_widget_class,
9 ELM_OBJ_SCROLLER
10};
11
12static void
13_elm_scroller_del(Elm_Scroller *sc)
14{
15 evas_object_del(sc->scroller_pan);
16 ((Elm_Obj_Class *)(((Elm_Scroller_Class *)(sc->clas))->parent))->del(ELM_OBJ(sc));
17}
18
19static void
20_elm_scroller_geom_set(Elm_Scroller *sc, int x, int y, int w, int h)
21{
22 Evas_Coord vw, vh;
23
24 if ((sc->w != w) || (sc->h != h) || (sc->x != x) || (sc->y != y))
25 {
26 Evas_List *l;
27 int tries = 0;
28
29 ((Elm_Widget_Class *)(((Elm_Scroller_Class *)(sc->clas))->parent))->geom_set(sc, x, y, w, h);
30 again:
31 tries++;
32 elm_smart_scroller_child_viewport_size_get(sc->base, &vw, &vh);
33 for (l = sc->children; l; l = l->next)
34 {
35 if (((Elm_Obj *)(l->data))->hastype(l->data, ELM_OBJ_WIDGET))
36 {
37 ((Elm_Widget *)(l->data))->size_alloc(l->data, vw, vh);
38 ((Elm_Widget *)(l->data))->geom_set(l->data,
39 ((Elm_Widget *)(l->data))->x,
40 ((Elm_Widget *)(l->data))->y,
41 ((Elm_Widget *)(l->data))->req.w,
42 ((Elm_Widget *)(l->data))->req.h);
43// FIXME: if scrollbars affect viewport size then we get an on/off effect of
44// resizing child up and down. we need to find a way to avoid this. this tries
45// this is a hack - but works.
46 if ((tries == 1) &&
47 (((vw == ((Elm_Widget *)(l->data))->req.w) ||
48 (vh == ((Elm_Widget *)(l->data))->req.h)))) goto again;
49 }
50 }
51 }
52}
53
54static void
55_elm_on_child_add(void *data, Elm_Scroller *sc, Elm_Cb_Type type, Elm_Obj *obj)
56{
57 Evas_Coord vw, vh;
58
59 if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
60 elm_smart_scroller_child_set(sc->base, ((Elm_Widget *)(obj))->base);
61 elm_smart_scroller_child_viewport_size_get(sc->base, &vw, &vh);
62 ((Elm_Widget *)(obj))->size_alloc(obj, vw, vh);
63 ((Elm_Widget *)(obj))->geom_set(obj,
64 ((Elm_Widget *)(obj))->x,
65 ((Elm_Widget *)(obj))->y,
66 ((Elm_Widget *)(obj))->req.w,
67 ((Elm_Widget *)(obj))->req.h);
68}
69
70static void
71_elm_on_child_del(void *data, Elm_Scroller *sc, Elm_Cb_Type type, Elm_Obj *obj)
72{
73 if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
74 elm_smart_scroller_child_set(sc->base, NULL);
75}
76
77EAPI Elm_Scroller *
78elm_scroller_new(Elm_Win *win)
79{
80 Elm_Scroller *sc;
81
82 sc = ELM_NEW(Elm_Scroller);
83 _elm_widget_init(sc);
84
85 sc->clas = &_elm_scroller_class;
86 sc->type = ELM_OBJ_SCROLLER;
87
88 sc->del = _elm_scroller_del;
89
90 sc->geom_set = _elm_scroller_geom_set;
91
92 sc->base = elm_smart_scroller_add(win->evas);
93
94 sc->cb_add(sc, ELM_CB_CHILD_ADD, _elm_on_child_add, NULL);
95 sc->cb_add(sc, ELM_CB_CHILD_DEL, _elm_on_child_del, NULL);
96 _elm_widget_post_init(sc);
97 win->child_add(win, sc);
98 return sc;
99}
diff --git a/src/lib/elm_table.c b/src/lib/elm_table.c
new file mode 100644
index 000000000..5478b5bb6
--- /dev/null
+++ b/src/lib/elm_table.c
@@ -0,0 +1,104 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4static void _elm_table_layout_update(Elm_Table *tb);
5static void _elm_table_pack(Elm_Table *tb, Elm_Widget *wid, int x, int y, int w, int h);
6
7Elm_Table_Class _elm_table_class =
8{
9 &_elm_widget_class,
10 ELM_OBJ_TABLE,
11 _elm_table_layout_update,
12 _elm_table_pack,
13};
14
15static void
16_elm_table_layout_update(Elm_Table *tb)
17{
18 _els_smart_table_homogenous_set(tb->base, tb->homogenous);
19}
20
21static void
22_elm_table_pack(Elm_Table *tb, Elm_Widget *wid, int x, int y, int w, int h)
23{
24 tb->child_add(tb, wid);
25 _els_smart_table_pack(tb->base, wid->base, x, y, w, h);
26}
27
28static void
29_elm_table_size_alloc(Elm_Table *tb, int w, int h)
30{
31 Evas_Coord mw, mh;
32
33 _els_smart_table_min_size_get(tb->base, &mw, &mh);
34 if (w < mw) w = mw;
35 if (h < mh) h = mh;
36 tb->req.w = w;
37 tb->req.h = h;
38}
39
40static void
41_elm_table_size_req(Elm_Table *tb, Elm_Widget *child, int w, int h)
42{
43 Evas_Coord mw, mh;
44
45 if (child)
46 {
47 Evas_Coord maxx, maxy;
48
49 child->size_alloc(child, 0, 0);
50 maxx = child->req.w;
51 maxy = child->req.h;
52 if (child->expand_x) maxx = 32767;
53 if (child->expand_y) maxy = 32767;
54 _els_smart_table_pack_options_set(child->base,
55 child->fill_x, child->fill_y,
56 child->expand_x, child->expand_y,
57 child->align_x, child->align_y,
58 child->req.w, child->req.h,
59 maxx, maxy);
60 }
61 else
62 {
63 // FIXME: handle.
64 }
65 _els_smart_table_min_size_get(tb->base, &mw, &mh);
66 ((Elm_Widget *)(tb->parent))->size_req(tb->parent, tb, mw, mh);
67 tb->geom_set(tb, tb->x, tb->y, mw, mh);
68}
69
70static void
71_elm_on_child_del(void *data, Elm_Table *tb, Elm_Cb_Type type, Elm_Obj *obj)
72{
73 Evas_Coord mw, mh;
74
75 if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
76 _els_smart_table_unpack(((Elm_Widget *)(obj))->base);
77 ((Elm_Widget *)(tb->parent))->size_req(tb->parent, tb, mw, mh);
78 tb->geom_set(tb, tb->x, tb->y, mw, mh);
79}
80
81EAPI Elm_Table *
82elm_table_new(Elm_Win *win)
83{
84 Elm_Table *tb;
85
86 tb = ELM_NEW(Elm_Table);
87
88 _elm_widget_init(tb);
89 tb->clas = &_elm_table_class;
90 tb->type = ELM_OBJ_TABLE;
91
92 tb->layout_update = _elm_table_layout_update;
93 tb->pack = _elm_table_pack;
94
95 tb->size_alloc = _elm_table_size_alloc;
96 tb->size_req = _elm_table_size_req;
97
98 tb->base = _els_smart_table_add(win->evas);
99
100 tb->cb_add(tb, ELM_CB_CHILD_DEL, _elm_on_child_del, NULL);
101 _elm_widget_post_init(tb);
102 win->child_add(win, tb);
103 return tb;
104}
diff --git a/src/lib/elm_theme.c b/src/lib/elm_theme.c
new file mode 100644
index 000000000..c9b77a5ca
--- /dev/null
+++ b/src/lib/elm_theme.c
@@ -0,0 +1,13 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4int
5_elm_theme_set(Evas_Object *o, const char *clas, const char *group)
6{
7 char buf[PATH_MAX];
8
9 // FIXME: actually handle themes for real
10 snprintf(buf, sizeof(buf), "%s/themes/%s.edj", PACKAGE_DATA_DIR,
11 "default");
12 return edje_object_file_set(o, buf, group);
13}
diff --git a/src/lib/elm_toggle.c b/src/lib/elm_toggle.c
new file mode 100644
index 000000000..1e73d20c0
--- /dev/null
+++ b/src/lib/elm_toggle.c
@@ -0,0 +1,210 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4static void _elm_toggle_text_set(Elm_Toggle *tg, const char *text);
5static void _elm_toggle_layout_update(Elm_Toggle *tg);
6static void _elm_toggle_states_text_set(Elm_Toggle *tg, const char *ontext, const char *offtext);
7
8Elm_Toggle_Class _elm_toggle_class =
9{
10 &_elm_widget_class,
11 ELM_OBJ_TOGGLE,
12 _elm_toggle_text_set,
13 _elm_toggle_layout_update,
14 _elm_toggle_states_text_set
15};
16
17static void
18_elm_toggle_text_set(Elm_Toggle *tg, const char *text)
19{
20 Evas_Coord mw, mh;
21
22 if (text)
23 {
24 edje_object_signal_emit(tg->base, "elm,state,text,visible", "elm");
25 edje_object_message_signal_process(tg->base);
26 }
27 else
28 {
29 edje_object_signal_emit(tg->base, "elm,state,text,hidden", "elm");
30 edje_object_message_signal_process(tg->base);
31 }
32 edje_object_part_text_set(tg->base, "elm.text", text);
33 edje_object_size_min_calc(tg->base, &mw, &mh);
34 if ((tg->minw != mw) || (tg->minh != mh))
35 {
36 tg->minw = mw;
37 tg->minh = mh;
38 ((Elm_Widget *)(tg->parent))->size_req(tg->parent, tg, tg->minw, tg->minh);
39 tg->geom_set(tg, tg->x, tg->y, tg->minw, tg->minh);
40 }
41}
42
43static void
44_elm_toggle_states_text_set(Elm_Toggle *tg, const char *ontext, const char *offtext)
45{
46 edje_object_part_text_set(tg->base, "elm.ontext", ontext);
47 edje_object_part_text_set(tg->base, "elm.offtext", offtext);
48}
49
50static void
51_elm_toggle_layout_update(Elm_Toggle *tg)
52{
53 if (tg->state_ptr) tg->state = *(tg->state_ptr);
54 if (tg->state)
55 edje_object_signal_emit(tg->base, "elm,state,toggle,on", "elm");
56 else
57 edje_object_signal_emit(tg->base, "elm,state,toggle,off", "elm");
58}
59
60static void
61_elm_toggle_size_alloc(Elm_Toggle *tg, int w, int h)
62{
63 if (w < tg->minw) w = tg->minw;
64 if (h < tg->minh) h = tg->minh;
65 tg->req.w = w;
66 tg->req.h = h;
67}
68
69static void
70_elm_toggle_size_req(Elm_Toggle *tg, Elm_Widget *child, int w, int h)
71{
72 Evas_Coord mw, mh;
73
74 if (child)
75 {
76 Evas_Coord maxx, maxy;
77
78 child->size_alloc(child, 0, 0);
79 maxx = child->req.w;
80 maxy = child->req.h;
81 if (child->expand_x) maxx = 32767;
82 if (child->expand_y) maxy = 32767;
83 edje_extern_object_min_size_set(child->base,
84 child->req.w,
85 child->req.h);
86 edje_object_part_swallow(tg->base , "elm.swallow.contents",
87 child->base);
88 edje_object_size_min_calc(tg->base, &mw, &mh);
89 if ((tg->minw != mw) || (tg->minh != mh))
90 {
91 tg->minw = mw;
92 tg->minh = mh;
93 ((Elm_Widget *)(tg->parent))->size_req(tg->parent, tg, mw, mh);
94 tg->geom_set(tg, tg->x, tg->y, mw, mh);
95 }
96 }
97 else
98 {
99 // FIXME: handle
100 }
101}
102
103static void
104_elm_on_child_add(void *data, Elm_Toggle *tg, Elm_Cb_Type type, Elm_Obj *obj)
105{
106 Evas_Coord mw, mh;
107
108 if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
109 edje_object_signal_emit(tg->base, "elm,state,icon,visible", "elm");
110 edje_object_message_signal_process(tg->base);
111 ((Elm_Widget *)(obj))->size_alloc(obj, 0, 0);
112 ((Elm_Widget *)(obj))->geom_set(obj,
113 ((Elm_Widget *)(obj))->x,
114 ((Elm_Widget *)(obj))->y,
115 ((Elm_Widget *)(obj))->req.w,
116 ((Elm_Widget *)(obj))->req.h);
117 edje_extern_object_min_size_set(((Elm_Widget *)(obj))->base,
118 ((Elm_Widget *)(obj))->req.w,
119 ((Elm_Widget *)(obj))->req.h);
120 edje_object_part_swallow(tg->base , "elm.swallow.contents",
121 ((Elm_Widget *)(obj))->base);
122 edje_object_size_min_calc(tg->base, &mw, &mh);
123 if ((tg->minw != mw) || (tg->minh != mh))
124 {
125 tg->minw = mw;
126 tg->minh = mh;
127 ((Elm_Widget *)(tg->parent))->size_req(tg->parent, tg, mw, mh);
128 tg->geom_set(tg, tg->x, tg->y, mw, mh);
129 }
130}
131
132static void
133_elm_on_child_del(void *data, Elm_Toggle *tg, Elm_Cb_Type type, Elm_Obj *obj)
134{
135 if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
136 // FIXME: allow for removal of child - size down
137 edje_object_signal_emit(tg->base, "elm,state,icon,hidden", "elm");
138 edje_object_message_signal_process(tg->base);
139}
140
141static void
142_elm_toggle_activate(Elm_Toggle *tg)
143{
144 if (tg->state_ptr) *(tg->state_ptr) = tg->state;
145 _elm_obj_nest_push();
146 _elm_cb_call(ELM_OBJ(tg), ELM_CB_CHANGED, NULL);
147 _elm_obj_nest_pop();
148}
149
150static void
151_elm_signal_toggle_on(void *data, Evas_Object *obj, const char *emission, const char *source)
152{
153 Elm_Toggle *tg = data;
154
155 if (tg->state) return;
156 tg->state = 1;
157 _elm_toggle_activate(tg);
158}
159
160static void
161_elm_signal_toggle_off(void *data, Evas_Object *obj, const char *emission, const char *source)
162{
163 Elm_Toggle *tg = data;
164
165 if (!tg->state) return;
166 tg->state = 0;
167 _elm_toggle_activate(tg);
168}
169
170static void
171_elm_toggle_del(Elm_Toggle *tg)
172{
173 if (tg->text) evas_stringshare_del(tg->text);
174 ((Elm_Obj_Class *)(((Elm_Toggle_Class *)(tg->clas))->parent))->del(ELM_OBJ(tg));
175}
176
177EAPI Elm_Toggle *
178elm_toggle_new(Elm_Win *win)
179{
180 Elm_Toggle *tg;
181
182 tg = ELM_NEW(Elm_Toggle);
183
184 _elm_widget_init(tg);
185 tg->clas = &_elm_toggle_class;
186 tg->type = ELM_OBJ_TOGGLE;
187
188 tg->del = _elm_toggle_del;
189
190 tg->size_alloc = _elm_toggle_size_alloc;
191 tg->size_req = _elm_toggle_size_req;
192
193 tg->text_set = _elm_toggle_text_set;
194 tg->layout_update = _elm_toggle_layout_update;
195 tg->states_text_set = _elm_toggle_states_text_set;
196
197 tg->base = edje_object_add(win->evas);
198 _elm_theme_set(tg->base, "toggle", "toggle");
199 edje_object_part_text_set(tg->base, "elm.ontext", "ON");
200 edje_object_part_text_set(tg->base, "elm.offtext", "OFF");
201 edje_object_signal_callback_add(tg->base, "elm,action,toggle,on", "",
202 _elm_signal_toggle_on, tg);
203 edje_object_signal_callback_add(tg->base, "elm,action,toggle,off", "",
204 _elm_signal_toggle_off, tg);
205 tg->cb_add(tg, ELM_CB_CHILD_ADD, _elm_on_child_add, NULL);
206 tg->cb_add(tg, ELM_CB_CHILD_DEL, _elm_on_child_del, NULL);
207 _elm_widget_post_init(tg);
208 win->child_add(win, tg);
209 return tg;
210}
diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c
new file mode 100644
index 000000000..2fddfa8b0
--- /dev/null
+++ b/src/lib/elm_widget.c
@@ -0,0 +1,137 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4static void _elm_widget_geom_set(Elm_Widget *wid, int x, int y, int w, int h);
5static void _elm_widget_show(Elm_Widget *wid);
6static void _elm_widget_hide(Elm_Widget *wid);
7static void _elm_widget_size_alloc(Elm_Widget *wid, int w, int h);
8static void _elm_widget_size_req(Elm_Widget *wid, Elm_Widget *child, int w, int h);
9static void _elm_widget_del(Elm_Widget *wid);
10static void _elm_widget_above(Elm_Widget *wid, Elm_Widget *above);
11static void _elm_widget_below(Elm_Widget *wid, Elm_Widget *below);
12
13Elm_Widget_Class _elm_widget_class =
14{
15 &_elm_obj_class, /* parent */
16 ELM_OBJ_WIDGET,
17 _elm_widget_geom_set,
18 _elm_widget_show,
19 _elm_widget_hide,
20 _elm_widget_size_alloc,
21 _elm_widget_size_req,
22 _elm_widget_above,
23 _elm_widget_below
24};
25
26static void
27_elm_widget_geom_set(Elm_Widget *wid, int x, int y, int w, int h)
28{
29 if ((wid->x != x) || (wid->y != y))
30 {
31 wid->x = x;
32 wid->y = y;
33 evas_object_move(wid->base, wid->x, wid->y);
34 }
35 if ((wid->w != w) || (wid->h != h))
36 {
37 wid->w = w;
38 wid->h = h;
39 evas_object_resize(wid->base, wid->w, wid->h);
40 _elm_obj_nest_push();
41 _elm_cb_call(ELM_OBJ(wid), ELM_CB_RESIZE, NULL);
42 _elm_obj_nest_pop();
43 }
44}
45
46static void
47_elm_widget_show(Elm_Widget *wid)
48{
49 evas_object_show(wid->base);
50}
51
52static void
53_elm_widget_hide(Elm_Widget *wid)
54{
55 evas_object_hide(wid->base);
56}
57
58static void
59_elm_widget_size_alloc(Elm_Widget *wid, int w, int h)
60{
61 // FIXME: widget gets to implement min/max etc. size here (indicating
62 // given the input w, h - what size it is willing to accept, then the
63 // parent checks and geometry_set()'s the child
64 wid->req.w = w;
65 wid->req.h = h;
66}
67
68static void
69_elm_widget_size_req(Elm_Widget *wid, Elm_Widget *child, int w, int h)
70{
71 // FIXME: a child will ask its parent for a requested size if something
72 // with its sizing setup. this is the call in the parent that will be
73 // called
74}
75
76static void
77_elm_widget_above(Elm_Widget *wid, Elm_Widget *above)
78{
79 if (above) evas_object_stack_above(wid->base, above->base);
80 else evas_object_raise(wid->base);
81}
82
83static void
84_elm_widget_below(Elm_Widget *wid, Elm_Widget *below)
85{
86 if (below) evas_object_stack_below(wid->base, below->base);
87 else evas_object_lower(wid->base);
88}
89
90static void
91_elm_widget_del(Elm_Widget *wid)
92{
93 if (_elm_obj_del_defer(ELM_OBJ(wid))) return;
94
95 evas_object_del(wid->base);
96
97 ((Elm_Obj_Class *)(((Elm_Widget_Class *)(wid->clas))->parent))->del(ELM_OBJ(wid));
98}
99
100void
101_elm_widget_init(Elm_Widget *wid)
102{
103 _elm_obj_init(ELM_OBJ(wid));
104 wid->clas = &_elm_widget_class;
105 wid->type = ELM_OBJ_WIDGET;
106
107 wid->del = _elm_widget_del;
108
109 wid->geom_set = _elm_widget_geom_set;
110 wid->show = _elm_widget_show;
111 wid->hide = _elm_widget_hide;
112 wid->size_alloc = _elm_widget_size_alloc;
113 wid->size_req = _elm_widget_size_req;
114 wid->above = _elm_widget_above;
115 wid->below = _elm_widget_below;
116
117 wid->align_x = 0.5;
118 wid->align_y = 0.5;
119 wid->expand_x = 1;
120 wid->expand_y = 1;
121 wid->fill_x = 1;
122 wid->fill_y = 1;
123}
124
125void
126_elm_widget_post_init(Elm_Widget *wid)
127{
128 if (wid->base) evas_object_data_set(wid->base, "__Elm", wid);
129}
130
131EAPI void
132elm_widget_sizing_update(Elm_Widget *wid)
133{
134 wid->size_alloc(wid, 0, 0);
135 if (!wid->parent) return;
136 ((Elm_Widget *)(wid->parent))->size_req(wid->parent, wid, wid->w, wid->h);
137}
diff --git a/src/lib/elm_win.c b/src/lib/elm_win.c
new file mode 100644
index 000000000..a0c7d185e
--- /dev/null
+++ b/src/lib/elm_win.c
@@ -0,0 +1,307 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4static void _elm_win_name_set(Elm_Win *win, const char *name);
5static void _elm_win_title_set(Elm_Win *win, const char *title);
6static void _elm_win_show(Elm_Win *win);
7static void _elm_win_hide(Elm_Win *win);
8static void _elm_win_del(Elm_Win *win);
9
10Elm_Win_Class _elm_win_class =
11{
12 &_elm_obj_class, /* parent */
13 ELM_OBJ_WIN,
14 _elm_win_name_set,
15 _elm_win_title_set
16};
17
18static void
19_elm_child_eval_job(Elm_Win *win)
20{
21 Evas_List *l;
22 int w, h;
23 int expand_x, expand_y;
24
25 win->deferred_child_eval_job = NULL;
26 _elm_obj_nest_push();
27 w = h = 0;
28 expand_x = expand_y = 0;
29 for (l = win->children; l; l = l->next)
30 {
31 if (((Elm_Obj *)(l->data))->hastype(l->data, ELM_OBJ_WIDGET))
32 {
33 if (((Elm_Widget *)(l->data))->w > w) w = ((Elm_Widget *)(l->data))->w;
34 if (((Elm_Widget *)(l->data))->h > h) h = ((Elm_Widget *)(l->data))->h;
35 if (((Elm_Widget *)(l->data))->expand_x) expand_x = 1;
36 if (((Elm_Widget *)(l->data))->expand_y) expand_y = 1;
37 }
38 }
39 ecore_evas_size_min_set(win->ee, w, h);
40 if ((!expand_x) && (!expand_y)) ecore_evas_size_max_set(win->ee, w, h);
41 else if (!expand_x) ecore_evas_size_max_set(win->ee, w, 32727);
42 else if (!expand_y) ecore_evas_size_max_set(win->ee, 32767, h);
43 else ecore_evas_size_max_set(win->ee, 0, 0);
44 if (w < win->w) w = win->w;
45 if (h < win->h) h = win->h;
46 if ((w > win->w) || (h > win->h)) ecore_evas_resize(win->ee, w, h);
47 if (win->showme)
48 {
49 win->showme = 0;
50 ecore_evas_show(win->ee);
51 }
52 _elm_obj_nest_pop();
53}
54
55static void
56_elm_on_child_add(void *data, Elm_Win *win, Elm_Cb_Type type, Elm_Obj *obj)
57{
58 if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
59 if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
60 win->deferred_child_eval_job = ecore_job_add(_elm_child_eval_job, win);
61}
62
63static void
64_elm_on_child_del(void *data, Elm_Win *win, Elm_Cb_Type type, Elm_Obj *obj)
65{
66 if (!(obj->hastype(obj, ELM_OBJ_WIDGET))) return;
67 if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
68 win->deferred_child_eval_job = ecore_job_add(_elm_child_eval_job, win);
69}
70
71static void
72_elm_win_name_set(Elm_Win *win, const char *name)
73{
74 if (win->name) evas_stringshare_del(win->name);
75 win->name = evas_stringshare_add(name);
76 if (win->ee) ecore_evas_name_class_set(win->ee, win->name, _elm_appname);
77}
78
79static void
80_elm_win_title_set(Elm_Win *win, const char *title)
81{
82 if (win->title) evas_stringshare_del(win->title);
83 win->title = evas_stringshare_add(title);
84 if (win->ee) ecore_evas_title_set(win->ee, win->title);
85}
86
87static void
88_elm_win_show(Elm_Win *win)
89{
90 if (win->deferred_child_eval_job)
91 win->showme = 1;
92 else
93 ecore_evas_show(win->ee);
94}
95
96static void
97_elm_win_hide(Elm_Win *win)
98{
99 win->showme = 0;
100 ecore_evas_hide(win->ee);
101}
102
103static void
104_elm_win_type_set(Elm_Win *win, Elm_Win_Type type)
105{
106 if (win->win_type == type) return;
107 win->win_type = type;
108 switch (win->win_type)
109 {
110 case ELM_WIN_BASIC:
111 if (win->xwin) ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NORMAL);
112 // FIXME: if child object is a scroll region, then put its child back
113 break;
114 case ELM_WIN_DIALOG_BASIC:
115 if (win->xwin) ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DIALOG);
116 // FIXME: if child object is a scroll region, then put its child back
117 break;
118 default:
119 break;
120 }
121}
122
123static void
124_elm_win_geom_set(Elm_Win *win, int x, int y, int w, int h)
125{
126 if ((win->w != w) || (win->h != h) || (win->x != x) || (win->y != y))
127 {
128 win->x = x;
129 win->y = y;
130 win->w = w;
131 win->h = h;
132 ecore_evas_move_resize(win->ee, win->x, win->y, win->w, win->h);
133 }
134}
135
136static void
137_elm_win_size_alloc(Elm_Win *win, int w, int h)
138{
139 /* this should never be called */
140}
141
142static void
143_elm_win_size_req(Elm_Win *win, Elm_Widget *child, int w, int h)
144{
145 if (child)
146 {
147 if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
148 win->deferred_child_eval_job = ecore_job_add(_elm_child_eval_job, win);
149 }
150 else
151 {
152 if ((w == win->w) && (h == win->h)) return;
153 ecore_evas_resize(win->ee, w, h);
154 }
155}
156
157static void
158_elm_win_above(Elm_Win *win, Elm_Widget *above)
159{
160}
161
162static void
163_elm_win_below(Elm_Win *win, Elm_Widget *below)
164{
165}
166
167static void
168_elm_win_del(Elm_Win *win)
169{
170 if (_elm_obj_del_defer(ELM_OBJ(win))) return;
171 if (win->ee)
172 {
173 ecore_evas_free(win->ee);
174 evas_stringshare_del(win->title);
175 evas_stringshare_del(win->name);
176 }
177 if (win->deferred_resize_job)
178 ecore_job_del(win->deferred_resize_job);
179 if (win->deferred_child_eval_job)
180 ecore_job_del(win->deferred_child_eval_job);
181 ((Elm_Obj_Class *)(((Elm_Win_Class *)(win->clas))->parent))->del(ELM_OBJ(win));
182}
183
184
185
186static void
187_elm_win_delete_request(Ecore_Evas *ee)
188{
189 Elm_Win *win = ecore_evas_data_get(ee, "__Elm");
190 if (!win) return;
191 _elm_obj_nest_push();
192 _elm_cb_call(ELM_OBJ(win), ELM_CB_DEL_REQ, NULL);
193 if (win->autodel) win->del(ELM_OBJ(win));
194 _elm_obj_nest_pop();
195}
196
197static void
198_elm_win_resize_job(Elm_Win *win)
199{
200 Evas_List *l;
201 int w, h;
202
203 win->deferred_resize_job = NULL;
204 ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
205 if ((win->w == w) && (win->h == h)) return;
206 win->w = w;
207 win->h = h;
208 /* resize all immediate children if they are widgets or sub-classes */
209 _elm_obj_nest_push();
210 for (l = win->children; l; l = l->next)
211 {
212 if (((Elm_Obj *)(l->data))->hastype(l->data, ELM_OBJ_WIDGET))
213 ((Elm_Widget *)(l->data))->geom_set(l->data, 0, 0, win->w, win->h);
214 }
215 _elm_cb_call(ELM_OBJ(win), ELM_CB_RESIZE, NULL);
216 _elm_obj_nest_pop();
217}
218
219static void
220_elm_win_resize(Ecore_Evas *ee)
221{
222 Elm_Win *win = ecore_evas_data_get(ee, "__Elm");
223 if (!win) return;
224 if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
225 win->deferred_resize_job = ecore_job_add(_elm_win_resize_job, win);
226}
227
228EAPI Elm_Win *
229elm_win_new(void)
230{
231 Elm_Win *win;
232
233 win = ELM_NEW(Elm_Win);
234
235 _elm_obj_init(ELM_OBJ(win));
236 win->clas = &_elm_win_class;
237 win->type = ELM_OBJ_WIN;
238
239 win->del = _elm_win_del;
240
241 win->geom_set = _elm_win_geom_set;
242 win->show = _elm_win_show;
243 win->hide = _elm_win_hide;
244 win->size_alloc = _elm_win_size_alloc;
245 win->size_req = _elm_win_size_req;
246 win->above = _elm_win_above;
247 win->below = _elm_win_below;
248
249 win->name_set = _elm_win_name_set;
250 win->title_set = _elm_win_title_set;
251
252 switch (_elm_config->engine)
253 {
254 case ELM_SOFTWARE_X11:
255 win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
256 if (win->ee) win->xwin = ecore_evas_software_x11_window_get(win->ee);
257 break;
258 case ELM_SOFTWARE_FB:
259 win->ee = ecore_evas_fb_new(NULL, 0, 1, 1);
260 ecore_evas_fullscreen_set(win->ee, 1);
261 break;
262 case ELM_SOFTWARE_16_X11:
263 win->ee = ecore_evas_software_x11_16_new(NULL, 0, 0, 0, 1, 1);
264 if (win->ee) win->xwin = ecore_evas_software_x11_16_window_get(win->ee);
265 break;
266 case ELM_XRENDER_X11:
267 win->ee = ecore_evas_xrender_x11_new(NULL, 0, 0, 0, 1, 1);
268 if (win->ee) win->xwin = ecore_evas_xrender_x11_window_get(win->ee);
269 break;
270 case ELM_OPENGL_X11:
271 win->ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
272 if (win->ee) win->xwin = ecore_evas_gl_x11_window_get(win->ee);
273 break;
274 default:
275 break;
276 }
277 if (!win->ee)
278 {
279 printf("ELEMENTARY: Error. Cannot create window.\n");
280 win->del(ELM_OBJ(win));
281 return NULL;
282 }
283 win->type = ELM_WIN_BASIC;
284 win->name = evas_stringshare_add("default");
285 win->title = evas_stringshare_add("Elementary Window");
286
287 win->evas = ecore_evas_get(win->ee);
288 ecore_evas_title_set(win->ee, win->title);
289 ecore_evas_name_class_set(win->ee, win->name, _elm_appname);
290 ecore_evas_data_set(win->ee, "__Elm", win);
291 ecore_evas_callback_delete_request_set(win->ee, _elm_win_delete_request);
292 ecore_evas_callback_resize_set(win->ee, _elm_win_resize);
293 // FIXME: use elm config for this
294 evas_image_cache_set(win->evas, 4096 * 1024);
295 evas_font_cache_set(win->evas, 512 * 1024);
296 evas_font_path_append(win->evas, "fonts");
297// evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_NONE);
298// evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_AUTO);
299// evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_BYTECODE);
300 edje_frametime_set(1.0 / 30.0);
301 edje_scale_set(_elm_config->scale);
302
303 win->cb_add(win, ELM_CB_CHILD_ADD, _elm_on_child_add, NULL);
304 win->cb_add(win, ELM_CB_CHILD_DEL, _elm_on_child_del, NULL);
305
306 return win;
307}
diff --git a/src/lib/els_box.c b/src/lib/els_box.c
new file mode 100644
index 000000000..516a7714f
--- /dev/null
+++ b/src/lib/els_box.c
@@ -0,0 +1,712 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4typedef struct _Smart_Data Smart_Data;
5typedef struct _Box_Item Box_Item;
6
7struct _Smart_Data
8{
9 Evas_Coord x, y, w, h;
10 Evas_Object *obj;
11 Evas_Object *clip;
12 int frozen;
13 unsigned char changed : 1;
14 unsigned char horizontal : 1;
15 unsigned char homogenous : 1;
16 Evas_List *items;
17 struct {
18 Evas_Coord w, h;