~ubuntu-branches/ubuntu/oneiric/tuxguitar/oneiric

« back to all changes in this revision

Viewing changes to src/org/herac/tuxguitar/gui/util/SplashShell.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2008-06-19 00:30:30 UTC
  • mto: (5.1.2 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20080619003030-h719szrhsngou7c6
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.herac.tuxguitar.gui.util;
2
 
 
3
 
import org.eclipse.swt.SWT;
4
 
import org.eclipse.swt.events.PaintEvent;
5
 
import org.eclipse.swt.events.PaintListener;
6
 
import org.eclipse.swt.graphics.Image;
7
 
import org.eclipse.swt.widgets.Display;
8
 
import org.eclipse.swt.widgets.Shell;
9
 
import org.herac.tuxguitar.gui.SystemImages;
10
 
import org.herac.tuxguitar.gui.TuxGuitar;
11
 
import org.herac.tuxguitar.gui.system.config.ConfigKeys;
12
 
 
13
 
public class SplashShell {
14
 
        private Shell shell;
15
 
        
16
 
        public SplashShell(Display display){
17
 
                if(TuxGuitar.instance().getConfig().getBooleanConfigValue(ConfigKeys.SHOW_SPLASH)){
18
 
                        this.open(display);
19
 
                }
20
 
        }
21
 
 
22
 
        private void open(Display display) {                            
23
 
                final Image image = SystemImages.TUXGUITAR_SPLASH;
24
 
                int width = image.getBounds().width;
25
 
                int height = image.getBounds().height;
26
 
                int x = ((display.getBounds().width - display.getBounds().x) / 2) - (width / 2);
27
 
                int y = ((display.getBounds().height - display.getBounds().y) / 2) - (height / 2);
28
 
                
29
 
                this.shell = new Shell(display, SWT.NO_TRIM | SWT.NO_BACKGROUND);
30
 
                this.shell.setBounds(x, y, width, height);
31
 
                this.shell.setImage(SystemImages.TUXGUITAR_ICON);
32
 
                this.shell.setText(TuxGuitar.getProperty("tuxguitar.title"));
33
 
                this.shell.addPaintListener(new PaintListener() {
34
 
                        public void paintControl(PaintEvent e) {
35
 
                                e.gc.drawImage(image, 0, 0);
36
 
                        }
37
 
                });
38
 
                this.shell.open();
39
 
        }
40
 
        
41
 
        public void close(){
42
 
                if(this.shell != null && !this.shell.isDisposed()){
43
 
                        this.shell.close();
44
 
                        this.shell.dispose();
45
 
                }
46
 
        }
47
 
}