1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2011-2013 Alexis Laferrière <alexis.laf@xymus.net>
4 # Copyright 2013 Nathan Heu <heu.nathan@courrier.uqam.ca>
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
18 module gtk_widgets_ext
is pkgconfig
("gtk+-3.0")
22 #Displays a calendar and allows the user to select a date
23 #@https://developer.gnome.org/gtk3/3.2/GtkCalendar.html
24 extern class GtkCalendar `{GtkCalendar *`}
28 return (GtkCalendar *)gtk_calendar_new
();
31 fun month=( month : Int, year : Int ) is extern `{
32 gtk_calendar_select_month
( recv
, month
, year
);
35 fun day=( day : Int ) is extern `{
36 gtk_calendar_select_day
( recv
, day
);
39 fun mark_day( day : Int ) is extern `{
40 gtk_calendar_mark_day
( recv
, day
);
43 fun unmark_day( day : Int ) is extern `{
44 gtk_calendar_unmark_day
( recv
, day
);
47 fun is_marked( day : Int ): Bool is extern `{
48 return gtk_calendar_get_day_is_marked
( recv
, day
);
51 fun clear_marks is extern `{
52 gtk_calendar_clear_marks
( recv
);
55 fun display_options : GtkCalendarDisplayOptions is extern `{
56 return gtk_calendar_get_display_options
( recv
);
60 fun display_options=( options : GtkCalendarDisplayOptions) is extern `{
61 gtk_calendar_set_display_options
( recv
, options
);
65 fun date: String is abstract
68 #enum GtkCalendarDisplayOptions
69 #@https://developer.gnome.org/gtk3/3.2/GtkCalendar.html#GtkCalendarDisplayOptions
70 extern class GtkCalendarDisplayOptions `{GtkCalendarDisplayOptions`}
71 new show_heading
`{ return GTK_CALENDAR_SHOW_HEADING; `}
72 new show_day_names `{ return GTK_CALENDAR_SHOW_DAY_NAMES; `}
73 new no_month_change
`{ return GTK_CALENDAR_NO_MONTH_CHANGE; `}
74 new show_week_numbers `{ return GTK_CALENDAR_SHOW_WEEK_NUMBERS; `}
75 new show_details
`{ return GTK_CALENDAR_SHOW_DETAILS; `}
79 #@https://developer.gnome.org/gtk3/stable/GtkSeparator.html
80 extern class GtkSeparator `{GtkSeparator *`}
83 new ( orientation
: GtkOrientation ) is extern `{
84 return (GtkSeparator *)gtk_separator_new( orientation );
89 #A widget which indicates progress visually
90 #@https://developer.gnome.org/gtk3/3.2/GtkProgressBar.html
91 extern class GtkProgressBar `{GtkProgressBar *`}
95 return (GtkProgressBar *)gtk_progress_bar_new
();
98 fun pulse is extern `{
99 gtk_progress_bar_pulse
( recv
);
102 fun pulse_step : Float is extern `{
103 return gtk_progress_bar_get_pulse_step
( recv
);
106 fun pulse_step=( step : Float ) is extern `{
107 gtk_progress_bar_set_pulse_step
( recv
, step
);
110 fun fraction : Float is extern `{
111 return gtk_progress_bar_get_fraction
( recv
);
114 fun fraction=( fraction : Float) is extern `{
115 gtk_progress_bar_set_fraction
( recv
, fraction
);
118 fun inverted : Bool is extern `{
119 return gtk_progress_bar_get_inverted
( recv
);
122 fun inverted=( is_inverted : Bool) is extern `{
123 gtk_progress_bar_set_inverted
( recv
, is_inverted
);
126 fun show_text : Bool is extern `{
127 return gtk_progress_bar_get_show_text
( recv
);
130 fun show_text=( show : Bool) is extern `{
131 gtk_progress_bar_set_show_text
( recv
, show
);
134 fun text : String is extern import NativeString.to_s `{
135 return NativeString_to_s( (char
*)gtk_progress_bar_get_text
( recv
) );
138 fun text=( value : String) is extern import String.to_cstring`{
139 gtk_progress_bar_set_text
( recv
, String_to_cstring( value
) );
142 fun ellipsize is abstract
146 extern class GtkColorSelectionDialog
148 new ( title : String, parent : GtkWindow ) is extern import String.to_cstring `{
149 return gtk_color_chooser_dialog_new
( String_to_cstring( title
), parent
);
152 #fun color_selection : is extern `{
153 # return gtk_color_selection_dialog_get_color_selection( GTK_COLOR_SELECTION_DIALOG( recv ) );
156 #fun color : Float is extern `{
157 # return gtk_color_selection_dialog_get_color_selection( GTK_COLOR_SELECTION_DIALOG( recv ) );
161 #Retrieve an integer or floating-point number from the user
162 #@https://developer.gnome.org/gtk3/3.2/GtkSpinButton.html
163 extern class GtkSpinButton `{GtkSpinButton *`}
166 new ( adjustment : GtkAdjustment, climb_rate : Float, digits : Int )is extern `{
167 return (GtkSpinButton *)gtk_spin_button_new
( adjustment
, climb_rate
, digits
);
170 new with_range( min : Float, max : Float, step : Float )is extern `{
171 return (GtkSpinButton *)gtk_spin_button_new_with_range
( min
, max
, step
);
174 fun configure ( adjustment : GtkAdjustment, climb_rate : Float, digits : Int ) is extern `{
175 gtk_spin_button_configure
( recv
, adjustment
, climb_rate
, digits
);
178 fun adjustment : GtkAdjustment is extern `{
179 return gtk_spin_button_get_adjustment
( recv
);
182 fun adjustment=( value : GtkAdjustment ) is extern `{
183 gtk_spin_button_set_adjustment
( recv
, value
);
186 fun digits : Int is extern `{
187 return gtk_spin_button_get_digits
( recv
);
190 fun digits=( nb_digits : Int ) is extern `{
191 gtk_spin_button_set_digits
( recv
, nb_digits
);
194 fun value : Float is extern `{
195 return gtk_spin_button_get_value
( recv
);
198 fun val=( val : Float ) is extern `{
199 gtk_spin_button_set_value
( recv
, val
);
202 fun spin( direction : GtkSpinType, increment : Float ) is extern`{
203 gtk_spin_button_spin
( recv
, direction
, increment
);
208 #The values of the GtkSpinType enumeration are used to specify the change to make in gtk_spin_button_spin().
209 #@https://developer.gnome.org/gtk3/stable/GtkSpinButton.html#GtkSpinType
210 extern class GtkSpinType `{GtkSpinType`}
211 #Increment by the adjustments step increment.
212 new step_forward
`{ return GTK_SPIN_STEP_FORWARD; `}
214 #Decrement by the adjustments step increment.
215 new step_backward `{ return GTK_SPIN_STEP_BACKWARD; `}
217 #Increment by the adjustments page increment.
218 new page_forward
`{ return GTK_SPIN_PAGE_FORWARD; `}
220 #Decrement by the adjustments page increment.
221 new page_backward `{ return GTK_SPIN_PAGE_BACKWARD; `}
223 #Go to the adjustments lower bound.
224 new lower_bound
`{ return GTK_SPIN_HOME; `}
226 #Go to the adjustments upper bound.
227 new upper_bound `{ return GTK_SPIN_END; `}
229 #Change by a specified amount.
230 new user_defined
`{ return GTK_SPIN_USER_DEFINED; `}
233 #A widget to unlock or lock privileged operations
234 #@https://developer.gnome.org/gtk3/stable/GtkLockButton.html
235 extern class GtkLockButton
239 #A button to launch a color selection dialog
240 #@https://developer.gnome.org/gtk3/stable/GtkColorButton.html
241 extern class GtkColorButton `{GtkColorButton *`}
245 return (GtkColorButton *)gtk_color_button_new( );
248 fun color
=( col
: GdkColor ) is extern `{
251 GdkColor *c = malloc(sizeof(GdkColor));
257 gtk_color_button_set_color( (GtkColorButton*)recv, c );*/