1 /* gtkscrollpanepeer.c -- Native implementation of GtkScrollPanePeer
2 Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
40 #include "gnu_java_awt_peer_gtk_GtkScrollPanePeer.h"
42 JNIEXPORT
void JNICALL
43 Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_create
44 (JNIEnv
*env
, jobject obj
, int width
, int height
)
48 /* Create global reference and save it for future use */
49 NSA_SET_GLOBAL_REF (env
, obj
);
53 sw
= gtk_scrolled_window_new (NULL
, NULL
);
55 gtk_widget_set_size_request (sw
, width
, height
);
59 NSA_SET_PTR (env
, obj
, sw
);
62 JNIEXPORT
void JNICALL
63 Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_setScrollPosition
64 (JNIEnv
*env
, jobject obj
, jint x
, jint y
)
66 GtkAdjustment
*hadj
, *vadj
;
67 GtkScrolledWindow
*sw
;
70 ptr
= NSA_GET_PTR (env
, obj
);
73 sw
= GTK_SCROLLED_WINDOW (ptr
);
75 hadj
= gtk_scrolled_window_get_hadjustment (sw
);
76 vadj
= gtk_scrolled_window_get_vadjustment (sw
);
78 gtk_adjustment_set_value (hadj
, x
);
79 gtk_adjustment_set_value (vadj
, y
);
83 JNIEXPORT
void JNICALL
84 Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_gtkScrolledWindowSetHScrollIncrement
85 (JNIEnv
*env
, jobject obj
, jint u
)
88 GtkScrolledWindow
*sw
;
91 ptr
= NSA_GET_PTR (env
, obj
);
94 sw
= GTK_SCROLLED_WINDOW(ptr
);
96 hadj
= gtk_scrolled_window_get_hadjustment (sw
);
97 hadj
->step_increment
= u
;
102 JNIEXPORT
void JNICALL
103 Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_gtkScrolledWindowSetVScrollIncrement
104 (JNIEnv
*env
, jobject obj
, jint u
)
107 GtkScrolledWindow
*sw
;
110 ptr
= NSA_GET_PTR (env
, obj
);
112 gdk_threads_enter ();
113 sw
= GTK_SCROLLED_WINDOW(ptr
);
115 vadj
= gtk_scrolled_window_get_hadjustment (sw
);
116 vadj
->step_increment
= u
;
118 gdk_threads_leave ();
121 JNIEXPORT jint JNICALL
122 Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_getHScrollbarHeight
123 (JNIEnv
*env
, jobject obj
)
126 GtkScrolledWindow
*sw
;
127 GtkRequisition requisition
;
131 ptr
= NSA_GET_PTR (env
, obj
);
133 gdk_threads_enter ();
134 sw
= GTK_SCROLLED_WINDOW (ptr
);
136 gtk_widget_size_request (sw
->hscrollbar
, &requisition
);
137 gtk_widget_style_get (GTK_WIDGET (sw
), "scrollbar_spacing", &spacing
, NULL
);
138 height
= requisition
.height
+ spacing
;
140 gdk_threads_leave ();
145 JNIEXPORT jint JNICALL
146 Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_getVScrollbarWidth
147 (JNIEnv
*env
, jobject obj
)
150 GtkScrolledWindow
*sw
;
151 GtkRequisition requisition
;
155 ptr
= NSA_GET_PTR (env
, obj
);
157 gdk_threads_enter ();
158 sw
= GTK_SCROLLED_WINDOW (ptr
);
160 gtk_widget_size_request (sw
->vscrollbar
, &requisition
);
161 gtk_widget_style_get (GTK_WIDGET (sw
), "scrollbar_spacing", &spacing
, NULL
);
162 width
= requisition
.width
+ spacing
;
164 gdk_threads_leave ();
169 JNIEXPORT
void JNICALL
170 Java_gnu_java_awt_peer_gtk_GtkScrollPanePeer_setPolicy
171 (JNIEnv
*env
, jobject obj
, jint policy
)
175 ptr
= NSA_GET_PTR (env
, obj
);
179 case AWT_SCROLLPANE_SCROLLBARS_AS_NEEDED
:
180 policy
= GTK_POLICY_AUTOMATIC
;
182 case AWT_SCROLLPANE_SCROLLBARS_ALWAYS
:
183 policy
= GTK_POLICY_ALWAYS
;
185 case AWT_SCROLLPANE_SCROLLBARS_NEVER
:
186 policy
= GTK_POLICY_NEVER
;
190 gdk_threads_enter ();
191 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ptr
), policy
, policy
);
192 gdk_threads_leave ();