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
Developer
Posts: 81
Registered: ‎06-24-2009
My Device: Not Specified

Re: PopupScreen with transparent background and theme for Storm

You are now where we are. That code will indeed make the background transparent, but you are stuck with the ugly border from the theme. You can use a blank applyTheme but then lose all transparency. This is where we are stuck.
Developer
Posts: 222
Registered: ‎11-11-2009
My Device: Storm

Re: PopupScreen with transparent background and theme for Storm

hmmm...

 

actually, i was not aware of applyTheme. can you please tell how you are making the theme as blank?

 

with regards,
Vignesh J

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Don't forget to mark your post as solved if you get the answer and dont forget to give kudos if the answer is useful for you.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
New Developer
Posts: 54
Registered: ‎01-24-2009
My Device: Not Specified

Re: PopupScreen with transparent background and theme for Storm

This is all we do:

 

 

   protected void applyTheme() {
    
   }

 

It gets rid of all the border, etc.  But it also gets rid of background transparency.

 

 

Developer
Posts: 222
Registered: ‎11-11-2009
My Device: Storm

Re: PopupScreen with transparent background and theme for Storm

[ Edited ]

Hi,

Its working for me in v4.5Smiley Happy

if i override the applytheme (nothing implemented within the method), then border is also become transparent

 

Edited: in PopupScreen, i have override the applytheme method.

 

with regards,
Vignesh J

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Don't forget to mark your post as solved if you get the answer and dont forget to give kudos if the answer is useful for you.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Developer
Posts: 81
Registered: ‎06-24-2009
My Device: Not Specified

Re: PopupScreen with transparent background and theme for Storm

Can you post complete sample code please.

Developer
Posts: 222
Registered: ‎11-11-2009
My Device: Storm

Re: PopupScreen with transparent background and theme for Storm

[ Edited ]

sure

here is the code for Transparent Popup Screen class

 

class TransPopupScreen extends PopupScreen {

    public TransPopupScreen()
    {
        super (new VerticalFieldManager(),Field.FOCUSABLE | Field.USE_ALL_HEIGHT | Field.USE_ALL_WIDTH);
    }

    public void sublayout (int width, int height)
    {
        super.sublayout (width, height); //Edited now. please add this code in your sample
        setExtent (75, 75); // manually setting the size
    }

    protected void paintBackground (Graphics graphics)
    {

        graphics.setGlobalAlpha (0);
        graphics.setBackgroundColor(Color.BLACK);
        graphics.fillRect(0, 0, 75, 75);
    }

    protected void paint (Graphics g)
    {
        g.setGlobalAlpha (255);

        //do your painting here
    }

    protected void applyTheme()
    {
        System.out.println ("Inside Apply Theme");
    }
}

 

Note: i not tested this code by changing different theme, because i am not having any device with 4.5 and theme. please test this in actual device by changing the different theme and tell me the result. I think it should work properly in all themes

with regards,
Vignesh J

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Don't forget to mark your post as solved if you get the answer and dont forget to give kudos if the answer is useful for you.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Developer
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Re: PopupScreen with transparent background and theme for Storm

Hi zany i executed your code, but it is giving me a white background instead of the transparent background.... the screen behind this popupscreen is invisible. it is no more transparent. 

 

do i need to add anything more to your code??

Thanks and Regards,
PraveenGoparaju.
Developer
Posts: 81
Registered: ‎06-24-2009
My Device: Not Specified

Re: PopupScreen with transparent background and theme for Storm

Same result here. This is the same code we've been playing with in the previous posts.

 

Anyone else have any ideas?

Developer
Posts: 222
Registered: ‎11-11-2009
My Device: Storm

Re: PopupScreen with transparent background and theme for Storm

oh, i have tested this code in the following models' simulators but not in any real devices of 4.5

8100
8330
8300
8703e

 

since it was working fine for me in the simulators, i thought it should have same behavior in the real device but it is not

 

sorry

 

with regards,
Vignesh J

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Don't forget to mark your post as solved if you get the answer and dont forget to give kudos if the answer is useful for you.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
Developer
Posts: 81
Registered: ‎06-24-2009
My Device: Not Specified

Re: PopupScreen with transparent background and theme for Storm

I was thinking maybe screens are the wrong way to go.

They don't want to be (easily) transparent without themes prior to 4.6.

 

Why can't we just position a transparent manager in the middle of the

screen to act as a popup? Managers don't have themes or transparency

issues--that I know of.

 

There will, of course, be issues with focus, menus, etc. But these can

be solved.

 

Here is an ugly proof of concept:

 

 

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;

class TestPopup extends MainScreen {

TestPopup() {
super(USE_ALL_WIDTH | USE_ALL_HEIGHT); // popup manager to manage the main screen content & popup
final PopupManager m = new PopupManager(); // manager for the main screen content
VerticalFieldManager vfm = new VerticalFieldManager(USE_ALL_WIDTH | USE_ALL_HEIGHT); vfm.add(new LabelField("Hello")); vfm.add(new LabelField("Hello2")); vfm.add(new LabelField("Hello3")); // add main screen manager to popup manager
m.add(vfm); // add popup manager to screen
add(m); addMenuItem(new MenuItem("Popup", 0, 10) { public void run() { // create manager for popup
Popup p = new Popup(); p.add(new LabelField("popup1")); p.add(new LabelField("popup2"));; // add popup to popup manager
m.add(p); m.invalidate(); } }); addMenuItem(new MenuItem("Kill popup", 1, 10) { public void run() { // remove popup from popup manager
m.delete(m.getField(1)); m.invalidate(); } }); } class PopupManager extends Manager { PopupManager() { super(USE_ALL_WIDTH | USE_ALL_HEIGHT); } protected void sublayout(int width, int height) { // layout main screen manager
// top left and full width, height
 Field f = getField(0); layoutChild(f, width, height); setPositionChild(f, 0, 0); setExtent(width, height);
// if a second field (the popup) is present, position where ever
 if(getFieldCount() == 2) { f = getField(1); layoutChild(f, 200, 200); setPositionChild(f, 50, 50); } } }
class Popup extends VerticalFieldManager { Popup() { super(USE_ALL_HEIGHT | USE_ALL_WIDTH); } // popup gets a transparent background
protected void paintBackground (Graphics graphics) { int alpha = graphics.getGlobalAlpha(); graphics.setGlobalAlpha (70); graphics.setBackgroundColor(Color.BLACK); graphics.fillRoundRect(0, 0, 200, 200, 20, 20); graphics.setGlobalAlpha(alpha); } } }

 

 

My idea is a manager that expects one and/or two fields. The first is a manager,

which lays out the normal screen elements. When the popup is needed another

manager is added that lays out the popup. The top manager gives the first

manager the whole screen. When the second manager is add, it is centered,

overlaying the first manager, simulating a popup screen

 

Any thoughts? Is this just going to be too complicated?