/apps/designer/widgets_info.c

http://ftk.googlecode.com/ · C · 100 lines · 56 code · 15 blank · 29 comment · 7 complexity · 7121ff1a771a7127e51db4956a029ba6 MD5 · raw file

  1. /*
  2. * File: widgets_info.c
  3. * Author: Li XianJing <xianjimli@hotmail.com>
  4. * Brief: widget infomation.
  5. *
  6. * Copyright (c) 2009 - 2011 Li XianJing <xianjimli@hotmail.com>
  7. *
  8. * Licensed under the Academic Free License version 2.1
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. */
  24. /*
  25. * History:
  26. * ================================================================
  27. * 2011-09-27 Li XianJing <xianjimli@hotmail.com> created
  28. *
  29. */
  30. #include "widgets_info.h"
  31. static const WidgetInfo s_widgets_info[] =
  32. {
  33. {FTK_BUTTON, "button", 60, 40, 60, 40, 1, 1, 1, ftk_button_create ,NULL, "ftk_button_create"},
  34. {FTK_LABEL, "label", 40, 22, 60, 22, 1, 1, 1, ftk_label_create ,NULL, "ftk_label_create"},
  35. {FTK_ENTRY, "entry", 40, 24, 60, 24, 1, 1, 1, ftk_entry_create ,NULL, "ftk_entry_create"},
  36. {FTK_WAIT_BOX, "wait_box", 32, 32, 32, 32, 1, 1, 1, ftk_wait_box_create ,NULL, "ftk_wait_box_create"},
  37. {FTK_PROGRESS_BAR, "progress_bar", 60, 22, 60, 22, 1, 1, 1, ftk_progress_bar_create ,NULL, "ftk_progress_bar_create"},
  38. {FTK_GROUP_BOX, "group_box", 80, 80, 80, 80, 0, 1, 1, ftk_group_box_create ,NULL, "ftk_group_box_create"},
  39. {FTK_RADIO_BUTTON, "radio_button", 60, 50, 60, 50, 1, 1, 1, ftk_check_button_create_radio ,NULL, "ftk_check_button_create_radio"},
  40. {FTK_CHECK_BUTTON, "check_button", 60, 50, 60, 50, 1, 1, 1, ftk_check_button_create ,NULL, "ftk_check_button_create"},
  41. {FTK_IMAGE, "image", 32, 32, 80, 80, 1, 1, 1, ftk_image_create ,NULL, "ftk_image_create"},
  42. {FTK_SCROLL_VBAR, "scroll_bar", 8, 8, 8, 32, 1, 1, 1, ftk_scroll_bar_create ,NULL, "ftk_scroll_bar_create"},
  43. {FTK_LIST_VIEW, "list_view", 80, 80, 80, 80, 1, 1, 1, ftk_list_view_default_create ,NULL, "ftk_list_view_default_create"},
  44. {FTK_ICON_VIEW, "icon_view", 80, 80, 80, 80, 1, 1, 1, ftk_icon_view_create ,NULL, "ftk_icon_view_create"},
  45. {FTK_COMBO_BOX, "combo_box", 60, 40, 60, 40, 1, 1, 1, ftk_combo_box_create ,NULL, "ftk_combo_box_create"},
  46. {FTK_PAINTER, "painter", 80, 80, 80, 80, 1, 1, 1, ftk_painter_create ,NULL, "ftk_painter_create"},
  47. {FTK_TAB, "tab", 180,180,180,180,0, 1, 1, ftk_tab_create ,NULL, "ftk_tab_create"},
  48. {FTK_TAB_PAGE, "page", 180,180,180,180,0, 1, 1, ftk_tab_page_create ,NULL, "ftk_tab_page_create"},
  49. {FTK_TEXT_VIEW, "text_view", 80, 80, 80, 80, 1, 1, 1, ftk_text_view_create ,NULL, "ftk_text_view_create"}
  50. };
  51. #define WIDGETS_INFO_NR sizeof(s_widgets_info)/sizeof(s_widgets_info[0])
  52. int widgets_info_get_nr(void)
  53. {
  54. return WIDGETS_INFO_NR;
  55. }
  56. const WidgetInfo* widgets_info_get(int index)
  57. {
  58. return_val_if_fail(index < WIDGETS_INFO_NR, NULL);
  59. return s_widgets_info+index;
  60. }
  61. const WidgetInfo* widgets_info_find(const char* name)
  62. {
  63. size_t i = 0;
  64. return_val_if_fail(name != NULL, NULL);
  65. for(i = 0; i < WIDGETS_INFO_NR; i++)
  66. {
  67. if(strcmp(name, s_widgets_info[i].name) == 0)
  68. {
  69. return s_widgets_info+i;
  70. }
  71. }
  72. return NULL;
  73. }
  74. const WidgetInfo* widgets_info_find_by_type(int type)
  75. {
  76. size_t i = 0;
  77. for(i = 0; i < WIDGETS_INFO_NR; i++)
  78. {
  79. if(type == s_widgets_info[i].type)
  80. {
  81. return s_widgets_info+i;
  82. }
  83. }
  84. return NULL;
  85. }