diff --git a/components/rtgui/common/dc.c b/components/rtgui/common/dc.c index 1de54318a5..b9834312ae 100644 --- a/components/rtgui/common/dc.c +++ b/components/rtgui/common/dc.c @@ -38,6 +38,7 @@ void rtgui_dc_destory(struct rtgui_dc* dc) dc->engine->fini(dc); rtgui_free(dc); } +RTM_EXPORT(rtgui_dc_destory); void rtgui_dc_draw_line (struct rtgui_dc* dc, int x1, int y1, int x2, int y2) { @@ -106,6 +107,7 @@ void rtgui_dc_draw_line (struct rtgui_dc* dc, int x1, int y1, int x2, int y2) } } } +RTM_EXPORT(rtgui_dc_draw_line); void rtgui_dc_draw_horizontal_line(struct rtgui_dc* dc, int x1, int x2, int y) { @@ -127,6 +129,7 @@ void rtgui_dc_draw_horizontal_line(struct rtgui_dc* dc, int x1, int x2, int y) /* restore color */ RTGUI_DC_FC(dc) = color; } +RTM_EXPORT(rtgui_dc_draw_horizontal_line); void rtgui_dc_draw_vertical_line(struct rtgui_dc* dc, int x, int y1, int y2) { @@ -148,6 +151,7 @@ void rtgui_dc_draw_vertical_line(struct rtgui_dc* dc, int x, int y1, int y2) /* restore color */ RTGUI_DC_FC(dc) = color; } +RTM_EXPORT(rtgui_dc_draw_vertical_line); void rtgui_dc_draw_rect (struct rtgui_dc* dc, struct rtgui_rect* rect) { @@ -157,6 +161,7 @@ void rtgui_dc_draw_rect (struct rtgui_dc* dc, struct rtgui_rect* rect) rtgui_dc_draw_vline(dc, rect->x1, rect->y1, rect->y2); rtgui_dc_draw_vline(dc, rect->x2 - 1, rect->y1, rect->y2); } +RTM_EXPORT(rtgui_dc_draw_rect); void rtgui_dc_fill_rect_forecolor(struct rtgui_dc* dc, struct rtgui_rect* rect) { @@ -169,6 +174,7 @@ void rtgui_dc_fill_rect_forecolor(struct rtgui_dc* dc, struct rtgui_rect* rect) i++; }while(!(rect->y1+i == rect->y2)); } +RTM_EXPORT(rtgui_dc_fill_rect_forecolor); void rtgui_dc_draw_round_rect(struct rtgui_dc* dc, struct rtgui_rect* rect, int r) { @@ -198,6 +204,7 @@ void rtgui_dc_draw_round_rect(struct rtgui_dc* dc, struct rtgui_rect* rect, int rtgui_dc_draw_vline(dc, rect->x2, rect->y1 + r, rect->y2 - r); } } +RTM_EXPORT(rtgui_dc_draw_round_rect); void rtgui_dc_fill_round_rect(struct rtgui_dc* dc, struct rtgui_rect* rect, int r) { @@ -231,6 +238,7 @@ void rtgui_dc_fill_round_rect(struct rtgui_dc* dc, struct rtgui_rect* rect, int rtgui_dc_fill_circle(dc, rect->x1 + r, rect->y2 - r, r); } } +RTM_EXPORT(rtgui_dc_fill_round_rect); void rtgui_dc_draw_shaded_rect(struct rtgui_dc* dc, rtgui_rect_t* rect, rtgui_color_t c1, rtgui_color_t c2) @@ -245,6 +253,7 @@ void rtgui_dc_draw_shaded_rect(struct rtgui_dc* dc, rtgui_rect_t* rect, rtgui_dc_draw_vline(dc, rect->x2 - 1, rect->y1, rect->y2); rtgui_dc_draw_hline(dc, rect->x1, rect->x2, rect->y2 - 1); } +RTM_EXPORT(rtgui_dc_draw_shaded_rect); void rtgui_dc_draw_focus_rect(struct rtgui_dc* dc, rtgui_rect_t* rect) { @@ -266,6 +275,7 @@ void rtgui_dc_draw_focus_rect(struct rtgui_dc* dc, rtgui_rect_t* rect) rtgui_dc_draw_point(dc, rect->x2-1, y); } } +RTM_EXPORT(rtgui_dc_draw_focus_rect); void rtgui_dc_draw_text (struct rtgui_dc* dc, const char* text, struct rtgui_rect* rect) { @@ -289,6 +299,7 @@ void rtgui_dc_draw_text (struct rtgui_dc* dc, const char* text, struct rtgui_rec len = strlen((const char*)text); rtgui_font_draw(font, dc, text, len, &text_rect); } +RTM_EXPORT(rtgui_dc_draw_text); void rtgui_dc_draw_text_stroke (struct rtgui_dc* dc, const char* text, struct rtgui_rect* rect, rtgui_color_t color_stroke, rtgui_color_t color_core) @@ -314,6 +325,7 @@ void rtgui_dc_draw_text_stroke (struct rtgui_dc* dc, const char* text, struct rt rtgui_dc_draw_text(dc, text, rect); RTGUI_DC_FC(dc) = fc; } +RTM_EXPORT(rtgui_dc_draw_text_stroke); /* * draw a monochrome color bitmap data @@ -332,16 +344,19 @@ void rtgui_dc_draw_mono_bmp(struct rtgui_dc* dc, int x, int y, int w, int h, con if ( ((data[i*w + j] >> (7-k)) & 0x01) != 0) rtgui_dc_draw_point(dc, x + 8*j + k, y + i); } +RTM_EXPORT(rtgui_dc_draw_mono_bmp); void rtgui_dc_draw_byte(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data) { rtgui_dc_draw_mono_bmp(dc, x, y, 8, h, data); } +RTM_EXPORT(rtgui_dc_draw_byte); void rtgui_dc_draw_word(struct rtgui_dc*dc, int x, int y, int h, const rt_uint8_t* data) { rtgui_dc_draw_mono_bmp(dc, x, y, 16, h, data); } +RTM_EXPORT(rtgui_dc_draw_word); void rtgui_dc_draw_border(struct rtgui_dc* dc, rtgui_rect_t* rect, int flag) { @@ -395,6 +410,7 @@ void rtgui_dc_draw_border(struct rtgui_dc* dc, rtgui_rect_t* rect, int flag) /* restore color */ RTGUI_DC_FC(dc) = color; } +RTM_EXPORT(rtgui_dc_draw_border); void rtgui_dc_draw_polygon(struct rtgui_dc* dc, const int *vx, const int *vy, int count) { @@ -427,6 +443,7 @@ void rtgui_dc_draw_polygon(struct rtgui_dc* dc, const int *vx, const int *vy, in } rtgui_dc_draw_line(dc, *x1, *y1, *vx, *vy); } +RTM_EXPORT(rtgui_dc_draw_polygon); void rtgui_dc_draw_regular_polygon(struct rtgui_dc* dc, int x, int y, int r, int count, rt_uint16_t angle) { @@ -474,6 +491,7 @@ void rtgui_dc_draw_regular_polygon(struct rtgui_dc* dc, int x, int y, int r, int rtgui_free(y_head); } +RTM_EXPORT(rtgui_dc_draw_regular_polygon); void rtgui_dc_fill_polygon(struct rtgui_dc* dc, const int* vx, const int* vy, int count) { @@ -556,6 +574,7 @@ void rtgui_dc_fill_polygon(struct rtgui_dc* dc, const int* vx, const int* vy, in /* release memory */ rtgui_free(poly_ints); } +RTM_EXPORT(rtgui_dc_fill_polygon); void rtgui_dc_draw_circle(struct rtgui_dc* dc, int x, int y, int r) { @@ -632,6 +651,7 @@ void rtgui_dc_draw_circle(struct rtgui_dc* dc, int x, int y, int r) cx++; }while (cx <= cy); } +RTM_EXPORT(rtgui_dc_draw_circle); void rtgui_dc_fill_circle(struct rtgui_dc* dc, rt_int16_t x, rt_int16_t y, rt_int16_t r) { @@ -707,6 +727,7 @@ void rtgui_dc_fill_circle(struct rtgui_dc* dc, rt_int16_t x, rt_int16_t y, rt_in cx++; } while (cx <= cy); } +RTM_EXPORT(rtgui_dc_fill_circle); void rtgui_dc_draw_arc(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r, rt_int16_t start, rt_int16_t end) { @@ -926,6 +947,7 @@ void rtgui_dc_draw_arc(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16 cx++; } while (cx <= cy); } +RTM_EXPORT(rtgui_dc_draw_arc); void rtgui_dc_draw_annulus(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r1, rt_int16_t r2, rt_int16_t start, rt_int16_t end) { @@ -977,6 +999,7 @@ void rtgui_dc_draw_annulus(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_i rtgui_dc_draw_line(dc, start_x, start_y, end_x, end_y); } +RTM_EXPORT(rtgui_dc_draw_annulus); void rtgui_dc_draw_sector(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r, rt_int16_t start, rt_int16_t end) { @@ -1010,6 +1033,7 @@ void rtgui_dc_draw_sector(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_in rtgui_dc_draw_line(dc, x, y, start_x, start_y); rtgui_dc_draw_line(dc, x, y, end_x, end_y); } +RTM_EXPORT(rtgui_dc_draw_sector); void rtgui_dc_fill_sector(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t r, rt_int16_t start, rt_int16_t end) { @@ -1044,6 +1068,7 @@ void rtgui_dc_fill_sector(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_in rtgui_dc_draw_line(dc, x, y, start_x, start_y); }while(!((start_x == end_x) && (start_y == end_y))); } +RTM_EXPORT(rtgui_dc_fill_sector); void rtgui_dc_draw_ellipse(struct rtgui_dc* dc, rt_int16_t x, rt_int16_t y, rt_int16_t rx, rt_int16_t ry) { @@ -1192,6 +1217,7 @@ void rtgui_dc_draw_ellipse(struct rtgui_dc* dc, rt_int16_t x, rt_int16_t y, rt_i } while (i > h); } } +RTM_EXPORT(rtgui_dc_draw_ellipse); void rtgui_dc_fill_ellipse(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_int16_t rx, rt_int16_t ry) { @@ -1300,5 +1326,5 @@ void rtgui_dc_fill_ellipse(struct rtgui_dc *dc, rt_int16_t x, rt_int16_t y, rt_i } while (i > h); } } - +RTM_EXPORT(rtgui_dc_fill_ellipse); diff --git a/components/rtgui/common/dc_client.c b/components/rtgui/common/dc_client.c index abff12b3a0..0046bc75ad 100644 --- a/components/rtgui/common/dc_client.c +++ b/components/rtgui/common/dc_client.c @@ -62,12 +62,14 @@ struct rtgui_dc* rtgui_dc_begin_drawing(rtgui_widget_t* owner) return dc; } +RTM_EXPORT(rtgui_dc_begin_drawing); void rtgui_dc_end_drawing(struct rtgui_dc* dc) { dc->engine->fini(dc); rtgui_screen_unlock(); } +RTM_EXPORT(rtgui_dc_end_drawing); const struct rtgui_dc_engine dc_client_engine = { diff --git a/components/rtgui/common/filerw.c b/components/rtgui/common/filerw.c index dd7ab18f20..5a0390c7c5 100644 --- a/components/rtgui/common/filerw.c +++ b/components/rtgui/common/filerw.c @@ -16,7 +16,6 @@ #include #ifdef RTGUI_USING_DFS_FILERW -#include /* standard file read/write */ struct rtgui_filerw_stdio @@ -95,93 +94,7 @@ static int stdio_close(struct rtgui_filerw *context) return -1; } -#elif defined(RTGUI_USING_STDIO_FILERW) -#include -/* standard file read/write */ -struct rtgui_filerw_stdio -{ - /* inherit from rtgui_filerw */ - struct rtgui_filerw parent; - - FILE* fp; -}; - -static int stdio_seek(struct rtgui_filerw *context, rt_off_t offset, int whence) -{ - struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context; - int stdio_whence[3] = {SEEK_SET, SEEK_CUR, SEEK_END}; - - if (whence < RTGUI_FILE_SEEK_SET || whence > RTGUI_FILE_SEEK_END) - { - return -1; - } - - if (fseek(stdio_filerw->fp, offset, stdio_whence[whence]) == 0) - { - return ftell(stdio_filerw->fp); - } - - return -1; -} - -static int stdio_read(struct rtgui_filerw *context, void *ptr, rt_size_t size, rt_size_t maxnum) -{ - size_t nread; - struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context; - - nread = fread(ptr, size, maxnum, stdio_filerw->fp); - if (nread == 0 && ferror(stdio_filerw->fp)) - { - return -1; - } - - return nread; -} - -static int stdio_write(struct rtgui_filerw *context, const void *ptr, rt_size_t size, rt_size_t num) -{ - size_t nwrote; - struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context; - - nwrote = fwrite(ptr, size, num, stdio_filerw->fp); - - if ( nwrote == 0 && ferror(stdio_filerw->fp) ) - { - return -1; - } - - return nwrote; -} - -static int stdio_tell(struct rtgui_filerw* context) -{ - struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context; - - return ftell(stdio_filerw->fp); -} - -static int stdio_eof(struct rtgui_filerw* context) -{ - struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context; - - return feof(stdio_filerw->fp); -} - -static int stdio_close(struct rtgui_filerw *context) -{ - struct rtgui_filerw_stdio* stdio_filerw = (struct rtgui_filerw_stdio *)context; - - if (stdio_filerw) - { - fclose(stdio_filerw->fp); - rtgui_free(stdio_filerw); - - return 0; - } - - return -1; -} #endif /* memory file read/write */ @@ -302,7 +215,11 @@ static int parse_mode(const char *mode) switch (*mode) { case 0: return f; - case 'b': break; +#ifdef _WIN32 + case 'b': f|=O_BINARY;break; +#else + case 'b': break; +#endif case 'r': f=O_RDONLY; break; case 'w': f=O_WRONLY|O_CREAT|O_TRUNC; break; case 'a': f=O_WRONLY|O_CREAT|O_APPEND; break; @@ -321,7 +238,11 @@ struct rtgui_filerw* rtgui_filerw_create_file(const char* filename, const char* RT_ASSERT(filename != RT_NULL); rw = RT_NULL; +#ifdef _WIN32 + fd = _open(filename, parse_mode(mode), 0); +#else fd = open(filename, parse_mode(mode), 0); +#endif if ( fd >= 0 ) { @@ -342,35 +263,7 @@ struct rtgui_filerw* rtgui_filerw_create_file(const char* filename, const char* return &(rw->parent); } -#elif defined(RTGUI_USING_STDIO_FILERW) -struct rtgui_filerw* rtgui_filerw_create_file(const char* filename, const char* mode) -{ - FILE *fp; - struct rtgui_filerw_stdio *rw; - RT_ASSERT(filename != RT_NULL); - - rw = RT_NULL; - fp = fopen(filename, mode); - - if ( fp != NULL ) - { - rw = (struct rtgui_filerw_stdio*) rtgui_malloc(sizeof(struct rtgui_filerw_stdio)); - if (rw != RT_NULL) - { - rw->parent.seek = stdio_seek; - rw->parent.read = stdio_read; - rw->parent.write = stdio_write; - rw->parent.tell = stdio_tell; - rw->parent.close = stdio_close; - rw->parent.eof = stdio_eof; - - rw->fp = fp; - } - } - - return &(rw->parent); -} #endif struct rtgui_filerw* rtgui_filerw_create_mem(const rt_uint8_t* mem, rt_size_t size) @@ -447,3 +340,12 @@ int rtgui_filerw_close(struct rtgui_filerw* context) return 0; } + +int rtgui_filerw_unlink(const char *filename) +{ +#ifdef _WIN32 + return _unlink(filename); +#else + return unlink(filename); +#endif +} diff --git a/components/rtgui/common/font_hz_file.c b/components/rtgui/common/font_hz_file.c index f5945442a8..f08c925a04 100644 --- a/components/rtgui/common/font_hz_file.c +++ b/components/rtgui/common/font_hz_file.c @@ -7,7 +7,19 @@ #include #ifdef RTGUI_USING_HZ_FILE +#ifdef _WIN32 +#include +#include +#include +#include +#define open _open +#define close _close +#define read _read +#define write _write +#define unlink _unlink +#else #include +#endif #define HZ_CACHE_MAX 64 diff --git a/components/rtgui/common/image.c b/components/rtgui/common/image.c index 424c684729..843d598360 100644 --- a/components/rtgui/common/image.c +++ b/components/rtgui/common/image.c @@ -81,7 +81,7 @@ static struct rtgui_image_engine* rtgui_image_get_engine(const char* type) return RT_NULL; } -#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) +#if defined(RTGUI_USING_DFS_FILERW) struct rtgui_image_engine* rtgui_image_get_engine_by_filename(const char* fn) { struct rtgui_list_node *node; @@ -105,6 +105,7 @@ struct rtgui_image_engine* rtgui_image_get_engine_by_filename(const char* fn) return RT_NULL; } +RTM_EXPORT(rtgui_image_get_engine_by_filename); struct rtgui_image* rtgui_image_create_from_file(const char* type, const char* filename, rt_bool_t load) { @@ -153,6 +154,7 @@ struct rtgui_image* rtgui_image_create_from_file(const char* type, const char* f return image; } +RTM_EXPORT(rtgui_image_create_from_file); struct rtgui_image* rtgui_image_create(const char* filename, rt_bool_t load) { @@ -201,6 +203,7 @@ struct rtgui_image* rtgui_image_create(const char* filename, rt_bool_t load) return image; } +RTM_EXPORT(rtgui_image_create); #endif struct rtgui_image* rtgui_image_create_from_mem(const char* type, const rt_uint8_t* data, rt_size_t length, rt_bool_t load) @@ -250,6 +253,7 @@ struct rtgui_image* rtgui_image_create_from_mem(const char* type, const rt_uint8 return image; } +RTM_EXPORT(rtgui_image_create_from_mem); void rtgui_image_destroy(struct rtgui_image* image) { @@ -260,6 +264,7 @@ void rtgui_image_destroy(struct rtgui_image* image) rtgui_free(image->palette); rtgui_free(image); } +RTM_EXPORT(rtgui_image_destroy); /* register an image engine */ void rtgui_image_register_engine(struct rtgui_image_engine* engine) @@ -268,6 +273,7 @@ void rtgui_image_register_engine(struct rtgui_image_engine* engine) rtgui_list_append(&_rtgui_system_image_list, &(engine->list)); } +RTM_EXPORT(rtgui_image_register_engine); void rtgui_image_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtgui_rect* rect) { @@ -282,6 +288,7 @@ void rtgui_image_blit(struct rtgui_image* image, struct rtgui_dc* dc, struct rtg image->engine->image_blit(image, dc, rect); } } +RTM_EXPORT(rtgui_image_blit); struct rtgui_image_palette* rtgui_image_palette_create(rt_uint32_t ncolors) { @@ -296,6 +303,7 @@ struct rtgui_image_palette* rtgui_image_palette_create(rt_uint32_t ncolors) return palette; } +RTM_EXPORT(rtgui_image_palette_create); void rtgui_image_get_rect(struct rtgui_image* image, struct rtgui_rect* rect) { @@ -305,4 +313,5 @@ void rtgui_image_get_rect(struct rtgui_image* image, struct rtgui_rect* rect) rect->x1 = 0; rect->y1 = 0; rect->x2 = image->w; rect->y2 = image->h; } +RTM_EXPORT(rtgui_image_get_rect); diff --git a/components/rtgui/common/image_bmp.c b/components/rtgui/common/image_bmp.c index 71f7adbec8..78c60d796b 100644 --- a/components/rtgui/common/image_bmp.c +++ b/components/rtgui/common/image_bmp.c @@ -832,6 +832,178 @@ static void rtgui_image_bmp_blit(struct rtgui_image *image, struct rtgui_dc *dc, while (0); } +/* + * config bitmap header. + */ +void rtgui_image_bmp_header_cfg(struct rtgui_image_bmp_header *bhr, rt_int32_t w, rt_int32_t h, rt_uint16_t bits_per_pixel) +{ + int image_size = w * h * bits_per_pixel/8; + int header_size = sizeof(struct rtgui_image_bmp_header); + + bhr->bfType = 0x4d42; /* BM */ + bhr->bfSize = header_size + image_size; /* data size */ + bhr->bfReserved1 = 0; + bhr->bfReserved2 = 0; + bhr->bfOffBits = header_size; + + bhr->biSize = 40; /* sizeof BITMAPINFOHEADER */ + bhr->biWidth = w; + bhr->biHeight = h; + bhr->biPlanes = 1; + bhr->biBitCount = bits_per_pixel; + bhr->biCompression = BI_BITFIELDS; + bhr->biSizeImage = image_size; + bhr->biXPelsPerMeter = 0; + bhr->biYPelsPerMeter = 0; + bhr->biClrUsed = 0; + bhr->biClrImportant = 0; + if(bhr->biBitCount == 16 && bhr->biCompression == BI_BITFIELDS) + { + bhr->bfSize += 12; + bhr->bfOffBits += 12; + } +} + +#define WRITE_CLUSTER_SIZE 2048 +void bmp_align_write(struct rtgui_filerw *file, char *dest, char *src, rt_int32_t len, rt_int32_t *count) +{ + rt_int32_t len_bak = len; + + while(len) + { + if(*count >= WRITE_CLUSTER_SIZE) + { + rtgui_filerw_write(file, dest, WRITE_CLUSTER_SIZE, 1); + *count = 0; + } + *(dest + *count) = *(src + (len_bak-len)); + len --; + (*count) ++; + } +} + +/* + * Grab screen and save as a BMP file + * MACRO RGB_CONVERT_TO_BGR: If the pixel of colors is BGR mode, defined it. + */ +void screenshot(const char *filename) +{ + struct rtgui_filerw *file; + int w, h, i, pitch; + rt_uint16_t *src; + rt_uint32_t mask; + struct rtgui_image_bmp_header bhr; + struct rtgui_graphic_driver *grp = hw_driver; +#ifdef RGB_CONVERT_TO_BGR + int j; + rt_uint16_t *line_buf; + rt_uint16_t color, tmp; +#endif + char *pixel_buf; + rt_int32_t write_count=0; + + file = rtgui_filerw_create_file(filename, "wb"); + if(file == RT_NULL) + { + rt_kprintf("create file failed\n"); + return; + } + + w = grp->width; + h = grp->height; + + pitch = w * sizeof(rt_uint16_t); +#ifdef RGB_CONVERT_TO_BGR + line_buf = rt_malloc(pitch); + if(line_buf == RT_NULL) + { + rt_kprintf("no memory!\n"); + return; + } +#endif + pixel_buf = rt_malloc(WRITE_CLUSTER_SIZE); + if(pixel_buf == RT_NULL) + { + rt_kprintf("no memory!\n"); +#ifdef RGB_CONVERT_TO_BGR + rt_free(line_buf); +#endif + return; + } + + rtgui_image_bmp_header_cfg(&bhr, w, h, grp->bits_per_pixel); + + bmp_align_write(file, pixel_buf, (char*)&bhr, + sizeof(struct rtgui_image_bmp_header), &write_count); + + if(bhr.biCompression == BI_BITFIELDS) + { + mask = 0xF800; /* Red Mask */ + bmp_align_write(file, pixel_buf, (char*)&mask, 4, &write_count); + mask = 0x07E0; /* Green Mask */ + bmp_align_write(file, pixel_buf, (char*)&mask, 4, &write_count); + mask = 0x001F; /* Blue Mask */ + bmp_align_write(file, pixel_buf, (char*)&mask, 4, &write_count); + } + rtgui_screen_lock(RT_WAITING_FOREVER); + if(grp->framebuffer != RT_NULL) + { + src = (rt_uint16_t*)grp->framebuffer; + src += w * h; + for(i=0; i>11; + + *(line_buf + i) = color; + } + bmp_align_write(file, pixel_buf, (char*)line_buf, pitch, &write_count); +#else + bmp_align_write(file, pixel_buf, (char*)src, pitch, &write_count); +#endif + } + } + else + { + rtgui_color_t pixel_color; + rt_uint16_t write_color; + int x; + for(i=h-1; i>=0; i--) + { + x = 0; + if(i%10==0)rt_kprintf(">",i); + while(x < w) + { + grp->ops->get_pixel(&pixel_color, x, i); + write_color = rtgui_color_to_565p(pixel_color); + bmp_align_write(file, pixel_buf, (char*)&write_color, + sizeof(rt_uint16_t), &write_count); + x++; + } + } + } + /* write The tail of the last */ + if(write_count < WRITE_CLUSTER_SIZE) + rtgui_filerw_write(file, pixel_buf, write_count, 1); + rtgui_screen_unlock(); +#ifdef RGB_CONVERT_TO_BGR + rt_free(line_buf); +#endif + rt_free(pixel_buf); + rt_kprintf("bmp create succeed.\n"); + rtgui_filerw_close(file); +} +#ifdef RT_USING_FINSH +#include +FINSH_FUNCTION_EXPORT(screenshot, usage: screenshot(filename)); +#endif + void rtgui_image_bmp_init() { /* register bmp on image system */ diff --git a/components/rtgui/common/rtgui_app.c b/components/rtgui/common/rtgui_app.c index da63107172..68876926dc 100644 --- a/components/rtgui/common/rtgui_app.c +++ b/components/rtgui/common/rtgui_app.c @@ -112,6 +112,7 @@ __mq_err: tid->user_data = 0; return RT_NULL; } +RTM_EXPORT(rtgui_app_create); #define _rtgui_application_check(app) \ do { \ @@ -152,6 +153,7 @@ void rtgui_app_destroy(struct rtgui_app *app) rt_mq_delete(app->mq); rtgui_object_destroy(RTGUI_OBJECT(app)); } +RTM_EXPORT(rtgui_app_destroy); struct rtgui_app* rtgui_app_self(void) { @@ -164,6 +166,7 @@ struct rtgui_app* rtgui_app_self(void) return app; } +RTM_EXPORT(rtgui_app_self); void rtgui_app_set_onidle(rtgui_idle_func_t onidle) { @@ -173,6 +176,7 @@ void rtgui_app_set_onidle(rtgui_idle_func_t onidle) if (app != RT_NULL) app->on_idle = onidle; } +RTM_EXPORT(rtgui_app_set_onidle); rtgui_idle_func_t rtgui_app_get_onidle(void) { @@ -184,6 +188,7 @@ rtgui_idle_func_t rtgui_app_get_onidle(void) else return RT_NULL; } +RTM_EXPORT(rtgui_app_get_onidle); rt_inline rt_bool_t _rtgui_application_dest_handle( struct rtgui_app *app, @@ -339,12 +344,14 @@ rt_base_t rtgui_app_run(struct rtgui_app *app) return app->exit_code; } +RTM_EXPORT(rtgui_app_run); void rtgui_app_exit(struct rtgui_app* app, rt_uint16_t code) { --app->ref_count; app->exit_code = code; } +RTM_EXPORT(rtgui_app_exit); void rtgui_app_activate(struct rtgui_app *app) { @@ -355,6 +362,7 @@ void rtgui_app_activate(struct rtgui_app *app) rtgui_send(app->tid, RTGUI_EVENT(&event), sizeof(struct rtgui_event_application)); } +RTM_EXPORT(rtgui_app_activate); void rtgui_app_close(struct rtgui_app *app) { @@ -365,6 +373,7 @@ void rtgui_app_close(struct rtgui_app *app) rtgui_send(app->tid, RTGUI_EVENT(&event), sizeof(struct rtgui_event_application)); } +RTM_EXPORT(rtgui_app_close); /** * set this application as window manager @@ -389,6 +398,7 @@ rt_err_t rtgui_app_set_as_wm(void) return RT_ERROR; } +RTM_EXPORT(rtgui_app_set_as_wm); void rtgui_app_set_main_win(struct rtgui_win* win) { @@ -400,3 +410,5 @@ void rtgui_app_set_main_win(struct rtgui_win* win) app->main_object = RTGUI_OBJECT(win); } } +RTM_EXPORT(rtgui_app_set_main_win); + diff --git a/components/rtgui/common/rtgui_object.c b/components/rtgui/common/rtgui_object.c index 95a7c4e17e..81c3acc701 100644 --- a/components/rtgui/common/rtgui_object.c +++ b/components/rtgui/common/rtgui_object.c @@ -34,6 +34,7 @@ DEFINE_CLASS_TYPE(object, "object", _rtgui_object_constructor, _rtgui_object_destructor, sizeof(struct rtgui_object)); +RTM_EXPORT(_rtgui_object); void rtgui_type_object_construct(const rtgui_type_t *type, rtgui_object_t *object) { @@ -121,6 +122,7 @@ rtgui_object_t *rtgui_object_create(rtgui_type_t *object_type) return new_object; } +RTM_EXPORT(rtgui_object_create); /** * @brief Destroys the object: it first sets the weak-pointers to RT_NULL, emits the "destroyed" signal, and then @@ -146,6 +148,7 @@ void rtgui_object_destroy(rtgui_object_t *object) /* release object */ rtgui_free(object); } +RTM_EXPORT(rtgui_object_destroy); /** * @brief Checks if @a object can be cast to @a type. @@ -166,6 +169,8 @@ rtgui_object_t *rtgui_object_check_cast(rtgui_object_t *obj, rtgui_type_t *obj_t return obj; } +RTM_EXPORT(rtgui_object_check_cast); + /** * @brief Gets the type of the object @@ -178,6 +183,7 @@ const rtgui_type_t *rtgui_object_object_type_get(rtgui_object_t *object) return object->type; } +RTM_EXPORT(rtgui_object_object_type_get); void rtgui_object_set_event_handler(struct rtgui_object *object, rtgui_event_handler_ptr handler) { @@ -185,9 +191,11 @@ void rtgui_object_set_event_handler(struct rtgui_object *object, rtgui_event_han object->event_handler = handler; } +RTM_EXPORT(rtgui_object_set_event_handler); rt_bool_t rtgui_object_event_handler(struct rtgui_object *object, struct rtgui_event* event) { return RT_FALSE; } +RTM_EXPORT(rtgui_object_event_handler); diff --git a/components/rtgui/common/rtgui_system.c b/components/rtgui/common/rtgui_system.c index 4669ef3010..ed2ad57705 100644 --- a/components/rtgui/common/rtgui_system.c +++ b/components/rtgui/common/rtgui_system.c @@ -87,6 +87,7 @@ rtgui_timer_t* rtgui_timer_create(rt_int32_t time, rt_int32_t flag, rtgui_timeou return timer; } +RTM_EXPORT(rtgui_timer_create); void rtgui_timer_destory(rtgui_timer_t* timer) { @@ -100,6 +101,7 @@ void rtgui_timer_destory(rtgui_timer_t* timer) rtgui_free(timer); } +RTM_EXPORT(rtgui_timer_destory); void rtgui_timer_start(rtgui_timer_t* timer) { @@ -108,6 +110,7 @@ void rtgui_timer_start(rtgui_timer_t* timer) /* start rt-thread timer */ rt_timer_start(&(timer->timer)); } +RTM_EXPORT(rtgui_timer_start); void rtgui_timer_stop (rtgui_timer_t* timer) { @@ -116,6 +119,7 @@ void rtgui_timer_stop (rtgui_timer_t* timer) /* stop rt-thread timer */ rt_timer_stop(&(timer->timer)); } +RTM_EXPORT(rtgui_timer_stop); /************************************************************************/ /* RTGUI Memory Management */ @@ -267,6 +271,7 @@ void* rtgui_malloc(rt_size_t size) return ptr; } +RTM_EXPORT(rtgui_malloc); void* rtgui_realloc(void* ptr, rt_size_t size) { @@ -285,6 +290,7 @@ void* rtgui_realloc(void* ptr, rt_size_t size) return new_ptr; } +RTM_EXPORT(rtgui_realloc); void rtgui_free(void* ptr) { @@ -295,6 +301,7 @@ void rtgui_free(void* ptr) rt_free(ptr); } +RTM_EXPORT(rtgui_free); #if defined(RTGUI_MEM_TRACE) && defined(RT_USING_FINSH) #include @@ -560,6 +567,7 @@ rt_err_t rtgui_send(rt_thread_t tid, rtgui_event_t* event, rt_size_t event_size) return result; } +RTM_EXPORT(rtgui_send); rt_err_t rtgui_send_urgent(rt_thread_t tid, rtgui_event_t* event, rt_size_t event_size) { @@ -583,6 +591,7 @@ rt_err_t rtgui_send_urgent(rt_thread_t tid, rtgui_event_t* event, rt_size_t even return result; } +RTM_EXPORT(rtgui_send_urgent); rt_err_t rtgui_send_sync(rt_thread_t tid, rtgui_event_t* event, rt_size_t event_size) { @@ -631,6 +640,7 @@ __return: rt_mb_detach(&ack_mb); return r; } +RTM_EXPORT(rtgui_send_sync); rt_err_t rtgui_ack(rtgui_event_t* event, rt_int32_t status) { @@ -641,6 +651,7 @@ rt_err_t rtgui_ack(rtgui_event_t* event, rt_int32_t status) return RT_EOK; } +RTM_EXPORT(rtgui_ack); rt_err_t rtgui_recv(rtgui_event_t* event, rt_size_t event_size) { @@ -658,6 +669,7 @@ rt_err_t rtgui_recv(rtgui_event_t* event, rt_size_t event_size) return r; } +RTM_EXPORT(rtgui_recv); rt_err_t rtgui_recv_nosuspend(rtgui_event_t* event, rt_size_t event_size) { @@ -675,6 +687,7 @@ rt_err_t rtgui_recv_nosuspend(rtgui_event_t* event, rt_size_t event_size) return r; } +RTM_EXPORT(rtgui_recv_nosuspend); rt_err_t rtgui_recv_filter(rt_uint32_t type, rtgui_event_t* event, rt_size_t event_size) { @@ -704,33 +717,41 @@ rt_err_t rtgui_recv_filter(rt_uint32_t type, rtgui_event_t* event, rt_size_t eve return -RT_ERROR; } +RTM_EXPORT(rtgui_recv_filter); rt_thread_t rtgui_get_server(void) { return rt_thread_find("rtgui"); } +RTM_EXPORT(rtgui_get_server); void rtgui_set_mainwin_rect(struct rtgui_rect *rect) { _mainwin_rect = *rect; } +RTM_EXPORT(rtgui_set_mainwin_rect); void rtgui_get_mainwin_rect(struct rtgui_rect *rect) { *rect = _mainwin_rect; } +RTM_EXPORT(rtgui_get_mainwin_rect); void rtgui_get_screen_rect(struct rtgui_rect *rect) { rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), rect); } +RTM_EXPORT(rtgui_get_screen_rect); void rtgui_screen_lock(rt_int32_t timeout) { rt_mutex_take(&_screen_lock, timeout); } +RTM_EXPORT(rtgui_screen_lock); void rtgui_screen_unlock(void) { rt_mutex_release(&_screen_lock); } +RTM_EXPORT(rtgui_screen_unlock); + diff --git a/components/rtgui/include/rtgui/filerw.h b/components/rtgui/include/rtgui/filerw.h index c254d51afa..03e030d539 100644 --- a/components/rtgui/include/rtgui/filerw.h +++ b/components/rtgui/include/rtgui/filerw.h @@ -14,6 +14,16 @@ #ifndef __RTGUI_FILERW_H__ #define __RTGUI_FILERW_H__ +#ifdef _WIN32 +#pragma warning(disable: 4996) +#include +#include +#include +#include +#else +#include +#endif + #include #define RTGUI_FILE_SEEK_SET 0 @@ -40,6 +50,7 @@ int rtgui_filerw_write(struct rtgui_filerw* context, const void* buffer, rt_size int rtgui_filerw_tell (struct rtgui_filerw* context); int rtgui_filerw_eof (struct rtgui_filerw* context); int rtgui_filerw_close(struct rtgui_filerw* context); +int rtgui_filerw_unlink(const char *filename); /* get memory data from filerw memory object */ const rt_uint8_t* rtgui_filerw_mem_getdata(struct rtgui_filerw* context); diff --git a/components/rtgui/include/rtgui/image.h b/components/rtgui/include/rtgui/image.h index 3314c444a0..6fe92e0a22 100644 --- a/components/rtgui/include/rtgui/image.h +++ b/components/rtgui/include/rtgui/image.h @@ -59,7 +59,7 @@ typedef struct rtgui_image rtgui_image_t; /* init rtgui image system */ void rtgui_system_image_init(void); -#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) +#if defined(RTGUI_USING_DFS_FILERW) struct rtgui_image_engine* rtgui_image_get_engine_by_filename(const char* fn); struct rtgui_image* rtgui_image_create_from_file(const char* type, const char* filename, rt_bool_t load); struct rtgui_image* rtgui_image_create(const char* filename, rt_bool_t load); diff --git a/components/rtgui/include/rtgui/image_bmp.h b/components/rtgui/include/rtgui/image_bmp.h index 19fdfc7f6e..a282e23984 100644 --- a/components/rtgui/include/rtgui/image_bmp.h +++ b/components/rtgui/include/rtgui/image_bmp.h @@ -14,6 +14,33 @@ #ifndef __RTGUI_IMAGE_BMP_H__ #define __RTGUI_IMAGE_BMP_H__ +#pragma pack(2) + +struct rtgui_image_bmp_header +{ + /* The Win32 BMP file header (14 bytes) */ + rt_uint16_t bfType; + rt_uint32_t bfSize; + rt_uint16_t bfReserved1; + rt_uint16_t bfReserved2; + rt_uint32_t bfOffBits; + + /* The Win32 BITMAPINFOHEADER struct (40 bytes) */ + rt_uint32_t biSize; + rt_int32_t biWidth; + rt_int32_t biHeight; + rt_uint16_t biPlanes; + rt_uint16_t biBitCount; + rt_uint32_t biCompression; + rt_uint32_t biSizeImage; + rt_int32_t biXPelsPerMeter; + rt_int32_t biYPelsPerMeter; + rt_uint32_t biClrUsed; + rt_uint32_t biClrImportant; +}; +#ifdef _WIN32 +#pragma warning(disable : 4103) +#endif void rtgui_image_bmp_init(void); #endif diff --git a/components/rtgui/include/rtgui/rtgui_config.h b/components/rtgui/include/rtgui/rtgui_config.h index 73672aa739..98160339f1 100644 --- a/components/rtgui/include/rtgui/rtgui_config.h +++ b/components/rtgui/include/rtgui/rtgui_config.h @@ -35,7 +35,7 @@ #define RTGUI_DEFAULT_FONT_SIZE 12 #define RTGUI_USING_STDIO_FILERW - // #define RTGUI_USING_DFS_FILERW + #define RTGUI_USING_DFS_FILERW #define RTGUI_IMAGE_CONTAINER #define RTGUI_IMAGE_XPM #define RTGUI_IMAGE_BMP @@ -47,7 +47,7 @@ #define RTGUI_MEM_TRACE #define RTGUI_USING_WINMOVE #define RTGUI_USING_NOTEBOOK_IMAGE - + // #define RTGUI_USING_HZ_FILE #else /* native running under RT-Thread */ #ifndef RT_USING_DFS diff --git a/components/rtgui/include/rtgui/rtgui_system.h b/components/rtgui/include/rtgui/rtgui_system.h index 48f6ebb100..31030fa2ae 100644 --- a/components/rtgui/include/rtgui/rtgui_system.h +++ b/components/rtgui/include/rtgui/rtgui_system.h @@ -50,8 +50,13 @@ void* rtgui_malloc(rt_size_t size); void rtgui_free(void* ptr); void* rtgui_realloc(void* ptr, rt_size_t size); +#ifdef _WIN32 +#define rtgui_enter_critical() +#define rtgui_exit_critical() +#else #define rtgui_enter_critical rt_enter_critical #define rtgui_exit_critical rt_exit_critical +#endif rt_thread_t rtgui_get_server(void); void rtgui_set_mainwin_rect(struct rtgui_rect *rect); diff --git a/components/rtgui/include/rtgui/widgets/edit.h b/components/rtgui/include/rtgui/widgets/edit.h index c1ca181992..75cbdd319a 100644 --- a/components/rtgui/include/rtgui/widgets/edit.h +++ b/components/rtgui/include/rtgui/widgets/edit.h @@ -17,27 +17,10 @@ #include #include -#ifdef _WIN32 -#include -#include -#include -#include -#else -#include -#endif - #ifdef __cplusplus extern "C" { #endif -#ifdef _WIN32 -#define open _open -#define close _close -#define read _read -#define write _write -#define unlink _unlink -#endif - DECLARE_CLASS_TYPE(edit); /** Gets the type of a edit */ @@ -65,11 +48,11 @@ struct edit_update struct edit_line { - rt_size_t zsize; /* zone size */ - rt_uint32_t len; + rt_int16_t zsize; /* zone size */ + rt_int16_t len; struct edit_line *prev; struct edit_line *next; - char *text; + char *text; }; struct rtgui_edit @@ -79,21 +62,22 @@ struct rtgui_edit /* edit flag */ rt_uint32_t flag; - rt_uint32_t max_rows, max_cols; - rt_uint16_t row_per_page, col_per_page; + rt_int16_t max_rows, max_cols; + rt_int16_t row_per_page, col_per_page; rtgui_point_t upleft; rtgui_point_t visual; rt_uint8_t tabsize; rt_uint8_t item_height; rt_uint8_t font_width,font_height; rt_uint8_t margin; - rt_size_t bzsize; /* base zone size */ + rt_int16_t bzsize; /* base zone size */ struct rtgui_timer *caret_timer; rtgui_color_t *caret; rtgui_rect_t caret_rect; struct edit_update update; char *update_buf; /* speed up renewal process */ + struct rtgui_dc *dbl_buf; struct edit_line *head; struct edit_line *tail; @@ -118,7 +102,8 @@ void rtgui_edit_update(struct rtgui_edit *edit); void rtgui_edit_ondraw(struct rtgui_edit *edit); rt_bool_t rtgui_edit_event_handler(struct rtgui_object* object, rtgui_event_t* event); void rtgui_edit_set_text(struct rtgui_edit *edit, const char* text); - +rtgui_point_t rtgui_edit_get_current_point(struct rtgui_edit *edit); +rt_uint32_t rtgui_edit_get_mem_consume(struct rtgui_edit *edit); rt_bool_t rtgui_edit_readin_file(struct rtgui_edit *edit, const char *filename); rt_bool_t rtgui_edit_saveas_file(struct rtgui_edit *edit, const char *filename); diff --git a/components/rtgui/include/rtgui/widgets/filelist_view.h b/components/rtgui/include/rtgui/widgets/filelist_view.h index 6fc3b0b9d7..78a38a2835 100644 --- a/components/rtgui/include/rtgui/widgets/filelist_view.h +++ b/components/rtgui/include/rtgui/widgets/filelist_view.h @@ -3,7 +3,7 @@ #include -#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) +#if defined(RTGUI_USING_DFS_FILERW) #define RTGUI_FITEM_FILE 0x0 #define RTGUI_FITEM_DIR 0x1 struct rtgui_file_item diff --git a/components/rtgui/server/driver.c b/components/rtgui/server/driver.c index 1b35e4f6fc..48a29ab5ff 100644 --- a/components/rtgui/server/driver.c +++ b/components/rtgui/server/driver.c @@ -24,6 +24,7 @@ struct rtgui_graphic_driver* rtgui_graphic_driver_get_default() { return &_driver; } +RTM_EXPORT(rtgui_graphic_driver_get_default); void rtgui_graphic_driver_get_rect(const struct rtgui_graphic_driver *driver, rtgui_rect_t *rect) { @@ -34,6 +35,7 @@ void rtgui_graphic_driver_get_rect(const struct rtgui_graphic_driver *driver, rt rect->x2 = driver->width; rect->y2 = driver->height; } +RTM_EXPORT(rtgui_graphic_driver_get_rect); rt_err_t rtgui_graphic_set_device(rt_device_t device) { @@ -70,6 +72,7 @@ rt_err_t rtgui_graphic_set_device(rt_device_t device) return RT_EOK; } +RTM_EXPORT(rtgui_graphic_set_device); /* screen update */ void rtgui_graphic_driver_screen_update(const struct rtgui_graphic_driver* driver, rtgui_rect_t *rect) @@ -81,14 +84,18 @@ void rtgui_graphic_driver_screen_update(const struct rtgui_graphic_driver* drive rect_info.height = rect->y2 - rect->y1; rt_device_control(driver->device, RTGRAPHIC_CTRL_RECT_UPDATE, &rect_info); } +RTM_EXPORT(rtgui_graphic_driver_screen_update); /* get video frame buffer */ rt_uint8_t* rtgui_graphic_driver_get_framebuffer(const struct rtgui_graphic_driver* driver) { return (rt_uint8_t*)driver->framebuffer; } +RTM_EXPORT(rtgui_graphic_driver_get_framebuffer); rt_uint8_t* rtgui_graphic_driver_get_default_framebuffer(void) { return rtgui_graphic_driver_get_framebuffer(&_driver); } +RTM_EXPORT(rtgui_graphic_driver_get_default_framebuffer); + diff --git a/components/rtgui/widgets/box.c b/components/rtgui/widgets/box.c index b69767e85d..2c6452fc35 100644 --- a/components/rtgui/widgets/box.c +++ b/components/rtgui/widgets/box.c @@ -44,11 +44,13 @@ struct rtgui_box* rtgui_box_create(int orientation, int border_size) return box; } +RTM_EXPORT(rtgui_box_create); void rtgui_box_destroy(struct rtgui_box* box) { rtgui_object_destroy(RTGUI_OBJECT(box)); } +RTM_EXPORT(rtgui_box_destroy); static void rtgui_box_layout_vertical(struct rtgui_box* box, struct rtgui_rect* extent) { @@ -259,6 +261,7 @@ void rtgui_box_layout(rtgui_box_t* box) rtgui_widget_update_clip(RTGUI_WIDGET(box->container)); } } +RTM_EXPORT(rtgui_box_layout); void rtgui_box_layout_rect(rtgui_box_t* box, struct rtgui_rect* rect) { @@ -281,3 +284,5 @@ void rtgui_box_layout_rect(rtgui_box_t* box, struct rtgui_rect* rect) rtgui_widget_update_clip(RTGUI_WIDGET(box->container)); } } +RTM_EXPORT(rtgui_box_layout_rect); + diff --git a/components/rtgui/widgets/button.c b/components/rtgui/widgets/button.c index 0e02b27611..27bf9d2e53 100644 --- a/components/rtgui/widgets/button.c +++ b/components/rtgui/widgets/button.c @@ -195,6 +195,7 @@ rt_bool_t rtgui_button_event_handler(struct rtgui_object* object, struct rtgui_e return RT_FALSE; } +RTM_EXPORT(rtgui_button_event_handler); rtgui_button_t* rtgui_button_create(const char* text) { @@ -215,6 +216,7 @@ rtgui_button_t* rtgui_button_create(const char* text) return btn; } +RTM_EXPORT(rtgui_button_create); rtgui_button_t* rtgui_pushbutton_create(const char* text) { @@ -225,11 +227,13 @@ rtgui_button_t* rtgui_pushbutton_create(const char* text) return btn; } +RTM_EXPORT(rtgui_pushbutton_create); void rtgui_button_destroy(rtgui_button_t* btn) { rtgui_widget_destroy(RTGUI_WIDGET(btn)); } +RTM_EXPORT(rtgui_button_destroy); void rtgui_button_set_pressed_image(rtgui_button_t* btn, rtgui_image_t* image) { @@ -237,6 +241,7 @@ void rtgui_button_set_pressed_image(rtgui_button_t* btn, rtgui_image_t* image) btn->pressed_image = image; } +RTM_EXPORT(rtgui_button_set_pressed_image); void rtgui_button_set_unpressed_image(rtgui_button_t* btn, rtgui_image_t* image) { @@ -244,6 +249,7 @@ void rtgui_button_set_unpressed_image(rtgui_button_t* btn, rtgui_image_t* image) btn->unpressed_image = image; } +RTM_EXPORT(rtgui_button_set_unpressed_image); void rtgui_button_set_onbutton(rtgui_button_t* btn, rtgui_onbutton_func_t func) { @@ -251,4 +257,5 @@ void rtgui_button_set_onbutton(rtgui_button_t* btn, rtgui_onbutton_func_t func) btn->on_button = func; } +RTM_EXPORT(rtgui_button_set_onbutton); diff --git a/components/rtgui/widgets/container.c b/components/rtgui/widgets/container.c index 4c3af36fbd..37df55c2ed 100644 --- a/components/rtgui/widgets/container.c +++ b/components/rtgui/widgets/container.c @@ -43,6 +43,7 @@ DEFINE_CLASS_TYPE(container, "container", _rtgui_container_constructor, _rtgui_container_destructor, sizeof(struct rtgui_container)); +RTM_EXPORT(_rtgui_container); rt_bool_t rtgui_container_dispatch_event(rtgui_container_t *container, rtgui_event_t* event) { @@ -61,6 +62,7 @@ rt_bool_t rtgui_container_dispatch_event(rtgui_container_t *container, rtgui_eve return RT_FALSE; } +RTM_EXPORT(rtgui_container_dispatch_event); /* broadcast means that the return value of event handlers will be ignored. The * events will always reach every child.*/ @@ -79,6 +81,7 @@ rt_bool_t rtgui_container_broadcast_event(struct rtgui_container *container, str return RT_FALSE; } +RTM_EXPORT(rtgui_container_broadcast_event); rt_bool_t rtgui_container_dispatch_mouse_event(rtgui_container_t *container, struct rtgui_event_mouse* event) { @@ -106,6 +109,7 @@ rt_bool_t rtgui_container_dispatch_mouse_event(rtgui_container_t *container, str return RT_FALSE; } +RTM_EXPORT(rtgui_container_dispatch_mouse_event); rt_bool_t rtgui_container_event_handler(struct rtgui_object* object, struct rtgui_event* event) { @@ -176,6 +180,7 @@ rt_bool_t rtgui_container_event_handler(struct rtgui_object* object, struct rtgu return RT_FALSE; } +RTM_EXPORT(rtgui_container_event_handler); rtgui_container_t* rtgui_container_create(void) { @@ -185,11 +190,13 @@ rtgui_container_t* rtgui_container_create(void) container = (struct rtgui_container*) rtgui_widget_create (RTGUI_CONTAINER_TYPE); return container; } +RTM_EXPORT(rtgui_container_create); void rtgui_container_destroy(rtgui_container_t* container) { rtgui_widget_destroy(RTGUI_WIDGET(container)); } +RTM_EXPORT(rtgui_container_destroy); /* * This function will add a child to a container widget @@ -216,6 +223,7 @@ void rtgui_container_add_child(rtgui_container_t *container, rtgui_widget_t* chi rtgui_container_broadcast_event(container, (struct rtgui_event*)&eup); } } +RTM_EXPORT(rtgui_container_add_child); /* remove a child to widget */ void rtgui_container_remove_child(rtgui_container_t *container, rtgui_widget_t* child) @@ -232,6 +240,7 @@ void rtgui_container_remove_child(rtgui_container_t *container, rtgui_widget_t* child->parent = RT_NULL; child->toplevel = RT_NULL; } +RTM_EXPORT(rtgui_container_remove_child); /* destroy all children of container */ void rtgui_container_destroy_children(rtgui_container_t *container) @@ -272,6 +281,7 @@ void rtgui_container_destroy_children(rtgui_container_t *container) /* update widget clip */ rtgui_toplevel_update_clip(RTGUI_TOPLEVEL(RTGUI_WIDGET(container)->toplevel)); } +RTM_EXPORT(rtgui_container_destroy_children); rtgui_widget_t* rtgui_container_get_first_child(rtgui_container_t* container) { @@ -286,6 +296,7 @@ rtgui_widget_t* rtgui_container_get_first_child(rtgui_container_t* container) return child; } +RTM_EXPORT(rtgui_container_get_first_child); void rtgui_container_set_box(rtgui_container_t* container, struct rtgui_box* box) { @@ -295,6 +306,7 @@ void rtgui_container_set_box(rtgui_container_t* container, struct rtgui_box* box container->layout_box = box; box->container = container; } +RTM_EXPORT(rtgui_container_set_box); void rtgui_container_layout(struct rtgui_container* container) { @@ -303,4 +315,5 @@ void rtgui_container_layout(struct rtgui_container* container) rtgui_box_layout(container->layout_box); } +RTM_EXPORT(rtgui_container_layout); diff --git a/components/rtgui/widgets/edit.c b/components/rtgui/widgets/edit.c index 21fe2929a8..faf04a1594 100644 --- a/components/rtgui/widgets/edit.c +++ b/components/rtgui/widgets/edit.c @@ -16,13 +16,17 @@ #include #include #include +#include +extern int isprint(unsigned char ch); /* Quote from shell.c */ static void rtgui_edit_draw_caret(struct rtgui_edit *edit); static void rtgui_edit_timeout(struct rtgui_timer* timer, void* parameter); static rt_bool_t rtgui_edit_onfocus(struct rtgui_object* object, rtgui_event_t* event); static rt_bool_t rtgui_edit_onunfocus(struct rtgui_object* object, rtgui_event_t* event); +#ifdef RTGUI_EDIT_USING_SCROLL static rt_bool_t rtgui_edit_hscroll_handle(struct rtgui_widget* widget, rtgui_event_t* event); static rt_bool_t rtgui_edit_vscroll_handle(struct rtgui_widget* widget, rtgui_event_t* event); +#endif void _rtgui_edit_constructor(struct rtgui_edit *edit) { @@ -61,6 +65,8 @@ void _rtgui_edit_constructor(struct rtgui_edit *edit) rtgui_font_get_metrics(RTGUI_WIDGET_FONT(edit), "H", &font_rect); edit->font_width = rtgui_rect_width(font_rect); edit->font_height = rtgui_rect_height(font_rect); + + edit->dbl_buf = rtgui_dc_buffer_create(edit->font_width*2+1, edit->font_height+1); edit->head = RT_NULL; edit->tail = RT_NULL; @@ -88,6 +94,8 @@ void _rtgui_edit_deconstructor(struct rtgui_edit *edit) edit->caret = RT_NULL; if(edit->update_buf != RT_NULL) rtgui_free(edit->update_buf); + + rtgui_dc_destory(edit->dbl_buf); } DEFINE_CLASS_TYPE(edit, "edit", @@ -156,6 +164,7 @@ void rtgui_edit_adjust_scroll(rtgui_scrollbar_t *bar) rtgui_widget_set_rect(bar,&rect); } } +RTM_EXPORT(rtgui_edit_adjust_scroll); #endif struct rtgui_edit* rtgui_edit_create(struct rtgui_container* container, int left, int top, int w, int h) @@ -233,11 +242,13 @@ struct rtgui_edit* rtgui_edit_create(struct rtgui_container* container, int left return edit; } +RTM_EXPORT(rtgui_edit_create); void rtgui_edit_destroy(struct rtgui_edit* edit) { rtgui_widget_destroy(RTGUI_WIDGET(edit)); } +RTM_EXPORT(rtgui_edit_destroy); /** * calc line buffer alloc length @@ -247,7 +258,7 @@ void rtgui_edit_destroy(struct rtgui_edit* edit) * * @return get a proper standard values */ -rt_inline rt_size_t rtgui_edit_alloc_len(rt_size_t n, rt_size_t m) +rt_inline rt_int16_t rtgui_edit_alloc_len(rt_int16_t n, rt_int16_t m) { if(n > m) return n; #ifndef RTGUI_USING_SMALL_SIZE @@ -261,7 +272,7 @@ rt_inline rt_size_t rtgui_edit_alloc_len(rt_size_t n, rt_size_t m) * please use it to replace rt_strlen * especially in reading the source file. */ -rt_inline rt_size_t rtgui_edit_line_strlen(const char *s) +rt_inline rt_int16_t rtgui_edit_line_strlen(const char *s) { const char *sc; /* ascii text end of 0x0A or 0x0D-0x0A*/ @@ -271,7 +282,7 @@ rt_inline rt_size_t rtgui_edit_line_strlen(const char *s) rt_bool_t rtgui_edit_append_line(struct rtgui_edit* edit, const char *text) { - rt_size_t len; + rt_int16_t len; struct edit_line *line, *node; RT_ASSERT(edit != RT_NULL); @@ -296,6 +307,7 @@ rt_bool_t rtgui_edit_append_line(struct rtgui_edit* edit, const char *text) edit->head = line; edit->tail = line; line->prev = RT_NULL; + edit->first_line = line; return RT_TRUE; } while(node->next != RT_NULL) node = node->next; @@ -307,10 +319,11 @@ rt_bool_t rtgui_edit_append_line(struct rtgui_edit* edit, const char *text) return RT_TRUE; } +RTM_EXPORT(rtgui_edit_append_line); rt_bool_t rtgui_edit_insert_line(struct rtgui_edit *edit, struct edit_line *p, char *text) { - rt_size_t len; + rt_int16_t len; struct edit_line *line; RT_ASSERT(edit != RT_NULL); @@ -346,6 +359,7 @@ rt_bool_t rtgui_edit_insert_line(struct rtgui_edit *edit, struct edit_line *p, c return RT_TRUE; } +RTM_EXPORT(rtgui_edit_insert_line); rt_bool_t rtgui_edit_delete_line(struct rtgui_edit* edit, struct edit_line *line) { @@ -396,10 +410,11 @@ rt_bool_t rtgui_edit_delete_line(struct rtgui_edit* edit, struct edit_line *line return RT_TRUE; } +RTM_EXPORT(rtgui_edit_delete_line); rt_bool_t rtgui_edit_connect_line(struct rtgui_edit* edit, struct edit_line *line, struct edit_line *connect) { - rt_size_t len1,len2; + rt_int16_t len1,len2; RT_ASSERT(edit != RT_NULL); RT_ASSERT(line != RT_NULL); @@ -416,6 +431,7 @@ rt_bool_t rtgui_edit_connect_line(struct rtgui_edit* edit, struct edit_line *lin line->len = rtgui_edit_line_strlen(line->text); return RT_TRUE; } +RTM_EXPORT(rtgui_edit_connect_line); static void rtgui_edit_get_caret_rect(struct rtgui_edit *edit, rtgui_rect_t *rect, rtgui_point_t visual) { @@ -536,6 +552,7 @@ struct edit_line* rtgui_edit_get_line_by_index(struct rtgui_edit *edit, rt_uint3 } return line; } +RTM_EXPORT(rtgui_edit_get_line_by_index); rt_uint32_t rtgui_edit_get_index_by_line(struct rtgui_edit *edit, struct edit_line *line) { @@ -559,6 +576,71 @@ rt_uint32_t rtgui_edit_get_index_by_line(struct rtgui_edit *edit, struct edit_li } return index; } +RTM_EXPORT(rtgui_edit_get_index_by_line); + +enum { + EDIT_IDENT_DIR_BOTH, + EDIT_IDENT_DIR_LEFT, + EDIT_IDENT_DIR_RIGHT +}; +/* +* identify a byte is double byte +* @param dir set direction. +* @param *p record the position of the effective. +* @return RT_TRUE is Got it, else not found. +*/ +static rt_bool_t identify_double_byte(struct rtgui_edit *edit, struct edit_line *line, + rt_uint32_t dir, rt_int16_t *p) +{ + int index, effe_nums; + + RT_ASSERT(edit != RT_NULL); + RT_ASSERT(line != RT_NULL); + + if(dir == EDIT_IDENT_DIR_BOTH) + { + } + else if(dir == EDIT_IDENT_DIR_LEFT) + { + if(edit->upleft.x == 0 && edit->visual.x == 0) + return RT_FALSE; + index = edit->upleft.x + edit->visual.x; + effe_nums = 0; + while(index--) + { + if(*(line->text + index) >= 0x80) + effe_nums ++; + else + break; + } + if(effe_nums > 0) + { + *p = 2-effe_nums%2; + return RT_TRUE; + } + } + else if(dir == EDIT_IDENT_DIR_RIGHT) + { + if(edit->upleft.x + edit->visual.x == line->len) + return RT_FALSE; + index = edit->upleft.x + edit->visual.x; + effe_nums = 0; + while(index < line->len) + { + if(*(line->text + index) >= 0x80) + effe_nums ++; + else + break; + index ++; + } + if(effe_nums > 0) + { + *p = 2-effe_nums%2; + return RT_TRUE; + } + } + return RT_FALSE; +} static void rtgui_edit_onmouse(struct rtgui_edit* edit, struct rtgui_event_mouse* emouse) { @@ -580,6 +662,7 @@ static void rtgui_edit_onmouse(struct rtgui_edit* edit, struct rtgui_event_mouse if(emouse->button & RTGUI_MOUSE_BUTTON_DOWN) { struct edit_line *line; + rt_int16_t tmp_pos=0; edit->visual.x = x; edit->visual.y = y; @@ -590,7 +673,16 @@ static void rtgui_edit_onmouse(struct rtgui_edit* edit, struct rtgui_event_mouse if(edit->visual.x > line->len) edit->visual.x = line->len; - + if(edit->upleft.x > 0) + { + if(edit->upleft.x >= line->len) + edit->upleft.x = 0; + else + edit->visual.x -= edit->upleft.x; + rtgui_edit_ondraw(edit); + } + if(identify_double_byte(edit, line, EDIT_IDENT_DIR_LEFT, &tmp_pos)) + edit->visual.x -= (2-tmp_pos); if(edit->flag & RTGUI_EDIT_CARET) { if(edit->caret_timer != RT_NULL) @@ -820,9 +912,11 @@ static rt_bool_t rtgui_edit_onkey(struct rtgui_object* object, rtgui_event_t* ev else { char *c; + rt_int16_t tmp_pos=1; + identify_double_byte(edit, line, EDIT_IDENT_DIR_RIGHT, &tmp_pos); /* remove character */ - for(c = &line->text[ofs]; c[1] != '\0'; c++) - *c = c[1]; + for(c = &line->text[ofs]; c[tmp_pos] != '\0'; c++) + *c = c[tmp_pos]; *c = '\0'; } update_type = EDIT_UPDATE; @@ -873,19 +967,23 @@ static rt_bool_t rtgui_edit_onkey(struct rtgui_object* object, rtgui_event_t* ev /* delete front character */ if(edit->visual.x == line->len) { - line->text[edit->visual.x-1] = '\0'; - edit->visual.x --; + rt_int16_t tmp_pos=1; + identify_double_byte(edit, line, EDIT_IDENT_DIR_LEFT, &tmp_pos); + line->text[edit->visual.x-tmp_pos] = '\0'; + edit->visual.x -= tmp_pos; } else if(edit->visual.x != 0) { /* remove current character */ char *c; + rt_int16_t tmp_pos=1; + identify_double_byte(edit, line, EDIT_IDENT_DIR_LEFT, &tmp_pos); /* remove character */ - for(c = &line->text[edit->visual.x - 1]; c[1] != '\0'; c++) + for(c = &line->text[edit->visual.x - tmp_pos]; c[tmp_pos] != '\0'; c++) { - *c = c[1]; + *c = c[tmp_pos]; } *c = '\0'; - edit->visual.x --; + edit->visual.x -= tmp_pos; } /* adjusted line buffer length */ if(rtgui_edit_alloc_len(edit->bzsize, line->len+2) < line->zsize) @@ -924,15 +1022,38 @@ static rt_bool_t rtgui_edit_onkey(struct rtgui_object* object, rtgui_event_t* ev { if(prev_line->len <= edit->upleft.x) { - edit->upleft.x = 0; - edit->visual.x = prev_line->len; + if(prev_line->len <= edit->col_per_page) + { + edit->upleft.x = 0; + edit->visual.x = prev_line->len; + } + else + { + edit->upleft.x = prev_line->len - (edit->col_per_page-1); + edit->visual.x = edit->col_per_page-1; + } update_type = EDIT_ONDRAW; } else if(prev_line->len - edit->upleft.x < edit->col_per_page) - edit->visual.x = prev_line->len - edit->upleft.x; + { + if(edit->visual.x > prev_line->len - edit->upleft.x) + edit->visual.x = prev_line->len - edit->upleft.x; + else + { + rt_int16_t tmp_pos=0; + if(identify_double_byte(edit, prev_line, EDIT_IDENT_DIR_LEFT, &tmp_pos)) + edit->visual.x -= (2-tmp_pos); + } + } } else if(edit->visual.x > prev_line->len) edit->visual.x = prev_line->len; + else if(prev_line->len >= 2) + { + rt_int16_t tmp_pos=0; + if(identify_double_byte(edit, prev_line, EDIT_IDENT_DIR_LEFT, &tmp_pos)) + edit->visual.x -= (2-tmp_pos); + } #ifdef RTGUI_EDIT_USING_SCROLL /* update vscroll */ @@ -974,15 +1095,38 @@ static rt_bool_t rtgui_edit_onkey(struct rtgui_object* object, rtgui_event_t* ev { if(next_line->len <= edit->upleft.x) { - edit->upleft.x = 0; - edit->visual.x = next_line->len; + if(next_line->len <= edit->col_per_page) + { + edit->upleft.x = 0; + edit->visual.x = next_line->len; + } + else + { + edit->upleft.x = next_line->len - (edit->col_per_page-1); + edit->visual.x = edit->col_per_page-1; + } update_type = EDIT_ONDRAW; } else if(next_line->len - edit->upleft.x < edit->col_per_page) - edit->visual.x = next_line->len - edit->upleft.x; + { + if(edit->visual.x > next_line->len - edit->upleft.x) + edit->visual.x = next_line->len - edit->upleft.x; + else + { + rt_int16_t tmp_pos=0; + if(identify_double_byte(edit, next_line, EDIT_IDENT_DIR_LEFT, &tmp_pos)) + edit->visual.x -= (2-tmp_pos); + } + } } else if(edit->visual.x > next_line->len) edit->visual.x = next_line->len; + else if(next_line->len >= 2) + { + rt_int16_t tmp_pos=0; + if(identify_double_byte(edit, next_line, EDIT_IDENT_DIR_LEFT, &tmp_pos)) + edit->visual.x -= (2-tmp_pos); + } #ifdef RTGUI_EDIT_USING_SCROLL /* update vscroll */ @@ -996,12 +1140,24 @@ static rt_bool_t rtgui_edit_onkey(struct rtgui_object* object, rtgui_event_t* ev else if(ekbd->key == RTGUIK_LEFT) { /* move to prev char */ if(edit->visual.x > 0) - edit->visual.x --; + { + rt_int16_t tmp_pos=1; + identify_double_byte(edit, line, EDIT_IDENT_DIR_LEFT, &tmp_pos); + edit->visual.x -= tmp_pos; + if(edit->visual.x == -1) + { + edit->visual.x = 0; + edit->upleft.x --; + update_type = EDIT_ONDRAW; + } + } else { if(edit->upleft.x > 0) { - edit->upleft.x --; + rt_int16_t tmp_pos=1; + identify_double_byte(edit, line, EDIT_IDENT_DIR_LEFT, &tmp_pos); + edit->upleft.x -= tmp_pos; update_type = EDIT_ONDRAW; } else @@ -1028,7 +1184,11 @@ static rt_bool_t rtgui_edit_onkey(struct rtgui_object* object, rtgui_event_t* ev if(edit->upleft.x+edit->col_per_page <= line->len) { if(edit->visual.x < edit->col_per_page-1) - edit->visual.x ++; + { + rt_int16_t tmp_pos=1; + identify_double_byte(edit, line, EDIT_IDENT_DIR_RIGHT, &tmp_pos); + edit->visual.x += tmp_pos; + } else if(edit->visual.x == edit->col_per_page-1) { if(edit->upleft.x+edit->col_per_page < line->len) @@ -1051,7 +1211,11 @@ static rt_bool_t rtgui_edit_onkey(struct rtgui_object* object, rtgui_event_t* ev else { if(edit->visual.x < line->len) - edit->visual.x ++; + { + rt_int16_t tmp_pos=1; + identify_double_byte(edit, line, EDIT_IDENT_DIR_RIGHT, &tmp_pos); + edit->visual.x += tmp_pos; + } else { struct rtgui_event_kbd event_kbd; @@ -1105,9 +1269,6 @@ static rt_bool_t rtgui_edit_onkey(struct rtgui_object* object, rtgui_event_t* ev { struct edit_line *update_end_line; struct rtgui_event_kbd event_kbd; - - update_type = EDIT_UPDATE; - edit->update.start = edit->visual; /* insert a new line buffer */ rtgui_edit_insert_line(edit, line, line->text + edit->upleft.x + edit->visual.x); @@ -1115,8 +1276,10 @@ static rt_bool_t rtgui_edit_onkey(struct rtgui_object* object, rtgui_event_t* ev line->len = rtgui_edit_line_strlen(line->text); /* adjust update line end position */ - if((edit->max_rows-edit->upleft.y) >= edit->row_per_page) + if((edit->max_rows-edit->upleft.y) > edit->row_per_page) { + update_type = EDIT_UPDATE; + edit->update.start = edit->visual; update_end_line = rtgui_edit_get_line_by_index(edit, edit->upleft.y+edit->row_per_page-1); if(update_end_line != RT_NULL) { @@ -1124,11 +1287,18 @@ static rt_bool_t rtgui_edit_onkey(struct rtgui_object* object, rtgui_event_t* ev edit->update.end.y = edit->upleft.y + edit->row_per_page; } } - else + else if((edit->max_rows-edit->upleft.y) < edit->row_per_page) { int update_end_index = rtgui_edit_get_index_by_line(edit, edit->tail); + update_type = EDIT_UPDATE; + edit->update.start = edit->visual; edit->update.end.x = edit->tail->len; edit->update.end.y = update_end_index; + } + else + { + /* nothing */ + /* it will be adjusted upleft.y when entering DOWN case */ } /* move the caret to the next line head */ @@ -1139,7 +1309,7 @@ static rt_bool_t rtgui_edit_onkey(struct rtgui_object* object, rtgui_event_t* ev } else { - if(isprint(ekbd->key)) + if(isprint((unsigned char)ekbd->key)) { /* it's may print character */ update_type = EDIT_UPDATE; edit->update.start = edit->visual; @@ -1164,7 +1334,7 @@ static rt_bool_t rtgui_edit_onkey(struct rtgui_object* object, rtgui_event_t* ev for(c = &line->text[line->len]; c != &line->text[ofs]; c--) *c = *(c-1); } - line->text[ofs] = ekbd->key; + line->text[ofs] = (char)ekbd->key; if(edit->visual.x < edit->col_per_page-1) edit->visual.x ++; line->text[line->len+1] = '\0'; @@ -1282,7 +1452,7 @@ static rt_bool_t rtgui_edit_vscroll_handle(struct rtgui_widget* widget, rtgui_ev /* local area update */ void rtgui_edit_update(struct rtgui_edit *edit) { - rt_uint32_t i,cpy_len=0,prev_len; + rt_int16_t i,cpy_len=0,prev_len; rtgui_rect_t rect, r; struct rtgui_dc *dc; char *src; @@ -1381,8 +1551,10 @@ void rtgui_edit_ondraw(struct rtgui_edit *edit) { rtgui_rect_t rect, r; struct rtgui_dc *dc; +#ifdef RTGUI_EDIT_USING_SCROLL int hscroll_flag=0; int vscroll_flag=0; +#endif RT_ASSERT(edit != RT_NULL); @@ -1424,8 +1596,39 @@ void rtgui_edit_ondraw(struct rtgui_edit *edit) rect.y2 = rect.y1 + edit->item_height; while(line) { + rt_int16_t tmp_pos=0, ofs; + char *str = line->text+edit->upleft.x; + if(edit->upleft.x < line->len) - rtgui_dc_draw_text(dc, line->text+edit->upleft.x, &rect); + { + rtgui_point_t p = edit->visual; /* backup */ + edit->visual.x = 0; + identify_double_byte(edit, line, EDIT_IDENT_DIR_LEFT, &tmp_pos); + ofs = tmp_pos % 2; + if(ofs == 1) + { /* use dc_buffer draw the left half of double byte */ + char dbl_bmp[3]; + rtgui_point_t pot = {0}; + rtgui_rect_t r = {0}; + + pot.x = edit->font_width; + r.x2 = edit->font_width*2; + r.y2 = edit->font_height; + dbl_bmp[0] = *(str-1); + dbl_bmp[1] = *str; + dbl_bmp[2] = '\0'; + RTGUI_DC_BC(edit->dbl_buf) = RTGUI_WIDGET_BACKGROUND(edit); + rtgui_dc_fill_rect(edit->dbl_buf, &r); + RTGUI_DC_FC(edit->dbl_buf) = RTGUI_WIDGET_FOREGROUND(edit); + rtgui_dc_draw_text(edit->dbl_buf, dbl_bmp, &r); + rtgui_dc_blit(edit->dbl_buf, &pot, dc, &rect); + } + rect.x1 += ofs * edit->font_width; + rtgui_dc_draw_text(dc, line->text+edit->upleft.x+ofs, &rect); + rect.x1 -= ofs * edit->font_width; + edit->visual = p; /* restore */ + } + line = line->next; rect.y1 += edit->item_height; if((rect.y1 + edit->item_height) < r.y2) @@ -1469,8 +1672,10 @@ void rtgui_edit_ondraw(struct rtgui_edit *edit) void rtgui_edit_set_text(struct rtgui_edit* edit, const char* text) { const char *begin, *ptr; +#ifdef RTGUI_EDIT_USING_SCROLL int hscroll_flag=0; int vscroll_flag=0; +#endif RT_ASSERT(edit != RT_NULL); @@ -1497,7 +1702,6 @@ void rtgui_edit_set_text(struct rtgui_edit* edit, const char* text) if(begin < ptr) rtgui_edit_append_line(edit, begin); } - edit->first_line = edit->head; #ifdef RTGUI_EDIT_USING_SCROLL if(edit->hscroll != RT_NULL) @@ -1539,11 +1743,12 @@ void rtgui_edit_set_text(struct rtgui_edit* edit, const char* text) { rtgui_edit_adjust_scroll(edit->vscroll); } -#endif + if(hscroll_flag || vscroll_flag) { rtgui_widget_update_clip(RTGUI_WIDGET(edit)); } +#endif } rt_bool_t rtgui_edit_event_handler(struct rtgui_object* object, rtgui_event_t* event) @@ -1587,21 +1792,56 @@ rt_bool_t rtgui_edit_event_handler(struct rtgui_object* object, rtgui_event_t* e return RT_FALSE; } +rtgui_point_t rtgui_edit_get_current_point(struct rtgui_edit *edit) +{ + rtgui_point_t p; + + RT_ASSERT(edit != RT_NULL); + + p.x = edit->upleft.x + edit->visual.x; + p.y = edit->upleft.y + edit->visual.y; + + return p; +} + +rt_uint32_t rtgui_edit_get_mem_consume(struct rtgui_edit *edit) +{ + rt_uint32_t mem_size; + struct edit_line *line; + + mem_size = sizeof(struct rtgui_edit); + mem_size += edit->col_per_page + 1; /* update_buf */ + if(edit->head != RT_NULL) + { + line = edit->head; + while(line) + { + mem_size += line->zsize; + mem_size += sizeof(struct edit_line); + line = line->next; + } + } + + return mem_size; +} + /** * File access component, General File Access Interface */ rt_bool_t rtgui_edit_readin_file(struct rtgui_edit *edit, const char *filename) { - int fd, num=0, read_bytes, size ,len=0; + struct rtgui_filerw *filerw; + int num=0, read_bytes, size ,len=0; char *text ,ch; - fd = open(filename, O_RDONLY, 0); - if (fd < 0) - { - return RT_FALSE; - } - + filerw = rtgui_filerw_create_file(filename, "rb"); + if (filerw == RT_NULL) return RT_FALSE; + /** + * If it was in the debug of the win32, If document encode is UTF-8 or Unicode, + * Will read to garbled code when using the function read documents. + * You can Change of the document contains the source code for ANSI. + */ while(edit->max_rows > 0) rtgui_edit_delete_line(edit, edit->head); edit->max_rows = 0; @@ -1611,8 +1851,8 @@ rt_bool_t rtgui_edit_readin_file(struct rtgui_edit *edit, const char *filename) if(text == RT_NULL) return RT_FALSE; do { - if ( (read_bytes = read(fd, &ch, 1)) > 0 ) - { + if ( (read_bytes = rtgui_filerw_read(filerw, &ch, 1, 1)) > 0 ) + { /* rt_kprintf("ch=%02X ",ch); DEBUG */ if(num >= size - 1) text = rt_realloc(text, rtgui_edit_alloc_len(size, num)); if(ch == 0x09) //Tab @@ -1630,9 +1870,14 @@ rt_bool_t rtgui_edit_readin_file(struct rtgui_edit *edit, const char *filename) } } + else if(num > 0) + { /* last line does not exist the end operator */ + *(text + num) = '\0'; + rtgui_edit_append_line(edit, text); + } } while(read_bytes); - close(fd); + rtgui_filerw_close(filerw); rtgui_free(text); rtgui_edit_ondraw(edit); @@ -1641,26 +1886,23 @@ rt_bool_t rtgui_edit_readin_file(struct rtgui_edit *edit, const char *filename) rt_bool_t rtgui_edit_saveas_file(struct rtgui_edit *edit, const char *filename) { - int fd; + struct rtgui_filerw *filerw; char ch_tailed = 0x0A; struct edit_line *line; - fd = open(filename, O_WRONLY | O_CREAT, 0); - if (fd < 0) - { - return RT_FALSE; - } + filerw = rtgui_filerw_create_file(filename, "wb"); + if (filerw == RT_NULL) return RT_FALSE; line = edit->head; while(line) { - write(fd, line->text, line->len); + rtgui_filerw_write(filerw, line->text, line->len, 1); if(line != edit->tail) - write(fd, &ch_tailed, 1); + rtgui_filerw_write(filerw, &ch_tailed, 1, 1); line = line->next; } - close(fd); + rtgui_filerw_close(filerw); return RT_TRUE; } diff --git a/components/rtgui/widgets/filelist_view.c b/components/rtgui/widgets/filelist_view.c index 67c141d456..9f1d049bd1 100644 --- a/components/rtgui/widgets/filelist_view.c +++ b/components/rtgui/widgets/filelist_view.c @@ -24,7 +24,7 @@ #include #include -#if defined(RTGUI_USING_DFS_FILERW) || defined(RTGUI_USING_STDIO_FILERW) +#if defined(RTGUI_USING_DFS_FILERW) #ifdef _WIN32 #include #include diff --git a/components/rtgui/widgets/label.c b/components/rtgui/widgets/label.c index a3ddbaa3ec..eb2cd47ec6 100644 --- a/components/rtgui/widgets/label.c +++ b/components/rtgui/widgets/label.c @@ -56,6 +56,7 @@ rt_bool_t rtgui_label_event_handler(struct rtgui_object *object, struct rtgui_ev return RT_FALSE; } +RTM_EXPORT(rtgui_label_event_handler); rtgui_label_t* rtgui_label_create(const char* text) { @@ -78,11 +79,13 @@ rtgui_label_t* rtgui_label_create(const char* text) return label; } +RTM_EXPORT(rtgui_label_create); void rtgui_label_destroy(rtgui_label_t* label) { rtgui_widget_destroy(RTGUI_WIDGET(label)); } +RTM_EXPORT(rtgui_label_destroy); char* rtgui_label_get_text(rtgui_label_t* label) { @@ -90,6 +93,7 @@ char* rtgui_label_get_text(rtgui_label_t* label) return label->text; } +RTM_EXPORT(rtgui_label_get_text); void rtgui_label_set_text(rtgui_label_t* label, const char* text) { @@ -110,4 +114,5 @@ void rtgui_label_set_text(rtgui_label_t* label, const char* text) /* update widget */ rtgui_theme_draw_label(label); } +RTM_EXPORT(rtgui_label_set_text); diff --git a/components/rtgui/widgets/list_view.c b/components/rtgui/widgets/list_view.c index 14244654f4..d4aa7a4bce 100644 --- a/components/rtgui/widgets/list_view.c +++ b/components/rtgui/widgets/list_view.c @@ -303,6 +303,7 @@ void rtgui_list_view_update_list(struct rtgui_list_view* view, rt_int16_t old_it rtgui_dc_end_drawing(dc); } +RTM_EXPORT(rtgui_list_view_update_list); void rtgui_list_view_ondraw(struct rtgui_list_view* view) { @@ -328,6 +329,7 @@ void rtgui_list_view_ondraw(struct rtgui_list_view* view) rtgui_dc_end_drawing(dc); } +RTM_EXPORT(rtgui_list_view_ondraw); static rt_bool_t rtgui_list_view_onmouse(struct rtgui_list_view* view, struct rtgui_event_mouse* emouse) { @@ -564,6 +566,7 @@ rt_bool_t rtgui_list_view_event_handler(struct rtgui_object* widget, struct rtgu /* use view event handler */ return rtgui_container_event_handler(widget, event); } +RTM_EXPORT(rtgui_list_view_event_handler); static void rtgui_list_view_calc(struct rtgui_list_view* view) { @@ -628,9 +631,12 @@ rtgui_list_view_t* rtgui_list_view_create(const struct rtgui_list_item* items, r return view; } +RTM_EXPORT(rtgui_list_view_create); void rtgui_list_view_destroy(rtgui_list_view_t* view) { /* destroy view */ rtgui_widget_destroy(RTGUI_WIDGET(view)); } +RTM_EXPORT(rtgui_list_view_destroy); + diff --git a/components/rtgui/widgets/listbox.c b/components/rtgui/widgets/listbox.c index 9ec5a3b3a6..3bcef6a085 100644 --- a/components/rtgui/widgets/listbox.c +++ b/components/rtgui/widgets/listbox.c @@ -102,6 +102,7 @@ void rtgui_listbox_ondraw(struct rtgui_listbox* box) } rtgui_dc_end_drawing(dc); } +RTM_EXPORT(rtgui_listbox_ondraw); static void rtgui_listbox_update_current(struct rtgui_listbox* box, rt_int16_t old_item) { @@ -324,6 +325,7 @@ rt_bool_t rtgui_listbox_event_handler(struct rtgui_object* object, struct rtgui_ /* use box event handler */ return rtgui_widget_event_handler(RTGUI_OBJECT(widget), event); } +RTM_EXPORT(rtgui_listbox_event_handler); rtgui_listbox_t* rtgui_listbox_create(const struct rtgui_listbox_item* items, rt_uint16_t count, rtgui_rect_t *rect) { @@ -342,12 +344,14 @@ rtgui_listbox_t* rtgui_listbox_create(const struct rtgui_listbox_item* items, rt return box; } +RTM_EXPORT(rtgui_listbox_create); void rtgui_listbox_destroy(rtgui_listbox_t* box) { /* destroy box */ rtgui_widget_destroy(RTGUI_WIDGET(box)); } +RTM_EXPORT(rtgui_listbox_destroy); void rtgui_listbox_set_onitem(rtgui_listbox_t* box, rtgui_event_handler_ptr func) { @@ -355,6 +359,7 @@ void rtgui_listbox_set_onitem(rtgui_listbox_t* box, rtgui_event_handler_ptr func box->on_item = func; } +RTM_EXPORT(rtgui_listbox_set_onitem); void rtgui_listbox_set_items(rtgui_listbox_t* box, struct rtgui_listbox_item* items, rt_uint16_t count) { @@ -369,6 +374,7 @@ void rtgui_listbox_set_items(rtgui_listbox_t* box, struct rtgui_listbox_item* it rtgui_widget_update(RTGUI_WIDGET(box)); } +RTM_EXPORT(rtgui_listbox_set_items); void rtgui_listbox_set_current_item(rtgui_listbox_t* box, int index) { @@ -384,4 +390,5 @@ void rtgui_listbox_set_current_item(rtgui_listbox_t* box, int index) rtgui_listbox_update_current(box, old_item); } } +RTM_EXPORT(rtgui_listbox_set_current_item); diff --git a/components/rtgui/widgets/listctrl.c b/components/rtgui/widgets/listctrl.c index b1e428d2ea..892a08633a 100644 --- a/components/rtgui/widgets/listctrl.c +++ b/components/rtgui/widgets/listctrl.c @@ -207,6 +207,7 @@ void rtgui_listctrl_update_current(struct rtgui_listctrl* ctrl, rt_uint16_t old_ rtgui_dc_end_drawing(dc); } +RTM_EXPORT(rtgui_listctrl_update_current); rt_bool_t rtgui_listctrl_event_handler(struct rtgui_object* object, struct rtgui_event* event) { @@ -361,6 +362,7 @@ rt_bool_t rtgui_listctrl_event_handler(struct rtgui_object* object, struct rtgui /* use ctrl event handler */ return rtgui_widget_event_handler(RTGUI_OBJECT(widget), event); } +RTM_EXPORT(rtgui_listctrl_event_handler); rtgui_listctrl_t* rtgui_listctrl_create(rt_uint32_t items, rt_uint16_t count, rtgui_rect_t *rect, rtgui_onitem_draw_t ondraw) @@ -380,12 +382,14 @@ rtgui_listctrl_t* rtgui_listctrl_create(rt_uint32_t items, rt_uint16_t count, rt return ctrl; } +RTM_EXPORT(rtgui_listctrl_create); void rtgui_listctrl_destroy(rtgui_listctrl_t* ctrl) { /* destroy ctrl */ rtgui_widget_destroy(RTGUI_WIDGET(ctrl)); } +RTM_EXPORT(rtgui_listctrl_destroy); void rtgui_listctrl_set_onitem(rtgui_listctrl_t* ctrl, rtgui_event_handler_ptr func) { @@ -393,6 +397,7 @@ void rtgui_listctrl_set_onitem(rtgui_listctrl_t* ctrl, rtgui_event_handler_ptr f ctrl->on_item = func; } +RTM_EXPORT(rtgui_listctrl_set_onitem); void rtgui_listctrl_set_items(rtgui_listctrl_t* ctrl, rt_uint32_t items, rt_uint16_t count) { @@ -407,6 +412,7 @@ void rtgui_listctrl_set_items(rtgui_listctrl_t* ctrl, rt_uint32_t items, rt_uint rtgui_widget_update(RTGUI_WIDGET(ctrl)); } +RTM_EXPORT(rtgui_listctrl_set_items); rt_bool_t rtgui_listctrl_get_item_rect(rtgui_listctrl_t* ctrl, rt_uint16_t item, rtgui_rect_t* item_rect) { @@ -427,6 +433,7 @@ rt_bool_t rtgui_listctrl_get_item_rect(rtgui_listctrl_t* ctrl, rt_uint16_t item, return RT_FALSE; } +RTM_EXPORT(rtgui_listctrl_get_item_rect); void rtgui_listctrl_set_itemheight(struct rtgui_listctrl* ctrl, int height) { @@ -436,4 +443,5 @@ void rtgui_listctrl_set_itemheight(struct rtgui_listctrl* ctrl, int height) ctrl->item_height = height; ctrl->page_items = rtgui_rect_height(RTGUI_WIDGET(ctrl)->extent) / (2 + ctrl->item_height); } +RTM_EXPORT(rtgui_listctrl_set_itemheight); diff --git a/components/rtgui/widgets/slider.c b/components/rtgui/widgets/slider.c index b0204d8a00..1bbbc773ad 100644 --- a/components/rtgui/widgets/slider.c +++ b/components/rtgui/widgets/slider.c @@ -192,6 +192,7 @@ rt_bool_t rtgui_slider_event_handler(struct rtgui_object *object, struct rtgui_e return RT_FALSE; } +RTM_EXPORT(rtgui_slider_event_handler); struct rtgui_slider* rtgui_slider_create(rt_size_t min, rt_size_t max, int orient) { @@ -213,6 +214,7 @@ struct rtgui_slider* rtgui_slider_create(rt_size_t min, rt_size_t max, int orien return slider; } +RTM_EXPORT(rtgui_slider_create); void rtgui_slider_set_range(struct rtgui_slider* slider, rt_size_t min, rt_size_t max) { @@ -221,6 +223,7 @@ void rtgui_slider_set_range(struct rtgui_slider* slider, rt_size_t min, rt_size_ slider->max = max; slider->min = min; } +RTM_EXPORT(rtgui_slider_set_range); void rtgui_slider_set_value(struct rtgui_slider* slider, rt_size_t value) { @@ -238,6 +241,7 @@ void rtgui_slider_set_value(struct rtgui_slider* slider, rt_size_t value) } } } +RTM_EXPORT(rtgui_slider_set_value); void rtgui_slider_set_orientation(struct rtgui_slider* slider, int orientation) { @@ -260,6 +264,7 @@ void rtgui_slider_set_orientation(struct rtgui_slider* slider, int orientation) } #endif } +RTM_EXPORT(rtgui_slider_set_orientation); rt_size_t rtgui_slider_get_value(struct rtgui_slider* slider) { @@ -267,3 +272,5 @@ rt_size_t rtgui_slider_get_value(struct rtgui_slider* slider) return slider->value; } +RTM_EXPORT(rtgui_slider_get_value); + diff --git a/components/rtgui/widgets/staticline.c b/components/rtgui/widgets/staticline.c index 0a2ea20079..1c41ccedac 100644 --- a/components/rtgui/widgets/staticline.c +++ b/components/rtgui/widgets/staticline.c @@ -42,6 +42,7 @@ rt_bool_t rtgui_staticline_event_handler(struct rtgui_object* object, struct rtg return RT_FALSE; } +RTM_EXPORT(rtgui_staticline_event_handler); rtgui_staticline_t * rtgui_staticline_create(int orientation) { @@ -55,11 +56,13 @@ rtgui_staticline_t * rtgui_staticline_create(int orientation) return staticline; } +RTM_EXPORT(rtgui_staticline_create); void rtgui_staticline_destroy(rtgui_staticline_t* staticline) { rtgui_widget_destroy(RTGUI_WIDGET(staticline)); } +RTM_EXPORT(rtgui_staticline_destroy); void rtgui_staticline_set_orientation(rtgui_staticline_t* staticline, int orientation) { @@ -81,3 +84,5 @@ void rtgui_staticline_set_orientation(rtgui_staticline_t* staticline, int orient } #endif } +RTM_EXPORT(rtgui_staticline_set_orientation); + diff --git a/components/rtgui/widgets/widget.c b/components/rtgui/widgets/widget.c index 0f506cd760..358f4c452f 100644 --- a/components/rtgui/widgets/widget.c +++ b/components/rtgui/widgets/widget.c @@ -91,6 +91,7 @@ DEFINE_CLASS_TYPE(widget, "widget", _rtgui_widget_constructor, _rtgui_widget_destructor, sizeof(struct rtgui_widget)); +RTM_EXPORT(_rtgui_widget); rtgui_widget_t *rtgui_widget_create(rtgui_type_t *widget_type) { @@ -100,11 +101,13 @@ rtgui_widget_t *rtgui_widget_create(rtgui_type_t *widget_type) return widget; } +RTM_EXPORT(rtgui_widget_create); void rtgui_widget_destroy(rtgui_widget_t* widget) { rtgui_object_destroy(RTGUI_OBJECT(widget)); } +RTM_EXPORT(rtgui_widget_destroy); void rtgui_widget_set_rect(rtgui_widget_t* widget, const rtgui_rect_t* rect) { @@ -142,6 +145,7 @@ void rtgui_widget_set_rect(rtgui_widget_t* widget, const rtgui_rect_t* rect) rtgui_widget_update_clip(widget->parent); } } +RTM_EXPORT(rtgui_widget_set_rect); void rtgui_widget_set_rectangle(rtgui_widget_t* widget, int x, int y, int width, int height) { @@ -152,12 +156,14 @@ void rtgui_widget_set_rectangle(rtgui_widget_t* widget, int x, int y, int width, rtgui_widget_set_rect(widget, &rect); } +RTM_EXPORT(rtgui_widget_set_rectangle); void rtgui_widget_set_parent(rtgui_widget_t* widget, rtgui_widget_t* parent) { /* set parent and toplevel widget */ widget->parent = parent; } +RTM_EXPORT(rtgui_widget_set_parent); void rtgui_widget_get_extent(rtgui_widget_t* widget, rtgui_rect_t *rect) { @@ -166,6 +172,7 @@ void rtgui_widget_get_extent(rtgui_widget_t* widget, rtgui_rect_t *rect) *rect = widget->extent; } +RTM_EXPORT(rtgui_widget_get_extent); void rtgui_widget_set_miniwidth(rtgui_widget_t* widget, int width) { @@ -173,6 +180,7 @@ void rtgui_widget_set_miniwidth(rtgui_widget_t* widget, int width) widget->mini_width = width; } +RTM_EXPORT(rtgui_widget_set_miniwidth); void rtgui_widget_set_miniheight(rtgui_widget_t* widget, int height) { @@ -180,6 +188,7 @@ void rtgui_widget_set_miniheight(rtgui_widget_t* widget, int height) widget->mini_height = height; } +RTM_EXPORT(rtgui_widget_set_miniheight); /* * This function moves widget and its children to a logic point @@ -204,6 +213,7 @@ void rtgui_widget_move_to_logic(rtgui_widget_t* widget, int dx, int dy) } } } +RTM_EXPORT(rtgui_widget_move_to_logic); void rtgui_widget_get_rect(rtgui_widget_t* widget, rtgui_rect_t *rect) { @@ -216,6 +226,7 @@ void rtgui_widget_get_rect(rtgui_widget_t* widget, rtgui_rect_t *rect) rect->y2 = widget->extent.y2 - widget->extent.y1; } } +RTM_EXPORT(rtgui_widget_get_rect); /** * set widget draw style @@ -247,6 +258,7 @@ void rtgui_widget_set_border(rtgui_widget_t* widget, rt_uint32_t style) break; } } +RTM_EXPORT(rtgui_widget_set_border); void rtgui_widget_set_onfocus(rtgui_widget_t* widget, rtgui_event_handler_ptr handler) { @@ -254,6 +266,7 @@ void rtgui_widget_set_onfocus(rtgui_widget_t* widget, rtgui_event_handler_ptr ha widget->on_focus_in = handler; } +RTM_EXPORT(rtgui_widget_set_onfocus); void rtgui_widget_set_onunfocus(rtgui_widget_t* widget, rtgui_event_handler_ptr handler) { @@ -261,6 +274,7 @@ void rtgui_widget_set_onunfocus(rtgui_widget_t* widget, rtgui_event_handler_ptr widget->on_focus_out = handler; } +RTM_EXPORT(rtgui_widget_set_onunfocus); void rtgui_widget_set_onshow(rtgui_widget_t* widget, rtgui_event_handler_ptr handler) { @@ -268,6 +282,7 @@ void rtgui_widget_set_onshow(rtgui_widget_t* widget, rtgui_event_handler_ptr han widget->on_show = handler; } +RTM_EXPORT(rtgui_widget_set_onshow); void rtgui_widget_set_onhide(rtgui_widget_t* widget, rtgui_event_handler_ptr handler) { @@ -275,6 +290,7 @@ void rtgui_widget_set_onhide(rtgui_widget_t* widget, rtgui_event_handler_ptr han widget->on_hide = handler; } +RTM_EXPORT(rtgui_widget_set_onhide); #ifndef RTGUI_USING_SMALL_SIZE void rtgui_widget_set_ondraw(rtgui_widget_t* widget, rtgui_event_handler_ptr handler) @@ -283,6 +299,7 @@ void rtgui_widget_set_ondraw(rtgui_widget_t* widget, rtgui_event_handler_ptr han widget->on_draw = handler; } +RTM_EXPORT(rtgui_widget_set_ondraw); void rtgui_widget_set_onmouseclick(rtgui_widget_t* widget, rtgui_event_handler_ptr handler) { @@ -290,6 +307,7 @@ void rtgui_widget_set_onmouseclick(rtgui_widget_t* widget, rtgui_event_handler_p widget->on_mouseclick = handler; } +RTM_EXPORT(rtgui_widget_set_onmouseclick); void rtgui_widget_set_onkey(rtgui_widget_t* widget, rtgui_event_handler_ptr handler) { @@ -297,6 +315,7 @@ void rtgui_widget_set_onkey(rtgui_widget_t* widget, rtgui_event_handler_ptr hand widget->on_key = handler; } +RTM_EXPORT(rtgui_widget_set_onkey); void rtgui_widget_set_onsize(rtgui_widget_t* widget, rtgui_event_handler_ptr handler) { @@ -304,6 +323,7 @@ void rtgui_widget_set_onsize(rtgui_widget_t* widget, rtgui_event_handler_ptr han widget->on_size = handler; } +RTM_EXPORT(rtgui_widget_set_onsize); void rtgui_widget_set_oncommand(rtgui_widget_t* widget, rtgui_event_handler_ptr handler) { @@ -311,6 +331,7 @@ void rtgui_widget_set_oncommand(rtgui_widget_t* widget, rtgui_event_handler_ptr widget->on_command = handler; } +RTM_EXPORT(rtgui_widget_set_oncommand); #endif /** @@ -343,6 +364,7 @@ void rtgui_widget_focus(rtgui_widget_t *widget) if (widget->on_focus_in != RT_NULL) widget->on_focus_in(RTGUI_OBJECT(widget), RT_NULL); } +RTM_EXPORT(rtgui_widget_focus); /** * @brief Unfocused the widget @@ -366,6 +388,7 @@ void rtgui_widget_unfocus(rtgui_widget_t *widget) /* refresh widget */ rtgui_widget_update(widget); } +RTM_EXPORT(rtgui_widget_unfocus); void rtgui_widget_point_to_device(rtgui_widget_t* widget, rtgui_point_t* point) { @@ -377,6 +400,7 @@ void rtgui_widget_point_to_device(rtgui_widget_t* widget, rtgui_point_t* point) point->y += widget->extent.y1; } } +RTM_EXPORT(rtgui_widget_point_to_device); void rtgui_widget_rect_to_device(rtgui_widget_t* widget, rtgui_rect_t* rect) { @@ -391,6 +415,7 @@ void rtgui_widget_rect_to_device(rtgui_widget_t* widget, rtgui_rect_t* rect) rect->y2 += widget->extent.y1; } } +RTM_EXPORT(rtgui_widget_rect_to_device); void rtgui_widget_point_to_logic(rtgui_widget_t* widget, rtgui_point_t* point) { @@ -402,6 +427,7 @@ void rtgui_widget_point_to_logic(rtgui_widget_t* widget, rtgui_point_t* point) point->y -= widget->extent.y1; } } +RTM_EXPORT(rtgui_widget_point_to_logic); void rtgui_widget_rect_to_logic(rtgui_widget_t* widget, rtgui_rect_t* rect) { @@ -416,6 +442,7 @@ void rtgui_widget_rect_to_logic(rtgui_widget_t* widget, rtgui_rect_t* rect) rect->y2 -= widget->extent.y1; } } +RTM_EXPORT(rtgui_widget_rect_to_logic); struct rtgui_win* rtgui_widget_get_toplevel(rtgui_widget_t* widget) { @@ -437,6 +464,7 @@ struct rtgui_win* rtgui_widget_get_toplevel(rtgui_widget_t* widget) return RTGUI_WIN(r); } +RTM_EXPORT(rtgui_widget_get_toplevel); rt_bool_t rtgui_widget_onupdate_toplvl(struct rtgui_object *object, struct rtgui_event *event) { @@ -453,6 +481,7 @@ rt_bool_t rtgui_widget_onupdate_toplvl(struct rtgui_object *object, struct rtgui return RT_FALSE; } +RTM_EXPORT(rtgui_widget_onupdate_toplvl); rt_bool_t rtgui_widget_event_handler(struct rtgui_object* object, rtgui_event_t* event) { @@ -496,6 +525,7 @@ rt_bool_t rtgui_widget_event_handler(struct rtgui_object* object, rtgui_event_t* return rtgui_object_event_handler(object, event); } +RTM_EXPORT(rtgui_widget_event_handler); /* * This function updates the clip info of widget @@ -558,6 +588,7 @@ void rtgui_widget_update_clip(rtgui_widget_t* widget) rtgui_widget_update_clip(rtgui_notebook_get_current(RTGUI_NOTEBOOK(widget))); } } +RTM_EXPORT(rtgui_widget_update_clip); void rtgui_widget_show(struct rtgui_widget *widget) { @@ -575,6 +606,7 @@ void rtgui_widget_show(struct rtgui_widget *widget) &eshow); } } +RTM_EXPORT(rtgui_widget_show); rt_bool_t rtgui_widget_onshow(struct rtgui_object *object, struct rtgui_event *event) { @@ -590,6 +622,7 @@ rt_bool_t rtgui_widget_onshow(struct rtgui_object *object, struct rtgui_event *e return RT_FALSE; } +RTM_EXPORT(rtgui_widget_onshow); rt_bool_t rtgui_widget_onhide(struct rtgui_object *object, struct rtgui_event *event) { @@ -621,6 +654,7 @@ rt_bool_t rtgui_widget_onhide(struct rtgui_object *object, struct rtgui_event *e return RT_FALSE; } +RTM_EXPORT(rtgui_widget_onhide); void rtgui_widget_hide(struct rtgui_widget *widget) { @@ -638,6 +672,7 @@ void rtgui_widget_hide(struct rtgui_widget *widget) &ehide); } } +RTM_EXPORT(rtgui_widget_hide); rtgui_color_t rtgui_widget_get_parent_foreground(rtgui_widget_t* widget) { @@ -654,6 +689,7 @@ rtgui_color_t rtgui_widget_get_parent_foreground(rtgui_widget_t* widget) return RTGUI_WIDGET_FOREGROUND(widget); } +RTM_EXPORT(rtgui_widget_get_parent_foreground); rtgui_color_t rtgui_widget_get_parent_background(rtgui_widget_t* widget) { @@ -670,6 +706,7 @@ rtgui_color_t rtgui_widget_get_parent_background(rtgui_widget_t* widget) return RTGUI_WIDGET_BACKGROUND(widget); } +RTM_EXPORT(rtgui_widget_get_parent_background); void rtgui_widget_update(rtgui_widget_t* widget) { @@ -689,6 +726,7 @@ void rtgui_widget_update(rtgui_widget_t* widget) &paint.parent); } } +RTM_EXPORT(rtgui_widget_update); rtgui_widget_t* rtgui_widget_get_next_sibling(rtgui_widget_t* widget) { @@ -701,6 +739,7 @@ rtgui_widget_t* rtgui_widget_get_next_sibling(rtgui_widget_t* widget) return sibling; } +RTM_EXPORT(rtgui_widget_get_next_sibling); rtgui_widget_t* rtgui_widget_get_prev_sibling(rtgui_widget_t* widget) { @@ -723,6 +762,7 @@ rtgui_widget_t* rtgui_widget_get_prev_sibling(rtgui_widget_t* widget) return sibling; } +RTM_EXPORT(rtgui_widget_get_prev_sibling); #ifdef RTGUI_WIDGET_DEBUG #include diff --git a/components/rtgui/widgets/window.c b/components/rtgui/widgets/window.c index 33ab4684a1..e7b56c9625 100644 --- a/components/rtgui/widgets/window.c +++ b/components/rtgui/widgets/window.c @@ -143,6 +143,7 @@ __on_err: rtgui_widget_destroy(RTGUI_WIDGET(win)); return RT_NULL; } +RTM_EXPORT(rtgui_win_create); rtgui_win_t* rtgui_mainwin_create(struct rtgui_win *parent_window, const char* title, rt_uint16_t style) { @@ -153,6 +154,7 @@ rtgui_win_t* rtgui_mainwin_create(struct rtgui_win *parent_window, const char* t return rtgui_win_create(parent_window, title, &rect, style); } +RTM_EXPORT(rtgui_mainwin_create); static rt_bool_t _rtgui_win_deal_close(struct rtgui_win *win, struct rtgui_event *event, @@ -215,6 +217,7 @@ void rtgui_win_destroy(struct rtgui_win* win) rtgui_widget_destroy(RTGUI_WIDGET(win)); } } +RTM_EXPORT(rtgui_win_destroy); /* send a close event to myself to get a consistent behavior */ rt_bool_t rtgui_win_close(struct rtgui_win* win) @@ -227,6 +230,7 @@ rt_bool_t rtgui_win_close(struct rtgui_win* win) (struct rtgui_event*)&eclose, RT_FALSE); } +RTM_EXPORT(rtgui_win_close); rt_base_t rtgui_win_show(struct rtgui_win* win, rt_bool_t is_modal) { @@ -298,6 +302,7 @@ rt_base_t rtgui_win_show(struct rtgui_win* win, rt_bool_t is_modal) return exit_code; } +RTM_EXPORT(rtgui_win_show); void rtgui_win_end_modal(struct rtgui_win* win, rtgui_modal_code_t modal_code) { @@ -309,6 +314,7 @@ void rtgui_win_end_modal(struct rtgui_win* win, rtgui_modal_code_t modal_code) /* remove modal mode */ win->flag &= ~RTGUI_WIN_FLAG_MODAL; } +RTM_EXPORT(rtgui_win_end_modal); void rtgui_win_hiden(struct rtgui_win* win) { @@ -333,6 +339,7 @@ void rtgui_win_hiden(struct rtgui_win* win) win->flag &= ~RTGUI_WIN_FLAG_ACTIVATE; } } +RTM_EXPORT(rtgui_win_hiden); rt_err_t rtgui_win_activate(struct rtgui_win *win) { @@ -343,6 +350,7 @@ rt_err_t rtgui_win_activate(struct rtgui_win *win) return rtgui_server_post_event_sync(RTGUI_EVENT(&eact), sizeof(eact)); } +RTM_EXPORT(rtgui_win_activate); rt_bool_t rtgui_win_is_activated(struct rtgui_win* win) { @@ -352,6 +360,7 @@ rt_bool_t rtgui_win_is_activated(struct rtgui_win* win) return RT_FALSE; } +RTM_EXPORT(rtgui_win_is_activated); void rtgui_win_move(struct rtgui_win* win, int x, int y) { @@ -385,6 +394,7 @@ void rtgui_win_move(struct rtgui_win* win, int x, int y) rtgui_widget_show(RTGUI_WIDGET(win)); return; } +RTM_EXPORT(rtgui_win_move); static rt_bool_t rtgui_win_ondraw(struct rtgui_win* win) { @@ -585,6 +595,7 @@ rt_bool_t rtgui_win_event_handler(struct rtgui_object* object, struct rtgui_even return RT_FALSE; } +RTM_EXPORT(rtgui_win_event_handler); void rtgui_win_set_rect(rtgui_win_t* win, rtgui_rect_t* rect) { @@ -604,6 +615,7 @@ void rtgui_win_set_rect(rtgui_win_t* win, rtgui_rect_t* rect) rtgui_server_post_event(&(event.parent), sizeof(struct rtgui_event_win_resize)); } } +RTM_EXPORT(rtgui_win_set_rect); void rtgui_win_set_onactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler) { @@ -612,6 +624,7 @@ void rtgui_win_set_onactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler) win->on_activate = handler; } } +RTM_EXPORT(rtgui_win_set_onactivate); void rtgui_win_set_ondeactivate(rtgui_win_t* win, rtgui_event_handler_ptr handler) { @@ -620,6 +633,7 @@ void rtgui_win_set_ondeactivate(rtgui_win_t* win, rtgui_event_handler_ptr handle win->on_deactivate = handler; } } +RTM_EXPORT(rtgui_win_set_ondeactivate); void rtgui_win_set_onclose(rtgui_win_t* win, rtgui_event_handler_ptr handler) { @@ -628,6 +642,7 @@ void rtgui_win_set_onclose(rtgui_win_t* win, rtgui_event_handler_ptr handler) win->on_close = handler; } } +RTM_EXPORT(rtgui_win_set_onclose); void rtgui_win_set_onkey(rtgui_win_t* win, rtgui_event_handler_ptr handler) { @@ -636,6 +651,7 @@ void rtgui_win_set_onkey(rtgui_win_t* win, rtgui_event_handler_ptr handler) win->on_key = handler; } } +RTM_EXPORT(rtgui_win_set_onkey); void rtgui_win_set_title(rtgui_win_t* win, const char *title) { @@ -656,6 +672,7 @@ void rtgui_win_set_title(rtgui_win_t* win, const char *title) win->title = rt_strdup(title); } } +RTM_EXPORT(rtgui_win_set_title); char* rtgui_win_get_title(rtgui_win_t* win) { @@ -663,3 +680,5 @@ char* rtgui_win_get_title(rtgui_win_t* win) return win->title; } +RTM_EXPORT(rtgui_win_get_title); +