Symbian 各种资源的定义

转载 2007年09月30日 17:47:00
各种资源的定义

一、最基本的定义格式
/* Copyright (c) 2002, Nokia. All rights reserved */

NAME HELL  //资源的ID。在一个项目内保证无重复名称

#include <eikon.rh>        //必须的一些内部结构和常量的定义
#include <eikon.rsg>       //必须的一些内部结构和常量的定义
#include <avkon.rh>        //必须的一些内部结构和常量的定义
#include <avkon.rsg>       //必须的一些内部结构和常量的定义
#include "HelloWorld.hrh"  //自定义的一些内部结构和常量的定义

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

//  以下两个不许在任何程序中做任何修改
//    This resource should be empty.

RESOURCE RSS_SIGNATURE { }

//    Default Document Name

RESOURCE TBUF r_default_document_name { buf=""; }

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

//标识菜单和快捷键的资源ID

RESOURCE EIK_APP_INFO
{
    menubar = r_helloworld_menubar;
    cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
}

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

// 定义菜单

RESOURCE MENU_BAR r_helloworld_menubar
{
    titles =
        {
        MENU_TITLE {menu_pane = r_helloworld_menu;}
        };
}

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

// 定义子菜单

RESOURCE MENU_PANE r_helloworld_menu
{
    items =
        {
        MENU_ITEM {command = EHelloWorldCommand1;  txt = "Hello";},

        //如果有子菜单,那么加入cascade = r_aknexlist_item_menu;这里

        // RESOURCE MENU_PANE r_aknexlist_item_menu

        MENU_ITEM {command = EAknSoftkeyExit;   txt = "Exit";}
        };
}



/* 定义了字符串资源。虽然这里是小写。但是在程序中引用时必须全部大写。这个和symbian的编译器相关。他把rss的资源串编译到< SDK_installation_directory>/include路径下,成为rsg文件。而CPP实际上#include的是这个rsg 文件。*/

RESOURCE TBUF32 r_hewb_command1_text { buf=qtn_hewb_command1_text; }

RESOURCE TBUF32 r_hewb_caption_string { buf=qtn_hewb_caption_string; }



// End of File



                    

二、关于对话框的定义:
1、  定义一个对话框资源

//构造方式:

    CMmssSendDialog* iSendDialog = new ( ELeave ) CMmssSendDialog;

    iSendDialog->SetMopParent( this );

    iSendDialog->ExecuteLD( R_MMSSEND_DIALOG );

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



RESOURCE DIALOG r_mmssend_dialog

    {

        flags =   EEikDialogFlagNoDrag |    // 无法拖曳

                  EEikDialogFlagNoTitleBar |  //无标题栏

                  EEikDialogFlagFillAppClientRect | //将应用程序客户区填满

                  EEikDialogFlagCbaButtons |  //使用CBA按钮

EEikDialogFlagModeless;   //不接受按钮事件

//以上可以参见SDK  :Developer Library ? API Reference ? C++ API reference ? UIKLAFGT

    buttons = R_AVKON_SOFTKEYS_OPTIONS_EXIT;

    form = r_mmssend_form;

    }



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

//默认的单行显示模式

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

//可以设置为double行显示


RESOURCE FORM r_mmssend_form

    {

    flags = EEikFormEditModeOnly |

EEikFormUseDoubleSpacedFormat;

//Specify a style of form optionally. The default setting is single line display.
//1、EEikFormUseDoubleSpacedFormat : Double line display.
//2、EEikFormHideEmptyFields : To make empty data fields Invisible.
//3、EEikFormShowBitmaps : To display a bitmap on a label.
//4、EEikFormEditModeOnly : To display the form in edit mode only.

    items =

        {

        DLG_LINE

            {

type = EEikCtEdwin;    //是一个编辑文本框 Editor window

//实际上这个是枚举类型,可参看SDK:

//Developer Library ? API Reference ? C++ API reference ? UIKLAFGT ? UIKLAFGT Resource Constants ? TEikStockControls

    prompt = qtn_mmssend_recipient_prompt;// 这个控件的label显示的字符串

            id = EMmsRecipientEditor;

            control = EDWIN

                {

                flags = EEikEdwinNoHorizScrolling | EEikEdwinResizable;

                width = qtn_mmssend_recipient_width;

                maxlength = qtn_mmssend_recipient_maxlenght;

                default_input_mode = EAknEditorNumericInputMode;//数字输入模式

                };

},


           DLG_LINE

            {

            type = EEikCtEdwin;

               prompt = qtn_mmssend_subject_prompt;

            id = EMmsSubjectEditor;

            control = EDWIN

                {

                flags = EEikEdwinNoHorizScrolling | EEikEdwinResizable;

                width = qtn_mmssend_subject_width;

                maxlength = qtn_mmssend_subject_maxlenght;

                default_input_mode = EAknEditorTextInputMode;//文本输入模式

                };

            }



           };

}

