mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-21 02:06:14 +08:00
merge new RTGUI in to trunk
The full log is at https://github.com/RTGUI/RTGUI/commits/merge_1 and it's difficult to merge the new tree commit by commit. I also converted all the file into unix eol so there are many fake diff. Big changes are noted in rtgui/doc/road_map.txt and rtgui/doc/attention.txt. Keep an eye on them if you want to migrate your old code. Note that the work is still in progress and the bsp is not prepared in trunk so far. git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2092 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
@@ -432,7 +432,7 @@ static void rtgui_winrect_show()
|
||||
rt_uint16_t x, y;
|
||||
rtgui_color_t c;
|
||||
rtgui_rect_t screen_rect, win_rect, win_rect_inner;
|
||||
void (*set_pixel) (rtgui_color_t *c, rt_base_t x, rt_base_t y);
|
||||
void (*set_pixel) (rtgui_color_t *c, int x, int y);
|
||||
|
||||
c = black;
|
||||
set_pixel = rtgui_graphic_driver_get_default()->ops->set_pixel;
|
||||
|
||||
@@ -1,315 +0,0 @@
|
||||
/*
|
||||
* File : panel.c
|
||||
* This file is part of RTGUI in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2009-10-04 Bernard first version
|
||||
*/
|
||||
|
||||
#include "panel.h"
|
||||
#include "mouse.h"
|
||||
|
||||
#include <rtgui/rtgui_system.h>
|
||||
|
||||
/* the global parameter */
|
||||
struct rtgui_list_node _rtgui_panel_list = {RT_NULL};
|
||||
|
||||
void rtgui_panel_register(char* name, rtgui_rect_t* extent)
|
||||
{
|
||||
register rt_base_t temp;
|
||||
struct rtgui_panel* panel;
|
||||
|
||||
panel = rtgui_panel_find(name);
|
||||
if (panel != RT_NULL )
|
||||
{
|
||||
/* there are already a same named panel exist. */
|
||||
return;
|
||||
}
|
||||
|
||||
panel = rtgui_malloc(sizeof(struct rtgui_panel));
|
||||
if (panel == RT_NULL)
|
||||
{
|
||||
/* can't alloc memory */
|
||||
return;
|
||||
}
|
||||
|
||||
/* copy name */
|
||||
for (temp = 0; temp < RTGUI_NAME_MAX; temp ++)
|
||||
{
|
||||
panel->name[temp] = name[temp];
|
||||
}
|
||||
|
||||
/* copy extent */
|
||||
panel->extent = *extent;
|
||||
|
||||
panel->wm_thread = RT_NULL;
|
||||
panel->is_focusable = RT_TRUE;
|
||||
|
||||
/* init list */
|
||||
rtgui_list_init(&(panel->sibling));
|
||||
rtgui_list_init(&(panel->thread_list));
|
||||
|
||||
/* add panel to panel list */
|
||||
rtgui_list_insert(&_rtgui_panel_list, &(panel->sibling));
|
||||
}
|
||||
|
||||
void rtgui_panel_deregister(char* name)
|
||||
{
|
||||
struct rtgui_panel* panel;
|
||||
|
||||
panel = rtgui_panel_find(name);
|
||||
if (panel != RT_NULL)
|
||||
{
|
||||
rtgui_list_remove(&_rtgui_panel_list, &(panel->sibling));
|
||||
|
||||
/* free pane node */
|
||||
rtgui_free(panel);
|
||||
}
|
||||
}
|
||||
|
||||
/* set default focused panel, please use it after registered panel */
|
||||
void rtgui_panel_set_default_focused(char* name)
|
||||
{
|
||||
extern struct rtgui_panel* rtgui_server_focus_panel;
|
||||
struct rtgui_panel* panel;
|
||||
|
||||
panel = rtgui_panel_find(name);
|
||||
if (panel != RT_NULL)
|
||||
{
|
||||
rtgui_server_focus_panel = panel;
|
||||
}
|
||||
}
|
||||
|
||||
void rtgui_panel_set_nofocused(char* name)
|
||||
{
|
||||
extern struct rtgui_panel* rtgui_server_focus_panel;
|
||||
struct rtgui_panel* panel;
|
||||
|
||||
panel = rtgui_panel_find(name);
|
||||
if (panel != RT_NULL)
|
||||
{
|
||||
panel->is_focusable = RT_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
struct rtgui_panel* rtgui_panel_find(char* name)
|
||||
{
|
||||
struct rtgui_list_node* node;
|
||||
struct rtgui_panel* panel;
|
||||
|
||||
rtgui_list_foreach(node, &_rtgui_panel_list)
|
||||
{
|
||||
panel = rtgui_list_entry(node, struct rtgui_panel, sibling);
|
||||
|
||||
if (rt_strncmp(panel->name, name, RTGUI_NAME_MAX) == 0)
|
||||
{
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
struct rtgui_panel* rtgui_panel_thread_add(char* name, rt_thread_t tid)
|
||||
{
|
||||
struct rtgui_panel* panel;
|
||||
|
||||
panel = rtgui_panel_find(name);
|
||||
if (panel != RT_NULL )
|
||||
{
|
||||
struct rtgui_panel_thread* thread;
|
||||
|
||||
/* allocate panel thread node */
|
||||
thread = rtgui_malloc(sizeof(struct rtgui_panel_thread));
|
||||
if (thread == RT_NULL)
|
||||
{
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
/* construct panel thread node */
|
||||
thread->tid = tid;
|
||||
|
||||
/* init list */
|
||||
rtgui_list_init(&(thread->list));
|
||||
rtgui_list_init(&(thread->monitor_list));
|
||||
|
||||
/* append thread to the list */
|
||||
rtgui_list_append(&(panel->thread_list), &(thread->list));
|
||||
}
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
void rtgui_panel_thread_remove(rtgui_panel_t* panel, rt_thread_t tid)
|
||||
{
|
||||
if (panel != RT_NULL )
|
||||
{
|
||||
struct rtgui_list_node* node;
|
||||
struct rtgui_panel_thread* thread;
|
||||
|
||||
rtgui_list_foreach(node, &(panel->thread_list))
|
||||
{
|
||||
thread = rtgui_list_entry(node, struct rtgui_panel_thread, list);
|
||||
if (thread->tid == tid)
|
||||
{
|
||||
/* remove node from list */
|
||||
rtgui_list_remove(&(panel->thread_list), &(thread->list));
|
||||
|
||||
/* free the panel thread node */
|
||||
rtgui_free(thread);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rt_thread_t rtgui_panel_get_active_thread(rtgui_panel_t* panel)
|
||||
{
|
||||
if (panel != RT_NULL)
|
||||
{
|
||||
if (panel->thread_list.next != RT_NULL)
|
||||
{
|
||||
struct rtgui_panel_thread* thread;
|
||||
thread = rtgui_list_entry(panel->thread_list.next, struct rtgui_panel_thread, list);
|
||||
|
||||
return thread->tid;
|
||||
}
|
||||
}
|
||||
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
void rtgui_panel_set_active_thread(rtgui_panel_t* panel, rt_thread_t tid)
|
||||
{
|
||||
/* get old active thread */
|
||||
rt_thread_t prev_actived = rtgui_panel_get_active_thread(panel);
|
||||
if (prev_actived != tid)
|
||||
{
|
||||
/* de-active old active workbench */
|
||||
struct rtgui_event_panel_hide ehide;
|
||||
RTGUI_EVENT_PANEL_HIDE_INIT(&ehide);
|
||||
|
||||
ehide.panel = panel;
|
||||
ehide.workbench = RT_NULL;
|
||||
rtgui_thread_send_urgent(prev_actived, &(ehide.parent), sizeof (ehide));
|
||||
}
|
||||
|
||||
if (panel != RT_NULL )
|
||||
{
|
||||
struct rtgui_list_node* node;
|
||||
struct rtgui_panel_thread* thread;
|
||||
|
||||
rtgui_list_foreach(node, &(panel->thread_list))
|
||||
{
|
||||
thread = rtgui_list_entry(node, struct rtgui_panel_thread, list);
|
||||
if (thread->tid == tid)
|
||||
{
|
||||
/* remove node from list */
|
||||
rtgui_list_remove(&(panel->thread_list), &(thread->list));
|
||||
|
||||
/* insert node to the header */
|
||||
rtgui_list_insert(&(panel->thread_list), &(thread->list));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* deactivate current activated thread -- move it to the end of list */
|
||||
void rtgui_panel_deactive_thread(rtgui_panel_t* panel)
|
||||
{
|
||||
RT_ASSERT(panel == RT_NULL);
|
||||
|
||||
if (panel->thread_list.next != RT_NULL)
|
||||
{
|
||||
struct rtgui_panel_thread* thread;
|
||||
thread = rtgui_list_entry(panel->thread_list.next, struct rtgui_panel_thread, list);
|
||||
|
||||
/* remove it */
|
||||
panel->thread_list.next = thread->list.next;
|
||||
|
||||
/* append to the tail of thread list */
|
||||
rtgui_list_append(&(panel->thread_list), &(thread->list));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get the panel which contains a point(x, y)
|
||||
*/
|
||||
rtgui_panel_t* rtgui_panel_get_contain(int x, int y)
|
||||
{
|
||||
struct rtgui_list_node* node;
|
||||
struct rtgui_panel* panel;
|
||||
|
||||
rtgui_list_foreach(node, &(_rtgui_panel_list))
|
||||
{
|
||||
panel = rtgui_list_entry(node, struct rtgui_panel, sibling);
|
||||
if (rtgui_rect_contains_point(&(panel->extent), x, y) == RT_EOK)
|
||||
{
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
|
||||
return RT_NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* append a rect to panel mouse monitor rect list
|
||||
*/
|
||||
void rtgui_panel_append_monitor_rect(rtgui_panel_t* panel, rt_thread_t tid, rtgui_rect_t* rect)
|
||||
{
|
||||
if (panel != RT_NULL )
|
||||
{
|
||||
struct rtgui_list_node* node;
|
||||
struct rtgui_panel_thread* thread;
|
||||
|
||||
rtgui_list_foreach(node, &(panel->thread_list))
|
||||
{
|
||||
thread = rtgui_list_entry(node, struct rtgui_panel_thread, list);
|
||||
if (thread->tid == tid)
|
||||
{
|
||||
/* add the monitor rect to list */
|
||||
rtgui_mouse_monitor_append(&(thread->monitor_list), rect);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* remove a rect from panel mouse monitor rect list
|
||||
*/
|
||||
void rtgui_panel_remove_monitor_rect(rtgui_panel_t* panel, rt_thread_t tid, rtgui_rect_t* rect)
|
||||
{
|
||||
if (panel != RT_NULL )
|
||||
{
|
||||
struct rtgui_list_node* node;
|
||||
struct rtgui_panel_thread* thread;
|
||||
|
||||
rtgui_list_foreach(node, &(panel->thread_list))
|
||||
{
|
||||
thread = rtgui_list_entry(node, struct rtgui_panel_thread, list);
|
||||
if (thread->tid == tid)
|
||||
{
|
||||
/* remove the monitor rect from list */
|
||||
rtgui_mouse_monitor_remove(&(thread->monitor_list), rect);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void rtgui_panel_set_wm(rtgui_panel_t* panel, rt_thread_t wm)
|
||||
{
|
||||
RT_ASSERT(wm != RT_NULL);
|
||||
RT_ASSERT(panel != RT_NULL);
|
||||
|
||||
panel->wm_thread = wm;
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* File : panel.h
|
||||
* This file is part of RTGUI in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rt-thread.org/license/LICENSE
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2009-10-04 Bernard first version
|
||||
*/
|
||||
|
||||
#ifndef __RT_PANEL_H__
|
||||
#define __RT_PANEL_H__
|
||||
|
||||
#include <rtgui/rtgui.h>
|
||||
#include <rtgui/list.h>
|
||||
#include <rtgui/region.h>
|
||||
|
||||
struct rtgui_panel_thread
|
||||
{
|
||||
/* thread id */
|
||||
rt_thread_t tid;
|
||||
|
||||
/* the list of thread */
|
||||
rtgui_list_t list;
|
||||
|
||||
/* monitor rect list */
|
||||
rtgui_list_t monitor_list;
|
||||
};
|
||||
typedef struct rtgui_panel_thread rtgui_panel_thread_list_t;
|
||||
|
||||
struct rtgui_panel
|
||||
{
|
||||
char name[RTGUI_NAME_MAX];
|
||||
|
||||
/* the extent of panel */
|
||||
rtgui_rect_t extent;
|
||||
|
||||
/* the list of panel */
|
||||
rtgui_list_t sibling;
|
||||
|
||||
/* the thread list in this panel */
|
||||
rtgui_list_t thread_list;
|
||||
|
||||
/* the workbench manager thread */
|
||||
rt_thread_t wm_thread;
|
||||
|
||||
/* is focusable */
|
||||
rt_bool_t is_focusable;
|
||||
};
|
||||
|
||||
/* find panel by name */
|
||||
struct rtgui_panel* rtgui_panel_find(char* name);
|
||||
|
||||
/* add or remove application thread from specified panel */
|
||||
rtgui_panel_t* rtgui_panel_thread_add(char* name, rt_thread_t tid);
|
||||
void rtgui_panel_thread_remove(rtgui_panel_t* panel, rt_thread_t tid);
|
||||
|
||||
rt_thread_t rtgui_panel_get_active_thread(rtgui_panel_t* panel);
|
||||
void rtgui_panel_set_active_thread(rtgui_panel_t* panel, rt_thread_t tid);
|
||||
|
||||
rtgui_panel_t* rtgui_panel_get_contain(int x, int y);
|
||||
void rtgui_panel_set_wm(rtgui_panel_t* panel, rt_thread_t wm);
|
||||
|
||||
void rtgui_panel_append_monitor_rect(rtgui_panel_t* panel, rt_thread_t tid, rtgui_rect_t* rect);
|
||||
void rtgui_panel_remove_monitor_rect(rtgui_panel_t* panel, rt_thread_t tid, rtgui_rect_t* rect);
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+159
-448
File diff suppressed because it is too large
Load Diff
+838
-581
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,6 @@
|
||||
#define __RTGUI_TOPWIN_H__
|
||||
|
||||
#include <rtgui/rtgui.h>
|
||||
#include <rtgui/list.h>
|
||||
#include <rtgui/region.h>
|
||||
#include <rtgui/event.h>
|
||||
#include <rtgui/widgets/title.h>
|
||||
@@ -25,25 +24,24 @@
|
||||
rt_err_t rtgui_topwin_add(struct rtgui_event_win_create* event);
|
||||
rt_err_t rtgui_topwin_remove(struct rtgui_win* wid);
|
||||
|
||||
/* raise window to front */
|
||||
void rtgui_topwin_raise(struct rtgui_win* wid, rt_thread_t sender);
|
||||
/* update clip info to a panel */
|
||||
void rtgui_topwin_update_clip_to_panel(struct rtgui_panel* panel);
|
||||
void rtgui_topwin_activate_win(struct rtgui_topwin* win);
|
||||
|
||||
/* show a window */
|
||||
void rtgui_topwin_show(struct rtgui_event_win* event);
|
||||
rt_err_t rtgui_topwin_show(struct rtgui_event_win* event);
|
||||
/* hide a window */
|
||||
void rtgui_topwin_hide(struct rtgui_event_win* event);
|
||||
rt_err_t rtgui_topwin_hide(struct rtgui_event_win* event);
|
||||
/* move a window */
|
||||
void rtgui_topwin_move(struct rtgui_event_win_move* event);
|
||||
rt_err_t rtgui_topwin_move(struct rtgui_event_win_move* event);
|
||||
/* resize a window */
|
||||
void rtgui_topwin_resize(struct rtgui_win* wid, rtgui_rect_t* r);
|
||||
/* a window is entering modal mode */
|
||||
rt_err_t rtgui_topwin_modal_enter(struct rtgui_event_win_modal_enter* event);
|
||||
|
||||
/* get window at (x, y) */
|
||||
struct rtgui_topwin* rtgui_topwin_get_wnd(int x, int y);
|
||||
struct rtgui_topwin* rtgui_topwin_get_wnd_no_modaled(int x, int y);
|
||||
|
||||
void rtgui_topwin_activate_win(struct rtgui_topwin* win);
|
||||
void rtgui_topwin_deactivate_win(struct rtgui_topwin* win);
|
||||
//void rtgui_topwin_deactivate_win(struct rtgui_topwin* win);
|
||||
|
||||
/* window title */
|
||||
void rtgui_topwin_title_ondraw(struct rtgui_topwin* win);
|
||||
@@ -53,7 +51,7 @@ void rtgui_topwin_title_onmouse(struct rtgui_topwin* win, struct rtgui_event_mou
|
||||
void rtgui_topwin_append_monitor_rect(struct rtgui_win* wid, rtgui_rect_t* rect);
|
||||
void rtgui_topwin_remove_monitor_rect(struct rtgui_win* wid, rtgui_rect_t* rect);
|
||||
|
||||
void rtgui_topwin_do_clip(rtgui_widget_t* widget);
|
||||
|
||||
/* get the topwin that is currently focused */
|
||||
struct rtgui_topwin* rtgui_topwin_get_focus(void);
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user