×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    27

    Smile problem Kernel Exec 3 on adding CEikRichTextEditor in custom control

    Hello Friends,

    I am new in symbian technology . I am preparing custom control
    for Instant messaging like messenger.

    I am facing problem in adding the control CEikRichTextEditor;
    in my container.

    my code is as under
    Code:
    void CMyControl::ConstructL(const TRect& aRect,const CCoeControl* aParent)
        {
        // No owner, so create an own window
        if(aParent == NULL)     
            {
            CreateWindowL();
            }
        // Use Parent's window
        else
            {
            // This is component in a compound control
            SetContainerWindowL(*aParent);
            }
     
        // Initialize component array
        InitComponentArrayL();
     
        // Create contained controls
        iStatusText = new (ELeave) CEikLabel;
        iStatusText->SetContainerWindowL(*this);
        iStatusText->SetTextL(_L("Praveen"));
        
        iEditableText = new (ELeave)CEikRichTextEditor;
        
        // Store component to component array
        Components().AppendLC(iStatusText);
        Components().AppendLC(iEditableText);
        CleanupStack::Pop(iEditableText);
        CleanupStack::Pop(iStatusText);
        
        SetRect(aRect); // or
        //SetExtentToWholeScreen(); //NOTE: Can not see CBA buttons
     
        // The application should call this function on 
        // all controls that are not components in a compound control
        if(aParent == NULL)     
            {
            ActivateL(); 
            }
        }
    I am getting Kernel Exec 3 at ActivateL() function.
    In iEditableText is my editor instance.

    How can i add it in my custom control.

    Thanks,

    Praveen.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,671

    Re: problem Kernel Exec 3 on adding CEikRichTextEditor in custom control

    Show your CountComponentControls and ComponentControl methods.
    Or first: make sure that both of them has the "const" at the end.

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    27

    Re: problem Kernel Exec 3 on adding CEikRichTextEditor in custom control

    Hi Wizard_Hu,

    here are the CountComponentControls and ComponentControl methods
    Code:
    CMyControl* CMyControl::NewL(const TRect& aRect,const CCoeControl* aParent)
        {
        CMyControl* self = CMyControl::NewLC(aRect,aParent);
        CleanupStack::Pop(self);
        return self;
        }
     
    CMyControl* CMyControl::NewLC(const TRect& aRect,const CCoeControl* aParent)
        {
        CMyControl* self = new(ELeave) CMyControl();
        CleanupStack::PushL(self);
        self->ConstructL(aRect,aParent);
        return self;
        }
     
    CMyControl::CMyControl()
        {
        }
     
    CMyControl::~CMyControl()
        {
        // NOTE: Does not delete iStatusText because we do not own it
        }
     
    void CMyControl::ConstructL(const TRect& aRect,const CCoeControl* aParent)
        {
        // No owner, so create an own window
        if(aParent == NULL)     
            {
            CreateWindowL();
            }
        // Use Parent's window
        else
            {
            // This is component in a compound control
            SetContainerWindowL(*aParent);
            }
     
        // Initialize component array
        InitComponentArrayL();
     
        // Create contained controls
        iStatusText = new (ELeave) CEikLabel;
        iStatusText->SetContainerWindowL(*this);
        iStatusText->SetTextL(_L("Praveen"));
        
        iEditableText = new (ELeave)CEikRichTextEditor;
        
        // Store component to component array
        Components().AppendLC(iStatusText);
        Components().AppendLC(iEditableText);
        CleanupStack::Pop(iEditableText);
        CleanupStack::Pop(iStatusText);
        
        SetRect(aRect); // or
        //SetExtentToWholeScreen(); //NOTE: Can not see CBA buttons
     
        // The application should call this function on 
        // all controls that are not components in a compound control
        if(aParent == NULL)     
            {
            ActivateL(); 
            }
        }
     
    TSize CMyControl::MinimumSize()
        {
        // Get CEikLabel minium size and grow it
        // that is this control MinimumSize.
        // Custom control also needs a few other methods so it can be laid out
        // and drawn. For example, custom controls usually implement MinimumSize(),
        // SizeChanged() and Draw() methods.
     
        // When using control in container control, set the minium size very small
        TRect rect = iStatusText->MinimumSize();
        rect.Grow(TSize(2,2));
        TRect editrect = iEditableText->MinimumSize();
        editrect.Grow(TSize(30,20));
        return Rect().Size();
     
        // When using the control in a dialog, set the control size large
        //return Rect().Size();
        }
     
    void CMyControl::SizeChanged()
        {
        // Responds to size changes to set the size and position of the contents
        // of this control. For a simple control this might include text or
        // graphics. For a compound control this sets the size and position of the
        // component. It has an empty default implementation and should be 
        // implemented by the CCoeControl-derived class.
        // The function is called whenever SetExtent(), SetSize(), SetRect(),
        // SetCornerAndSize(), or SetExtentToWholeScreen() are called on 
        // the control.
        if (iStatusText)
            {
            TRect labelRect(Rect());
            labelRect.Shrink(TSize(15,20));
            iStatusText->SetRect(labelRect);
            }
        if(iEditableText)
        	{
        	 TRect EditorRect(Rect());
        	 EditorRect.Shrink(TSize(50,20));
        	}
        }
     
    void CMyControl::Draw(const TRect& /*aRect*/) const
        {
        CWindowGc& gc = SystemGc();
        gc.SetBrushColor(KRgbGray);
        gc.Clear(Rect());
        }
    CCoeControl* CMyControl::ComponentControl(TInt aIndex) const
    {
    	switch ( aIndex )
    	{
    		case 0:
    			return iStatusText;
    		case 1:
    		    return iEditableText;
    		default:
    	    	return NULL;
    	}
    }
    
    
    
    TInt CMyControl::CountComponentControls() const
    {
    	return 2;
    }

    Thanks,
    Praveen
    Last edited by praveenp; 2008-05-15 at 06:33.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,671

    Re: problem Kernel Exec 3 on adding CEikRichTextEditor in custom control

    Note that your editor needs
    - ConstructL
    - SetContainerWindow
    You can find an example in http://discussion.forum.nokia.com/fo...ad.php?t=82396 though it is a bit old.

  5. #5
    Registered User
    Join Date
    May 2008
    Posts
    28

    Re: problem Kernel Exec 3 on adding CEikRichTextEditor in custom control

    how to add CEikRichTextEditor & image in custom control

    can anyone tel us abt

    email me at vi_ragha@yahoo.com & vijayaraghavan@inxsasia.com

    regds
    Vijay

  6. #6
    Super Contributor
    Join Date
    Jul 2007
    Posts
    596

    Re: problem Kernel Exec 3 on adding CEikRichTextEditor in custom control

    have u searched in wiki . Go thrrogh below link and try with some

    keyword CEikRichTextEditor or image some thing like that.

    http://wiki.forum.nokia.com/index.php/Wiki_Home


    Thanks

  7. #7
    Registered User
    Join Date
    May 2008
    Posts
    28

    Re: problem Kernel Exec 3 on adding CEikRichTextEditor in custom control

    hi kishore,

    how to add CEikRichTextEditor & image in custom control and as well as scrollbar for that window... suppose am creating 4 richtext editor,listbox,image in the UI design. i like to use scroll bar for those control.. so tel me how to create custom scrollbar for those controls


    regds
    Vijay

    email me: vi_ragha@yahoo.com / vijayaraghavan@inxsasia.com

  8. #8
    Registered User
    Join Date
    May 2008
    Posts
    28

    Re: problem Kernel Exec 3 on adding CEikRichTextEditor in custom control

    hi,

    how to set the height of the each listbox item in the custom draw list...

    rightnow, am using SetItemHeight(4*size.iHeight);
    but i have to change the height of the each row item

    is tat possible r not
    CCustomListItemDrawer::CCustomListItemDrawer(const CEikTextListBox& aListBox)
    :CListItemDrawer(),
    iListBox(aListBox)
    {
    // Store a GC for later use
    iGc = &CCoeEnv::Static()->SystemGc();
    SetGc(iGc);
    }

    CCustomListItemDrawer::~CCustomListItemDrawer()
    {
    DeleteIconArray();
    }


    void CCustomListItemDrawer::DrawActualItem(TInt aItemIndex,
    const TRect& aActualItemRect, TBool aItemIsCurrent,
    TBool /*aViewIsEmphasized*/, TBool /*aViewIsDimmed*/,
    TBool aItemIsSelected) const
    {
    const MDesCArray* itemArray = iListBox.Model()->ItemTextArray();

    if ((!itemArray) || (itemArray->MdcaCount() <= aItemIndex))
    return;

    // Gets the item text if the conditions above are met.
    TPtrC itemText = itemArray->MdcaPoint(aItemIndex);
    // We have to find the position of tabs to decide the components
    // available in the item text (icon, heading and text).
    TInt tabPosition1 = itemText.Locate('\t');
    TInt tabPosition2 = itemText.Mid(tabPosition1 + 1).Locate('\t');
    if (tabPosition2 >= 0)
    {
    // We need to add tabPosition1 because the return value of
    // Locate() is relative to tabPosition1.
    tabPosition2 += tabPosition1 + 1;
    }

    // Sets the attributes to draw the icon.
    iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
    if ((aItemIsCurrent) || (aItemIsSelected))
    {
    iGc->SetBrushColor(TRgb(255,214,193));
    iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
    }
    else
    {
    // TRgb backColor( 255,190,125);
    if(aItemIndex%2==0)
    {
    iGc->SetBrushColor(TRgb(215,235,255));
    iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
    }
    else
    {

    iGc->SetBrushColor(TRgb(250,252,254));
    iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
    }
    }

    // Gets the icon index, i.e. the number in the text item before
    // the first tab.
    TInt iconIndex = 0;
    if (tabPosition1 > 0)
    {
    TLex(itemText.Mid(0, tabPosition1)).Val(iconIndex);
    }
    if ((iIconArray) && (iIconArray->Count() > iconIndex)
    && (tabPosition1 > 0))
    {
    // Draws the icon.
    const TRect& tmp=aActualItemRect;


    CFbsBitmap* bitmap = (*iIconArray)[iconIndex]->Bitmap();
    iGc->BitBltMasked(
    TPoint(aActualItemRect.iTl.iX,aActualItemRect.iTl.iY),
    bitmap,
    TRect(TPoint(0, 0), bitmap->Header().iSizeInPixels),
    (*iIconArray)[iconIndex]->Mask(),
    ETrue);

    // Draws the rectangle, just in case there are some icons that are
    // smaller than the height of item width and/or height.
    iGc->SetPenStyle(CGraphicsContext::ENullPen);
    if (bitmap->Header().iSizeInPixels.iHeight < aActualItemRect.Height())
    {
    TRect rect(
    aActualItemRect.iTl.iX,
    aActualItemRect.iTl.iY + bitmap->Header().iSizeInPixels.iHeight,
    aActualItemRect.iTl.iX + iMaxIconSize.iWidth,
    aActualItemRect.iBr.iY);
    iGc->DrawRect(rect);
    }

    if (bitmap->Header().iSizeInPixels.iWidth < iMaxIconSize.iWidth)
    {
    TRect rect = TRect(
    aActualItemRect.iTl.iX + bitmap->Header().iSizeInPixels.iWidth,
    aActualItemRect.iTl.iY,
    aActualItemRect.iTl.iX + iMaxIconSize.iWidth,
    aActualItemRect.iBr.iY);
    iGc->DrawRect(rect);
    }
    }
    else
    {
    iGc->SetPenStyle(CGraphicsContext::ENullPen);
    TRect rect(
    (aActualItemRect.iBr.iX)*75/100,
    aActualItemRect.iTl.iY,
    aActualItemRect.iTl.iX + iMaxIconSize.iWidth,
    aActualItemRect.iBr.iY);
    iGc->DrawRect(rect);
    }

    // Sets the attributes to draw text, except the font.
    const CFont* font = Font(aItemIndex);
    iGc->SetPenStyle(CGraphicsContext::ESolidPen);
    iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
    if ((aItemIsCurrent) || (aItemIsSelected))
    {
    iGc->SetPenColor(iHighlightedTextColor);
    //iGc->SetBrushColor(iHighlightedBackColor);
    iGc->SetBrushColor(TRgb(255,214,193));
    iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
    }
    else
    {
    iGc->SetPenColor(iTextColor);
    //iGc->SetBrushColor(iBackColor);
    if(aItemIndex%2==0)
    {
    iGc->SetBrushColor(TRgb(215,235,255));
    iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
    }
    else
    {

    iGc->SetBrushColor(TRgb(250,252,254));
    iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
    }
    }

    // If there is only one tab, it means we have to display single line item
    if (tabPosition2 < 0)
    {
    if (!font)
    {
    font = CEikonEnv::Static()->LegendFont();
    }
    iGc->UseFont(font);
    TRect textRect(
    TPoint(aActualItemRect.iTl.iX,// + iMaxIconSize.iWidth,
    aActualItemRect.iTl.iY),
    aActualItemRect.iBr);
    TInt baseline =
    (textRect.iBr.iY - textRect.iTl.iY - font->HeightInPixels()) / 2
    + font->AscentInPixels();

    if (tabPosition1 < 0)
    {
    iGc->DrawText(itemText, textRect, baseline,
    CGraphicsContext::ELeft, 1);
    }
    else
    {
    iGc->DrawText(itemText.Mid(tabPosition1 + 1), textRect, baseline,
    CGraphicsContext::ELeft, 1);
    }
    }
    else
    {
    // If there are more than one tab, then we have to display double line
    // item text
    TRect textRect(
    TPoint(aActualItemRect.iTl.iX,// + iMaxIconSize.iWidth,
    aActualItemRect.iTl.iY),
    aActualItemRect.iBr);
    textRect.iBr.iY -= aActualItemRect.Height() / 2;

    // Draws the first line.
    if (!font)
    {
    font = CEikonEnv::Static()->LegendFont();
    }
    iGc->UseFont(font);
    TPtrC outputText = AknTextUtils::ChooseScalableText(
    itemText.Mid(tabPosition1 + 1, tabPosition2 - tabPosition1 - 1),
    *font, textRect.iBr.iX);
    CFont::TMeasureTextOutput* iOutput;
    TInt iTextWidth = font->MeasureText(outputText,NULL,NULL);


    if(aItemIsSelected)
    {


    TInt highlightwidth = font->TextWidthInPixels(itemText.Left(aActualItemRect.iBr.iY));
    TRect highlighted = aActualItemRect;
    highlighted.SetWidth(highlightwidth);
    TPoint topleft(aActualItemRect.iTl.iX + highlightwidth, aActualItemRect.iTl.iY);
    TRect unhighlighted(topleft, aActualItemRect.iBr);

    iGc->DrawText(itemText.Left(aActualItemRect.iBr.iY),highlighted,(font->AscentInPixels() + aActualItemRect.Height())/2);
    iGc->SetBrushColor(KRgbWhite);
    iGc->DrawText(itemText.Mid(aActualItemRect.iBr.iY),unhighlighted,(font->AscentInPixels() + aActualItemRect.Height())/2);

    }
    else{
    TInt baseline =
    (textRect.iBr.iY - textRect.iTl.iY - font->HeightInPixels()) / 2
    + font->AscentInPixels();
    iGc->DrawText(
    itemText.Mid(tabPosition1 + 1, tabPosition2 - tabPosition1 - 1),
    textRect, baseline, CGraphicsContext::ELeft, 1);

    if ((iIconArray) && (iIconArray->Count() > iconIndex))
    {
    CFbsBitmap* bitmap = (*iIconArray)[iconIndex]->Bitmap();
    iGc->BitBltMasked(
    TPoint((aActualItemRect.iBr.iX)*75/100,aActualItemRect.iTl.iY),
    bitmap,
    TRect(TPoint(0, 0), bitmap->Header().iSizeInPixels),
    (*iIconArray)[iconIndex]->Mask(),
    ETrue);

    // Draws the rectangle, just in case there are some icons that are
    // smaller than the height of item width and/or height.
    iGc->SetPenStyle(CGraphicsContext::ENullPen);
    if (bitmap->Header().iSizeInPixels.iHeight < aActualItemRect.Height())
    {
    TRect rect(
    (aActualItemRect.iBr.iX)*75/100,
    aActualItemRect.iTl.iY + bitmap->Header().iSizeInPixels.iHeight,
    aActualItemRect.iTl.iX+ iMaxIconSize.iWidth,
    aActualItemRect.iBr.iY);
    iGc->DrawRect(rect);
    }

    if (bitmap->Header().iSizeInPixels.iWidth < iMaxIconSize.iWidth)
    {
    TRect rect = TRect(
    (aActualItemRect.iBr.iX)*75/100+ bitmap->Header().iSizeInPixels.iWidth,
    aActualItemRect.iTl.iY,
    aActualItemRect.iTl.iX + iMaxIconSize.iWidth,
    aActualItemRect.iBr.iY);
    iGc->DrawRect(rect);
    }

    }
    // Draws the second line. For the second line, we use normal font.
    font = CEikonEnv::Static()->LegendFont();
    iGc->UseFont(font);
    textRect.Move(0, aActualItemRect.Height() / 2);
    textRect.iTl.iX=0;
    baseline =
    (textRect.iBr.iY - textRect.iTl.iY - font->HeightInPixels()) / 2
    + font->AscentInPixels();

    iGc->DrawText(itemText.Mid(tabPosition2 + 1), textRect, baseline,
    CGraphicsContext::ELeft, 1);
    }
    }
    }

    void CCustomListItemDrawer::SetIconArray(CArrayPtr<CGulIcon>* aIconArray)
    {
    DeleteIconArray();
    iIconArray = aIconArray;
    CalculateMaxIconSize();
    }

    TSize CCustomListItemDrawer::MaxIconSize() const
    {
    return iMaxIconSize;
    }

    void CCustomListItemDrawer::DeleteIconArray()
    {
    if (iIconArray)
    {
    iIconArray->ResetAndDestroy();
    delete iIconArray;
    iIconArray = 0;
    }
    }

    void CCustomListItemDrawer::CalculateMaxIconSize()
    {
    iMaxIconSize = TSize(0, 0);

    // Finds the maximum width and height of the icon.
    if (iIconArray)
    {
    for (TInt i = 0; i < iIconArray->Count(); i++)
    {
    TInt width = (*iIconArray)[i]->Bitmap()->Header().iSizeInPixels.iWidth;
    if (iMaxIconSize.iWidth < width)
    {
    iMaxIconSize.iWidth = width;
    }

    TInt height = (*iIconArray)[i]->Bitmap()->Header().iSizeInPixels.iHeight;
    if (iMaxIconSize.iHeight < height)
    {
    iMaxIconSize.iHeight = height;
    }
    } // for
    } // iIconArray
    }


    // --------------------------------------------------------------------------
    // CCustomListBox
    // --------------------------------------------------------------------------

    CCustomListBox::CCustomListBox()
    :CEikTextListBox()
    {
    }

    void CCustomListBox::ConstructL(const CCoeControl* aParent, TInt aFlags)
    {
    CEikTextListBox::ConstructL(aParent, aFlags);
    }

    void CCustomListBox::CreateItemDrawerL()
    {
    iItemDrawer = new (ELeave) CCustomListItemDrawer(*this);
    }

  9. #9
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,671

    Re: problem Kernel Exec 3 on adding CEikRichTextEditor in custom control

    It would be preferable if you would be the one who locates the panicking statement (if any, actually you just dumped more than 300 line of unformatted, uncommented code without saying a single word about it, so I just guess that you have a panic, due to the title of the thread) using a debugger (enable Just In Time debugging in emulator preferences, then your code will stop on the panic, and your last line will be in the call stack).
    And remember to use [CODE ] and [/CODE ] tags (without the spaces) in the future, as the original poster did. By the way, this thread was about having an editor, what are you doing with your listbox here?

  10. #10
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    68

    Re: problem Kernel Exec 3 on adding CEikRichTextEditor in custom control

    you should add

    iEditableText->SetContainerWindowL(*this);
    and some others set actions just like

    iEditableText->SetExtent();
    iEditableText->ActivateL();

    after the following line i think,

    iEditableText = new (ELeave)CEikRichTextEditor;



    Quote Originally Posted by praveenp View Post
    Hello Friends,

    I am new in symbian technology . I am preparing custom control
    for Instant messaging like messenger.

    I am facing problem in adding the control CEikRichTextEditor;
    in my container.

    my code is as under
    Code:
    void CMyControl::ConstructL(const TRect& aRect,const CCoeControl* aParent)
        {
        // No owner, so create an own window
        if(aParent == NULL)     
            {
            CreateWindowL();
            }
        // Use Parent's window
        else
            {
            // This is component in a compound control
            SetContainerWindowL(*aParent);
            }
     
        // Initialize component array
        InitComponentArrayL();
     
        // Create contained controls
        iStatusText = new (ELeave) CEikLabel;
        iStatusText->SetContainerWindowL(*this);
        iStatusText->SetTextL(_L("Praveen"));
        
        iEditableText = new (ELeave)CEikRichTextEditor;
        
        // Store component to component array
        Components().AppendLC(iStatusText);
        Components().AppendLC(iEditableText);
        CleanupStack::Pop(iEditableText);
        CleanupStack::Pop(iStatusText);
        
        SetRect(aRect); // or
        //SetExtentToWholeScreen(); //NOTE: Can not see CBA buttons
     
        // The application should call this function on 
        // all controls that are not components in a compound control
        if(aParent == NULL)     
            {
            ActivateL(); 
            }
        }
    I am getting Kernel Exec 3 at ActivateL() function.
    In iEditableText is my editor instance.

    How can i add it in my custom control.

    Thanks,

    Praveen.

Similar Threads

  1. Problem about Progress Bar Control
    By tommylkc in forum Symbian User Interface
    Replies: 9
    Last Post: 2007-10-03, 04:38
  2. Edwin control problem
    By msulaiman in forum Symbian
    Replies: 2
    Last Post: 2007-09-16, 14:30
  3. PIM API adding new contacts problem
    By hoppelmoppel in forum Mobile Java General
    Replies: 3
    Last Post: 2007-04-22, 17:12
  4. Custom control in CAknDialog
    By Diamond in forum Symbian User Interface
    Replies: 5
    Last Post: 2007-02-27, 12:14
  5. Problem of install nokia_c110 on linux
    By nonexist in forum Multimodecards
    Replies: 1
    Last Post: 2002-12-13, 10: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
  •  
×