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
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.
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
----------------------------
[/CODE]
I need a display like
[CODE]
------------------------------
name distance rating
item1 100m 7
item2 200m 11
item 3 300m 15
------------------------------
[/CODE]
----------------------------------------------------------------------------------
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
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.
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]
[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)
{
}
[/CODE]
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.
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.
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()?
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();
}
Re: can i make a custom control
Now I am able to draw. thanks
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]
[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]
[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)
{
}
[/CODE]
Re: can i make a custom control
someone please help me on this
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
// [B]Now draw the line[/B]
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)
Re: can i make a custom control
How to create a local CDesCArray?
I used
CDesCArray Array;-------gives compilation error
CDesCArray* Array=new(ELeave) CDesCArray;-----gives compilation error
I need messages coming from socket and SMS Listener to go into a queue;
from the queue it will be read into the descriptor using observer design pattern.
So queue need to be syncchronised also.
queue contains all new messages received and array contains all messages belonging to the list
I guess CDesCArray can point to another descriptor array. But can not be created as a stand alone.
So, what array should I use.
something that comes to my mind is RArray<RBuf> Array;
Please suggedt me...
Re: can i make a custom control
You can create a CDeCArray as a member variable of the list box class(not local to a function) & keep on updating that array as new messages are received. You can call a method in the listbox class, as soon as new message is received, which will update the array(append/insert items into it) & then call a method which would update the listbox.
CDesCArrayFlat* Array ; // in header
Array = new(ELeave)CDesCArrayFlat(1); // in ConstructL() (for e.g)