×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Feb 2007
    Posts
    14

    Redrawing & Windows

    I begin with graphics in Symbian OS and I would have a drawing (representing 3 cursors with a rectangle of selection) and update it when the user choose a submenu (softkey).
    I've written this code but it doesn't work properly :

    View.cpp
    CBasicDrawingView::~CBasicDrawingView()
    {
    if (iContainer)
    {
    AppUi()->RemoveFromViewStack(*this, iContainer);
    delete iContainer;
    }
    }

    CBasicDrawingView* CBasicDrawingView::NewL()
    {
    CBasicDrawingView* self = CBasicDrawingView::NewLC();
    CleanupStack::Pop(self);
    return self;
    }


    CBasicDrawingView* CBasicDrawingView::NewLC()
    {
    CBasicDrawingView* self = new (ELeave) CBasicDrawingView();
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }


    void CBasicDrawingView::ConstructL()
    {
    BaseConstructL(R_BASICDRAWING_VIEW);
    }


    TUid CBasicDrawingView::Id() const
    {
    return KViewId;
    }


    void CBasicDrawingView::HandleCommandL(TInt aCommand)
    {
    switch (aCommand)
    {
    case EAknSoftkeyBack:
    {
    AppUi()->HandleCommandL(EEikCmdExit);
    break;
    }
    case ECommandRight:
    {
    iContainer->MoveSelectRight();
    );
    break;
    }
    default:
    {
    AppUi()->HandleCommandL(aCommand);
    break;
    }
    }
    }

    void CBasicDrawingView::DoActivateL(
    const TVwsViewId& /*aPrevViewId*/,
    TUid /*aCustomMessageId*/,
    const TDesC8& /*aCustomMessage*/)
    {
    if (!iContainer)
    {
    iContainer = CBasicDrawingContainer::NewL(ClientRect());
    iContainer->SetMopParent(this);
    AppUi()->AddToStackL(*this, iContainer);
    }
    }

    void CBasicDrawingView::DoDeactivate()
    {
    if (iContainer)
    {
    AppUi()->RemoveFromViewStack(*this, iContainer);
    }

    delete iContainer;
    iContainer = NULL;
    }

    Container.cpp

    CBasicDrawingContainer* CBasicDrawingContainer::NewL(const TRect& aRect)
    {
    CBasicDrawingContainer* self = CBasicDrawingContainer::NewLC(aRect);
    CleanupStack::Pop(self);
    return self;
    }

    CBasicDrawingContainer* CBasicDrawingContainer::NewLC(const TRect& aRect)
    {
    CBasicDrawingContainer* self = new (ELeave) CBasicDrawingContainer();
    CleanupStack::PushL(self);
    self->ConstructL(aRect);
    return self;
    }


    void CBasicDrawingContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();
    SetRect(aRect);
    ActivateL();
    }

    CBasicDrawingContainer::~CBasicDrawingContainer()
    {
    }

    void CBasicDrawingContainer::Draw(const TRect& /*aRect*/) const
    {
    CWindowGc& gc = SystemGc();
    gc.Clear();
    gc.SetPenColor(colorBlack);
    gc.SetPenStyle(CGraphicsContext::ESolidPen);
    gc.SetPenSize(penSize);
    gc.DrawLine(point1, point2);
    gc.DrawLine(point3, point4);
    gc.DrawLine(point5, point6);

    gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushColor(colorBlack);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.SetPenSize(penSize);
    gc.DrawRect(curseurLeft);
    gc.SetPenStyle(CGraphicsContext::ENullPen);
    gc.SetBrushColor(colorBlack);
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.SetPenSize(penSize);
    gc.DrawRect(curseurMed);
    gc.DrawRect(curseurRight);
    gc.SetPenColor(colorYellow);
    gc.SetPenStyle(CGraphicsContext::ESolidPen);
    gc.SetBrushStyle(CGraphicsContext::ENullBrush);
    gc.SetPenSize(penSize);
    gc.DrawRect(selectLeft);
    }

    void CBasicDrawingContainer::MoveSelectRight()
    {
    CWindowGc& gc = SystemGc();
    gc.Activate(Window());
    Window().BeginRedraw();

    gc.SetPenColor(colorWhite);
    gc.SetPenStyle(CGraphicsContext::ESolidPen);
    gc.SetBrushStyle(CGraphicsContext::ENullBrush);
    gc.SetPenSize(penSize);
    gc.DrawRect(selectLeft);
    gc.SetPenColor(colorYellow);
    gc.SetPenStyle(CGraphicsContext::ESolidPen);
    gc.SetBrushStyle(CGraphicsContext::ENullBrush);
    gc.SetPenSize(penSize);
    gc.DrawRect(selectMed);

    Window().EndRedraw();
    gc.Deactivate();
    }

    Ui.cpp
    void CBasicDrawingAppUi::ConstructL()
    {
    BaseConstructL();
    CEikStatusPane* sp = StatusPane();
    iNaviPane = (CAknNavigationControlContainer*)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
    CBasicDrawingView* basicView = CBasicDrawingView::NewLC();
    AddViewL(basicView);
    CleanupStack::Pop(basicView);
    SetDefaultViewL(*basicView);
    }

    CBasicDrawingAppUi::~CBasicDrawingAppUi()
    {
    delete iDecoratedTabGroup;
    }

    void CBasicDrawingAppUi::HandleCommandL(TInt aCommand)
    {
    switch (aCommand)
    {
    case EEikCmdExit:
    {
    Exit();
    break;
    }
    default:
    break;
    }
    }

    ************
    The Draw() function initializes the drawing.
    When the user choose a softkey associated to the command ECommandRight, the function MoveSelectRight() is called so the yellow and white (to clear the first yellow) rectangles appear in an other window, which superimpose itself on the first, which becomes blurred. If the user continues to press the softkey, the first drawing finaly dissapears.

    In fact, I believe that a new window is created when MoveSelectRight() is called. My problem is that I would update my first drawing and so always use the same window. How do this ?
    Furthermore Draw() is often called by the framework, what reinitializes the drawing, while it's not desired.

    I need help because it's important for me.
    If somebody has ideas to do this or knows a good method, it would be nice.
    Thanks in advance.

  2. #2
    Regular Contributor
    Join Date
    Mar 2007
    Location
    Brazil
    Posts
    103

    Re: Redrawing & Windows

    Bump! I also would like to know.

  3. #3
    Registered User
    Join Date
    Aug 2006
    Location
    europe
    Posts
    35

    Re: Redrawing & Windows

    Normally you should not handle the redraw yourself, you should rely on the window server. You can request a redraw event by using the method DrawDeferred(). If you really need to draw immediately, you can use DrawNow().
    The window server keeps track of the current window order, so a draw will be clipped by the window server against any window that might be in front of yours.

Similar Threads

  1. Porting a Windows C application under S60 2nd edition
    By goodslaurels in forum Symbian C++
    Replies: 1
    Last Post: 2007-05-10, 07:13
  2. Suggestion:Why don't Nokia get rid of Windows?
    By rockrockrockrockrockrock in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2007-04-20, 12:45
  3. Infrared socket connection between Symbian device and Windows
    By vespe in forum Symbian Networking & Messaging (Closed)
    Replies: 15
    Last Post: 2003-10-10, 16:50
  4. TCP socket connection between Symbian device and Windows
    By raghucp in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2003-09-15, 10:15
  5. D211: new Windows Drivers/SDK & Support for Windows 2003?
    By bsmuehmer in forum Multimodecards
    Replies: 1
    Last Post: 2003-08-08, 12:21

Posting Permissions

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