Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libjava / classpath / native / jni / qt-peer / qtmenubarpeer.cpp
blob2c855773e7c2c1382b9cc7e162c5724f45f430cf
1 /* qtmenubarpeer.cpp --
2 Copyright (C) 2005 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)
9 any later version.
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., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
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.
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. */
38 #include <assert.h>
39 #include <QMenuBar>
40 #include <QToolBar>
41 #include <QMenu>
42 #include <QList>
43 #include <QThread>
44 #include <gnu_java_awt_peer_qt_QtMenuBarPeer.h>
45 #include "nativewrapper.h"
46 #include "qtstrings.h"
47 #include "mainthreadinterface.h"
50 * Event wrapper to add a menu to a menu bar
52 class MenuBarAdd : public AWTEvent {
54 private:
55 QMenuBar *widget;
56 QMenu *menu;
57 bool isHelp;
59 public:
60 MenuBarAdd(QMenuBar *w, QMenu *m, bool help) : AWTEvent()
62 widget = w;
63 menu = m;
64 isHelp = help;
67 void runEvent()
69 if ( isHelp )
70 widget->addSeparator();
71 QAction *ptr = widget->addMenu( menu );
75 /**
76 * Event wrapper to remove a menu from a menu bar.
78 class MenuBarRemove : public AWTEvent {
80 private:
81 QMenuBar *widget;
82 QMenu *menu;
84 public:
85 MenuBarRemove(QMenuBar *w, QMenu *m) : AWTEvent()
87 widget = w;
88 menu = m;
91 void runEvent()
93 // FIXME
99 * Constructs a QMenuBar object.
101 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_init
102 (JNIEnv *env, jobject obj)
104 QMenuBar *menubar = new QMenuBar();
105 assert( menubar );
106 setNativeObject( env, obj, menubar );
110 * Adds a menu item.
112 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_addMenu
113 (JNIEnv *env, jobject obj, jobject menuPeer)
115 QMenuBar *menubar = (QMenuBar *)getNativeObject(env, obj);
116 assert( menubar );
117 QMenu *menu = (QMenu *)getNativeObject(env, menuPeer);
118 assert( menu );
119 mainThread->postEventToMain( new MenuBarAdd( menubar, menu, false ) );
123 * Add a help menu.
125 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_addHelpMenu
126 (JNIEnv *env, jobject obj, jobject menuPeer)
128 QMenuBar *menubar = (QMenuBar *)getNativeObject(env, obj);
129 assert( menubar );
130 QMenu *menu = (QMenu *)getNativeObject(env, menuPeer);
131 assert( menu );
133 mainThread->postEventToMain( new MenuBarAdd( menubar, menu, true ) );
137 * Delete a menu.
139 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtMenuBarPeer_delMenu
140 (JNIEnv *env, jobject obj, jobject menuPeer)
142 QMenuBar *menubar = (QMenuBar *)getNativeObject(env, obj);
143 assert( menubar );
144 QMenu *menu = (QMenu *)getNativeObject(env, menuPeer);
145 assert( menu );
147 // FIXME