三、定义AVKON_VIEW:
该类相当于新的view函数。

构造函数的承载

BaseConstructL( R_AKNEXLIST_VIEW_COLUMNVIEW );

//--------------------------资源-----------------------------------------------------

RESOURCE AVKON_VIEW r_aknexlist_view_columnview

    {

    menubar = r_aknexlist_menubar_main;

    hotkeys = r_aknexlist_hotkeys;

}

四、定义LISTBOX:
构造LISTBOX:

1)

resourceId = R_AKNEXLIST_MENULIST_SINGLE_NUMBER_HEADING;

//可以用祖先     CEikFormattedCellListBox* iListBox;在类中先申明该对象。调用的使用可以根据需要创建需要的派生类。
listBox = new(ELeave)CAknSingleStyleListBox();

listBox->SetContainerWindowL( parent);
TResourceReader reader;
CEikonEnv::Static()->CreateResourceReaderLC(reader, aResourceId);
listBox->SetObserver(observer);
listBox->ConstructFromResourceL( reader );
CleanupStack::PopAndDestroy(); // resource stuffs.





2) CEikColumnListBox* iColListBox;
CEikFormattedCellListBox* iForListBox;

iColListBox = new (ELeave) CAknSingleStyleListBox();
iForListBox = new (ELeave) CAknDoubleGraphicStyleListBox();

iColListBox->SetContainerWindowL( *this );
iForListBox->SetContainerWindowL( *this );

//从资源文件中生成LISTBOX
TResourceReader reader;
CEikonEnv::Static()->CreateResourceReaderLC( reader, R_TEST_SINGLE);
iColListBox->ConstructFromResourceL( reader );

CEikonEnv::Static()->CreateResourceReaderLC( reader, R_TEST_DOUBLE);
iForListBox->ConstructFromResourceL( reader );

//设置SCROLLBAR
iColListBox->CreateScrollBarFrameL( ETrue );
iColListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );

iForListBox->CreateScrollBarFrameL( ETrue );
iForListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );

//适合窗口大小
iColListBox->SetRect(Rect());
iForListBox->SetRect(Rect());

//激活
iColListBox->ActivateL();
iForListBox->ActivateL();

//--------------------------样式一览参观-----------------------------------------------------------
// CAknDoubleStyleListBox

  
//CAknDoubleNumberStyleListBox();

  
//CAknDoubleLargeStyleListBox()


//CAknDoubleStyleListBox();


//CAknDoubleLargeStyleListBox();

  
//-----------------listbox属性-------------------------------------------------------

RESOURCE LISTBOX r_aknexlist_menulist_single_number_heading

    {

    array_id = r_aknexlist_item_single_number_heading;

    flags = EAknListBoxMenuList;

    }

RESOURCE ARRAY r_aknexlist_item_single_number_heading

    {

    items =

        {

        LBUF

            {

            txt = “item1”;

            },

        LBUF

            {

            txt = ”item2”;

            },

        LBUF

            {

            txt = ”item3”;

            },

        LBUF

            {

            txt = ”item4”;

            },

        LBUF

            {

            txt = ”item5”;

            },

        LBUF

            {

            txt = ”item6”;

            }

        LBUF

            {

            txt = ”item7”;

            }

        };

    }







五、定义Tedit:
CEikLabel*  iLabel2;//定义标签

        CEikEdwin*  iEdwin;//定义edit.

CEikGlobalTextEditor*   iGTextEd;//定义基本上同edit


--------------------资源------------------------------------------

RESOURCE GTXTED r_aknexeditor_view1_gtexted

    {

    flags = EAknEditorFlagDefault;

    width = qnn_aknexeditor_view1_gtexted_width;

    height = qnn_aknexeditor_view1_gtexted_height;

    numlines = qnn_aknexeditor_view1_gtexted_numlines;

    textlimit= qnn_aknexeditor_view1_gtexted_textlimit;

    fontcontrolflags = EGulFontControlAll;

    fontnameflags = EGulNoSymbolFonts;

    }

