BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 03-12-2010, 07:42 AM   #1 (permalink)
New Member
 
Join Date: Mar 2010
Model: 9550
PIN: N/A
Carrier: telus
Posts: 11
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default background text help

Please Login to Remove!

Hi All,
I need to put the text from a Word document onto a screen I have tried to make the word document a png and use BitmapBackground, It seems too big for the screen and will not scroll down, There has to be a better way
Can anybody send me in the right direction

If I type it all in a LabelField it will not show the whole thing on the screen
What do I need to do for this to happen?

Or is any of this not possible?

Cheers!!!
Offline  
Old 03-12-2010, 09:43 AM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2010
Model: N/A
PIN: N/A
Carrier: Fledge
Posts: 43
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Norm,

Use an editfield and make it readonly. This way there will be a cursor so you can scroll up and down.
Offline  
Old 03-12-2010, 10:26 AM   #3 (permalink)
New Member
 
Join Date: Mar 2010
Model: 9550
PIN: N/A
Carrier: telus
Posts: 11
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Jacob,

The BitmapBackground with the png works fine on the STORM simulator but does not scroll on the other models with a trackball
Am I not using the simulator tools right?

Also I am having a little trouble centering the png moving it FIELD LEFT or FIELD RIGHT or FIELD HCENTER does not seem to work

Any ideas?
Cheers!!!
Offline  
Old 03-12-2010, 10:56 AM   #4 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2010
Model: N/A
PIN: N/A
Carrier: Fledge
Posts: 43
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Norm,

The default behavior for scrolling with the trackwheel within a manager is to adjust the scroll based on which field currently has focus. If you currently only have one field in the manager (your bitmap), then there will be no scrolling behavior at all.

You can manual implement scrolling by overriding your manager's method: protected boolean navigationMmovement(int dx, int dy, int status, int time). You can set a data member of your class called "offset", and then increment or decrement the offset based on which directional button was pressed. Then, you can update the manager's current scroll position by using the setVerticalScroll(int position) method in your Manager.

So it is possible to scroll when you only have a single field on the screen, but if you use an EditField with the READONLY attribute set, you can achieve the same goal without doing any work.
Offline  
Old 03-12-2010, 11:03 AM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2010
Model: N/A
PIN: N/A
Carrier: Fledge
Posts: 43
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

On to your question about centering a field:

By default, a BitmapField will only use as much width as its bitmap. So for example if your screen is 320px wide and your Bitmap is 50 px wide, your BitmapField will only be 50px wide as well.

Since the Bitmap is 50px wide and the BitmapField is 50px wide, the Bitmap is centered if it is positioned at (0,0).

What we need to do is increase the size of the field to 320px. This way, the Bitmap will be centered if it is positioned at x coordinate: (320/2) - (50/2) = 135.

So, the short answer to your question is to use this style bit for your field:
(Field.USE_ALL_WIDTH | Field.FIELD_HCENTER)
Offline  
Old 03-14-2010, 12:08 AM   #6 (permalink)
New Member
 
Join Date: Mar 2010
Model: 9550
PIN: N/A
Carrier: telus
Posts: 11
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Jacob...
Your answers were a huge help


Cheers!!!
Offline  
Old 03-15-2010, 07:07 AM   #7 (permalink)
New Member
 
