Helloworldbasic.rss 浅析

/*
* ==============================================================================
*  Name        : Helloworldbasic.rss
*  Part of      : Helloworldbasic
*  Description : 这里只是在讲RSS这个文件
*  Author        :宝杰
* ==============================================================================
*/

   进入今天的正题,以前我们看的代码都是系统默认的工程的,今天我们来看一个s60的例子,如何导入这个工程呢?我一步一步说明。

  需求:Carbide c++ V2.0 + Symbian SDK 9.2版本

   导入:打开carbide c++ -> file -> import ->Symbian OS bld.inf file -> next -> 选择你的路径,我的SDK安装在E,路径如:: E:/Symbian/9.2/S60_3rd_FP1/S60Ex/HelloWorldBasic/group ->选择bld.inf

一路Next就可以了;

  运行:按照上一节讲得快速调试方法,你可以建一个DLL的工程,方便调试;

   接下来进入今天的正题,我们一起学习RSS文件,高手可以路过,我这就是当自己的读书笔记的。


//  RESOURCE IDENTIFIER

NAME HEWB     // 4 letter ID


在Include前居然还有这么一行,感觉和宏一般,看如下的解释

 

在 .rss资源文件 中,可以使用以下这些语句:

 

语句描述
NAME 四个大写字母,在文档开头处指定
STRUCT定义一个结构体,用于整合资源
RESOURCE定义资源
ENUM定义枚举类型 ,与C的语法类似
CHARACTER_SET定义在资源文件 中使用的字符集,如果是中文则可以使用

 

接下来是一堆Include 我们只要关心“ ”起来的部分就可以;

 

//  INCLUDES

#include <eikon.rh>

#include <avkon.rh>

#include <avkon.rsg>

#include <appinfo.rh>

#include "HelloWorldBasic.hrh"

#include "HelloWorldBasic.rls"


 

这样我们就来看Sc++文件系统

 

 

bld.inf    Build描述文件 //刚才导入的文件,我觉得是代表这个工程

.mmp     项目文件

.cpp       源文件           //熟悉

.h           头文件

.rhr         资源头文件     //上面有用到这个文件的类型,是一个头文件,在资源类中需要调用,

                                //这样以后用资  源类就可以包含头文件就可以了

.rss         资源定义文件  //今天学习的文件

.rls         字符串文件     //常量初始化文件,前几节讲过这个文件

.svg        矢量图文件

.mpm     位图文件

.pkg        打包文件       //发布程序SIS用到,这个证书申请本人正在学习

 

我觉得这两段代码不需要过多解释,读者可以自己看懂。

//  RESOURCE DEFINITIONS

// -----------------------------------------------------------------------------

//

//    Define the resource file signature

//    This resource should be empty.

//

// -----------------------------------------------------------------------------

//

RESOURCE RSS_SIGNATURE

    {

    }

 

// -----------------------------------------------------------------------------

//

//    Default Document Name

//

// -----------------------------------------------------------------------------

//

RESOURCE TBUF r_default_document_name

    {

    buf= "HEWB" ;

    }

 

这段代码就有味道了,EIK_APP_INFO 自己查看帮助,知道是在是用来定义很多如 menus, toolbars, status pane, toolbar, toolband, CBA (Control Button Array) and hotkeys的资源

// -----------------------------------------------------------------------------

//

//    Define default menu and CBA key.

//

// -----------------------------------------------------------------------------

//

RESOURCE EIK_APP_INFO

    {

    menubar = r_helloworldbasic_menubar;  

    cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT ;

    }


 那么我们的默认工程也是这样定义Menu的吗? 去看看去,果然如此,接下来也就顺理成章的定义Menu_Bar

// -----------------------------------------------------------------------------

//

//   r_menubar

//   Main menubar

//

// -----------------------------------------------------------------------------

//

RESOURCE MENU_BAR r_menubar

    {

    titles =

       {

       MENU_TITLE { menu_pane = r_menu; }

//这里只是定义了一个Pane,感觉和Java的Panel差不多,也许一个Menu_bar上可以替换多个Pane吧,现//在去查证下,似乎没法解决,希望高手路过解释下,今天老大没来上班

       };

    }

定义好了Menu_bar,就是定义了Menu_Pane,那么接下来定义的Pane我们似乎很熟悉吧,之前已经学习过,今天就可以跳过了

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->

// -----------------------------------------------------------------------------

//

//   r_helloworldbasic_menu

//   Menu for "Options"

//

// -----------------------------------------------------------------------------

//

