S60平台设置项类型——资源。
3.1 Binary Switch
二进制开关是最简单的设置项类型了,它允许设置成开和关,并且不需要单独的设置页,在设置列表中就可以改变。二进制开关设置项类型返回一个布尔(TBool)型变量在应用程序设置数据中。设置项类中使用的二进制开关类型是CAknBinaryPopupSettingItem。
图1 二进制开关设置项
下面是一个二进制开关资源定义的例子:
view plaincopy to clipboardprint?
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_binary
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline07;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingBinary;
setting_page_resource = r_binary_setting _page;
associated_resource = r_popup_setting_binary_texts;
name = qtn_exsl_binary_title;
}
};
}
RESOURCE AVKON_POPUP_SETTING_TEXTS r_popup_setting_binary_texts
{
flags = 0;
setting_texts_resource = r_on_off_texts;
popped_up_texts_resource = r_popped_up_on_off_texts;
}
RESOURCE ARRAY r_on_off_texts
{
items =
{
AVKON_ENUMERATED_TEXT { value=1; text = qtn_exsl_texts_on; },
AVKON_ENUMERATED_TEXT { value=0; text = qtn_exsl_texts_off; }
};
}
RESOURCE ARRAY r_popped_up_on_off_texts
{
items =
{
LBUF { txt = qtn_exsl_texts_enabled; },
LBUF { txt = qtn_exsl_texts_disabled; }
};
}
RESOURCE AVKON_SETTING_PAGE r_binary_setting_page
{
number= 0;
label= qtn_exsl_binary_title;
type = EAknCtPopupSettingList;
}
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_binary
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline07;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingBinary;
setting_page_resource = r_binary_setting _page;
associated_resource = r_popup_setting_binary_texts;
name = qtn_exsl_binary_title;
}
};
}
RESOURCE AVKON_POPUP_SETTING_TEXTS r_popup_setting_binary_texts
{
flags = 0;
setting_texts_resource = r_on_off_texts;
popped_up_texts_resource = r_popped_up_on_off_texts;
}
RESOURCE ARRAY r_on_off_texts
{
items =
{
AVKON_ENUMERATED_TEXT { value=1; text = qtn_exsl_texts_on; },
AVKON_ENUMERATED_TEXT { value=0; text = qtn_exsl_texts_off; }
};
}
RESOURCE ARRAY r_popped_up_on_off_texts
{
items =
{
LBUF { txt = qtn_exsl_texts_enabled; },
LBUF { txt = qtn_exsl_texts_disabled; }
};
}
RESOURCE AVKON_SETTING_PAGE r_binary_setting_page
{
number= 0;
label= qtn_exsl_binary_title;
type = EAknCtPopupSettingList;
}
3.2 Text Editor
文本设置项允许用户输入设置的值。这些设置值存储在用户指定描述符(user-specified descriptor)中。设置项类使用的文本编辑类型是CAknTextSettingItem。
图2 文本设置项和文本设置页
下面是文本编辑设置项资源定义的例子:
view plaincopy to clipboardprint?
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_text
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline01;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingText;
setting_page_resource = r_text_setting_page;
name = qtn_exsl_text_title;
}
};
}
RESOURCE AVKON_SETTING_PAGE r_text_setting_page
{
number = TEXT_SETTING_PAGE_NUMBER;
label = qtn_exsl_text_title;
type = EEikCtEdwin;
editor_resource_id = r_settinglist_edwin;
}
RESOURCE EDWIN r_settinglist_edwin
{
width = TEXT_SETTING_PAGE_WIDTH;
lines = TEXT_SETTING_PAGE_LINES;
maxlength = TEXT_SETTING_PAGE_MAXLENGTH20;
}
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_text
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline01;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingText;
setting_page_resource = r_text_setting_page;
name = qtn_exsl_text_title;
}
};
}
RESOURCE AVKON_SETTING_PAGE r_text_setting_page
{
number = TEXT_SETTING_PAGE_NUMBER;
label = qtn_exsl_text_title;
type = EEikCtEdwin;
editor_resource_id = r_settinglist_edwin;
}
RESOURCE EDWIN r_settinglist_edwin
{
width = TEXT_SETTING_PAGE_WIDTH;
lines = TEXT_SETTING_PAGE_LINES;
maxlength = TEXT_SETTING_PAGE_MAXLENGTH20;
}
3.3 Enumerated Text
枚举文本设置项为用户提供一个选择列表。它也允许为设置项再输入一个文本值,通过选择弹出菜单的“Other”来完成它。这样实际上就有了三种不同的枚举文本视图:设置列表中包含设置项,设置页显示多种选择,文本编辑器输入非预定义的文本。这些设置值存储在设置项构造的描述符中。设置项类使用枚举文本类型是CAknEnumeratedTextPopupSettingItem。
图3 枚举文本设置项和设置页
图4 枚举文本、文本编辑器
下面是枚举文本设置项的资源定义的例子:
view plaincopy to clipboardprint?
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_enumtext
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline04;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingEnumText;
setting_page_resource = r_enumtext_setting_page;
associated_resource = r_popup_setting_list;
name = qtn_exsl_enumtext_title;
}
};
}
RESOURCE AVKON_SETTING_PAGE r_enumtext_setting_page
{
number= 1;
label= qtn_exsl_enumtext_title;
type = EAknCtPopupSettingList;
editor_resource_id = r_popup_setting_list_new_entry;
}
RESOURCE AVKON_POPUP_SETTING_TEXTS r_popup_setting_list
{
setting_texts_resource = r_settinglist_page_list;
popped_up_texts_resource = r_settinglist_list_item_array;
}
RESOURCE ARRAY r_settinglist_page_list
{
items =
{
AVKON_ENUMERATED_TEXT {value = 0;text = qtn_exsl_item_list0;},
AVKON_ENUMERATED_TEXT {value = 1;text = qtn_exsl_item_list1;},
AVKON_ENUMERATED_TEXT {value = 2;text = qtn_exsl_item_list2;},
. . .
AVKON_ENUMERATED_TEXT {value = 9;text = qtn_exsl_item_list9;}
};
}
RESOURCE ARRAY r_settinglist_list_item_array
{
items =
{
LBUF { txt = qtn_exsl_item_list0; },
LBUF { txt = qtn_exsl_item_list1; },
LBUF { txt = qtn_exsl_item_list2; },
. . .
LBUF { txt = qtn_exsl_item_list9; }
};
}
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_enumtext
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline04;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingEnumText;
setting_page_resource = r_enumtext_setting_page;
associated_resource = r_popup_setting_list;
name = qtn_exsl_enumtext_title;
}
};
}
RESOURCE AVKON_SETTING_PAGE r_enumtext_setting_page
{
number= 1;
label= qtn_exsl_enumtext_title;
type = EAknCtPopupSettingList;
editor_resource_id = r_popup_setting_list_new_entry;
}
RESOURCE AVKON_POPUP_SETTING_TEXTS r_popup_setting_list
{
setting_texts_resource = r_settinglist_page_list;
popped_up_texts_resource = r_settinglist_list_item_array;
}
RESOURCE ARRAY r_settinglist_page_list
{
items =
{
AVKON_ENUMERATED_TEXT {value = 0;text = qtn_exsl_item_list0;},
AVKON_ENUMERATED_TEXT {value = 1;text = qtn_exsl_item_list1;},
AVKON_ENUMERATED_TEXT {value = 2;text = qtn_exsl_item_list2;},
. . .
AVKON_ENUMERATED_TEXT {value = 9;text = qtn_exsl_item_list9;}
};
}
RESOURCE ARRAY r_settinglist_list_item_array
{
items =
{
LBUF { txt = qtn_exsl_item_list0; },
LBUF { txt = qtn_exsl_item_list1; },
LBUF { txt = qtn_exsl_item_list2; },
. . .
LBUF { txt = qtn_exsl_item_list9; }
};
}
3.4 Alphanumeric Password Editor
字母数字密码编辑器
密码设置项允许保密数据。密码设置项允许输入字母或数字(3.5章节是数字密码编辑器)。设置值存储在设置项构造的描述符中。设置项类使用密码类型是
CAknPasswordSettingItem。
图5 字母密码设置项和密码设置页
下面是字母数字密码设置项的资源定义的例子:
view plaincopy to clipboardprint?
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_pw
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline08;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingPassAlph;
setting_page_resource = r_alpha_password_setting_page;
name = qtn_exsl_alpha_title;
}
};
}
RESOURCE AVKON_SETTING_PAGE r_alpha_password_setting_page
{
number = ALPHA_PASSWORD_SETTING_PAGE_NUMBER;
label = qtn_exsl_alpha_title;
type = EEikCtSecretEd;
editor_resource_id = r_settinglist_alpha_password;
}
RESOURCE SECRETED r_settinglist_alpha_password
{
num_letters = ALPHA_PASSWORD_LENGTH_OF_STRING;
}
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_pw
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline08;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingPassAlph;
setting_page_resource = r_alpha_password_setting_page;
name = qtn_exsl_alpha_title;
}
};
}
RESOURCE AVKON_SETTING_PAGE r_alpha_password_setting_page
{
number = ALPHA_PASSWORD_SETTING_PAGE_NUMBER;
label = qtn_exsl_alpha_title;
type = EEikCtSecretEd;
editor_resource_id = r_settinglist_alpha_password;
}
RESOURCE SECRETED r_settinglist_alpha_password
{
num_letters = ALPHA_PASSWORD_LENGTH_OF_STRING;
}
3.5 Numeric Password Editor
密码设置项允许输入密码。密码设置项可以是字母数字或数字(PIN码)。设置值存储在设置项构造的描述符中。设置项类使用的密码类型是CAknPasswordSettingItem。
图6 数字密码设置项和设置页
下面是数字密码设置项资源定义的例子:
view plaincopy to clipboardprint?
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_pin
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline09;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingPassNumber;
setting_page_resource =
r_ol09_numeric_password_setting_page;
name = qtn_exsl_numeric_title;
}
};
}
RESOURCE AVKON_SETTING_PAGE r_ol09_numeric_password_setting_page
{
number = NUMERIC_PASSWORD_OL09_SETTING_PAGE_NUMBER;
label = qtn_exsl_numeric_title;
type = EAknCtNumericSecretEditor;
editor_resource_id = r_settinglist_numeric_password;
}
RESOURCE NUMSECRETED r_settinglist_numeric_password
{
num_code_chars = NUMERIC_PASSWORD_LENGTH_OF_STRING;
}
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_pin
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline09;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingPassNumber;
setting_page_resource =
r_ol09_numeric_password_setting_page;
name = qtn_exsl_numeric_title;
}
};
}
RESOURCE AVKON_SETTING_PAGE r_ol09_numeric_password_setting_page
{
number = NUMERIC_PASSWORD_OL09_SETTING_PAGE_NUMBER;
label = qtn_exsl_numeric_title;
type = EAknCtNumericSecretEditor;
editor_resource_id = r_settinglist_numeric_password;
}
RESOURCE NUMSECRETED r_settinglist_numeric_password
{
num_code_chars = NUMERIC_PASSWORD_LENGTH_OF_STRING;
}
3.6 Slider
滑块设置项允许用户指定一个整数值。这个整数值有个最小值和最大值,用滑动块控件选择指定的值。滑动块设置项的值存储在整型(TInt)变量中。滑动设置项类使用滑动块类型CAknSliderSettingItem。
图7 滑动设置项和设置页
下面是滑动设置项的资源定义的例子:
view plaincopy to clipboardprint?
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_slider
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline02;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingSlider;
setting_page_resource = r_slider_setting_page;
name = qtn_exsl_slider_title;
}
};
}
RESOURCE AVKON_SETTING_PAGE r_slider_setting_page
{
number = SLIDER_SETTING_PAGE_NUMBER;
label = qtn_exsl_slider_title;
type = EAknCtSlider;
editor_resource_id = r_settinglist_slider;
}
RESOURCE SLIDER r_settinglist_slider
{
layout = EAknSettingsItemSliderLayout;
minvalue = SLIDER_SETTING_PAGE_MINVALUE;
maxvalue = SLIDER_SETTING_PAGE_MAXVALUE;
step = SLIDER_SETTING_PAGE_STEP;
valuetype = EAknSliderValuePercentage;
minlabel = qtn_slider_minlabel; maxlabel = qtn_slider_maxlabel;
}
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_slider
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline02;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingSlider;
setting_page_resource = r_slider_setting_page;
name = qtn_exsl_slider_title;
}
};
}
RESOURCE AVKON_SETTING_PAGE r_slider_setting_page
{
number = SLIDER_SETTING_PAGE_NUMBER;
label = qtn_exsl_slider_title;
type = EAknCtSlider;
editor_resource_id = r_settinglist_slider;
}
RESOURCE SLIDER r_settinglist_slider
{
layout = EAknSettingsItemSliderLayout;
minvalue = SLIDER_SETTING_PAGE_MINVALUE;
maxvalue = SLIDER_SETTING_PAGE_MAXVALUE;
step = SLIDER_SETTING_PAGE_STEP;
valuetype = EAknSliderValuePercentage;
minlabel = qtn_slider_minlabel; maxlabel = qtn_slider_maxlabel;
}
3.7 Volume Control
音量设置项存储一个整型值变量,类似于滑动设置项。然而,音量控件可供选择的范围是1到10,也没有在设置页上摆放可以拖动的控件。设置项类使用音量控件类型是CAknVolumeSettingItem。
图8 音量设置项和设置页
下面是音量控制设置项的资源定义的例子:
view plaincopy to clipboardprint?
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_volume
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline03;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingVolume;
setting_page_resource = r_volume_setting_page;
name = qtn_exsl_volume_title;
}
};
}
RESOURCE AVKON_SETTING_PAGE r_volume_setting_page
{
number = VOLUME_SETTING_PAGE_NUMBER;
label = qtn_exsl_volume_title;
type = EAknCtVolumeControl;
editor_resource_id = r_settinglist_volume;
}
RESOURCE VOLUME r_settinglist_volume
{
flags = ESettingsVolumeControl;
value = VOLUME_SETTING_PAGE_VALUE;
}
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_volume
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline03;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingVolume;
setting_page_resource = r_volume_setting_page;
name = qtn_exsl_volume_title;
}
};
}
RESOURCE AVKON_SETTING_PAGE r_volume_setting_page
{
number = VOLUME_SETTING_PAGE_NUMBER;
label = qtn_exsl_volume_title;
type = EAknCtVolumeControl;
editor_resource_id = r_settinglist_volume;
}
RESOURCE VOLUME r_settinglist_volume
{
flags = ESettingsVolumeControl;
value = VOLUME_SETTING_PAGE_VALUE;
}
3.8 Time Editor
时间设置项用来设置时间值,与之相关联设置项的变量类型是TTime。设置项类使用时间和日期的设置项类型是CAknTimeOrDateSettingItem,用第二个构造器的参数指定额外的类型。
图9 时间设置项和设置页
下面是时间设置项资源定义的例子:
view plaincopy to clipboardprint?
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_time
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline06;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingTime;
setting_page_resource = r_time_setting_page;
name = qtn_exsl_time_title;
}
};
}
RESOURCE AVKON_SETTING_PAGE r_time_setting_page
{
number = TIME_SETTING_PAGE_NUMBER;
label = qtn_exsl_time_title;
type = EEikCtTimeEditor;
editor_resource_id = r_settinglist_time_editor;
}
RESOURCE TIME_EDITOR r_settinglist_time_editor
{
minTime = TIME
{
second = TIME_EDITOR_MIN_SECOND;
minute = TIME_EDITOR_MIN_MINUTE;
hour = TIME_EDITOR_MIN_HOUR;
};
maxTime = TIME
{
second = TIME_EDITOR_MAX_SECOND;
minute = TIME_EDITOR_MAX_MINUTE;
hour = TIME_EDITOR_MAX_HOUR;
};
}
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_time
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline06;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingTime;
setting_page_resource = r_time_setting_page;
name = qtn_exsl_time_title;
}
};
}
RESOURCE AVKON_SETTING_PAGE r_time_setting_page
{
number = TIME_SETTING_PAGE_NUMBER;
label = qtn_exsl_time_title;
type = EEikCtTimeEditor;
editor_resource_id = r_settinglist_time_editor;
}
RESOURCE TIME_EDITOR r_settinglist_time_editor
{
minTime = TIME
{
second = TIME_EDITOR_MIN_SECOND;
minute = TIME_EDITOR_MIN_MINUTE;
hour = TIME_EDITOR_MIN_HOUR;
};
maxTime = TIME
{
second = TIME_EDITOR_MAX_SECOND;
minute = TIME_EDITOR_MAX_MINUTE;
hour = TIME_EDITOR_MAX_HOUR;
};
}
3.9 Date Editor
日期设置项类似于时间设置项类型,区别在于输入的是日期值。
图10 日期设置项和设置页
下面是日期设置项资源定义的例子:
view plaincopy to clipboardprint?
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_date
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline05;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingDate;
setting_page_resource = r_date_setting_page;
name = qtn_exsl_date_title;
}
};
}
RESOURCE AVKON_SETTING_PAGE r_date_setting_page
{
label= qtn_exsl_date_title;
type = EEikCtDateEditor;
editor_resource_id = r_settinglist_date;
}
RESOURCE DATE_EDITOR r_settinglist_date
{
minDate= DATE {year=1980;};
maxDate= DATE {year=2060;};
flags=0;
}
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_date
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline05;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingDate;
setting_page_resource = r_date_setting_page;
name = qtn_exsl_date_title;
}
};
}
RESOURCE AVKON_SETTING_PAGE r_date_setting_page
{
label= qtn_exsl_date_title;
type = EEikCtDateEditor;
editor_resource_id = r_settinglist_date;
}
RESOURCE DATE_EDITOR r_settinglist_date
{
minDate= DATE {year=1980;};
maxDate= DATE {year=2060;};
flags=0;
}
3.10 IP Address Editor
IP地址设置项类型允许用户进行IP地址设置,与之对应的设置项变量类型是TInetAddr。设置项类使用的IP地址类型是CAknIpFieldSettingItem。
图11 IP地址设置项和设置页
下面是IP地址设置项资源定义的例子:
view plaincopy to clipboardprint?
RESOURCE AVKON_SETTING_ITEM_LIST r_setting_list_setting_ip
{
flags= EAknSettingItemNumberedStyle;
title = qtn_exsl_outline10;
initial_number = 1;
items =
{
AVKON_SETTING_ITEM
{
identifier = EAknExSettingIpAddress;
setting_page_resource = r_ip_address_setting_page;
name = qtn_exsl_ip_editor_title;
}
};
}
RESOURCE AVKON_SETTING_PAGE r_ip_address_setting_page
{
label= qtn_exsl_ip_editor_title;
type = EAknCtIpFieldEditor;
editor_resource_id = r_settinglist_ip_editor;
}
RESOURCE IP_FIELD_EDITOR r_settinglist_ip_editor
{
min_field_values = IP_FIELD
{
first_field = IP_EDITOR_MIN_FIELD_VALUE;
second_field = IP_EDITOR_MIN_FIELD_VALUE;
third_field = IP_EDITOR_MIN_FIELD_VALUE;
fourth_field = IP_EDITOR_MIN_FIELD_VALUE;
};
max_field_values = IP_FIELD
{
first_field = IP_EDITOR_MAX_FIELD_VALUE;
second_field = IP_EDITOR_MAX_FIELD_VALUE;
third_field = IP_EDITOR_MAX_FIELD_VALUE;
fourth_field = IP_EDITOR_MAX_FIELD_VALUE;
};
flags = 0;
}