summaryrefslogtreecommitdiff
path: root/src/bin/test.c
blob: 3d85be552d1cd3b2eebb661ba3571a15d2b05f7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
#include <Elementary.h>

/* This is a test app (that is also functional) to test the api and serve
 * as an example
 */

static void
on_win_resize(void *data, Elm_Win *win, Elm_Cb_Type type, void *info)
{
   /* window is resized */
   printf("resize to: %ix%i\n", win->w, win->h);
}

static void
on_win_del_req(void *data, Elm_Win *win, Elm_Cb_Type type, void *info)
{
   /* because autodel is on - after this callback the window will be deleted */
   /* but to be explicit - exit the app when window is closed */
   elm_exit();
}

static void
win_bg_simple(void)
{
   Elm_Win *win;
   Elm_Bg *bg;

   win = elm_win_new(); /* create a window */
   win->name_set(win, "win_simple"); /* set the window name - used by window 
				      * manager. make it uniqie for windows
				      * with in this application */
   win->title_set(win, "Simple Window with default Bg"); /* set the title */
   win->autodel = 0; /* dont auto delete the window if someone closes it.
		      * this means the del+req handler has to delete it. by
		      * default it is on */
   /* add a callback that is called when the user tries to close the window */
   win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
   /* add a callback that gets called when the window is resized */
   win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);

   /* our window needs a baground, so ask for one - it will be set with a
    * default bg */
   bg = elm_bg_new(win);
   bg->show(bg); /* show the bg */
   
   win->size_req(win, NULL, 240, 320); /* request that the window is 240x240 
					* no min/max size enforced */
   win->show(win); /* show the window */
}

static void
win_bg_image(void)
{
   Elm_Win *win;
   Elm_Bg *bg;
   char buf[PATH_MAX];

   win = elm_win_new();
   win->name_set(win, "win_bg");
   win->title_set(win, "Simple Window with and image Bg");
   win->autodel = 0;
   win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
   win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);

   bg = elm_bg_new(win);
   /* this is a test - shows how to have your own custom wallpaper in
    * your app - don't use this unless you have a very good reason! there
    * is a default and all apps look nicer sharing the default, but if
    * you insist... */
   snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", PACKAGE_DATA_DIR);
   bg->file_set(bg, buf, NULL); /* set the bg - the NULL is for special
				 * files that contain multiple images
				 * inside 1 file. not normally used but
				 * might be if you have archive files with
				 * multiple images in them */
   bg->show(bg);

   win->size_req(win, NULL, 240, 240);
   win->show(win);
}