Join Date: Mar 2010
Model: 9550
PIN: N/A
Carrier: telus
Posts: 11
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have entered the Edit Field but when it scrolls I just noticed it skips the middle part of the bitmap The bitmap is 1005 X 1108 here is the code as I have it :
public Spare1Screen(){

add(new EditField(READONLY));
add(new LabelField("RED WINE",(Field.FIELD_HCENTER)));

VerticalFieldManager manager = (VerticalFieldManager)getMainManager();
manager.setBackground(BackgroundFactory.createSoli dBackground(Color.OLIVEDRAB));
Bitmap logoBitmap = Bitmap.getBitmapResource("File1-Test83D.png");
bitmapField = new BitmapField(logoBitmap,Field.USE_ALL_WIDTH);
bitmapField = new BitmapField(logoBitmap,Field.FIELD_HCENTER);
bitmapField = new BitmapField(logoBitmap,Field.USE_ALL_HEIGHT);
add(bitmapField);

storeButton = new ButtonField("FOOD", ButtonField.CONSUME_CLICK);
Offline  
Old 03-15-2010, 10:44 AM   #8 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2010
Model: N/A
PIN: N/A
Carrier: Fledge
Posts: 43
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

The scrolling will not show the middle of a field that occupies more vertical space than your screen offers. This is because focus jumps from focusable field to focusable field.

You are going to need to override onNavigationMovement() if you want to use such a large bitmap.
Offline  
Old 03-16-2010, 06:11 AM   #9 (permalink)
New Member
 
Join Date: Mar 2010
Model: 9550
PIN: N/A
Carrier: telus
Posts: 11
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I apoligize, but could you show me this in the code above
I have spent hours and cannot get my head around this
Offline  
Old 03-16-2010, 12:18 PM   #10 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2010
Model: N/A
PIN: N/A
Carrier: Fledge
Posts: 43
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hope this helps. Notice that you need to make at least one field focusable or navigationMovement() never occurs, that may have been your problem. And of course replace 'image.png' with your image name.

Code:
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.container.VerticalFieldManager;

public class BitmapScroller extends VerticalFieldManager {
	private BitmapField bitmapField;

	public BitmapScroller(){
		super(VERTICAL_SCROLL | HORIZONTAL_SCROLL);
		bitmapField = new BitmapField(Bitmap.getBitmapResource("image.png"), FOCUSABLE);
		add(bitmapField);
	}

	protected boolean navigationMovement(int dx, int dy, int status, int time) {
		if (dx > 0) setHorizontalScroll(getHorizontalScroll() + 5);
		if (dx < 0) setHorizontalScroll(getHorizontalScroll() - 5);
		if (dy > 0) setVerticalScroll(getVerticalScroll() + 5);
		if (dy < 0) setVerticalScroll(getVerticalScroll() - 5);
		return true;
	}
}
You will need to set constraints so if someone tries to adjust the scrolling below 0 you set it to 0. I didn't do it because I thought it would just clutter the code and it's common sense.
Offline  
Old 03-17-2010, 06:22 AM   #11 (permalink)
New Member
 
Join Date: Mar 2010
Model: 9550
PIN: N/A
Carrier: telus
Posts: 11
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks again,
But...
If this is a class by itself I cannot "pushScreen" from my main screen (I think because I cannot "extend MainScreen")
If it is code to add to my exsisting class above I cannot fit it in and have it not red line everywhere and set off the debug
I have to assume I am over thinking this and missing something simple
Please don't give up

Cheers!!!
Offline  
Old 03-17-2010, 11:23 AM   #12 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2010
Model: N/A
PIN: N/A
Carrier: Fledge
Posts: 43
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Norm, it's a Manager. So put it in the same package as a class that has your test MainScreen and go like this:

Manager bitmapScroller = new BitmapScroller();
mainScreen.add(bitmapScroller);

Are you familiar with Managers?
Offline  
Old 03-19-2010, 05:35 AM   #13 (permalink)
New Member
 
Join Date: Mar 2010
Model: 9550
PIN: N/A
Carrier: telus
Posts: 11
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Familiar with Managers? yes
Comfortable with managers ? not so much

I think I am close but "mainScreen" keeps redlining and offers to create a variable, field , parameter or a conatant,
Is it any of these or am I still out to lunch?

public xxxxxxxxScreen(){

Manager bitmapScroller = new BitmapScroller();
mainScreen.add(bitmapScroller);


VerticalFieldManager manager = (VerticalFieldManager)getMainManager();
manager.setBackground(BackgroundFactory.createSoli dBackground(Color.ALICEBLUE));
add(new LabelField("XXXXXXXX",Field.FIELD_HCENTER));


Cheers!!!
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





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