title.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * File : title.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2009-10-16 Bernard first version
  13. */
  14. #include <rtgui/widgets/title.h>
  15. #include <rtgui/rtgui_system.h>
  16. /* there is no event handler in wintitle but handle the event on topwin of server */
  17. static void _rtgui_wintitle_constructor(rtgui_wintitle_t* wintitle)
  18. {
  19. wintitle->title = RT_NULL;
  20. RTGUI_WIDGET(wintitle)->flag = RTGUI_WIDGET_FLAG_DEFAULT;
  21. }
  22. rtgui_type_t* rtgui_wintitle_type_get()
  23. {
  24. static rtgui_type_t *wintitle_type = RT_NULL;
  25. if (!wintitle_type)
  26. {
  27. wintitle_type = rtgui_type_create("wintitle", RTGUI_TOPLEVEL_TYPE,
  28. sizeof(rtgui_wintitle_t), RTGUI_CONSTRUCTOR(_rtgui_wintitle_constructor), RT_NULL);
  29. }
  30. return wintitle_type;
  31. }
  32. rtgui_wintitle_t* rtgui_wintitle_create(const rt_uint8_t* title)
  33. {
  34. rtgui_wintitle_t* wintitle;
  35. wintitle = (rtgui_wintitle_t*)rtgui_widget_create(RTGUI_WINTITLE_TYPE);
  36. if (wintitle != RT_NULL)
  37. {
  38. rtgui_wintitle_set_title(wintitle, title);
  39. }
  40. return wintitle;
  41. }
  42. void rtgui_wintitle_destroy(rtgui_wintitle_t* wintitle)
  43. {
  44. rtgui_widget_destroy(RTGUI_WIDGET(wintitle));
  45. }
  46. void rtgui_wintitle_set_title(rtgui_wintitle_t* wintitle, const rt_uint8_t* title)
  47. {
  48. RT_ASSERT(wintitle != RT_NULL);
  49. if (wintitle->title != RT_NULL)
  50. {
  51. rtgui_free(wintitle->title);
  52. }
  53. if (title != RT_NULL) wintitle->title = (unsigned char*)rt_strdup((const char*)title);
  54. else wintitle->title = RT_NULL;
  55. }
  56. rt_uint8_t *rtgui_wintitle_get_title(rtgui_wintitle_t* wintitle)
  57. {
  58. RT_ASSERT(wintitle != RT_NULL);
  59. return wintitle->title;
  60. }