static void
win_scrollable_label(void)
{
   Elm_Win *win;
   Elm_Bg *bg;
   Elm_Scroller *scroller;
   Elm_Label *label;

   win = elm_win_new();
   win->name_set(win, "win_bg");
   win->title_set(win, "Simple Window with scroller and label inside");
   win->autodel = 0;
   win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
   win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);

   bg = elm_bg_new(win);
   bg->show(bg);
   
   scroller = elm_scroller_new(win);
   
   label = elm_label_new(win);
   label->text_set(label, 
		   "Hello world<br>"
		   "<br>"
		   "I am a label. I come here to temonstrate how to put<br>"
		   "text into a label, with newlines, even markup to test<br>"
		   "things like <b>bold text</b> where markup can be custom<br>"
		   "and extensible, defined by the theme's textbloxk style<br>"
		   "for the label.<br>"
		   "<br>"
		   "Note that the markup is html-like and things like newline<br>"
		   "chars and tab chars like stdout text are not valid text<br>"
		   "markup mechanisms. Use markup tags instead.<br>"
		   "<br>"
		   "Now we shall borrow some text from another test program<br>"
		   "(Expedite) to put some more tests in here<br>"
		   "<br>"
		   "<style=outline color=#fff outline_color=#000>Styled</> "
		   "<style=shadow shadow_color=#fff8>text</> "
		   "<style=soft_shadow shadow_color=#0002>should</> "
		   "<style=glow color=#fff glow2_color=#fe87 glow_color=#f214 >go here</> "
		   "<style=far_shadow shadow_color=#0005>as it is</> "
		   "<style=outline_shadow color=#fff outline_color=#8228 shadow_color=#005>within</> "
		   "<style=outline_soft_shadow color=#fff outline_color=#8228 shadow_color=#0002>right tags</> "
		   "<style=far_soft_shadow color=#fff shadow_color=#0002>to make it align to the</> "
		   "<underline=on underline_color=#00f>right hand</> "
		   "<backing=on backing_color=#fff8>side </><backing_color=#ff08>of</><backing_color=#0f08> </>"
		   "<strikethrough=on strikethrough_color=#f0f8>the textblock</>."
		   "<br>"
		   "<underline=double underline_color=#f00 underline2_color=#00f>now we need</> "
		   "to test some <color=#f00 font_size=8>C</><color=#0f0 font_size=10>O</>"
		   "<color=#00f font_size=12>L</><color=#fff font_size=14>O</>"
		   "<color=#ff0 font_size=16>R</><color=#0ff font_size=18> Bla Rai</>"
		   "<color=#f0f font_size=20> Stuff</>."
		   "<br>"
		   "<style=outline color=#fff outline_color=#000>Round about the cauldron go;</> "
		   "In the poison'd entrails throw.<br>"
		   "<style=shadow shadow_color=#fff8>Toad, that under cold stone</> "
		   "Days and nights has thirty-one<br>"
		   "<style=soft_shadow shadow_color=#0002>Swelter'd venom sleeping got,</> "
		   "<style=glow color=#fff glow2_color=#fe87 glow_color=#f214 >Boil thou first i' the charmed pot.</><br>"
		   "Double, double toil and trouble; "
		   "Fire burn, and cauldron bubble.<br>"
		   "<style=far_shadow shadow_color=#0005>Fillet of a fenny snake,</> "
		   "In the cauldron boil and bake;<br>"
		   "<style=outline_shadow color=#fff outline_color=#8228 shadow_color=#005>Eye of newt and toe of frog,</> "
		   "<underline=on underline_color=#00f>Wool of bat and tongue of dog,</><br>"
		   "<backing=on backing_color=#fff8>Adder's fork and blind-worm's sting,</> "
		   "<underline=double underline_color=#f00 underline2_color=#00f>Lizard's leg and owlet's wing,</><br>"
		   "<color=#808 font_size=20>For a charm of powerful trouble, "
		   "Like a hell-broth boil and bubble.<br>"
		   "Double, double toil and trouble;</> "
		   "Fire burn and cauldron bubble.<br>"
		   "Scale of dragon, tooth of wolf, "
		   "Witches' mummy, maw and gulf<br>"
		   "Of the ravin'd salt-sea shark, "
		   "Root of hemlock digg'd i' the dark,<br>"
		   "Liver of blaspheming Jew, "
		   "Gall of goat, and slips of yew<br>"
		   "Silver'd in the moon's eclipse, "
		   "Nose of Turk and Tartar's lips,<br>"
		   "Finger of birth-strangled babe "
		   "Ditch-deliver'd by a drab,<br>"
		   "Make the gruel thick and slab: "
		   "Add thereto a tiger's chaudron,<br>"
		   "For the ingredients of our cauldron. "
		   "Double, double toil and trouble;<br>"
		   "Fire burn and cauldron bubble. "
		   "Cool it with a baboon's blood,<br>"
		   "Then the charm is firm and good.<br>"
		   "<br>"
		   "Heizölrückstoßabdämpfung fløde pingüino kilómetros cœur déçu l'âme<br>"
		   "plutôt naïve Louÿs rêva crapaüter Íosa Úrmhac Óighe pór Éava Ádhaim<br>"
		   );
   scroller->child_add(scroller, label);
   label->show(label);
   scroller->show(scroller);

   win->size_req(win, NULL, 240, 480);
   win->show(win);
}

