els_icon exception handling code added
[framework/uifw/elementary.git] / src / lib / els_icon.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3
4 typedef struct _Smart_Data Smart_Data;
5
6 struct _Smart_Data
7 {
8    Evas_Coord   x, y, w, h;
9    Evas_Object *obj;
10    Evas_Object *prev;
11    int          size;
12    double       scale;
13    Eina_Bool fill_inside : 1;
14    Eina_Bool scale_up : 1;
15    Eina_Bool scale_down : 1;
16    Eina_Bool preloading : 1;
17    Eina_Bool show : 1;
18    Eina_Bool edit : 1;
19    Eina_Bool edje : 1;
20    Eina_Bool aspect_ratio_retained: 1;
21    Elm_Image_Orient orient;
22 };
23
24 /* local subsystem functions */
25 static void _smart_reconfigure(Smart_Data *sd);
26 static void _smart_init(void);
27 static void _smart_add(Evas_Object *obj);
28 static void _smart_del(Evas_Object *obj);
29 static void _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
30 static void _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
31 static void _smart_show(Evas_Object *obj);
32 static void _smart_hide(Evas_Object *obj);
33 static void _smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
34 static void _smart_clip_set(Evas_Object *obj, Evas_Object * clip);
35 static void _smart_clip_unset(Evas_Object *obj);
36
37 static void _els_smart_icon_flip_horizontal(Smart_Data *sd);
38 static void _els_smart_icon_flip_vertical(Smart_Data *sd);
39 static void _els_smart_icon_rotate_180(Smart_Data *sd);
40 static Eina_Bool _els_smart_icon_dropcb(void *,Evas_Object *, Elm_Selection_Data *);
41
42 /* local subsystem globals */
43 static Evas_Smart *_e_smart = NULL;
44
45 /* externally accessible functions */
46 Evas_Object *
47 _els_smart_icon_add(Evas *evas)
48 {
49    _smart_init();
50    return evas_object_smart_add(evas, _e_smart);
51 }
52
53 static void
54 _preloaded(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event __UNUSED__)
55 {
56    Smart_Data *sd = data;
57
58    sd->preloading = EINA_FALSE;
59    if (obj == sd->obj)
60      {
61         if (sd->show)
62           evas_object_show(sd->obj);
63      }
64    if (sd->prev) evas_object_del(sd->prev);
65    sd->prev = NULL;
66 }
67
68 Eina_Bool
69 _els_smart_icon_file_key_set(Evas_Object *obj, const char *file, const char *key)
70 {
71    Smart_Data *sd;
72    Evas_Object *pclip;
73
74    sd = evas_object_smart_data_get(obj);
75    if (!sd) return EINA_FALSE;
76    /* smart code here */
77    /* NOTE: Do not merge upstream for the if (sd->edje) { } statements
78       But wonder whether the edje resource icons have no problem. */
79    if (sd->edje)
80      {
81         if (sd->prev) evas_object_del(sd->prev);
82         pclip = evas_object_clip_get(sd->obj);
83         if (sd->obj) sd->prev = sd->obj;
84         sd->obj = evas_object_image_add(evas_object_evas_get(obj));
85         evas_object_event_callback_add(sd->obj,
86                                        EVAS_CALLBACK_IMAGE_PRELOADED,
87                                        _preloaded, sd);
88         evas_object_smart_member_add(sd->obj, obj);
89         if (sd->prev) evas_object_smart_member_add(sd->prev, obj);
90         evas_object_image_scale_hint_set(sd->obj,
91                                          EVAS_IMAGE_SCALE_HINT_STATIC);
92         evas_object_clip_set(sd->obj, pclip);
93
94         sd->edje = EINA_FALSE;
95      }
96
97    if (!sd->size)
98      evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
99    evas_object_image_file_set(sd->obj, file, key);
100    // NOTE: Do not merge upstream for sd->preloading.
101    sd->preloading = EINA_FALSE; // by default preload off by seok.j.jeong
102    sd->show = EINA_TRUE;
103    // NOTE: Do not merge upstream for sd->preloading.
104    if (sd->preloading)
105      evas_object_image_preload(sd->obj, EINA_FALSE);
106    // NOTE: Do not merge upstream for sd->preloading.
107    if (sd->preloading) // sd->preloading can be changed by above function. so add "if (sd->preloading)" as below
108      evas_object_hide(sd->obj);
109    if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
110      {
111         ERR("Things are going bad for '%s' (%p)", file, sd->obj);
112         return EINA_FALSE;
113      }
114    _smart_reconfigure(sd);
115    return EINA_TRUE;
116 }
117
118 Eina_Bool
119 _els_smart_icon_file_edje_set(Evas_Object *obj, const char *file, const char *part)
120 {
121    Smart_Data *sd;
122    Evas_Object *pclip;
123
124    sd = evas_object_smart_data_get(obj);
125    if (!sd) return EINA_FALSE;
126    /* smart code here */
127    if (sd->prev) evas_object_del(sd->prev);
128    sd->prev = NULL;
129
130    if (!sd->edje)
131      {
132         pclip = evas_object_clip_get(sd->obj);
133         if (sd->obj) evas_object_del(sd->obj);
134         sd->obj = edje_object_add(evas_object_evas_get(obj));
135         evas_object_smart_member_add(sd->obj, obj);
136         if (sd->show) evas_object_show(sd->obj);
137         evas_object_clip_set(sd->obj, pclip);
138      }
139    sd->edje = EINA_TRUE;
140    if (!edje_object_file_set(sd->obj, file, part))
141      return EINA_FALSE;
142    _smart_reconfigure(sd);
143    return EINA_TRUE;
144 }
145
146 void
147 _els_smart_icon_file_get(const Evas_Object *obj, const char **file, const char **key)
148 {
149    Smart_Data *sd = evas_object_smart_data_get(obj);
150    if (!sd) return;
151    if (sd->edje)
152      edje_object_file_get(sd->obj, file, key);
153    else
154      evas_object_image_file_get(sd->obj, file, key);
155 }
156
157 void
158 _els_smart_icon_smooth_scale_set(Evas_Object *obj, Eina_Bool smooth)
159 {
160    Smart_Data *sd = evas_object_smart_data_get(obj);
161    if (!sd) return;
162    if (sd->edje)
163      return;
164    evas_object_image_smooth_scale_set(sd->obj, smooth);
165 }
166
167 Eina_Bool
168 _els_smart_icon_smooth_scale_get(const Evas_Object *obj)
169 {
170    Smart_Data *sd = evas_object_smart_data_get(obj);
171    if (!sd) return EINA_FALSE;
172    if (sd->edje)
173      return EINA_FALSE;
174    return evas_object_image_smooth_scale_get(sd->obj);
175 }
176
177 Evas_Object *
178 _els_smart_icon_object_get(const Evas_Object *obj)
179 {
180    Smart_Data *sd = evas_object_smart_data_get(obj);
181    if (!sd) return NULL;
182    return sd->obj;
183 }
184
185 void
186 _els_smart_icon_size_get(const Evas_Object *obj, int *w, int *h)
187 {
188    Smart_Data *sd;
189    int tw, th;
190    int cw, ch;
191    const char *type;
192
193    sd = evas_object_smart_data_get(obj);
194    if (!sd) return;
195    type = evas_object_type_get(sd->obj);
196    if (!type) return;
197    if (!strcmp(type, "edje"))
198      edje_object_size_min_get(sd->obj, &tw, &th);
199    else
200      evas_object_image_size_get(sd->obj, &tw, &th);
201    evas_object_geometry_get(sd->obj, NULL, NULL, &cw, &ch);
202    tw = tw > cw ? tw : cw;
203    th = th > ch ? th : ch;
204    tw = ((double)tw) * sd->scale;
205    th = ((double)th) * sd->scale;
206    if (w) *w = tw;
207    if (h) *h = th;
208 }
209
210 void
211 _els_smart_icon_fill_inside_set(Evas_Object *obj, Eina_Bool fill_inside)
212 {
213    Smart_Data *sd;
214
215    sd = evas_object_smart_data_get(obj);
216    if (!sd) return;
217    if (((sd->fill_inside) && (fill_inside)) ||
218        ((!sd->fill_inside) && (!fill_inside))) return;
219    sd->fill_inside = fill_inside;
220    _smart_reconfigure(sd);
221 }
222
223 Eina_Bool
224 _els_smart_icon_fill_inside_get(const Evas_Object *obj)
225 {
226    Smart_Data *sd = evas_object_smart_data_get(obj);
227    if (!sd) return EINA_FALSE;
228    return sd->fill_inside;
229 }
230
231 void
232 _els_smart_icon_scale_up_set(Evas_Object *obj, Eina_Bool scale_up)
233 {
234    Smart_Data *sd;
235
236    sd = evas_object_smart_data_get(obj);
237    if (!sd) return;
238    if (((sd->scale_up) && (scale_up)) ||
239        ((!sd->scale_up) && (!scale_up))) return;
240    sd->scale_up = scale_up;
241    _smart_reconfigure(sd);
242 }
243
244 Eina_Bool
245 _els_smart_icon_scale_up_get(const Evas_Object *obj)
246 {
247    Smart_Data *sd; sd = evas_object_smart_data_get(obj);
248    if (!sd) return EINA_FALSE;
249    return sd->scale_up;
250 }
251
252 void
253 _els_smart_icon_scale_down_set(Evas_Object *obj, Eina_Bool scale_down)
254 {
255    Smart_Data *sd;
256
257    sd = evas_object_smart_data_get(obj);
258    if (!sd) return;
259    if (((sd->scale_down) && (scale_down)) ||
260        ((!sd->scale_down) && (!scale_down))) return;
261    sd->scale_down = scale_down;
262    _smart_reconfigure(sd);
263 }
264
265 Eina_Bool
266 _els_smart_icon_scale_down_get(const Evas_Object *obj)
267 {
268    Smart_Data *sd; sd = evas_object_smart_data_get(obj);
269    if (!sd) return EINA_FALSE;
270    return sd->scale_up;
271 }
272
273 void
274 _els_smart_icon_scale_size_set(Evas_Object *obj, int size)
275 {
276    Smart_Data *sd;
277
278    sd = evas_object_smart_data_get(obj);
279    if (!sd) return;
280    sd->size = size;
281    if (!sd->obj) return;
282    if (sd->edje)
283      return;
284    evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
285 }
286
287 int
288 _els_smart_icon_scale_size_get(const Evas_Object *obj)
289 {
290    Smart_Data *sd; sd = evas_object_smart_data_get(obj);
291    if (!sd) return 0;
292    return sd->size;
293 }
294
295 void
296 _els_smart_icon_scale_set(Evas_Object *obj, double scale)
297 {
298    Smart_Data *sd = evas_object_smart_data_get(obj);
299    if (!sd) return;
300    sd->scale = scale;
301    _smart_reconfigure(sd);
302 }
303
304 double
305 _els_smart_icon_scale_get(const Evas_Object *obj)
306 {
307    Smart_Data *sd; sd = evas_object_smart_data_get(obj);
308    if (!sd) return 0.0;
309    return sd->scale;
310 }
311
312 void
313 _els_smart_icon_orient_set(Evas_Object *obj, Elm_Image_Orient orient)
314 {
315    Smart_Data   *sd;
316    Evas_Object  *tmp;
317    unsigned int *data, *data2, *to, *from;
318    int           x, y, w, hw, iw, ih;
319    const char   *file, *key;
320
321    sd = evas_object_smart_data_get(obj);
322    if (!sd) return;
323    if (sd->edje)
324      return;
325
326    switch (orient)
327      {
328       case ELM_IMAGE_FLIP_HORIZONTAL:
329          _els_smart_icon_flip_horizontal(sd);
330          return;
331       case ELM_IMAGE_FLIP_VERTICAL:
332          _els_smart_icon_flip_vertical(sd);
333          return;
334       case ELM_IMAGE_ROTATE_180_CW:
335          _els_smart_icon_rotate_180(sd);
336          return;
337       default:
338          break;
339      }
340
341    evas_object_image_size_get(sd->obj, &iw, &ih);
342    evas_object_image_file_get(sd->obj, &file, &key);
343    tmp = evas_object_image_add(evas_object_evas_get(sd->obj));
344    evas_object_image_file_set(tmp, file, key);
345    data2 = evas_object_image_data_get(tmp, EINA_FALSE);
346
347    w = ih;
348    ih = iw;
349    iw = w;
350    hw = w * ih;
351
352    evas_object_image_size_set(sd->obj, iw, ih);
353    data = evas_object_image_data_get(sd->obj, EINA_TRUE);
354    switch (orient)
355      {
356       case ELM_IMAGE_FLIP_TRANSPOSE:
357          to = data;
358          hw = -hw + 1;
359          break;
360       case ELM_IMAGE_FLIP_TRANSVERSE:
361          to = data + hw - 1;
362          w = -w;
363          hw = hw - 1;
364          break;
365       case ELM_IMAGE_ROTATE_90_CW:
366          to = data + w - 1;
367          hw = -hw - 1;
368          break;
369       case ELM_IMAGE_ROTATE_90_CCW:
370          to = data + hw - w;
371          w = -w;
372          hw = hw + 1;
373          break;
374       default:
375          ERR("unknown orient %d", orient);
376          evas_object_del(tmp);
377          evas_object_image_data_set(sd->obj, data); // give it back
378          return;
379      }
380    from = data2;
381    for (x = iw; --x >= 0;)
382      {
383         for (y = ih; --y >= 0;)
384           {
385              *to = *from;
386              from++;
387              to += w;
388           }
389         to += hw;
390      }
391    sd->orient = orient;
392    evas_object_del(tmp);
393    evas_object_image_data_set(sd->obj, data);
394    evas_object_image_data_update_add(sd->obj, 0, 0, iw, ih);
395    _smart_reconfigure(sd);
396 }
397
398 Elm_Image_Orient
399 _els_smart_icon_orient_get(const Evas_Object *obj)
400 {
401    Smart_Data *sd; sd = evas_object_smart_data_get(obj);
402    if (!sd) return 0;
403    return sd->orient;
404 }
405
406 /**
407  * Turns on editing through drag and drop and copy and paste.
408  */
409 void
410 _els_smart_icon_edit_set(Evas_Object *obj, Eina_Bool edit, Evas_Object *parent)
411 {
412    Smart_Data   *sd = evas_object_smart_data_get(obj);
413    if (!sd) return;
414
415    if (sd->edje)
416      {
417         printf("No editing edje objects yet (ever)\n");
418         return;
419      }
420
421    /* Unfortunately eina bool is not a bool, but a char */
422    if (edit == sd->edit) return;
423
424    sd->edit = edit;
425
426    if (sd->edit)
427      elm_drop_target_add(obj, ELM_SEL_FORMAT_IMAGE, _els_smart_icon_dropcb,
428                          parent);
429    else
430      elm_drop_target_del(obj);
431 }
432
433 Eina_Bool
434 _els_smart_icon_edit_get(const Evas_Object *obj)
435 {
436    Smart_Data *sd; sd = evas_object_smart_data_get(obj);
437    if (!sd) return EINA_FALSE;
438    return sd->edit;
439 }
440
441 Evas_Object *
442 _els_smart_icon_edje_get(Evas_Object *obj)
443 {
444    Smart_Data *sd = evas_object_smart_data_get(obj);
445    if (!sd) return NULL;
446    if (!sd->edje) return NULL;
447    return sd->obj;
448 }
449
450 void
451 _els_smart_icon_aspect_ratio_retained_set(Evas_Object *obj, Eina_Bool retained)
452 {
453    Smart_Data *sd;
454
455    sd = evas_object_smart_data_get(obj);
456    if (!sd) return;
457
458    retained = !!retained;
459    if (sd->aspect_ratio_retained == retained) return;
460    sd->aspect_ratio_retained = retained;
461    _smart_reconfigure(sd);
462 }
463
464 Eina_Bool
465 _els_smart_icon_aspect_ratio_retained_get(const Evas_Object *obj)
466 {
467    Smart_Data *sd;
468
469    sd = evas_object_smart_data_get(obj);
470    if (!sd) return EINA_FALSE;
471    return sd->aspect_ratio_retained;
472 }
473
474 /* local subsystem globals */
475 static void
476 _smart_reconfigure(Smart_Data *sd)
477 {
478    Evas_Coord x, y, w, h;
479    const char *type;
480
481    if (!sd->obj) return;
482
483    w = sd->w;
484    h = sd->h;
485
486    type = evas_object_type_get(sd->obj);
487    if (!type) return;
488    if (!strcmp(type, "edje"))
489      {
490         x = sd->x;
491         y = sd->y;
492         evas_object_move(sd->obj, x, y);
493         evas_object_resize(sd->obj, w, h);
494      }
495    else
496      {
497         int iw = 0, ih = 0;
498
499         evas_object_image_size_get(sd->obj, &iw, &ih);
500
501         iw = ((double)iw) * sd->scale;
502         ih = ((double)ih) * sd->scale;
503
504         if (iw < 1) iw = 1;
505         if (ih < 1) ih = 1;
506
507         if (sd->aspect_ratio_retained)
508           {
509              h = ((double)ih * w) / (double)iw;
510              if (sd->fill_inside)
511                {
512                   if (h > sd->h)
513                     {
514                        h = sd->h;
515                        w = ((double)iw * h) / (double)ih;
516                     }
517                }
518              else
519                {
520                   if (h < sd->h)
521                     {
522                        h = sd->h;
523                        w = ((double)iw * h) / (double)ih;
524                     }
525                }
526           }
527         if (!sd->scale_up)
528           {
529              if (w > iw) w = iw;
530              if (h > ih) h = ih;
531           }
532         if (!sd->scale_down)
533           {
534              if (w < iw) w = iw;
535              if (h < ih) h = ih;
536           }
537         x = sd->x + ((sd->w - w) / 2);
538         y = sd->y + ((sd->h - h) / 2);
539         evas_object_move(sd->obj, x, y);
540         evas_object_image_fill_set(sd->obj, 0, 0, w, h);
541         evas_object_resize(sd->obj, w, h);
542      }
543 }
544
545 static void
546 _smart_init(void)
547 {
548    if (_e_smart) return;
549      {
550         static const Evas_Smart_Class sc =
551           {
552              "e_icon",
553              EVAS_SMART_CLASS_VERSION,
554              _smart_add,
555              _smart_del,
556              _smart_move,
557              _smart_resize,
558              _smart_show,
559              _smart_hide,
560              _smart_color_set,
561              _smart_clip_set,
562              _smart_clip_unset,
563              NULL,
564              NULL,
565              NULL,
566              NULL,
567              NULL,
568              NULL,
569              NULL
570           };
571         _e_smart = evas_smart_class_new(&sc);
572      }
573 }
574
575 static void
576 _smart_add(Evas_Object *obj)
577 {
578    Smart_Data *sd;
579
580    sd = calloc(1, sizeof(Smart_Data));
581    if (!sd) return;
582    sd->obj = evas_object_image_add(evas_object_evas_get(obj));
583    sd->prev = NULL;
584    evas_object_image_scale_hint_set(sd->obj, EVAS_IMAGE_SCALE_HINT_STATIC);
585    sd->x = 0;
586    sd->y = 0;
587    sd->w = 0;
588    sd->h = 0;
589    sd->fill_inside = EINA_TRUE;
590    sd->scale_up = EINA_TRUE;
591    sd->scale_down = EINA_TRUE;
592    sd->aspect_ratio_retained = EINA_TRUE;
593    sd->size = 64;
594    sd->scale = 1.0;
595    evas_object_smart_member_add(sd->obj, obj);
596    evas_object_smart_data_set(obj, sd);
597    evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_IMAGE_PRELOADED,
598                                   _preloaded, sd);
599 }
600
601 static void
602 _smart_del(Evas_Object *obj)
603 {
604    Smart_Data *sd;
605
606    sd = evas_object_smart_data_get(obj);
607    if (!sd) return;
608    evas_object_del(sd->obj);
609    if (sd->prev) evas_object_del(sd->prev);
610    free(sd);
611 }
612
613 static void
614 _smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
615 {
616    Smart_Data *sd;
617
618    sd = evas_object_smart_data_get(obj);
619    if (!sd) return;
620    if ((sd->x == x) && (sd->y == y)) return;
621    sd->x = x;
622    sd->y = y;
623    _smart_reconfigure(sd);
624 }
625
626 static void
627 _smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
628 {
629    Smart_Data *sd;
630
631    sd = evas_object_smart_data_get(obj);
632    if (!sd) return;
633    if ((sd->w == w) && (sd->h == h)) return;
634    sd->w = w;
635    sd->h = h;
636    _smart_reconfigure(sd);
637 }
638
639 static void
640 _smart_show(Evas_Object *obj)
641 {
642    Smart_Data *sd;
643
644    sd = evas_object_smart_data_get(obj);
645    if (!sd) return;
646    sd->show = EINA_TRUE;
647    if (!sd->preloading)
648      {
649         evas_object_show(sd->obj);
650         if (sd->prev) evas_object_del(sd->prev);
651         sd->prev = NULL;
652      }
653 }
654
655 static void
656 _smart_hide(Evas_Object *obj)
657 {
658    Smart_Data *sd;
659
660    sd = evas_object_smart_data_get(obj);
661    if (!sd) return;
662    sd->show = EINA_FALSE;
663    evas_object_hide(sd->obj);
664    if (sd->prev) evas_object_del(sd->prev);
665    sd->prev = NULL;
666 }
667
668 static void
669 _smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
670 {
671    Smart_Data *sd;
672
673    sd = evas_object_smart_data_get(obj);
674    if (!sd) return;
675    evas_object_color_set(sd->obj, r, g, b, a);
676    if (sd->prev) evas_object_color_set(sd->prev, r, g, b, a);
677 }
678
679 static void
680 _smart_clip_set(Evas_Object *obj, Evas_Object * clip)
681 {
682    Smart_Data *sd;
683
684    sd = evas_object_smart_data_get(obj);
685    if (!sd) return;
686    evas_object_clip_set(sd->obj, clip);
687    if (sd->prev) evas_object_clip_set(sd->prev, clip);
688 }
689
690 static void
691 _smart_clip_unset(Evas_Object *obj)
692 {
693    Smart_Data *sd;
694
695    sd = evas_object_smart_data_get(obj);
696    if (!sd) return;
697    evas_object_clip_unset(sd->obj);
698    if (sd->prev) evas_object_clip_unset(sd->prev);
699 }
700
701 static void
702 _els_smart_icon_flip_horizontal(Smart_Data *sd)
703 {
704    unsigned int   *data;
705    unsigned int   *p1, *p2, tmp;
706    int             x, y, iw, ih;
707
708    evas_object_image_size_get(sd->obj, &iw, &ih);
709    data = evas_object_image_data_get(sd->obj, EINA_TRUE);
710
711    for (y = 0; y < ih; y++)
712      {
713         p1 = data + (y * iw);
714         p2 = data + ((y + 1) * iw) - 1;
715         for (x = 0; x < (iw >> 1); x++)
716           {
717              tmp = *p1;
718              *p1 = *p2;
719              *p2 = tmp;
720              p1++;
721              p2--;
722           }
723      }
724
725    evas_object_image_data_set(sd->obj, data);
726    evas_object_image_data_update_add(sd->obj, 0, 0, iw, ih);
727    _smart_reconfigure(sd);
728 }
729
730 static void
731 _els_smart_icon_flip_vertical(Smart_Data *sd)
732 {
733    unsigned int   *data;
734    unsigned int   *p1, *p2, tmp;
735    int             x, y, iw, ih;
736
737    evas_object_image_size_get(sd->obj, &iw, &ih);
738    data = evas_object_image_data_get(sd->obj, EINA_TRUE);
739
740    for (y = 0; y < (ih >> 1); y++)
741      {
742         p1 = data + (y * iw);
743         p2 = data + ((ih - 1 - y) * iw);
744         for (x = 0; x < iw; x++)
745           {
746              tmp = *p1;
747              *p1 = *p2;
748              *p2 = tmp;
749              p1++;
750              p2++;
751           }
752      }
753
754    evas_object_image_data_set(sd->obj, data);
755    evas_object_image_data_update_add(sd->obj, 0, 0, iw, ih);
756    _smart_reconfigure(sd);
757 }
758
759 static void
760 _els_smart_icon_rotate_180(Smart_Data *sd)
761 {
762    unsigned int   *data;
763    unsigned int   *p1, *p2, tmp;
764    int             x, hw, iw, ih;
765
766    evas_object_image_size_get(sd->obj, &iw, &ih);
767    data = evas_object_image_data_get(sd->obj, 1);
768
769    hw = iw * ih;
770    x = (hw / 2);
771    p1 = data;
772    p2 = data + hw - 1;
773    for (; --x > 0;)
774      {
775         tmp = *p1;
776         *p1 = *p2;
777         *p2 = tmp;
778         p1++;
779         p2--;
780      }
781    evas_object_image_data_set(sd->obj, data);
782    evas_object_image_data_update_add(sd->obj, 0, 0, iw, ih);
783    _smart_reconfigure(sd);
784 }
785
786 static Eina_Bool
787 _els_smart_icon_dropcb(void *elmobj,Evas_Object *obj, Elm_Selection_Data *drop)
788 {
789    _els_smart_icon_file_key_set(obj, drop->data, NULL);
790    evas_object_smart_callback_call(elmobj, "drop", drop->data);
791
792    return EINA_TRUE;
793 }
794 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-3f0^-2{2(0W1st0 :*/