2
* Created on 28-ene-2006
4
* TODO To change the template for this generated file go to
5
* Window - Preferences - Java - Code Style - Code Templates
7
package org.herac.tuxguitar.gui.table;
9
import org.eclipse.swt.SWT;
10
import org.eclipse.swt.custom.SashForm;
11
import org.eclipse.swt.layout.GridData;
12
import org.eclipse.swt.layout.GridLayout;
13
import org.eclipse.swt.widgets.Button;
14
import org.eclipse.swt.widgets.Composite;
15
import org.eclipse.swt.widgets.Control;
16
import org.herac.tuxguitar.gui.editors.TablatureEditor;
21
* TODO To change the template for this generated type comment go to
22
* Window - Preferences - Java - Code Style - Code Templates
24
public class SongTable extends Composite{
25
private TablatureEditor editor;
26
private SashForm form;
27
private SongTableColumn[] columns;
29
public SongTable(Composite parent,int columns,TablatureEditor editor) {
30
super(parent,SWT.NONE);
32
this.setLayout(makeLayout());
33
this.setLayoutData(new GridData(SWT.FILL,SWT.TOP,true,false,0,0));
35
this.form = new SashForm(this,SWT.HORIZONTAL);
36
this.form.setLayoutData(new GridData(SWT.FILL,SWT.TOP,true,false,0,0));
37
this.form.SASH_WIDTH = 1;
39
this.makeColumns(columns);
42
private GridLayout makeLayout(){
43
GridLayout layout = new GridLayout();
45
layout.marginBottom = 0;
46
layout.marginLeft = 0;
47
layout.marginRight = 0;
48
layout.marginHeight = 0;
49
layout.marginWidth = 0;
50
layout.horizontalSpacing = 0;
51
layout.verticalSpacing = 0;
55
public void makeColumns(int columns){
56
this.columns = new SongTableColumn[columns];
57
for(int i = 0; i< columns;i++){
58
this.columns[i] = new SongTableColumn(this.form);
62
public SongTableColumn getColumn(int index){
63
return this.columns[index];
66
public void clearColumnsAfter(int index){
67
for(int i = 0; i< this.columns.length;i++){
68
this.columns[i].clearAfter(index);
72
public int getItemCount(){
73
return getColumn(0).getItemCount();
76
public int getHeaderHeight(){
77
return getColumn(0).getHeaderHeight();
82
for(int i = 0; i< this.columns.length;i++){
83
this.columns[i].layout();
88
public void setWeights(int[] weights){
89
this.form.setWeights(weights);
93
public class SongTableColumn extends Composite{
94
private Button header;
96
public SongTableColumn(Composite parent){
97
super(parent,SWT.NONE);
98
this.setLayout(makeLayout());
99
this.header = new Button(this,SWT.LEFT);
100
this.header.setLayoutData(new GridData(SWT.FILL,SWT.TOP,true,false,0,0));
103
private GridLayout makeLayout(){
104
GridLayout layout = new GridLayout();
105
layout.marginTop = 0;
106
layout.marginBottom = 0;
107
layout.marginLeft = 0;
108
layout.marginRight = 0;
109
layout.marginHeight = 0;
110
layout.marginWidth = 0;
111
layout.horizontalSpacing = 0;
112
layout.verticalSpacing = 0;
116
public void setName(String name){
117
this.header.setText(name);
120
public int getItemCount(){
121
return getChildren().length - 1;
124
public int getItemHeight(){
125
Control[] controls = getChildren();
126
return controls[1].getBounds().height;
129
public Control getItem(int index){
130
Control[] controls = getChildren();
131
return controls[index + 1];
134
public int getHeaderHeight(){
135
return this.header.getBounds().height;
138
public boolean isEmpty(){
139
return getChildren().length <= 1;
142
public void clearAfter(int index){
143
Control[] controls = getChildren();
144
for(int i = (index + 1);i < controls.length;i++){
145
controls[i].dispose();