jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKEngine.java
author rriggs
Tue, 03 Jun 2014 11:18:03 -0400
changeset 25122 1ecc464c69d2
parent 5506 202f599c92aa
permissions -rw-r--r--
8044460: Cleanup new Boolean and single character strings Reviewed-by: pchelko, serb, rriggs Contributed-by: otaviopolianasantana@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1837
diff changeset
     2
 * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1837
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1837
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1837
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1837
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1837
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.java.swing.plaf.gtk;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.image.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.swing.plaf.synth.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import com.sun.java.swing.plaf.gtk.GTKConstants.ArrowType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import com.sun.java.swing.plaf.gtk.GTKConstants.ExpanderStyle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import com.sun.java.swing.plaf.gtk.GTKConstants.Orientation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import com.sun.java.swing.plaf.gtk.GTKConstants.PositionType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import com.sun.java.swing.plaf.gtk.GTKConstants.ShadowType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import com.sun.java.swing.plaf.gtk.GTKConstants.TextDirection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import sun.awt.image.SunWritableRaster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import sun.swing.ImageCache;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * GTKEngine delegates all painting job to native GTK libraries.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * Painting with GTKEngine looks like this:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * First, startPainting() is called. It prepares an offscreen buffer of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *   required size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * Then, any number of paintXXX() methods can be called. They effectively ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *   the Graphics parameter and draw to the offscreen buffer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * Finally, finishPainting() should be called. It fills the data buffer passed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *   in with the image data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * @author Josh Outwater
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
class GTKEngine {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    final static GTKEngine INSTANCE = new GTKEngine();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /** Size of the image cache */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private static final int CACHE_SIZE = 50;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    /** This enum mirrors that in gtk2_interface.h */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    static enum WidgetType {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        BUTTON, CHECK_BOX, CHECK_BOX_MENU_ITEM, COLOR_CHOOSER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        COMBO_BOX, COMBO_BOX_ARROW_BUTTON, COMBO_BOX_TEXT_FIELD,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        DESKTOP_ICON, DESKTOP_PANE, EDITOR_PANE, FORMATTED_TEXT_FIELD,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        HANDLE_BOX, HPROGRESS_BAR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        HSCROLL_BAR, HSCROLL_BAR_BUTTON_LEFT, HSCROLL_BAR_BUTTON_RIGHT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        HSCROLL_BAR_TRACK, HSCROLL_BAR_THUMB,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        HSEPARATOR, HSLIDER, HSLIDER_TRACK, HSLIDER_THUMB, HSPLIT_PANE_DIVIDER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        INTERNAL_FRAME, INTERNAL_FRAME_TITLE_PANE, IMAGE, LABEL, LIST, MENU,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        MENU_BAR, MENU_ITEM, MENU_ITEM_ACCELERATOR, OPTION_PANE, PANEL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        PASSWORD_FIELD, POPUP_MENU, POPUP_MENU_SEPARATOR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        RADIO_BUTTON, RADIO_BUTTON_MENU_ITEM, ROOT_PANE, SCROLL_PANE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        SPINNER, SPINNER_ARROW_BUTTON, SPINNER_TEXT_FIELD,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        SPLIT_PANE, TABBED_PANE, TABBED_PANE_TAB_AREA, TABBED_PANE_CONTENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        TABBED_PANE_TAB, TABLE, TABLE_HEADER, TEXT_AREA, TEXT_FIELD, TEXT_PANE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        TITLED_BORDER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        TOGGLE_BUTTON, TOOL_BAR, TOOL_BAR_DRAG_WINDOW, TOOL_BAR_SEPARATOR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        TOOL_TIP, TREE, TREE_CELL, VIEWPORT, VPROGRESS_BAR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        VSCROLL_BAR, VSCROLL_BAR_BUTTON_UP, VSCROLL_BAR_BUTTON_DOWN,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        VSCROLL_BAR_TRACK, VSCROLL_BAR_THUMB,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        VSEPARATOR, VSLIDER, VSLIDER_TRACK, VSLIDER_THUMB,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        VSPLIT_PANE_DIVIDER
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * Representation of GtkSettings properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * When we need more settings we can add them here and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * to all implementations of getGTKSetting().
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    static enum Settings {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        GTK_FONT_NAME,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        GTK_ICON_SIZES
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /* Custom regions are needed for representing regions that don't exist
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * in the original Region class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    static class CustomRegion extends Region {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
         * TITLED_BORDER Region is mapped to GtkFrame class which can draw
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
         * titled borders around components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        static Region TITLED_BORDER = new CustomRegion("TitledBorder");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        private CustomRegion(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            super(name, null, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
1837
efd004b550b7 6771030: Code improvement and warnings removing from the com.sun.java.swing.plaf.gtk package
rupashka
parents: 2
diff changeset
   115
    private static HashMap<Region, Object> regionToWidgetTypeMap;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    private ImageCache cache = new ImageCache(CACHE_SIZE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    private int x0, y0, w0, h0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    private Graphics graphics;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    private Object[] cacheArgs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    private native void native_paint_arrow(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            int widgetType, int state, int shadowType, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            int x, int y, int width, int height, int arrowType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    private native void native_paint_box(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            int widgetType, int state, int shadowType, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            int x, int y, int width, int height, int synthState, int dir);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    private native void native_paint_box_gap(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            int widgetType, int state, int shadowType, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            int x, int y, int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            int gapSide, int gapX, int gapWidth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    private native void native_paint_check(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            int widgetType, int synthState, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            int x, int y, int width, int height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    private native void native_paint_expander(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            int widgetType, int state, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            int x, int y, int width, int height, int expanderStyle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    private native void native_paint_extension(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            int widgetType, int state, int shadowType, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            int x, int y, int width, int height, int placement);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    private native void native_paint_flat_box(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            int widgetType, int state, int shadowType, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            int x, int y, int width, int height, boolean hasFocus);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    private native void native_paint_focus(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            int widgetType, int state, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            int x, int y, int width, int height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    private native void native_paint_handle(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            int widgetType, int state, int shadowType, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            int x, int y, int width, int height, int orientation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    private native void native_paint_hline(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            int widgetType, int state, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            int x, int y, int width, int height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    private native void native_paint_option(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            int widgetType, int synthState, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            int x, int y, int width, int height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    private native void native_paint_shadow(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            int widgetType, int state, int shadowType, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            int x, int y, int width, int height, int synthState, int dir);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    private native void native_paint_slider(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            int widgetType, int state, int shadowType, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            int x, int y, int width, int height, int orientation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    private native void native_paint_vline(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            int widgetType, int state, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            int x, int y, int width, int height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    private native void native_paint_background(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            int widgetType, int state, int x, int y, int width, int height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    private native Object native_get_gtk_setting(int property);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    private native void nativeSetRangeValue(int widgetType, double value,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                                            double min, double max,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                                            double visible);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    private native void nativeStartPainting(int w, int h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    private native int nativeFinishPainting(int[] buffer, int width, int height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    private native void native_switch_theme();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        // Make sure the awt toolkit is loaded so we have access to native
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        // methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        Toolkit.getDefaultToolkit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        // Initialize regionToWidgetTypeMap
1837
efd004b550b7 6771030: Code improvement and warnings removing from the com.sun.java.swing.plaf.gtk package
rupashka
parents: 2
diff changeset
   181
        regionToWidgetTypeMap = new HashMap<Region, Object>(50);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        regionToWidgetTypeMap.put(Region.ARROW_BUTTON, new WidgetType[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            WidgetType.SPINNER_ARROW_BUTTON,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            WidgetType.COMBO_BOX_ARROW_BUTTON,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            WidgetType.HSCROLL_BAR_BUTTON_LEFT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            WidgetType.HSCROLL_BAR_BUTTON_RIGHT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            WidgetType.VSCROLL_BAR_BUTTON_UP,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            WidgetType.VSCROLL_BAR_BUTTON_DOWN});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        regionToWidgetTypeMap.put(Region.BUTTON, WidgetType.BUTTON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        regionToWidgetTypeMap.put(Region.CHECK_BOX, WidgetType.CHECK_BOX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        regionToWidgetTypeMap.put(Region.CHECK_BOX_MENU_ITEM,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                                  WidgetType.CHECK_BOX_MENU_ITEM);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        regionToWidgetTypeMap.put(Region.COLOR_CHOOSER, WidgetType.COLOR_CHOOSER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        regionToWidgetTypeMap.put(Region.FILE_CHOOSER, WidgetType.OPTION_PANE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        regionToWidgetTypeMap.put(Region.COMBO_BOX, WidgetType.COMBO_BOX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        regionToWidgetTypeMap.put(Region.DESKTOP_ICON, WidgetType.DESKTOP_ICON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        regionToWidgetTypeMap.put(Region.DESKTOP_PANE, WidgetType.DESKTOP_PANE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        regionToWidgetTypeMap.put(Region.EDITOR_PANE, WidgetType.EDITOR_PANE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        regionToWidgetTypeMap.put(Region.FORMATTED_TEXT_FIELD, new WidgetType[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            WidgetType.FORMATTED_TEXT_FIELD, WidgetType.SPINNER_TEXT_FIELD});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        regionToWidgetTypeMap.put(GTKRegion.HANDLE_BOX, WidgetType.HANDLE_BOX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        regionToWidgetTypeMap.put(Region.INTERNAL_FRAME,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                                  WidgetType.INTERNAL_FRAME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        regionToWidgetTypeMap.put(Region.INTERNAL_FRAME_TITLE_PANE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                                  WidgetType.INTERNAL_FRAME_TITLE_PANE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        regionToWidgetTypeMap.put(Region.LABEL, new WidgetType[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            WidgetType.LABEL, WidgetType.COMBO_BOX_TEXT_FIELD});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        regionToWidgetTypeMap.put(Region.LIST, WidgetType.LIST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        regionToWidgetTypeMap.put(Region.MENU, WidgetType.MENU);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        regionToWidgetTypeMap.put(Region.MENU_BAR, WidgetType.MENU_BAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        regionToWidgetTypeMap.put(Region.MENU_ITEM, WidgetType.MENU_ITEM);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        regionToWidgetTypeMap.put(Region.MENU_ITEM_ACCELERATOR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                                  WidgetType.MENU_ITEM_ACCELERATOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        regionToWidgetTypeMap.put(Region.OPTION_PANE, WidgetType.OPTION_PANE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        regionToWidgetTypeMap.put(Region.PANEL, WidgetType.PANEL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        regionToWidgetTypeMap.put(Region.PASSWORD_FIELD,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                                  WidgetType.PASSWORD_FIELD);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        regionToWidgetTypeMap.put(Region.POPUP_MENU, WidgetType.POPUP_MENU);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        regionToWidgetTypeMap.put(Region.POPUP_MENU_SEPARATOR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                                  WidgetType.POPUP_MENU_SEPARATOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        regionToWidgetTypeMap.put(Region.PROGRESS_BAR, new WidgetType[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            WidgetType.HPROGRESS_BAR, WidgetType.VPROGRESS_BAR});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        regionToWidgetTypeMap.put(Region.RADIO_BUTTON, WidgetType.RADIO_BUTTON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        regionToWidgetTypeMap.put(Region.RADIO_BUTTON_MENU_ITEM,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                                  WidgetType.RADIO_BUTTON_MENU_ITEM);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        regionToWidgetTypeMap.put(Region.ROOT_PANE, WidgetType.ROOT_PANE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        regionToWidgetTypeMap.put(Region.SCROLL_BAR, new WidgetType[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            WidgetType.HSCROLL_BAR, WidgetType.VSCROLL_BAR});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        regionToWidgetTypeMap.put(Region.SCROLL_BAR_THUMB, new WidgetType[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            WidgetType.HSCROLL_BAR_THUMB, WidgetType.VSCROLL_BAR_THUMB});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        regionToWidgetTypeMap.put(Region.SCROLL_BAR_TRACK, new WidgetType[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            WidgetType.HSCROLL_BAR_TRACK, WidgetType.VSCROLL_BAR_TRACK});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        regionToWidgetTypeMap.put(Region.SCROLL_PANE, WidgetType.SCROLL_PANE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        regionToWidgetTypeMap.put(Region.SEPARATOR, new WidgetType[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            WidgetType.HSEPARATOR, WidgetType.VSEPARATOR});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        regionToWidgetTypeMap.put(Region.SLIDER, new WidgetType[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            WidgetType.HSLIDER, WidgetType.VSLIDER});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        regionToWidgetTypeMap.put(Region.SLIDER_THUMB, new WidgetType[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            WidgetType.HSLIDER_THUMB, WidgetType.VSLIDER_THUMB});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        regionToWidgetTypeMap.put(Region.SLIDER_TRACK, new WidgetType[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            WidgetType.HSLIDER_TRACK, WidgetType.VSLIDER_TRACK});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        regionToWidgetTypeMap.put(Region.SPINNER, WidgetType.SPINNER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        regionToWidgetTypeMap.put(Region.SPLIT_PANE, WidgetType.SPLIT_PANE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        regionToWidgetTypeMap.put(Region.SPLIT_PANE_DIVIDER, new WidgetType[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            WidgetType.HSPLIT_PANE_DIVIDER, WidgetType.VSPLIT_PANE_DIVIDER});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        regionToWidgetTypeMap.put(Region.TABBED_PANE, WidgetType.TABBED_PANE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        regionToWidgetTypeMap.put(Region.TABBED_PANE_CONTENT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                                  WidgetType.TABBED_PANE_CONTENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        regionToWidgetTypeMap.put(Region.TABBED_PANE_TAB,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                                  WidgetType.TABBED_PANE_TAB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        regionToWidgetTypeMap.put(Region.TABBED_PANE_TAB_AREA,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                                  WidgetType.TABBED_PANE_TAB_AREA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        regionToWidgetTypeMap.put(Region.TABLE, WidgetType.TABLE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        regionToWidgetTypeMap.put(Region.TABLE_HEADER, WidgetType.TABLE_HEADER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        regionToWidgetTypeMap.put(Region.TEXT_AREA, WidgetType.TEXT_AREA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        regionToWidgetTypeMap.put(Region.TEXT_FIELD, new WidgetType[] {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            WidgetType.TEXT_FIELD, WidgetType.COMBO_BOX_TEXT_FIELD});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        regionToWidgetTypeMap.put(Region.TEXT_PANE, WidgetType.TEXT_PANE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        regionToWidgetTypeMap.put(CustomRegion.TITLED_BORDER, WidgetType.TITLED_BORDER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        regionToWidgetTypeMap.put(Region.TOGGLE_BUTTON, WidgetType.TOGGLE_BUTTON);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        regionToWidgetTypeMap.put(Region.TOOL_BAR, WidgetType.TOOL_BAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        regionToWidgetTypeMap.put(Region.TOOL_BAR_CONTENT, WidgetType.TOOL_BAR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        regionToWidgetTypeMap.put(Region.TOOL_BAR_DRAG_WINDOW,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                                  WidgetType.TOOL_BAR_DRAG_WINDOW);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        regionToWidgetTypeMap.put(Region.TOOL_BAR_SEPARATOR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                                  WidgetType.TOOL_BAR_SEPARATOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        regionToWidgetTypeMap.put(Region.TOOL_TIP, WidgetType.TOOL_TIP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        regionToWidgetTypeMap.put(Region.TREE, WidgetType.TREE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        regionToWidgetTypeMap.put(Region.TREE_CELL, WidgetType.TREE_CELL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        regionToWidgetTypeMap.put(Region.VIEWPORT, WidgetType.VIEWPORT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    /** Translate Region and JComponent into WidgetType ordinals */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    static WidgetType getWidgetType(JComponent c, Region id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        Object value = regionToWidgetTypeMap.get(id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        if (value instanceof WidgetType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            return (WidgetType)value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        WidgetType[] widgets = (WidgetType[])value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        if (c == null ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            return widgets[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        if (c instanceof JScrollBar) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            return (((JScrollBar)c).getOrientation() == JScrollBar.HORIZONTAL) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                widgets[0] : widgets[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        } else if (c instanceof JSeparator) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            JSeparator separator = (JSeparator)c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            /* We should return correrct WidgetType if the seperator is inserted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
             * in Menu/PopupMenu/ToolBar. BugID: 6465603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            if (separator.getParent() instanceof JPopupMenu) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                return WidgetType.POPUP_MENU_SEPARATOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            } else if (separator.getParent() instanceof JToolBar) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                return WidgetType.TOOL_BAR_SEPARATOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            return (separator.getOrientation() == JSeparator.HORIZONTAL) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                widgets[0] : widgets[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        } else if (c instanceof JSlider) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            return (((JSlider)c).getOrientation() == JSlider.HORIZONTAL) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                widgets[0] : widgets[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        } else if (c instanceof JProgressBar) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            return (((JProgressBar)c).getOrientation() == JProgressBar.HORIZONTAL) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                widgets[0] : widgets[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        } else if (c instanceof JSplitPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            return (((JSplitPane)c).getOrientation() == JSplitPane.HORIZONTAL_SPLIT) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                widgets[1] : widgets[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        } else if (id == Region.LABEL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
             * For all ListCellRenderers we will use COMBO_BOX_TEXT_FIELD widget
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
             * type because we can get correct insets. List items however won't be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
             * drawn as a text entry (see GTKPainter.paintLabelBackground).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
            if (c instanceof ListCellRenderer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                return widgets[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                return widgets[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        } else if (id == Region.TEXT_FIELD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            String name = c.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            if (name != null && name.startsWith("ComboBox")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                return widgets[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                return widgets[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        } else if (id == Region.FORMATTED_TEXT_FIELD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            String name = c.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
            if (name != null && name.startsWith("Spinner")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                return widgets[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                return widgets[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        } else if (id == Region.ARROW_BUTTON) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
            if (c.getParent() instanceof JScrollBar) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                Integer prop = (Integer)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                    c.getClientProperty("__arrow_direction__");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                int dir = (prop != null) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                    prop.intValue() : SwingConstants.WEST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                switch (dir) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                case SwingConstants.WEST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                    return WidgetType.HSCROLL_BAR_BUTTON_LEFT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                case SwingConstants.EAST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                    return WidgetType.HSCROLL_BAR_BUTTON_RIGHT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                case SwingConstants.NORTH:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                    return WidgetType.VSCROLL_BAR_BUTTON_UP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                case SwingConstants.SOUTH:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                    return WidgetType.VSCROLL_BAR_BUTTON_DOWN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                    return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
            } else if (c.getParent() instanceof JComboBox) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                return WidgetType.COMBO_BOX_ARROW_BUTTON;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                return WidgetType.SPINNER_ARROW_BUTTON;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    private static int getTextDirection(SynthContext context) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        TextDirection dir = TextDirection.NONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        JComponent comp = context.getComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        if (comp != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            ComponentOrientation co = comp.getComponentOrientation();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            if (co != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                dir = co.isLeftToRight() ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                    TextDirection.LTR : TextDirection.RTL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        return dir.ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    public void paintArrow(Graphics g, SynthContext context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            Region id, int state, ShadowType shadowType, ArrowType direction,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            String detail, int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        int widget = getWidgetType(context.getComponent(), id).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        native_paint_arrow(widget, state, shadowType.ordinal(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                detail, x - x0, y - y0, w, h, direction.ordinal());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    public void paintBox(Graphics g, SynthContext context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
            Region id, int state, ShadowType shadowType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
            String detail, int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        int gtkState =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
            GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        int synthState = context.getComponentState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        int dir = getTextDirection(context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        int widget = getWidgetType(context.getComponent(), id).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        native_paint_box(widget, gtkState, shadowType.ordinal(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                         detail, x - x0, y - y0, w, h, synthState, dir);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    public void paintBoxGap(Graphics g, SynthContext context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            Region id, int state, ShadowType shadowType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
            String detail, int x, int y, int w, int h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            PositionType boxGapType, int tabBegin, int size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        int widget = getWidgetType(context.getComponent(), id).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        native_paint_box_gap(widget, state, shadowType.ordinal(), detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                x - x0, y - y0, w, h, boxGapType.ordinal(), tabBegin, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    public void paintCheck(Graphics g, SynthContext context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            Region id, String detail, int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        int synthState = context.getComponentState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        int widget = getWidgetType(context.getComponent(), id).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        native_paint_check(widget, synthState, detail, x - x0, y - y0, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    public void paintExpander(Graphics g, SynthContext context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
            Region id, int state, ExpanderStyle expanderStyle, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
            int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        int widget = getWidgetType(context.getComponent(), id).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        native_paint_expander(widget, state, detail, x - x0, y - y0, w, h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                              expanderStyle.ordinal());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    public void paintExtension(Graphics g, SynthContext context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            Region id, int state, ShadowType shadowType, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
            int x, int y, int w, int h, PositionType placement, int tabIndex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        int widget = getWidgetType(context.getComponent(), id).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        native_paint_extension(widget, state, shadowType.ordinal(), detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                               x - x0, y - y0, w, h, placement.ordinal());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    public void paintFlatBox(Graphics g, SynthContext context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            Region id, int state, ShadowType shadowType, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            int x, int y, int w, int h, ColorType colorType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        int widget = getWidgetType(context.getComponent(), id).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        native_paint_flat_box(widget, state, shadowType.ordinal(), detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                              x - x0, y - y0, w, h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                              context.getComponent().hasFocus());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    public void paintFocus(Graphics g, SynthContext context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            Region id, int state, String detail, int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        int widget = getWidgetType(context.getComponent(), id).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        native_paint_focus(widget, state, detail, x - x0, y - y0, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    public void paintHandle(Graphics g, SynthContext context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            Region id, int state, ShadowType shadowType, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
            int x, int y, int w, int h, Orientation orientation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        int widget = getWidgetType(context.getComponent(), id).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        native_paint_handle(widget, state, shadowType.ordinal(), detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                            x - x0, y - y0, w, h, orientation.ordinal());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    public void paintHline(Graphics g, SynthContext context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            Region id, int state, String detail, int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        int widget = getWidgetType(context.getComponent(), id).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        native_paint_hline(widget, state, detail, x - x0, y - y0, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    public void paintOption(Graphics g, SynthContext context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            Region id, String detail, int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        int synthState = context.getComponentState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        int widget = getWidgetType(context.getComponent(), id).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        native_paint_option(widget, synthState, detail, x - x0, y - y0, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    public void paintShadow(Graphics g, SynthContext context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
            Region id, int state, ShadowType shadowType, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        int gtkState =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        int synthState = context.getComponentState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        int dir = getTextDirection(context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        int widget = getWidgetType(context.getComponent(), id).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        native_paint_shadow(widget, gtkState, shadowType.ordinal(), detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                            x - x0, y - y0, w, h, synthState, dir);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    public void paintSlider(Graphics g, SynthContext context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
            Region id, int state, ShadowType shadowType, String detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            int x, int y, int w, int h, Orientation orientation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        int widget = getWidgetType(context.getComponent(), id).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        native_paint_slider(widget, state, shadowType.ordinal(), detail,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                            x - x0, y - y0, w, h, orientation.ordinal());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    public void paintVline(Graphics g, SynthContext context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
            Region id, int state, String detail, int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        int widget = getWidgetType(context.getComponent(), id).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        native_paint_vline(widget, state, detail, x - x0, y - y0, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    public void paintBackground(Graphics g, SynthContext context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            Region id, int state, Color color, int x, int y, int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        int widget = getWidgetType(context.getComponent(), id).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        native_paint_background(widget, state, x - x0, y - y0, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    private final static ColorModel[] COLOR_MODELS = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        // Transparency.OPAQUE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        new DirectColorModel(24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        // Transparency.BITMASK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        new DirectColorModel(25, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x01000000),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        // Transparency.TRANSLUCENT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        ColorModel.getRGBdefault(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    private final static int[][] BAND_OFFSETS = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        { 0x00ff0000, 0x0000ff00, 0x000000ff },             // OPAQUE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        { 0x00ff0000, 0x0000ff00, 0x000000ff, 0x01000000 }, // BITMASK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        { 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }  // TRANSLUCENT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * Paint a cached image identified by its size and a set of additional
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * arguments, if there's one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * @return true if a cached image has been painted, false otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    public boolean paintCachedImage(Graphics g,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
            int x, int y, int w, int h, Object... args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        if (w <= 0 || h <= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        // look for cached image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        Image img = cache.getImage(getClass(), null, w, h, args);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        if (img != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
            g.drawImage(img, x, y, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * Allocate a native offscreen buffer of the specified size.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    public void startPainting(Graphics g,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            int x, int y, int w, int h, Object... args) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        nativeStartPainting(w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        x0 = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        y0 = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        w0 = w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        h0 = h;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        graphics = g;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        cacheArgs = args;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * Convenience method that delegates to finishPainting() with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * caching enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
    public void finishPainting() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        finishPainting(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * Called to indicate that painting is finished. We create a new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * BufferedImage from the offscreen buffer, (optionally) cache it,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * and paint it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    public void finishPainting(boolean useCache) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        DataBufferInt dataBuffer = new DataBufferInt(w0 * h0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        // Note that stealData() requires a markDirty() afterwards
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        // since we modify the data in it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        int transparency =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
            nativeFinishPainting(SunWritableRaster.stealData(dataBuffer, 0),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                                 w0, h0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        SunWritableRaster.markDirty(dataBuffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
        int[] bands = BAND_OFFSETS[transparency - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        WritableRaster raster = Raster.createPackedRaster(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                dataBuffer, w0, h0, w0, bands, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        ColorModel cm = COLOR_MODELS[transparency - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
        Image img = new BufferedImage(cm, raster, false, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        if (useCache) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
            cache.setImage(getClass(), null, w0, h0, cacheArgs, img);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        graphics.drawImage(img, x0, y0, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * Notify native layer of theme change, and flush cache
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    public void themeChanged() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        synchronized(sun.awt.UNIXToolkit.GTK_LOCK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
            native_switch_theme();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        cache.flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    /* GtkSettings enum mirrors that in gtk2_interface.h */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    public Object getSetting(Settings property) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        synchronized(sun.awt.UNIXToolkit.GTK_LOCK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
            return native_get_gtk_setting(property.ordinal());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * Sets up the GtkAdjustment values for the native GtkRange widget
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * associated with the given region (e.g. SLIDER, SCROLL_BAR).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    void setRangeValue(SynthContext context, Region id,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
                       double value, double min, double max, double visible) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        int widget = getWidgetType(context.getComponent(), id).ordinal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        nativeSetRangeValue(widget, value, min, max, visible);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
}