From 093c579a4ffd9551acb901bba9617e7aa776989d Mon Sep 17 00:00:00 2001 From: Silenio Quarti Date: Wed, 1 Jul 2009 14:50:54 +0000 Subject: restore HEAD after accidental deletion by error in automated build script --- .../gtk/org/eclipse/swt/internal/theme/Theme.java | 267 +++++++++++++++++++++ 1 file changed, 267 insertions(+) create mode 100644 bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/Theme.java (limited to 'bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/Theme.java') diff --git a/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/Theme.java b/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/Theme.java new file mode 100644 index 0000000000..a174a93105 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT Theme/gtk/org/eclipse/swt/internal/theme/Theme.java @@ -0,0 +1,267 @@ +/******************************************************************************* + * 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.*; +import org.eclipse.swt.internal.gtk.*; + +public class Theme { + Device device; + + int /*long*/ shellHandle, fixedHandle, buttonHandle, arrowHandle, + frameHandle, entryHandle, checkButtonHandle, radioButtonHandle, + notebookHandle, treeHandle, progressHandle, toolbarHandle, + labelHandle, separatorHandle; + +public Theme(Device device) { + this.device = device; + shellHandle = OS.gtk_window_new (OS.GTK_WINDOW_TOPLEVEL); + fixedHandle = OS.gtk_fixed_new(); + buttonHandle = OS.gtk_button_new(); + arrowHandle = OS.gtk_arrow_new(OS.GTK_ARROW_DOWN, OS.GTK_SHADOW_NONE); + checkButtonHandle = OS.gtk_check_button_new(); + frameHandle = OS.gtk_check_button_new(); + entryHandle = OS.gtk_entry_new(); + radioButtonHandle = OS.gtk_radio_button_new(0); + notebookHandle = OS.gtk_notebook_new(); + progressHandle = OS.gtk_progress_bar_new(); + toolbarHandle = OS.gtk_toolbar_new(); + treeHandle = OS.gtk_tree_view_new_with_model(0); + separatorHandle = OS.gtk_vseparator_new(); + labelHandle = OS.gtk_label_new(null); + OS.gtk_container_add (fixedHandle, labelHandle); + OS.gtk_container_add (fixedHandle, frameHandle); + OS.gtk_container_add (fixedHandle, entryHandle); + OS.gtk_container_add (fixedHandle, separatorHandle); + OS.gtk_container_add (fixedHandle, arrowHandle); + OS.gtk_container_add (fixedHandle, toolbarHandle); + OS.gtk_container_add (fixedHandle, progressHandle); + OS.gtk_container_add (fixedHandle, checkButtonHandle); + OS.gtk_container_add (fixedHandle, radioButtonHandle); + OS.gtk_container_add (fixedHandle, buttonHandle); + OS.gtk_container_add (fixedHandle, treeHandle); + OS.gtk_container_add (fixedHandle, notebookHandle); + OS.gtk_container_add (shellHandle, fixedHandle); + OS.gtk_widget_realize (separatorHandle); + OS.gtk_widget_realize (labelHandle); + OS.gtk_widget_realize (frameHandle); + OS.gtk_widget_realize (entryHandle); + OS.gtk_widget_realize (arrowHandle); + OS.gtk_widget_realize (buttonHandle); + OS.gtk_widget_realize (treeHandle); + OS.gtk_widget_realize (notebookHandle); + OS.gtk_widget_realize (checkButtonHandle); + OS.gtk_widget_realize (radioButtonHandle); + OS.gtk_widget_realize (progressHandle); + OS.gtk_widget_realize (toolbarHandle); + OS.gtk_widget_realize (shellHandle); +} + +//TODO - share this code +static int /*long*/ createPixbuf(Image image) { + int [] w = new int [1], h = new int [1]; + OS.gdk_drawable_get_size (image.pixmap, w, h); + int /*long*/ colormap = OS.gdk_colormap_get_system (); + int /*long*/ pixbuf; + boolean hasMask = image.mask != 0 && OS.gdk_drawable_get_depth (image.mask) == 1; + if (hasMask) { + pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, true, 8, w [0], h [0]); + if (pixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES); + OS.gdk_pixbuf_get_from_drawable (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]); + int /*long*/ maskPixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, w [0], h [0]); + if (maskPixbuf == 0) SWT.error (SWT.ERROR_NO_HANDLES); + OS.gdk_pixbuf_get_from_drawable(maskPixbuf, image.mask, 0, 0, 0, 0, 0, w [0], h [0]); + int stride = OS.gdk_pixbuf_get_rowstride(pixbuf); + int /*long*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf); + byte[] line = new byte[stride]; + int maskStride = OS.gdk_pixbuf_get_rowstride(maskPixbuf); + int /*long*/ maskPixels = OS.gdk_pixbuf_get_pixels(maskPixbuf); + byte[] maskLine = new byte[maskStride]; + for (int y=0; y