From 99e14a0d8f0447290eaff38be4e71afb63a3e332 Mon Sep 17 00:00:00 2001 From: Patrick Hornecker Date: Fri, 5 Feb 2010 10:22:24 +0100 Subject: tex source and barcode improvements --- friendfinder/DlTdkw19.xhtml.part | 560 --------------------------------------- friendfinder/Makefile.inc | 2 +- friendfinder/barcode.c | 55 +++- friendfinder/barcode.h | 1 + friendfinder/barcode.png | Bin 1561 -> 524 bytes friendfinder/gui | Bin 188787 -> 186893 bytes friendfinder/gui.c | 4 +- 7 files changed, 53 insertions(+), 569 deletions(-) delete mode 100644 friendfinder/DlTdkw19.xhtml.part (limited to 'friendfinder') diff --git a/friendfinder/DlTdkw19.xhtml.part b/friendfinder/DlTdkw19.xhtml.part deleted file mode 100644 index dd4b938..0000000 --- a/friendfinder/DlTdkw19.xhtml.part +++ /dev/null @@ -1,560 +0,0 @@ - - - - - - - - - -git.openslx.org - lsfks/friendfinder.git/blob - friendfinder/e_smart_map.c - - - - - - - - - -
- -
- -
-bugs and memory fixes -
-
[lsfks/friendfinder.git] / friendfinder / e_smart_map.c
-
-
1 #include <stdio.h>
-
2 #include <string.h>
-
3
-
4 #include <Ecore.h>
-
5 #include <Ecore_Evas.h>
-
6 #include <Edje.h>
-
7 #include <Elementary.h>
-
8
-
9 #include "e_smart_map.h"
-
10 #include "e_smart_tile.h"
-
11
-
12 #include "render/line.h"
-
13
-
14 #include "map/smart_map_priv.h"
-
15
-
16 #include "util/sqlite_helper.h"
-
17
-
18 static Evas_Smart *get_smart();
-
19 static void _map_object_add(Evas_Object *o);
-
20 static void _map_object_del(Evas_Object *o);
-
21 static void _map_object_move(Evas_Object *o, Evas_Coord x, Evas_Coord y);
-
22 static void _map_object_resize(Evas_Object *o, Evas_Coord w, Evas_Coord h);
-
23 static void _map_object_show(Evas_Object *o);
-
24 static void _map_object_hide(Evas_Object *o);
-
25 static void _map_object_color_set(Evas_Object *o, int r, int g, int b, int a);
-
26 static void _map_object_clip_set(Evas_Object *o, Evas_Object *clip);
-
27 static void _map_object_clip_unset(Evas_Object *o);
-
28
-
29 #define SMART_MAP_NAME "e_smart_map"
-
30
-
31 void e_smart_map_set_info(Evas_Object *o, const char *info)
-
32 {
-
33         struct smart_map *smart;
-
34
-
35         smart = evas_object_smart_data_get(o);
-
36         if(smart->theme == NULL)
-
37                 return;
-
38
-
39         edje_object_part_text_set(smart->theme, "position", info);
-
40 }
-
41
-
42 struct bubble
-
43 {
-
44         struct overlay_object object;
-
45         Evas_Object *av;
-
46         Evas_Object *bb;
-
47 };
-
48
-
49 static struct bubble *create_text_bubble(struct smart_map *smart, char *info, char *text)
-
50 {
-
51         struct bubble *bubble;
-
52
-
53         bubble = (struct bubble*)malloc(sizeof(struct bubble));
-
54
-
55         bubble->object.obj = elm_box_add(smart->win);
-
56         evas_object_size_hint_weight_set(bubble->object.obj, 1.0, 1.0);
-
57         evas_object_size_hint_align_set(bubble->object.obj, 0.0, 0.0);
-
58         
-
59         bubble->av = elm_entry_add(smart->win);
-
60         elm_entry_entry_set(bubble->av, text);
-
61         elm_entry_line_wrap_set(bubble->av, 0);
-
62         evas_object_size_hint_weight_set(bubble->av, 1.0, 1.0);
-
63         // evas_object_smart_callback_add(av, "anchor,clicked", my_anchorblock_anchor, av);
-
64
-
65         bubble->bb = elm_bubble_add(smart->win);
-
66         elm_bubble_info_set(bubble->bb, info);
-
67         evas_object_size_hint_min_set(bubble->bb, 150, 150);
-
68         evas_object_size_hint_max_set(bubble->bb, 300, 300);
-
69         evas_object_size_hint_weight_set(bubble->bb, 1.0, 1.0);
-
70         evas_object_size_hint_align_set(bubble->bb, 0.0, 0.0);
-
71         elm_bubble_content_set(bubble->bb, bubble->av);
-
72         evas_object_show(bubble->av);
-
73         elm_anchorblock_hover_end(bubble->av);
-
74         elm_box_pack_end(bubble->object.obj, bubble->bb);
-
75                 
-
76         //      evas_object_resize(bb, 100, 80);
-
77         //      evas_object_move(bb, 120 - 15,160-23);
-
78         evas_object_show(bubble->bb);
-
79         bubble->object.ox = -14;
-
80         bubble->object.oy = -14;
-
81         bubble->object.sw = 480;
-
82         bubble->object.sh = 640;
-
83         //fprintf(stderr, "FIXME: %s:%i\n", __FILE__, __LINE__);
-
84         return bubble;
-
85 }
-
86
-
87 void e_smart_map_overlay_set_bubble(Evas_Object *o, char *overlay, char *info, char *text, double lat, double lon, int flags, int type)
-
88 {
-
89         struct smart_map *smart;
-
90         smart = evas_object_smart_data_get(o);
-
91
-
92         struct bubble *bb;
-
93         struct overlay_item *poi = malloc(sizeof(struct overlay_item));
-
94         bb = create_text_bubble(smart, info, text);
-
95
-
96         if (type == 0)
-
97         {
-
98
-
99                 poi->obj = &bb->object;
-
100                 poi->lat = lat;
-
101                 poi->lon = lon;
-
102                 poi->level_mask = flags;
-
103
-
104                 struct map_overlay *ov = overlay_find_by_name(smart, overlay);
-
105                 if(ov == NULL)
-
106                         e_smart_map_add_overlay(o, overlay);
-
107
-
108                 ov = overlay_find_by_name(smart, overlay);
-
109                 if(ov == NULL)
-
110                         return;
-
111
-
112                 overlay_add(smart, ov, poi);
-
113                 overlay_change_level(smart, smart->current_level);
-
114                 map_object_update(smart);
-
115         }
-
116
-
117         if (type == 1)
-
118         {
-
119                 poi->obj = &bb->object;
-
120                 poi->lat = lat;
-
121                 poi->lon = lon;
-
122                 poi->level_mask = flags;
-
123
-
124                 struct map_overlay *ov = overlay_find_by_name(smart, overlay);
-
125                 if(ov == NULL)
-
126                         e_smart_map_add_overlay(o, overlay);
-
127
-
128                 ov = overlay_find_by_name(smart, overlay);
-
129                 if(ov == NULL)
-
130                         return;
-
131                 
-
132                 map_object_update(smart);               
-
133         }
-
134 }
-
135
-
136 void e_smart_map_overlay_hide(Evas_Object *o, char *overlay)
-
137 {
-
138         struct smart_map *smart;
-
139         smart = evas_object_smart_data_get(o);
-
140
-
141         overlay_hide(smart, overlay);
-
142 }
-
143
-
144 void e_smart_map_set_pos_px(Evas_Object *o, Evas_Coord x, Evas_Coord y)
-
145 {
-
146         struct smart_map *smart;
-
147
-
148         smart = evas_object_smart_data_get(o);
-
149         smart->ta.ox = x;
-
150         smart->ta.oy = y;
-
151         smart->ta.mode = POSITION_PX;
-
152         map_object_update(smart);
-
153 }
-
154
-
155 void e_smart_map_set_pos(Evas_Object *o, double lat, double lon)
-
156 {
-
157         struct smart_map *smart;
-
158
-
159         smart = evas_object_smart_data_get(o);
-
160         smart->ta.lat = lat;
-
161         smart->ta.lon = lon;
-
162         smart->ta.mode = POSITION_WORLD;
-
163         smart->lat = lat;
-
164         smart->lon = lon;
-
165         map_object_update(smart);
-
166 }
-
167
-
168 void e_smart_map_get_pos(Evas_Object *o, double *lat, double *lon)
-
169 {
-
170         struct smart_map *smart;
-
171
-
172         smart = evas_object_smart_data_get(o);
-
173         *lat = smart->lat;
-
174         *lon = smart->lon;
-
175         printf("%f \n", smart->lat);
-
176 }
-
177
-
178
-
179 void e_smart_map_move(Evas_Object *o, Evas_Coord dx, Evas_Coord dy)
-
180 {
-
181         struct smart_map *smart;
-
182
-
183         smart = evas_object_smart_data_get(o);
-
184         smart->ta.ox += dx;
-
185         smart->ta.oy += dy;
-
186         smart->ta.mode = POSITION_PX;
-
187         map_object_update(smart);
-
188 }
-
189
-
190 static inline void 
-
191 _polyline_to_map(struct smart_map *smart, struct polyline *pl)
-
192 {
-
193         int i;
-
194         int bx, by;     
-
195   
-
196         if(smart->li == NULL)
-
197                 return;
-
198   
-
199         for(i = 0; i < pl->count; i++)
-
200         {
-
201                 if(i == 0)
-
202                 {
-
203                 
-
204                         latlon_to_map(smart->li, 
-
205                                 pl->points[i].lat, pl->points[i].lon, &bx, &by);
-
206                         pl->points[i].x = bx;
-
207                         pl->points[i].y = by;
-
208                 }
-
209                 else {
-
210                         int x, y;
-
211                         latlon_to_map(smart->li, 
-
212                                 pl->points[i].lat, pl->points[i].lon, &x, &y);
-
213                         pl->points[i].x = x;
-
214                         pl->points[i].y = y;
-
215
-
216                 }
-
217         //      point_dump(&pl->points[i]);
-
218         }
-
219 }
-
220
-
221 int e_smart_map_add_path(Evas_Object *o, struct polyline *_pl)
-
222 {
-
223         struct smart_map *smart;
-
224         smart = evas_object_smart_data_get(o);
-
225
-
226         Evas_Object *poly = e_smart_line_add(smart->evas);
-
227         _polyline_to_map(smart, _pl);
-
228         e_smart_line_set(poly, _pl);
-
229         evas_object_layer_set(poly, 0);
-
230         evas_object_pass_events_set(poly, 1);
-
231         evas_object_layer_set(smart->c.ctrl, 5);        
-
232         evas_object_show(poly);
-
233         eina_array_push(smart->paths, poly);
-
234         map_object_update(smart);
-
235         return 0;
-
236 }
-
237
-
238 int e_smart_map_add_overlay(Evas_Object *o, char *name)
-
239 {
-
240         struct smart_map *smart;
-
241         smart = evas_object_smart_data_get(o);
-
242         
-
243         struct map_overlay *ov = overlay_create(smart, name);
-
244         if(ov == NULL)
-
245                 return -1;
-
246
-
247         return eina_array_push(smart->overlays, ov);    
-
248 }
-
249
-
250 Evas_Object *e_smart_map_add(Evas_Object *win, const char *map_eet)
-
251 {
-
252         Evas_Object *obj;
-
253         struct smart_map *smart;
-
254         Evas *e;
-
255
-
256         e = evas_object_evas_get(win);
-
257         obj = evas_object_smart_add(e, get_smart());
-
258         if(obj == NULL)
-
259                 return NULL;
-
260
-
261         smart = evas_object_smart_data_get(obj);
-
262         if(smart == NULL)
-
263         {
-
264                 evas_object_del(obj);
-
265                 return NULL;
-
266         }
-
267         smart->mi = map_info_read(map_eet);
-
268         if(smart->mi == NULL)
-
269         {
-
270                 printf("map_info read failed\n");
-
271                 evas_object_del(obj);
-
272                 return NULL;
-
273         }
-
274
-
275         smart->evas = e;
-
276         smart->li = NULL;
-
277         smart->ta.tiles = NULL;
-
278         smart->ta.ox = 0;
-
279         smart->ta.oy = 0;
-
280         smart->ta.mode = POSITION_PX;
-
281         smart->drag = 0;
-
282         smart->theme = NULL;
-
283         smart->win = win;
-
284         smart->overlays = eina_array_new(4);
-
285         smart->paths = eina_array_new(4);
-
286         controls_init(smart);
-
287         _set_level(smart, 8);   
-
288         return obj;
-
289 }
-
290
-
291 int _set_level(struct smart_map *smart, int level)
-
292 {
-
293         Eina_Array_Iterator iterator;
-
294         int i;
-
295         Evas_Object *path;
-
296         
-
297         smart->li = map_info_get_level(smart->mi, &level);
-
298         if(smart->li == NULL)
-
299                 return -1;
-
300
-
301         smart->current_level = level;
-
302         smart->ta.lat = smart->lat;
-
303         smart->ta.lon = smart->lon;
-
304         smart->ta.mode = POSITION_WORLD;
-
305
-
306         EINA_ARRAY_ITER_NEXT(smart->paths, i, path, iterator)
-
307         {
-
308                 struct polyline *_pl = e_smart_line_get(path);
-
309                 if(_pl == NULL)
-
310                         continue;
-
311                 _polyline_to_map(smart, _pl);
-
312                 e_smart_line_set(path, _pl);
-
313                 evas_object_show(path);
-
314         }
-
315
-
316         overlay_change_level(smart, level);
-
317         map_object_update(smart);
-
318         return 0;
-
319 }
-
320
-
321 int e_smart_map_set_level(Evas_Object *o, int level)
-
322 {
-
323         struct smart_map *smart;
-
324
-
325         smart = evas_object_smart_data_get(o);
-
326         return _set_level(smart, level);
-
327 }
-
328
-
329 static void
-
330 zoom_cb(void *data, Evas_Object *o, const char *emission, const char *source)
-
331 {
-
332         double x, y;
-
333         int new_level;
-
334         struct smart_map *smart = (struct smart_map *)data;
-
335         int max_level = smart->mi->max_level; 
-
336         int min_level = smart->mi->min_level;
-
337
-
338         edje_object_part_drag_value_get(smart->theme, "zoom", &x, &y);
-
339         new_level = max_level - ((max_level - min_level) * y);
-
340
-
341         smart->ta.lat = smart->lat;
-
342         smart->ta.lon = smart->lon;
-
343         smart->ta.mode = POSITION_WORLD;
-
344
-
345         _set_level(smart, new_level);
-
346 }
-
347
-
348 int e_smart_map_set_theme(Evas_Object *o, const char *theme, const char *group)
-
349 {
-
350         Evas_Object *edje;
-
351         struct smart_map *smart;
-
352
-
353         smart = evas_object_smart_data_get(o);
-
354         edje = edje_object_add(evas_object_evas_get(o));
-
355         if(!edje_object_file_set(edje, theme, group))
-
356         {
-
357                 printf("failed loading %s/%s\n", theme, group);
-
358                 return -1;
-
359         }
-
360
-
361         // XXX: reset ? 
-
362         smart->theme = edje;
-
363
-
364         evas_object_smart_member_add(edje, o);
-
365         evas_object_move(edje, smart->x, smart->y);
-
366         evas_object_resize(edje, smart->w, smart->h);
-
367         evas_object_clip_set(edje, smart->clip);
-
368         evas_object_show(edje);
-
369
-
370         edje_object_signal_callback_add(edje, "drag", "zoom", zoom_cb, smart);
-
371         edje_object_part_drag_value_set(edje, "zoom", 0.0, 0.5);
-
372         return 0;
-
373 }
-
374
-
375 static void _map_object_add(Evas_Object *o)
-
376 {
-
377         struct smart_map *smart;
-
378
-
379         smart = calloc(1, sizeof(struct smart_map));
-
380         if(smart == NULL)
-
381                 return;
-
382
-
383         smart->obj = o;
-
384         smart->x = 0;
-
385         smart->y = 0;
-
386         smart->w = 0;
-
387         smart->h = 0;
-
388
-
389         smart->clip = evas_object_rectangle_add(evas_object_evas_get(o));
-
390         evas_object_smart_member_add(smart->clip, o);
-
391         evas_object_color_set(smart->clip, 255, 255, 255, 255);
-
392
-
393                 evas_object_smart_data_set(o, smart);
-
394 }
-
395
-
396 static void _map_object_del(Evas_Object *o)
-
397 {
-
398         struct smart_map *smart;
-
399         smart = evas_object_smart_data_get(o);
-
400
-
401         // XXX
-
402
-
403         free(smart);
-
404 }
-
405
-
406 static void _map_object_move(Evas_Object *o, Evas_Coord x, Evas_Coord y)
-
407 {
-
408         struct smart_map *smart;
-
409         smart = evas_object_smart_data_get(o);
-
410         if(!smart)
-
411                 return;
-
412
-
413         smart->x = x;
-
414         smart->y = y;
-
415         evas_object_move(smart->clip, x, y);
-
416         evas_object_move(smart->c.ctrl, x, y);
-
417         if(smart->theme)
-
418                 evas_object_move(smart->theme, x, y);
-
419         map_object_update(smart);
-
420 }
-
421
-
422 static void _map_object_resize(Evas_Object *o, Evas_Coord w, Evas_Coord h)
-
423 {
-
424         struct smart_map *smart;
-
425         smart = evas_object_smart_data_get(o);
-
426         if(!smart)
-
427                 return;
-
428         smart->w = w;
-
429         smart->h = h;
-
430         smart->ta.w = w;
-
431         smart->ta.h = h;
-
432         evas_object_resize(smart->clip, w, h);
-
433         evas_object_resize(smart->c.ctrl, w, h);
-
434         if(smart->theme)
-
435                 evas_object_resize(smart->theme, w, h);
-
436         map_object_update(smart);
-
437 }
-
438
-
439 static void _map_object_show(Evas_Object *o)
-
440 {
-
441         struct smart_map *smart;
-
442         smart = evas_object_smart_data_get(o);
-
443         if(!smart)
-
444                 return;
-
445         evas_object_show(smart->clip);
-
446 }
-
447
-
448 static void _map_object_hide(Evas_Object *o)
-
449 {
-
450         struct smart_map *smart;
-
451         smart = evas_object_smart_data_get(o);
-
452         if(!smart)
-
453                 return;
-
454         evas_object_hide(smart->clip);  
-
455 }
-
456
-
457 static void _map_object_color_set(Evas_Object *o, int r, int g, int b, int a)
-
458 {
-
459         struct smart_map *smart;
-
460         smart = evas_object_smart_data_get(o);
-
461         if(!smart)
-
462                 return;
-
463         evas_object_color_set(smart->clip, r, g, b, a);
-
464 }
-
465
-
466 static void _map_object_clip_set(Evas_Object *o, Evas_Object *clip)
-
467 {
-
468         struct smart_map *smart;
-
469         smart = evas_object_smart_data_get(o);
-
470         if(!smart)
-
471                 return;
-
472         evas_object_clip_set(smart->clip, clip);        
-
473 }
-
474
-
475 static void _map_object_clip_unset(Evas_Object *o)
-
476 {
-
477         struct smart_map *smart;
-
478         smart = evas_object_smart_data_get(o);
-
479         if(!smart)
-
480                 return;
-
481         evas_object_clip_unset(smart->clip);    
-
482 }
-
483
-
484 static Evas_Smart *get_smart()
-
485 {
-
486         static Evas_Smart *e_smart_map = NULL;
-
487         
-
488         if(e_smart_map != NULL)
-
489                 return e_smart_map;
-
490
-
491         e_smart_map = evas_smart_new(SMART_MAP_NAME,
-
492                 _map_object_add,
-
493                 _map_object_del,
-
494                 NULL,
-
495                 NULL,
-
496                 NULL,
-
497                 NULL,
-
498                 NULL,
-
499                 _map_object_move,
-
500                 _map_object_resize,
-
501                 _map_object_show,
-
502                 _map_object_hide,
-
503                 _map_object_color_set,
-
504                 _map_object_clip_set,
-
505                 _map_object_clip_unset,
-
506                 NULL);
-
507         return e_smart_map;
-
508 }
-
509
-
- - \ No newline at end of file diff --git a/friendfinder/Makefile.inc b/friendfinder/Makefile.inc index 019f3d6..75b248c 100644 --- a/friendfinder/Makefile.inc +++ b/friendfinder/Makefile.inc @@ -4,7 +4,7 @@ CFLAGS = -g -Wall -rdynamic -std=c99 INCLUDES = -I../include -LIBS = -ledje -lecore -levas -lelementary -lircclient -lcrypto -lproj -lpthread -ldmtx -lImlib2 +LIBS = -ledje -lecore -levas -lelementary -lircclient -lcrypto -lproj -lpthread -lqrencode ########### diff --git a/friendfinder/barcode.c b/friendfinder/barcode.c index 25866e0..21915db 100644 --- a/friendfinder/barcode.c +++ b/friendfinder/barcode.c @@ -2,13 +2,54 @@ #include #include -#include "dmtx.h" +#include "qrencode.h" #include "Imlib2.h" #include "barcode.h" +#include "Evas.h" +#include "Ecore.h" +#include "Ecore_Evas.h" +void write_img(QRcode *code) +{ + Ecore_Evas *ee; + Evas_Object *pic; + Evas *e; + + + ee = ecore_evas_buffer_new(1, 1); + e = ecore_evas_get(ee); + + if (!e) + { + fputs("ERROR: could not create ecore evas buffer\n", stderr); + return; + } + + evas_image_cache_set(e, 0); + evas_font_cache_set(e, 0); + + pic = evas_object_image_add(e); + evas_object_image_file_set(pic, "barcode.png", NULL); + + evas_object_image_size_set(pic, code->width, code->width); + //evas_object_image_alpha_set(pic, 0); + evas_object_image_data_set(pic, code->data); + evas_object_image_data_convert(pic, EVAS_COLORSPACE_ARGB8888); + evas_object_image_save(pic, "barcode.png", NULL, "quality=100 compress=9"); +// return pic; +} void generate_barcode(char* key) { + QRcode *code; + + code = QRcode_encodeString8bit(key, 0, QR_ECLEVEL_M);//, QR_MODE_8, 1); + + write_img(code); + + QRcode_free(code); +/* + Evas_Object *pic; size_t width, height, bytesPerPixel; unsigned char *pxl; DmtxEncode *enc; @@ -28,12 +69,12 @@ void generate_barcode(char* key) dmtxImageSetProp(enc->image, DmtxPropImageFlip, DmtxFlipNone); - write_img(enc); -} - - -void write_img(DmtxEncode* enc) -{ + write_img(enc, win); + + if (pic != NULL) + printf("barcode created...\n"); */ +// return pic; } + diff --git a/friendfinder/barcode.h b/friendfinder/barcode.h index ca00d68..715a44d 100644 --- a/friendfinder/barcode.h +++ b/friendfinder/barcode.h @@ -1,6 +1,7 @@ #ifndef __GUI_H_ #define __GUI_H_ + void generate_barcode(char* key); #endif diff --git a/friendfinder/barcode.png b/friendfinder/barcode.png index 6e4cdd6..17a47e7 100644 Binary files a/friendfinder/barcode.png and b/friendfinder/barcode.png differ diff --git a/friendfinder/gui b/friendfinder/gui index ad42c82..2a3c03f 100755 Binary files a/friendfinder/gui and b/friendfinder/gui differ diff --git a/friendfinder/gui.c b/friendfinder/gui.c index 4138d67..9dfb1c0 100644 --- a/friendfinder/gui.c +++ b/friendfinder/gui.c @@ -113,17 +113,19 @@ static void create_barcode(void *data, Evas_Object *obj, void *event_info) else return; Evas_Object *img = elm_image_add(win); - printf("%i \n",elm_image_file_set(img, "barcode.png", "")); + elm_image_file_set(img, "barcode.png", ""); evas_object_size_hint_weight_set(img, 1.0, 1.0); evas_object_size_hint_align_set(img, -1.0, -1.0); evas_object_resize(img, w*0.5, h*0.5); elm_box_pack_end((Evas_Object*)data, img); evas_object_show(img); + } static void on_keyenter(void *data, Evas_Object *obj, void *event_info) { +// key = (char*) malloc(sizeof(char) * sizeof(data)); key = elm_entry_entry_get(obj); } -- cgit v1.2.3-55-g7522