View Javadoc

1   /*
2    *  File: ITableHeaderRenderer.java 
3    *  Copyright (c) 2004-2007  Peter Kliem (Peter.Kliem@jaret.de)
4    *  A commercial license is available, see http://www.jaret.de.
5    *
6    * All rights reserved. This program and the accompanying materials
7    * are made available under the terms of the Common Public License v1.0
8    * which accompanies this distribution, and is available at
9    * http://www.eclipse.org/legal/cpl-v10.html
10   */
11  package de.jaret.util.ui.table.renderer;
12  
13  import org.eclipse.swt.graphics.GC;
14  import org.eclipse.swt.graphics.Rectangle;
15  import org.eclipse.swt.printing.Printer;
16  
17  import de.jaret.util.ui.table.model.IColumn;
18  
19  /***
20   * Interface describing a header renderer for the jaret table.
21   * 
22   * @author Peter Kliem
23   * @version $Id: ITableHeaderRenderer.java 608 2007-10-23 19:24:34Z kliem $
24   */
25  public interface ITableHeaderRenderer {
26      /***
27       * Draw a table header.
28       * 
29       * @param gc GC to be used
30       * @param rectangle rectangle to draw within
31       * @param column the column for which the header is painted.
32       * @param sortingPosition if the column is part of the sorting set this indicates the sorting order position. A
33       * value of 0 means no sorting.
34       * @param sortDir if sorting this indicates the sorting direction. <code>true</code> means ascending.
35       * @param printing true if the draw operation is for a printer
36       */
37      void draw(GC gc, Rectangle rectangle, IColumn column, int sortingPosition, boolean sortDir, boolean printing);
38  
39      /***
40       * If this method returns <code>true</code> the gc for drawing will not be limited by a clipping rect. This is
41       * useful for slanted header texts but should be used with the appropriate care.
42       * 
43       * @return true if the rendering should not be clipped.
44       */
45      boolean disableClipping();
46  
47      /***
48       * Check whether a click hits the area reserved for sorting indication.
49       * 
50       * @param drawingArea drawing aea of the header
51       * @param column column
52       * @param x x coordinat of the click
53       * @param y y coordinate of the click
54       * @return true if the click is in the area that should be active for sorting
55       */
56      boolean isSortingClick(Rectangle drawingArea, IColumn column, int x, int y);
57  
58      /***
59       * Create a table header renderer for printing.
60       * 
61       * @param printer the printer that will be used
62       * @return a configured header renderer for printing.
63       */
64      ITableHeaderRenderer getPrintRenderer(Printer printer);
65  
66      /***
67       * Dispose any resources allocated.
68       * 
69       */
70      void dispose();
71  
72  }