BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-15-2009, 08:39 PM   #1 (permalink)
New Member
 
Join Date: Jul 2009
Model: 8300
PIN: N/A
Carrier: VZ
Posts: 13
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default For ObjectListField, can you call another Field's paint() within drawListRow()?

Please Login to Remove!

Question for ObjectListField. If I wanted to make a list of LableFields, could I call the LabelField.paint(g) method within my implementation of the ObjectListField.drawListRow(...) method?

Reason I ask, is every example I've ever seen with ListRow/DrawListRow has in it's implementation something like g.drawText() or g.drawBitmap() or whatever - and I'm wondering if "paint" would work.

So then the extension of this is, could I have a ObjectListField full of, say HorizontalFieldManagers (with any child field combination I wanted in it, say ButtonField and EditField or whatever) and call the manager's paint(g) method and have it render itself and all of the children?


PHP Code:
public class MyFieldList extends ObjectListField {

    public 
void drawListRowListField lfGraphics gint iint yint w 
   {
        
LabelField lf = (LabelFieldgetlf);

        
lf.paint(g);  // Will this work, if not, why?

    
}

Offline  
Old 07-15-2009, 09:28 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

Try it and tell us how it worked
Offline  
Old 07-16-2009, 08:52 AM   #3 (permalink)
New Member
 
Join Date: Jul 2009
Model: 8300
PIN: N/A
Carrier: VZ
Posts: 13
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Can ObjectListField Fields and paint them?

No dice, at least not yet. Even if I override the paint() method in the ObjectListField to handle all of the painting, I don't see the objects rendered.

Here is the important parts of my code. MyObj is a javabean, in the MyListField constructor, I create an array of MyListRow, which extends RichTextField.

For example:
PHP Code:
public class MyListField extends ObjectListField implements ListFieldCallback {
     
    private 
MyListRow _rowsxxx91;xxx93;;

     
        public 
MyListField(MyObject myObjsxxx91;xxx93;)
    {
        
super(Field.USE_ALL_HEIGHT);
        
_rows = new MyListRowxxx91;myObjs.lengthxxx93;;
        for(
int i=0;i<myObjs.lengthi++)
            
_rowsxxx91;ixxx93; = new MyListRow(rxsxxx91;ixxx93;);
        
this.set(_rows);
        
this.setCallback(this);
    }


    
/*
     * This is the class what I want to call paint() on, a 
     * RichTextField in this case.
     */ 
    
class MyListRow extends RichTextField
    
{
        public 
MyListRow(MyObj myObj)
        {
            
super(my.getText(), 0);                      
        }
        
        public 
void paintMe(Graphics gint y)
        {
            
super.setPosition(0y);
            
super.paint(g);
        }
    }


    
/*
     * Overriden ObjectListField paint method.
     */
    
protected void paint(Graphics graphics
    {

        
/* I've removed a lot of code here  to make
         * the example more clear - basically stuff that 
         * gets the rowHeight, drawing/clipping rectangle
         * and stuff like that.
         */

        
for(; startLine <= endLine; ++startLine
        {              
            
            
/* this next call, MyListRow.paintMe() 
             * is essentially RichTextField.paint(g) 
             */
        
_rowsxxx91;startLinexxx93;.paintMe(graphics,y);  //  <<<< my call to paint() 


            /* more code to increment the y position removed */    
        
}
    } 
I think the key here is that the MyListRow (RichTextField) objects do not belong to any layout manager. I want the ObjectListField to essentially *be* the layout manager, in that is will paint them.

Is there a way to make this work -- or is something fundamentally wrong?
Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.