Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
sathishkumar_it
Posts: 24
Registered: ‎05-19-2011
My Device: Blackberry storm
My Carrier: verizon

Horizontalfieldmanager inside verticalfieldmanger for centering the fields (x position of the first field)

Hi

 

I am working on tooltip of tab button. I want position the tooltip and I got one issue.

 

 

The issue is I have five button with 47*47 dimension image. And I make center by

 

 


  _tabManager =new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER)                _tabManager.setBackground(BackgroundFactory                .createSolidBackground(0x0000FF00));                        VerticalFieldManager vfmCentre = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH);  

vfmCentre.setBackground(BackgroundFactory                .createSolidBackground(0x0000FF00));  

 

            _tab1.setMargin(2,10,0,0);       

_tabManager.add(_tab1);       

 _tab2.setMargin(2,10,0,0);     

  _tabManager.add(_tab2);   

      _tab3.setMargin(2,10,0,0);   

    _tabManager.add(_tab3);       

  _tab4.setMargin(2,10,0,0);     

  _tabManager.add(_tab4);      

    _tab5.setMargin(2,0,0,0); 

      _tabManager.add(_tab5);     

        System.out.println("Width"+_tabManager.getPaddingLeft());       

        vfmCentre.add(_tabManager);     

  add(vfmCentre);

 

 

Can anybody please suggest if putting Horizontalfieldmanager inside verticalfieldmanger for centering the fields. How we calculate the starting point(x postion) of the first field in  Horizontalfieldmanager ?

 

 

Thanks in advance.

 

 

Regards,

Sathish

Please use plain text.
Contributor
snarasimhan
Posts: 24
Registered: ‎08-04-2010
My Device: Not Specified

Re: Horizontalfieldmanager inside verticalfieldmanger for centering the fields (x position of the first field)

You can get hold of the 1st field of HorizontalFieldManager within the VerticalFieldManager by using the following code

 

Manager tempManager = (Manager) vfmCentre.getField(0);

//This returns the HorizontalFieldManager _tabManager in ur case

 

int xPosition = tempManager.getField(0).getContentLeft();

//This should ideally return the x co-ordinate of the first field in the horizontal manager

 

Havent tried it, but I guess this should work!

 

Regards

Suhas

 

 

Please use plain text.
Developer
ahmadahmad
Posts: 404
Registered: ‎05-31-2011
My Device: curve
My Carrier: devel

Re: Horizontalfieldmanager inside verticalfieldmanger for centering the fields (x position of the first field)

you can redefine the height and the width for the horizontalfieldmanager and verticalfieldmanager by override the subayout method and the will help u to centering the fields.
Please use plain text.
Contributor
imantung
Posts: 48
Registered: ‎05-26-2011
My Device: Bold 9700
My Carrier: Telkomsel

Re: Horizontalfieldmanager inside verticalfieldmanger for centering the fields (x position of the first field)

You may use recursive to calculate position of your tooltips. Below is piece of code from my project, hope could suitable with you too.

	protected XYPoint getTooltipPoint(Field field, int x, int y) {
		XYRect rect = field.getContentRect();
		XYPoint point = new XYPoint(x + rect.x, y + rect.y);

		if (field.getManager() != null) {
			point.y -= field.getManager().getVerticalScroll();
		}

		if (field instanceof Manager) {
			Manager manager = (Manager) field;
			return getTooltipPoint(manager.getFieldWithFocus(), point.x,
					point.y);
		} else {
			return point;
		}
	}

 

 

Please use plain text.