×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    9

    CEikEdwin with background

    Hi

    I want a nice-looking form view.
    I have created a CEikEdwin element in which I can type and edit text. I have seen the std notepad application and want to do something like that.
    I.e I want to want to put an image in the background of the form element. This would create a paper feel to the form.

    I can see 2 approaches to this problem:
    1. I put an image as a CEikImage which covers the whole background of the view. I then put the form on top of the image and make the form transparent.

    2. I set the image as the background of the form element.

    I would lite to use approach 1 because then I could put several form elements on top of the same image.


    Best
    .tobias

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    391
    anybody accomplish this , any idea?

    use CEikEdwin or derive one from it or write a completely new Edit Control?

    thx!

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    9

    CEikEdwin with background

    I used CEikEdwin and placed an image on top of it. I had to re-draw the image after every key-event. Not a pretty solution so I hope there is a better solution available now.


    Tobias

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    391
    Hei, Have u ever try

    MFormCustomDraw.DrawBackground
    iLayout->SetCustomDraw();

    i did as below, but it seems take no effect.,My EditWin backgraound is always white,the derived draw method never be called . can u share me some of ur codes .


    class CSimpleEditor: public MFormCustomDraw,public CEikEdwin //CEikRichTextEditor
    {
    public:
    CSimpleEditor();
    ~CSimpleEditor();
    void Draw(const TRect& aRect) const;
    virtual void DrawBackground(const TParam& aParam,const TRgb& aBackground,TRect& aDrawn) const;

    private:
    CFbsBitmap* splash;
    };

    --------------------------------------------------------------------cpp
    //#include <w32std.h>
    #include <eikedwin.h>
    #include <gdi.h>
    #include <frmtlay.h>
    #include <eikenv.h>
    #include "SjAppUi.h"

    #include "SimpleEditor.h"

    CSimpleEditor::CSimpleEditor()
    {

    splash = new (ELeave) CFbsBitmap;
    LoadImageL(splash,_L("etc.mbm"),7);

    }

    CSimpleEditor::~CSimpleEditor()
    {
    delete splash;
    }

    void CSimpleEditor::Draw(const TRect& aRect) const
    {

    iLayout->SetCustomDraw(this);
    CEikEdwin::Draw(aRect);
    }

    void CSimpleEditor::DrawBackground(const TParam& aParam, const TRgb& /*aBackground*/,TRect& aDrawn) const
    {
    CGraphicsContext& gc = aParam.iGc;
    if(splash)
    {
    //CWindowGc& gc = SystemGc();
    gc.UseBrushPattern(splash);
    gc.SetBrushStyle(CGraphicsContext::EPatternedBrush);
    gc.DrawRect(aDrawn);
    }
    gc.SetBrushStyle(CGraphicsContext::ENullBrush);

    }
    Last edited by goready@163.com; 2005-04-19 at 08:33.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    391
    i try ur method and the backbround is still white, where did i do wrong?:

    --------------------------------------------------------------------------------.h file
    class CSimpleEditor: public MFormCustomDraw,public CEikEdwin //CEikRichTextEditor
    {
    public:
    CSimpleEditor();
    ~CSimpleEditor();
    void Draw(const TRect& aRect) const;
    virtual void DrawBackground(const TParam& aParam,const TRgb& aBackground,TRect& aDrawn) const;
    virtual void DrawLineGraphics(const TParam& aParam,const TLineInfo& aLineInfo) const;
    TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
    void AdjuestHeight();
    void ShowBandHeight();
    mutable TInt iLineSpace;
    TInt EditorLines;
    TBool bNeedDrawBackLine;

    private:
    CFbsBitmap* splash;
    };


    ------------------------------------------------------cpp file

    //#include <w32std.h>
    #include <eikedwin.h>
    #include <gdi.h>
    #include <frmtlay.h>
    #include <eikenv.h>
    #include "SjAppUi.h"

    #include "SimpleEditor.h"

    CSimpleEditor::CSimpleEditor()
    {
    splash = new (ELeave) CFbsBitmap;
    CSjAppUi::LoadImageL(splash,_L("etc.mbm"),10);

    }

    CSimpleEditor::~CSimpleEditor()
    {
    delete splash;
    }

    void CSimpleEditor::Draw(const TRect& aRect) const
    {

    CWindowGc& gc = SystemGc();
    if(splash)
    {
    gc.UseBrushPattern(splash);
    gc.SetBrushStyle(CGraphicsContext::EPatternedBrush);
    gc.DrawRect(aRect);
    }


    CEikEdwin::Draw(aRect);
    }

    TKeyResponse CSimpleEditor::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
    {
    TKeyResponse res = CEikEdwin::OfferKeyEventL(aKeyEvent, aType);
    Window().Invalidate(Rect());
    return res;
    }

  6. #6
    Registered User
    Join Date
    May 2003
    Posts
    9

    CEikEdwin with background

    Well, I did not go as deep into the problem as you are ;)
    I used at std CEikEdwin, placed an image on top of it and made sure that the image was drawn after the CEikEdwin object.
    This made it look like there was lines in the background of the edit-field.

    To make sure the lines was always there I wrote my own OfferKeyEventL function to re-draw the image after each event.

    TKeyResponse CVykortContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
    {
    TInt code=aKeyEvent.iCode;
    ........

    iBackgroundImage->DrawNow();
    return EKeyWasNotConsumed;
    }

    As I said.. Not pretty but I was satisfied.

    /Tobias

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    391
    thx, i understand. but what i need is the whole background to be a bitmap not only lines

  8. #8
    Registered User
    Join Date
    May 2003
    Posts
    9

    CEikEdwin with background

    That is what I wanted also.

    It would be so nice to be able to set a transperancy on std UI-objects like CEikEdwin. Then you could make really cool applicationUI's.

    Here is what my application ended up like. I just created the first version for Nokia 7650 and 3650 but I think the UI has not changed that much.

    http://wap.posten.se/


    /Tobias

  9. #9
    Super Contributor
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037
    Hi kummel2,

    I have probably simillar problem as all of you, what I need are lines in CEikEdwin like in SMS application. For more details you could look onto http://discussion.forum.nokia.com/fo...hreadid=58327, where I described my problem. I downloaded your application "Posten vykort", it looked nice and work on my 6600 ans SE900 without prblem. It is a pity that it is not translated into english...

    I saw that when writing address there are lines in your edwin. They dont work super, because line below actual line I am writing dissapear, but may be it should be changed... I did what you explained: I create bitmap with lines and put it into my container Draw() method and than I called DrawNow() in OfferKeyEvent() method, but background is still white... Could you please put here the complete code??
    thanx
    STEN

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×