×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    24

    About window views

    Does anybody has any idea of how to create two window view in an applications ( like in 9200 or 9500)? Here is some useful info on window views. But I am unable to figures out how to do it?

    Only the active, selected window has a frame and a drop shadow. Also, if needed, the active window is emphasized by the title bar, which resides only in the active frame . The inactive window's title is black and has a Title line underneath. The selection bar is visible only in the active window. In some cases, selection of the inactive window needs to be indicated, and then the selection bar is a simple frame with a white background. This occurs, for example, when one list item is selected on the left window and its content is presented in the right window and the right window is activated and the selection bar resides on the right window. The width of the left window depends on the view. At maximum it takes half of the Application Area, but preferably should be narrower (minimum one-third of the Application Area). The width of the details window (that is, the right window) depends on the CBA. The margins are 4 pixels to the Application Area borders. The space between windows is 7 pixels.

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,165
    Hi

    You are propably looking for this piece of code. Can't really remember where I found this, but it was a long time ago. Anyway no gredits for me for the code.

    yucca

    //-start of code

    CTitledView, a generic Symbian Crystal view using the CCknAppTitle control
    The CCknAppTitle control provides a title bar as used in most Crystal applications. The simple view class below shows how to use it properly.

    CTitledView definition
    #ifndef __TITLEDVIEW_H__
    #define __TITLEDVIEW_H__

    #include <ckntitle.h>
    #include <cknitlbx.h>
    #include <cknlbv.h>


    class CTitledView : public CCoeControl
    {
    public:
    static CTitledView* NewL(const TRect& aRect, const TDesC &aTitle);
    CTitledView();
    ~CTitledView();
    virtual void ConstructL(const TRect& aRect, const TDesC &aTitle);

    virtual void Draw(const TRect& aRect) const;
    virtual void SetFocus(TBool aFocus, TDrawNow aDrawNow=ENoDrawNow);

    protected:
    void CreateTitleControlL(const TRect& aRect, const TDesC &aTitle);
    void DrawFocusShadow() const;
    virtual CCoeControl *ComponentControl(TInt aIndex) const;
    virtual TInt CountComponentControls() const;

    private:
    CCknAppTitle *iViewTitleControl;
    };

    #endif



    CTitledView implementation
    #include "TitledView.h"
    #include <EIKENV.H>

    #define RIGHTANDBOTTOMMARGINTICKNESS 6

    CTitledView::CTitledView()
    {
    }


    CTitledView *CTitledView::NewL(const TRect& aRect, const TDesC &aTitle)
    {
    CTitledView *self = new(ELeave) CTitledView();
    //
    // methods that can leave and wrapped around push and pop
    // this garatees that if an exception occures, the object will be cleaned and all.
    //
    CleanupStack::PushL(self);
    self->ConstructL(aRect, aTitle);
    CleanupStack::Pop();
    return self;
    }

    CTitledView::~CTitledView()
    {
    delete iViewTitleControl;
    }

    void CTitledView::CreateTitleControlL(const TRect& aRect, const TDesC &aTitle)
    {
    iViewTitleControl = CCknAppTitle::NewL(CCknAppTitle::EList);
    iViewTitleControl->SetTextL(aTitle, CCknAppTitle::EMainTitle);
    TRect totalRectWoutMargins = aRect;
    totalRectWoutMargins.iBr.iX -= RIGHTANDBOTTOMMARGINTICKNESS;
    totalRectWoutMargins.iBr.iY -= RIGHTANDBOTTOMMARGINTICKNESS;
    TInt titleHeight = iViewTitleControl->MinimumSize().iHeight;
    titleHeight++;
    TRect titleRect(1, 1, totalRectWoutMargins.Width(), titleHeight);
    iViewTitleControl->SetRect(titleRect);
    }

    void CTitledView::ConstructL(const TRect& aRect, const TDesC &aTitle)
    {
    CreateWindowL();
    // CREATE TITLE CONTROL
    CreateTitleControlL(aRect, aTitle);

    // TODO : ADD YOUR OTHER CONTROLS HERE

    // COMPLETE VIEW SETUP
    SetRect(aRect);
    ActivateL();
    }

    void CTitledView::DrawFocusShadow() const
    {
    CWindowGc& gc = SystemGc();
    // DRAW CONTOUR
    TRect contourRect = Rect();
    contourRect.iBr.iX -= RIGHTANDBOTTOMMARGINTICKNESS-1;
    contourRect.iBr.iY -= RIGHTANDBOTTOMMARGINTICKNESS-1;
    gc.DrawRect(contourRect);
    // DRAW SHADOW
    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    gc.SetBrushColor(KRgbGray);
    gc.SetPenColor(KRgbGray);
    TRect rightShadowArea = Rect();
    rightShadowArea.iTl.iX = rightShadowArea.iBr.iX - RIGHTANDBOTTOMMARGINTICKNESS + 1;
    rightShadowArea.iTl.iY += RIGHTANDBOTTOMMARGINTICKNESS;
    gc.DrawRect(rightShadowArea);
    TRect bottomShadowArea = Rect();
    bottomShadowArea.iTl.iX += RIGHTANDBOTTOMMARGINTICKNESS + 1;
    bottomShadowArea.iTl.iY += bottomShadowArea.iBr.iY - RIGHTANDBOTTOMMARGINTICKNESS + 1;
    gc.DrawRect(bottomShadowArea);
    }

    void CTitledView::Draw(const TRect& /*aRect*/) const
    {
    CWindowGc& gc = SystemGc();
    gc.Clear();
    if (IsFocused())
    {
    DrawFocusShadow();
    }
    return;
    }

    CCoeControl *CTitledView::ComponentControl(TInt aIndex) const
    {
    switch (aIndex)
    {
    case 0:
    return iViewTitleControl;
    }
    return NULL;
    }


    TInt CTitledView::CountComponentControls() const
    {
    return 1;
    }

    void CTitledView::SetFocus(TBool aFocus, TDrawNow aDrawNow)
    {
    // This next line is important. It's what makes the CCknAppTitle display the appropriate apparence.
    if (iViewTitleControl) iViewTitleControl->SetFocus(aFocus, aDrawNow);
    CCoeControl::SetFocus(aFocus, aDrawNow);
    }



    Constructing the views
    void CExampleAppUi::ConstructL()
    {
    BaseConstructL();

    TRect rightRect = ClientRect();
    TRect leftRect = rightRect;
    rightRect.iTl.iX = leftRect.iBr.iX = rightRect.iTl.iX + (rightRect.Width()/4);
    iLeftView = CTitledView::NewL(leftRect, _L("Left"));
    iRightView = CTitledView::NewL(rightRect, _L("Right"));

    iLeftView->SetFocus(ETrue);
    iRightView->SetFocus(EFalse);
    iActiveView = iLeftView;
    }



    Switching focus
    TKeyResponse CExampleAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
    {
    TInt code = aKeyEvent.iCode;
    switch (code)
    {
    case EKeyRightArrow:
    {
    if (iActiveView == iLeftView)
    {
    if (iLeftView->OfferKeyEventL(aKeyEvent,aType) == EKeyWasNotConsumed)
    {
    iRightView->SetFocus(ETrue);
    iLeftView->SetFocus(EFalse);
    iLeftView->DrawNow();
    iRightView->DrawNow();
    iActiveView = iRightView;
    }
    return EKeyWasConsumed;
    }
    else return iActiveView->OfferKeyEventL(aKeyEvent,aType);
    }

    case EKeyLeftArrow:
    {
    if (iActiveView == iRightView)
    {
    if (iRightView->OfferKeyEventL(aKeyEvent,aType) == EKeyWasNotConsumed)
    {
    iLeftView->SetFocus(ETrue);
    iLeftView->DrawNow();
    iRightView->SetFocus(EFalse);
    iRightView->DrawNow();
    iActiveView = iLeftView;
    }
    return EKeyWasConsumed;
    }
    else return iActiveView->OfferKeyEventL(aKeyEvent,aType);
    }
    default: return iActiveView->OfferKeyEventL(aKeyEvent,aType);
    }
    return EKeyWasNotConsumed;
    }


    //-- end of code

Posting Permissions

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