mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-10 18:58:32 +08:00
gui 引擎代码更新;
This commit is contained in:
@@ -121,6 +121,8 @@ struct rtgui_dc_buffer
|
||||
struct rtgui_image_item *image_item;
|
||||
#endif
|
||||
|
||||
/* pixel alpha */
|
||||
rt_uint8_t pixel_alpha;
|
||||
/* pixel data */
|
||||
rt_uint8_t *pixel;
|
||||
};
|
||||
@@ -138,6 +140,7 @@ struct rtgui_dc *rtgui_img_dc_create_pixformat(rt_uint8_t pixel_format, rt_uint8
|
||||
struct rtgui_image_item *image_item);
|
||||
#endif
|
||||
struct rtgui_dc *rtgui_dc_buffer_create_from_dc(struct rtgui_dc* dc);
|
||||
void rtgui_dc_buffer_set_alpha(struct rtgui_dc* dc, rt_uint8_t pixel_alpha);
|
||||
|
||||
/* create a widget dc */
|
||||
struct rtgui_dc *rtgui_dc_widget_create(struct rtgui_widget * owner);
|
||||
|
||||
@@ -329,6 +329,7 @@ enum rtgui_gesture_type
|
||||
RTGUI_GESTURE_PINCH = 0x0002,
|
||||
RTGUI_GESTURE_DRAG = 0x0004,
|
||||
RTGUI_GESTURE_LONGPRESS = 0x0008,
|
||||
RTGUI_GESTURE_DRAGGED = 0x0001 | 0x0004 | 0x0008,
|
||||
/* PINCH, DRAG finished. */
|
||||
RTGUI_GESTURE_FINISH = 0x8000,
|
||||
/* The corresponding gesture should be canceled. */
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <rtgui/dc.h>
|
||||
#include <rtgui/font.h>
|
||||
#include <rtgui/filerw.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -99,9 +99,9 @@ int rtgui_region_is_flat(rtgui_region_t *region);
|
||||
/* rect functions */
|
||||
extern rtgui_rect_t rtgui_empty_rect;
|
||||
|
||||
void rtgui_rect_moveto(rtgui_rect_t *rect, int x, int y);
|
||||
void rtgui_rect_moveto_point(rtgui_rect_t *rect, int x, int y);
|
||||
void rtgui_rect_moveto_align(const rtgui_rect_t *rect, rtgui_rect_t *to, int align);
|
||||
void rtgui_rect_move(rtgui_rect_t *rect, int x, int y);
|
||||
void rtgui_rect_move_to_point(rtgui_rect_t *rect, int x, int y);
|
||||
void rtgui_rect_move_to_align(const rtgui_rect_t *rect, rtgui_rect_t *to, int align);
|
||||
void rtgui_rect_inflate(rtgui_rect_t *rect, int d);
|
||||
void rtgui_rect_intersect(rtgui_rect_t *src, rtgui_rect_t *dest);
|
||||
int rtgui_rect_contains_point(const rtgui_rect_t *rect, int x, int y);
|
||||
|
||||
@@ -158,6 +158,7 @@ enum RTGUI_ALIGN
|
||||
RTGUI_ALIGN_CENTER = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL,
|
||||
RTGUI_ALIGN_EXPAND = 0x10,
|
||||
RTGUI_ALIGN_STRETCH = 0x20,
|
||||
RTGUI_ALIGN_TTF_SIZE = 0x40,
|
||||
};
|
||||
|
||||
enum RTGUI_TEXTSTYLE
|
||||
@@ -172,7 +173,7 @@ enum RTGUI_MODAL_CODE
|
||||
{
|
||||
RTGUI_MODAL_OK,
|
||||
RTGUI_MODAL_CANCEL,
|
||||
RTGUI_MODAL_MAX = 0xFFFF,
|
||||
RTGUI_MODAL_MAX = 0xFFFFFFFF,
|
||||
};
|
||||
typedef enum RTGUI_MODAL_CODE rtgui_modal_code_t;
|
||||
|
||||
|
||||
@@ -88,6 +88,9 @@ struct rtgui_win
|
||||
/* inherit from container */
|
||||
rtgui_container_t parent;
|
||||
|
||||
/* update count */
|
||||
rt_base_t update;
|
||||
|
||||
/* drawing count */
|
||||
rt_base_t drawing;
|
||||
struct rtgui_rect drawing_rect;
|
||||
@@ -137,6 +140,11 @@ struct rtgui_win
|
||||
|
||||
/* Private data. */
|
||||
rt_base_t (*_do_show)(struct rtgui_win *win);
|
||||
|
||||
/* app ref_count */
|
||||
rt_uint16_t app_ref_count;
|
||||
/* win magic flag, magic value is 0xA5A55A5A */
|
||||
rt_uint32_t magic;
|
||||
};
|
||||
|
||||
rtgui_win_t *rtgui_win_create(struct rtgui_win *parent_window, const char *title,
|
||||
|
||||
+47
-25
File diff suppressed because it is too large
Load Diff
@@ -117,7 +117,7 @@ static void rtgui_box_layout_vertical(struct rtgui_box *box, struct rtgui_rect *
|
||||
rtgui_rect_init(rect, 0, 0, widget->min_width, widget->min_height);
|
||||
|
||||
/* left in default */
|
||||
rtgui_rect_moveto(rect, next_x, next_y);
|
||||
rtgui_rect_move(rect, next_x, next_y);
|
||||
|
||||
if (widget->align & RTGUI_ALIGN_EXPAND)
|
||||
{
|
||||
@@ -212,12 +212,12 @@ static void rtgui_box_layout_horizontal(struct rtgui_box *box, struct rtgui_rect
|
||||
rect = &(widget->extent);
|
||||
|
||||
/* reset rect */
|
||||
rtgui_rect_moveto(rect, -rect->x1, -rect->y1);
|
||||
rtgui_rect_move(rect, -rect->x1, -rect->y1);
|
||||
rect->x2 = widget->min_width;
|
||||
rect->y2 = widget->min_height;
|
||||
|
||||
/* top in default */
|
||||
rtgui_rect_moveto(rect, next_x, next_y);
|
||||
rtgui_rect_move(rect, next_x, next_y);
|
||||
|
||||
if (widget->align & RTGUI_ALIGN_EXPAND)
|
||||
{
|
||||
|
||||
+8
-10
@@ -313,7 +313,6 @@ void rtgui_dc_draw_text(struct rtgui_dc *dc, const char *text, struct rtgui_rect
|
||||
{
|
||||
rt_uint32_t len;
|
||||
struct rtgui_font *font;
|
||||
struct rtgui_rect text_rect;
|
||||
|
||||
RT_ASSERT(dc != RT_NULL);
|
||||
|
||||
@@ -324,12 +323,11 @@ void rtgui_dc_draw_text(struct rtgui_dc *dc, const char *text, struct rtgui_rect
|
||||
font = rtgui_font_default();
|
||||
}
|
||||
|
||||
/* text align */
|
||||
rtgui_font_get_metrics(font, text, &text_rect);
|
||||
rtgui_rect_moveto_align(rect, &text_rect, RTGUI_DC_TEXTALIGN(dc));
|
||||
|
||||
len = strlen((const char *)text);
|
||||
rtgui_font_draw(font, dc, text, len, &text_rect);
|
||||
if (len == 0)
|
||||
return;
|
||||
|
||||
rtgui_font_draw(font, dc, text, len, rect);
|
||||
}
|
||||
RTM_EXPORT(rtgui_dc_draw_text);
|
||||
|
||||
@@ -349,7 +347,7 @@ void rtgui_dc_draw_text_stroke(struct rtgui_dc *dc, const char *text, struct rtg
|
||||
for (y = -1; y < 2; y++)
|
||||
{
|
||||
r = *rect;
|
||||
rtgui_rect_moveto(&r, x, y);
|
||||
rtgui_rect_move(&r, x, y);
|
||||
rtgui_dc_draw_text(dc, text, &r);
|
||||
}
|
||||
}
|
||||
@@ -1781,7 +1779,7 @@ void rtgui_dc_rect_to_device(struct rtgui_dc *dc, struct rtgui_rect *rect)
|
||||
/* get owner */
|
||||
owner = RTGUI_CONTAINER_OF(dc, struct rtgui_widget, dc_type);
|
||||
|
||||
rtgui_rect_moveto(rect, owner->extent.x1, owner->extent.y1);
|
||||
rtgui_rect_move(rect, owner->extent.x1, owner->extent.y1);
|
||||
break;
|
||||
}
|
||||
case RTGUI_DC_HW:
|
||||
@@ -1791,7 +1789,7 @@ void rtgui_dc_rect_to_device(struct rtgui_dc *dc, struct rtgui_rect *rect)
|
||||
|
||||
dc_hw = (struct rtgui_dc_hw *) dc;
|
||||
owner = dc_hw->owner;
|
||||
rtgui_rect_moveto(rect, owner->extent.x1, owner->extent.y1);
|
||||
rtgui_rect_move(rect, owner->extent.x1, owner->extent.y1);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1920,7 +1918,7 @@ void rtgui_dc_end_drawing(struct rtgui_dc *dc, rt_bool_t update)
|
||||
RTGUI_OBJECT(win)->event_handler(RTGUI_OBJECT(win), (struct rtgui_event *)&ewin_update);
|
||||
}
|
||||
|
||||
if (rtgui_graphic_driver_is_vmode() == RT_FALSE && update)
|
||||
if (rtgui_graphic_driver_is_vmode() == RT_FALSE && win->update == 0 && update)
|
||||
{
|
||||
#ifdef RTGUI_USING_MOUSE_CURSOR
|
||||
rt_mutex_release(&cursor_mutex);
|
||||
|
||||
@@ -1651,7 +1651,7 @@ rtgui_dc_blend_fill_rect(struct rtgui_dc* dst, const rtgui_rect_t *rect,
|
||||
|
||||
/* convert logic to device */
|
||||
draw_rect = *rect;
|
||||
rtgui_rect_moveto(&draw_rect,owner->extent.x1, owner->extent.y1);
|
||||
rtgui_rect_move(&draw_rect,owner->extent.x1, owner->extent.y1);
|
||||
|
||||
/* calculate rect intersect */
|
||||
if (prect->y1 > draw_rect.y2 || prect->y2 <= draw_rect.y1) return ;
|
||||
@@ -1669,7 +1669,7 @@ rtgui_dc_blend_fill_rect(struct rtgui_dc* dst, const rtgui_rect_t *rect,
|
||||
prect = ((rtgui_rect_t *)(owner->clip.data + index + 1));
|
||||
|
||||
draw_rect = *rect;
|
||||
rtgui_rect_moveto(&draw_rect,owner->extent.x1, owner->extent.y1);
|
||||
rtgui_rect_move(&draw_rect,owner->extent.x1, owner->extent.y1);
|
||||
|
||||
/* calculate rect intersect */
|
||||
if (prect->y1 > draw_rect.y2 || prect->y2 <= draw_rect.y1) continue;
|
||||
@@ -1680,6 +1680,21 @@ rtgui_dc_blend_fill_rect(struct rtgui_dc* dst, const rtgui_rect_t *rect,
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (dst->type == RTGUI_DC_HW)
|
||||
{
|
||||
rtgui_rect_t draw_rect = *rect;
|
||||
struct rtgui_dc_hw *dc = (struct rtgui_dc_hw *) dst;
|
||||
|
||||
draw_rect.x2 = dc->owner->extent.x1 + draw_rect.x2 - draw_rect.x1;
|
||||
draw_rect.y2 = dc->owner->extent.y1 + draw_rect.y2 - draw_rect.y1;
|
||||
|
||||
draw_rect.x1 = dc->owner->extent.x1 > 0 ? dc->owner->extent.x1 : 0;
|
||||
draw_rect.y1 = dc->owner->extent.y1 > 0 ? dc->owner->extent.y1 : 0;
|
||||
draw_rect.x2 = draw_rect.x2 > hw_driver->width ? hw_driver->width : draw_rect.x2;
|
||||
draw_rect.y2 = draw_rect.y2 > hw_driver->height ? hw_driver->height : draw_rect.y2;
|
||||
|
||||
func(dst, &draw_rect, blendMode, r, g, b, a);
|
||||
}
|
||||
else
|
||||
{
|
||||
func(dst, rect, blendMode, r, g, b, a);
|
||||
@@ -1764,7 +1779,7 @@ rtgui_dc_blend_fill_rects(struct rtgui_dc * dst, const rtgui_rect_t *rects, int
|
||||
|
||||
/* convert logic to device */
|
||||
draw_rect = rect;
|
||||
rtgui_rect_moveto(&draw_rect,owner->extent.x1, owner->extent.y1);
|
||||
rtgui_rect_move(&draw_rect,owner->extent.x1, owner->extent.y1);
|
||||
|
||||
/* calculate rect intersect */
|
||||
if (prect->y1 > draw_rect.y2 || prect->y2 <= draw_rect.y1) return ;
|
||||
@@ -1782,7 +1797,7 @@ rtgui_dc_blend_fill_rects(struct rtgui_dc * dst, const rtgui_rect_t *rects, int
|
||||
prect = ((rtgui_rect_t *)(owner->clip.data + index + 1));
|
||||
|
||||
draw_rect = rect;
|
||||
rtgui_rect_moveto(&draw_rect,owner->extent.x1, owner->extent.y1);
|
||||
rtgui_rect_move(&draw_rect,owner->extent.x1, owner->extent.y1);
|
||||
|
||||
/* calculate rect intersect */
|
||||
if (prect->y1 > draw_rect.y2 || prect->y2 <= draw_rect.y1) continue;
|
||||
|
||||
@@ -88,6 +88,7 @@ struct rtgui_dc *rtgui_dc_buffer_create_pixformat(rt_uint8_t pixel_format, int w
|
||||
dc->gc.font = rtgui_font_default();
|
||||
dc->gc.textalign = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_TOP;
|
||||
dc->pixel_format = pixel_format;
|
||||
dc->pixel_alpha = 255;
|
||||
|
||||
dc->width = w;
|
||||
dc->height = h;
|
||||
@@ -127,6 +128,7 @@ struct rtgui_dc *rtgui_img_dc_create_pixformat(rt_uint8_t pixel_format,
|
||||
dc->gc.font = rtgui_font_default();
|
||||
dc->gc.textalign = RTGUI_ALIGN_LEFT | RTGUI_ALIGN_TOP;
|
||||
dc->pixel_format = pixel_format;
|
||||
dc->pixel_alpha = 255;
|
||||
|
||||
dc->width = image_item->image->w;
|
||||
dc->height = image_item->image->h;
|
||||
@@ -160,7 +162,8 @@ struct rtgui_dc *rtgui_dc_buffer_create_from_dc(struct rtgui_dc* dc)
|
||||
d->height);
|
||||
if (buffer != RT_NULL)
|
||||
{
|
||||
rt_memcpy(buffer->pixel, d->pixel, d->pitch * d->height);
|
||||
memcpy(buffer->pixel, d->pixel, d->pitch * d->height);
|
||||
d->pixel_alpha = 255;
|
||||
|
||||
return RTGUI_DC(buffer);
|
||||
}
|
||||
@@ -170,6 +173,15 @@ struct rtgui_dc *rtgui_dc_buffer_create_from_dc(struct rtgui_dc* dc)
|
||||
}
|
||||
RTM_EXPORT(rtgui_dc_buffer_create_from_dc);
|
||||
|
||||
void rtgui_dc_buffer_set_alpha(struct rtgui_dc* dc, rt_uint8_t pixel_alpha)
|
||||
{
|
||||
struct rtgui_dc_buffer *d = (struct rtgui_dc_buffer*) dc;
|
||||
if (d)
|
||||
{
|
||||
d->pixel_alpha = pixel_alpha;
|
||||
}
|
||||
}
|
||||
|
||||
rt_uint8_t *rtgui_dc_buffer_get_pixel(struct rtgui_dc *dc)
|
||||
{
|
||||
struct rtgui_dc_buffer *dc_buffer;
|
||||
@@ -465,10 +477,13 @@ static void rtgui_dc_buffer_blit(struct rtgui_dc *self,
|
||||
{
|
||||
/* use rtgui_blit */
|
||||
|
||||
struct rtgui_blit_info info;
|
||||
struct rtgui_blit_info info = { 0 };
|
||||
struct rtgui_widget *owner;
|
||||
|
||||
info.a = 255;
|
||||
if (self->type == RTGUI_DC_BUFFER)
|
||||
info.a = dc->pixel_alpha;
|
||||
else
|
||||
info.a = 255;
|
||||
|
||||
/* blit source */
|
||||
info.src = _dc_get_pixel(dc, dc_point.x, dc_point.y);
|
||||
@@ -496,7 +511,7 @@ static void rtgui_dc_buffer_blit(struct rtgui_dc *self,
|
||||
{
|
||||
/* use rtgui_blit */
|
||||
rt_uint8_t bpp, hw_bpp;
|
||||
struct rtgui_blit_info info;
|
||||
struct rtgui_blit_info info = { 0 };
|
||||
struct rtgui_widget *owner;
|
||||
struct rtgui_region dest_region;
|
||||
struct rtgui_rect dest_extent;
|
||||
@@ -518,7 +533,10 @@ static void rtgui_dc_buffer_blit(struct rtgui_dc *self,
|
||||
rects = rtgui_region_rects(&dest_region);
|
||||
|
||||
/* common info */
|
||||
info.a = 255;
|
||||
if (self->type == RTGUI_DC_BUFFER)
|
||||
info.a = dc->pixel_alpha;
|
||||
else
|
||||
info.a = 255;
|
||||
info.src_fmt = dc->pixel_format;
|
||||
info.src_pitch = dc->pitch;
|
||||
|
||||
@@ -564,7 +582,7 @@ static void rtgui_dc_buffer_blit(struct rtgui_dc *self,
|
||||
else RT_ASSERT(0);
|
||||
|
||||
/* change the logic coordinate to the device coordinate */
|
||||
rtgui_rect_moveto(dest_rect, owner->extent.x1, owner->extent.y1);
|
||||
rtgui_rect_move(dest_rect, owner->extent.x1, owner->extent.y1);
|
||||
|
||||
for (index = dest_rect->y1; index < dest_rect->y1 + rect_height; index ++)
|
||||
{
|
||||
@@ -602,9 +620,12 @@ static void rtgui_dc_buffer_blit(struct rtgui_dc *self,
|
||||
struct rtgui_dc_buffer *dest_dc = (struct rtgui_dc_buffer*)dest;
|
||||
|
||||
/* use rtgui_blit to handle buffer blit */
|
||||
struct rtgui_blit_info info;
|
||||
struct rtgui_blit_info info = { 0 };
|
||||
|
||||
info.a = 255;
|
||||
if (self->type == RTGUI_DC_BUFFER)
|
||||
info.a = dc->pixel_alpha;
|
||||
else
|
||||
info.a = 255;
|
||||
|
||||
/* blit source */
|
||||
info.src = _dc_get_pixel(dc, dc_point.x, dc_point.y);
|
||||
@@ -645,7 +666,7 @@ static void rtgui_dc_buffer_blit_line(struct rtgui_dc *self, int x1, int x2, int
|
||||
x2 = dc->width-1;
|
||||
|
||||
pixel = _dc_get_pixel(dc,x1,y);
|
||||
rt_memcpy(pixel, line_data, (x2 - x1) * rtgui_color_get_bpp(dc->pixel_format));
|
||||
memcpy(pixel, line_data, (x2 - x1) * rtgui_color_get_bpp(dc->pixel_format));
|
||||
}
|
||||
|
||||
#ifdef RT_USING_DFS
|
||||
|
||||
@@ -216,22 +216,32 @@ static void rtgui_dc_hw_fill_rect(struct rtgui_dc *self, struct rtgui_rect *rect
|
||||
return;
|
||||
if (x1 < dc->owner->extent.x1)
|
||||
x1 = dc->owner->extent.x1;
|
||||
if (x1 < 0)
|
||||
x1 = 0;
|
||||
|
||||
x2 = rect->x2 + dc->owner->extent.x1;
|
||||
if (x2 < dc->owner->extent.x1)
|
||||
return;
|
||||
if (x2 > dc->owner->extent.x2)
|
||||
x2 = dc->owner->extent.x2;
|
||||
if (x2 > dc->hw_driver->width)
|
||||
x2 = dc->hw_driver->width;
|
||||
|
||||
y1 = rect->y1 + dc->owner->extent.y1;
|
||||
if (y1 > dc->owner->extent.y2)
|
||||
return;
|
||||
if (y1 < dc->owner->extent.y1)
|
||||
y1 = dc->owner->extent.y1;
|
||||
if (y1 < 0)
|
||||
y1 = 0;
|
||||
|
||||
y2 = rect->y2 + dc->owner->extent.y1;
|
||||
if (y2 < dc->owner->extent.y1)
|
||||
return;
|
||||
if (y2 > dc->owner->extent.y2)
|
||||
y2 = dc->owner->extent.y2;
|
||||
if (y2 > dc->hw_driver->height)
|
||||
y2 = dc->hw_driver->height;
|
||||
|
||||
/* fill rect */
|
||||
for (; y1 < y2; y1++)
|
||||
|
||||
@@ -653,7 +653,7 @@ struct rtgui_dc* rtgui_dc_rotate_90degrees(struct rtgui_dc_buffer* src, int numC
|
||||
if (src->pitch == dst->pitch)
|
||||
{
|
||||
/* If the pitch is the same for both surfaces, the memory can be copied all at once. */
|
||||
rt_memcpy(dst->pixel, src->pixel, (src->height * src->pitch));
|
||||
memcpy(dst->pixel, src->pixel, (src->height * src->pitch));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -663,7 +663,7 @@ struct rtgui_dc* rtgui_dc_rotate_90degrees(struct rtgui_dc_buffer* src, int numC
|
||||
|
||||
for (row = 0; row < src->height; row++)
|
||||
{
|
||||
rt_memcpy(dstBuf, srcBuf, dst->width * bpp);
|
||||
memcpy(dstBuf, srcBuf, dst->width * bpp);
|
||||
srcBuf += src_ipr;
|
||||
dstBuf += dst_ipr;
|
||||
} /* end for(col) */
|
||||
|
||||
@@ -166,7 +166,7 @@ static int mem_read(struct rtgui_filerw *context, void *ptr, rt_size_t size, rt_
|
||||
if (total_bytes > mem_available)
|
||||
total_bytes = mem_available;
|
||||
|
||||
rt_memcpy(ptr, mem->mem_position, total_bytes);
|
||||
memcpy(ptr, mem->mem_position, total_bytes);
|
||||
mem->mem_position += total_bytes;
|
||||
|
||||
return (total_bytes / size);
|
||||
|
||||
@@ -95,6 +95,7 @@ static void rtgui_bitmap_font_draw_text(struct rtgui_font *font, struct rtgui_dc
|
||||
const char *text, rt_ubase_t len, struct rtgui_rect *rect)
|
||||
{
|
||||
rt_uint32_t length;
|
||||
struct rtgui_rect text_rect;
|
||||
struct rtgui_font_bitmap *bmp_font = (struct rtgui_font_bitmap *)(font->data);
|
||||
#ifdef RTGUI_USING_FONTHZ
|
||||
struct rtgui_font *hz_font;
|
||||
@@ -102,18 +103,21 @@ static void rtgui_bitmap_font_draw_text(struct rtgui_font *font, struct rtgui_dc
|
||||
|
||||
RT_ASSERT(bmp_font != RT_NULL);
|
||||
|
||||
rtgui_font_get_metrics(rtgui_dc_get_gc(dc)->font, text, &text_rect);
|
||||
rtgui_rect_move_to_align(rect, &text_rect, RTGUI_DC_TEXTALIGN(dc));
|
||||
|
||||
/* parameter check */
|
||||
if (rect->y1 > rect->y2) return;
|
||||
if (text_rect.y1 > text_rect.y2) return;
|
||||
|
||||
#ifdef RTGUI_USING_FONTHZ
|
||||
hz_font = rtgui_font_refer("hz", font->height);
|
||||
while ((rect->x1 < rect->x2) && len)
|
||||
while ((text_rect.x1 < text_rect.x2) && len)
|
||||
{
|
||||
length = 0;
|
||||
while ((rt_uint8_t) * (text + length) >= 0x80) length ++; /* it's not a ascii character */
|
||||
if (length > 0)
|
||||
{
|
||||
if (hz_font != RT_NULL) rtgui_font_draw(hz_font, dc, text, length, rect);
|
||||
if (hz_font != RT_NULL) rtgui_font_draw(hz_font, dc, text, length, &text_rect);
|
||||
text += length;
|
||||
len -= length;
|
||||
}
|
||||
@@ -123,15 +127,15 @@ static void rtgui_bitmap_font_draw_text(struct rtgui_font *font, struct rtgui_dc
|
||||
if (length > 0)
|
||||
{
|
||||
len -= length;
|
||||
while (length-- && rect->x1 < rect->x2)
|
||||
while (length-- && text_rect.x1 < text_rect.x2)
|
||||
{
|
||||
rtgui_bitmap_font_draw_char(bmp_font, dc, *text, rect);
|
||||
rtgui_bitmap_font_draw_char(bmp_font, dc, *text, &text_rect);
|
||||
|
||||
/* move x to next character */
|
||||
if (bmp_font->char_width == RT_NULL)
|
||||
rect->x1 += bmp_font->width;
|
||||
text_rect.x1 += bmp_font->width;
|
||||
else
|
||||
rect->x1 += bmp_font->char_width[*text - bmp_font->first_char];
|
||||
text_rect.x1 += bmp_font->char_width[*text - bmp_font->first_char];
|
||||
text ++;
|
||||
}
|
||||
}
|
||||
@@ -140,22 +144,22 @@ static void rtgui_bitmap_font_draw_text(struct rtgui_font *font, struct rtgui_dc
|
||||
if (hz_font != RT_NULL) rtgui_font_derefer(hz_font);
|
||||
|
||||
#else
|
||||
while ((rect->x1 < rect->x2) && len)
|
||||
while ((text_rect.x1 < text_rect.x2) && len)
|
||||
{
|
||||
length = 0;
|
||||
while (((rt_uint8_t) * (text + length) < 0x80) && *(text + length)) length ++;
|
||||
if (length > 0)
|
||||
{
|
||||
len -= length;
|
||||
while (length-- && rect->x1 < rect->x2)
|
||||
while (length-- && text_rect.x1 < text_rect.x2)
|
||||
{
|
||||
rtgui_bitmap_font_draw_char(bmp_font, dc, *text, rect);
|
||||
rtgui_bitmap_font_draw_char(bmp_font, dc, *text, &text_rect);
|
||||
|
||||
/* move x to next character */
|
||||
if (bmp_font->char_width == RT_NULL)
|
||||
rect->x1 += bmp_font->width;
|
||||
text_rect.x1 += bmp_font->width;
|
||||
else
|
||||
rect->x1 += bmp_font->char_width[*text - bmp_font->first_char];
|
||||
text_rect.x1 += bmp_font->char_width[*text - bmp_font->first_char];
|
||||
text ++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,10 +44,14 @@ void rtgui_fnt_font_draw_text(struct rtgui_font *font, struct rtgui_dc *dc, cons
|
||||
rt_uint32_t position;
|
||||
struct fnt_font *fnt;
|
||||
rt_uint8_t *data_ptr;
|
||||
struct rtgui_rect text_rect;
|
||||
|
||||
fnt = (struct fnt_font*)font->data;
|
||||
RT_ASSERT(fnt != RT_NULL);
|
||||
|
||||
rtgui_font_get_metrics(rtgui_dc_get_gc(dc)->font, text, &text_rect);
|
||||
rtgui_rect_move_to_align(rect, &text_rect, RTGUI_DC_TEXTALIGN(dc));
|
||||
|
||||
while (len)
|
||||
{
|
||||
/* get character */
|
||||
@@ -81,16 +85,16 @@ void rtgui_fnt_font_draw_text(struct rtgui_font *font, struct rtgui_dc *dc, cons
|
||||
for (c = 0; c < (fnt->header.height + 7)/8; c ++)
|
||||
{
|
||||
/* check drawable region */
|
||||
if ((rect->x1 + i > rect->x2) || (rect->y1 + c * 8 + j > rect->y2))
|
||||
if ((text_rect.x1 + i > text_rect.x2) || (text_rect.y1 + c * 8 + j > text_rect.y2))
|
||||
continue;
|
||||
|
||||
if (data_ptr[i + c * width] & (1 << j))
|
||||
rtgui_dc_draw_point(dc, rect->x1 + i, rect->y1 + c * 8 + j);
|
||||
rtgui_dc_draw_point(dc, text_rect.x1 + i, text_rect.y1 + c * 8 + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rect->x1 += width;
|
||||
text_rect.x1 += width;
|
||||
text += 1;
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -131,9 +131,13 @@ static void rtgui_hz_bitmap_font_draw_text(struct rtgui_font *font, struct rtgui
|
||||
rt_uint32_t len;
|
||||
struct rtgui_font *efont;
|
||||
struct rtgui_font_bitmap *bmp_font = (struct rtgui_font_bitmap *)(font->data);
|
||||
struct rtgui_rect text_rect;
|
||||
|
||||
RT_ASSERT(dc != RT_NULL);
|
||||
|
||||
rtgui_font_get_metrics(rtgui_dc_get_gc(dc)->font, text, &text_rect);
|
||||
rtgui_rect_move_to_align(rect, &text_rect, RTGUI_DC_TEXTALIGN(dc));
|
||||
|
||||
/* get English font */
|
||||
efont = rtgui_font_refer("asc", bmp_font->height);
|
||||
if (efont == RT_NULL) efont = rtgui_font_default(); /* use system default font */
|
||||
@@ -145,7 +149,7 @@ static void rtgui_hz_bitmap_font_draw_text(struct rtgui_font *font, struct rtgui
|
||||
/* draw text with English font */
|
||||
if (len > 0)
|
||||
{
|
||||
rtgui_font_draw(efont, dc, text, len, rect);
|
||||
rtgui_font_draw(efont, dc, text, len, &text_rect);
|
||||
|
||||
text += len;
|
||||
length -= len;
|
||||
@@ -155,7 +159,7 @@ static void rtgui_hz_bitmap_font_draw_text(struct rtgui_font *font, struct rtgui
|
||||
while (((rt_uint8_t) * (text + len)) >= 0x80 && len < length) len ++;
|
||||
if (len > 0)
|
||||
{
|
||||
_rtgui_hz_bitmap_font_draw_text(bmp_font, dc, text, len, rect);
|
||||
_rtgui_hz_bitmap_font_draw_text(bmp_font, dc, text, len, &text_rect);
|
||||
|
||||
text += len;
|
||||
length -= len;
|
||||
|
||||
@@ -206,10 +206,14 @@ static void rtgui_hz_file_font_draw_text(struct rtgui_font *font, struct rtgui_d
|
||||
rt_uint32_t len;
|
||||
struct rtgui_font *efont;
|
||||
struct rtgui_hz_file_font *hz_file_font = (struct rtgui_hz_file_font *)font->data;
|
||||
struct rtgui_rect text_rect;
|
||||
|
||||
RT_ASSERT(dc != RT_NULL);
|
||||
RT_ASSERT(hz_file_font != RT_NULL);
|
||||
|
||||
rtgui_font_get_metrics(rtgui_dc_get_gc(dc)->font, text, &text_rect);
|
||||
rtgui_rect_move_to_align(rect, &text_rect, RTGUI_DC_TEXTALIGN(dc));
|
||||
|
||||
/* get English font */
|
||||
efont = rtgui_font_refer("asc", hz_file_font->font_size);
|
||||
if (efont == RT_NULL) efont = rtgui_font_default(); /* use system default font */
|
||||
@@ -221,7 +225,7 @@ static void rtgui_hz_file_font_draw_text(struct rtgui_font *font, struct rtgui_d
|
||||
/* draw text with English font */
|
||||
if (len > 0)
|
||||
{
|
||||
rtgui_font_draw(efont, dc, text, len, rect);
|
||||
rtgui_font_draw(efont, dc, text, len, &text_rect);
|
||||
|
||||
text += len;
|
||||
length -= len;
|
||||
@@ -231,7 +235,7 @@ static void rtgui_hz_file_font_draw_text(struct rtgui_font *font, struct rtgui_d
|
||||
while (((rt_uint8_t) * (text + len)) >= 0x80 && len < length) len ++;
|
||||
if (len > 0)
|
||||
{
|
||||
_rtgui_hz_file_font_draw_text(hz_file_font, dc, text, len, rect);
|
||||
_rtgui_hz_file_font_draw_text(hz_file_font, dc, text, len, &text_rect);
|
||||
|
||||
text += len;
|
||||
length -= len;
|
||||
|
||||
@@ -423,14 +423,14 @@ static rt_bool_t rtgui_image_bmp_load(struct rtgui_image *image, struct rtgui_fi
|
||||
{
|
||||
if (bmp->scale == 0)
|
||||
{
|
||||
rt_memcpy((void *)dst, (void *)wrkBuffer, readLength);
|
||||
memcpy((void *)dst, (void *)wrkBuffer, readLength);
|
||||
dst += readLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (loadIndex = skipLength; loadIndex < readLength; loadIndex += bytePerPixel << bmp->scale)
|
||||
{
|
||||
rt_memcpy((void *)dst, (void *)&wrkBuffer[loadIndex], bytePerPixel);
|
||||
memcpy((void *)dst, (void *)&wrkBuffer[loadIndex], bytePerPixel);
|
||||
dst += bytePerPixel;
|
||||
}
|
||||
if (readLength % (1 << bmp->scale))
|
||||
|
||||
@@ -393,13 +393,18 @@ rtgui_image_item_t *rtgui_image_container_get(const char *filename)
|
||||
if (item == RT_NULL)
|
||||
{
|
||||
item = (struct rtgui_image_item *) rtgui_malloc(sizeof(struct rtgui_image_item));
|
||||
if (item == RT_NULL) return RT_NULL;
|
||||
if (item == RT_NULL)
|
||||
{
|
||||
rt_mutex_release(&_image_hash_lock);
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
/* create a image object */
|
||||
item->image = rtgui_image_create(filename, RT_TRUE);
|
||||
if (item->image == RT_NULL)
|
||||
{
|
||||
rtgui_free(item);
|
||||
rt_mutex_release(&_image_hash_lock);
|
||||
return RT_NULL; /* create image failed */
|
||||
}
|
||||
item->refcount = 1;
|
||||
|
||||
@@ -30,7 +30,9 @@
|
||||
|
||||
#define HDC_MAGIC_LEN 4
|
||||
|
||||
#ifdef PKG_USING_FASTLZ
|
||||
extern int fastlz_decompress(const void *input, int length, void *output, int maxout);
|
||||
#endif
|
||||
|
||||
static rt_bool_t rtgui_image_hdc_check(struct rtgui_filerw *file);
|
||||
static rt_bool_t rtgui_image_hdc_load(struct rtgui_image *image, struct rtgui_filerw *file, rt_bool_t load);
|
||||
|
||||
@@ -427,7 +427,7 @@ static void rtgui_image_jpeg_blit(struct rtgui_image *image, struct rtgui_dc *dc
|
||||
/* blit ARGB888 to this buffered DC */
|
||||
int dst_x, dst_y;
|
||||
int w, h;
|
||||
struct rtgui_blit_info info;
|
||||
struct rtgui_blit_info info = { 0 };
|
||||
struct rtgui_dc_buffer *buffer = (struct rtgui_dc_buffer*)dc;
|
||||
|
||||
w = _UI_MIN(image->w, rtgui_rect_width(*rect));
|
||||
@@ -704,7 +704,7 @@ static UINT tjpgd_out_func(JDEC *jdec, void *bitmap, JRECT *rect)
|
||||
/* Left-top of destination rectangular */
|
||||
for (h = rect->top; h <= rect->bottom; h++)
|
||||
{
|
||||
rt_memcpy(dst, src, rectWidth);
|
||||
memcpy(dst, src, rectWidth);
|
||||
src += rectWidth;
|
||||
dst += imageWidth; /* Next line */
|
||||
}
|
||||
@@ -945,7 +945,7 @@ static void rtgui_image_jpeg_blit(struct rtgui_image *image,
|
||||
/* if the format is not match, only support DC buffer */
|
||||
else if (dc->type == RTGUI_DC_BUFFER)
|
||||
{
|
||||
struct rtgui_blit_info info;
|
||||
struct rtgui_blit_info info = { 0 };
|
||||
struct rtgui_dc_buffer *buffer;
|
||||
|
||||
buffer = (struct rtgui_dc_buffer*)dc;
|
||||
|
||||
@@ -550,7 +550,7 @@ static void rtgui_image_png_blit(struct rtgui_image *image, struct rtgui_dc *dc,
|
||||
{
|
||||
int x, y;
|
||||
int w, h;
|
||||
struct rtgui_blit_info info;
|
||||
struct rtgui_blit_info info = {0};
|
||||
struct rtgui_graphic_driver *hw_driver = rtgui_graphic_driver_get_default();
|
||||
|
||||
RT_ASSERT(image != RT_NULL && dc != RT_NULL && rect != RT_NULL);
|
||||
@@ -653,10 +653,10 @@ static void rtgui_image_png_blit(struct rtgui_image *image, struct rtgui_dc *dc,
|
||||
{
|
||||
int dst_x, dst_y;
|
||||
|
||||
info.a = 0;
|
||||
info.a = 255;
|
||||
|
||||
/* initialize source blit information */
|
||||
info.src_fmt = RTGRAPHIC_PIXEL_FORMAT_ARGB888;;
|
||||
info.src_fmt = RTGRAPHIC_PIXEL_FORMAT_ARGB888;
|
||||
info.src_h = h;
|
||||
info.src_w = w;
|
||||
info.src_pitch = image->w * rtgui_color_get_bpp(RTGRAPHIC_PIXEL_FORMAT_ARGB888);
|
||||
@@ -674,6 +674,9 @@ static void rtgui_image_png_blit(struct rtgui_image *image, struct rtgui_dc *dc,
|
||||
struct rtgui_dc_buffer *buffer;
|
||||
buffer = (struct rtgui_dc_buffer*)dc;
|
||||
|
||||
if (buffer->pixel_alpha == 0)
|
||||
info.a = 0;
|
||||
|
||||
info.dst = rtgui_dc_buffer_get_pixel(RTGUI_DC(buffer)) + dst_y * buffer->pitch +
|
||||
dst_x * rtgui_color_get_bpp(buffer->pixel_format);
|
||||
info.dst_h = h;
|
||||
|
||||
@@ -235,7 +235,7 @@ void rtgui_mouse_moveto(int x, int y)
|
||||
#endif
|
||||
|
||||
/* move winrect */
|
||||
rtgui_rect_moveto(&(_rtgui_cursor->win_rect), x - _rtgui_cursor->cx,
|
||||
rtgui_rect_move(&(_rtgui_cursor->win_rect), x - _rtgui_cursor->cx,
|
||||
y - _rtgui_cursor->cy);
|
||||
rtgui_winrect_save();
|
||||
|
||||
@@ -360,7 +360,7 @@ static void rtgui_cursor_restore()
|
||||
|
||||
for (idx = 0; idx < height; idx ++)
|
||||
{
|
||||
rt_memcpy(fb_ptr, cursor_ptr, cursor_pitch);
|
||||
memcpy(fb_ptr, cursor_ptr, cursor_pitch);
|
||||
|
||||
fb_ptr += _rtgui_cursor->screen_pitch;
|
||||
cursor_ptr += _rtgui_cursor->cursor_pitch;
|
||||
@@ -387,7 +387,7 @@ static void rtgui_cursor_save()
|
||||
|
||||
for (idx = 0; idx < height; idx ++)
|
||||
{
|
||||
rt_memcpy(cursor_ptr, fb_ptr, cursor_pitch);
|
||||
memcpy(cursor_ptr, fb_ptr, cursor_pitch);
|
||||
|
||||
fb_ptr += _rtgui_cursor->screen_pitch;
|
||||
cursor_ptr += _rtgui_cursor->cursor_pitch;
|
||||
@@ -407,7 +407,7 @@ static void rtgui_cursor_show()
|
||||
set_pixel = rtgui_graphic_driver_get_default()->ops->set_pixel;
|
||||
|
||||
rtgui_mouse_get_cursor_rect(&rect);
|
||||
rtgui_rect_moveto(&rect, _rtgui_cursor->cx, _rtgui_cursor->cy);
|
||||
rtgui_rect_move(&rect, _rtgui_cursor->cx, _rtgui_cursor->cy);
|
||||
|
||||
/* draw each point */
|
||||
for (y = rect.y1; y < rect.y2; y ++)
|
||||
@@ -530,7 +530,7 @@ static void rtgui_winrect_show()
|
||||
#define display_direct_memcpy(src, dest, src_pitch, dest_pitch, height, len) \
|
||||
for (idx = 0; idx < height; idx ++) \
|
||||
{ \
|
||||
rt_memcpy(dest, src, len); \
|
||||
memcpy(dest, src, len); \
|
||||
src += src_pitch; \
|
||||
dest += dest_pitch; \
|
||||
}
|
||||
|
||||
+17
-19
@@ -2077,7 +2077,7 @@ void rtgui_region_draw_clip(rtgui_region_t *region, struct rtgui_dc *dc)
|
||||
|
||||
rect = rects[i];
|
||||
|
||||
rtgui_rect_moveto(&rect, -x, -y);
|
||||
rtgui_rect_move(&rect, -x, -y);
|
||||
rtgui_dc_draw_rect(dc, &rect);
|
||||
|
||||
rt_snprintf(text, sizeof(text) - 1, "%d", i);
|
||||
@@ -2100,7 +2100,7 @@ int rtgui_region_is_flat(rtgui_region_t *region)
|
||||
}
|
||||
RTM_EXPORT(rtgui_region_is_flat);
|
||||
|
||||
void rtgui_rect_moveto(rtgui_rect_t *rect, int x, int y)
|
||||
void rtgui_rect_move(rtgui_rect_t *rect, int x, int y)
|
||||
{
|
||||
rect->x1 += x;
|
||||
rect->x2 += x;
|
||||
@@ -2108,9 +2108,9 @@ void rtgui_rect_moveto(rtgui_rect_t *rect, int x, int y)
|
||||
rect->y1 += y;
|
||||
rect->y2 += y;
|
||||
}
|
||||
RTM_EXPORT(rtgui_rect_moveto);
|
||||
RTM_EXPORT(rtgui_rect_move);
|
||||
|
||||
void rtgui_rect_moveto_point(rtgui_rect_t *rect, int x, int y)
|
||||
void rtgui_rect_move_to_point(rtgui_rect_t *rect, int x, int y)
|
||||
{
|
||||
int mx, my;
|
||||
|
||||
@@ -2123,9 +2123,9 @@ void rtgui_rect_moveto_point(rtgui_rect_t *rect, int x, int y)
|
||||
rect->y1 += my;
|
||||
rect->y2 += my;
|
||||
}
|
||||
RTM_EXPORT(rtgui_rect_moveto_point);
|
||||
RTM_EXPORT(rtgui_rect_move_to_point);
|
||||
|
||||
void rtgui_rect_moveto_align(const rtgui_rect_t *rect, rtgui_rect_t *to, int align)
|
||||
void rtgui_rect_move_to_align(const rtgui_rect_t *rect, rtgui_rect_t *to, int align)
|
||||
{
|
||||
int dw, dh;
|
||||
dw = 0;
|
||||
@@ -2138,11 +2138,11 @@ void rtgui_rect_moveto_align(const rtgui_rect_t *rect, rtgui_rect_t *to, int ali
|
||||
if (dh < 0) dh = 0;
|
||||
|
||||
/* move to insider of rect */
|
||||
rtgui_rect_moveto(to, rect->x1, rect->y1);
|
||||
rtgui_rect_move_to_point(to, rect->x1, rect->y1);
|
||||
|
||||
/* limited the destination rect to source rect */
|
||||
// if (dw == 0) to->x2 = rect->x2;
|
||||
// if (dh == 0) to->y2 = rect->y2;
|
||||
if (dw == 0) to->x2 = rect->x2;
|
||||
if (dh == 0) to->y2 = rect->y2;
|
||||
|
||||
/* align to right */
|
||||
if (align & RTGUI_ALIGN_RIGHT)
|
||||
@@ -2150,6 +2150,12 @@ void rtgui_rect_moveto_align(const rtgui_rect_t *rect, rtgui_rect_t *to, int ali
|
||||
to->x1 += dw;
|
||||
to->x2 += dw;
|
||||
}
|
||||
/* align to center horizontal */
|
||||
else if (align & RTGUI_ALIGN_CENTER_HORIZONTAL)
|
||||
{
|
||||
to->x1 += dw >> 1;
|
||||
to->x2 += dw >> 1;
|
||||
}
|
||||
|
||||
/* align to bottom */
|
||||
if (align & RTGUI_ALIGN_BOTTOM)
|
||||
@@ -2157,22 +2163,14 @@ void rtgui_rect_moveto_align(const rtgui_rect_t *rect, rtgui_rect_t *to, int ali
|
||||
to->y1 += dh;
|
||||
to->y2 += dh;
|
||||
}
|
||||
|
||||
/* align to center horizontal */
|
||||
if (align & RTGUI_ALIGN_CENTER_HORIZONTAL)
|
||||
{
|
||||
to->x1 += dw >> 1;
|
||||
to->x2 += dw >> 1;
|
||||
}
|
||||
|
||||
/* align to center vertical */
|
||||
if (align & RTGUI_ALIGN_CENTER_VERTICAL)
|
||||
else if (align & RTGUI_ALIGN_CENTER_VERTICAL)
|
||||
{
|
||||
to->y1 += dh >> 1;
|
||||
to->y2 += dh >> 1;
|
||||
}
|
||||
}
|
||||
RTM_EXPORT(rtgui_rect_moveto_align);
|
||||
RTM_EXPORT(rtgui_rect_move_to_align);
|
||||
|
||||
void rtgui_rect_inflate(rtgui_rect_t *rect, int d)
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <rtgui/rtgui_system.h>
|
||||
#include <rtgui/rtgui_app.h>
|
||||
#include <rtgui/widgets/window.h>
|
||||
#include <topwin.h>
|
||||
|
||||
static void _rtgui_app_constructor(struct rtgui_app *app)
|
||||
{
|
||||
@@ -82,7 +83,7 @@ struct rtgui_app *rtgui_app_create(const char *title)
|
||||
|
||||
rt_snprintf(mq_name, RT_NAME_MAX, "g%s", title);
|
||||
app->mq = rt_mq_create(mq_name,
|
||||
sizeof(union rtgui_event_generic), 64,
|
||||
sizeof(union rtgui_event_generic), 256,
|
||||
RT_IPC_FLAG_FIFO);
|
||||
if (app->mq == RT_NULL)
|
||||
{
|
||||
@@ -185,7 +186,6 @@ RTM_EXPORT(rtgui_app_set_onidle);
|
||||
|
||||
rtgui_idle_func_t rtgui_app_get_onidle(struct rtgui_app *app)
|
||||
{
|
||||
|
||||
_rtgui_application_check(app);
|
||||
return app->on_idle;
|
||||
}
|
||||
@@ -200,6 +200,11 @@ rt_inline rt_bool_t _rtgui_application_dest_handle(
|
||||
|
||||
if (wevent->wid == RT_NULL)
|
||||
return RT_FALSE;
|
||||
|
||||
if (wevent->wid->magic != 0xA5A55A5A)
|
||||
{
|
||||
return RT_FALSE;
|
||||
}
|
||||
|
||||
/* this window has been closed. */
|
||||
if (wevent->wid != RT_NULL && wevent->wid->flag & RTGUI_WIN_FLAG_CLOSED)
|
||||
@@ -276,11 +281,14 @@ rt_bool_t rtgui_app_event_handler(struct rtgui_object *object, rtgui_event_t *ev
|
||||
|
||||
case RTGUI_EVENT_TIMER:
|
||||
{
|
||||
rt_base_t level;
|
||||
struct rtgui_timer *timer;
|
||||
struct rtgui_event_timer *etimer = (struct rtgui_event_timer *) event;
|
||||
|
||||
timer = etimer->timer;
|
||||
level = rt_hw_interrupt_disable();
|
||||
timer->pending_cnt--;
|
||||
rt_hw_interrupt_enable(level);
|
||||
RT_ASSERT(timer->pending_cnt >= 0);
|
||||
if (timer->state == RTGUI_TIMER_ST_DESTROY_PENDING)
|
||||
{
|
||||
@@ -309,6 +317,21 @@ rt_bool_t rtgui_app_event_handler(struct rtgui_object *object, rtgui_event_t *ev
|
||||
|
||||
if (ecmd->wid != RT_NULL)
|
||||
return _rtgui_application_dest_handle(app, event);
|
||||
else
|
||||
{
|
||||
struct rtgui_topwin *wnd;
|
||||
|
||||
wnd = rtgui_topwin_get_focus();
|
||||
if (wnd != RT_NULL)
|
||||
{
|
||||
RT_ASSERT(wnd->flag & WINTITLE_ACTIVATE)
|
||||
|
||||
/* send to focus window */
|
||||
ecmd->wid = wnd->wid;
|
||||
|
||||
return _rtgui_application_dest_handle(app, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
return rtgui_object_event_handler(object, event);
|
||||
|
||||
@@ -124,7 +124,7 @@ rtgui_graphic_driver_get_rect_buffer(const struct rtgui_graphic_driver *driver,
|
||||
|
||||
while (h--)
|
||||
{
|
||||
rt_memcpy(dst, pixel, buffer->pitch);
|
||||
memcpy(dst, pixel, buffer->pitch);
|
||||
|
||||
dst += buffer->pitch;
|
||||
pixel += driver->pitch;
|
||||
@@ -419,7 +419,7 @@ static void framebuffer_draw_raw_hline(rt_uint8_t *pixels, int x1, int x2, int y
|
||||
|
||||
drv = rtgui_graphic_get_device();
|
||||
dst = GET_PIXEL(drv, x1, y, rt_uint8_t);
|
||||
rt_memcpy(dst, pixels,
|
||||
memcpy(dst, pixels,
|
||||
(x2 - x1) * _UI_BITBYTES(drv->bits_per_pixel));
|
||||
}
|
||||
|
||||
|
||||
@@ -351,7 +351,7 @@ void *rtgui_realloc(void *ptr, rt_size_t size)
|
||||
new_ptr = rtgui_malloc(size);
|
||||
if ((new_ptr != RT_NULL) && (ptr != RT_NULL))
|
||||
{
|
||||
rt_memcpy(new_ptr, ptr, size);
|
||||
memcpy(new_ptr, ptr, size);
|
||||
rtgui_free(ptr);
|
||||
}
|
||||
#else
|
||||
@@ -417,6 +417,7 @@ const char *rtgui_event_string[] =
|
||||
"WIN_CLOSE", /* close a window */
|
||||
"WIN_MOVE", /* move a window */
|
||||
"WIN_RESIZE", /* resize a window */
|
||||
"WIN_UPDATE_END",
|
||||
"WIN_MODAL_ENTER", /* a window modals */
|
||||
|
||||
"SET_WM", /* set window manager */
|
||||
@@ -546,6 +547,8 @@ static void rtgui_event_dump(struct rtgui_app* app, rtgui_event_t *event)
|
||||
break;
|
||||
|
||||
case RTGUI_EVENT_WIN_ACTIVATE:
|
||||
case RTGUI_EVENT_WIN_DESTROY:
|
||||
case RTGUI_EVENT_WIN_CLOSE:
|
||||
case RTGUI_EVENT_WIN_DEACTIVATE:
|
||||
case RTGUI_EVENT_WIN_SHOW:
|
||||
case RTGUI_EVENT_WIN_HIDE:
|
||||
@@ -755,7 +758,7 @@ rt_err_t rtgui_recv_filter(rt_uint32_t type, rtgui_event_t *event, rt_size_t eve
|
||||
{
|
||||
if (e->type == type)
|
||||
{
|
||||
rt_memcpy(event, e, event_size);
|
||||
memcpy(event, e, event_size);
|
||||
return RT_EOK;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -764,7 +764,7 @@ rt_err_t rtgui_topwin_move(struct rtgui_event_win_move *event)
|
||||
|
||||
old_rect = topwin->extent;
|
||||
/* move window rect */
|
||||
rtgui_rect_moveto(&(topwin->extent), dx, dy);
|
||||
rtgui_rect_move(&(topwin->extent), dx, dy);
|
||||
|
||||
/* move the monitor rect list */
|
||||
rtgui_list_foreach(node, &(topwin->monitor_list))
|
||||
@@ -772,7 +772,7 @@ rt_err_t rtgui_topwin_move(struct rtgui_event_win_move *event)
|
||||
struct rtgui_mouse_monitor *monitor = rtgui_list_entry(node,
|
||||
struct rtgui_mouse_monitor,
|
||||
list);
|
||||
rtgui_rect_moveto(&(monitor->rect), dx, dy);
|
||||
rtgui_rect_move(&(monitor->rect), dx, dy);
|
||||
}
|
||||
|
||||
/* update windows clip info */
|
||||
@@ -790,6 +790,7 @@ rt_err_t rtgui_topwin_move(struct rtgui_event_win_move *event)
|
||||
struct rtgui_event_paint epaint;
|
||||
RTGUI_EVENT_PAINT_INIT(&epaint);
|
||||
epaint.wid = topwin->wid;
|
||||
|
||||
rtgui_send(topwin->app, &(epaint.parent), sizeof(epaint));
|
||||
}
|
||||
|
||||
|
||||
@@ -218,12 +218,12 @@ void rtgui_widget_set_minheight(rtgui_widget_t *widget, int height)
|
||||
}
|
||||
RTM_EXPORT(rtgui_widget_set_minheight);
|
||||
|
||||
static void _widget_moveto(struct rtgui_widget* widget, int dx, int dy)
|
||||
static void _widget_move(struct rtgui_widget* widget, int dx, int dy)
|
||||
{
|
||||
struct rtgui_list_node *node;
|
||||
rtgui_widget_t *child, *parent;
|
||||
|
||||
rtgui_rect_moveto(&(widget->extent), dx, dy);
|
||||
rtgui_rect_move(&(widget->extent), dx, dy);
|
||||
|
||||
/* handle visiable extent */
|
||||
widget->extent_visiable = widget->extent;
|
||||
@@ -243,7 +243,7 @@ static void _widget_moveto(struct rtgui_widget* widget, int dx, int dy)
|
||||
{
|
||||
child = rtgui_list_entry(node, rtgui_widget_t, sibling);
|
||||
|
||||
_widget_moveto(child, dx, dy);
|
||||
_widget_move(child, dx, dy);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -280,7 +280,7 @@ void rtgui_widget_move_to_logic(rtgui_widget_t *widget, int dx, int dy)
|
||||
}
|
||||
|
||||
/* move this widget (and its children if it's a container) to destination point */
|
||||
_widget_moveto(widget, dx, dy);
|
||||
_widget_move(widget, dx, dy);
|
||||
/* update this widget */
|
||||
rtgui_widget_update_clip(widget);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <rtgui/rtgui_app.h>
|
||||
|
||||
#include <rtgui/widgets/window.h>
|
||||
//#include <rtgui/widgets/button.h>
|
||||
#include <rtgui/widgets/title.h>
|
||||
|
||||
static rt_bool_t _rtgui_win_deal_close(struct rtgui_win *win,
|
||||
@@ -42,6 +41,7 @@ static void _rtgui_win_constructor(rtgui_win_t *win)
|
||||
RTGUI_WIDGET(win)->toplevel = win;
|
||||
|
||||
/* init win property */
|
||||
win->update = 0;
|
||||
win->drawing = 0;
|
||||
|
||||
RTGUI_WIDGET(win)->flag |= RTGUI_WIDGET_FLAG_FOCUSABLE;
|
||||
@@ -208,6 +208,8 @@ RTM_EXPORT(rtgui_win_init);
|
||||
|
||||
int rtgui_win_fini(struct rtgui_win* win)
|
||||
{
|
||||
win->magic = 0;
|
||||
|
||||
/* close the window first if it's not. */
|
||||
if (!(win->flag & RTGUI_WIN_FLAG_CLOSED))
|
||||
{
|
||||
@@ -372,6 +374,7 @@ rt_base_t rtgui_win_enter_modal(struct rtgui_win *win)
|
||||
return exit_code;
|
||||
|
||||
win->flag |= RTGUI_WIN_FLAG_MODAL;
|
||||
win->app_ref_count = win->app->ref_count + 1;
|
||||
exit_code = rtgui_app_run(win->app);
|
||||
win->flag &= ~RTGUI_WIN_FLAG_MODAL;
|
||||
|
||||
@@ -437,6 +440,8 @@ rt_base_t rtgui_win_show(struct rtgui_win *win, rt_bool_t is_modal)
|
||||
{
|
||||
RTGUI_WIDGET_UNHIDE(win);
|
||||
|
||||
win->magic = 0xA5A55A5A;
|
||||
|
||||
if (is_modal)
|
||||
win->flag |= RTGUI_WIN_FLAG_MODAL;
|
||||
if (win->_do_show)
|
||||
@@ -447,9 +452,22 @@ RTM_EXPORT(rtgui_win_show);
|
||||
|
||||
void rtgui_win_end_modal(struct rtgui_win *win, rtgui_modal_code_t modal_code)
|
||||
{
|
||||
int i = 0;
|
||||
if (win == RT_NULL || !(win->flag & RTGUI_WIN_FLAG_MODAL))
|
||||
return;
|
||||
|
||||
while (win->app_ref_count < win->app->ref_count)
|
||||
{
|
||||
rtgui_app_exit(win->app, 0);
|
||||
|
||||
i ++;
|
||||
if (i >= 1000)
|
||||
{
|
||||
rt_kprintf(" =*=> rtgui_win_end_modal while (win->app_ref_count < win->app->ref_count) \n");
|
||||
RT_ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
rtgui_app_exit(win->app, modal_code);
|
||||
|
||||
/* remove modal mode */
|
||||
@@ -530,7 +548,7 @@ void rtgui_win_move(struct rtgui_win *win, int x, int y)
|
||||
dy = y - wgt->extent.y1;
|
||||
rtgui_widget_move_to_logic(wgt, dx, dy);
|
||||
}
|
||||
rtgui_rect_moveto(&win->outer_extent, dx, dy);
|
||||
rtgui_rect_move(&win->outer_extent, dx, dy);
|
||||
|
||||
if (win->flag & RTGUI_WIN_FLAG_CONNECTED)
|
||||
{
|
||||
@@ -572,6 +590,7 @@ static rt_bool_t rtgui_win_ondraw(struct rtgui_win *win)
|
||||
/* paint each widget */
|
||||
RTGUI_EVENT_PAINT_INIT(&event);
|
||||
event.wid = RT_NULL;
|
||||
|
||||
rtgui_container_dispatch_event(RTGUI_CONTAINER(win),
|
||||
(rtgui_event_t *)&event);
|
||||
|
||||
@@ -1095,7 +1114,7 @@ void rtgui_theme_draw_win(struct rtgui_wintitle *wint)
|
||||
{
|
||||
/* get close button rect */
|
||||
rtgui_rect_t box_rect = {0, 0, WINTITLE_CB_WIDTH, WINTITLE_CB_HEIGHT};
|
||||
rtgui_rect_moveto_align(&rect, &box_rect, RTGUI_ALIGN_CENTER_VERTICAL | RTGUI_ALIGN_RIGHT);
|
||||
rtgui_rect_move_to_align(&rect, &box_rect, RTGUI_ALIGN_CENTER_VERTICAL | RTGUI_ALIGN_RIGHT);
|
||||
box_rect.x1 -= 3;
|
||||
box_rect.x2 -= 3;
|
||||
rtgui_dc_fill_rect(dc, &box_rect);
|
||||
|
||||
Reference in New Issue
Block a user