PageRenderTime 31ms CodeModel.GetById 1ms app.highlight 23ms RepoModel.GetById 1ms app.codeStats 0ms

/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/*
 26 * History:
 27 * ================================================================
 28 * 2011-09-27 Li XianJing <xianjimli@hotmail.com> created
 29 *
 30 */
 31
 32#include "widgets_info.h"
 33
 34static const WidgetInfo s_widgets_info[] = 
 35{
 36 {FTK_BUTTON,       "button",       60, 40, 60, 40, 1, 1, 1,     ftk_button_create             ,NULL, "ftk_button_create"},
 37 {FTK_LABEL,        "label",        40, 22, 60, 22, 1, 1, 1,     ftk_label_create              ,NULL, "ftk_label_create"},
 38 {FTK_ENTRY,        "entry",        40, 24, 60, 24, 1, 1, 1,     ftk_entry_create              ,NULL, "ftk_entry_create"},
 39 {FTK_WAIT_BOX,     "wait_box",     32, 32, 32, 32, 1, 1, 1,     ftk_wait_box_create           ,NULL, "ftk_wait_box_create"},
 40 {FTK_PROGRESS_BAR, "progress_bar", 60, 22, 60, 22, 1, 1, 1,     ftk_progress_bar_create       ,NULL, "ftk_progress_bar_create"},
 41 {FTK_GROUP_BOX,    "group_box",    80, 80, 80, 80, 0, 1, 1,     ftk_group_box_create          ,NULL, "ftk_group_box_create"},
 42 {FTK_RADIO_BUTTON, "radio_button", 60, 50, 60, 50, 1, 1, 1,     ftk_check_button_create_radio ,NULL, "ftk_check_button_create_radio"},
 43 {FTK_CHECK_BUTTON, "check_button", 60, 50, 60, 50, 1, 1, 1,     ftk_check_button_create       ,NULL, "ftk_check_button_create"},
 44 {FTK_IMAGE,        "image",        32, 32, 80, 80, 1, 1, 1,     ftk_image_create              ,NULL, "ftk_image_create"},
 45 {FTK_SCROLL_VBAR,  "scroll_bar",    8,  8,  8, 32, 1, 1, 1,     ftk_scroll_bar_create         ,NULL, "ftk_scroll_bar_create"},
 46 {FTK_LIST_VIEW,    "list_view",    80, 80, 80, 80, 1, 1, 1,     ftk_list_view_default_create  ,NULL, "ftk_list_view_default_create"},
 47 {FTK_ICON_VIEW,    "icon_view",    80, 80, 80, 80, 1, 1, 1,     ftk_icon_view_create          ,NULL, "ftk_icon_view_create"},
 48 {FTK_COMBO_BOX,    "combo_box",    60, 40, 60, 40, 1, 1, 1,     ftk_combo_box_create          ,NULL, "ftk_combo_box_create"},
 49 {FTK_PAINTER,      "painter",      80, 80, 80, 80, 1, 1, 1,     ftk_painter_create            ,NULL, "ftk_painter_create"},
 50 {FTK_TAB,          "tab",          180,180,180,180,0, 1, 1,     ftk_tab_create                ,NULL, "ftk_tab_create"},
 51 {FTK_TAB_PAGE,     "page",         180,180,180,180,0, 1, 1,     ftk_tab_page_create           ,NULL, "ftk_tab_page_create"},
 52 {FTK_TEXT_VIEW,    "text_view",    80, 80, 80, 80, 1, 1, 1,     ftk_text_view_create          ,NULL, "ftk_text_view_create"}
 53};
 54
 55#define WIDGETS_INFO_NR sizeof(s_widgets_info)/sizeof(s_widgets_info[0])
 56
 57int widgets_info_get_nr(void)
 58{
 59	return WIDGETS_INFO_NR;
 60}
 61
 62const WidgetInfo* widgets_info_get(int index)
 63{
 64	return_val_if_fail(index < WIDGETS_INFO_NR, NULL);
 65
 66	return s_widgets_info+index;
 67}
 68
 69const WidgetInfo* widgets_info_find(const char* name)
 70{
 71	size_t i = 0;
 72
 73	return_val_if_fail(name != NULL, NULL);
 74
 75	for(i = 0; i < WIDGETS_INFO_NR; i++)
 76	{
 77		if(strcmp(name, s_widgets_info[i].name) == 0)
 78		{
 79			return s_widgets_info+i;
 80		}
 81	}
 82
 83	return NULL;
 84}
 85
 86const WidgetInfo* widgets_info_find_by_type(int type)
 87{
 88	size_t i = 0;
 89
 90	for(i = 0; i < WIDGETS_INFO_NR; i++)
 91	{
 92		if(type == s_widgets_info[i].type)
 93		{
 94			return s_widgets_info+i;
 95		}
 96	}
 97
 98	return NULL;
 99}
100