OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [native/] [jni/] [qt-peer/] [qtscrollpanepeer.cpp] - Blame information for rev 774

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 774 jeremybenn
/* qtscrollpanepeer.cpp --
2
   Copyright (C)  2005  Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
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)
9
any later version.
10
 
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.
15
 
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., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
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
24
combination.
25
 
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. */
37
 
38
#include <assert.h>
39
#include <QScrollArea>
40
#include <QScrollBar>
41
#include <gnu_java_awt_peer_qt_QtScrollPanePeer.h>
42
#include "qtcomponent.h"
43
#include "containers.h"
44
#include "mainthreadinterface.h"
45
#include "componentevent.h"
46
#include "keybindings.h"
47
 
48
// Constants in java.awt.ScrollPane
49
#define SCROLLBARS_AS_NEEDED    0
50
#define SCROLLBARS_ALWAYS       1
51
#define SCROLLBARS_NEVER        2
52
 
53
 
54
class MyScrollArea : public QScrollArea
55
{
56
public:
57
  MyScrollArea(JNIEnv *env, jobject obj, QWidget *parent) : QScrollArea( parent )
58
  {
59
    setup(env, obj);
60
  }
61
 
62
  ~MyScrollArea()
63
  {
64
    destroy();
65
  }
66
 
67
#define I_KNOW_WHAT_IM_DOING
68
#define PARENT QScrollArea
69
#include "eventmethods.h"
70
};
71
 
72
 
73
class ScrollPanePolicy : public AWTEvent {
74
 
75
 private:
76
  QScrollArea *widget;
77
  Qt::ScrollBarPolicy policy;
78
 
79
 public:
80
  ScrollPanePolicy(QScrollArea *w, Qt::ScrollBarPolicy p) : AWTEvent()
81
  {
82
    widget = w;
83
    policy = p;
84
  }
85
 
86
  void runEvent()
87
  {
88
    widget->setHorizontalScrollBarPolicy(policy);
89
    widget->setVerticalScrollBarPolicy(policy);
90
  }
91
};
92
 
93
/**
94
 * Returns the child widget, given the owner Component.
95
 */
96
QWidget *scrollPaneChildWidget( JNIEnv *env, jobject component )
97
{
98
  jclass scrollpaneCls = env->FindClass( "java/awt/ScrollPane" );
99
  jmethodID getPeerMID = env->GetMethodID( scrollpaneCls,
100
                                           "getPeer",
101
                                           "()Ljava/awt/peer/ComponentPeer;");
102
  assert(getPeerMID != 0);
103
  jobject scrollpanepeerobj = env->CallObjectMethod( component, getPeerMID, NULL );
104
  QScrollArea *view = (QScrollArea *) getNativeObject( env, scrollpanepeerobj );
105
  assert(view != 0);
106
  return view->viewport();
107
}
108
 
109
/*
110
 * Creates a QScrollArea object.
111
 */
112
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_init
113
(JNIEnv *env, jobject obj)
114
{
115
  QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
116
  assert( parentWidget );
117
  //  QScrollArea *pane = new MyScrollArea( env, obj, parentWidget );
118
  QScrollArea *pane = new QScrollArea( parentWidget );
119
  assert( pane );
120
  setNativeObject( env, obj, pane );
121
}
122
 
123
/*
124
 * Resize the child.
125
 */
126
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_childResized
127
(JNIEnv *env, jobject obj, jint w, jint h)
128
{
129
  QScrollArea *view = (QScrollArea *) getNativeObject( env, obj );
130
  assert( view );
131
 
132
  QWidget *child = view->viewport();
133
  assert( child );
134
  //  child->setGeometry( 0, 0, w, h );
135
//   child->update();
136
  mainThread->postEventToMain( new AWTResizeEvent(child, 0, 0, w, h) );
137
}
138
 
139
/*
140
 * Returns the horizontal scrollbar height.
141
 */
142
JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_getHScrollbarHeight
143
(JNIEnv *env, jobject obj)
144
{
145
  QScrollArea *pane = (QScrollArea *) getNativeObject( env, obj );
146
  assert( pane );
147
  QScrollBar *hbar = pane->horizontalScrollBar();
148
  if(hbar == NULL)
149
    return 0;
150
  if(!hbar->isVisible())
151
    return 0;
152
  int height = hbar->height();
153
 
154
  return height;
155
}
156
 
157
/*
158
 * Returns the vertical scrollbar width.
159
 */
160
JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_getVScrollbarWidth
161
(JNIEnv *env, jobject obj)
162
{
163
  QScrollArea *pane = (QScrollArea *) getNativeObject( env, obj );
164
  assert( pane );
165
  QScrollBar *vbar = pane->verticalScrollBar();
166
  if(vbar == NULL)
167
    return 0;
168
  if(!vbar->isVisible())
169
    return 0;
170
  int width = vbar->width();
171
 
172
  return width;
173
}
174
 
175
/*
176
 * Sets the current upper-left corner to x, y.
177
 */
178
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_setScrollPosition
179
(JNIEnv *env, jobject obj, jint x, jint y)
180
{
181
  QScrollArea *pane = (QScrollArea *) getNativeObject( env, obj );
182
  assert( pane );
183
  // pane->scrollContentsBy( x, y );
184
}
185
 
186
/*
187
 * Sets the scrollbar policy
188
 */
189
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollPanePeer_setPolicy
190
(JNIEnv *env, jobject obj, jint policy)
191
{
192
  QScrollArea *pane = (QScrollArea *) getNativeObject( env, obj );
193
  assert( pane );
194
 
195
  Qt::ScrollBarPolicy qtpolicy;
196
  switch( policy )
197
    {
198
    case SCROLLBARS_ALWAYS:
199
      qtpolicy = Qt::ScrollBarAlwaysOn;
200
      break;
201
 
202
    case SCROLLBARS_NEVER:
203
      qtpolicy = Qt::ScrollBarAlwaysOff;
204
      break;
205
 
206
    default:
207
    case SCROLLBARS_AS_NEEDED:
208
      qtpolicy = Qt::ScrollBarAsNeeded;
209
      break;
210
   }
211
 
212
  mainThread->postEventToMain( new ScrollPanePolicy( pane, qtpolicy ) );
213
}
214
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.