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

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/gui/items/menu/ViewMenuItem.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
/*
 
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.widgets.Menu;
 
11
import org.eclipse.swt.widgets.MenuItem;
 
12
import org.eclipse.swt.widgets.Shell;
 
13
import org.herac.tuxguitar.gui.TuxGuitar;
 
14
import org.herac.tuxguitar.gui.actions.layout.SetChordDiagramEnabledAction;
 
15
import org.herac.tuxguitar.gui.actions.layout.SetChordNameEnabledAction;
 
16
import org.herac.tuxguitar.gui.actions.layout.SetCompactViewAction;
 
17
import org.herac.tuxguitar.gui.actions.layout.SetLinearLayoutAction;
 
18
import org.herac.tuxguitar.gui.actions.layout.SetMultitrackViewAction;
 
19
import org.herac.tuxguitar.gui.actions.layout.SetPageLayoutAction;
 
20
import org.herac.tuxguitar.gui.actions.layout.SetScoreEnabledAction;
 
21
import org.herac.tuxguitar.gui.actions.layout.SetTablatureEnabledAction;
 
22
import org.herac.tuxguitar.gui.actions.view.ShowFretBoardAction;
 
23
import org.herac.tuxguitar.gui.actions.view.ShowMatrixAction;
 
24
import org.herac.tuxguitar.gui.actions.view.ShowMixerAction;
 
25
import org.herac.tuxguitar.gui.actions.view.ShowPianoAction;
 
26
import org.herac.tuxguitar.gui.actions.view.ShowTransportAction;
 
27
import org.herac.tuxguitar.gui.editors.tab.layout.LinearViewLayout;
 
28
import org.herac.tuxguitar.gui.editors.tab.layout.PageViewLayout;
 
29
import org.herac.tuxguitar.gui.editors.tab.layout.ViewLayout;
 
30
import org.herac.tuxguitar.gui.items.MenuItems;
 
31
 
 
32
/**
 
33
 * @author julian
 
34
 *
 
35
 * TODO To change the template for this generated type comment go to
 
36
 * Window - Preferences - Java - Code Style - Code Templates
 
37
 */
 
