It is very troublesome to do a configuration window in brew, but the configuration list of s60 is quite convenient. In particular, the use of resource files to construct configuration pages. The content written in RSS is a bit complicated, but the code is much simplified.
First, let's look at the simple code. You need to construct a settingitemlist class that is derived from caknsettingitemlist:
Class cuninewssettingitemlist: Public caknsettingitemlist
...{
Public:
Void constructl ();
Caknsettingitem * createsettingiteml (tint aidentifier );
Public:
Tbool idown;
TTime itime;
};
Here, idown and itime are two items to be configured. (In this example, I need to ask the user to select "whether to automatically download" on the configuration page to determine the "Automatic download time ".)
In the implementation code, void cuninewssettingitemlist: constructl ()
...{
Caknsettingitemlist: constructfromresourcel (r_resource_item_list );
}
Caknsettingitem * cuninewssettingitemlist: createsettingiteml (tint aidentifier)
...{
Caknsettingitem * settingitem = NULL;
Switch (aidentifier)
...{
Case emysettingitembinary:
Settingitem =
New (eleave) caknbinarypopupsettingitem (
Aidentifier, idown );
Break;
Case emysettingitemtime:
Settingitem =
New (eleave) cakntimeordatesettingitem (
Aidentifier, cakntimeordatesettingitem: etime, itime );
Break;
}
Return settingitem;
}
In constructl, the basic class function is called to generate a configuration page from the resource. In the createsettingiteml function, the aidentifier is used to read the corresponding description from the resource file to generate a configuration item.
You can use caknbinarypopupsettingitem to create a bool configuration item. The second parameter of the constructor is the idown member. In this way, the configuration item is associated with the idown member. Similarly,
Cakntimeordatesettingitem instance, associated with the itime member. There are many related configuration items. You can find them in the SDK: api reference guide/C ++ api reference/UI framework/setting pages API.
The code is almost like this. It is similar to the common ListBox. You only need to pay attention to it when saving and loading it.
When the configuration page is displayed, remember to first let ilistbox-> loadsettingsl () Let ilistbox load data from the member variable, and at the same time, ilistbox-> storesettingsl () let the member variables get the configuration results from the configuration page.
Now let's take a look at the description in RSS, which is a little complicated compared to the code. Resource avkon_view r_view_cfg
{
CBA = r_avkon_softkeys_done_cancel;
}
Resource avkon_setting_item_list r_resource_item_list
{
Flags = eaknsettingitemnumberedstyle;
Title = qtn_cfg_title;
Initial_number = 1;
Items =
{
Avkon_setting_item
{
Identifier = emysettingitembinary;
Setting_page_resource = r_binary_setting_page;
Associated_resource = r_popup_setting_binary_texts;
Name = qtn_cfg_autodown;
},
Avkon_setting_item
{
Identifier = emysettingitemtime;
Setting_page_resource = r_time_setting_page;
Name = qtn_cfg_autotime;
}
};
}
Resource avkon_setting_page r_binary_setting_page
{
Number = 1;
Label = qtn_cfg_autodown;
Type = eaknctpopupsettinglist;
Editor_resource_id = r_binary_popup_setting_list;
}
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_cfg_autodown_on ;},
Avkon_enumerated_text {value = 0; text = qtn_assist_autodown_off ;}
};
}
Resource array r_popped_up_on_off_texts
{
Items =
{
Lbuf {TXT = qtn_cfg_autodown_on ;},
Lbuf {TXT = qtn_cfg_autodown_off ;}
};
}
Resource popup_setting_list r_binary_popup_setting_list
{
Flags = 0;
}
Resource avkon_setting_page r_time_setting_page
{
Number = 2;
Label = qtn_cfg_autotime;
Type = eeikcttimeeditor;
Editor_resource_id = r_settinglist_time_editor;
}
Resource time_editor r_settinglist_time_editor
{
Mintime = Time
{
Second = 0;
Minute = 0;
Hour = 0;
};
Maxtime = Time
{
Second = 59;
Minute = 59;
Hour = 23;
};
}
I also adapted the information I found online. Although it looks a little more, it is still quite regular to understand it. It should be easier than writing a bunch of things in code.
In fact, the configuration page can be dynamically generated in the code without relying on the description in the resource file. But that is too complicated. I will study it later.