static void
win_label_determines_min_size(void)
{
   Elm_Win *win;
   Elm_Bg *bg;
   Elm_Label *label;

   win = elm_win_new();
   win->name_set(win, "win_bg");
   win->title_set(win, "Simple Window with label setting minimum size");
   win->autodel = 0;
   win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
   win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);

   bg = elm_bg_new(win);
   bg->expand_x = 0; /* allows the window to grow in the y axis because */
   bg->expand_y = 1; /* its only child can expand in y */
   bg->show(bg);
   
   label = elm_label_new(win);
   label->text_set(label, 
		   "Hello world<br>"
		   "<br>"
		   "I am a label. I come here to temonstrate how to put<br>"
		   "text into a label, with newlines, even markup to test<br>"
		   "things like <b>bold text</b> where markup can be custom<br>"
		   "and extensible, defined by the theme's textbloxk style<br>"
		   "for the label.<br>"
		   "<br>"
		   "Note that the markup is html-like and things like newline<br>"
		   "chars and tab chars like stdout text are not valid text<br>"
		   "markup mechanisms. Use markup tags instead.<br>"
		   );
   label->show(label);
   label->expand_x = 0; /* allows the window to grow in the y axis because */
   label->expand_y = 1; /* its only child can expand in y */
   /* why do i change expand on both bg and label? both are children of the
    * window widget and thus both affect the window sizing. if any expands
    * in an axis then window expanding is allowed always */
   elm_widget_sizing_update(label); /* make sure that the lable knows about its
				     * sizing changes like expand above */
   win->show(win);
}

static void
win_box_vert_of_labels(void)
{
   Elm_Win *win;
   Elm_Bg *bg;
   Elm_Box *box;
   Elm_Label *label;

   win = elm_win_new();
   win->name_set(win, "win_bg");
   win->title_set(win, "Simple Window with box + labels setting minimum size");
   win->autodel = 0;
   win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
   win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);

   bg = elm_bg_new(win);
   bg->expand_x = 1;
   bg->expand_y = 1;
   bg->show(bg);
   
   box = elm_box_new(win);
   box->expand_x = 1;
   box->expand_y = 1;
   
   label = elm_label_new(win);
   label->text_set(label, "Expand X/Y 0/0, Fill X/Y 0/0, Align: 0.5 0.5");
   box->pack_end(box, label);
   label->show(label);
   label->align_x = 0.5;
   label->align_y = 0.5;
   label->expand_x = 0;
   label->expand_y = 0;
   label->fill_x = 0;
   label->fill_y = 0;
   elm_widget_sizing_update(label);

   label = elm_label_new(win);
   label->text_set(label, "Expand X/Y 1/1, Fill X/Y 0/0, Align: 0.5 0.5");
   box->pack_end(box, label);
   label->show(label);
   label->align_x = 0.5;
   label->align_y = 0.5;
   label->expand_x = 1;
   label->expand_y = 1;
   label->fill_x = 0;
   label->fill_y = 0;
   elm_widget_sizing_update(label);

   label = elm_label_new(win);
   label->text_set(label, "Expand X/Y 1/1, Fill X/Y 1/1, Align: 0.5 0.5");
   box->pack_end(box, label);
   label->show(label);
   label->align_x = 0.5;
   label->align_y = 0.5;
   label->expand_x = 1;
   label->expand_y = 1;
   label->fill_x = 1;
   label->fill_y = 1;
   elm_widget_sizing_update(label);

   label = elm_label_new(win);
   label->text_set(label, "Expand X/Y 0/0, Fill X/Y 1/1, Align: 0.5 0.5");
   box->pack_end(box, label);
   label->show(label);
   label->align_x = 0.5;
   label->align_y = 0.5;
   label->expand_x = 0;
   label->expand_y = 0;
   label->fill_x = 1;
   label->fill_y = 1;
   elm_widget_sizing_update(label);

   label = elm_label_new(win);
   label->text_set(label, "Expand X/Y 0/0, Fill X/Y 1/1, Align: 0.0 0.5");
   box->pack_end(box, label);
   label->show(label);
   label->align_x = 0.0;
   label->align_y = 0.5;
   label->expand_x = 0;
   label->expand_y = 0;
   label->fill_x = 1;
   label->fill_y = 1;
   elm_widget_sizing_update(label);

   label = elm_label_new(win);
   label->text_set(label, "Expand X/Y 0/0, Fill X/Y 1/1, Align: 1.0 0.5");
   box->pack_end(box, label);
   label->show(label);
   label->align_x = 1.0;
   label->align_y = 0.5;
   label->expand_x = 0;
   label->expand_y = 0;
   label->fill_x = 1;
   label->fill_y = 1;
   elm_widget_sizing_update(label);

   label = elm_label_new(win);
   label->text_set(label, "Expand X/Y 0/0, Fill X/Y 1/1, Align: 0.5 0.0");
   box->pack_end(box, label);
   label->show(label);
   label->align_x = 0.5;
   label->align_y = 0.0;
   label->expand_x = 0;
   label->expand_y = 0;
   label->fill_x = 1;
   label->fill_y = 1;
   elm_widget_sizing_update(label);

   label = elm_label_new(win);
   label->text_set(label, "Expand X/Y 0/0, Fill X/Y 1/1, Align: 0.5 1.0");
   box->pack_end(box, label);
   label->show(label);
   label->align_x = 0.5;
   label->align_y = 1.0;
   label->expand_x = 0;
   label->expand_y = 0;
   label->fill_x = 1;
   label->fill_y = 1;
   elm_widget_sizing_update(label);

   elm_widget_sizing_update(box);
   box->show(box);
   
   win->show(win);
}

