BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 05-20-2008, 10:22 PM   #1
CELITE
Thumbs Must Hurt
 
Join Date: Dec 2005
Model: 8310
Carrier: Rogers
Posts: 138
Default Transparent "window" on the ribbon.

Please Login to Remove!

There was a post a while back about creating a window that was slightly transparent and overlays the ribbon. The purpose of this was to create a clock application (I think?) that sits on top of the homescreen for easy reference.

I posted a solution in a completely unrelated thread but this should probably be in separate thread (the original one was closed).

Here's the code:

Code:
class FloatingScreenMain extends UiApplication {
    
    public static void main( String[] args ) {
        FloatingScreenMain app = new FloatingScreenMain();
        app.enterEventDispatcher();
    }
    
    FloatingScreenMain() {    
    
        /**
         * Putting this on the event stack instead of pushing a screen from main 
         * ensures that the backbuffer is not cleared and that the main ribbon
         * continues to repaint.
         */
        UiApplication.getUiApplication().invokeLater( new Runnable() {
            public void run() {
                CustomPopupScreen popup = new CustomPopupScreen();
                pushScreen( popup );
            }
        });
    }
} 


class CustomPopupScreen extends Screen {
    
    private final static int _CUSTOM_SIZE   = 100;
    private final static int _ALPHA         = 0xBF; // 75% alpha
    private final static int _X             = ( Display.getWidth() - _CUSTOM_SIZE ) >> 1;
    private final static int _Y             = ( Display.getHeight() - _CUSTOM_SIZE ) >> 1; 
    
    
    CustomPopupScreen() {    
        super( new VerticalFieldManager( Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR ) );
        add( new LabelField( "Floating Popup" ) );
    }
    
    protected void sublayout( int width, int height ) {
        setExtent( _CUSTOM_SIZE, _CUSTOM_SIZE );
        setPosition( _X, _Y );
        layoutDelegate( _CUSTOM_SIZE, _CUSTOM_SIZE );
    }
    
    protected void paintBackground( Graphics g ) {
        XYRect myExtent = getExtent();
        int color = g.getColor();
        int alpha = g.getGlobalAlpha();
        g.setGlobalAlpha( _ALPHA );
        g.setColor( 0xE3E3E3 );
        g.fillRect( 0, 0, myExtent.width, myExtent.height );
        g.setColor( color );
        g.setGlobalAlpha( alpha );
    }
    
    protected boolean keyDown( int keycode, int status ) {
        if ( Keypad.key( keycode ) == Keypad.KEY_ESCAPE ) {
            close();
            return true;
        }
        return super.keyDown( keycode, status );
    }
        
    
    
}
Offline  
Closed Thread



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


4 Count Case GE ProLine 2 Bulb 120V T12 Electronic Fluorescent Light Ballasts picture

4 Count Case GE ProLine 2 Bulb 120V T12 Electronic Fluorescent Light Ballasts

$49.99



Ballast Box 3 Point Category 1 Tractor Loader 2

Ballast Box 3 Point Category 1 Tractor Loader 2" Hitches Quick Tach Attachment

$199.99



3 Point Ballast Box Category 1 Tractor Quick Tach Hitch Counterweight Red Heavy picture

3 Point Ballast Box Category 1 Tractor Quick Tach Hitch Counterweight Red Heavy

$199.99



Philips ADVANCE AmbiStar RELB-2S40-N Replacement Ballast 40-Watt 2-Lamp T12 picture

Philips ADVANCE AmbiStar RELB-2S40-N Replacement Ballast 40-Watt 2-Lamp T12

$18.79



PHILIPS ADVANCE Core-Coil Ballast Kit 71A5389- 1-100W M90 Metal Halide.FreeShip picture

PHILIPS ADVANCE Core-Coil Ballast Kit 71A5389- 1-100W M90 Metal Halide.FreeShip

$22.99



NEW ICN2S54T35I Philips Advance Electronic 54W 2 Lamp T5 Fluorescent Ballast picture

NEW ICN2S54T35I Philips Advance Electronic 54W 2 Lamp T5 Fluorescent Ballast

$24.99







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