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.graphics.*;
13: import org.eclipse.swt.internal.win32.*;
14:
15: public class GroupDrawData extends DrawData {
16: public int headerWidth;
17: public int headerHeight;
18: public Rectangle headerArea;
19:
20: public GroupDrawData() {
21: state = new int[1];
22: }
23:
24: static final int GROUP_HEADER_X = 9;
25: static final int GROUP_HEADER_PAD = 2;
26:
27: void draw(Theme theme, GC gc, Rectangle bounds) {
28: if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed()) {
29: int /*long*/hTheme = OS.OpenThemeData(0, getClassId());
30: RECT rect = new RECT();
31: rect.left = bounds.x;
32: rect.right = bounds.x + bounds.width;
33: rect.top = bounds.y + this .headerHeight / 2;
34: rect.bottom = bounds.y + bounds.height;
35: int headerX = bounds.x + GROUP_HEADER_X, headerY = bounds.y;
36: int savedDC = OS.SaveDC(gc.handle);
37: OS.ExcludeClipRect(gc.handle, headerX - GROUP_HEADER_PAD,
38: headerY, headerX + this .headerWidth
39: + GROUP_HEADER_PAD, headerY
40: + this .headerHeight);
41: int[] part = getPartId(DrawData.WIDGET_WHOLE);
42: OS.DrawThemeBackground(hTheme, gc.handle, part[0], part[1],
43: rect, null);
44: OS.RestoreDC(gc.handle, savedDC);
45: Rectangle headerArea = this .headerArea;
46: if (headerArea != null) {
47: headerArea.x = headerX;
48: headerArea.y = headerY;
49: headerArea.width = this .headerWidth;
50: headerArea.height = this .headerHeight;
51: }
52: Rectangle clientArea = this .clientArea;
53: if (clientArea != null) {
54: RECT contentRect = new RECT();
55: OS.GetThemeBackgroundContentRect(hTheme, gc.handle,
56: part[0], part[1], rect, contentRect);
57: clientArea.x = contentRect.left;
58: clientArea.y = contentRect.top;
59: clientArea.width = contentRect.right - contentRect.left;
60: clientArea.height = contentRect.bottom
61: - contentRect.top;
62: }
63: OS.CloseThemeData(hTheme);
64: }
65: }
66:
67: int[] getPartId(int part) {
68: int state = this .state[part];
69: int iPartId = OS.BP_GROUPBOX, iStateId = OS.GBS_NORMAL;
70: if ((state & DrawData.DISABLED) != 0)
71: iStateId = OS.GBS_DISABLED;
72: return new int[] { iPartId, iStateId };
73: }
74:
75: int hit(Theme theme, Point position, Rectangle bounds) {
76: return bounds.contains(position) ? DrawData.WIDGET_WHOLE
77: : DrawData.WIDGET_NOWHERE;
78: }
79:
80: }
|