static void
win_scrollable_box_vert_of_labels(void)
{
   Elm_Win *win;
   Elm_Bg *bg;
   Elm_Scroller *scroller;
   Elm_Box *box;
   Elm_Label *label;
   int i;

   win = elm_win_new();
   win->name_set(win, "win_bg");
   win->title_set(win, "Simple Window with scroller and box + labels inside");
   win->autodel = 0;
   win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
   win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);

   bg = elm_bg_new(win);
   bg->expand_x = 1;
   bg->expand_y = 1;
   bg->show(bg);
   
   scroller = elm_scroller_new(win);

   box = elm_box_new(win);
   box->expand_x = 1;
   box->expand_y = 1;

   for (i = 0; i < 40; i++)
     {
	char buf[200];
	
	snprintf(buf, sizeof(buf), "This is a Label in a box, #%i", i);
	label = elm_label_new(win);
	label->text_set(label, buf);
	box->pack_end(box, label);
	label->show(label);
	label->expand_x = 0;
	label->expand_y = 0;
	elm_widget_sizing_update(label);
	label->show(label);
     }

   scroller->child_add(scroller, box);
   
   elm_widget_sizing_update(box);
   box->show(box);
   
   scroller->show(scroller);

   win->size_req(win, NULL, 240, 240);
   win->show(win);
}

static void
win_table_of_labels(void)
{
   Elm_Win *win;
   Elm_Bg *bg;
   Elm_Table *table;
   Elm_Label *label;

   win = elm_win_new();
   win->name_set(win, "win_bg");
   win->title_set(win, "Simple Window with table + labels setting minimum size");
   win->autodel = 0;
   win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
   win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);

   bg = elm_bg_new(win);
   bg->expand_x = 1;
   bg->expand_y = 1;
   bg->show(bg);
   
   table = elm_table_new(win);
   table->expand_x = 1;
   table->expand_y = 1;
   
   label = elm_label_new(win);
   label->text_set(label, "X");
   table->pack(table, label, 0, 0, 1, 1);
   label->fill_x = 0;
   label->fill_y = 0;
   label->show(label);
   elm_widget_sizing_update(label);

   label = elm_label_new(win);
   label->text_set(label, "Y");
   table->pack(table, label, 1, 0, 1, 1);
   label->fill_x = 0;
   label->fill_y = 0;
   label->show(label);
   elm_widget_sizing_update(label);

   label = elm_label_new(win);
   label->text_set(label, "Z");
   table->pack(table, label, 2, 0, 1, 1);
   label->fill_x = 0;
   label->fill_y = 0;
   label->show(label);
   elm_widget_sizing_update(label);

   label = elm_label_new(win);
   label->text_set(label, "A");
   table->pack(table, label, 0, 1, 1, 1);
   label->fill_x = 0;
   label->fill_y = 0;
   label->show(label);
   elm_widget_sizing_update(label);

   label = elm_label_new(win);
   label->text_set(label, "BB");
   table->pack(table, label, 1, 1, 2, 1);
   label->fill_x = 0;
   label->fill_y = 0;
   label->show(label);
   elm_widget_sizing_update(label);

   label = elm_label_new(win);
   label->text_set(label, "CCC");
   table->pack(table, label, 0, 2, 3, 1);
   label->fill_x = 0;
   label->fill_y = 0;
   label->show(label);
   elm_widget_sizing_update(label);

   elm_widget_sizing_update(table);
   table->show(table);
   
   win->show(win);
}

