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

« back to all changes in this revision

Viewing changes to src/org/herac/tuxguitar/gui/items/menu/PlayMenuItem.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2008-06-19 00:30:30 UTC
  • mfrom: (1.1.1 upstream) (2.1.3 hardy)
  • Revision ID: james.westby@ubuntu.com-20080619003030-agens2gvd5m4dacu
New upstream release (Closes: #481728) also (LP: #176979, #212207)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Created on 02-dic-2005
3
 
 *
4
 
 * TODO To change the template for this generated file go to
5
 
 * Window - Preferences - Java - Code Style - Code Templates
6
 
 */
7
 
package org.herac.tuxguitar.gui.items.menu;
8
 
 
9
 
import org.eclipse.swt.SWT;
10
 
import org.eclipse.swt.events.SelectionAdapter;
11
 
import org.eclipse.swt.events.SelectionEvent;
12
 
import org.eclipse.swt.widgets.Menu;
13
 
import org.eclipse.swt.widgets.MenuItem;
14
 
import org.eclipse.swt.widgets.Shell;
15
 
import org.herac.tuxguitar.gui.SystemImages;
16
 
import org.herac.tuxguitar.gui.TuxGuitar;
17
 
import org.herac.tuxguitar.gui.editors.TablatureEditor;
18
 
import org.herac.tuxguitar.gui.items.MenuItems;
19
 
 
20
 
/**
21
 
 * @author julian
22
 
 *
23
 
 * TODO To change the template for this generated type comment go to
24
 
 * Window - Preferences - Java - Code Style - Code Templates
25
 
 */
26
 
public class PlayMenuItem implements MenuItems{
27
 
        private static final int STATUS_STOPED = 1;
28
 
        private static final int STATUS_PAUSED = 2;
29
 
        private static final int STATUS_RUNNING = 3;            
30
 
        
31
 
    private TablatureEditor tablatureEditor;
32
 
    private Shell shell;
33
 
    private MenuItem playMenuItem;
34
 
    private Menu menu;     
35
 
    private MenuItem play;
36
 
    private MenuItem stop;
37
 
    private int status;
38
 
    
39
 
    public PlayMenuItem(Shell shell,Menu parent, int style,TablatureEditor tablatureEditor) {
40
 
        this.playMenuItem = new MenuItem(parent, style);
41
 
        this.tablatureEditor = tablatureEditor;
42
 
        this.shell = shell;
43
 
        this.menu = new Menu(shell, SWT.DROP_DOWN);
44
 
    }
45
 
 
46
 
    
47
 
    public void showItems(){                                            
48
 
                this.play = new MenuItem(this.menu,SWT.PUSH);
49
 
                this.play.setImage(SystemImages.TRANSPORT_ICON_PLAY_1);
50
 
                this.play.addSelectionListener(new SelectionAdapter() {
51
 
                        public void widgetSelected(SelectionEvent e) {
52
 
                                TuxGuitar.instance().getTransport().play(e);
53
 
                        }               
54
 
                });              
55
 
                
56
 
        this.stop = new MenuItem(this.menu, SWT.PUSH);
57
 
                this.stop.setImage(SystemImages.TRANSPORT_ICON_STOP_1);
58
 
                this.stop.addSelectionListener(new SelectionAdapter() {
59
 
                        public void widgetSelected(SelectionEvent e) {
60
 
                                TuxGuitar.instance().getTransport().stop(e);
61
 
                        }               
62
 
                });                             
63
 
        
64
 
                this.status = STATUS_STOPED;
65
 
        this.playMenuItem.setMenu(menu);             
66
 
        this.loadProperties();
67
 
    }
68
 
 
69
 
    public void update(){
70
 
        int lastStatus = this.status;
71
 
        
72
 
        if(TuxGuitar.instance().getPlayer().isRunning()){
73
 
                this.status = STATUS_RUNNING;                                   
74
 
                }else if(TuxGuitar.instance().getPlayer().isPaused()){
75
 
                        this.status = STATUS_PAUSED;
76
 
                }else{
77
 
                        this.status = STATUS_STOPED;
78
 
        }               
79
 
                
80
 
                if(lastStatus != this.status){
81
 
                        if(this.status == STATUS_RUNNING){
82
 
                                this.stop.setImage(SystemImages.TRANSPORT_ICON_STOP_2);
83
 
                                this.play.setImage(SystemImages.TRANSPORT_ICON_PAUSE);                          
84
 
                        }else if(this.status == STATUS_PAUSED){
85
 
                                this.stop.setImage(SystemImages.TRANSPORT_ICON_STOP_2);
86
 
                                this.play.setImage(SystemImages.TRANSPORT_ICON_PLAY_2);                                 
87
 
                        }else if(this.status == STATUS_STOPED){
88
 
                                this.stop.setImage(SystemImages.TRANSPORT_ICON_STOP_1);
89
 
                                this.play.setImage(SystemImages.TRANSPORT_ICON_PLAY_1);
90
 
                        }       
91
 
                }      
92
 
    }
93
 
    
94
 
    public void loadProperties(){
95
 
        this.playMenuItem.setText(TuxGuitar.getProperty("player"));  
96
 
        this.play.setText(TuxGuitar.getProperty("player.start"));
97
 
        this.stop.setText(TuxGuitar.getProperty("player.stop"));
98
 
    }         
99
 
}