52 |
// The current state of the GTK checkbox. |
// The current state of the GTK checkbox. |
53 |
private boolean currentState; |
private boolean currentState; |
54 |
|
|
55 |
public native void nativeCreate (GtkCheckboxGroupPeer group, |
public native void create (GtkCheckboxGroupPeer group); |
|
boolean state); |
|
56 |
public native void nativeSetCheckboxGroup (GtkCheckboxGroupPeer group); |
public native void nativeSetCheckboxGroup (GtkCheckboxGroupPeer group); |
57 |
public native void connectSignals (); |
public native void connectSignals (); |
58 |
native void gtkSetFont (String name, int style, int size); |
native void gtkSetFont (String name, int style, int size); |
59 |
public native void gtkSetLabel (String label); |
native void gtkButtonSetLabel (String label); |
60 |
|
native void gtkToggleButtonSetActive (boolean is_active); |
61 |
|
|
62 |
public GtkCheckboxPeer (Checkbox c) |
public GtkCheckboxPeer (Checkbox c) |
63 |
{ |
{ |
64 |
super (c); |
super (c); |
65 |
} |
} |
66 |
|
|
67 |
// We can't fully use the ordinary getArgs code here, due to |
// FIXME: we must be able to switch between a checkbutton and a |
68 |
// oddities of this particular widget. In particular we must be |
// radiobutton dynamically. |
|
// able to switch between a checkbutton and a radiobutton |
|
|
// dynamically. |
|
69 |
public void create () |
public void create () |
70 |
{ |
{ |
71 |
CheckboxGroup g = ((Checkbox) awtComponent).getCheckboxGroup (); |
Checkbox checkbox = (Checkbox) awtComponent; |
72 |
|
CheckboxGroup g = checkbox.getCheckboxGroup (); |
73 |
old_group = GtkCheckboxGroupPeer.getCheckboxGroupPeer (g); |
old_group = GtkCheckboxGroupPeer.getCheckboxGroupPeer (g); |
74 |
currentState = ((Checkbox)awtComponent).getState(); |
create (old_group); |
75 |
nativeCreate (old_group, currentState); |
gtkToggleButtonSetActive (checkbox.getState ()); |
76 |
|
gtkButtonSetLabel (checkbox.getLabel ()); |
77 |
} |
} |
78 |
|
|
79 |
public void setState (boolean state) |
public void setState (boolean state) |
80 |
{ |
{ |
81 |
if (currentState != state) |
if (currentState != state) |
82 |
set ("active", state); |
gtkToggleButtonSetActive (state); |
83 |
} |
} |
84 |
|
|
85 |
public void setLabel (String label) |
public void setLabel (String label) |
86 |
{ |
{ |
87 |
gtkSetLabel (label); |
gtkButtonSetLabel (label); |
88 |
} |
} |
89 |
|
|
90 |
public void setCheckboxGroup (CheckboxGroup group) |
public void setCheckboxGroup (CheckboxGroup group) |
100 |
} |
} |
101 |
} |
} |
102 |
|
|
|
public void getArgs (Component component, GtkArgList args) |
|
|
{ |
|
|
super.getArgs (component, args); |
|
|
args.add ("active", ((Checkbox) component).getState ()); |
|
|
args.add ("label", ((Checkbox) component).getLabel ()); |
|
|
} |
|
|
|
|
103 |
// Override the superclass postItemEvent so that the peer doesn't |
// Override the superclass postItemEvent so that the peer doesn't |
104 |
// need information that we have. |
// need information that we have. |
105 |
public void postItemEvent (Object item, int stateChange) |
public void postItemEvent (Object item, int stateChange) |