×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 21

Hybrid View

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    34

    can i make a custom control

    Hi,
    1>I need a multiselection listbox with 3 columns- name, distance and rating.with action to be taken on each row selected and multiple rows can be selected How can i implement that?
    2>Also I need link to IMEI, phone number and cell id finding code.

    3>I am confused between HTTP and socket connection. Is it
    HTTP- send a request to server at any time and get response from server immediately
    Socket- keep connection established, send a request to server at any time and get response any time.

    Is there any other difference between them

  2. #2
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143

    Re: can i make a custom control

    1. Basically you might want to do a custom item from CCoeControl, and then another one hansling them in a list.
    2. You can not get MSISDN from teh device, but do check CTelephony for getting IMSI & IMEI
    3. You could mayeb use your favourite search engine for checking what HTTP is, anyway, as you already determined its Query-Response thingi, where teh connection is lost after the reply.

  3. #3
    Registered User
    Join Date
    Nov 2012
    Posts
    34

    Re: can i make a custom control

    hi Yucca,
    thanks for your reply.
    I got IMEI .
    next i require is custom listbox.

    the default display is like
    Code:
    ----------------------------
    item1
    item2
    item3
    ----------------------------
    I need a display like
    Code:
    ------------------------------
    name    distance   rating
    item1     100m        7
    item2     200m       11
    item 3    300m       15
    ------------------------------
    ----------------------------------------------------------------------------------
    If you chose one row you get option"call"
    If you chose multiple options you get option "send voice message"
    -----------------------------------------------------------------------------------
    Can i implement that?
    As you have written , we can derive a custom control from CCoentrol
    What next?
    Can you elaborate on it?


    regards!
    Sandeep
    Last edited by sandeepmhptr3; 2012-12-07 at 09:46.

  4. #4
    Nokia Developer Expert
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,143

    Re: can i make a custom control

    Basically I suggested making one custom control that acts as a listbox, and each line is then an instance of another custom control, in which you would draw the name/distance/rating into the screen. Not certain how I could explain more on the idea.

  5. #5
    Registered User
    Join Date
    Nov 2012
    Posts
    34

    Re: can i make a custom control

    Hi, I tried this way
    1>if the approach is correct
    2>I am unable to dra text from control

    Code:
    class CCustomListBox : public CCoeControl, MCoeControlObserver
    	{
    public:
    	// Constructors and destructor
    
    	/**
    	 * Destructor.
    	 */
    	~CCustomListBox();
    
    	/**
    	 * Two-phased constructor.
    	 */
    	static CCustomListBox* NewL(const TRect& aRect);
    
    	/**
    	 * Two-phased constructor.
    	 */
    	static CCustomListBox* NewLC(const TRect& aRect);
    
    private:
    
    	/**
    	 * Constructor for performing 1st stage construction
    	 */
    	CCustomListBox();
    
    	/**
    	 * EPOC default constructor for performing 2nd stage construction
    	 */
    	void ConstructL(const TRect& aRect);
    private: // Functions from base classes
    
           /**
            * From CoeControl,SizeChanged.
            */
            void SizeChanged();
    
           /**
            * From CoeControl,CountComponentControls.
            */
            TInt CountComponentControls() const;
    
           /**
            * From CCoeControl,ComponentControl.
            */
            CCoeControl* ComponentControl(TInt aIndex) const;
    
           /**
            * From CCoeControl,Draw.
            */
            void Draw(const TRect& aRect) const;
    
           /**
            * From CCoeControl, HandleControlEventL.
            */
            // event handling section
            // e.g Listbox events
            void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
            
    
    	};
    
    #endif // CUSTOMLISTBOX_H
    Code:
    #include "CustomListBox.h"
    
    CCustomListBox::CCustomListBox()
    	{
    	// No implementation required
    	}
    
    CCustomListBox::~CCustomListBox()
    	{
    	}
    
    CCustomListBox* CCustomListBox::NewLC(const TRect& aRect)
    	{
    	CCustomListBox* self = new (ELeave) CCustomListBox();
    	CleanupStack::PushL(self);
    	self->ConstructL(aRect);
    	return self;
    	}
    
    CCustomListBox* CCustomListBox::NewL(const TRect& aRect)
    	{
    	CCustomListBox* self = CCustomListBox::NewLC(aRect);
    	CleanupStack::Pop(); // self;
    	return self;
    	}
    
    void CCustomListBox::ConstructL(const TRect& aRect)
    	{
    
    	}
    
           /**
            * From CoeControl,SizeChanged.
            */
            void CCustomListBox::SizeChanged()
            	{
            	
            	}
    
           /**
            * From CoeControl,CountComponentControls.
            */
            TInt CCustomListBox::CountComponentControls() const
            	{
            	return 0;
            	}
    
           /**
            * From CCoeControl,ComponentControl.
            */
            CCoeControl* CCustomListBox::ComponentControl(TInt aIndex) const
            	{
            	switch ( aIndex )
            	        {
            	        
            	        default:
            	            return NULL;
            	        }
            }
    
           /**
            * From CCoeControl,Draw.
            */
            void CCustomListBox::Draw(const TRect& aRect) const
            	{
            	_LIT(KText,"ABC");
            	CWindowGc& gc = SystemGc();
            	//CFont* fontUsed = ->TitleFont();
            	//gc.UseFont(fontUsed);
    
            	    gc.SetPenStyle(CGraphicsContext::ESolidPen);
            	    gc.SetBrushColor(KRgbWhite);
            	    gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
            	    gc.DrawRect(aRect);
            	    gc.SetBrushColor(KRgbBlack);
            	    gc.DrawText(KText,TPoint(20,20));
            	    
            	}
    
           /**
            * From CCoeControl, HandleControlEventL.
            */
            // event handling section
            // e.g Listbox events
            void CCustomListBox::HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType)
            	{
            	
            	}
    Last edited by sandeepmhptr3; 2012-12-07 at 11:13.

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,568

    Re: can i make a custom control

    DrawText can not work without a font (and there is no default font selected), so the commented part is necessary, just the left side of the -> is missing. Place the iEikonEnv back there (or a "CEikonEnv::Static()"), and solve the compiler error via #include-ing eikenv.h.

  7. #7
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,956

    Re: can i make a custom control

    Did you tried the code with those font using lines commented?, i am quite sure the code must have panicked in such case if any draw text statement is encountered.

  8. #8
    Registered User
    Join Date
    Nov 2012
    Posts
    34

    Re: can i make a custom control

    selection of an item is done.

    1> I need custom menupane- 2 options are there call, send voice message
    a>when no item is selected both are disabled
    b>when 1 item is selected both are enabled
    c> when multiple items are selected only send voice message is enabled

    I tried with DynInitMenuPanel in view, but no results.
    Last edited by sandeepmhptr3; 2012-12-15 at 09:25.

  9. #9
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,956

    Re: can i make a custom control

    DynInitMenuPanel should be good to do that. You can take up an integer variable & store the different states in that(For e.g: no item: iItemState=0, one selected: iItemState=1,&multiple:iItemState=2) & check for these values inside the DynInitMenuPanel & hide-unhide the menu option accordingly.

    Also remember to use the MENU_PANE id(from rss) inside the DynInitMenuPanel not MENU_BAR

    For scrolling you can implement a ScrollBar in your container, but you need to synchronize its movement with that of your custom listbox. A related wiki article is also present:
    http://www.developer.nokia.com/Commu...tainer_control

    Alternatively as suggested you can also handle the drag case inside the HandlePointerEventL() for the movement of listbox(the up & down movement will depend on positioning the control)

  10. #10
    Registered User
    Join Date
    Nov 2012
    Posts
    34

    Re: can i make a custom control

    I included the lines:
    CFont* fontUsed = const_cast<CFont*>(CEikonEnv::Static()->TitleFont());
    gc.UseFont(fontUsed);
    it does not help.

    also I tried with
    _LIT(KText,"ABC");
    TBidiText* iText=TBidiText::NewL(KText,1);
    const CCoeFontProvider& fontProvider = FindFontProvider();
    const CFont& font = fontProvider.Font(TCoeFont::LegendFont(), AccumulatedZoom());

    XCoeTextDrawer textDrawer( TextDrawer() );
    textDrawer.SetAlignment(EHCenterVCenter);
    textDrawer.DrawText(gc, KText, aRect, font);

    No results


    I read that controls should have public constructor, so I made both
    constructor and constructL() public

    Now I want to know how to over ride ActivateL() and how the Rect variable is passed to Draw()?
    Last edited by sandeepmhptr3; 2012-12-07 at 12:56.

  11. #11
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,956

    Re: can i make a custom control

    I do not see the following lines in the ConstructL() of this CCoeControl derived class:

    void CCustomListBox ::ConstructL(const TRect& aRect)
    {
    // Create a window for this application view
    CreateWindowL();

    // Set the windows size
    SetRect(aRect);

    // Activate the window, which makes it ready to be drawn
    ActivateL();
    }

  12. #12
    Registered User
    Join Date
    Nov 2012
    Posts
    34

    Re: can i make a custom control

    Now I am able to draw. thanks

  13. #13
    Registered User
    Join Date
    Nov 2012
    Posts
    34

    Re: can i make a custom control

    I am adding lines to the custom Listbox

    1>adding line Control in void CCustomListBox::AppendLine() does not have anny effect, only constructl() does the drawing
    ConstructL is called 1st time that control is drawn. Next time onwards CCustomListBox::AppendLine() is called.
    CCustomListBox::AppendLine() tries add new lines to list box, after once the list box has been drawn with some lines.



    Code:
    CCustomColumnOfLineOfListBox::CCustomColumnOfLineOfListBox()
    	{
    	// No implementation required
    	}
    
    CCustomColumnOfLineOfListBox::~CCustomColumnOfLineOfListBox()
    	{
    	}
    
    CCustomColumnOfLineOfListBox* CCustomColumnOfLineOfListBox::NewLC(const TRect& aRect)
    	{
    	CCustomColumnOfLineOfListBox* self = new (ELeave) CCustomColumnOfLineOfListBox();
    	CleanupStack::PushL(self);
    	self->ConstructL(aRect);
    	return self;
    	}
    
    CCustomColumnOfLineOfListBox* CCustomColumnOfLineOfListBox::NewL(const TRect& aRect)
    	{
    	CCustomColumnOfLineOfListBox* self = CCustomColumnOfLineOfListBox::NewLC(aRect);
    	CleanupStack::Pop(); // self;
    	return self;
    	}
    
    void CCustomColumnOfLineOfListBox::ConstructL(const TRect& aRect)
    	{
    	CreateWindowL();
    
    
    		// Set the windows size
    		 SetRect(aRect);
    		 
    		// Activate the window, which makes it ready to be drawn
    		 ActivateL();
    	}
    
    
    
           /**
            * From CoeControl,SizeChanged.
            */
            void CCustomColumnOfLineOfListBox::SizeChanged()
            	{
            	
            	}
            
    
           /**
            * From CoeControl,CountComponentControls.
            */
            TInt CCustomColumnOfLineOfListBox::CountComponentControls() const
            	{
            	return 0;
            	}
    
           /**
            * From CCoeControl,ComponentControl.
            */
            CCoeControl* CCustomColumnOfLineOfListBox::ComponentControl(TInt aIndex) const
            	{
            	switch ( aIndex )
            	        	        {
            		
            	        	        default:
            	        	            return NULL;
            	        	        }
            	}
    
           /**
            * From CCoeControl,Draw.
            */
            void CCustomColumnOfLineOfListBox::Draw(const TRect& aRect) const
            	{
          	    
            	CWindowGc& gc = SystemGc();
            	CFont* fontUsed = const_cast<CFont*>(iEikonEnv ->LegendFont());//NormalFont());
            	gc.UseFont(fontUsed);
            	gc.SetPenStyle(CGraphicsContext::ESolidPen);
            	gc.SetBrushColor(KRgbWhite);
            	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
            	gc.DrawRect(aRect);
            	gc.SetBrushColor(KRgbWhite);
            	gc.DrawText(_L("Sandeep"),aRect,fontUsed->AscentInPixels(),CGraphicsContext::ECenter);        	     
            	        	        	     
            	}
    
           /**
            * From CCoeControl, HandleControlEventL.
            */
            // event handling section
            // e.g Listbox events
            void CCustomColumnOfLineOfListBox::HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType)
            	{
            	
            	}
    Code:
    CCustomLineOfListbox::CCustomLineOfListbox()
    	{
    	// No implementation required
    	}
    
    CCustomLineOfListbox::~CCustomLineOfListbox()
    	{
    	}
    
    CCustomLineOfListbox* CCustomLineOfListbox::NewLC(const TRect& aRect)
    	{
    	CCustomLineOfListbox* self = new (ELeave)CCustomLineOfListbox();
    	CleanupStack::PushL(self);
    	self->ConstructL(aRect);
    	return self;
    	}
    
    CCustomLineOfListbox* CCustomLineOfListbox::NewL(const TRect& aRect)
    	{
    	CCustomLineOfListbox* self = CCustomLineOfListbox::NewLC(aRect);
    	CleanupStack::Pop(); // self;
    	return self;
    	}
    
    void CCustomLineOfListbox::ConstructL(const TRect& aRect)
    	{
    	CreateWindowL();
    	TRect a(0,0,100,20);
    	TRect b(0,0,150,20);
    	TRect c(0,0,50,20);
    	 iColumn1 = CCustomColumnOfLineOfListBox::NewL(a);
    	 iColumn1->SetContainerWindowL( *this );
    	 //iColumn1->SetTextL( _L("a") );
    	 iColumn2 = CCustomColumnOfLineOfListBox::NewL(b);
    	 iColumn2->SetContainerWindowL( *this );
    	 //iColumn2->SetTextL( _L(" menu") );
    	 iColumn3 = CCustomColumnOfLineOfListBox::NewL(c);
    	 iColumn3->SetContainerWindowL( *this );
    	 //iColumn3->SetTextL( _L("u") );
    
    		// Set the windows size
    	 SetRect(a);
    	 SetRect(b);
    	 SetRect(c);
    		 SetRect(aRect);
    		 
    		// Activate the window, which makes it ready to be drawn
    		 ActivateL();
    	}
    
    
    
           /**
            * From CoeControl,SizeChanged.
            */
            void CCustomLineOfListbox::SizeChanged()
            	{
            	iColumn1->SetExtent( this->iPosition, TSize(120,20) );
            	iColumn2->SetExtent( this->iPosition+TPoint(120,0), TSize(50,20) );
            	iColumn3->SetExtent( this->iPosition+TPoint(170,0), TSize(50,20) );
            	}
            
    
           /**
            * From CoeControl,CountComponentControls.
            */
            TInt CCustomLineOfListbox::CountComponentControls() const
            	{
            	return 3;
            	}
    
           /**
            * From CCoeControl,ComponentControl.
            */
            CCoeControl* CCustomLineOfListbox::ComponentControl(TInt aIndex) const
            	{
            	switch ( aIndex )
            	        	        {
            		case 0:
            			return iColumn1;
            			
            		case 1:
            			return iColumn2;
            			
            		case 2:
            			return iColumn3;
            	        	        default:
            	        	            return NULL;
            	        	        }
            	}
    
           /**
            * From CCoeControl,Draw.
            */
            void CCustomLineOfListbox::Draw(const TRect& aRect) const
            	{
          	    
            	CWindowGc& gc = SystemGc();
            	CFont* fontUsed = const_cast<CFont*>(iEikonEnv ->LegendFont());//NormalFont());
            	gc.UseFont(fontUsed);
            	gc.SetPenStyle(CGraphicsContext::ESolidPen);
            	gc.SetBrushColor(KRgbWhite);
            	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
            	gc.DrawRect(aRect);
            	gc.SetBrushColor(KRgbWhite);
            	//gc.DrawText(_L("Sandeep"),aRect,fontUsed->AscentInPixels(),CGraphicsContext::ECenter);        	     
            	        	        	     
            	}
    
           /**
            * From CCoeControl, HandleControlEventL.
            */
            // event handling section
            // e.g Listbox events
            void CCustomLineOfListbox::HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType)
            	{
            	
            	}
    Code:
    CCustomListBox::CCustomListBox(const TRect& aRect):iRect(aRect)
    	{
    	// No implementation required
    	}
    
    CCustomListBox::~CCustomListBox()
    	{
    	}
    
    //CCustomListBox* CCustomListBox::NewLC(const TRect& aRect)
    //	{
    //	CCustomListBox* self = new (ELeave) CCustomListBox();
    //	CleanupStack::PushL(self);
    //	self->ConstructL(aRect);
    //	return self;
    //	}
    //
    //CCustomListBox* CCustomListBox::NewL(const TRect& aRect)
    //	{
    //	CCustomListBox* self = CCustomListBox::NewLC(aRect);
    //	CleanupStack::Pop(); // self;
    //	return self;
    //	}
    
    
    void CCustomListBox::ConstructL(const TRect& aRect)
    	{
    	CreateWindowL();
    	TInt width=aRect.Width()-26,height=20;
    	
    	TRect a(0,0,width,height);
    	for(TInt i=0;i<2;i++)
    		{
    	        CCustomLineOfListbox* TempLine=CCustomLineOfListbox::NewL(a);
    		 	TempLine->SetContainerWindowL( *this );
    		 	iLines.AppendL(TempLine);
    		 	SetRect(a);
    		 	
    		}
         SetRect(iRect);
    	 ActivateL();
    	}
     void CCustomListBox::AppendLine()
    	 {
    	 
    	 TRect a(0,0,iRect.Width(),20);
    	 CCustomLineOfListbox* TempLine=CCustomLineOfListbox::NewL(a);
    	 	
    	 	iLines.AppendL(TempLine);
    	 	TempLine->SetContainerWindowL(*this);
    	 //for(TInt i=0;i<iLines.Count();i++)	 iLines[i]->SetContainerWindowL(*this);
    	 this->RequestRelayout(TempLine);
     
    	 }
           /**
            * From CoeControl,SizeChanged.
            */
            void CCustomListBox::SizeChanged()
            	{
            	TInt x=17,y=40,width=iRect.Width()-50,height=20;
            	for(TInt i=0;i<iLines.Count();i++)
            		{
            		iLines[i]->SetExtent(TPoint(x,i*(height+1)+y), iLines[i]->MinimumSize());
            		}
            	}
    
           /**
            * From CoeControl,CountComponentControls.
            */
            TInt CCustomListBox::CountComponentControls() const
            	{
            	return iLines.Count();
            	}
    
           /**
            * From CCoeControl,ComponentControl.
            */
            CCoeControl* CCustomListBox::ComponentControl(TInt aIndex) const
            	{
    
            	if(aIndex>=0 && aIndex<iLines.Count())
            		return iLines[aIndex];
    
            	return NULL;
    	        }
            
    
           /**
            * From CCoeControl,Draw.
            */
            void CCustomListBox::Draw(const TRect& aRect) const
            	{
            	_LIT(KName,"Name              Distance Rating");
            	CWindowGc& gc = SystemGc();
            	CFont* fontUsed = const_cast<CFont*>(iEikonEnv ->LegendFont());
            	gc.UseFont(fontUsed);
            	gc.SetPenStyle(CGraphicsContext::ESolidPen);
            	gc.SetBrushColor(KRgbWhite);
            	gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
            	gc.DrawRect(aRect);
            	TRect a(17,20,iRect.Width()-26,20);
            	gc.DrawRect(a);
            	gc.SetBrushColor(KRgbBlack);
            	gc.DrawText(KName,TPoint(20,38));
    
            	    
            	    
            	}
    
           /**
            * From CCoeControl, HandleControlEventL.
            */
            // event handling section
            // e.g Listbox events
            void CCustomListBox::HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType)
            	{
            	
            	}
    Last edited by sandeepmhptr3; 2012-12-11 at 06:20.

  14. #14
    Registered User
    Join Date
    Nov 2012
    Posts
    34

    Re: can i make a custom control

    someone please help me on this

  15. #15
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,956

    Re: can i make a custom control

    In my opinion that seems to be a bit lengthy/complex way to draw custom list of some items using so many classes.You can follow the following steps in order to accomplish you are trying to do:

    1) Make use of only a single class (let say only ccustomListBox)

    2) Fill up array(s) which is(are) to contain your list data (you can take up CDesCArray('s) if the data is purely text type)

    3) you can define an array of TPoint, to store the points as where to draw the text/line

    4) Step 2 can be done in ConstructL()(as its only needed once) & step 3 can be done in SizeChanged()

    5) Inside Draw(), start drawing the text & line by taking up a for loop(draw text first then line)

    Like:

    for (TInt iCount = 0; iCount < iListCount; iCount++)
    {
    ....
    gc.DrawText(iTextArray[iCount],TPoint(//from the TPoint array, defined in sizechanged()));
    // iTextArray -> CDesCArray, defined in ConstructL(), containing the text items for list

    // Now draw the line
    gc.DrawLine(//The TPoint here can be the point with 5-10 pixel below the text item(a separate TPoint array can be maintained for this))
    }
    6) Nothing is needed inside countcomponentcontrol() or componentcontrol() (as the view/container is purely a combination of text & image)

Similar Threads

  1. Custom control in form
    By patriot2009 in forum Symbian User Interface
    Replies: 1
    Last Post: 2012-05-03, 10:37
  2. Custom Tab Control
    By fazlay.rabbi in forum Symbian User Interface
    Replies: 2
    Last Post: 2011-02-23, 05:44
  3. Custom control doesn't display in a custom dialog
    By curiouswalker in forum Symbian User Interface
    Replies: 9
    Last Post: 2010-07-14, 06:20
  4. custom control help!!!!!!!!!!!!!
    By raj8nokiaforum in forum Symbian
    Replies: 13
    Last Post: 2009-06-08, 04:33
  5. Custom Tab Control
    By murthy.pramod in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-11-05, 09:47

Posting Permissions

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