Ver código fonte

move the onbutton call back to the end of event handler in button widget.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@337 bbd45198-f89e-11dd-88c7-29a3b14d5316
bernard.xiong 15 anos atrás
pai
commit
0c817b1d16

+ 2 - 3
rtgui/common/rtgui_theme.c

@@ -282,10 +282,9 @@ void rtgui_theme_draw_win(struct rtgui_topwin* win)
 		{
 			RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(win->title)) = RTGUI_RGB(212, 208, 200);
 		}
-		// rtgui_dc_fill_rect(dc, &rect);
 
 		rect.x1 += 4;
-		rect.y1 += 2;
+		rect.y1 += 2; rect.y2 = rect.y1 + WINTITLE_CB_HEIGHT;
 		rtgui_dc_draw_text(dc, rtgui_wintitle_get_title(win->title), &rect);
 
 		if (win->flag & WINTITLE_CLOSEBOX)
@@ -321,7 +320,7 @@ void rtgui_theme_draw_button(rtgui_button_t* btn)
 	/* get widget rect */
 	rtgui_widget_get_rect(RTGUI_WIDGET(btn), &rect);
 
-	/* get forecolor */
+	/* get foreground color */
 	fc = RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(btn));
 
 	/* fill button rect with background color */

+ 1 - 1
rtgui/include/rtgui/rtgui_config.h

@@ -18,7 +18,7 @@
 /* RTGUI options */
 
 /* name length of RTGUI object */
-#define RTGUI_NAME_MAX		32
+#define RTGUI_NAME_MAX		16
 
 /* #define RTGUI_USING_MOUSE_CURSOR */
 

+ 6 - 6
rtgui/widgets/button.c

@@ -165,18 +165,18 @@ rt_bool_t rtgui_button_event_handler(struct rtgui_widget* widget, struct rtgui_e
 #endif
 						rtgui_theme_draw_button(btn);
 
-					if (!(btn->flag & RTGUI_BUTTON_FLAG_PRESS) && (btn->on_button != RT_NULL))
-					{
-						/* call on button handler */
-						btn->on_button(widget, event);
-					}
-
 #ifndef RTGUI_USING_SMALL_SIZE
 					/* invokes call back */
 					if (widget->on_mouseclick != RT_NULL &&
 						emouse->button & RTGUI_MOUSE_BUTTON_UP)
 						return widget->on_mouseclick(widget, event);
 #endif
+
+					if (!(btn->flag & RTGUI_BUTTON_FLAG_PRESS) && (btn->on_button != RT_NULL))
+					{
+						/* call on button handler */
+						btn->on_button(widget, event);
+					}
 				}
 
 			}