9 class editable_signals obj = object
10 inherit widget_signals obj
11 method activate = GtkSignal.connect ~sgn:Editable.Signals.activate obj ~after
12 method changed = GtkSignal.connect ~sgn:Editable.Signals.changed obj ~after
14 GtkSignal.connect ~sgn:Editable.Signals.insert_text obj ~after
16 GtkSignal.connect ~sgn:Editable.Signals.delete_text obj ~after
19 class editable obj = object
21 method connect = new editable_signals obj
22 method select_region = Editable.select_region obj
23 method insert_text = Editable.insert_text obj
24 method delete_text = Editable.delete_text obj
25 method get_chars = Editable.get_chars obj
26 method cut_clipboard () = Editable.cut_clipboard obj
27 method copy_clipboard () = Editable.copy_clipboard obj
28 method paste_clipboard () = Editable.paste_clipboard obj
29 method delete_selection () = Editable.delete_selection obj
30 method set_position = Editable.set_position obj
31 method position = Editable.get_position obj
32 method set_editable = Editable.set_editable obj
34 if Editable.has_selection obj then
35 Some (Editable.selection_start_pos obj, Editable.selection_end_pos obj)
39 class entry obj = object
41 method event = new GObj.event_ops obj
42 method set_text = Entry.set_text obj
43 method append_text = Entry.append_text obj
44 method prepend_text = Entry.prepend_text obj
45 method set_visibility = Entry.set_visibility obj
46 method set_max_length = Entry.set_max_length obj
47 method text = Entry.get_text obj
48 method text_length = Entry.text_length obj
51 let set_editable ?editable ?(width = -2) ?(height = -2) w =
52 may editable ~f:(Editable.set_editable w);
53 if width <> -2 || height <> -2 then Widget.set_usize w ~width ~height
55 let entry ?max_length ?text ?visibility ?editable
56 ?width ?height ?packing ?show () =
57 let w = Entry.create ?max_length () in
58 Entry.set w ?text ?visibility;
59 set_editable w ?editable ?width ?height;
60 pack_return (new entry w) ~packing ~show
62 class spin_button obj = object
63 inherit entry (obj : Gtk.spin_button obj)
64 method adjustment = new GData.adjustment (SpinButton.get_adjustment obj)
65 method value = SpinButton.get_value obj
66 method value_as_int = SpinButton.get_value_as_int obj
67 method spin = SpinButton.spin obj
68 method update = SpinButton.update obj
69 method set_adjustment adj =
70 SpinButton.set_adjustment obj (GData.as_adjustment adj)
71 method set_digits = SpinButton.set_digits obj
72 method set_value = SpinButton.set_value obj
73 method set_update_policy = SpinButton.set_update_policy obj
74 method set_numeric = SpinButton.set_numeric obj
75 method set_wrap = SpinButton.set_wrap obj
76 method set_shadow_type = SpinButton.set_shadow_type obj
77 method set_snap_to_ticks = SpinButton.set_snap_to_ticks obj
80 let spin_button ?adjustment ?rate ?digits ?value ?update_policy
81 ?numeric ?wrap ?shadow_type ?snap_to_ticks
82 ?width ?height ?packing ?show () =
83 let w = SpinButton.create ?rate ?digits
84 ?adjustment:(may_map ~f:GData.as_adjustment adjustment) () in
85 SpinButton.set w ?value ?update_policy
86 ?numeric ?wrap ?shadow_type ?snap_to_ticks;
87 set_editable w ?width ?height;
88 pack_return (new spin_button w) ~packing ~show
90 class combo obj = object
91 inherit GObj.widget (obj : Gtk.combo obj)
92 method entry = new entry (Combo.entry obj)
93 method list = new GList.liste (Combo.list obj)
94 method set_popdown_strings = Combo.set_popdown_strings obj
95 method set_use_arrows = Combo.set_use_arrows' obj
96 method set_case_sensitive = Combo.set_case_sensitive obj
97 method set_value_in_list = Combo.set_value_in_list obj
98 method disable_activate () = Combo.disable_activate obj
99 method set_item_string (item : GList.list_item) =
100 Combo.set_item_string obj item#as_item
103 let combo ?popdown_strings ?use_arrows
104 ?case_sensitive ?value_in_list ?ok_if_empty
105 ?border_width ?width ?height ?packing ?show () =
106 let w = Combo.create () in
107 Combo.set w ?popdown_strings ?use_arrows
108 ?case_sensitive ?value_in_list ?ok_if_empty;
109 Container.set w ?border_width ?width ?height;
110 pack_return (new combo w) ~packing ~show
112 class text obj = object (self)
113 inherit editable (obj : Gtk.text obj) as super
114 method get_chars ~start ~stop:e =
115 if start < 0 || e > Text.get_length obj || e < start then
116 invalid_arg "GEdit.text#get_chars";
117 super#get_chars ~start ~stop:e
118 method event = new GObj.event_ops obj
119 method set_point = Text.set_point obj
120 method set_hadjustment adj =
121 Text.set_adjustment obj ~horizontal:(GData.as_adjustment adj) ()
122 method set_vadjustment adj =
123 Text.set_adjustment obj ~vertical:(GData.as_adjustment adj) ()
124 method set_word_wrap = Text.set_word_wrap obj
125 method set_line_wrap = Text.set_line_wrap obj
126 method hadjustment = new GData.adjustment (Text.get_hadjustment obj)
127 method vadjustment = new GData.adjustment (Text.get_vadjustment obj)
128 method point = Text.get_point obj
129 method length = Text.get_length obj
130 method freeze () = Text.freeze obj
131 method thaw () = Text.thaw obj
132 method insert ?font ?foreground ?background text =
133 let colormap = try Some self#misc#colormap with _ -> None in
134 Text.insert obj text ?font
135 ?foreground:(may_map foreground ~f:(GDraw.color ?colormap))
136 ?background:(may_map background ~f:(GDraw.color ?colormap))
139 let text ?hadjustment ?vadjustment ?editable
140 ?word_wrap ?line_wrap ?width ?height ?packing ?show () =
141 let w = Text.create ()
142 ?hadjustment:(may_map ~f:GData.as_adjustment hadjustment)
143 ?vadjustment:(may_map ~f:GData.as_adjustment vadjustment) in
144 may word_wrap ~f:(Text.set_word_wrap w);
145 may line_wrap ~f:(Text.set_line_wrap w);
146 set_editable w ?editable ?width ?height;
147 pack_return (new text w) ~packing ~show