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.*;
13: import org.eclipse.swt.graphics.*;
14: import org.eclipse.swt.internal.win32.*;
15:
16: public class ExpanderDrawData extends DrawData {
17:
18: public ExpanderDrawData() {
19: state = new int[1];
20: }
21:
22: void draw(Theme theme, GC gc, Rectangle bounds) {
23: if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed()) {
24: int /*long*/hTheme = OS.OpenThemeData(0, getClassId());
25: int iStateId = OS.GLPS_CLOSED;
26: if ((this .style & SWT.DOWN) != 0)
27: iStateId = OS.GLPS_OPENED;
28: SIZE size = new SIZE();
29: OS.GetThemePartSize(hTheme, gc.handle, OS.TVP_GLYPH,
30: iStateId, null, OS.TS_TRUE, size);
31: RECT rect = new RECT();
32: rect.left = bounds.x;
33: rect.right = rect.left + size.cx;
34: rect.top = bounds.y;
35: rect.bottom = rect.top + size.cy;
36: OS.DrawThemeBackground(hTheme, gc.handle, OS.TVP_GLYPH,
37: iStateId, rect, null);
38: OS.CloseThemeData(hTheme);
39: }
40: }
41:
42: char[] getClassId() {
43: return TREEVIEW;
44: }
45:
46: int[] getPartId(int part) {
47: int iPartId = OS.TVP_GLYPH;
48: int iStateId = OS.GLPS_CLOSED;
49: if ((this .style & SWT.DOWN) != 0)
50: iStateId = OS.GLPS_OPENED;
51: return new int[] { iPartId, iStateId };
52: }
53:
54: int hit(Theme theme, Point position, Rectangle bounds) {
55: if (!(OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed()))
56: return DrawData.WIDGET_NOWHERE;
57: if (!bounds.contains(position))
58: return DrawData.WIDGET_NOWHERE;
59: int /*long*/hTheme = OS.OpenThemeData(0, getClassId());
60: SIZE size = new SIZE();
61: int[] part = getPartId(DrawData.WIDGET_WHOLE);
62: OS.GetThemePartSize(hTheme, 0, part[0], part[1], null,
63: OS.TS_TRUE, size);
64: OS.CloseThemeData(hTheme);
65: if (new Rectangle(bounds.x, bounds.y, size.cx, size.cy)
66: .contains(position)) {
67: return DrawData.WIDGET_WHOLE;
68: }
69: return DrawData.WIDGET_NOWHERE;
70: }
71:
72: }
|