static void
on_button_activate(void *data, Elm_Button *bt, Elm_Cb_Type type, void *info)
{
   printf("Button %p activate\n", bt);
}

static void
win_table_of_buttons(void)
{
   Elm_Win *win;
   Elm_Bg *bg;
   Elm_Icon *icon;
   Elm_Table *table;
   Elm_Button *button;
   char buf[PATH_MAX];

   win = elm_win_new();
   win->name_set(win, "win_bg");
   win->title_set(win, "Simple Window with table + buttons setting minimum size");
   win->autodel = 0;
   win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
   win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);

   bg = elm_bg_new(win);
   bg->expand_x = 1;
   bg->expand_y = 1;
   bg->show(bg);
   
   table = elm_table_new(win);
   table->expand_x = 1;
   table->expand_y = 1;

   button = elm_button_new(win);
   button->text_set(button, "Button 1");
   table->pack(table, button, 0, 0, 1, 1);
   button->fill_x = 0;
   button->fill_y = 0;
   button->show(button);
   elm_widget_sizing_update(button);
   button->cb_add(button, ELM_CB_ACTIVATED, on_button_activate, NULL);

   button = elm_button_new(win);
   button->text_set(button, "Button 2");
   table->pack(table, button, 1, 0, 1, 1);
   button->fill_x = 0;
   button->fill_y = 0;
   button->show(button);
   elm_widget_sizing_update(button);
   button->cb_add(button, ELM_CB_ACTIVATED, on_button_activate, NULL);

   button = elm_button_new(win);
   button->text_set(button, "Button 3");
   table->pack(table, button, 2, 0, 1, 1);
   button->fill_x = 0;
   button->fill_y = 0;
   button->show(button);
   elm_widget_sizing_update(button);
   button->cb_add(button, ELM_CB_ACTIVATED, on_button_activate, NULL);

   button = elm_button_new(win);
   button->text_set(button, "Button 4");
   table->pack(table, button, 0, 1, 1, 1);
   button->fill_x = 1;
   button->fill_y = 0;
   button->show(button);
   elm_widget_sizing_update(button);
   button->cb_add(button, ELM_CB_ACTIVATED, on_button_activate, NULL);

   button = elm_button_new(win);
   icon = elm_icon_new(win);
   snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR);
   icon->file_set(icon, buf, NULL);
   icon->scale_up = 0;
   icon->layout_update(icon);
   button->child_add(button, icon);
   table->pack(table, button, 1, 1, 2, 1);
   button->fill_x = 1;
   button->fill_y = 1;
   button->show(button);
   elm_widget_sizing_update(button);
   button->cb_add(button, ELM_CB_ACTIVATED, on_button_activate, NULL);

   button = elm_button_new(win);
   button->text_set(button, "Button 6");
   icon = elm_icon_new(win);
   snprintf(buf, sizeof(buf), "%s/images/logo.png", PACKAGE_DATA_DIR);
   icon->file_set(icon, buf, NULL);
   button->child_add(button, icon);
   table->pack(table, button, 0, 2, 3, 1);
   button->fill_x = 1;
   button->fill_y = 1;
   button->show(button);
   elm_widget_sizing_update(button);
   button->cb_add(button, ELM_CB_ACTIVATED, on_button_activate, NULL);

   elm_widget_sizing_update(table);
   table->show(table);
   
   win->show(win);
}

static void
on_toggle_changed(void *data, Elm_Toggle *tg, Elm_Cb_Type type, void *info)
{
   printf("toggle: %i\n", tg->state);
}

