Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT Theme/carbon/org/eclipse/swt/internal/theme/ExpanderDrawData.java')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Theme/carbon/org/eclipse/swt/internal/theme/ExpanderDrawData.java77
1 files changed, 77 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/carbon/org/eclipse/swt/internal/theme/ExpanderDrawData.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/carbon/org/eclipse/swt/internal/theme/ExpanderDrawData.java
new file mode 100644
index 0000000000..9c04a0c68d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/carbon/org/eclipse/swt/internal/theme/ExpanderDrawData.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.internal.theme;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.carbon.OS;
+import org.eclipse.swt.internal.carbon.CGRect;
+import org.eclipse.swt.internal.carbon.HIThemeButtonDrawInfo;
+
+public class ExpanderDrawData extends DrawData {
+
+public ExpanderDrawData() {
+ state = new int[1];
+}
+
+HIThemeButtonDrawInfo getInfo() {
+ int state = this.state[DrawData.WIDGET_WHOLE];
+ HIThemeButtonDrawInfo info = new HIThemeButtonDrawInfo();
+ info.version = 0;
+ info.kind = OS.kThemeDisclosureTriangle;
+ if ((style & SWT.DOWN) != 0) {
+ info.value = OS.kThemeButtonOn;
+ } else {
+ info.value = OS.kThemeButtonOff;
+ }
+ if ((state & DrawData.PRESSED) != 0) {
+ info.state = OS.kThemeStatePressed;
+ } else {
+ if ((state & DrawData.ACTIVE) != 0) {
+ info.state = (state & DrawData.DISABLED) == 0 ? OS.kThemeStateActive : OS.kThemeStateUnavailable;
+ } else {
+ info.state = (state & DrawData.DISABLED) == 0 ? OS.kThemeStateInactive : OS.kThemeStateUnavailableInactive;
+ }
+ }
+ return info;
+}
+
+void draw(Theme theme, GC gc, Rectangle bounds) {
+ HIThemeButtonDrawInfo info = getInfo();
+ CGRect rect = new CGRect();
+ rect.x = bounds.x;
+ rect.y = bounds.y;
+ rect.width = bounds.width;
+ rect.height = bounds.height;
+ CGRect backRect = new CGRect();
+ OS.HIThemeGetButtonBackgroundBounds(rect, info, backRect);
+ rect.x += (rect.x - backRect.x);
+ rect.y += (rect.y - backRect.y);
+ int[] metric = new int[1];
+ OS.GetThemeMetric(OS.kThemeMetricDisclosureTriangleWidth, metric);
+ rect.width = metric[0];
+ OS.GetThemeMetric(OS.kThemeMetricDisclosureTriangleHeight, metric);
+ rect.height = metric[0];
+ OS.HIThemeDrawButton(rect, info, gc.handle, OS.kHIThemeOrientationNormal, null);
+}
+
+int hit(Theme theme, Point position, Rectangle bounds) {
+ if (!bounds.contains(position)) return DrawData.WIDGET_NOWHERE;
+ int[] metric = new int[1];
+ OS.GetThemeMetric(OS.kThemeMetricDisclosureTriangleWidth, metric);
+ int width = metric[0];
+ OS.GetThemeMetric(OS.kThemeMetricDisclosureTriangleHeight, metric);
+ int height = metric[0];
+ if (new Rectangle(bounds.x, bounds.y, width, height).contains(position)) return DrawData.WIDGET_WHOLE;
+ return DrawData.WIDGET_NOWHERE;
+}
+
+}

Back to the top