2009-11-24 07:34:58 +08:00
|
|
|
/*
|
|
|
|
* File : title.c
|
|
|
|
* This file is part of 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-16 Bernard first version
|
|
|
|
*/
|
|
|
|
#include <rtgui/widgets/title.h>
|
|
|
|
#include <rtgui/rtgui_system.h>
|
|
|
|
|
|
|
|
/* there is no event handler in wintitle but handle the event on topwin of server */
|
2012-11-26 10:42:52 +08:00
|
|
|
static void _rtgui_wintitle_constructor(rtgui_wintitle_t *wintitle)
|
2009-11-24 07:34:58 +08:00
|
|
|
{
|
2012-11-26 10:42:52 +08:00
|
|
|
wintitle->title = RT_NULL;
|
|
|
|
RTGUI_WIDGET(wintitle)->flag = RTGUI_WIDGET_FLAG_DEFAULT;
|
|
|
|
RTGUI_WIDGET_TEXTALIGN(wintitle) = RTGUI_ALIGN_CENTER_VERTICAL;
|
2009-11-24 07:34:58 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
static void _rtgui_wintitle_deconstructor(rtgui_wintitle_t *wintitle)
|
2009-11-24 07:34:58 +08:00
|
|
|
{
|
2012-11-26 10:42:52 +08:00
|
|
|
if (wintitle->title != RT_NULL)
|
|
|
|
rt_free(wintitle->title);
|
|
|
|
wintitle->title = RT_NULL;
|
2009-11-24 07:34:58 +08:00
|
|
|
}
|
|
|
|
|
2012-09-07 09:50:13 +08:00
|
|
|
DEFINE_CLASS_TYPE(wintitle, "wintitle",
|
2012-11-26 10:42:52 +08:00
|
|
|
RTGUI_WIDGET_TYPE,
|
|
|
|
_rtgui_wintitle_constructor,
|
|
|
|
_rtgui_wintitle_deconstructor,
|
|
|
|
sizeof(struct rtgui_wintitle));
|
2009-11-24 07:34:58 +08:00
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
rtgui_wintitle_t *rtgui_wintitle_create(struct rtgui_win *window, const char *title)
|
2009-11-24 07:34:58 +08:00
|
|
|
{
|
2012-11-26 10:42:52 +08:00
|
|
|
rtgui_wintitle_t *wintitle;
|
2009-11-24 07:34:58 +08:00
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
wintitle = (rtgui_wintitle_t *)rtgui_widget_create(RTGUI_WINTITLE_TYPE);
|
|
|
|
if (wintitle != RT_NULL)
|
|
|
|
{
|
|
|
|
rtgui_wintitle_set_title(wintitle, title);
|
2012-09-07 09:50:13 +08:00
|
|
|
RTGUI_WIDGET(wintitle)->toplevel = window;
|
2012-11-26 10:42:52 +08:00
|
|
|
}
|
2009-11-24 07:34:58 +08:00
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
return wintitle;
|
2009-11-24 07:34:58 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
void rtgui_wintitle_destroy(rtgui_wintitle_t *wintitle)
|
2009-11-24 07:34:58 +08:00
|
|
|
{
|
2012-11-26 10:42:52 +08:00
|
|
|
rtgui_widget_destroy(RTGUI_WIDGET(wintitle));
|
2009-11-24 07:34:58 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
void rtgui_wintitle_set_title(rtgui_wintitle_t *wintitle, const char *title)
|
2009-11-24 07:34:58 +08:00
|
|
|
{
|
2012-11-26 10:42:52 +08:00
|
|
|
RT_ASSERT(wintitle != RT_NULL);
|
2009-11-24 07:34:58 +08:00
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
if (wintitle->title != RT_NULL)
|
|
|
|
{
|
|
|
|
rt_free(wintitle->title);
|
|
|
|
}
|
2009-11-24 07:34:58 +08:00
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
if (title != RT_NULL) wintitle->title = (char *)rt_strdup((const char *)title);
|
|
|
|
else wintitle->title = RT_NULL;
|
2009-11-24 07:34:58 +08:00
|
|
|
}
|
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
char *rtgui_wintitle_get_title(rtgui_wintitle_t *wintitle)
|
2009-11-24 07:34:58 +08:00
|
|
|
{
|
2012-11-26 10:42:52 +08:00
|
|
|
RT_ASSERT(wintitle != RT_NULL);
|
2009-11-24 07:34:58 +08:00
|
|
|
|
2012-11-26 10:42:52 +08:00
|
|
|
return wintitle->title;
|
2009-11-24 07:34:58 +08:00
|
|
|
}
|