static void
win_box_vert_of_toggles(void)
{
   Elm_Win *win;
   Elm_Bg *bg;
   Elm_Box *box;
   Elm_Toggle *toggle;
   Elm_Icon *icon;
   char buf[PATH_MAX];

   win = elm_win_new();
   win->name_set(win, "win_bg");
   win->title_set(win, "Simple Window with box + toggles setting min size");
   win->autodel = 0;
   win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
   win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);

   bg = elm_bg_new(win);
   bg->expand_x = 0;
   bg->expand_y = 0;
   bg->show(bg);
   
   box = elm_box_new(win);
   box->expand_x = 0;
   box->expand_y = 0;

   toggle = elm_toggle_new(win);
   toggle->text_set(toggle, "Label ON/OFF");
   toggle->state = 1;
   toggle->layout_update(toggle);
   toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
   box->pack_end(box, toggle);
   toggle->show(toggle);
   toggle->expand_y = 0;
   toggle->fill_y = 0;
   elm_widget_sizing_update(toggle);

   toggle = elm_toggle_new(win);
   toggle->text_set(toggle, "Icon + Label ON/OFF");
   icon = elm_icon_new(win);
   snprintf(buf, sizeof(buf), "%s/images/logo.png", PACKAGE_DATA_DIR);
   icon->file_set(icon, buf, NULL);
   toggle->child_add(toggle, icon);
   toggle->state = 1;
   toggle->layout_update(toggle);
   toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
   box->pack_end(box, toggle);
   toggle->show(toggle);
   toggle->expand_y = 0;
   toggle->fill_y = 0;
   elm_widget_sizing_update(toggle);

   toggle = elm_toggle_new(win);
   toggle->text_set(toggle, NULL);
   icon = elm_icon_new(win);
   snprintf(buf, sizeof(buf), "%s/images/logo.png", PACKAGE_DATA_DIR);
   icon->file_set(icon, buf, NULL);
   toggle->child_add(toggle, icon);
   toggle->state = 1;
   toggle->layout_update(toggle);
   toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
   box->pack_end(box, toggle);
   toggle->show(toggle);
   toggle->expand_y = 0;
   toggle->fill_y = 0;
   elm_widget_sizing_update(toggle);

   toggle = elm_toggle_new(win);
   toggle->text_set(toggle, "Label Yes/No");
   toggle->states_text_set(toggle, "Yes", "No");
   toggle->state = 1;
   toggle->layout_update(toggle);
   toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
   box->pack_end(box, toggle);
   toggle->show(toggle);
   toggle->expand_y = 0;
   toggle->fill_y = 0;
   elm_widget_sizing_update(toggle);

   elm_widget_sizing_update(box);
   box->show(box);
   
   win->show(win);
}