----------------------------------------------------------------------



iCoeEnv->ReadResource( text, R_AKNEXEDITOR_VIEW1_LABEL1);

------------------------------资源-------------------------------------------------------

RESOURCE TBUF32 r_aknexeditor_view1_label1

    {

    buf = qtn_aknexeditor_label_edwin;

    }

--------------------------------------------------------------------------------------------------

    iLabel2 = new ( ELeave ) CEikLabel;

    iLabel2->SetContainerWindowL( *this ); //设置附着的容器

    iLabel2->SetTextL( text );

    iLabel2->SetExtent( GTEXTED_LABEL_POS, iLabel1->MinimumSize() );



    TResourceReader reader;

    iCoeEnv->CreateResourceReaderLC( reader, R_AKNEXEDITOR_VIEW1_EDWIN );

//将资源数据读入

    iEdwin = new ( ELeave ) CEikEdwin;

    iEdwin->SetContainerWindowL( *this );//设置附着的容器

    iEdwin->ConstructFromResourceL( reader );

    //将资源和iEdwin关联。

iEdwin ->SetExtent( position, iEdwin ->MinimumSize() );

// 其中TPoint position;设置主要的控件位置

// 以下是设置情况 Edwins

iEdwins->SetAknEditorCase( EAknEditorUpperCase );

//->SetAknEditorCase( EAknEditorLowerCase );

//->SetAknEditorCase( EAknEditorTextCase );

--------------------------资源----------------------------------------------------------------------

RESOURCE EDWIN r_aknexeditor_view1_edwin

    {

    flags = EAknEditorFlagDefault;

    width = qnn_aknexeditor_view1_edwin_width;

    lines= qnn_aknexeditor_view1_edwin_height;

    maxlength = qnn_aknexeditor_view1_edwin_maxlength;

    }

------------------------------------------------------------------------------------------------------------

    CleanupStack::PopAndDestroy();  // Resource reader

    iEdwin->SetExtent( EDWIN_POS, iEdwin->MinimumSize() );

iEdwin->SetFocus( ETrue );//设置控件的焦点。





六、字符串数组类:
CDesCArrayFlat* items =

iCoeEnv->ReadDesCArrayResourceL( R_AKNEXEDITOR_VIEW5_LABELS );

CleanupStack::PushL( items );

---------------------------资源定义---------------------------------------------------------



RESOURCE ARRAY r_aknexeditor_view5_labels

    {

    items =

        {

        LBUF { txt = qtn_aknexeditor_view5_label1; },

        LBUF { txt = qtn_aknexeditor_view5_label2; },

        LBUF { txt = qtn_aknexeditor_view5_label3; },

        LBUF { txt = qtn_aknexeditor_view5_label4; },

        LBUF { txt = qtn_aknexeditor_view5_label5; },

        LBUF { txt = qtn_aknexeditor_view5_label6; }

        };

    }

七、如何控制多个面版(view)
1、  CAknNavigationControlContainer* iNaviPane;

CAknTabGroup*                   iTabGroup;

CAknNavigationDecorator*        iDecoratedTabGroup;

CAknTitlePane*                  iTitlePane;

CAknExEditorScenarioManager*    iScenarioManager;

TUid                            iCurrentViewId;

2、CEikStatusPane *sp = StatusPane();

iTitlePane =

  static_cast<CAknTitlePane*>( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );

    iNaviPane = ( CAknNavigationControlContainer* ) sp->ControlL(

        TUid::Uid( EEikStatusPaneUidNavi ) );

    iDecoratedTabGroup = iNaviPane->ResourceDecorator();

    if ( iDecoratedTabGroup )

        {

        iTabGroup = ( CAknTabGroup* ) iDecoratedTabGroup->DecoratedControl();

        }

    // 屏幕管理器

iScenarioManager = new ( ELeave ) CAknExEditorScenarioManager;

3、各种VIEW后,加入调用

// Create and add views.

    CAknExEditorView1* view1 = new ( ELeave ) CAknExEditorView1;

    CleanupStack::PushL( view1 );

    view1->ConstructL();

    CleanupStack::Pop();    // view1

    AddViewL( view1 );        //加入调用

    CAknExEditorView4* view4 = new ( ELeave ) CAknExEditorView4;

    CleanupStack::PushL( view4 );

    view4->ConstructL();

    CleanupStack::Pop();    // view4

AddViewL( view4 );        //加入调用