38
public class ViewMenuItem implements MenuItems{
 
39
        
 
40
        private Menu menu;
 
41
        private Menu chordMenu;
 
42
        private MenuItem layoutMenuItem;
 
43
        private MenuItem showMixer;
 
44
        private MenuItem showTransport;
 
45
        private MenuItem showFretBoard;
 
46
        private MenuItem showPiano;
 
47
        private MenuItem showMatrix;
 
48
        private MenuItem pageLayout;
 
49
        private MenuItem linearLayout;
 
50
        private MenuItem multitrack;
 
51
        private MenuItem scoreEnabled;
 
52
        private MenuItem tablatureEnabled;
 
53
        private MenuItem compact;
 
54
        
 
55
        private MenuItem chordMenuItem;
 
56
        private MenuItem chordName;
 
57
        private MenuItem chordDiagram;
 
58
        
 
59
        public ViewMenuItem(Shell shell,Menu parent, int style) {
 
60
                this.layoutMenuItem = new MenuItem(parent, style);
 
61
                this.menu = new Menu(shell, SWT.DROP_DOWN);
 
62
        }
 
63
        
 
64
        public void showItems(){
 
65
                //--MIXER--
 
66
                this.showMixer = new MenuItem(this.menu, SWT.CHECK);
 
67
                this.showMixer.addSelectionListener(TuxGuitar.instance().getAction(ShowMixerAction.NAME));
 
68
                
 
69
                //--TRANSPORT--
 
70
                this.showTransport = new MenuItem(this.menu, SWT.CHECK);
 
71
                this.showTransport.addSelectionListener(TuxGuitar.instance().getAction(ShowTransportAction.NAME));
 
72
                
 
73
                //--FRETBOARD--
 
74
                this.showFretBoard = new MenuItem(this.menu, SWT.CHECK);
 
75
                this.showFretBoard.addSelectionListener(TuxGuitar.instance().getAction(ShowFretBoardAction.NAME));
 
76
                
 
77
                //--PIANO--
 
78
                this.showPiano = new MenuItem(this.menu, SWT.CHECK);
 
79
                this.showPiano.addSelectionListener(TuxGuitar.instance().getAction(ShowPianoAction.NAME));
 
80
                
 
81
                //--MATRIX--
 
82
                this.showMatrix = new MenuItem(this.menu, SWT.CHECK);
 
83
                this.showMatrix.addSelectionListener(TuxGuitar.instance().getAction(ShowMatrixAction.NAME));
 
84
                
 
85
                new MenuItem(this.menu, SWT.SEPARATOR);
 
86
                
 
87
                //--PAGE LAYOUT--
 
88
                this.pageLayout = new MenuItem(this.menu, SWT.RADIO);
 
89
                this.pageLayout.addSelectionListener(TuxGuitar.instance().getAction(SetPageLayoutAction.NAME));
 
90
                
 
91
                //--LINEAR LAYOUT--
 
92
                this.linearLayout = new MenuItem(this.menu, SWT.RADIO);
 
93
                this.linearLayout.addSelectionListener(TuxGuitar.instance().getAction(SetLinearLayoutAction.NAME));
 
94
                
 
95
                //--MULTITRACK--
 
96
                this.multitrack = new MenuItem(this.menu, SWT.CHECK);
 
97
                this.multitrack.addSelectionListener(TuxGuitar.instance().getAction(SetMultitrackViewAction.NAME));
 
98
                
 
99
                //--SCORE
 
100
                this.scoreEnabled = new MenuItem(this.menu, SWT.CHECK);
 
101
                this.scoreEnabled.addSelectionListener(TuxGuitar.instance().getAction(SetScoreEnabledAction.NAME));
 
102
                
 
103
                //--SCORE
 
104
                this.tablatureEnabled = new MenuItem(this.menu, SWT.CHECK);
 
105
                this.tablatureEnabled.addSelectionListener(TuxGuitar.instance().getAction(SetTablatureEnabledAction.NAME));
 
106
                
 
107
                //--COMPACT
 
108
                this.compact = new MenuItem(this.menu, SWT.CHECK);
 
109
                this.compact.addSelectionListener(TuxGuitar.instance().getAction(SetCompactViewAction.NAME));
 
110
                
 
111
                new MenuItem(this.menu, SWT.SEPARATOR);
 
112
                
 
113
                //--CHORD STYLE
 
114
                this.chordMenuItem = new MenuItem(this.menu,SWT.CASCADE);
 
115
                this.chordMenu = new Menu(this.menu.getShell(), SWT.DROP_DOWN);
 
116
                
 
117
                this.chordName = new MenuItem(this.chordMenu, SWT.CHECK);
 
118
                this.chordName.addSelectionListener(TuxGuitar.instance().getAction(SetChordNameEnabledAction.NAME));
 
119
                
 
120
                this.chordDiagram = new MenuItem(this.chordMenu, SWT.CHECK);
 
121
                this.chordDiagram.addSelectionListener(TuxGuitar.instance().getAction(SetChordDiagramEnabledAction.NAME));
 
122
                
 
123
                this.chordMenuItem.setMenu(this.chordMenu);
 
124
                this.layoutMenuItem.setMenu(this.menu);
 
125
                
 
126
                this.loadIcons();
 
127
                this.loadProperties();
 
128
        }
 
129
        
 
130
        public void update(){
 
131
                ViewLayout layout = TuxGuitar.instance().getTablatureEditor().getTablature().getViewLayout();
 
132
                int style = layout.getStyle();
 
133
                this.showMixer.setSelection(!TuxGuitar.instance().getMixer().isDisposed());
 
134
                this.showTransport.setSelection(!TuxGuitar.instance().getTransport().isDisposed());
 
135
                this.showFretBoard.setSelection(TuxGuitar.instance().getFretBoardEditor().isVisible());
 
136
                this.showPiano.setSelection(!TuxGuitar.instance().getPianoEditor().isDisposed());
 
137
                this.showMatrix.setSelection(!TuxGuitar.instance().getMatrixEditor().isDisposed());
 
138
                this.pageLayout.setSelection(layout instanceof PageViewLayout);
 
139
                this.linearLayout.setSelection(layout instanceof LinearViewLayout);
 
140
                this.multitrack.setSelection( (style & ViewLayout.DISPLAY_MULTITRACK) != 0 );
 
141
                this.scoreEnabled.setSelection( (style & ViewLayout.DISPLAY_SCORE) != 0 );
 
142
                this.tablatureEnabled.setSelection( (style & ViewLayout.DISPLAY_TABLATURE) != 0 );
 
143
                this.compact.setSelection( (style & ViewLayout.DISPLAY_COMPACT) != 0 );
 
144
                this.compact.setEnabled((style & ViewLayout.DISPLAY_MULTITRACK) == 0 || layout.getSongManager().getSong().countTracks() == 1);
 
145
                this.chordName.setSelection( (style & ViewLayout.DISPLAY_CHORD_NAME) != 0 );
 
146
                this.chordDiagram.setSelection( (style & ViewLayout.DISPLAY_CHORD_DIAGRAM) != 0 );
 
147
        }
 
148
        
 
149
        public void loadProperties(){
 
150
                this.layoutMenuItem.setText(TuxGuitar.getProperty("view"));
 
151
                this.showMixer.setText(TuxGuitar.getProperty("view.show-mixer"));
 
152
                this.showTransport.setText(TuxGuitar.getProperty("view.show-transport"));
 
153
                this.showFretBoard.setText(TuxGuitar.getProperty("view.show-fretboard"));
 
154
                this.showPiano.setText(TuxGuitar.getProperty("view.show-piano"));
 
155
                this.showMatrix.setText(TuxGuitar.getProperty("view.show-matrix"));
 
156
                this.pageLayout.setText(TuxGuitar.getProperty("view.layout.page"));
 
157
                this.linearLayout.setText(TuxGuitar.getProperty("view.layout.linear"));
 
158
                this.multitrack.setText(TuxGuitar.getProperty("view.layout.multitrack"));
 
159
                this.scoreEnabled.setText(TuxGuitar.getProperty("view.layout.score-enabled"));
 
160
                this.tablatureEnabled.setText(TuxGuitar.getProperty("view.layout.tablature-enabled"));
 
161
                this.compact.setText(TuxGuitar.getProperty("view.layout.compact"));
 
162
                this.chordMenuItem.setText(TuxGuitar.getProperty("view.layout.chord-style"));
 
163
                this.chordName.setText(TuxGuitar.getProperty("view.layout.chord-name"));
 
164
                this.chordDiagram.setText(TuxGuitar.getProperty("view.layout.chord-diagram"));
 
165
        }
 
166
        
 
167
        public void loadIcons(){
 
168
                //Nothing to do
 
169
        }
 
170
}