Last change
on this file was 2, checked in by bird, 22 years ago |
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
File size:
1.2 KB
|
Line | |
---|
1 | // Native Gtk AWT button code
|
---|
2 |
|
---|
3 | #include <config.h>
|
---|
4 |
|
---|
5 | #include <gcj/cni.h>
|
---|
6 |
|
---|
7 | #include "gtkcommon.h"
|
---|
8 | #include <gnu/awt/gtk/GtkButtonPeer.h>
|
---|
9 | #include <java/awt/Button.h>
|
---|
10 |
|
---|
11 | void
|
---|
12 | gnu::awt::gtk::GtkButtonPeer::setLabel (java::lang::String *label)
|
---|
13 | {
|
---|
14 | _Jv_GdkThreadLock sync;
|
---|
15 | jsize len = 0;
|
---|
16 | if (label)
|
---|
17 | len = JvGetStringUTFLength (label);
|
---|
18 | char buf[len + 1];
|
---|
19 | // FIXME: this can allocate an unbounded amount. Should use heap
|
---|
20 | // even though it is slower.
|
---|
21 | if (label)
|
---|
22 | JvGetStringUTFRegion (label, 0, len, buf);
|
---|
23 | buf[len] = '\0';
|
---|
24 | // The button child is a label.
|
---|
25 | GtkBin *bin = GTK_BIN (ptr);
|
---|
26 | gtk_label_set_text (GTK_LABEL (bin->child), buf);
|
---|
27 | }
|
---|
28 |
|
---|
29 | void
|
---|
30 | gnu::awt::gtk::GtkButtonPeer::create ()
|
---|
31 | {
|
---|
32 | if (! ptr)
|
---|
33 | {
|
---|
34 | _Jv_GdkThreadLock sync;
|
---|
35 | // This is a little inefficient.
|
---|
36 | ptr = (gnu::gcj::RawData *) gtk_button_new_with_label ("");
|
---|
37 |
|
---|
38 | using namespace ::java::awt;
|
---|
39 | Button *button = reinterpret_cast<Button *> (awtComponent);
|
---|
40 | setLabel (button->getLabel ());
|
---|
41 | }
|
---|
42 |
|
---|
43 | gnu::awt::gtk::GtkComponentPeer::create ();
|
---|
44 | }
|
---|
45 |
|
---|
46 | // void
|
---|
47 | // gnu::awt::gtk::GtkButtonPeer::clicked (::gnu::gcj::RawData *button_wrap,
|
---|
48 | // ::gnu::gcj::RawData *peer_wrap)
|
---|
49 | // {
|
---|
50 | // GtkButtonPeer *button = reinterpret_cast<GtkButtonPeer *> (peer_wrap);
|
---|
51 |
|
---|
52 | // }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.