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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 774 jeremybenn
/* qtdialogpeer.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 <qdialog.h>
40
#include <gnu_java_awt_peer_qt_QtDialogPeer.h>
41
#include "qtcomponent.h"
42
#include "containers.h"
43
#include "qtstrings.h"
44
#include "keybindings.h"
45
#include "mainthreadinterface.h"
46
 
47
class MyDialog : public QDialog
48
{
49
public:
50
  MyDialog(JNIEnv *env, jobject obj, QWidget *parent) : QDialog(parent)
51
  {
52
    setup(env, obj);
53
  }
54
 
55
  ~MyDialog()
56
  {
57
    destroy();
58
  }
59
 
60
#define I_KNOW_WHAT_IM_DOING
61
#define PARENT QDialog
62
#include "eventmethods.h"
63
};
64
 
65
class DialogSettingsEvent : public AWTEvent {
66
 
67
 private:
68
  QDialog *widget;
69
  bool modal;
70
  bool value;
71
 
72
 public:
73
  DialogSettingsEvent(QDialog *w, bool m, bool v) : AWTEvent()
74
  {
75
    widget = w;
76
    modal = m;
77
    value = v;
78
  }
79
 
80
  void runEvent()
81
  {
82
    if( modal )
83
      widget->setModal( value );
84
    else
85
      widget->setSizeGripEnabled( value );
86
  }
87
};
88
 
89
class DialogResizeEvent : public AWTEvent {
90
 
91
 private:
92
  QWidget *widget;
93
  bool fixed;
94
  int x, y, w, h;
95
 
96
 public:
97
  DialogResizeEvent(QWidget *wid, int x0, int y0, int w0, int h0, bool f)
98
  {
99
    widget = wid;
100
    fixed = f;
101
    x = x0; y = y0;
102
    w = w0; h = h0;
103
    if(w == 0 && h == 0) w = h = 10;
104
  }
105
 
106
  void runEvent()
107
  {
108
    if( fixed )
109
      widget->setFixedSize( w, h );
110
    widget->setGeometry( x, y, w, h );
111
  }
112
};
113
 
114
/*
115
 * Constructs a QDialog native object.
116
 */
117
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_init
118
(JNIEnv *env, jobject obj)
119
{
120
  QWidget *parentWidget = (QWidget *) getParentWidget( env, obj );
121
  //  QDialog *dialog = new QDialog(parentWidget);
122
  MyDialog *dialog = new MyDialog(env, obj, parentWidget);
123
  assert( dialog );
124
  setNativeObject( env, obj, dialog );
125
}
126
 
127
 
128
/*
129
 * Sets the modality of the dialog.
130
 */
131
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_setModal
132
(JNIEnv *env, jobject obj, jboolean flag)
133
{
134
  QDialog *dialog = (QDialog *) getNativeObject( env, obj );
135
  assert( dialog );
136
  mainThread->postEventToMain( new DialogSettingsEvent(dialog, true, (flag == JNI_TRUE)));
137
}
138
 
139
 
140
/*
141
 * Set resizeable.
142
 */
143
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_setResizable
144
(JNIEnv *env, jobject obj, jboolean flag)
145
{
146
  QDialog *dialog = (QDialog *) getNativeObject( env, obj );
147
  assert( dialog );
148
  mainThread->postEventToMain( new DialogSettingsEvent(dialog, false, (flag == JNI_TRUE)));
149
}
150
 
151
/*
152
 * Overloaded to allow for size locking.
153
 */
154
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtDialogPeer_setBoundsNative
155
(JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height, jboolean fixed)
156
{
157
  QWidget *widget = (QWidget *) getNativeObject( env, obj );
158
  assert( widget );
159
 
160
  QRect g = widget->geometry();
161
  if(g.x() != x || g.y() != y ||
162
     g.width() != width || g.height() != height)
163
    mainThread->postEventToMain( new DialogResizeEvent( widget, x, y, width, height, (fixed == JNI_TRUE) ) );
164
}

powered by: WebSVN 2.1.0

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