RESOURCE MENU_PANE r_helloworldbasic_menu

    {

    items =

        {

        // added the new Options menu command here

        MENU_ITEM

                {

                command = EHelloWorldBasicCommand1;

                txt = STRING_r_hewb_command1;

                },

        MENU_ITEM

                {

                command = EHelloWorldBasicCommand2;

                txt = STRING_r_hewb_command2;

                },

        MENU_ITEM

                {

                command = EHelloWorldBasicCommand3;

                txt = STRING_r_hewb_command3;

                },

        MENU_ITEM

                {

                command = EAknSoftkeyExit;

                txt = STRING_r_hewb_exit;

                }

        };

    }

 

 

 

 

细心的读者可能发现,默认的工程中的TXT参数可都是红的啊,今天怎么变了了,自己查看默认工程,点击Txt红色文字(同时按住 Ctrl),发现跳转到了.rls文件,很多#defined,而今天我们的文件中有很多rls,每个中都有定义我们的这些变量常值。可是都不是用#defined,使用RLS_String,查看每个文件,相信读者都会明白是不同语言的定义,之后我们还看到一个rls文件,打开,看到:

 / /    自己查看注释相信不难理解意思。

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->

//  LOCALISATION STRINGS

 

#ifdef LANGUAGE_SC

#include "helloworldbasic_01.rls"    // default U.K. English

#elif defined LANGUAGE_01

#include "helloworldbasic_01.rls"    // U.K. English

#elif defined LANGUAGE_09

#include "helloworldbasic_09.rls"    // Finnish

#elif defined LANGUAGE_31

#include "helloworldbasic_31.rls"    // PRC Chinese

#elif defined LANGUAGE_32

#include "helloworldbasic_32.rls"    // Japanese

#endif

至于这个文件如何工作,等我查到了再不上,见谅。

 

回过头来,我们看RSS文件,接下来就是内容字符串的定义,请允许我这么叫,感觉我更能记忆

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->

// -----------------------------------------------------------------------------

//

// Resources for messages.

//

// -----------------------------------------------------------------------------

//

RESOURCE TBUF32 r_hewb_command1_text { buf=STRING_r_hewb_command1_text; }

RESOURCE TBUF32 r_hewb_file_text { buf=STRING_r_hewb_file_text; }

RESOURCE TBUF32 r_hewb_caption_string { buf=STRING_r_hewb_caption_string; }

 

r_hewb_command1_text等这些常量我们在真正的程序中用到,这个是给这个变量初始化赋值;

 

下面这段代码定义LOCALISABLE_APP_INFO

// ----------------------------------------------------------------------------

//

// r_helloworldbasic_localisable_app_info

//

// ----------------------------------------------------------------------------

//

RESOURCE LOCALISABLE_APP_INFO r_helloworldbasic_localisable_app_info

    {

    short_caption = STRING_r_hewb_caption_string;

    caption_and_icon =

    CAPTION_AND_ICON_INFO

        {

        caption = STRING_r_hewb_caption_string;

 

        number_of_icons = 1;

       icon_file = "//resource//apps//Helloworldbasic_aif.mif" ;

        };

    }

查看帮助知道

Unlike most resource files, because there is only one resource defined in the file, it does not need to include a four character NAME or an RSS_SIGNATURE resource, and the LOCALISABLE_APP_INFO resource does not need an ID .

帮助代码如下

RESOURCE LOCALISABLE_APP_INFO
    {
    short_caption = STRING_r_short_caption;
    caption_and_icon =
        {
        CAPTION_AND_ICON_INFO
            {
            caption = STRING_r_caption;
            number_of_icons = 3; // each icon must be a bitmap/mask pair
            icon_file = STRING_r_icon_file;
            }
        };                          
    }

对于以上的资源命名习惯个人觉得有时间可以多加研究。

 

最后,资源定义了r_dialog_text_edit_query,调试代码发现有个文本输入框,应该就是这个

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->

// ----------------------------------------------------------------------------

//

// r_dialog_text_edit_query

//

// ----------------------------------------------------------------------------

//

RESOURCE DIALOG r_dialog_text_edit_query

    {

    flags = EGeneralQueryFlags ;

    buttons = R_AVKON_SOFTKEYS_OK_CANCEL ;

    items =

        {

        DLG_LINE

            {

            type = EAknCtQuery;

            id = EGeneralQuery;

            control = AVKON_DATA_QUERY

                {

                layout = EDataLayout;

                label = "INPUT" ; //笔者自己调试个个属性,读者也可自己尝试

                control = EDWIN

                    {

                    width = 32;

                    maxlength = 32;

                    lines = 1;

                    };

                };

            }

        };

    }

时间也差不多了 饭来了 吃好后我们在继续……

博文完

Eleven

Thanks

<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值