01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.swt.internal.theme;
11:
12: import org.eclipse.swt.SWT;
13: import org.eclipse.swt.graphics.*;
14: import org.eclipse.swt.internal.win32.*;
15:
16: public class TabFolderDrawData extends DrawData {
17: public int tabsWidth;
18: public int tabsHeight;
19: public Rectangle tabsArea;
20: public int selectedX;
21: public int selectedWidth;
22: public int spacing;
23:
24: public TabFolderDrawData() {
25: state = new int[1];
26: if (SWT.getPlatform().equals("gtk")) {
27: spacing = -2;
28: }
29: }
30:
31: void draw(Theme theme, GC gc, Rectangle bounds) {
32: if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed()) {
33: int /*long*/hTheme = OS.OpenThemeData(0, getClassId());
34: RECT rect = new RECT();
35: rect.left = bounds.x;
36: rect.right = bounds.x + bounds.width;
37: rect.top = bounds.y;
38: if ((style & SWT.BOTTOM) != 0) {
39: rect.bottom = bounds.y + bounds.height - tabsHeight;
40: } else {
41: rect.top += tabsHeight;
42: rect.bottom = bounds.y + bounds.height;
43: }
44: int[] part = getPartId(DrawData.WIDGET_WHOLE);
45: OS.DrawThemeBackground(hTheme, gc.handle, part[0], part[1],
46: 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)
71: iStateId = OS.TIS_HOT;
72: if ((state & DrawData.SELECTED) != 0)
73: iStateId = OS.TIS_SELECTED;
74: }
75: return new int[] { iPartId, iStateId };
76: }
77:
78: int hit(Theme theme, Point position, Rectangle bounds) {
79: if (!bounds.contains(position))
80: return DrawData.WIDGET_NOWHERE;
81: return DrawData.WIDGET_WHOLE;
82: }
83:
84: }
|