static void
win_scrollable_box_vert_of_toggles_and_buttons(void)
{
   Elm_Win *win;
   Elm_Bg *bg;
   Elm_Box *box;
   Elm_Scroller *scroller;
   Elm_Toggle *toggle;
   Elm_Icon *icon;
   Elm_Button *button;
   Elm_Label *label;
   char buf[PATH_MAX];

   win = elm_win_new();
   win->name_set(win, "win_bg");
   win->title_set(win, "Simple Window with scroller + box + toggles + buttons");
   win->autodel = 0;
   win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
   win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);

   bg = elm_bg_new(win);
   bg->expand_x = 1;
   bg->expand_y = 1;
   bg->show(bg);
   
   scroller = elm_scroller_new(win);

   box = elm_box_new(win);

   toggle = elm_toggle_new(win);
   toggle->text_set(toggle, "Label ON/OFF");
   toggle->state = 1;
   toggle->layout_update(toggle);
   toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
   box->pack_end(box, toggle);
   toggle->show(toggle);
   toggle->expand_y = 0;
   toggle->fill_y = 0;
   elm_widget_sizing_update(toggle);

   toggle = elm_toggle_new(win);
   toggle->text_set(toggle, "Icon + Label ON/OFF");
   icon = elm_icon_new(win);
   snprintf(buf, sizeof(buf), "%s/images/logo.png", PACKAGE_DATA_DIR);
   icon->file_set(icon, buf, NULL);
   toggle->child_add(toggle, icon);
   toggle->state = 1;
   toggle->layout_update(toggle);
   toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
   box->pack_end(box, toggle);
   toggle->show(toggle);
   toggle->expand_y = 0;
   toggle->fill_y = 0;
   elm_widget_sizing_update(toggle);

   toggle = elm_toggle_new(win);
   toggle->text_set(toggle, NULL);
   icon = elm_icon_new(win);
   snprintf(buf, sizeof(buf), "%s/images/logo.png", PACKAGE_DATA_DIR);
   icon->file_set(icon, buf, NULL);
   toggle->child_add(toggle, icon);
   toggle->state = 1;
   toggle->layout_update(toggle);
   toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
   box->pack_end(box, toggle);
   toggle->show(toggle);
   toggle->expand_y = 0;
   toggle->fill_y = 0;
   elm_widget_sizing_update(toggle);

   toggle = elm_toggle_new(win);
   toggle->text_set(toggle, "Label Yes/No");
   toggle->states_text_set(toggle, "Yes", "No");
   toggle->state = 1;
   toggle->layout_update(toggle);
   toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
   box->pack_end(box, toggle);
   toggle->show(toggle);
   toggle->expand_y = 0;
   toggle->fill_y = 0;
   elm_widget_sizing_update(toggle);

   toggle = elm_toggle_new(win);
   toggle->text_set(toggle, "Toggle ");
   toggle->states_text_set(toggle, "Up", "Down");
   toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
   box->pack_end(box, toggle);
   toggle->show(toggle);
   toggle->expand_y = 0;
   toggle->fill_y = 0;
   elm_widget_sizing_update(toggle);

   toggle = elm_toggle_new(win);
   toggle->text_set(toggle, "Toggle ");
   toggle->states_text_set(toggle, "In", "Out");
   toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
   box->pack_end(box, toggle);
   toggle->show(toggle);
   toggle->expand_y = 0;
   toggle->fill_y = 0;
   elm_widget_sizing_update(toggle);

   toggle = elm_toggle_new(win);
   toggle->text_set(toggle, "Toggle ");
   toggle->states_text_set(toggle, "Up", "Down");
   toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
   box->pack_end(box, toggle);
   toggle->show(toggle);
   toggle->expand_y = 0;
   toggle->fill_y = 0;
   elm_widget_sizing_update(toggle);

   label = elm_label_new(win);
   label->text_set(label, 
		   "Hello world<br>"
		   "<br>"
		   "I am a label. I come here to temonstrate how to put<br>"
		   "text into a label, with newlines, even markup to test<br>"
		   "things like <b>bold text</b> where markup can be custom<br>"
		   "and extensible, defined by the theme's textbloxk style<br>"
		   "for the label.<br>"
		   "<br>"
		   "Note that the markup is html-like and things like newline<br>"
		   "chars and tab chars like stdout text are not valid text<br>"
		   "markup mechanisms. Use markup tags instead.<br>"
		   );
   box->pack_end(box, label);
   label->expand_y = 0;
   label->fill_y = 0;
   elm_widget_sizing_update(label);
   label->show(label);
   
   button = elm_button_new(win);
   button->text_set(button, "Button 1");
   box->pack_end(box, button);
   button->expand_y = 0;
   button->fill_y = 0;
   button->show(button);
   elm_widget_sizing_update(button);
   button->cb_add(button, ELM_CB_ACTIVATED, on_button_activate, NULL);
   
   button = elm_button_new(win);
   button->text_set(button, "Button 2");
   box->pack_end(box, button);
   button->expand_y = 0;
   button->fill_y = 0;
   button->show(button);
   elm_widget_sizing_update(button);
   button->cb_add(button, ELM_CB_ACTIVATED, on_button_activate, NULL);
   
   button = elm_button_new(win);
   button->text_set(button, "Button 3");
   box->pack_end(box, button);
   button->expand_y = 0;
   button->fill_y = 0;
   button->show(button);
   elm_widget_sizing_update(button);
   button->cb_add(button, ELM_CB_ACTIVATED, on_button_activate, NULL);
   
   scroller->child_add(scroller, box);
   
   elm_widget_sizing_update(box);
   box->show(box);
   
   scroller->show(scroller);

   win->size_req(win, NULL, 400, 320);
   
   win->show(win);
}

static void
on_clock_changed(void *data, Elm_Clock *cloc, Elm_Cb_Type type, void *info)
{
   printf("clock: %i:%i:%i\n", cloc->hrs, cloc->min, cloc->sec);
}

