d65476024e930ba9b998eeea1eaa6837f8a1bdde
[nit.git] / lib / gtk / gtk_widgets_ext.nit
1 module gtk_widgets_ext
2 import gtk_core
3
4 #Displays a calendar and allows the user to select a date
5 #@https://developer.gnome.org/gtk3/3.2/GtkCalendar.html
6 extern GtkCalendar `{GtkCalendar *`}
7 super GtkWidget
8
9 new is extern `{
10 return (GtkCalendar *)gtk_calendar_new();
11 `}
12
13 fun month=( month : Int, year : Int ) is extern `{
14 gtk_calendar_select_month( recv, month, year );
15 `}
16
17 fun day=( day : Int ) is extern `{
18 gtk_calendar_select_day( recv, day );
19 `}
20
21 fun mark_day( day : Int ) is extern `{
22 gtk_calendar_mark_day( recv, day );
23 `}
24
25 fun unmark_day( day : Int ) is extern `{
26 gtk_calendar_unmark_day( recv, day );
27 `}
28
29 fun is_marked( day : Int ): Bool is extern `{
30 return gtk_calendar_get_day_is_marked( recv, day );
31 `}
32
33 fun clear_marks is extern `{
34 gtk_calendar_clear_marks( recv );
35 `}
36
37 fun display_options : GtkCalendarDisplayOptions is extern `{
38 return gtk_calendar_get_display_options( recv );
39 `}
40
41
42 fun display_options=( options : GtkCalendarDisplayOptions) is extern `{
43 gtk_calendar_set_display_options( recv, options );
44 `}
45
46 #date en nit...
47 fun date: String is abstract
48 end
49
50 #enum GtkCalendarDisplayOptions
51 #@https://developer.gnome.org/gtk3/3.2/GtkCalendar.html#GtkCalendarDisplayOptions
52 extern GtkCalendarDisplayOptions `{GtkCalendarDisplayOptions`}
53 new show_heading `{ return GTK_CALENDAR_SHOW_HEADING; `}
54 new show_day_names `{ return GTK_CALENDAR_SHOW_DAY_NAMES; `}
55 new no_month_change `{ return GTK_CALENDAR_NO_MONTH_CHANGE; `}
56 new show_week_numbers `{ return GTK_CALENDAR_SHOW_WEEK_NUMBERS; `}
57 new show_details `{ return GTK_CALENDAR_SHOW_DETAILS; `}
58 end
59
60 #A separator widget
61 #@https://developer.gnome.org/gtk3/stable/GtkSeparator.html
62 extern GtkSeparator `{GtkSeparator *`}
63 super GtkWidget
64
65 new ( orientation : GtkOrientation ) is extern `{
66 return (GtkSeparator *)gtk_separator_new( orientation );
67 `}
68
69 end
70
71 #A widget which indicates progress visually
72 #@https://developer.gnome.org/gtk3/3.2/GtkProgressBar.html
73 extern GtkProgressBar `{GtkProgressBar *`}
74 super GtkWidget
75
76 new is extern `{
77 return (GtkProgressBar *)gtk_progress_bar_new();
78 `}
79
80 fun pulse is extern `{
81 gtk_progress_bar_pulse( recv );
82 `}
83
84 fun pulse_step : Float is extern `{
85 return gtk_progress_bar_get_pulse_step( recv );
86 `}
87
88 fun pulse_step=( step : Float ) is extern `{
89 gtk_progress_bar_set_pulse_step( recv, step);
90 `}
91
92 fun fraction : Float is extern `{
93 return gtk_progress_bar_get_fraction( recv );
94 `}
95
96 fun fraction=( fraction : Float) is extern `{
97 gtk_progress_bar_set_fraction( recv, fraction );
98 `}
99
100 fun inverted : Bool is extern `{
101 return gtk_progress_bar_get_inverted( recv );
102 `}
103
104 fun inverted=( is_inverted : Bool) is extern `{
105 gtk_progress_bar_set_inverted( recv, is_inverted );
106 `}
107
108 fun show_text : Bool is extern `{
109 return gtk_progress_bar_get_show_text( recv );
110 `}
111
112 fun show_text=( show : Bool) is extern `{
113 gtk_progress_bar_set_show_text( recv, show );
114 `}
115
116 fun text : String is extern import String::to_cstring`{
117 return new_String_from_cstring( (char *)gtk_progress_bar_get_text( recv ) );
118 `}
119
120 fun text=( value : String) is extern import String::to_cstring`{
121 gtk_progress_bar_set_text( recv, String_to_cstring( value ) );
122 `}
123
124 fun ellipsize is abstract
125
126 end
127
128 extern GtkColorSelectionDialog
129 super GtkWidget
130 new ( title : String, parent : GtkWindow ) is extern import String::to_cstring `{
131 return gtk_color_chooser_dialog_new( String_to_cstring( title ), parent );
132 `}
133
134 #fun color_selection : is extern `{
135 # return gtk_color_selection_dialog_get_color_selection( GTK_COLOR_SELECTION_DIALOG( recv ) );
136 #`}
137
138 #fun color : Float is extern `{
139 # return gtk_color_selection_dialog_get_color_selection( GTK_COLOR_SELECTION_DIALOG( recv ) );
140 #`}
141 end
142
143 #Retrieve an integer or floating-point number from the user
144 #@https://developer.gnome.org/gtk3/3.2/GtkSpinButton.html
145 extern GtkSpinButton `{GtkSpinButton *`}
146 super GtkEntry
147
148 new ( adjustment : GtkAdjustment, climb_rate : Float, digits : Int )is extern `{
149 return (GtkSpinButton *)gtk_spin_button_new( adjustment, climb_rate, digits );
150 `}
151
152 new with_range( min : Float, max : Float, step : Float )is extern `{
153 return (GtkSpinButton *)gtk_spin_button_new_with_range( min, max, step );
154 `}
155
156 fun configure ( adjustment : GtkAdjustment, climb_rate : Float, digits : Int ) is extern `{
157 gtk_spin_button_configure( recv, adjustment, climb_rate, digits );
158 `}
159
160 fun adjustment : GtkAdjustment is extern `{
161 return gtk_spin_button_get_adjustment( recv );
162 `}
163
164 fun adjustment=( value : GtkAdjustment ) is extern `{
165 gtk_spin_button_set_adjustment( recv, value );
166 `}
167
168 fun digits : Int is extern `{
169 return gtk_spin_button_get_digits( recv );
170 `}
171
172 fun digits=( nb_digits : Int ) is extern `{
173 gtk_spin_button_set_digits( recv, nb_digits );
174 `}
175
176 fun value : Float is extern `{
177 return gtk_spin_button_get_value( recv );
178 `}
179
180 fun val=( val : Float ) is extern `{
181 gtk_spin_button_set_value( recv, val );
182 `}
183
184 fun spin( direction : GtkSpinType, increment : Float ) is extern`{
185 gtk_spin_button_spin( recv, direction, increment );
186 `}
187 end
188
189 #enum GtkSpinType
190 #The values of the GtkSpinType enumeration are used to specify the change to make in gtk_spin_button_spin().
191 #@https://developer.gnome.org/gtk3/stable/GtkSpinButton.html#GtkSpinType
192 extern GtkSpinType `{GtkSpinType`}
193 #Increment by the adjustments step increment.
194 new step_forward `{ return GTK_SPIN_STEP_FORWARD; `}
195
196 #Decrement by the adjustments step increment.
197 new step_backward `{ return GTK_SPIN_STEP_BACKWARD; `}
198
199 #Increment by the adjustments page increment.
200 new page_forward `{ return GTK_SPIN_PAGE_FORWARD; `}
201
202 #Decrement by the adjustments page increment.
203 new page_backward `{ return GTK_SPIN_PAGE_BACKWARD; `}
204
205 #Go to the adjustments lower bound.
206 new lower_bound `{ return GTK_SPIN_HOME; `}
207
208 #Go to the adjustments upper bound.
209 new upper_bound `{ return GTK_SPIN_END; `}
210
211 #Change by a specified amount.
212 new user_defined `{ return GTK_SPIN_USER_DEFINED; `}
213 end
214
215 #An entry which shows a search icon
216 #@https://developer.gnome.org/gtk3/stable/GtkSearchEntry.html
217 extern GtkSearchEntry `{GtkSearchEntry *`}
218 super GtkEntry
219
220 new is extern `{
221 return (GtkSearchEntry *)gtk_search_entry_new( );
222 `}
223 end
224
225 #A widget to unlock or lock privileged operations
226 #@https://developer.gnome.org/gtk3/stable/GtkLockButton.html
227 extern GtkLockButton
228 super GtkButton
229 end
230
231 #A button to launch a color selection dialog
232 #@https://developer.gnome.org/gtk3/stable/GtkColorButton.html
233 extern GtkColorButton `{GtkColorButton *`}
234 super GtkButton
235
236 new is extern `{
237 return (GtkColorButton *)gtk_color_button_new( );
238 `}
239
240 fun color=( col : GdkColor ) is extern `{
241
242 /* deprecated
243 GdkColor *c = malloc(sizeof(GdkColor));
244 c->pixel = 50;
245 c->red = 50;
246 c->green = 50;
247 c->blue = 50;
248
249 gtk_color_button_set_color( (GtkColorButton*)recv, c );*/
250 `}
251 end
252