4、激活一个VIEW:

ActivateViewL( view1->Id() );

//-----------------------实现--------------------------

void CAknExEditorAppUi::ActivateViewL( TUid aViewId )

    {

    ActivateLocalViewL( aViewId );

    iCurrentViewId = aViewId;



    TBuf<KTitleBufLength> newTitle;

    iScenarioManager->GetTitle( aViewId, &newTitle );

    iTitlePane->SetTextL( newTitle );

    }

5、实现前翻、后翻

void CAknExEditorAppUi::ActivateNextViewL()

    {

    TUid viewId = iScenarioManager->NextViewTo( iCurrentViewId );

    if ( viewId == TUid::Uid( KScenarioNotFound ) )

        {

        viewId = iScenarioManager->FirstViewId();

        }

    ActivateViewL( viewId );

    }



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

// CAknExEditorAppUi::ActivatePrevViewL()

// Activates previous view.

// ( other items were commented in a header ).

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

//

void CAknExEditorAppUi::ActivatePrevViewL()

    {

    TUid viewId = iScenarioManager->PrevViewTo( iCurrentViewId );

    if ( viewId == TUid::Uid( KScenarioNotFound ) )

        {

        viewId = iScenarioManager->LastViewId();

        }

    ActivateViewL( viewId );

    }



八、MCoeControlObserver接口:
这个接口可以直接派生出VIEW的容器类

class CAknExEditorContainer : public CCoeControl, McoeControlObserver

这种容器类可以在view的容器上嵌入相关的edit、label等组件。而不是用

GC来直接操作这些界面元素。



在view类中如何调用:



    private:

        void DoActivateL( const TVwsViewId& /*aPrevViewId*/,

                          TUid /*aCustomMessageId*/,

                          const TDesC8& /*aCustomMessage*/ );//创建容器类

        void DoDeactivate();//删除容器类

        CAknExEditorContainer1* iContainer;//-------------------implentment---------------------

void CAknExEditorView1::DoActivateL( const TVwsViewId& /*aPrevViewId*/,

                                     TUid /*aCustomMessageId*/,

                                     const TDesC8& /*aCustomMessage*/ )

    {

    iContainer = new ( ELeave ) CAknExEditorContainer1;

    iContainer->SetMopParent( this );

    iContainer->ConstructL( ClientRect() );

    AppUi()->AddToStackL( *this, iContainer );

    }

    void CAknExEditorView1::DoDeactivate()
    {

        if ( iContainer )
        {
          AppUi()->RemoveFromStack( iContainer );

        }

    delete iContainer;

    iContainer = NULL;

    }
 
来源:http://tb.blog.csdn.net/TrackBack.aspx?PostId=637286

相关文章推荐

Symbian 显示中文资源

文章比较老,但有借鉴价值。 本文使用的模拟器为S60 2.1 Chinese版SDK附带的,此模拟器支持中文,其他英文版本的模拟器不在本文讨论范围之内。1.  将中文字符串定义在单独头文件中,用记事本...

Symbian 资源文件解析 .

一、何为资源文件: 在symbian应用程序中,资源文件指的是后缀名为.rss的文件,每个应用程序至少要有一个与之关联的资源文件。资源编译器rcomp编译资源文件后,生成一个.rsc二进制文件和一个...

symbian下实现自定义模态对话框

大家可能对自定义控件有所了解,其实自定义对话框和自定义控件类似。但是自定义模态对话的实现最关键的地方就是进行阻塞。比如: CAknInformationNote* pNote = new(ELeav...

S60:symbian 自定义TabGroup [转]

一直没有时间来总结工作中学到的东西,也在一直想做一个自己的自定义控件库。也许是有点懒的缘故,但是真正当自己需要用这些东西的时候又要到处去寻找答案,去搜寻自己所做的项目的时候却发现还是把一下小小的零件拆...

android下res目录 资源定义及使用

1、  颜色 #RGB #ARGB #RRGGBB #AARRGGBB 颜色资源应该位于标签下 路径res/values/colors.xml  名字可以随意定义value 使用 Reso...

Symbian 资源浅析

  • 2009-09-22 12:43
  • 224KB
  • 下载

Android res文件夹下资源定义及使用

1、  颜色 #RGB #ARGB #RRGGBB #AARRGGBB   颜色资源应该位于标签下   路径res/values/colors.xml 名字可以随意   定义value ...
  • wm111
  • wm111
  • 2012-03-05 10:48
  • 1278
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)