static void
win_box_vert_of_clock_and_toggles(void)
{
   Elm_Win *win;
   Elm_Bg *bg;
   Elm_Box *box;
   Elm_Toggle *toggle;
   Elm_Clock *cloc;
   Elm_Pad *pad;
   Elm_Frame *frame;
   char buf[PATH_MAX];

   win = elm_win_new();
   win->name_set(win, "win_bg");
   win->title_set(win, "Simple Window with box + toggles setting min size");
   win->autodel = 0;
   win->cb_add(win, ELM_CB_DEL_REQ, on_win_del_req, NULL);
   win->cb_add(win, ELM_CB_RESIZE, on_win_resize, NULL);

   bg = elm_bg_new(win);
   snprintf(buf, sizeof(buf), "%s/images/sky_04.jpg", PACKAGE_DATA_DIR);
   bg->file_set(bg, buf, NULL);
   bg->expand_x = 0;
   bg->expand_y = 0;
   bg->show(bg);
   
   pad = elm_pad_new(win);
   pad->expand_x = 0;
   pad->expand_y = 0;
   pad->show(pad);

   frame = elm_frame_new(win);
   pad->child_add(pad, frame);
   frame->text_set(frame, "Time");
   frame->expand_x = 0;
   frame->expand_y = 0;
   frame->show(frame);
/*
   pad = elm_pad_new(win);
   frame->child_add(frame, pad);
   pad->expand_x = 0;
   pad->expand_y = 0;
   pad->show(pad);
*/
   box = elm_box_new(win);
//   pad->child_add(pad, box);
   frame->child_add(frame, box);
   box->expand_x = 0;
   box->expand_y = 0;

   toggle = elm_toggle_new(win);
   toggle->text_set(toggle, "Alarm");
   toggle->states_text_set(toggle, "ON", "OFF");
   toggle->state = 0;
   toggle->layout_update(toggle);
   toggle->cb_add(toggle, ELM_CB_CHANGED, on_toggle_changed, NULL);
   box->pack_end(box, toggle);
   toggle->show(toggle);
   toggle->expand_y = 0;
   toggle->fill_y = 0;
   elm_widget_sizing_update(toggle);

   cloc = elm_clock_new(win);
   cloc->expand_x = 0;
   cloc->fill_x = 0;
   cloc->edit = 1;
   cloc->hrs = 6;
   cloc->min = 54;
   cloc->sec = 32;
   cloc->time_update(cloc);
   cloc->cb_add(cloc, ELM_CB_CHANGED, on_clock_changed, NULL);
   box->pack_end(box, cloc);
   elm_widget_sizing_update(cloc);
   cloc->show(cloc);
   
   cloc = elm_clock_new(win);
   cloc->expand_x = 0;
   cloc->fill_x = 0;
   box->pack_end(box, cloc);
   elm_widget_sizing_update(cloc);
   cloc->show(cloc);
   
   cloc = elm_clock_new(win);
   cloc->am_pm = 0;
   cloc->seconds = 1;
   cloc->time_update(cloc);
   cloc->expand_x = 0;
   cloc->fill_x = 0;
   box->pack_end(box, cloc);
   elm_widget_sizing_update(cloc);
   cloc->show(cloc);
   
   cloc = elm_clock_new(win);
   cloc->am_pm = 0;
   cloc->seconds = 0;
   cloc->time_update(cloc);
   cloc->expand_x = 0;
   cloc->fill_x = 0;
   box->pack_end(box, cloc);
   elm_widget_sizing_update(cloc);
   cloc->show(cloc);

/*   
   cloc = elm_clock_new(win);
   cloc->am_pm = 1;
   cloc->seconds = 0;
   cloc->time_update(cloc);
   cloc->expand_x = 0;
   cloc->fill_x = 0;
   box->pack_end(box, cloc);
   elm_widget_sizing_update(cloc);
   cloc->show(cloc);
 */
   
   elm_widget_sizing_update(box);
   box->show(box);

   win->show(win);
}

int
main(int argc, char **argv)
{
   /* init Elementary (all Elementary calls begin with elm_ and all data
    * types, enums and macros will be Elm_ and ELM_ etc.) */
   elm_init(argc, argv);

   /* setup some windows with test widgets in them */
   win_bg_simple();
   win_bg_image();
   win_scrollable_label();
   win_label_determines_min_size();
   win_box_vert_of_labels();
   win_scrollable_box_vert_of_labels();
   win_table_of_labels();
   win_table_of_buttons();
   win_box_vert_of_toggles();
   win_scrollable_box_vert_of_toggles_and_buttons();
   win_box_vert_of_clock_and_toggles();
   
   elm_run(); /* and run the program now  and handle all events etc. */
   
   elm_shutdown(); /* clean up and shut down */
   return 0; 
}