Keresés

Aktív témák

  • flugi

    tag

    válasz tildy #56 üzenetére

    cserébe egy rajzolóprogram vagy egy okos jegyzettömb alig másfél HelloWorld ;)

  • flugi

    tag

    válasz tildy #53 üzenetére

    C++ Symbian kód, UIQ (vagyis Ericsson vonal) kiadásra egy hivatalos HelloWorld:

    Minden fájl neve bennevan kommentként.


    //////
    // HelloWorld.h
    // ------------
    //
    // Copyright (c) 2000 Symbian Ltd. All rights reserved.
    //

    ////////////////////////////////////////////////////////////////////
    // HelloWorld
    // ----------
    //
    //
    // The class definitions for the simple example application
    // containing a single view with the text ''Hello World !'' drawn
    // on it.
    //
    // The class definitions are:
    //
    // CExampleApplication
    // CExampleAppUi
    // CExampleAppView
    // CExampleDocument
    //
    //
    ////////////////////////////////////////////////////////////////////
    #ifndef __HELLOWORLD_H
    #define __HELLOWORLD_H

    #include <coeccntx.h>

    #include <eikenv.h>
    #include <eikappui.h>
    #include <eikapp.h>
    #include <eikdoc.h>
    #include <eikmenup.h>

    #include <eikon.hrh>

    #include <helloworld.rsg>
    #include ''helloworld.hrh''



    ////////////////////////////////////////////////////////////////////////
    //
    // CExampleApplication
    //
    ////////////////////////////////////////////////////////////////////////

    class CExampleApplication : public CEikApplication
    {
    private:
    // Inherited from class CApaApplication
    CApaDocument* CreateDocumentL();
    TUid AppDllUid() const;
    };

    ////////////////////////////////////////////////////////////////////////
    //
    // CExampleAppView
    //
    ////////////////////////////////////////////////////////////////////////
    class CExampleAppView : public CCoeControl
    {
    public:
    static CExampleAppView* NewL(const TRect& aRect);
    CExampleAppView();
    ~CExampleAppView();
    void ConstructL(const TRect& aRect);

    private:
    // Inherited from CCoeControl
    void Draw(const TRect& /*aRect*/) const;

    private:
    HBufC* iExampleText;
    };


    ////////////////////////////////////////////////////////////////////////
    //
    // CExampleAppUi
    //
    ////////////////////////////////////////////////////////////////////////
    class CExampleAppUi : public CEikAppUi
    {
    public:
    void ConstructL();
    ~CExampleAppUi();

    private:
    // Inherirted from class CEikAppUi
    void HandleCommandL(TInt aCommand);

    #if defined(_DEBUG)
    /* Only used in this application to add a Close item in Debug mode */
    void DynInitMenuPaneL(TInt aMenuId, CEikMenuPane* aMenuPane);
    #endif

    private:
    CCoeControl* iAppView;
    };


    ////////////////////////////////////////////////////////////////////////
    //
    // CExampleDocument
    //
    ////////////////////////////////////////////////////////////////////////
    class CExampleDocument : public CEikDocument
    {
    public:
    static CExampleDocument* NewL(CEikApplication& aApp);
    CExampleDocument(CEikApplication& aApp);
    void ConstructL();
    private:
    // Inherited from CEikDocument
    CEikAppUi* CreateAppUiL();
    };


    #endif



    // HelloWorld.hrh
    //
    // Copyright (c) 2000 Symbian Ltd. All rights reserved.
    //


    enum TExampleMenuCommands
    {
    EExampleItem0 = 200,
    EExampleItem1,
    EExampleItem2
    };

    // HelloWorld.mmp
    //
    // Copyright (c) 2002 Symbian Ltd. All rights reserved.
    //

    // using relative paths for sourcepath and user includes

    TARGET HelloWorld.app
    TARGETTYPE app
    UID 0x100039CE 0x101F6163
    TARGETPATH \system\apps\HelloWorld
    SOURCEPATH .
    SOURCE HelloWorld_Main.cpp
    SOURCE HelloWorld_Application.cpp
    SOURCE HelloWorld_Document.cpp
    SOURCE HelloWorld_AppUi.cpp
    SOURCE HelloWorld_AppView.cpp
    USERINCLUDE .
    SYSTEMINCLUDE \epoc32\include
    RESOURCE HelloWorld.rss
    LIBRARY euser.lib apparc.lib cone.lib eikcore.lib eikcoctl.lib
    // HelloWorld.RSS
    //
    // Copyright (c) 1997-1999 Symbian Ltd. All rights reserved.
    //

    NAME HEWO

    #include <eikon.rh>
    #include <eikcore.rsg>

    #include ''helloworld.hrh''

    RESOURCE RSS_SIGNATURE { }

    RESOURCE TBUF { buf=''''; }

    RESOURCE EIK_APP_INFO
    {
    hotkeys=r_example_hotkeys;
    menubar=r_example_menubar;
    }



    RESOURCE HOTKEYS r_example_hotkeys
    {
    control=
    {
    HOTKEY { command=EEikCmdExit; key='e'; }
    };
    }

    RESOURCE MENU_BAR r_example_menubar
    {
    titles=
    {
    MENU_TITLE { menu_pane=r_example_first_menu; txt=''HelloWorld''; }
    };
    }

    RESOURCE MENU_PANE r_example_first_menu
    {
    items=
    {
    MENU_ITEM { command=EExampleItem0; txt=''Item 0''; },
    MENU_ITEM { command=EExampleItem1; txt=''Item 1''; },
    MENU_ITEM { command=EExampleItem2; txt=''Item 2''; }
    };
    }


    RESOURCE TBUF r_example_text_Hello { buf=''Hello World!''; }
    RESOURCE TBUF r_example_text_Item0 { buf=''Item 0''; }
    RESOURCE TBUF r_example_text_Item1 { buf=''Item 1''; }
    RESOURCE TBUF r_example_text_Item2 { buf=''Item 2''; }
    RESOURCE TBUF r_example_close_command { buf=''Close (debug)''; }

    //// És most jön a lényeg :)

    // HelloWorld_CExampleApplication.cpp
    // ----------------------------------
    //
    // Copyright (c) 2002 Symbian Ltd. All rights reserved.
    //

    ////////////////////////////////////////////////////////////////////////
    //
    // Source file for the implementation of the
    // application class - CExampleApplication
    //
    ////////////////////////////////////////////////////////////////////////

    #include ''HelloWorld.h''

    const TUid KUidHelloWorld = { 0x101F6163 };

    // The function is called by the UI framework to ask for the
    // application's UID. The returned value is defined by the
    // constant KUidHelloWorlde and must match the second value
    // defined in the project definition file.
    //
    TUid CExampleApplication::AppDllUid() const
    {
    return KUidHelloWorld;
    }

    // This function is called by the UI framework at
    // application start-up. It creates an instance of the
    // document class.
    //
    CApaDocument* CExampleApplication:: CreateDocumentL()
    {
    return new (ELeave) CExampleDocument(*this);
    }



    // HelloWorld_CExampleAppView.cpp
    // ------------------------------
    //
    // Copyright (c) 2000 Symbian Ltd. All rights reserved.
    //

    ////////////////////////////////////////////////////////////////////////
    //
    // Source file for the implementation of the
    // application view class - CExampleAppView
    //
    ////////////////////////////////////////////////////////////////////////

    #include ''HelloWorld.h''

    //
    // Constructor for the view.
    //
    CExampleAppView:: CExampleAppView()
    {
    }


    // Static NewL() function to start the standard two
    // phase construction.
    //
    CExampleAppView* CExampleAppView::NewL(const TRect& aRect)
    {
    CExampleAppView* self = new(ELeave) CExampleAppView();
    CleanupStack:: PushL(self);
    self->ConstructL(aRect);
    CleanupStack:: Pop();
    return self;
    }


    //
    // Destructor for the view.
    //
    CExampleAppView::~CExampleAppView()
    {
    delete iExampleText;
    }


    // Second phase construction.
    //
    void CExampleAppView:: ConstructL(const TRect& aRect)
    {
    // Fetch the text from the resource file.
    iExampleText = iEikonEnv->AllocReadResourceL(R_EXAMPLE_TEXT_HELLO);
    // Control is a window owning control
    CreateWindowL();
    // Extent of the control. This is
    // the whole rectangle available to application.
    // The rectangle is passed to us from the application UI.
    SetRect(aRect);
    // At this stage, the control is ready to draw so
    // we tell the UI framework by activating it.
    ActivateL();
    }


    // Drawing the view - in this example,
    // consists of drawing a simple outline rectangle
    // and then drawing the text in the middle.
    // We use the Normal font supplied by the UI.
    //
    // In this example, we don't use the redraw
    // region because it's easier to redraw to
    // the whole client area.
    //
    void CExampleAppView:: Draw(const TRect& /*aRect*/) const
    {
    // Window graphics context
    CWindowGc& gc = SystemGc();
    // Area in which we shall draw
    TRect drawRect = Rect();
    // Font used for drawing text
    const CFont* fontUsed;

    // Start with a clear screen
    gc.Clear();
    // Draw an outline rectangle (the default pen
    // and brush styles ensure this) slightly
    // smaller than the drawing area.
    drawRect.Shrink(10,10);
    gc.DrawRect(drawRect);
    // Use the title font supplied by the UI
    fontUsed = iEikonEnv->TitleFont();
    gc.UseFont(fontUsed);
    // Draw the text in the middle of the rectangle.
    TInt baselineOffset=(drawRect.Height() - fontUsed->HeightInPixels())/2;
    gc.DrawText(*iExampleText,drawRect,baselineOffset,CGraphicsContext::ECenter, 0);
    // Finished using the font
    gc.DiscardFont();
    }




    // HelloWorld_CExampleAppUi.cpp
    // ----------------------------
    //
    // Copyright (c) 2002 Symbian Ltd. All rights reserved.
    //

    ////////////////////////////////////////////////////////////////////////
    //
    // Source file for the implementation of the
    // application UI class - CExampleAppUi
    //
    ////////////////////////////////////////////////////////////////////////

    // To enable the dynamic loading of the menu with a Close command in the UDEB version
    #include <eikmenub.h>

    #include ''HelloWorld.h''

    // The second phase constructor of the application UI class.
    // The application UI creates and owns the one and only view.
    //
    void CExampleAppUi:: ConstructL()
    {
    // BaseConstructL() completes the UI framework's
    // construction of the App UI.
    BaseConstructL();
    // Create the single application view in which to
    // draw the text ''Hello World!'', passing into it
    // the rectangle available to it.
    iAppView = CExampleAppView::NewL(ClientRect());
    }


    // The app Ui owns the two views and is.
    // therefore, responsible for destroying them
    //
    CExampleAppUi::~CExampleAppUi()
    {
    delete iAppView;
    }


    // Called by the UI framework when a command has been issued.
    // In this example, a command can originate through a
    // hot-key press or by selection of a menu item.
    // The command Ids are defined in the .hrh file
    // and are 'connected' to the hot-key and menu item in the
    // resource file.
    // Note that the EEikCmdExit is defined by the UI
    // framework and is pulled in by including eikon.hrh
    //
    void CExampleAppUi::HandleCommandL(TInt aCommand)
    {
    switch (aCommand)
    {
    // Just issue simple info messages to show that
    // the menu items have been selected
    case EExampleItem0:
    iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM0);
    break;


    case EExampleItem1:
    iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM1);
    break;

    case EExampleItem2:
    iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM2);
    break;
    // Exit the application. The call is
    // implemented by the UI framework.

    case EEikCmdExit:
    Exit();
    break;
    }
    }


    // This is a way to dynamically initialize the menu.
    // If it is the debug version, the menu should contain a Close command.
    // In the release version, there should be no Close command.
    #if defined(_DEBUG)
    void CExampleAppUi:: DynInitMenuPaneL(TInt aMenuId, CEikMenuPane* aMenuPane)
    {
    if(aMenuId == R_EXAMPLE_FIRST_MENU)
    {
    CEikMenuPaneItem::SData itemData;
    TBuf<16> closeCommandText;
    iEikonEnv->ReadResource(closeCommandText, R_EXAMPLE_CLOSE_COMMAND);
    itemData.iText=closeCommandText;
    itemData.iCommandId=EEikCmdExit;
    itemData.iFlags=0;
    itemData.iCascadeId=0;
    aMenuPane->AddMenuItemL(itemData);
    }
    }
    #endif
    // HelloWorld_CExampleDocument.cpp
    // -------------------------------
    //
    // Copyright (c) 2000 Symbian Ltd. All rights reserved.
    //

    ////////////////////////////////////////////////////////////////////////
    //
    // Source file for the implementation of the
    // document class - CExampleDocument
    //
    ////////////////////////////////////////////////////////////////////////

    #include ''HelloWorld.h''

    // The constructor of the document class just passes the
    // supplied reference to the constructor initialisation list.
    // The document has no real work to do in this application.
    //
    CExampleDocument:: CExampleDocument(CEikApplication& aApp)
    : CEikDocument(aApp)
    {
    }


    // This is called by the UI framework as soon as the
    // document has been created. It creates an instance
    // of the ApplicationUI. The Application UI class is
    // an instance of a CEikAppUi derived class.
    //
    CEikAppUi* CExampleDocument:: CreateAppUiL()
    {
    return new(ELeave) CExampleAppUi;
    }

    // HelloWorld_Main.cpp
    // -------------------
    //
    // Copyright (c) 2000 Symbian Ltd. All rights reserved.
    //

    ////////////////////////////////////////////////////////////////////////
    //
    // HelloWorld
    // ----------
    //
    //
    // The example is a simple application containing a single view with
    // the text ''Hello World !'' drawn on it.
    //
    // The example includes code for displaying a very simple menu.
    //
    // ---------------------------------------------------------------------
    //
    // This source file contains the single exported function required by
    // all UI applications and the E32Dll function which is also required
    // but is not used here.
    //
    ////////////////////////////////////////////////////////////////////////


    #include ''HelloWorld.h''

    // The entry point for the application code. It creates
    // an instance of the CApaApplication derived
    // class, CExampleApplication.
    //
    EXPORT_C CApaApplication* NewApplication()
    {
    return new CExampleApplication;
    }

    // This function is required by all EPOC32 DLLs. In this
    // example, it does nothing.
    //
    GLDEF_C TInt E32Dll(TDllReason)
    {
    return KErrNone;
    }


    /////////////////////
    Laza, mi? :D



    [Szerkesztve: szmájlikat kiírtottam amik a kódban a kettőspont-dé és hasonlók miatt jöttek be]

    [Szerkesztve]

Aktív témák