01-11-2010 05:45 AM
Hi,i want a dragger or scroller like component,is there any widgets similar to it,or else custom component needs to be prepared ,component similar to it ,needs to be done .I need on idea on this.in short ,
Regards
Rakesh shankar.p
01-11-2010 07:33 AM
Hi Rakesh,
Your image is not visible in firefox and IE. Can you please check it, also can you give a brief about the component which you want?
01-11-2010 08:30 AM
I'm pretty sure that images must be approved by a moderator before they will be displayed. It takes a very long time before they are approved so it is easier to post it on another site and provide a link.
As for the component, guessing from the image name "dragger.jpg" I am guessing that you want either some bar graph that you can control or you want some drag and drop control.
01-11-2010 11:49 PM - edited 01-12-2010 02:17 AM
yes bar like component,with scroller in it,while dragging the scroller,value should change based on dragging of the scroller,can understand me Sir and this is link of the image
http://www.filefactory.com/file/a18929d/n/dragger.
i want a idea on this
Regards
Rakesh shankar.p
01-12-2010 12:30 AM
Hi Rakesh,
I think you need this component for storm. If then here is the sample code of the custom component
class HorzScroll extends GaugeField {
private int _maxValue, _minValue, _value;
public HorzScroll()
{
super();
_maxValue = Display.getWidth();
_minValue = 0;
_value = 10;
}
public int getPreferredHeight()
{
return 7;
}
public int getPreferredWidth()
{
return _maxValue;
}
protected void paint (Graphics g)
{
g.setBackgroundColor(Color.BLACK);
g.fillRect (_value, 1, 10, 4);
}
protected void layout(int width, int height) {
super.layout(width, height);
setExtent (_maxValue, 7);
}
protected boolean touchEvent (TouchEvent message)
{
if ((message.getEvent() == TouchEvent.CLICK) ||
(message.getEvent() == TouchEvent.MOVE))
{
int y = message.getGlobalY (1);
if ((y < 0) || (y > getPreferredHeight()))
return false;
_value = message.getGlobalX (1);
if (_value >= _maxValue - 10)
_value = _maxValue - 10;
invalidate();
return true;
}
return false;
}
public int getValueMax()
{
return _maxValue;
}
public int getValueMin()
{
return _minValue;
}
public int getValue()
{
return _value;
}
}
class VertScroll extends GaugeField {
private int _maxValue, _minValue, _value;
public VertScroll()
{
super();
_maxValue = Display.getHeight();
_minValue = 0;
_value = 10;
}
public int getPreferredHeight()
{
return _maxValue;
}
public int getPreferredWidth()
{
return 7;
}
protected void paint (Graphics g)
{
g.setBackgroundColor(Color.BLACK);
g.fillRect (1, _value, 4, 10);
}
protected void layout(int width, int height) {
super.layout(width, height);
setExtent (7, _maxValue);
}
protected boolean touchEvent (TouchEvent message)
{
if ((message.getEvent() == TouchEvent.CLICK) ||
(message.getEvent() == TouchEvent.MOVE))
{
int x = message.getGlobalX (1);
if ((x < 0) || (x > getPreferredWidth()))
return false;
_value = message.getGlobalY (1);
if (_value >= _maxValue - 10)
_value = _maxValue - 10;
invalidate();
return true;
}
return false;
}
public int getValueMax()
{
return _maxValue;
}
public int getValueMin()
{
return _minValue;
}
public int getValue()
{
return _value;
}
}
01-12-2010 02:04 AM - edited 01-12-2010 02:08 AM
Hi Vignesh,this is the sample image of component that i described earlierr
http://www.filefactory.com/f/ef594ce25b74ba1a
/--chk this link
01-12-2010 02:16 AM
Hi Rakesh,
Here is the sample code which will solve your requirement.
class HorzScroll extends GaugeField {
public HorzScroll()
{
super ("", 0, Display.getWidth(), 5, GaugeField.NO_TEXT);
}
public int getPreferredHeight()
{
return 32;
}
protected void paint (Graphics g)
{
int value = getValue();
if (value >= getValueMax() - 10)
value = getValueMax() - 10;
g.setBackgroundColor(Color.BLUE);
g.fillRect (0, 11, value, 12);
Bitmap image = Bitmap.getBitmapResource("image.jpg");
g.drawBitmap (value - (image.getWidth()/2), 0, image.getWidth(), image.getHeight(), image, 0, 0);
}
protected void layout(int width, int height) {
super.layout(width, height);
setExtent (_maxValue, 32);
}
protected boolean touchEvent (TouchEvent message)
{
if ((message.getEvent() == TouchEvent.CLICK) ||
(message.getEvent() == TouchEvent.MOVE))
{
int y = message.getGlobalY (1);
if ((y < 0) || (y > getPreferredHeight()))
return false;
setValue(message.getGlobalX (1));
invalidate();
return true;
}
return false;
}
}