KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > swt > internal > theme > TabFolderDrawData


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.swt.internal.theme;
12
13 import org.eclipse.swt.SWT;
14 import org.eclipse.swt.graphics.*;
15 import org.eclipse.swt.internal.win32.*;
16
17 public class TabFolderDrawData extends DrawData {
18     public int tabsWidth;
19     public int tabsHeight;
20     public Rectangle tabsArea;
21     public int selectedX;
22     public int selectedWidth;
23     public int spacing;
24     
25 public TabFolderDrawData() {
26     state = new int[1];
27     if (SWT.getPlatform().equals("gtk")) {
28         spacing = -2;
29     }
30 }
31
32 void draw(Theme theme, GC gc, Rectangle bounds) {
33     if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) {
34         int hTheme = OS.OpenThemeData(0, getClassId());
35         RECT rect = new RECT ();
36         rect.left = bounds.x;
37         rect.right = bounds.x + bounds.width;
38         rect.top = bounds.y;
39         if ((style & SWT.BOTTOM) != 0) {
40             rect.bottom = bounds.y + bounds.height - tabsHeight;
41         } else {
42             rect.top += tabsHeight;
43             rect.bottom = bounds.y + bounds.height;
44         }
45         int[] part = getPartId(DrawData.WIDGET_WHOLE);
46         OS.DrawThemeBackground (hTheme, gc.handle, part[0], part[1], rect, null);
47         OS.CloseThemeData(hTheme);
48         if (tabsArea != null) {
49             tabsArea.x = bounds.x;
50             tabsArea.y = bounds.y;
51             tabsArea.width = bounds.width;
52             tabsArea.height = tabsHeight;
53             if ((style & SWT.BOTTOM) != 0) {
54                 tabsArea.y += bounds.height - tabsHeight;
55             }
56         }
57     }
58 }
59
60 char[] getClassId() {
61     return TAB;
62 }
63
64 int[] getPartId(int part) {
65     int state = this.state[part];
66     int iPartId = OS.TABP_PANE, iStateId = OS.TIS_NORMAL;
67     if ((state & DrawData.DISABLED) != 0) {
68         iStateId = OS.TIS_DISABLED;
69     } else {
70         if ((state & DrawData.HOT) != 0) iStateId = OS.TIS_HOT;
71         if ((state & DrawData.SELECTED) != 0) iStateId = OS.TIS_SELECTED;
72     }
73     return new int[]{iPartId, iStateId};
74 }
75
76 int hit(Theme theme, Point position, Rectangle bounds) {
77     if (!bounds.contains(position)) return DrawData.WIDGET_NOWHERE;
78     return DrawData.WIDGET_WHOLE;
79 }
80
81 }
82
Popular Tags