commit 5106228da25e343949e917ed4dedc50107dbe116 Author: mollusk Date: Fri Nov 25 00:27:22 2016 -0700 First commit diff --git a/editor b/editor new file mode 100755 index 0000000..90174ba --- /dev/null +++ b/editor @@ -0,0 +1,13 @@ +#!/bin/bash + + + +if [ ! -f /usr/bin/eui ];then + sudo ./tools/euphoria-manager i + eui ./tools/WEE/wee.exw +else + if [ "${1}" = "-c" ];then + euc ./tools/WEE/wee.exw + fi + eui ./tools/WEE/wee.exw +fi diff --git a/eugtk/GtkAboutDialog.e b/eugtk/GtkAboutDialog.e new file mode 100644 index 0000000..3176199 --- /dev/null +++ b/eugtk/GtkAboutDialog.e @@ -0,0 +1,39 @@ + +------------------- +namespace about -- Generic About dialog +------------------- + +export constant version = "4.12.0" + +--# EXPORTS: about:Dialog -- use run(about:Dialog), not show() + +include GtkEngine.e +public include euphoria/info.e + +if not equal(version,gtk:version) then + Error(,,"GtkAboutDialog version mismatch","should be version " & gtk:version) +end if + +export atom Dialog = create(GtkAboutDialog,{ + {"name","about:dialog"}, + {"logo","thumbnails/eugtk.png"}, + {"program name",prg_name}, + {"version","EuGTK version: " & gtk:version}, + {"copyright",copyright}, + {"comments","For information on the Euphoria\nprogramming language, click below"}, + + -- must specify custom as the license type if supplying license text; + {"license type",GTK_LICENSE_CUSTOM}, + {"license",LGPL}, -- LGPL text is built into EuGTK + {"wrap license",0}, + + {"website","http://OpenEuphoria.org"}, + {"website label","OpenEuphoria"}, + {"authors",{"Irv Mullins"}}, + + --{"artists",0}, + --{"documenters",0}, + --{"translator credits",0}, + --{"add credit section","Special Thanks to",{"\nBob's Burgers\nDuff's Beer"}}, + $}) + diff --git a/eugtk/GtkCairo.e b/eugtk/GtkCairo.e new file mode 100644 index 0000000..24126d1 --- /dev/null +++ b/eugtk/GtkCairo.e @@ -0,0 +1,643 @@ + +---------------------------- +namespace cairo +---------------------------- + +export constant version = "4.12.0" + +include GtkEngine.e + +if not equal(version,gtk:version) then + Error(,,"GtkCairo version mismatch","should be version " & gtk:version) +end if + +export constant pango_version = gtk_str_func("pango_version_string") + +widget[GdkCairo_t] = {"gdk_cairo", +{Cairo_t}, + {"new",{P},-routine_id("newGdkCairo")}, + {"draw_from_gl",{P,P,I,I,I,I,I,I,I}}, -- 3.16 + {"get_clip_rectangle",{P},-routine_id("getClipRect")}, + {"set_source_pixbuf",{P,P,D,D}}, + {"set_source_window",{P,P,D,D}}, + {"region",{P,P}}, + {"region_create_from_surface",{P},P}, + {"surface_create_from_pixbuf",{P,I,P},P,0,CairoSurface_t}, + {"set_source_rgba",{P,I,I,I,D},-routine_id("setCairoRGBA")}, + {"set_color",{P,P},-routine_id("setCairoColor")}, +"GdkCairo_t"} + + function getClipRect(atom cr) + atom fn = define_func("gdk_cairo_get_clip_rectangle",{P,P},B) + atom rect = allocate(8,1) + if c_func(fn,{cr,rect}) then + return rect + else return -1 + end if + end function + + function newGdkCairo(atom win) + return gtk_func("gdk_cairo_create",{P},{win}) + end function + + ---------------------------------------------------------------- + -- to use the Cairo color specs, where colors are 0.0 => 1.0 + ---------------------------------------------------------------------- + function setCairoRGBA(atom cr, atom r, atom g, atom b, atom a=1) + gtk_proc("cairo_set_source_rgba",{P,D,D,D,D},{cr,r,g,b,a}) + return 1 + end function + + -------------------------------------------- + -- it's easier to use named colors + -------------------------------------------- + function setCairoColor(atom cr, object color) + if atom(color) then color = sprintf("#%06x",color) end if + color = to_rgba(color) + color = from_rgba(color,7) + setCairoRGBA(cr,color[1],color[2],color[3],color[4]) + return 1 + end function + +widget[Cairo_t] = {"cairo", +{GObject}, + {"create",{P},P}, + {"reference",{P},P}, + {"destroy",{P}}, + {"status",{P},I}, + {"save",{P}}, + {"restore",{P}}, + {"get_target",{P},P,0,CairoSurface_t}, + {"push_group",{P}}, + {"push_group_with_content",{P,P}}, + {"pop_group",{P},P}, + {"pop_group_to_source",{P}}, + {"get_group_target",{P},P}, + {"set_source_rgb",{P,D,D,D}}, + {"set_source",{P,P}}, + {"get_source",{P},P}, + {"set_source_surface",{P,P,D,D}}, + {"set_antialias",{P,I}}, + {"get_antialias",{P},I}, + {"set_dash",{P,P,I,D}}, + {"get_dash_count",{P},I}, + {"get_dash",{P,D,D}}, + {"set_fill_rule",{P,I}}, + {"get_fill_rule",{P},I}, + {"set_line_cap",{P,I}}, + {"get_line_cap",{P},I}, + {"set_line_join",{P,I}}, + {"get_line_join",{P},I}, + {"set_line_width",{P,D}}, + {"get_line_width",{P},D}, + {"set_miter_limit",{P,I}}, + {"get_miter_limit",{P},I}, + {"set_operator",{P,I}}, + {"get_operator",{P},I}, + {"set_tolerance",{P,D}}, + {"get_tolerance",{P},D}, + {"clip",{P}}, + {"clip_preserve",{P}}, + {"clip_extents",{P,D,D,D,D}}, + {"in_clip",{P,D,D},B}, + {"reset_clip",{P}}, + {"rectangle_list_destroy",{P}}, + {"fill",{P}}, + {"fill_preserve",{P}}, + {"fill_extents",{P,D,D,D,D}}, + {"in_fill",{P,D,D},B}, + {"mask",{P,P}}, + {"mask_surface",{P,P,D,D}}, + {"paint",{P}}, + {"paint_with_alpha",{P,D}}, + {"stroke",{P}}, + {"stroke_preserve",{P}}, + {"stroke_extents",{P,D,D,D,D}}, + {"in_stroke",{P,D,D},B}, + {"copy_page",{P}}, + {"show_page",{P}}, + {"copy_path",{P},P}, + {"copy_path_flat",{P},P}, + {"path_destroy",{P}}, + {"append_path",{P,P}}, + {"has_current_point",{P},B}, + {"get_current_point",{P,D,D}}, + {"new_path",{P}}, + {"new_sub_path",{P}}, + {"close_path",{P}}, + {"set_user_data",{P,S,P,P},I}, + {"get_user_data",{P,S}}, + {"arc",{P,D,D,D,D,D}}, + {"arc_negative",{P,D,D,D,D,D}}, + {"move_to",{P,D,D}}, + {"rel_move_to",{P,D,D}}, + {"line_to",{P,D,D}}, + {"rel_line_to",{P,D,D}}, + {"rectangle",{P,D,D,D,D}}, + {"glyph_path",{P,I,I}}, + {"text_path",{P,S}}, + {"curve_to",{P,D,D,D,D,D,D}}, + {"rel_curve_to",{P,D,D,D,D,D,D}}, + {"path_extents",{P,D,D,D,D}}, + {"set_font_face",{P,S}}, + {"device_get_type",{P},I}, + {"device_status",{P},I}, + {"status_to_string",{I},S}, + {"translate",{P,D,D}}, + {"scale",{P,D,D}}, + {"rotate",{P,D}}, + {"transform",{P,P}}, + {"translate",{P,D,D}}, + {"scale",{P,D,D}}, + {"rotate",{P,D}}, + {"transform",{P,P}}, + {"set_matrix",{P,P}}, + {"get_matrix",{P,P}}, + {"identity_matrix",{P}}, + {"user_to_device",{P,D,D}}, + {"user_to_device_distance",{P,D,D}}, + {"device_to_user",{P,D,D}}, + {"device_to_user_distance",{P,D,D}}, + {"version",{},I}, + {"version_string",{},S}, + {"set_font_size",{P,D}}, + {"set_font_matrix",{P,P}}, + {"get_font_matrix",{P,P}}, + {"set_font_options",{P,P}}, + {"get_font_options",{P,P}}, + {"select_font_face",{P,S,I,I}}, + {"get_font_face",{P},P}, + {"set_scaled_font",{P,P}}, + {"get_scaled_font",{P},P}, + {"show_glyphs",{P,P}}, + {"show_text_glyphs",{P,S,I,P,I,P,I,I}}, + {"font_extents",{P,P}}, + {"text_extents",{P,S,P}}, + {"glyph_extents",{P,P,I,P}}, + {"toy_font_face_create",{S,I,I},P}, + {"toy_font_face_get_slant",{P},I}, + {"toy_font_face_get_weight",{P},I}, + {"glyph_allocate",{I},P}, + {"glyph_free",{P}}, + {"text_cluster_allocate",{I},P}, + {"text_cluster_free",{P}}, + {"show_text",{P,S}}, + {"set_source_rgba",{P,D,D,D,D},-routine_id("setCairoRGBA")}, + {"set_color",{P,S},-routine_id("setCairoColor")}, + {"should_draw_window",{P,P},-routine_id("CairoShouldDrawWin")}, + {"transform_to_window",{P,P,P},-routine_id("CairoTransformToWin")}, +"Cairo_t"} + + function CairoShouldDrawWin(atom cr, atom win) + return gtk_func("gtk_cairo_should_draw_window",{P,P},{cr,win}) + end function + + function CairoTransformToWin(atom cr, atom win1, atom win2) + gtk_proc("gtk_cairo_transform_to_window",{P,P,P},{cr,win1,win2}) + return 1 + end function + +widget[CairoPattern_t] = {0, +{Cairo_t}, +"CairoPattern_t"} + +widget[CairoFontOptions] = {"cairo_font_options", +{0}, +"CairoFontOptions"} + +widget[CairoContent_t] = {0, +{Cairo_t}, +"CairoContent_t"} + +widget[CairoStatus_t] = {0, +{0}, +"CairoStatus_t"} + +widget[CairoPattern] = {"cairo_pattern", +{CairoPattern_t}, + {"new",{P},-routine_id("newCairoPattern")}, + {"add_color_stop_rgb",{P,D,D,D,D}}, + {"add_color_stop_rgba",{P,D,D,D,D,D}}, + {"get_color_stop_count",{P,I},P,0,CairoStatus_t}, + {"get_color_stop_rgba",{P,I,D,D,D,D,D},P,0,CairoStatus_t}, + {"create_rgb",{D,D,D},P,0,CairoPattern_t}, + {"create_rgba",{D,D,D,D},P,0,CairoPattern_t}, + {"get_rgba",{P,D,D,D,D},P,0,CairoPattern_t}, + {"create_for_surface",{P},P,0,CairoPattern_t}, + {"reference",{P},P,0,CairoPattern_t}, + {"destroy",{P}}, + {"status",{P},P,0,CairoStatus_t}, + {"set_extend",{P,I}}, + {"get_extend",{P},I}, + {"set_filter",{P,I}}, + {"get_filter",{P},I}, + {"set_matrix",{P,P}}, + {"get_matrix",{P,P}}, + {"get_type",{P},I}, + {"get_reference_count",{P},I}, +"CairoPattern"} + + function newCairoPattern(atom surf) + return gtk_func("cairo_pattern_create_for_surface",{P},{surf}) + end function + +widget[CairoLinearGradient] = {"cairo_pattern", +{CairoPattern}, + {"new",{D,D,D,D},-routine_id("newLinearGradient"),0,CairoPattern_t}, + {"get_linear_points",{P,D,D,D,D},P,0,CairoStatus_t}, +"CairoLinearGradient"} + + function newLinearGradient(atom a, atom b, atom c, atom d) + return gtk_func("cairo_pattern_create_linear",{D,D,D,D},{a,b,c,d}) + end function + +widget[CairoRadialGradient] = {"cairo_pattern", +{CairoPattern}, + {"new",{D,D,D,D,D,D},-routine_id("newRadialGradient"),0,CairoPattern_t}, + {"get_radial_circles",{P,D,D,D,D,D,D},P,0,CairoStatus_t}, +"CairoRadialGradient"} + + function newRadialGradient(atom a, atom b, atom c, atom d, atom e, atom f) + return gtk_func("cairo_pattern_create_radial",{D,D,D,D,D,D},{a,b,c,d,e,f}) + end function + +widget[CairoRegion_t] = {"cairo_region_t", -- FIXME! +{Cairo_t}, +"CairoRegion_t"} + +widget[CairoSurface_t] = {"cairo_surface_t", +{Cairo_t}, + {"get_write_to_png",{P,S},-routine_id("writetoPNG")}, + {"create_similar",{P,P,I,I},P,0,CairoSurface_t}, + {"create_for_rectangle",{P,D,D,D,D},P,0,CairoSurface_t}, + {"reference",{P},P,0,CairoSurface_t}, + {"destroy",{P}}, + {"finish",{P}}, + {"flush",{P}}, + {"get_font_options",{P,P}}, + {"mark_dirty",{P}}, + {"mark_dirty_rectangle",{P,I,I,I,I}}, + {"show_page",{P}}, +"CairoSurface_t"} + + function writetoPNG(atom surf, object name) -- note difference in call name; + return gtk_func("cairo_surface_write_to_png",{P,S},{surf,name}) + end function + +widget[CairoImageSurface] = {"cairo_image_surface", +{CairoSurface_t}, + {"new",{P},-routine_id("newCairoImageSurface")}, + {"get_format",{P},I}, + {"get_width",{P},P}, + {"get_height",{P},P}, + {"get_stride",{P},I}, +"CairoImageSurface"} + + function newCairoImageSurface(object png) + if string(png) then + png = locate_file(png) if file_type(png) = 1 then + png = allocate_string(png) + end if + end if + return gtk_func("cairo_image_surface_create_from_png",{S},{png}) + end function + +widget[PangoCairoLayout] = {"pango_cairo", +{PangoLayout}, + {"new",{P},-routine_id("newPangoCairoLayout")}, + {"update_layout",{P,P},-routine_id("updateLayout")}, + {"show_glyph_string",{P,P,P}}, + {"show_glyph_item",{P,S,P}}, + {"show_layout_line",{P,P}}, + {"layout_line_path",{P,P}}, + {"layout_path",{P,P}}, +"PangoCairoLayout"} + + function newPangoCairoLayout(atom cr) + atom pcl = gtk_func("pango_cairo_create_layout",{P},{cr}) + register(pcl,PangoLayout) + return pcl + end function + + function updateLayout(atom pl, atom cr) -- params swapped; + gtk_proc("pango_cairo_update_layout",{P,P},{cr,pl}) + return 1 + end function + +widget[PangoFont] = {"pango_font", +{0}, + {"describe",{P},P,0,PangoFontDescription}, + {"describe_with_absolute_size",{P},P,0,PangoFontDescription}, + {"get_coverage",{P,P},P}, + {"get_metrics",{P,P},P}, + {"get_font_map",{P},P,0,PangoFontMap}, +"PangoFont"} + +widget[PangoAttrList] = {"pango_attr_list", +{0}, +"PangoAttrList"} + +widget[PangoFontDescription] = {"pango_font_description", +{PangoFont}, + {"new",{P},-routine_id("newPangoFontDescription")}, + {"copy",{P},P,0,PangoFontDescription}, + {"copy_static",{P},P,0,PangoFontDescription}, + {"hash",{P},I}, + {"equal",{P,P},B}, + {"free",{P}}, + {"set_family",{P,S}}, + {"set_family_static",{P,S}}, + {"get_family",{P},S}, + {"set_style",{P,I}}, + {"get_style",{P},I}, + {"set_variant",{P,I}}, + {"get_variant",{P},P}, + {"set_weight",{P,I}}, + {"get_weight",{P},I}, + {"set_stretch",{P,I}}, + {"get_stretch",{P},I}, + {"set_size",{P,I}}, + {"get_size",{P},I}, + {"set_absolute_size",{P,D}}, + {"get_size_is_absolute",{P},B}, + {"set_gravity",{P,I}}, + {"get_gravity",{P},I}, + {"get_set_fields",{P},I}, + {"unset_fields",{P,I}}, + {"merge",{P,P,B}}, + {"merge_static",{P,P,B}}, + {"better_match",{P,P,P},B}, + -- from_string, see new + {"to_string",{P},S}, + {"to_filename",{P},S}, +"PangoFontDescription"} + + function newPangoFontDescription(object name=0) + if atom(name) then + return gtk_func("pango_font_description_new") + else + return gtk_func("pango_font_description_from_string",{P},{allocate_string(name,1)}) + end if + end function + +widget[PangoContext] = {"pango_context", +{GObject}, + {"new",{},P}, + {"load_font",{P,P},P}, + {"load_fontset",{P,P,P},P}, + {"get_metrics",{P,P,P},P}, + {"list_families",{P,A,I}}, + {"set_font_description",{P,P}}, + {"get_font_description",{P},P,0,PangoFontDescription}, + {"set_font_map",{P,P}}, + {"get_font_map",{P},P}, + {"set_base_gravity",{P,I}}, + {"get_language",{P},P}, + {"set_language",{P,P}}, + {"get_layout",{P},P}, + {"get_base_dir",{P},I}, + {"set_base_dir",{P,I}}, + {"get_base_gravity",{P},I}, + {"set_base_gravity",{P,I}}, + {"get_gravity",{P},I}, + {"get_gravity_hint",{P},I}, + {"set_gravity_hint",{P,I}}, + {"get_matrix",{P},P}, + {"set_matrix",{P,P}}, +"PangoContext"} + +widget[PangoFontsetSimple] = {"pango_fontset_simple", +{GObject}, + {"new",{P},P}, + {"append",{P,P}}, + {"size",{P},I}, +"PangoFontsetSimple"} + +widget[PangoFontSet] = {"pango_fontset", +{PangoFontsetSimple}, + {"get_font",{P,I},P,0,PangoFont}, + {"get_metrics",{P},P}, + {"foreach",{P,P,P}}, +"PangoFontSet"} + +widget[PangoFontMap] = {"pango_font_map", +{PangoFontSet}, + {"create_context",{P},P}, + {"load_font",{P,P,S},P}, + {"load_fontset",{P,P,S,P},P}, + {"list_families",{P,A,I}}, + {"get_shape_engine_type",{P},S}, + {"get_serial",{P},I}, + {"changed",{P}}, +"PangoFontMap"} + +widget[PangoFontFace] = {"pango_font_face", +{PangoFontMap}, + {"get_face_name",{P},S}, + {"list_sizes",{P,P,I}}, + {"describe",{P},P,0,PangoFontDescription}, + {"is_synthesized",{P},B}, +"PangoFontFace"} + +widget[PangoFontFamily] = {"pango_font_family", +{PangoFontFace}, + {"get_name",{P},S}, + {"is_monospace",{P},B}, + {"list_faces",{P,P,I}}, +"PangoFontFamily"} + +widget[PangoLayout] = {"pango_layout", +{GObject}, + {"new",{P},-routine_id("newPangoLayout")}, + {"set_text",{P,P},-routine_id("pl_set_text")}, + {"get_text",{P},S}, + {"get_character_count",{P},I}, + {"set_markup",{P,S},-routine_id("pl_set_markup")}, + {"set_markup_with_accel",{P,S,I,I},-routine_id("pl_set_markup_with_accel")}, + {"set_font_description",{P,P}}, + {"get_font_description",{P},P}, + {"set_attributes",{P,P}}, + {"get_attributes",{P},P,0,PangoAttrList}, + {"set_width",{P,I}}, + {"get_width",{P},I}, + {"set_height",{P,I}}, + {"get_height",{P},I}, + {"get_size",{P,I,I}}, + {"get_pixel_size",{P,I,I}}, + {"set_wrap",{P,I}}, + {"get_wrap",{P},I}, + {"is_wrapped",{P},B}, + {"set_ellipsize",{P,I}}, + {"get_ellipsize",{P},I}, + {"is_ellipsized",{P},B}, + {"set_indent",{P,I}}, + {"get_extents",{P,P,P}}, + {"get_indent",{P},I}, + {"get_pixel_size",{P,I,I}}, + {"get_size",{P,I,I}}, + {"set_spacing",{P,I}}, + {"get_spacing",{P},I}, + {"set_justify",{P,B}}, + {"get_justify",{P},B}, + {"set_auto_dir",{P,B}}, + {"get_auto_dir",{P},B}, + {"set_alignment",{P,P}}, + {"get_alignment",{P},P}, + {"set_tabs",{P,A}}, + {"get_tabs",{P},A}, + {"set_single_paragraph_mode",{P,B}}, + {"get_single_paragraph_mode",{P},B}, + {"get_unknown_glyphs_count",{P},I}, + {"get_log_attrs",{P,P,I}}, + {"get_log_attrs_readonly",{P,I},P}, + {"index_to_pos",{P,I,P}}, + {"index_to_line_x",{P,I,B,I,I}}, + {"xy_to_line",{P,I,I,I,I},B}, + {"get_cursor_pos",{P,I,P,P}}, + {"move_cursor_visually",{P,B,I,I,I,I,I}}, + {"get_pixel_extents",{P,P,P}}, + {"get_baseline",{P},I}, + {"get_line_count",{P},I}, + {"get_line",{P,I},P,0,PangoLayoutLine}, + {"get_line_readonly",{P,I},P,0,PangoLayoutLine}, + {"get_lines",{P},A,0,GSList}, + {"get_lines_readonly",{P},A,0,GSList}, + {"get_iter",{P},P,0,PangoLayoutIter}, + {"show_layout",{P,P},-routine_id("pl_show_layout")}, + {"get_context",{P},P,0,PangoContext}, + {"context_changed",{P}}, + {"get_serial",{P},I}, + {"get_extents",{P,P,P}}, +"PangoLayout"} + + function newPangoLayout(atom cr=0) + if cr=0 then + Error(,,"requires cairo_t as param!") + end if + return gtk_func("pango_cairo_create_layout",{P},{cr}) + end function + + function pl_set_text(atom layout, object txt) + if string(txt) then + txt = allocate_string(txt,1) + end if + gtk_proc("pango_layout_set_text",{P,P,I},{layout,txt,-1}) + return 1 + end function + + function pl_set_markup(atom layout, object txt) + if string(txt) then + txt = allocate_string(txt,1) + end if + gtk_proc("pango_layout_set_markup",{P,P,I},{layout,txt,-1}) + return 1 + end function + + function pl_set_markup_with_accel(atom layout, object txt, + integer marker, integer char) + if string(txt) then + txt = allocate_string(txt,1) + end if + gtk_proc("pango_layout_set_markup_with_accel",{P,P,I,I,I}, + {layout,txt,-1,marker,char}) + return 1 + end function + + function pl_show_layout(atom pcl, atom cr) + gtk_proc("pango_cairo_show_layout",{P,P},{cr,pcl}) + return 1 + end function + +widget[PangoLayoutLine] = {"pango_layout_line", +{0}, + {"ref",{P},P}, + {"unref",{P}}, + {"get_extents",{P,P,P}}, + {"get_pixel_extents",{P,P,P}}, + {"index_to_x",{P,I,B,I}}, + {"x_to_index",{P,I,I,I},B}, + {"get_x_ranges",{P,I,I,P,P}}, +"PangoLayoutLine"} + +widget[PangoLayoutIter] = {"pango_layout_iter", +{0}, + {"copy",{P},P,0,PangoLayoutIter}, + {"free",{P}}, + {"next_run",{P},B}, + {"next_char",{P},B}, + {"next_cluster",{P},B}, + {"next_line",{P},B}, + {"at_last_line",{P},B}, + {"get_index",{P},I}, + {"get_baseline",{P},I}, + {"get_run",{P},P,0,PangoLayoutRun}, + {"get_run_readonly",{P},P,0,PangoLayoutRun}, + {"get_line",{P},P,0,PangoLayoutLine}, + {"get_line_readonly",{P},P,0,PangoLayoutLine}, + {"get_layout",{P},P,0,PangoLayout}, + {"get_char_extents",{P,P}}, + {"get_cluster_extents",{P,P,P}}, + {"get_run_extents",{P,P,P}}, + {"get_line_yrange",{P,I,I}}, + {"get_line_extents",{P,P,P}}, + {"get_layout_extents",{P,P,P}}, +"PangoLayoutIter"} + +widget[PangoLayoutRun] = {"pango_layout_run", +{0}, +"PangoLayoutRun"} + +widget[PangoTabArray] = {"pango_tab_array", +{0}, + {"new",{I,B},P}, + {"get_size",{P},I}, + {"resize",{P,I}}, + {"set_tab",{P,I,I,I}}, + {"get_tab",{P,I,P,P}}, + {"get_tabs",{P,P,P}}, + {"get_position_in_pixels",{P},B}, +"PangoTabArray"} + +widget[PangoLanguage] = {"pango_language", +{GObject}, + {"new",{S},-routine_id("newPangoLanguage")}, + {"get_default",{P},-routine_id("getDefaultLanguage")}, + {"get_sample_string",{P},-routine_id("getSampleStr")}, + {"to_string",{P},S}, + {"matches",{P,S},B}, + {"includes_script",{P,P},B}, +"PangoLanguage"} + + function newPangoLanguage(object s) + return gtk_func("pango_language_from_string",{S},{s}) + end function + + function getDefaultLanguage(object junk) + return gtk_str_func("pango_language_get_default") + end function + + function getSampleStr(object x) + return gtk_str_func("pango_language_get_sample_string",{P},{x}) + end function + +export enum by * 2 + PANGO_STRETCH_ULTRA_CONDENSED, + PANGO_STRETCH_EXTRA_CONDENSED, + PANGO_STRETCH_CONDENSED, + PANGO_STRETCH_SEMI_CONDENSED, + PANGO_STRETCH_NORMAL, + PANGO_STRETCH_SEMI_EXPANDED, + PANGO_STRETCH_EXPANDED = 64, + PANGO_STRETCH_EXTRA_EXPANDED, + PANGO_STRETCH_ULTRA_EXPANDED + +export enum by * 2 + PANGO_FONT_MASK_FAMILY, + PANGO_FONT_MASK_STYLE, + PANGO_FONT_MASK_VARIANT, + PANGO_FONT_MASK_WEIGHT, + PANGO_FONT_MASK_STRETCH, + PANGO_FONT_MASK_SIZE, + PANGO_FONT_MASK_GRAVITY + + diff --git a/eugtk/GtkEngine.e b/eugtk/GtkEngine.e new file mode 100644 index 0000000..d3e9129 --- /dev/null +++ b/eugtk/GtkEngine.e @@ -0,0 +1,9648 @@ + +------------- +namespace gtk +------------- + +------------------------------------------------------------------------ +-- This library is free software; you can redistribute it +-- and/or modify it under the terms of the GNU Lesser General +-- Public License as published by the Free Software Foundation; +-- either version 2 of the License, or (at your option) any later +-- version. + +-- This library is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +-- See the GNU Lesser General Public License for more details. + +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Pl, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------ + +export constant + version = "4.12.0", + release = "Sept 1, 2016", + copyright = " © 2016 by Irv Mullins" + +public object ACCEL_FONT = "italic 10" -- affects accels in menus; +public integer BTN_ICON_SIZE = 20 -- pixels; +public integer BTN_TEXT_SIZE = 12 +public integer BTN_SHOW_IMG = 1 + +public include GtkEnums.e + +-- GtkEnums includes most of Eu std libraries as public, +-- making them available to your eu programs without +-- having to specifically include them. + +if not equal(gtk:version,enums:version) then -- these 2 must be in sync! + crash("Version mismatch: GtkEnums should be version %s",{version}) +end if + +-- std/math, std/locale, std/datetime, etc. aren't made +-- public, because that would cause too many conflicts, +-- requiring you to use namespaces everywhere, +-- but we do need them here; + +include std/datetime.e +include std/locale.e +include std/math.e +include std/net/dns.e +include std/utils.e +include std/net/http.e +include std/pipeio.e as pipe + +public constant -- 'shorthand' identifiers to save space in method prototypes; + P = C_POINTER, -- any valid pointer + B = C_BYTE, -- 8 bits (boolean) + I = C_INT, -- 32 (integer) + S = E_ATOM, -- 64 (string) + D = C_DOUBLE, -- 64 (double) + F = C_FLOAT, -- 32 (float) + A = E_INTEGER, -- 32/64 (glist ptr) + X = E_OBJECT, -- 32/64 (array of pointers) + V = E_SEQUENCE -- 32/64 (pointer to array of strings) + +-- hopefully, the above are compatible with both 32 and 64-bit architectures + +export object LIBS -- a single lib in UNIX, a sequence of dll's for Windows; + +ifdef OSX then -- thanks to Pete Eberlein for testing with OSX! + LIBS = {open_dll("/opt/local/lib/libgtk-3.dylib" )} + +elsifdef UNIX then -- Linux, BSD, etc. + LIBS = {open_dll("libgtk-3.so.0" )} + +elsifdef WINDOWS then + +object path = "C:/Program Files/GTK3-Runtime Win64/bin/" -- 3.18.6 is the vers. tested. + + LIBS = dir(path & "*.dll") -- get a list of all .dll's in that folder; + LIBS = vslice(LIBS,1) -- retain only the filenames; + + if atom(LIBS) then -- none found; + crash("\nFATAL ERROR:\n************ Cannot find GTK runtime libraries (.dlls)\n") + end if + + atom x + + for i = 1 to length(LIBS) do -- load each; + x = open_dll(LIBS[i]) + if x = 0 then + display("Error loading []",{LIBS[i]}) + else + LIBS[i] = x -- append this lib to list of libs; + end if + end for + +end ifdef -- PLATFORMS; + +if not object(LIBS) then -- no point in continuing; + crash("Required libraries not found!") +end if + +constant cmd = pad_tail(command_line(),4,"") + +if not gtk_func("gtk_init_check",{P,P},{0,0}) then -- initialize the GTK library; + crash("GTK Library error - cannot init GTK!") + +else -- success! + gtk_proc("g_set_prgname",{S}," " & filename(cmd[2])) -- set default pgm name; + gtk_proc("g_type_init",{}) -- initialize normal GTK types; + +end if + +public constant -- two special types must be initialized at run-time; + gPIX = gtk_func("gdk_pixbuf_get_type"), + gCOMBO = gtk_func("gtk_combo_box_get_type") + +------------------------------------------------------------- +-- Obtain a lot of sometimes useful system info; +------------------------------------------------------------- +include euphoria/info.e + +constant os_info = os:uname() + +export object + + major_version = gtk_func("gtk_get_major_version"), + minor_version = gtk_func("gtk_get_minor_version"), + micro_version = gtk_func("gtk_get_micro_version"), + + user_name = gtk_str_func("g_get_user_name"), + real_name = gtk_str_func("g_get_real_name"), + + curr_dir = current_dir(), + home_dir = gtk_str_func("g_get_home_dir"), + temp_dir = gtk_str_func("g_get_tmp_dir"), + data_dir = gtk_str_func("g_get_user_data_dir"), + conf_dir = gtk_str_func("g_get_user_config_dir"), + runt_dir = gtk_str_func("g_get_user_runtime_dir"), + + app_name = gtk_str_func("g_get_application_name"), + prg_name = gtk_str_func("g_get_prgname"), + lang_ = gtk_func("gtk_get_default_language"), + def_lang = gtk_str_func("pango_language_to_string",{P},{lang_}), + login = pathname(cmd[2]), + + os_pid = os:get_pid(), -- process id: e.g:1234 + os_name = os_info[1], -- e.g: Linux + os_distro = os_info[2], -- e.g: Mint17 + os_version = os_info[3], -- e.g: 3.13.0-24-generic + os_compiled = os_info[4], + os_arch = os_info[5], -- e.g: AMD64 + os_inc = getenv("EUINC"), + os_dir = getenv("EUDIR"), + os_path = getenv("PATH"), + os_shell = getenv("SHELL"), + os_term = getenv("TERM"), + + eu_platform = platform_name(), + host_name = gtk_str_func("g_get_host_name"), + host_addr = "127.0.0.1" + +ifdef BITS64 then + constant eu_arch_bits = "64" +elsedef + constant eu_arch_bits = "32" +end ifdef + +if atom(os_term) then os_term = "none" end if + +ifdef WINDOWS then + user_name = getenv("USERNAME") + real_name = getenv("USERNAME") + home_dir = getenv("HOMEPATH") + temp_dir = getenv("TEMP") + os_name = getenv("OS") + os_term = getenv("SESSIONNAME") + os_compiled = getenv("PROCESSOR_IDENTIFIER") +end ifdef + +-- following added because Windows misbehaves in the ifdef above :( + +if atom(os_term) then os_term = getenv("SESSIONNAME") end if +if atom(os_shell) then os_shell = getenv("ComSpec") end if +if atom(os_arch) then os_arch = getenv("PROCESSOR_ARCHITECTURE") end if + +export object info = { -- above system info in key/value form, sometimes this is useful; + "version=" & version, + "release=" & release, + "copyright=" & copyright, + "major=" & to_string(major_version), + "minor=" & to_string(minor_version), + "micro=" & to_string(micro_version), + "user_name=" & user_name, + "real_name=" & real_name, + "host_name=" & host_name, + "host_addr=" & host_addr, + "home_dir=" & home_dir, + "temp_dir=" & temp_dir, + "curr_dir=" & curr_dir, + "data_dir=" & data_dir, + "conf_dir=" & conf_dir, + "runt_dir=" & runt_dir, + "app_name=" & app_name, + "prg_name=" & prg_name, + "os_pid=" & to_string(os:get_pid()), + "os_name=" & os_info[1], + "os_distro=" & os_info[2], + "os_vers=" & os_info[3], + "os_comp=" & os_compiled, + "os_arch=" & os_arch, + "os_term=" & os_term, + "os_shell=" & os_shell, + "os_inc=" & os_inc, + "os_dir=" & os_dir, + "os_path=" & os_path, + "def_lang=" & def_lang, + "eu_version=" & version_string_short(), + "eu_revision=" & to_string(version_revision()), + "eu_platform=" & eu_platform, + "eu_arch_bits=" & eu_arch_bits, + "eu_date=" & version_date(), + "today=" & datetime:format(datetime:now(),"%A %B %d, %Y"), + "start_time=" & datetime:format(datetime:now(),"%H:%M:%S"), + "CMD1=" & cmd[1], + "CMD2=" & canonical_path(cmd[2]), + "CMD3=" & pathname(canonical_path(cmd[2])), + $} + +--------------------------- +export function networked() +--------------------------- +atom m = gtk_func("g_network_monitor_get_default") +return gtk_func("g_network_monitor_get_network_available",{P},{m}) +end function + +----------------------------------- +export function inet_connected() -- ping msftncsi +----------------------------------- +atom err = allocate(8) err = 0 +atom x = gtk_func("g_network_address_parse_uri",{P,I,P}, + {allocate_string("www.msftncsi.com"),80,err}) +if x > 0 then return gtk_str_func("g_socket_connectable_to_string",{P},{x}) +else return x +end if +end function + +-------------------------------- +export function get_net_address() +-------------------------------- + object results + object addr + + ifdef UNIX then + sequence tmp = temp_file(,"MYIP-") + system_exec(sprintf(`ifconfig | grep "inet addr:" > %s`,{tmp}),2) + results = trim(read_file(tmp)) + results = split(results," ") + delete_file(tmp) + for i = 1 to length(results) do + if match("inet addr:",results[i]) = 1 then + addr = split(results[i],':') + host_addr = addr[2] + info[11] = "host_addr=" & host_addr + return host_addr + end if + end for + end ifdef + + return "127.0.0.1" +end function + +--------------------------------------------------------- +public procedure requires(sequence a, object msg="Error") +--------------------------------------------------------- +-- an easy way to ensure that your program is using the +-- appropriate GTK version; +object s = split(a,'.') + if length(s) < 3 then s = append(s,"0") end if + s[1] = to_number(s[1]) + s[2] = to_number(s[2]) + s[3] = to_number(s[3]) + +object msg2 = gtk_str_func("gtk_check_version",{I,I,I},{s[1],s[2],s[3]}) + if string(msg2) then + Warn(,msg,msg2, + text:format("Requires Gtk version []\nInstalled is Gtk [].[].[]", + {a,major_version,minor_version,micro_version})) + abort(1) + end if +end procedure + +enum NAME,PARAMS,RETVAL,VECTOR,CLASS + +--------------------------------------------------------- +public function create(integer class, + object p1=0, object p2=0, object p3=0, object p4=0, + object p5=0, object p6=0, object p7=0, object p8=0) +--------------------------------------------------------- +-- This function does the following: +-- 1. initializes the class if not already initialized, +-- 2. creates a new instance of the class (returning a handle to that instance) +-- 3. optionally sets one or more properties and/or connects the default signal. +--------------------------------------------------------------------------------------- + if class = GtkStockList then -- GtkStock is not a real widget, but we fake it + return newStockList()-- also, stock items are deprecated as of 3.10+ + end if -- so don't get in the habit of using them too much :) + + if class = GtkColumn then return newColumn(p1) end if + + if not initialized[class] then -- create a routine_id for each 'method' in class + init(class) -- but only do it if this is the first call to that class + end if + + object method = lookup("new",vslice(widget[class],1),widget[class],0) + if method[VECTOR] = -1 then -- a 'new' method name was not found; + Error(,,widget[class][$],"not implemented in this GTK version!") + abort(class) + end if + + object props = 0, dataitem = 0 + if sequence(p1) and sequence(p1[1]) then -- a list of properties was provided. + props = p1 -- save until widget is created, + p1 = 0 -- then set them in one 'swell foop' + elsif string(p1) and match("=",p1) then -- properties were provided in string form, + props = keyvalues(p1,,,,"\t\n\r")-- break them up into key/value pairs, + p1 = 0 -- save for later; + dataitem = vlookup("data",props,1,2) + end if + + atom handle = 0 + object params = method[PARAMS] + object args = {p1,p2,p3,p4,p5,p6,p7,p8} + + args = args[1..length(params)] -- discard un-needed args; + + ifdef PARAMS then display(params) end ifdef -- debug; + + for i = 1 to length(params) do -- ensure values match formal params; + + switch params[i] do + + case S then -- convert string to pointer to cstring; + if string(args[i]) then + args[i] = allocate_string(args[i]) + end if + case B then -- convert "1", "TRUE", or "YES" to 1, + if string(args[i]) then + if args[i] = "1" + or upper(args[i]) = "TRUE" + or upper(args[i]) = "YES" then + args[i] = 1 + else + args[i] = 0 -- anything else is 0; + end if + end if + end switch + end for + + ifdef CREATE then -- debug; + display(decode_method("CREATE",class,method)) + puts(1,"\tArgs: ") display(args,{2,5,10,78,"%d","%.2g",32,127,1,0}) + ifdef METHOD then display(method) end ifdef + end ifdef + + if method[RETVAL] > 0 then -- it's a GTK function (routine_id is positive); + handle = c_func(method[VECTOR],args) + end if + + if method[RETVAL] < -1 then -- it's a Eu func (a negated routine_id) + handle = call_func(-method[VECTOR],args) -- convert to positive rid and call; + end if + + if handle = 0 then -- failure :( + ifdef CREATE then + display("Create failed for class []",{widget[class][$]}) + end ifdef + return handle + end if + + object sig = 0, arg1 = 0 ,arg2 = 0 + + switch class do -- connect a default signal for some common controls; + case GtkButton then sig ="clicked" arg1 = p2 arg2 = p3 + case GtkToolButton then sig ="clicked" arg1 = p3 arg2 = p4 + case GtkRadioButton then sig ="toggled" arg1 = p3 arg2 = p4 + case GtkRadioToolButton then sig = "toggled" arg1 = p3 arg2 = p4 + case GtkRadioMenuItem then sig ="toggled" arg1 = p3 arg2 = p4 + case GtkMenuItem then sig ="activate" arg1 = p2 arg2 = p3 + case GtkCheckMenuItem then sig = "toggled" arg1 = p2 arg2 = p3 + case GtkCellRendererToggle then sig = "toggled" arg1 = p1 arg2 = p2 + case GtkFontButton then sig = "font-set" arg1 = p2 arg2 = p3 + case GtkStatusIcon then sig = "activate" arg1 = p1 arg2 = p2 + case GtkSwitch then sig = "notify::active" arg1 = p1 arg2 = p2 + case GtkColorButton then sig = "color-set" arg1 = p2 arg2 = p3 + case GtkCalendar then sig = "day-selected-double-click" arg1 = p2 arg2 = p3 + case GtkComboBoxText, GtkComboBoxEntry then sig ="changed" arg1 = p1 arg2 = p2 + case GtkCheckButton then sig ="toggled" arg1 = p2 arg2 = p3 + case GtkToggleButton then sig ="toggled" arg1 = p2 arg2 = p3 + case GtkToggleToolButton then sig ="toggled" arg1 = p2 arg2 = p3 + end switch + + if atom(arg2) and arg2 = 0 then arg2 = dataitem end if + connect(handle,sig,arg1,arg2) -- connect per above switch; + + ifdef CREATE then -- debug; + display("\t[] => []\n",{widget[class][$],handle}) + end ifdef + + register(handle,class) + + if class = GtkWindow then -- if not otherwise specified, use OpenEu logo; + atom err= allocate(8,1) + gtk_func("gtk_window_set_default_icon_from_file",{P,P}, + {allocate_string(locate_file("./thumbnails/mongoose.png"),1),err}) + end if + ---------------------------------------------------------------------- + -- set properties using the new key/val style; + ---------------------------------------------------------------------- + object p = 0, signal, name, v1, v2, v3, v4 + + if not atom(props) then + + if handle > 0 then + + for i = 1 to length(props) do + while length(props[i]) < 5 do + props[i] &= 0 + end while + for n = 1 to 5 do + props[i][n] = numeric_test(props[i][n]) + end for + end for + + for i = 1 to length(props) do + name = props[i][1] + v1 = props[i][2] + v2 = props[i][3] + v3 = props[i][4] + v4 = props[i][5] + + ifdef SET then + display("\nset []->[]",{widget[class][$],props[i]}) + end ifdef + + if match("sig.",name) = 1 then + signal = name[5..$] + connect(handle,signal,v1,dataitem) + elsif match("$",name) = 1 then + signal = name[2..$] + connect(handle,signal,v1,dataitem) + elsif match("data.",name) = 1 then + set(handle,"data",name[6..$],v1) + else + set(handle,name,v1,v2,v3,v4) + end if + end for + end if + end if + + return handle -- a pointer to the newly created instance + +end function + +------------------------------------------------------------------------ +public function set(object handle, sequence property, + object p1=0, object p2=0, object p3=0, object p4=0, + object p5=0, object p6=0, object p7=0, object p8=0) +------------------------------------------------------------------------ +-- This routine sets a property or sequence of properties +-- for the given widget. +-- In order to work with Glade, widget names in string form +-- may be used, otherwise set() expects a handle. +-- Property is always a string, p1...p8 are optional parameters. +-- Any parameter expected but not supplied is set to null, excess +-- parameters are discarded. +------------------------------------------------------------------------ +integer class=-1 +object name = "unknown" +object result = 0 +object allocated = {} + + name = handle + + ifdef SETX then display({name,property,p1,p2,p3,p4}) end ifdef + + if string(handle) then handle = pointer(handle) end if + + if handle = 0 then + printf(1,"Critical error\n" & + "Objects must have a unique name!\n%s [%d]",{name,handle}) + return 0 + end if + + object prop = 0 + + if string(property) and match("=",property) > 0 then -- convert string props + property = keyvalues(property,,,,"\t\t\n") -- to key/val form; + end if + + if sequence(property) -- new create format (key=value pairs); + and not string(property) then + for i = 1 to length(property) do + while length(property[i]) < 5 do + property[i] &= 0 + end while + for n = 1 to 5 do + property[i][n] = numeric_test(property[i][n]) + end for + end for + + for i = 1 to length(property) do + prop = property[i] if prop[1][1]='$' then continue end if + while length(prop) < 8 do prop &= 0 end while + set(handle,prop[1],prop[2],prop[3],prop[4],prop[5],prop[6],prop[7],prop[8]) + end for + return 0 + end if + + class = vlookup(handle,registry,1,2,-1) -- get widget's class; + + if class = -1 then -- fail; + display("Set invalid handle [] []",{handle,prop}) + end if + + property = "set_" & lower(join(split(property,' '),'_')) -- conform; + + object method = lookup_method(class,property) + ifdef METHOD then display(method) end ifdef + + if atom(method) then + if not set_property(handle,property[5..$],numeric_test(p1)) then + Error(,,"Cannot set property",class_name(handle) & property) + end if + return 0 + end if + + if method[VECTOR] = -1 then + Warn(,,"Method not found", + sprintf("%s->%s",{class_name(handle),property})) + return 0 + end if + + -- method was found; + + object params = method[PARAMS] + + switch method[1] do -- make life easier for a common operation; + case "set_from_file" then p1 = canonical_path(p1) + end switch + + object args = {handle,p1,p2,p3,p4,p5,p6,p7,p8} + + ifdef PARAMS then + puts(1,"Params: ") display(params) + puts(1,"Args: ") display(args) + end ifdef + + args = args[1..length(params)] -- match args to formal parameters; + for i = 2 to length(args) do + switch params[i] do + + case A then -- array of strings; + if not atom(args[i]) then + args[i] = allocate_string_pointer_array(args[i]) + allocated &= args[i] + end if + + case S then -- string; + if atom(args[i]) then + args[i] = sprintf("%g",args[i]) + end if + if string(args[i]) then + args[i] = allocate_string(args[i]) + allocated &= args[i] + end if + + case B then + if string(args[i]) then + if equal("TRUE",upper(args[i])) + or equal("YES",upper(args[i])) + or equal("1",args[i]) then + args[i] = 1 + end if + if equal("FALSE",upper(args[i])) + or equal("NO",upper(args[i])) + or equal("0",args[i]) then + args[i] = 0 + end if + end if + + case I,D then + if string(args[i]) then + args[i] = to_number(args[i]) + end if + + -- apply patches for zero-based indexes; + switch method[1] do + case "add_attribute", + "set_active", + "set_text_column", + "set_pixbuf_column", + "set_tooltip_column", + "set_search_column", + "attribute_connect", + "reorder_child", + "page", + "remove_page", + "set_current_page", + "set_sort_column_id" then args[i]-=1 + end switch + end switch + end for + + ifdef SET then -- debug; + display(decode_method("SET",class,method)) + puts(1,"\tArgs: ") + display(decode_args(method,args), + {2,2,11,78,"%d","%2.22f",32,127,1,0}) + puts(1,"\n") + end ifdef + + if equal("set_name",property) then + p8 = find(handle,vslice(registry,1)) + registry[p8][4] = p1 + end if + + if method[RETVAL] = 0 then -- it's a GTK proc; + c_proc(method[VECTOR],args) + end if + + if method[RETVAL] > 0 then -- it's a GTK func; + result = c_func(method[VECTOR],args) + end if + + if method[RETVAL] <-1 then -- it's a Eu func; + result = call_func(-method[VECTOR],args) + end if + + if method[VECTOR] = -1 then -- GTK doesn't know about this method! + printf(1, + "Warning: %s->%s call is invalid," & + "******** perhaps you need a later GTK version", + {widget[class][$],property}) + end if + + if not equal("set_data",property) then + for i = 1 to length(allocated) do + free(allocated[i]) + end for + end if + + return result + +end function + +----------------------------------------------------------------------------------- +export function get(object handle, sequence property, + object p1=MINF, object p2=MINF, object p3=MINF, object p4=MINF, object p5=MINF) +----------------------------------------------------------------------------------- +-- This routine gets one or more values for a given property name. +-- Property name is always a string, handle is usually an atom, +-- but may sometimes be a string in order to work with Glade. +----------------------------------------------------------------------------------- +integer class +object name = "unknown" + + if string(handle) then + name = handle + handle = pointer(handle) + end if + + class = vlookup(handle,registry,1,2,-1) -- get widget's class; + + if class = -1 then + return 0 + end if + + property = "get_" & lower(join(split(property,' '),'_')) + + object method = lookup_method(class,property) + + if atom(method) then -- not found, try fallback to Object; + return get_property(handle,property[5..$]) + end if + + -- else, method found; + + object params = method[PARAMS] + + if method[VECTOR] = -1 then + crash("\nERROR:\n****** Invalid call: %s->%s",{widget[class][$],method[1]}) + end if + + object result = {} + + if string(p1) then p1 = allocate_string(p1,1) end if + if string(p2) then p2 = allocate_string(p2,1) end if + if string(p3) then p3 = allocate_string(p3,1) end if + if string(p4) then p4 = allocate_string(p4,1) end if + + object args = {handle,allocate(8,1),allocate(8,1),allocate(8,1),allocate(8,1)} + if p1 > MINF then args[2]=p1 end if + if p2 > MINF then args[3]=p2 end if + if p3 > MINF then args[4]=p3 end if + if p4 > MINF then args[5]=p4 end if + + args = args[1..length(params)] + + ifdef GET then -- debug + display(decode_method("GET",class,method),0) + puts(1,"\tArgs: ") + display(decode_args(method,args), + {2,2,11,78,"%d","%2.22f",32,127,4,-1}) + end ifdef + +----------------------------------------------------------------------------------- + if method[RETVAL] = 0 then -- it's a GTK proc, may have multiple return values; + c_proc(method[VECTOR],args) + result = repeat(0,length(args)) + for i = 1 to length(args) do + switch params[i] do -- convert arg pointer to value; + case D then result[i] = float64_to_atom(peek({args[i],8})) + case F then result[i] = float32_to_atom(peek({args[i],4})) + case I then result[i] = peek4s(args[i]) + case B then result[i] = peek(args[i]) + case A then result[i] = unpack_gs_str_list(args[i]) + case X then result[i] = unpack_gs_atom_list(args[i]) + case V then result[i] = deallocate_string_pointer_array(args[i]) + case S then if args[i] > 0 then result[i] = peek_string(args[i]) end if + case else result[i] = args[i] + end switch + end for + result = result[2..$] -- don't return handle, just results; + goto "fini" + end if + +-------------------------------------------------- + if method[RETVAL] > 0 then -- it's a GTK func; + result = c_func(method[VECTOR],args) + switch method[RETVAL] do -- convert function result to value; + case A then result = unpack_gs_str_list(result) + case X then result = unpack_gs_atom_list(result) + case V then result = deallocate_string_pointer_array(result) + case S then if result > 0 then result = peek_string(result) else result = 0 end if + case I then + switch method[1] do -- patch for zero-based indexing; + case + "get_active", + "get_text_column", + "get_pixbuf_column", + "get_column", + "get_tooltip_column", + "get_search_column", + "get_current_page", + "get_index", + "get_item_index", + "page_num", + "get_sort_column_id" then result += 1 + end switch + end switch + goto "fini" + end if + +---------------------------------------------------------------------- + if method[RETVAL] <-1 then -- it's a Eu func (negated routine_id); + result = call_func(-method[VECTOR],args) + end if + +label "fini" + + if method[CLASS] != GSList then -- for widgets created 'internally' by GTK + if method[CLASS] != 0 then -- as a result of creating a parent widget; + if not initialized[method[CLASS]] then init(method[CLASS]) end if + if atom(result) then register(result,method[CLASS]) + else for z = 1 to length(result) do + register(result[z],method[CLASS]) -- must be registered; + end for + end if + end if + end if + + ifdef GET then display("\tReturns: []\n",{result}) end ifdef + +return result +end function + +--------------------------------------------------- +public function add(object parent, object child) -- add widgets to container; +--------------------------------------------------- + + ifdef ADD then + display("Add [] []",{parent,child}) + end ifdef + + if atom(child) and child = 0 then + display("Null pointer passed to add()\n") + return 0 + end if + + if class_id(child) = GdkPixbuf then -- issue a warning; + return Warn(,,"Cannot add a pixbuf to a container", + "Create an image from it first,\nthen add the image.",,child) + end if + + if class_id(parent) = GtkBuilder then + load_builder(parent,child) + return 1 + end if + + if string(parent) then -- convert to handle; + parent = pointer(parent) + end if + + if string(child) then -- convert to handle; + child = pointer(child) + end if + + -- Switch below implements an easier-to-remember 'add' syntax + -- as an alias for the various 'set' calls shown. + -- The GTK original is still available, if you wish to use it. + + switch class_id(parent) do + + case GtkComboBoxText, GtkComboBoxEntry then + for i = 1 to length(child) do + set(parent,"append text",child[i]) + end for + + case GtkToolbar then + if atom(child) then + set(parent,"insert",child,-1) + else for i = 1 to length(child) do + add(parent,child[i]) + end for + end if + return child + + case GtkFileChooserDialog then + if atom(child) then + if class_id(child) = GtkFileFilter then + set(parent,"add filter",child) + end if + else for i = 1 to length(child) do + add(parent,child[i]) + end for + end if + + case GtkSizeGroup then + set(parent,"add widgets",child) + return child + + case GtkTextTagTable then + set(parent,"add",child) + return child + + case GtkTreeView then + set(parent,"append columns",child) + return child + + case else + if atom(child) then + gtk_proc("gtk_container_add",{P,P},{parent,child}) + else + for i = 1 to length(child) do + gtk_proc("gtk_container_add",{P,P},{parent,child[i]}) + end for + end if + return child + + end switch +return -1 +end function + +------------------------------------------------------------------------ +public function pack(object parent, object child, + integer expand=0, integer fill=0, integer padding=0) +------------------------------------------------------------------------ +-- pack a child widget or {list} of child widgets into parent container; +-- prepending a negative sign to the child pointer means +--'pack end'. this is an alias which is sometimes useful. +------------------------------------------------------------------------ + + if string(parent) then parent = pointer(parent) end if + if string(child) then child = pointer(child) end if + + if atom(child) then + if child > 0 then + pack_start(parent,child,expand,fill,padding) + else + child = -child + pack_end(parent,child,expand,fill,padding) + end if + else + for i = 1 to length(child) do + pack(parent,child[i],expand,fill,padding) + end for + end if + + return abs(child) +end function + +function valid(object x) +object msg = "Invalid object []" +atom p +if string(x) then + p = pointer(x) + if p = 0 then + display(msg,{x}) + return 0 + else return p + end if +end if +if x = 0 then + display(msg) +end if +return x +end function + +-- following 2 functions provided for compatibility with GTK calls; + +public function pack_start(object parent, object child, + boolean expand=0, boolean fill=0, integer padding=0) + parent = valid(parent) + child = valid(child) + set(parent,"pack start",child,expand,fill,padding) +return child + +end function + +public function pack_end(object parent, object child, + boolean expand=0, boolean fill=0, integer padding=0) + parent = valid(parent) + child = valid(child) + set(parent,"pack end",child,expand,fill,padding) +return child +end function + +---------------------------------- +public procedure show(object x) -- show widget x or a {list} of widgets; +---------------------------------- + if string(x) then x = pointer(x) end if + if atom(x) then + set(x,"show") + else + for i = 1 to length(x) do + show(x[i]) + end for + end if +end procedure + +------------------------------------- +public function show_all(object x) -- show container x and all children; +------------------------------------- + if string(x) then x = pointer(x) end if + if atom(x) then + set(x,"show all") + else + for i = 1 to length(x) do + set(x[i],"show all") + end for + end if +return 1 +end function + +--------------------------------- +public function hide(object x) -- hide a widget or a {list} of widgets; +--------------------------------- + if string(x) then x = pointer(x) end if + if atom(x) then + set(x,"hide") + else + for i = 1 to length(x) do + hide(x[i]) + end for + end if +return 1 +end function + +-------------------------------------- +public procedure hide_all(object x) -- hide container x and any children it contains; +-------------------------------------- + set(x,"hide all") +end procedure + +-------------------------------------- +export function destroy(object ctl) -- destroy a widget or {list} of widgets; +-------------------------------------- + if sequence(ctl) then + for i = 1 to length(ctl) do + destroy(ctl[i]) + end for + else + if ctl > 0 then + set(ctl,"destroy") + deregister(ctl) + end if + end if +return 1 +end function + +-------------------------- +export procedure main() -- start the GTK engine; +-------------------------- + gtk_proc("gtk_main") +end procedure + +without warning {not_reached} + + -------------------------------------------------------------------------- + export function Quit(atom ctl=0, object errcode=0) -- kill the GTK engine; + -------------------------------------------------------------------------- + abort(errcode) + return 1 + end function + export constant main_quit = call_back(routine_id("Quit")) + +with warning {not_reached} + +---------------------------------- +function numeric_test(object x) -- convert numbers passed in key=value format; +---------------------------------- + atom z + if atom(x) then + return x + end if + if string(x) then + if equal("TRUE",x) then return 1 end if + if equal("FALSE",x) then return 0 end if + if equal("YES",x) then return 1 end if + if equal("NO",x) then return 0 end if + if equal("VERTICAL",x) then return 1 end if + if equal("CENTER",x) then return 1 end if + if equal("HORIZONTAL",x) then return 0 end if + + z = to_number(x) + if z != 0 then + ifdef NUM then display("string [] converted to number []",{x,z}) end ifdef + return z + else + ifdef NUM then display("returning string '[]'",{x}) end ifdef + return x + end if + end if + ifdef NUM then display("error []",x) end ifdef + return x +end function + +------------------------------------------------------------------------ +-- Following functions register and initialize class methods +------------------------------------------------------------------------ +-- A class is initialized the first time a widget of that class is created. +-- This means the widget's method vectors are filled in with Eu routine_ids, +-- either direct or generated by define_c_func or define_c_proc as appropriate. + +-- When a subsequent call is made to a widget method, that vector is +-- used by calling c_func, c_proc, or call_func. + +-- If the call is to a method not implemented by the widget, but is +-- instead a method inherited from one of the widget's ancestors, +-- then that ancestor is also initialized if necessary. + +-- This scheme means that program startup isn't delayed as it would be +-- if all 300+ widgets and nearly 4000 methods were to be initialized +-- first, most of which would likely never be used in any given program. + +------------------------------------------------------------------------ +global procedure init(integer class) +------------------------------------------------------------------------ +object name, params, retval + + ifdef INITX then + display("\nInit class:[] []",{class,widget[class][$]}) + display(widget[class]) + end ifdef + + if initialized[class] then return end if + + for method = 3 to length(widget[class])-1 do + + name = sprintf("+%s_%s",{widget[class][NAME],widget[class][method][NAME]}) + + widget[class][method] = pad_tail(widget[class][method],5,0) + params = widget[class][method][PARAMS] + retval = widget[class][method][RETVAL] + + if class = GtkSpinButton then + switch widget[class][method][NAME] do + case "get_increments","get_range" then params[2] = P params[3] = P + case else -- do nothing; + end switch + end if + + if widget[class][method][RETVAL] = 0 then -- it's a GTK proc + widget[class][method][VECTOR] = define_proc(name,params) + goto "init" + end if + + if widget[class][method][RETVAL] > 0 then -- it's a GTK func + widget[class][method][VECTOR] = define_func(name,params,retval) + goto "init" + end if + + if widget[class][method][RETVAL] < -1 then -- it's a Eu func + widget[class][method][VECTOR] = widget[class][method][RETVAL] + end if + + label "init" + + initialized[class] = TRUE + + ifdef INIT then + display("INIT: [].[] RID:[]", + {widget[class][$],widget[class][method][NAME],widget[class][method][VECTOR]}) + end ifdef + + ifdef INIT_ERR then + if widget[class][method][VECTOR] = -1 then -- function is invalid! + display("\tINIT ERROR: [].[] ERR:[]", + {widget[class][$],widget[class][method][NAME],widget[class][method][VECTOR]}) + end if + end ifdef + + end for + +end procedure + +------------------------------------------------------------------------ +-- The registry associates a control's handle with its class, +-- so that future calls to set or get that control's properties +-- can go directly to the correct set of functions stored in the +-- large widget{} structure. +------------------------------------------------------------------------ +export object registry = {} + +---------------------------------------------------------------------------------------- +global function register(atom handle, integer class, object name="-nil-", object v=math:MINF) +---------------------------------------------------------------------------------------- +integer x = find(handle,vslice(registry,1)) + + if x > 0 then -- handle already exists in the registry, + ifdef REG_DUP then -- debug + display("Note: [] handle [] already registered to [] []", + {widget[class][$],handle,registry[x][3],name}) + end ifdef + -- update it in case handle has been recycled. + registry[x] = {handle,class,widget[class][$],name,v} + return 1 + end if + + -- else, add the widget to the registry; + registry = append(registry,{handle,class,widget[class][$],name,v}) + + -- initialize class if this is the first use of that class; + if not initialized[class] then init(class) end if + + ifdef REG then -- debug + printf(1,text:format("Registry + [3:20]\thandle: [1:10>]\tname: [4]\tvalue: [5]\n",registry[$])) + end ifdef + +return 1 +end function + +------------------------------------ +procedure deregister(atom handle) -- when object no longer used; +------------------------------------ +integer x = find(handle,vslice(registry,1)) +if x > 0 then + ifdef REG then + printf(1,text:format("Registry - [3:16]\thandle: [1:12>]\t",registry[x])) + if string(registry[x][4]) then printf(1,"name: %s",{registry[x][4]}) end if + puts(1,"\n") + end ifdef + registry = remove(registry,x) +end if +end procedure + + +----------------------------------------- +public function class_id(object handle) -- returns an integer widget class; +----------------------------------------- + if string(handle) then handle = pointer(handle) end if + return vlookup(handle,registry,1,2,-1) +end function + +------------------------------------------- +public function class_name(object handle) -- returns class_name for a given handle; +------------------------------------------- + if string(handle) then handle = pointer(handle) end if + return vlookup(handle,registry,1,3,"!") +end function + +------------------------------------------ +public function object_name(atom handle) -- returns name of object, or -nil-; +------------------------------------------ + return vlookup(handle,registry,1,4,"!") +end function + +--------------------------------------- +public function pointer(object name) -- returns handle to object or null, +--------------------------------------- + return vlookup(name,registry,4,1,0) +end function + +------------------------------------------------------------------------ +function lookup_method(integer class, sequence prop) +------------------------------------------------------------------------ +-- Finds the method to set or get a property for a given class, +-- if not found, ancestors of that class are checked until the method +-- is located. + + if class = -1 then return 0 end if + + ifdef LOOK then display("Look []->[]",{widget[class][$],prop}) end ifdef + + object method = lookup(prop,vslice(widget[class],NAME),widget[class],0) + + ifdef LOOKUP then display(widget[class][$]) end ifdef + + if atom(method) then -- try sans the set_ or get_ prefix; + method = lookup(prop[5..$],vslice(widget[class],NAME),widget[class],0) + end if + + if sequence(method) then -- method was found in this class, we're done! + return method + end if + + object ancestor -- if not found, need to look for method in ancestors; + for i = 1 to length(widget[class][PARAMS]) do + ancestor = widget[class][PARAMS][i] + if ancestor = 0 then return 0 end if + + if not initialized[ancestor] then + init(ancestor) + end if + + ifdef LOOKUP then -- debug; + display("trying ancestor: []",{widget[ancestor][$]}) + end ifdef + + method = lookup(prop,vslice(widget[ancestor],NAME),widget[ancestor],0) + if atom(method) then + method = lookup(prop[5..$],vslice(widget[ancestor],NAME),widget[ancestor],0) + end if + + if sequence(method) then -- found it! + ifdef LOOKUP then display("\t []",{method[1]}) end ifdef + return method + end if + + end for + + return -1 -- method not found (not implemented) + +end function + +----------------------------------------------------------------------------- +public function connect(object ctl, object sig, object fn=0, object data=0, + atom closure=0, integer flags=0) +----------------------------------------------------------------------------- +-- tells control to call your Eu function, sending data along for the ride, +-- whenever that control gets the specified signal. + + integer result = -1 + atom rid = 0 + + if atom(fn) and fn = 0 then -- no point in registering null functions! + return 0 + end if + + if string(ctl) then + ctl = pointer(ctl) -- convert name to pointer; + end if + + if sequence(ctl) then + for i = 1 to length(ctl) do + connect(ctl[i],sig,fn,data,closure,flags) + end for + return 1 + end if + + if string(fn) then -- if interpreted, we can call functions by name if in scope; + ifdef COMPILE then -- do compile test if requested; + display("Connecting [] [] Signal '[]' Function [] Data []", + {class_name(ctl),ctl,sig,fn,data}) + if not equal("Quit",fn) then + printf(1,"\n\tCaution: function %s will not link when compiled!\n\t********\n",{fn}) + end if + end ifdef + + rid = routine_id(fn) + if rid > 0 then -- named function is in scope; + fn = call_back(rid) -- so obtain a callback; + else + printf(1,"\n\tError: function %s is not in scope\n\t****** (make it global or link via routine_id)\n",{fn}) + Warn(,,sprintf("function %s is not in scope",{fn}),"make it global or link via routine_id") + end if + end if + + sig = join(split(sig,' '),'-') -- normalize signal names; + sig = allocate_string(sig) -- convert to string pointer; + + if integer(data) then -- can be attached directly; + result = gtk_func("g_signal_connect_data",{P,S,P,P,I,I},{ctl,sig,fn,data,closure,flags}) + free(sig) + return result + end if + + if atom(data) then + data = prepend({data},"ATOM") -- must be serialized and unpacked later; + data = allocate_wstring(serialize(data)+1) + result = gtk_func("g_signal_connect_data",{P,S,P,P,I,I},{ctl,sig,fn,data,closure,flags}) + free(sig) + return result + end if + + if string(data) then + data = prepend({data},"STR") -- must be serialized and unpacked later; + data = allocate_wstring(serialize(data)+1) + result = gtk_func("g_signal_connect_data",{P,S,P,P,I,I},{ctl,sig,fn,data,closure,flags}) + free(sig) + return result + end if + + if sequence(data) then + data = prepend(data,"SEQ")-- must be serialized and unpacked later; + data = allocate_wstring(serialize(data)+1) + result = gtk_func("g_signal_connect_data",{P,S,P,P,I,I},{ctl,sig,fn,data,closure,flags}) + free(sig) + return result + end if + +end function + +------------------------------------------------------- +export procedure disconnect(atom ctl, integer sigid) -- disconnect a signal from ctl; +------------------------------------------------------- + gtk_proc("g_signal_handler_disconnect",{P,I},{ctl,sigid}) +end procedure + +-------------------------------------- +export function unpack(object data) -- retrieves data passed in a control's data space; +-------------------------------------- +if atom(data) and data = 0 then return 0 end if +object result = deserialize(peek_wstring(data)-1) + switch result[1][1] do + case "ATOM","STR","INT" then return result[1][2] + case "SEQ" then return result[1][2..$] + case else return result + end switch +end function + +------------------------------------------------------- +export function deallocate_string_pointer_array(atom x) +------------------------------------------------------- +integer i = 0 +object result = {} + while peek4u(x+i) > 0 do + result = append(result,peek_string(peek4u(x+i))) + i += 8 + end while + return result +end function + +------------------------------------------------------------------------ +-- following 3 'decode_x' functions are for debugging purposes, +-- they make displays more readable; +------------------------------------------------------------------------ +function decode_args(object method, object args) +------------------------------------------------------------------------ + for i = 1 to length(method[PARAMS]) do + switch method[PARAMS][i] do + case S then + if atom(args[i]) and args[i] > 0 then + args[i] = peek_string(args[i]) + if length(args[i]) > 40 then + args[i] = args[i][1..40] & "..." + end if + args[i] = args[i] + end if + case else -- do not convert + end switch + end for + return args +end function + +constant ptype = {0,P,I,D,F,S,B,A} +constant pname = {{},"None","Ptr ","Int ","Dbl ","Flt ","Str ","Bool ","Array "} + +------------------------------------------------------------------------ +function decode_params(object params) +------------------------------------------------------------------------ + return transmute(params,ptype,pname) +end function + +------------------------------------------------------------------------ +function decode_method(sequence title, integer class, object method) +------------------------------------------------------------------------ +object z = {} +integer n + z = prepend(method,widget[class][$]) + z = prepend(z,title) + z[4] = decode_params(method[PARAMS]) + while length(z) < 5 do + z = append(z,0) + end while + if length(method) >= RETVAL then + n = find(method[RETVAL],ptype) + z[5] = pname[n+1] + end if + return text:format("[]\n\tCall: []->[]\n\tParams: []\n\tReturn type: []\n\tVector: []",z) +end function + +--------------------------------------------------------- +public function to_sequence(atom glist, integer fmt=0) -- mostly internal use; +--------------------------------------------------------- +-- convert glist pointer back to a Euphoria sequence; +-- results are returned in a choice of formats; + integer len = gtk_func("g_list_length",{P},{glist}) + object s = {} + atom data + for i = 0 to len-1 do + data = gtk_func("g_slist_nth_data",{P,I},{glist,i}) + switch fmt do + case 0 then s = append(s,peek_string(data)) + case 1 then s = append(s,data) + case 2 then s = append(s,gtk_str_func("gtk_tree_path_to_string",{P},{data})) + case 3 then s = append(s,to_number(gtk_str_func("gtk_tree_path_to_string",{P},{data}))) + case else Warn(,,"Converting glist to_sequence", + "invalid format supplied,\nvalues are 0 to 3") + end switch + end for + return s +end function + +----------------------------------------------------------------------------------------- +-- METHOD DECLARATIONS: +----------------------------------------------------------------------------------------- + +sequence initialized = repeat(0,500) +-- This is a set of flags which are set to 1 when a given widget has +-- been initialized. This prevents having to initialize a widget's +-- methods repeatedly. Size is larger than GtkFinal to allow 'plugin' +-- widgets to be added at runtime. + +export sequence widget = repeat(0,GtkFinal) +-- This structure holds prototypes for each GTK method call, +-- organized by widget. When each widget is initialized, +-- vectors are added pointing to the routine_ids needed +-- to call the GTK functions that implement each method. + +-- The widgets below need not be in any specific order. +-- Widget names must also be added to the list in GtkEnums + +sequence stock_list = create(GtkStockList) -- a fake object; + +widget[GObject] = {"g_object", +{0}, + {"new",{I,S,S,I},P}, + {"set",{P,S,P,P}}, + {"set_property",{P,S,P},-routine_id("set_property")}, + {"get_property",{P,S},-routine_id("get_property")}, + {"get_data",{P,P},S}, + {"set_data",{P,S,S}}, + {"set_data_full",{P,S,S,P}}, + {"steal_data",{P,S},P}, + {"signal",{P,P,P,P,P,P},-routine_id("connect")}, + {"connect",{P,P,P,P,P,P},-routine_id("connect")}, +"GObject"} + + constant + fn1 = define_proc("g_object_get",{P,P,P,P}), + doubles = {"angle","climb-rate","fraction","max-value","min-value", + "scale","value","pulse-step","scale","size-points","text-xalign", + "text-yalign","xalign","yalign"} + + constant prop = allocate_string("property") + + function set_property(object handle, object a, object b) + -------------------------------------------------------------- + object params = {P,P,P,P} + if find(a,doubles) then params = {P,P,D,P} end if + if string(a) then a = allocate_string(a,1) end if + if string(b) then b = allocate_string(b,1) end if + gtk_proc("g_object_set",params,{handle,a,b,0}) + return 1 + end function + + function get_property(atom handle, object p) + -------------------------------------------------- + atom x = allocate(8,1) + if string(p) then p = allocate_string(p,1) end if + c_proc(fn1,{handle,p,x,0}) + object result = peek4u(x) + return result + end function + +widget[GtkAdjustment] = {"gtk_adjustment", +{GObject}, + {"new",{D,D,D,D,D,D},P}, + {"set_value",{P,D}}, + {"get_value",{P},D}, + {"clamp_page",{P,D,D}}, + {"value_changed",{P}}, + {"configure",{P,D,D,D,D,D,D}}, + {"get_lower",{P},D}, + {"get_page_increment",{P},D}, + {"get_step_increment",{P},D}, + {"get_minimum_increment",{P},D}, + {"set_upper",{P,D}}, + {"get_upper",{P},D}, + {"set_page_increment",{P,D}}, + {"set_page_size",{P,D}}, + {"set_step_increment",{P,D}}, + {"set_upper",{P,D}}, +"GtkAdjustment"} + +widget[GtkWidgetPath] = {"gtk_widget_path", +{GObject}, + {"new",{},P}, + {"append_type",{P,I},I}, + {"append_with_siblings",{P,P,I},I}, + {"append_for_widget",{P,P},I}, + {"copy",{P},P,0,GtkWidgetPath}, + {"get_object_type",{P},I}, + {"has_parent",{P,I},B}, + {"is_type",{P,I},B}, + {"iter_add_class",{P,I,S}}, + {"iter_add_region",{P,I,S,I}}, + {"iter_clear_classes",{P,I}}, + {"iter_clear_regions",{P,I}}, + {"iter_get_name",{P,I},S}, + {"iter_get_object_type",{P,I},I}, + {"iter_get_siblings",{P,I},P,0,GtkWidgetPath}, + {"iter_get_sibling_index",{P,I},I}, + {"iter_has_class",{P,I,S},B}, + {"iter_has_name",{P,I,S},B}, + {"iter_has_qclass",{P,I,P},B}, + {"iter_has_qname",{P,I,P},B}, + {"iter_has_qregion",{P,I,P,I},B}, + {"iter_has_region",{P,I,S,I},B}, + {"iter_list_classes",{P,I},A,0,GSList}, + {"iter_list_regions",{P,I},A,0,GSList}, + {"iter_remove_class",{P,I,S}}, + {"iter_remove_region",{P,I,S}}, + {"iter_set_name",{P,I,S}}, + {"iter_set_object_type",{P,I,I}}, + {"iter_set_object_name",{P,I,S}}, -- 3.20 + {"iter_get_object_name",{P,I},S}, -- 3.20 + {"iter_get_state",{P,I},I}, -- 3.14 + {"iter_set_state",{P,I,I}}, -- 3.14 + {"length",{P},I}, + {"prepend_type",{P,I}}, + {"to_string",{P},S}, + {"get_object_name",{P,I},S}, -- 3.20 + {"set_object_name",{P,I,S}}, -- 3.20 +"GtkWidgetPath"} + +widget[GtkStyle] = {"gtk_style", +{GObject}, +"GtkStyle"} + +widget[GAction] = {"g_action", +{GObject}, + {"name_is_valid",{S},B}, + {"get_name",{P},S}, + {"get_parameter_type",{P},I}, + {"get_state_type",{P},I}, + {"get_state_hint",{P},I}, + {"get_enabled",{P},B}, + {"get_state",{P},I}, + {"change_state",{P,I}}, + {"activate",{P,I}}, + {"parse_detailed_name",{P,S,P,P},B}, + {"print_detailed_name",{P,I},S}, +"GAction"} + +widget[GSimpleAction] = {"g_simple_action", +{GObject}, + {"new",{S,I},P}, + {"new_stateful",{S,I,I}}, + {"set_enabled",{P,B}}, + {"set_state",{P,I}}, + {"set_state_hint",{P,I}}, +"GSimpleAction"} + +widget[GPropertyAction] = {"g_property_action", +{GObject}, + {"new",{S,P,S},P}, +"GPropertyAction"} + +widget[GActionGroup] = {"g_action_group", +{GSimpleAction,GObject}, +"GActionGroup"} + +widget[GSimpleActionGroup] = {"g_simple_action_group", +{GApplication,GActionGroup,GObject}, + {"new",{}}, +"GSimpleActionGroup"} + +widget[GActionMap] = {"g_action_map", +{0}, + {"lookup_action",{P,S},P}, + {"add_action_entries",{P,P,I,P}}, + {"add_action",{P,P}}, + {"remove_action",{P,S}}, +"GActionMap"} + +widget[GtkWidgetClass] = {"gtk_widget_class", +{GtkWidget,GtkBuildable,GObject}, + {"set_template",{P,P}}, -- 3.10 + {"set_template_from_resource",{P,S}}, -- 3.10 + {"get_template_child",{P,I,S},P,0,GObject}, + {"bind_template_child_full",{P,S,B,I}}, + {"bind_template_callback_full",{P,S,P}}, + {"set_connect_func",{P,P,P,P}}, + {"set_css_name",{P,S}}, -- 3.20 + {"get_css_name",{P},S}, -- 3.20 +"GtkWidgetClass"} + +widget[GtkWidget] = {"gtk_widget", +{GtkBuildable,GObject}, + +-- Aliases to fix awkward overrides; ordinarily you will use one of these 4, + {"set_font",{P,S},-routine_id("widget_set_font")}, + {"set_color",{P,P},-routine_id("widget_set_foreground")}, + {"set_foreground",{P,P},-routine_id("widget_set_foreground")}, + {"set_background",{P,P},-routine_id("widget_set_background")}, + +-- Only use following versions when you need to change the color +-- of a control in a state other than normal. Rarely used since themes +-- often disallow the use of stateful colors; + {"override_background_color",{P,I,P},-routine_id("widget_override_background_color")}, + {"override_color",{P,I,P},-routine_id("widget_override_color")}, +---- + {"new",{I},P}, + {"destroy",{P}}, + {"in_destruction",{P},B}, + {"destroyed",{P},B}, + {"unparent",{P}}, + {"show",{P}}, + {"show_now",{P}}, + {"hide",{P}}, + {"show_all",{P}}, + {"map",{P}}, + {"unmap",{P}}, + {"realize",{P}}, + {"unrealize",{P}}, + {"draw",{P}}, + {"queue_draw",{P}}, + {"queue_resize",{P}}, + {"queue_resize_no_redraw",{P}}, + {"get_frame_clock",{P},P,0,GdkFrameClock}, + {"add_tick_callback",{P,P,P,P},I}, + {"remove_tick_callback",{P,I}}, -- GTK 3.8+ + {"set_size_request",{P,P,P},-routine_id("widget_set_size_request")}, + {"size_allocate",{P,P}}, + {"size_allocate_with_baseline",{P,P,I}}, + {"add_accelerator",{P,S,P,I,I}}, + {"remove_accelerator",{P,P,I,I},B}, + {"set_accel_path",{P,S,P}}, + {"can_activate_accel",{P,I},B}, + {"event",{P,P},B}, + {"activate",{P},B}, + {"reparent",{P,P}}, -- deprecated 3.14 + {"intersect",{P,P,P},B}, + {"is_focus",{P},B}, + {"grab_focus",{P},B}, + {"grab_default",{P}}, + {"set_name",{P,S},-routine_id("widget_set_name")}, + {"get_name",{P},S}, + {"set_sensitive",{P,B}}, + {"get_sensitive",{P},B}, + {"set_parent",{P,P}}, + {"get_parent",{P},P}, + {"set_parent_window",{P,P}}, + {"get_parent_window",{P},P}, + {"set_events",{P,I}}, + {"get_events",{P},I}, + {"add_events",{P,I}}, + {"set_device_events",{P,P,I}}, + {"get_device_events",{P,P},I}, + {"add_device_events",{P,P,I}}, + {"set_device_enabled",{P,P,B}}, + {"get_device_enabled",{P,P},B}, + {"get_toplevel",{P},P}, + {"get_ancestor",{P,I},P}, + {"is_ancestor",{P,P},B}, + {"set_visual",{P,P}}, + {"get_visual",{P},P,0,GdkVisual}, + {"get_pointer",{P,I,I}}, -- deprecated 3.4 + {"translate_coordinates",{P,P,I,I,I,I},B}, + {"hide_on_delete",{P},B}, + {"set_direction",{P,I}}, + {"get_direction",{P},I}, + {"set_default_direction",{I}}, + {"get_default_direction",{},I}, + {"shape_combine_region",{P,P}}, + {"create_pango_context",{P},P}, + {"get_pango_context",{P},P,0,PangoContext}, + {"create_pango_layout",{P,S},P}, + {"queue_draw_area",{P,I,I,I,I}}, + {"queue_draw_region",{P,P}}, + {"set_app_paintable",{P,B}}, + {"set_double_buffered",{P,B}}, -- deprecated 3.14 + {"set_redraw_on_allocate",{P,B}}, + {"mnemonic_activate",{P,B},B}, + {"send_expose",{P,P},I}, + {"send_focus_change",{P,P},B}, + {"get_accessible",{P},P}, + {"child_focus",{P,I},B}, + {"child_notify",{P,S}}, + {"freeze_child_notify",{P}}, + {"get_child_visible",{P},B}, + {"get_parent",{P},P}, + {"get_path",{P},P,0,GtkWidgetPath}, + {"get_settings",{P},P,0,GtkSettings}, + {"get_clipboard",{P,I},P,0,GtkClipboard}, + {"get_display",{P},P,0,GdkDisplay}, + {"get_root_window",{P},P,0,GdkWindow}, -- deprecated 3.12 + {"get_screen",{P},P,0,GdkScreen}, + {"has_screen",{P},B}, + {"get_size_request",{P,I,I}}, + {"set_child_visible",{P,B}}, + {"thaw_child_notify",{P}}, + {"set_no_show_all",{P,B}}, + {"get_no_show_all",{P},B}, + {"add_mnemonic_label",{P,P}}, + {"remove_mnemonic_label",{P,P}}, + {"is_composited",{P},B}, + {"set_tooltip_markup",{P,S}}, + {"get_tooltip_markup",{P},S}, + {"set_tooltip_text",{P,S}}, + {"get_tooltip_text",{P},S}, + {"set_tooltip_window",{P,P}}, + {"get_tooltip_window",{P},P,0,GtkWindow}, + {"set_has_tooltip",{P,B}}, + {"get_has_tooltip",{P},B}, + {"trigger_tooltip_query",{P}}, + {"get_window",{P},P,0,GdkWindow}, + {"register_window",{P,P}}, -- GTK 3.8+ + {"unregister_window",{P,P}}, -- GTK 3.8+ + {"get_allocated_width",{P},I}, + {"get_allocated_height",{P},I}, + {"get_allocation",{P},-routine_id("widget_get_allocation")}, + {"set_allocation",{P,P}}, + {"get_allocated_baseline",{P},I}, + {"get_app_paintable",{P},B}, + {"set_can_default",{P,B}}, + {"get_can_default",{P},B}, + {"get_can_focus",{P},B}, + {"get_double_buffered",{P},B}, -- deprecated 3.14 + {"get_has_window",{P},B}, + {"get_sensitive",{P},B}, + {"get_visible",{P},B}, + {"is_visible",{P},B}, -- GTK 3.8+ + {"set_visible",{P,B}}, + {"set_state_flags",{P,I,B}}, + {"unset_state_flags",{P,I}}, + {"get_state_flags",{P},I}, + {"has_default",{P},B}, + {"has_focus",{P},B}, + {"has_visible_focus",{P},B}, + {"has_grab",{P},B}, + {"is_drawable",{P},B}, + {"is_toplevel",{P},B}, + {"set_window",{P,P}}, + {"set_receives_default",{P,B}}, + {"get_receives_default",{P},B}, + {"set_support_multidevice",{P,B}}, + {"get_support_multidevice",{P},B}, + {"set_realized",{P,B}}, + {"get_realized",{P},B}, + {"set_mapped",{P,B}}, + {"get_mapped",{P},B}, + {"device_is_shadowed",{P,P},B}, + {"get_modifier_mask",{P,I},I}, + {"insert_action_group",{P,S,P}}, + {"get_opacity",{P},D}, -- GTK 3.8+ + {"set_opacity",{P,D}}, -- GTK 3.8+ + {"get_path",{P},P,0,GtkWidgetPath}, + {"get_style",{P},P,0,GtkStyle}, + {"get_style_context",{P},P,0,GtkStyleContext}, + {"reset_style",{P}}, + {"get_preferred_height",{P,I,I}}, + {"get_preferred_width",{P,I,I}}, + {"get_preferred_height_for_width",{P,I,I,I}}, + {"get_preferred_width_for_height",{P,I,I,I}}, + {"get_preferred_height_and_baseline_for_width",{P,I,I,I,I,I}}, + {"get_request_mode",{P},I}, + {"get_preferred_size",{P,P,P}}, + {"get_preferred_size_and_baseline",{P,P,I,I}}, + {"get_halign",{P},I}, + {"set_halign",{P,I}}, + {"get_valign",{P},I}, + {"set_valign",{P,I}}, + {"set_margin_left",{P,I}}, -- deprecated 3.12 + {"get_margin_left",{P},I}, -- deprecated 3.12 + {"set_margin_right",{P,I}}, -- deprecated 3.12 + {"get_margin_right",{P},I}, -- deprecated 3.12 + {"get_margin_end",{P},I}, -- new 3.12 + {"set_margin_end",{P,I}}, -- new 3.12 + {"get_margin_start",{P},I}, -- new 3.12 + {"set_margin_start",{P,I}}, -- new 3.12 + {"set_margin_top",{P,I}}, + {"get_margin_top",{P},I}, + {"set_margin_bottom",{P,I}}, + {"get_margin_bottom",{P},I}, + {"get_hexpand",{P},B}, + {"set_hexpand",{P,B}}, + {"get_hexpand_set",{P},B}, + {"set_hexpand_set",{P,B}}, + {"get_vexpand",{P},B}, + {"set_vexpand",{P,B}}, + {"get_vexpand_set",{P},B}, + {"set_vexpand_set",{P,B}}, + {"queue_compute_expand",{P}}, + {"compute_expand",{P,I},B}, + {"init_template",{P}}, + {"get_automated_child",{P,I,S},P,0,GObject}, + {"get_clip",{P,P}}, -- 3.14 + {"set_clip",{P},P}, -- 3.14 + {"get_action_group",{P,S},P,0,GActionGroup}, -- 3.16 + {"list_action_prefixes",{P},A}, -- 3.16 + {"get_font_map",{P},P,0,PangoFontMap}, -- 3.18 + {"set_font_map",{P,P}}, -- 3.18 + {"get_font_options",{P},P}, -- 3.18 + {"set_font_options",{P,P}}, -- 3.18 + {"signal",{P,P,P,P,P,P},-routine_id("connect")}, + {"list_accel_closures",{P},X,0,GList}, + {"get_font",{P},-routine_id("widget_get_font")}, + {"get_allocated_size",{P,P,I}}, -- 3.20 + {"get_focus_on_click",{P},B}, -- 3.20 + {"set_focus_on_click",{P,B}}, -- 3.20 +"GtkWidget"} + + function widget_set_size_request(atom ctl, object x=0, object y=0) + if string(x) then + x = split(x,'x') + y = to_number(x[2]) + x = to_number(x[1]) + end if + gtk_func("gtk_widget_set_size_request",{P,I,I},{ctl,x,y}) + return 1 + end function + + function widget_get_font(atom x) + object layout = get(x,"layout") + object context = gtk_func("pango_layout_get_context",{P},{layout}) + object descr = gtk_func("pango_context_get_font_description",{P},{context}) + return gtk_str_func("pango_font_description_to_string",{P},{descr}) + end function + + function widget_get_allocation(atom obj) + atom al = allocate(32,1) + gtk_func("gtk_widget_get_allocation",{P,P},{obj,al}) + return peek4u({al,4}) + end function + + function widget_set_name(atom ctl, object name) + gtk_proc("gtk_widget_set_name",{P,P},{ctl,name}) + integer x = find(ctl,vslice(registry,1)) + if x > 0 then + registry[x][4] = peek_string(name) + end if + return 1 + end function + + -- This allows specifying a font name, e.g. "Courier bold 12" as a string, + -- instead of a pango font description object; + function widget_set_font(atom x, object fnt) + fnt = gtk_func("pango_font_description_from_string",{P},{fnt}) + gtk_proc("gtk_widget_override_font",{P,P},{x,fnt}) + return 1 + end function + + -- The functions below handle color conversion to/from rgba, + -- as well as supplying easier-to-use method names for setting background + -- and foreground. These methods are only used to set the colors of a widget + -- in the NORMAL state, whereas if you want to set the colors in + -- some other state, such as mouse-over, etc, you use the original + -- set(widget,"override background",STATE,"color") syntax. + + function widget_set_foreground(atom x, object c) -- alias 'color' + return widget_override_color(x,0,c) + end function + + function widget_set_background(atom x, object c) -- alias 'background' + return widget_override_background_color(x,0,c) + end function + + function widget_override_color(atom x, integer state=0, object c) + if atom(c) then + c = text:format("#[:06X]",c) + end if + gtk_proc("gtk_widget_override_color",{P,I,P},{x,state,to_rgba(c)}) + return 1 + end function + + function widget_override_background_color(atom x, integer state=0, object c) + if atom(c) then + c = text:format("#[:06X]",c) + end if + gtk_proc("gtk_widget_override_background_color",{P,I,P},{x,state,to_rgba(c)}) + return 1 + end function + +widget[GtkContainer] = {"gtk_container", +{GtkWidget,GtkBuildable,GObject}, + {"add",{P,P}}, + {"remove",{P,P}}, + {"check_resize",{P}}, + {"foreach",{P,P,P}}, + {"get_children",{P},X}, + {"get_path_for_child",{P,P},S}, + {"set_focus_child",{P,P}}, + {"get_focus_child",{P},P}, + {"set_focus_vadjustment",{P,P}}, + {"get_focus_vadjustment",{P},P,0,GtkAdjustment}, + {"set_focus_hadjustment",{P,P}}, + {"get_focus_hadjustment",{P},P,0,GtkAdjustment}, + {"child_type",{P},I}, + {"forall",{P,P,P}}, + {"set_border",{P,I},-routine_id("set_border")}, + {"set_border_width",{P,I}}, + {"get_border_width",{P},I}, + {"propagate_draw",{P,P,P}}, + {"child_notify",{P,P,S}}, + {"child_notify_by_pspec",{P,P,P}}, -- 3.18 + {"class_install_child_properties",{P,I,P}}, -- 3.18 +"GtkContainer"} + + function set_border(atom cont, integer w) -- alias for 'border_width'; + gtk_proc("gtk_container_set_border_width",{P,I},{cont,w}) + return 1 + end function + +widget[GdkKeymap] = {"gdk_keymap", +{GObject}, + {"new",{},-routine_id("new_keymap")}, + {"get_default",{},-routine_id("new_keymap")}, + {"get_for_display",{P},P,0,GdkKeymap}, + {"get_capslock_state",{P},B}, + {"get_numlock_state",{P},B}, + {"get_modifier_state",{P},I}, + {"get_direction",{P},I}, + {"have_bidi_layouts",{P},B}, + {"lookup_key",{P,P},I}, + {"get_scroll_lock_state",{P,B}}, +"GdkKeymap"} + + function new_keymap(atom disp=0) + if disp=0 then + return gtk_func("gdk_keymap_get_default") + else + return gtk_func("gdk_keymap_get_for_display",{P},P) + end if + end function + +widget[GtkBin] = {"gtk_bin", +{GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"get_child",{P},P}, +"GtkBin"} + +widget[GtkBox] = {"gtk_box", +{GtkContainer,GtkWidget,GtkOrientable,GtkBuildable,GObject}, + {"new",{I,I},P}, + {"pack_start",{P,P,B,B,I}}, + {"pack_end",{P,P,B,B,I}}, + {"set_homogeneous",{P,B}}, + {"get_homogeneous",{P},B}, + {"set_spacing",{P,I}}, + {"get_spacing",{P},I}, + {"reorder_child",{P,P,I}}, + {"query_child_packing",{P,P,B,B,I,I}}, + {"set_child_packing",{P,P,B,B,I,I}}, + {"set_baseline_position",{P,I}}, + {"get_baseline_position",{P},I}, + {"get_center_widget",{P},P,0,GtkWidget}, -- 3.12 + {"set_center_widget",{P,P}}, -- 3.12 +"GtkBox"} + +widget[GtkButtonBox] = {"gtk_button_box", +{GtkBox,GtkContainer,GtkWidget,GtkBuilder,GtkOrientable,GObject}, + {"new",{I},P}, + {"set_layout",{P,I}}, + {"get_layout",{P},I}, + {"set_child_secondary",{P,P,B}}, + {"get_child_secondary",{P,P},B}, + {"set_child_non_homogeneous",{P,P,B}}, + {"get_child_non_homogeneous",{P,P},P}, +"GtkButtonBox"} + +widget[GtkWindowGroup] = {"gtk_window_group", +{GObject}, + {"new",{},P}, + {"add_window",{P,P}}, + {"remove_window",{P,P}}, + {"list_windows",{P},X,0,GList}, + {"get_current_grab",{P},P,0,GtkWidget}, + {"get_current_grab_device",{P,P},P,0,GtkWidget}, +"GtkWindowGroup"} + +-- shortcuts are new in 3.20, inadequate documentation means there's no way to test yet; +widget[GtkShortcutsWindow] = {"gtk_shortcuts_window", +{GtkWindow,GtkBin,GtkContainer,GtkWidget,GObject}, +-- properties: +-- section-name +-- view-name +"GtkShortcutsWindow"} + +widget[GtkShortcutsSection] = {"gtk_shortcuts_section", +{GtkBox,GtkContainer,GtkWidget,GObject}, +-- properties; +-- max-height +-- section-name +-- title +-- view-name +"GtkShortcutsSection"} + +widget[GtkShortcutsGroup] = {"gtk_shortcuts_group", +{GtkBox,GtkContainer,GtkWidget,GObject}, +-- properties; +-- accel-size-group +-- height +-- title +-- title-size-group +-- view +"GtkShortcutsGroup"} + +widget[GtkShortcutsShortcut] = {"gtk_shortcuts_shortcut", +{GtkBox,GtkContainer,GtkWidget,GObject}, +-- properties; +-- accel-size-group +-- accelerator +-- title +-- title-size-group +"GtkShortcutsShortcut"} + +widget[GtkShortcutsGesture] = {"gtk_shortcuts_gesture", +{GtkBox,GtkContainer,GtkWidget,GObject}, +-- properties; +-- icon +-- icon-size-group +-- subtitle +-- title +-- title-size-group +"GtkShortcutsGesture"} + +widget[GtkWindow] = {"gtk_window", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{I},P}, + {"set_title",{P,S}}, + {"get_title",{P},S}, + {"set_resizable",{P,B}}, + {"get_resizable",{P},B}, + {"get_size",{P,I,I}}, + {"set_size",{P,P},-routine_id("win_set_size")}, -- alias; + {"set_position",{P,P},-routine_id("win_set_pos")}, -- alias + --{"set_position",{P,I}}, -- alias above allows 2 forms of 'position'; + {"set_default",{P,P}}, + {"set_default_size",{P,I,I}}, + {"get_default_size",{P,I,I}}, + {"get_position",{P,I,I}}, + {"add_accel_group",{P,P}}, + {"remove_accel_group",{P,P}}, + {"activate_focus",{P},B}, + {"activate_default",{P},B}, + {"set_modal",{P,B}}, + {"get_modal",{P},B}, + {"set_default_geometry",{P,I,I}}, + {"set_geometry_hints",{P,P,P,I}}, + {"set_gravity",{P,I}}, + {"get_gravity",{P},I}, + {"set_transient_for",{P,P}}, + {"get_transient_for",{P},P,0,GtkWindow}, + {"set_attached_to",{P,P}}, + {"get_attached_to",{P},P,0,GtkWidget}, + {"set_destroy_with_parent",{P,B}}, + {"get_destroy_with_parent",{P},B}, + {"set_hide_titlebar_when_maximized",{P,B}}, + {"get_hide_titlebar_when_maximized",{P},B}, + {"set_screen",{P,P}}, + {"get_screen",{P},P,0,GdkScreen}, + {"is_active",{P},B}, + {"list_toplevels",{P},X,0,GSList}, + {"has_toplevel_focus",{P},B}, + {"add_mnemonic",{P,I,P}}, + {"remove_mnemonic",{P,I,P}}, + {"set_mnemonics_visible",{P,B}}, + {"get_mnemonics_visible",{P},B}, + {"mnemonic_activate",{P,I,I},B}, + {"activate_key",{P,P},B}, + {"propagate_key_event",{P,P},B}, + {"get_focus",{P},P,0,GtkWidget}, + {"set_focus",{P,P}}, + {"set_focus_visible",{P,B}}, + {"get_focus_visible",{P},B}, + {"get_default_widget",{P},P,0,GtkWidget}, + {"set_default",{P,P}}, + {"present",{P}}, + {"present_with_time",{P,P}}, + {"iconify",{P}}, + {"deiconify",{P}}, + {"stick",{P}}, + {"unstick",{P}}, + {"maximize",{P}}, + {"unmaximize",{P}}, + {"fullscreen",{P}}, + {"unfullscreen",{P}}, + {"set_keep_above",{P,B}}, + {"set_keep_below",{P,B}}, + {"begin_resize_drag",{P,I,I,I,I,I}}, + {"begin_move_drag",{P,I,I,I,I}}, + {"set_decorated",{P,B}}, + {"get_decorated",{P},B}, + {"set_deletable",{P,B}}, + {"get_deletable",{P},B}, + {"set_mnemonic_modifier",{P,I}}, + {"get_mnemonic_modifier",{P},I}, + {"set_type_hint",{P,I}}, + {"get_type_hint",{P},I}, + {"set_skip_taskbar_hint",{P,B}}, + {"get_skip_taskbar_hint",{P},B}, + {"set_skip_pager_hint",{P,B}}, + {"get_skip_pager_hint",{P},B}, + {"set_urgency_hint",{P,B}}, + {"get_urgency_hint",{P},B}, + {"set_accept_focus",{P,B}}, + {"get_accept_focus",{P},B}, + {"set_focus_on_map",{P,B}}, + {"get_focus_on_map",{P},B}, + {"set_startup_id",{P,S}}, + {"set_role",{P,S}}, + {"get_role",{P},S}, + {"get_icon",{P},P,0,GdkPixbuf}, + {"get_icon_name",{P},S}, + {"get_icon_list",{P},P,0,GList}, + {"get_default_icon_list",{P},X,0,GList}, + {"get_group",{P},P,0,GtkWindowGroup}, + {"has_group",{P},B}, + {"get_window_type",{P},I}, + {"move",{P,I,I}}, + {"parse_geometry",{P,S},B}, + {"resize",{P,I,I}}, + {"resize_to_geometry",{P,I,I}}, + {"set_has_resize_grip",{P,B}}, + {"get_has_resize_grip",{P},B}, + {"resize_grip_is_visible",{P},B}, -- deprecated 3.14 + {"get_resize_grip_area",{P,P},B}, -- deprecated 3.14 + {"set_titlebar",{P,P}}, -- 3.10 + {"get_titlebar",{P},P,0,GtkWidget}, -- 3.16 + {"set_icon",{P,P},-routine_id("win_set_icon")}, + {"restore",{P},-routine_id("win_restore")}, -- see below; + {"close",{P}}, -- 3.10 + {"set_opacity",{P,D}}, + {"is_maximized",{P},B}, -- 3.12 + {"set_interactive_debugging",{B}}, -- 3.14 + {"fullscreen_on_monitor",{P,P,I}}, -- 3.18 + {"set_application",{P,P}}, + {"get_application",{P},P,0,GtkApplication}, + {"set_cursor",{P,P},-routine_id("win_set_cursor")}, +"GtkWindow"} + + function win_set_size(atom win, object size) + -- allow for WxH format to be passed; + if match("x",size) then size = split(size,'x') end if + if match("{",size) = 1 and match("}",size) = length(size) then + size = size[2..$-1] + size = split(size,',') + end if + set(win,"default_size",size[1],size[2]) + return 1 + end function + + function win_set_pos(atom win, object pos) + if integer(pos) then -- only one integer passed; + gtk_proc("gtk_window_set_position",{P,I},{win,pos}) -- use original call; + return 1 + end if + -- else position is WxH format, so call move instead; + if match("x",pos) then pos = split(pos,'x') end if + if match("{",pos) = 1 and match("}",pos) = length(pos) then + pos = pos[2..$-1] + pos = split(pos,',') + end if + set(win,"move",pos[1],pos[2]) + return 1 + end function + + function win_set_cursor(atom win, object cursor) + atom gdkwin = get(win,"window") + cursor = create(GdkCursor,cursor) + set(gdkwin,"cursor",cursor) + return cursor + end function + + -- this replaces a handy but deprecated GTK function which + -- restores a window to its original size after being resized + -- to fit larger contents; + function win_restore(atom win) + set(win,"hide") + set(win,"unrealize") + gtk_proc("gtk_window_set_position",{P,I},{win,1}) + set(win,"show") + return 1 + end function + + -- manages the creation of window icon from a variety of source formats. + -- this makes life much easier for the programmer. + function win_set_icon(object win, object icon) + object path + + if string(icon) then + path = locate_file(icon)--display(path) + if file_type(path) = 1 then + gtk_proc("gtk_window_set_icon_from_file",{P,P}, + {win,allocate_string(path,1)}) + return 1 + else + gtk_proc("gtk_window_set_icon_name",{P,P}, + {win,allocate_string(icon,1)}) + return 1 + end if + end if + + if sequence(icon) then + gtk_proc("gtk_window_set_icon",{P,P},{win,xpm_to_pixbuf(icon)}) + end if + + if atom(icon) then + if class_id(icon) = GtkImage then + icon = get(icon,"pixbuf") + end if + if class_id(icon) = GdkPixbuf then + gtk_proc("gtk_window_set_icon",{P,P},{win,icon}) + end if + return 1 + end if + + return 0 + end function + +widget[GtkMisc] = {"gtk_misc", -- deprecated 3.14 +{GtkWidget,GtkBuildable,GObject}, + {"set_alignment",{P,F,F}}, + {"get_alignment",{P,F,F}}, + {"set_padding",{P,I,I}}, + {"get_padding",{P,I,I}}, +"GtkMisc"} + +widget[GtkLabel] = {"gtk_label", +{GtkMisc,GtkWidget,GtkBuildable,GObject}, + {"new",{S},P}, + {"new_with_mnemonic",{S},P,0,GtkLabel}, + {"set_text",{P,S}}, + {"set_value",{P,D},-routine_id("lbl_set_value")}, -- convenience, converts # to readable form; + {"get_text",{P},S}, + {"set_markup",{P,S}}, + {"set_text_with_mnemonic",{P,S}}, + {"set_markup_with_mnemonic",{P,S}}, + {"set_pattern",{P,S}}, + {"set_justify",{P,I}}, + {"get_justify",{P},I}, + {"get_attributes",{P},P,0,PangoAttrList}, + {"set_ellipsize",{P,I}}, + {"get_ellipsize",{P},I}, + {"set_width_chars",{P,I}}, + {"get_width_chars",{P},I}, + {"set_max_width_chars",{P,I}}, + {"get_max_width_chars",{P},I}, + {"set_line_wrap",{P,B}}, + {"get_line_wrap",{P},B}, + {"set_line_wrap_mode",{P,I}}, + {"get_layout_offsets",{P,I,I}}, + {"get_mnemonic_keyval",{P},I}, + {"set_selectable",{P,B}}, + {"get_selectable",{P},B}, + {"select_region",{P,I,I}}, + {"get_selection_bounds",{P,I,I},B}, + {"set_mnemonic_widget",{P,P}}, + {"get_mnemonic_widget",{P},P,0,GtkWidget}, + {"get_label",{P},S}, + {"get_layout",{P},P,0,PangoLayout}, + {"get_line_wrap_mode",{P},I}, + {"set_use_markup",{P,B}}, + {"get_use_markup",{P},B}, + {"set_use_underline",{P,B}}, + {"get_use_underline",{P},B}, + {"set_single_line_mode",{P,B}}, + {"get_single_line_mode",{P},B}, + {"set_angle",{P,D}}, + {"get_current_uri",{P},S}, + {"set_track_visited_links",{P,B}}, + {"get_track_visited_links",{P},B}, + {"set_lines",{P,I}}, -- 3.10 + {"get_lines",{P},I}, -- 3.10 + {"get_xalign",{P},F}, -- 3.16 + {"get_yalign",{P},F}, -- 3.16 + {"set_xalign",{P,F}}, -- 3.16 + {"set_yalign",{P,F}}, -- 3.16 +"GtkLabel"} + + function lbl_set_value(atom lbl, atom val) -- provided for convenience; + set(lbl,"text",sprintf("%2.2f",val)) -- convert atom to string for label; + return 1 + end function + +widget[GtkImage] = {"gtk_image", +{GtkMisc,GtkWidget,GtkBuildable,GObject}, + {"new",{P,I,I,I},-routine_id("newImage")}, + {"set_image",{P,P,P},-routine_id("setImage")}, -- not a gtk func + {"set_from_file",{P,S}}, + {"set_from_pixbuf",{P,P}}, + {"set_from_icon_name",{P,S,I}}, + {"set_from_animation",{P,P}}, + {"set_from_gicon",{P,P,I}}, + {"set_from_resource",{P,S}}, + {"set_from_surface",{P,P}}, -- 3.10 + {"clear",{P}}, + {"set_pixel_size",{P,I}}, + {"get_pixel_size",{P},I}, + {"get_pixbuf",{P},P,0,GdkPixbuf}, -- doesn't work! + {"get_animation",{P},P,0,GdkPixbufAnimation}, + {"get_storage_type",{P},I}, + {"get_icon_name",{P},-routine_id("img_get_icon_name")}, +"GtkImage"} + +----------------------------------------------------- + -- create an image from a variety of source formats + ---------------------------------------------------- + function newImage(object icon=0, integer size=6, integer w=0, integer h=0) + + if atom(icon) then + if icon = 0 then + return gtk_func("gtk_image_new") -- just a blank image requested; + else + switch class_id(icon) do + case GdkPixbuf then + icon = gtk_func("gtk_image_new_from_pixbuf",{P},{icon}) + case GIcon then + icon = gtk_func("gtk_image_new_from_gicon",{P,I},{icon,size}) + case CairoSurface_t then + icon = gtk_func("gtk_image_new_from_surface",{P},{icon}) + case else -- do nothing + end switch + end if + return icon + end if + + object theme, icon_info + + if string(icon) then + + if begins("gtk-",icon) then -- from stock (deprecated) + if size = 0 then size = 6 end if + return gtk_func("gtk_image_new_from_icon_name",{P,I}, + {allocate_string(icon,1),size}) -- size is a GTK_ICON_SIZE_ enum; + end if + + if file_exists(canonical_path(icon)) then -- from file + icon = canonical_path(icon) + if h = 0 and w = 0 then -- return at natural size; + return gtk_func("gtk_image_new_from_file",{P}, + {allocate_string(icon,1)}) + else + icon = newPixbuf(icon,w,h,size) -- resize it; + return gtk_func("gtk_image_new_from_pixbuf",{P},{icon}) + end if + end if + + if file_exists(locate_file(icon)) then -- from file + icon = locate_file(icon) + if h = 0 and w = 0 then -- return at natural size; + return gtk_func("gtk_image_new_from_file",{P}, + {allocate_string(icon,1)}) + else + icon = newPixbuf(icon,w,h,size) -- resize it; + return gtk_func("gtk_image_new_from_pixbuf",{P},{icon}) + end if + end if + + if size < 7 then + icon = gtk_func("gtk_image_new_from_icon_name",{P,I},{icon,size}) + else + theme = create(GtkIconTheme) -- get current theme; + icon_info = get(theme,"lookup icon",icon,size) -- get icon details; + icon = get(icon_info,"load icon") -- load selected icon; + return create(GtkImage,icon) + end if + + end if + + return icon + end function + + ----------------------------------------------------------------------------------- + function setImage(atom img, object icon, integer size=0) + ----------------------------------------------------------------------------------- + + if size = 0 then + size = get(img,"pixel size") + end if + + if string(icon) then + + if file_exists(canonical_path(icon)) then -- from file + set(img,"from file",icon) + set(img,"pixel size",size) + return img + end if + + if begins("gtk-",icon) then -- from stock (deprecated) + set(img,"from stock",icon) + return img + end if + + set(img,"from icon name",icon) + return img + + end if + return img + end function + + function img_get_icon_name(atom img) + atom name = allocate(8), size = allocate(8) + atom fn = define_proc("gtk_image_get_icon_name",{P,P,P}) + c_proc(fn,{img,name,size}) + if name > 0 then + return {peek_string(peek4u(name)),peek4u(size)} + else return -1 + end if + end function + +widget[GdkCursor] = {"gdk_cursor", +{GObject}, + {"new",{P,P,P},-routine_id("newCursor")}, + {"get_display",{P},P,0,GdkDisplay}, + {"get_image",{P},P,0,GdkPixbuf}, + {"get_surface",{P,D,D},P,0,CairoSurface_t}, + {"get_cursor_type",{P},I}, +"GdkCursor"} + + -- manages cursor creation from a variety of sources + function newCursor(object a, object b=0, integer c=0) + atom disp = gtk_func("gdk_display_get_default") + + if string(a) then + return gtk_func("gdk_cursor_new_from_name",{P,P},{disp,allocate_string(a,1)}) + end if + + if class_id(a) = GdkPixbuf then + return gtk_func("gdk_cursor_new_from_pixbuf",{P,P,I,I},{disp,a,b,c}) + end if + + if class_id(a) = CairoSurface_t then + return gtk_func("gdk_cursor_new_from_surface",{P,P,D,D},{disp,a,b,c}) + end if + + if integer(a) then + return gtk_func("gdk_cursor_new_for_display",{P,I},{disp,a}) + end if + + end function + +widget[GdkWindow] = {"gdk_window", +{GObject}, + {"new",{P,P,I},P}, + {"set_title",{P,S}}, + {"destroy",{P}}, + {"get_width",{P},I}, + {"get_height",{P},I}, + {"get_position",{P,I,I}}, + {"get_device_position",{P,P,P,P,P},P,0,GdkWindow}, + {"get_device_position_double",{P,P,P,P,P},P,0,GdkWindow}, + {"get_origin",{P,I,I}}, + {"get_parent",{P},P,0,GdkWindow}, + {"get_toplevel",{P},P,0,GdkWindow}, + {"get_children",{P},A,0,GList}, + {"get_children_with_user_data",{P,P},A,0,GList}, + {"peek_children",{P},P,0,GList}, + {"get_events",{P},I}, + {"set_events",{P,I}}, + {"set_icon_name",{P,S}}, + {"set_transient_for",{P,P}}, + {"get_root_origin",{P,I,I}}, + {"get_root_coords",{P,I,I,P,P}}, + {"get_frame_extents",{P,P}}, + {"set_modal_hint",{P,B}}, + {"get_modal_hint",{P},B}, + {"set_type_hint",{P,I}}, + {"get_type_hint",{P},I}, + {"get_window_type",{P},I}, + {"get_display",{P},P,0,GdkDisplay}, + {"get_screen",{P},P,0,GdkScreen}, + {"get_visual",{P},P,0,GdkVisual}, + {"show",{P}}, + {"show_unraised",{P}}, + {"hide",{P}}, + {"is_destroyed",{P},B}, + {"is_visible",{P},B}, + {"is_viewable",{P},B}, + {"is_input_only",{P},B}, + {"is_shaped",{P},B}, + {"set_composited",{P,B}}, -- deprecated 3.16 + {"get_composited",{P},B}, -- deprecated 3.16 + {"set_opacity",{P,D}}, + {"set_cursor",{P,P}}, + {"get_cursor",{P},P}, + {"get_state",{P},I}, + {"withdraw",{P}}, + {"iconify",{P}}, + {"deiconify",{P}}, + {"stick",{P}}, + {"unstick",{P}}, + {"maximize",{P}}, + {"unmaximize",{P}}, + {"fullscreen",{P}}, + {"unfullscreen",{P}}, + {"set_fullscreen_mode",{P,I}}, + {"get_fullscreen_mode",{P},I}, + {"set_opacity",{P,D}}, + {"scroll",{P,I,I}}, + {"move_region",{P,P,I,I}}, + {"shape_combine_region",{P,P,I,I}}, + {"set_child_shapes",{P}}, + {"merge_child_shapes",{P}}, + {"input_shape_combine_region",{P,P,I,I}}, + {"set_child_input_shapes",{P}}, + {"merge_child_input_shapes",{P}}, + {"get_geometry",{P,I,I,I,I}}, + {"set_background_rgba",{P,P}}, + {"set_fullscreen_mode",{P,I}}, + {"get_fullscreen_mode",{P},I}, + {"get_scale_factor",{P},I}, + {"set_opaque_region",{P,P}}, + {"get_effective_parent",{P},P,0,GdkWindow}, + {"get_effective_toplevel",{P},P,0,GdkWindow}, + {"beep",{}}, + {"focus",{P,I}}, + {"restack",{P,P,B}}, + {"raise",{P}}, + {"lower",{P}}, + {"set_keep_above",{P,B}}, + {"set_keep_below",{P,B}}, + {"reparent",{P,P,I,I}}, + {"ensure_native",{P},B}, + {"has_native",{P},B}, + {"register_dnd",{P}}, + {"move",{P,I,I}}, + {"scroll",{P,I,I}}, + {"resize",{P,I,I}}, + {"move_resize",{P,I,I,I,I}}, + {"move_region",{P,P,I,I}}, + {"begin_resize_drag",{P,I,I,I,I,I}}, + {"begin_resize_drag_for_device",{P,I,P,I,I,I,I}}, + {"begin_move_drag",{P,I,I,I,I}}, + {"begin_move_drag_for_device",{P,P,I,I,I,I}}, + {"show_window_menu",{P,P},B}, + {"create_gl_context",{P,P},P,0,GdkGLContext}, -- 3.16 + {"mark_paint_from_clip",{P,P}}, -- 3.16 + {"get_clip_region",{P},P,0,CairoRegion_t}, + {"begin_paint_rect",{P,P}}, + {"begin_paint_region",{P,P}}, + {"end_paint",{P}}, + {"set_opaque_region",{P,P}}, + {"get_visible_region",{P},P,0,CairoRegion_t}, + {"set_invalidate_handler",{P,P}}, + {"invalidate_rect",{P,P,B}}, + {"invalidate_region",{P,P,B}}, + {"invalidate_maybe_recurse",{P,P,P,P}}, + {"get_update_area",{P},P,0,CairoRegion_t}, + {"freeze_updates",{P}}, + {"thaw_updates",{P}}, + {"process_all_updates",{P}}, + {"process_updates",{P,B}}, + {"get_frame_clock",{P},P,0,GdkFrameClock}, + {"set_user_data",{P,P}}, + {"get_user_data",{P,P}}, + {"set_override_redirect",{P,B}}, + {"set_accept_focus",{P,B}}, + {"get_accept_focus",{P},B}, + {"set_focus_on_map",{P,B}}, + {"get_focus_on_map",{P},B}, + {"add_filter",{P,P,P}}, + {"remove_filter",{P,P,P}}, + {"set_background_pattern",{P,P}}, + {"get_background_pattern",{P},P,0,CairoPattern_t}, + {"set_geometry_hints",{P,P,I}}, + {"set_functions",{P,I}}, + {"get_pass_through",{P},B}, + {"set_pass_through",{P,B}}, + {"create_gl_context",{P,P},P,0,GdkGLContext}, + {"mark_paint_from_clip",{P,P}}, +"GdkWindow"} + +widget[GdkPixbuf] = {"gdk_pixbuf", +{GObject}, + {"new",{P,I,I,I},-routine_id("newPixbuf")}, + {"get_from_window",{P,I,I,I,I},P,0,GdkPixbuf}, + {"get_from_surface",{P,I,I,I,I},P,0,GdkPixbuf}, + {"flip",{P,I},P,0,GdkPixbuf}, + {"rotate_simple",{P,I},P,0,GdkPixbuf}, + {"scale_simple",{P,I,I,I},P,0,GdkPixbuf}, + {"add_alpha",{P,B,I,I,I},P,0,GdkPixbuf}, + {"copy_area",{P,I,I,I,I,P,I,I}}, + {"apply_embedded_orientation",{P},P,0,GdkPixbuf}, + {"fill",{P,P}}, + {"get_n_channels",{P},I}, + {"get_has_alpha",{P},B}, + {"get_colorspace",{P},I}, + {"get_bits_per_sample",{P},I}, + {"get_pixels_with_length",{P,I},P}, + {"get_width",{P},I}, + {"get_height",{P},I}, + {"get_size",{P},-routine_id("getPixbufSize")}, + {"get_rowstride",{P},I}, + {"get_byte_length",{P},I}, + {"get_option",{P,S},S}, + {"saturate_and_pixelate",{P,P,F,B},0,GdkPixbuf}, + {"composite_color_simple",{}},-- Cannot implement, use gtk_func if required. + {"save",{P,P,P,P},-routine_id("pb_save")}, + {"get_file_info",{P,S},-routine_id("pb_get_file_info")}, + {"get_format",{P,S},-routine_id("pb_get_format")}, +"GdkPixbuf"} + + -- creates a pixbuf from a variety of sources + + function newPixbuf(object name, integer w=0, integer h=0, atom ratio=0) + ----------------------------------------------------------------------- + atom err = allocate(32,1) err = 0 + object path=allocate_string("gtk-missing-image",1) + object pix = 0 + + if string(name) then + + path = canonical_path(locate_file(name)) + + if file_exists(path) then + ifdef PIXBUF then + display("PIXBUF from file: []",{abbreviate_path(path)},0) + end ifdef + path = allocate_string(path,1) + goto "build" + end if + + if has_icon(name) then + path = icon_info(name) + ifdef PIXBUF then + display("PIXBUF from icon: []",{filename(path[3])},0) + end ifdef + if string(path[3]) then + path = allocate_string(path[3],1) + else + path = "!" + end if + goto "build" + else return 0 + end if + + else + ifdef PIXBUF then + display("PIXBUF from atom: [] []",{name,peek_string(name)},0) + end ifdef + end if -- string name; + + label "build" + + if h = 0 and w = 0 then -- return at original size; + ifdef PIXBUF then display("Orig size") end ifdef + pix = gtk_func("gdk_pixbuf_new_from_file",{P,P},{path,err}) + + else -- if one or other dimension given, scale it, otherwise size it; + if w > 0 and h = 0 then h = -1 end if + if w = 0 and h > 0 then w = -1 end if + ifdef PIXBUF then display("\t SCALE []x[] []",{w,h,ratio}) end ifdef + pix = gtk_func("gdk_pixbuf_new_from_file_at_scale",{P,I,I,B,P},{path,w,h,ratio,err}) + end if + + ifdef PIXBUF_ERR then + if pix = 0 then + display("CAUTION: cannot create pixbuf from []",{peek_string(path)}) + end if + end ifdef + + return pix + end function + + -- save a pixbuf in various formats based on file extension(.png, .jpg, etc) + function pb_save(atom handle, object fn, object ft, object params = 0) + if string(fn) then fn = allocate_string(fn,1) end if + if string(ft) then ft = allocate_string(ft,1) end if + if string(params) then + params = split(params,'=') + for i = 1 to length(params) do + params[i] = allocate_string(params[i],1) + end for + end if + + atom err = allocate(8,1) err = 0 + if atom(params) then + return gtk_func("gdk_pixbuf_save",{P,P,P,P,P},{handle,fn,ft,err,0}) + else + return gtk_func("gdk_pixbuf_save",{P,P,P,P,P,P,P},{handle,fn,ft,err,params[1],params[2],0}) + end if + end function + + function getPixbufSize(object pb) + return {get(pb,"width"),get(pb,"height")} + end function + + function pb_get_file_info(atom pb, object name) + atom w = allocate(8,1), h = allocate(8,1) + object fmt = gtk_func("gdk_pixbuf_get_file_info",{P,P,P}, + {name,w,h}) + return {fmt,peek4u(w),peek4u(h)} + end function + + function pb_get_format(atom pb, object name) + object fmt = pb_get_file_info(pb,name) + return fmt + end function + + export function pixbuf_formats() + object fmts = gtk_func("gdk_pixbuf_get_formats") + register(fmts,GSList) + return unpack_gs_str_list(fmts) + end function + +widget[GdkPixbufFormat] = {"gdk_pixbuf_format", +{GObject}, + {"get_name",{P},S}, + {"get_description",{P},S}, + {"get_mime_types",{P},A}, + -- {"extensions",{P},P}, -- error + {"is_writable",{P},B}, + {"is_scalable",{P},B}, + {"is_disabled",{P},B}, + {"set_disabled",{P,B}}, + {"get_license",{P},S}, +"GdkPixbufFormat"} + +widget[GtkDialog] = {"gtk_dialog", +{GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"run",{P},I}, + {"get_action_area",{P},P,0,GtkBox}, -- deprecated 3.12 + {"get_content_area",{P},P,0,GtkBox}, + {"response",{P,I}}, + {"add_button",{P,S,I},P,0,GtkButton}, + {"add_action_widget",{P,P,I}}, + {"set_default_response",{P,I}}, + {"set_response_sensitive",{P,I,B}}, + {"get_response_for_widget",{P,P},I}, + {"get_widget_for_response",{P,I},P,0,GtkWidget}, + {"get_header_bar",{P},P,0,GtkContainer},-- GTK 3.12 +"GtkDialog"} + +widget[GtkMessageDialog] = {"gtk_message_dialog", +{GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{P,I,I,I,S,S},P}, + {"new_with_markup",{P,I,I,I,S,S},P}, + {"set_markup",{P,S}}, + {"set_image",{P,P}}, -- deprecated 3.12 + {"get_image",{P},P,0,GtkImage}, -- deprecated 3.12 + {"format_secondary_text",{P,S,S}}, + {"format_secondary_markup",{P,S,S}}, + {"get_message_area",{P},P,0,GtkContainer}, +"GtkMessageDialog"} + +widget[GtkSeparator] = {"gtk_separator", +{GtkWidget,GObject,GtkBuildable,GtkOrientable}, + {"new",{I},P}, +"GtkSeparator"} + +widget[GtkEditable] = {"gtk_editable", +{0}, + {"select_region",{P,I,I}}, + {"get_selection_bounds",{P,I,I}}, + {"insert_text",{P,S,I,I}}, + {"delete_text",{P,I,I}}, + {"get_chars",{P,I,I},S}, + {"cut_clipboard",{P}}, + {"copy_clipboard",{P}}, + {"paste_clipboard",{P}}, + {"delete_selection",{P}}, + {"set_position",{P,I}}, + {"get_position",{P},I}, + {"set_editable",{P,B}}, + {"get_editable",{P},B}, +"GtkEditable"} + +widget[GtkTextIter] = {"gtk_text_iter", +{GObject}, + {"get_buffer",{P},P,0,GtkTextBuffer}, + {"copy",{P},P,0,GtkTextIter}, + {"free",{P}}, + {"get_offset",{P},I}, + {"get_line",{P},I}, + {"get_line_offset",{P},I}, + {"get_line_index",{P},I}, + {"get_visible_line_index",{P},I}, + {"get_visible_line_offset",{P},I}, + {"get_char",{P},I}, + {"get_slice",{P,P},S}, + {"get_text",{P,P},S}, + {"get_visible_slice",{P,P},S}, + {"get_visible_text",{P,P},S}, + {"get_pixbuf",{P},P,0,GdkPixbuf}, + {"get_marks",{P},X,0,GSList}, + {"get_toggled_tags",{P,B},X,0,GSList}, + {"get_child_anchor",{P},P,0,GtkTextChildAnchor}, + {"begins_tag",{P,P},B}, + {"ends_tag",{P,P},B}, + {"toggles_tag",{P,P},B}, + {"has_tag",{P,P},B}, + {"get_tags",{P},X,0,GSList}, + {"editable",{P,B},B}, + {"can_insert",{P,B},B}, + {"starts_word",{P},B}, + {"ends_word",{P},B}, + {"inside_word",{P},B}, + {"starts_line",{P},B}, + {"ends_line",{P},B}, + {"starts_sentence",{P},B}, + {"ends_sentence",{P},B}, + {"inside_sentence",{P},B}, + {"is_cursor_position",{P},B}, + {"get_chars_in_line",{P},I}, + {"get_bytes_in_line",{P},I}, + {"get_attributes",{P,P},B}, + {"get_language",{P},P,0,PangoLanguage}, + {"is_end",{P},B}, + {"is_start",{P},B}, + {"forward_char",{P},B}, + {"backward_char",{P},B}, + {"forward_chars",{P,I},B}, + {"backward_chars",{P,I},B}, + {"forward_line",{P},B}, + {"backward_line",{P},B}, + {"forward_lines",{P,I},B}, + {"backward_lines",{P,I},B}, + {"forward_word_ends",{P,I},B}, + {"backward_word_starts",{P,I},B}, + {"forward_word_ends",{P},B}, + {"backward_word_start",{P},B}, + {"forward_cursor_position",{P},B}, + {"backward_cursor_position",{P},B}, + {"forward_cursor_positions",{P,I},B}, + {"backward_cursor_positions",{P,I},B}, + {"backward_sentence_start",{P},B}, + {"backward_sentence_starts",{P,I},B}, + {"forward_sentence_end",{P},B}, + {"forward_sentence_ends",{P,I},B}, + {"forward_visible_word_ends",{P,I},B}, + {"backward_visible_word_starts",{P,I},B}, + {"forward_visible_word_end",{P},B}, + {"backward_visible_word_start",{P},B}, + {"forward_visible_cursor_position",{P},B}, + {"backward_visible_cursor_position",{P},B}, + {"forward_visible_cursor_positions",{P,I},B}, + {"backward_visible_cursor_positions",{P,I},B}, + {"forward_visible_line",{P},B}, + {"backward_visible_line",{P},B}, + {"forward_visible_lines",{P,I},B}, + {"backward_visible_lines",{P,I},B}, + {"set_offset",{P,I}}, + {"set_line",{P,I}}, + {"set_line_offset",{P,I}}, + {"set_line_index",{P,I}}, + {"set_visible_line_index",{P,I}}, + {"set_visible_line_offset",{P,I}}, + {"forward_to_end",{P}}, + {"forward_to_line_end",{P},B}, + {"forward_to_tag_toggle",{P,P},B}, + {"backward_to_tag_toggle",{P,P},B}, + {"forward_find_char",{P,P,P,P},B}, + {"backward_find_char",{P,P,P,P},B}, + {"forward_search",{P,S,I,P,P,P},B}, + {"backward_search",{P,S,I,P,P,P},B}, + {"equal",{P,P},B}, + {"compare",{P,P},I}, + {"in_range",{P,P,P},B}, + {"order",{P,P}}, + {"starts_tag",{P,P},B}, -- 3.20 +"GtkTextIter"} + +widget[GtkEntry] = {"gtk_entry", +{GtkWidget,GtkEditable,GtkCellEditable,GtkBuildable,GObject}, + {"new",{},P}, + {"get_buffer",{P},P,0,GtkEntryBuffer}, + {"set_buffer",{P,P}}, + {"set_text",{P,S}}, + {"set_value",{P,D},-routine_id("entry_set_value")}, -- not GTK, a convenience func; + {"get_text",{P},S}, + {"get_value",{P},-routine_id("entry_get_value")}, -- not GTK, a convenience func; + {"get_text_length",{P},I}, + {"get_text_area",{P,P}}, + {"set_visibility",{P,B}}, + {"get_visibility",{P},B}, + {"set_invisible_char",{P,I}}, + {"get_invisible_char",{P},I}, + {"unset_invisible_char",{P}}, + {"set_max_length",{P,I}}, + {"get_max_length",{P},I}, + {"set_activates_default",{P,B}}, + {"get_activates_default",{P},B}, + {"set_has_frame",{P,B}}, + {"get_has_frame",{P},B}, + {"set_width_chars",{P,I}}, + {"get_width_chars",{P},I}, + {"set_alignment",{P,F}}, + {"get_alignment",{P},F}, + {"set_placeholder_text",{P,S}}, -- GTK 3.2+ + {"get_placeholder_text",{P},S}, -- GTK 3.2+ + {"set_overwrite_mode",{P,B}}, + {"get_overwrite_mode",{P},B}, + {"get_layout",{P},P,0,PangoLayout}, + {"get_layout_offsets",{P,I,I}}, + {"set_completion",{P,P}}, + {"get_completion",{P},P,0,GtkEntryCompletion}, + {"set_progress_fraction",{P,D}}, + {"set_progress_pulse_step",{P,D}}, + {"progress_pulse",{P}}, + {"set_icon_from_stock",{P,I,S}}, -- deprecated 3.10 + {"set_icon_from_pixbuf",{P,I,P}}, + {"set_icon_from_icon_name",{P,I,S}}, + {"set_icon_from_gicon",{P,I,P}}, + {"get_icon_storage_type",{P,I},I}, + {"get_icon_pixbuf",{P,I},P,0,GdkPixbuf}, + {"get_icon_name",{P,I},S}, + {"get_icon_area",{P,I,I}}, + {"get_icon_gicon",{P,I},P,0,GIcon}, + {"set_icon_activatable",{P,I,B}}, + {"set_icon_sensitive",{P,I,B}}, + {"get_icon_at_pos",{P,I,I},I}, + {"set_icon_tooltip_text",{P,I,S}}, + {"get_icon_tooltip_text",{P,I},S}, + {"set_icon_tooltip_markup",{P,I,S}}, + {"get_icon_tooltip_markup",{P,I},S}, + {"set_tabs",{P,P}}, -- 3.10 + {"get_tabs",{P},P,0,PangoTabArray}, -- 3.10 + {"get_max_width_chars",{P},I}, -- 3.12 + {"set_max_width_chars",{P,I}}, -- 3.12 + {"im_context_filter_keypress",{P,I},B}, + {"grab_focus_without_selecting",{P}}, --3.16 +"GtkEntry"} + + function entry_get_value(atom x) -- retrieve input text as a number; + object txt = get(x,"text") + return to_number(txt) + end function + + function entry_set_value(atom x, atom v) -- convert number to text equivalent; + if integer(v) then + set(x,"text",sprintf("%d",v)) + else + set(x,"text",sprintf("%2.2f",v)) + end if + return 1 + end function + +widget[GtkSpinButton] = {"gtk_spin_button", +{GtkEntry,GtkWidget,GtkEditable,GtkCellEditable,GtkOrientable,GtkBuildable,GObject}, + {"set_adjustment",{P,P}}, + {"get_adjustment",{P},P,0,GtkAdjustment}, + {"set_digits",{P,I}}, + {"get_digits",{P},I}, + {"set_range",{P,D,D}}, + {"get_range",{P,D,D}}, + {"set_value",{P,D}}, + {"get_value",{P},-routine_id("getSpinVal")}, + {"get_value_as_int",{P},I}, + {"set_update_policy",{P,I}}, + {"set_numeric",{P,B}}, + {"get_numeric",{P},B}, + {"set_wrap",{P,B}}, + {"get_wrap",{P},B}, + {"spin",{P,I,D}}, + {"update",{P}}, + {"get_increments",{P,D,D}}, + {"set_snap_to_ticks",{P,B}}, + {"get_snap_to_ticks",{P},B}, + {"configure",{P,P,D,I}}, + {"new",{D,D,D},-routine_id("newSpinButton")}, +"GtkSpinButton"} + + -- create a spin button from an ajustment object or from a range of values + + function newSpinButton(atom a=0, atom b=0, atom c=0) + ---------------------------------------------------- + atom sb = 0 + if a+b+c = 0 then a = create(GtkAdjustment,0,0,100,1) end if + if class_id(a) = GtkAdjustment then + sb = gtk_func("gtk_spin_button_new",{P,D,I},{a,b,c}) + else + sb = gtk_func("gtk_spin_button_new_with_range",{D,D,D},{a,b,c}) + end if + return sb + end function + + function getSpinVal(atom spin) + ------------------------------ + object range = get(spin,"range") + atom fn = define_func("gtk_spin_button_get_value",{P},D) + atom val = c_func(fn,{spin}) + val = math:ensure_in_range(val,range) + return val + end function + +widget[GtkOrientable] = {"gtk_orientable", +{GObject}, + {"set_orientation",{P,I}}, + {"get_orientation",{P},I}, +"GtkOrientable"} + +widget[GtkRange] = {"gtk_range", +{GtkWidget,GtkOrientable,GtkBuildable,GObject}, + {"set_fill_level",{P,D}}, + {"get_fill_level",{P},D}, + {"set_restrict_to_fill_level",{P,B}}, + {"get_restrict_to_fill_level",{P},B}, + {"set_show_fill_level",{P,B}}, + {"get_show_fill_level",{P},B}, + {"set_adjustment",{P,P}}, + {"get_adjustment",{P},P}, + {"set_inverted",{P,B}}, + {"get_inverted",{P},B}, + {"set_value",{P,D}}, + {"get_value",{P},D}, + {"set_increments",{P,D,D}}, + {"set_range",{P,D,D}}, + {"set_round_digits",{P,I}}, + {"get_round_digits",{P},I}, + {"set_lower_stepper_sensitivity",{P,I}}, + {"get_lower_stepper_sensitivity",{P},I}, + {"set_upper_stepper_sensitivity",{P,I}}, + {"get_upper_stepper_sensitivity",{P},I}, + {"set_flippable",{P,B}}, + {"get_flippable",{P},B}, + {"set_min_slider_size",{P,I}}, + {"get_min_slider_size",{P},I}, + {"get_slider_range",{P,I,I}}, + {"set_slider_size_fixed",{P,B}}, + {"get_slider_size_fixed",{P},B}, +"GtkRange"} + +widget[GtkScale] = {"gtk_scale", +{GtkRange,GtkWidget,GtkOrientable,GtkBuildable,GObject}, + {"set_digits",{P,I}}, + {"get_digits",{P},I}, + {"set_draw_value",{P,B}}, + {"get_draw_value",{P},B}, + {"set_has_origin",{P,B}}, + {"get_has_origin",{P},B}, + {"set_value_pos",{P,I}}, + {"get_value_pos",{P},I}, + {"get_layout",{P},P,0,PangoLayout}, + {"get_layout_offsets",{P,I,I}}, + {"add_mark",{P,D,I,S}}, + {"clear_marks",{P}}, + {"new",{P,P,P,P},-routine_id("newScale")}, +"GtkScale"} + + -- create scale from range or adjustment; + function newScale(integer orient, atom min=0, atom max=0, atom step=0) + if min+max+step = 0 then + return gtk_func("gtk_scale_new",{I,P},{orient,0}) + end if + if class_id(min) = GtkAdjustment then + return gtk_func("gtk_scale_new",{I,P},{orient,min}) + else + return gtk_func("gtk_scale_new_with_range",{I,D,D,D},{orient,min,max,step}) + end if + end function + +widget[GTimeout] = {"g_timeout", +{0}, + {"new",{I,P,P},-routine_id("newTimeout")}, + {"add",{I,P,P},-routine_id("newTimeout")}, +"GTimeout"} + + function newTimeout(integer ms, atom fn, atom data) + return gtk_func("g_timeout_add",{I,P,P},{ms,fn,data}) + end function + +widget[GIdle] = {"g_idle", +{0}, + {"new",{P,P},-routine_id("newIdle")}, + {"add",{P,P},-routine_id("newIdle")}, +"GIdle"} + + function newIdle(atom fn, atom data) + return gtk_func("g_idle_add",{P,P},{fn,data}) + end function + +widget[GNotification] = {"g_notification", +{0}, + {"new",{S},P}, + {"set_title",{P,S}}, + {"set_body",{P,S}}, + {"set_icon",{P,P}}, + --{"set_priority",{P,I}}, error + {"set_default_action",{P,S}}, + {"add_button",{P,S,S}}, + {"add_button_with_target_value",{P,S,S,I}}, + {"set_default_action_and_target_value",{P,S,I}}, +"GNotification"} + +widget[GApplication] = {"g_application", +{0}, + {"new",{S,I},P}, + {"get_id",{P},S}, + {"set_id",{P,S}}, + {"id_is_valid",{P,S},B}, + {"get_inactivity_timeout",{P},I}, + {"set_inactivity_timeout",{P,I}}, + {"get_flags",{P},I}, + {"set_flags",{P,I}}, + {"get_resource_base_path",{P},S}, + {"set_resource_base_path",{P,S}}, + {"get_dbus_connection",{P},P}, + {"get_dbus_object_path",{P},S}, + {"get_is_registered",{P},B}, + {"get_is_remote",{P},B}, + {"register",{P,P,P},B}, + {"hold",{P}}, + {"release",{P}}, + {"quit",{P}}, + {"activate",{P}}, + {"open",{P,P,I,I}}, + {"send_notification",{P,S,P}}, + {"withdraw_notification",{P,S}}, + {"run",{P,I,P},I}, + {"add_main_option_entries",{P,P}}, + {"add_option_group",{P,P}}, + {"add_main_option",{P,S,S,I,I,S,S}}, + {"set_default",{P}}, + {"mark_busy",{P}}, + {"unmark_busy",{P}}, + {"get_is_busy",{P},B}, + {"bind_busy_property",{P,P,S}}, + {"unbind_busy_property",{P,P,S}}, +"GApplication"} + +widget[GAppInfo] = {"g_app_info", +{0}, + {"get_name",{P},S}, + {"get_display_name",{P},S}, + {"get_description",{P},S}, + {"get_executable",{P},S}, + {"get_commandline",{P},S}, + {"get_icon",{P},P,0,GIcon}, + {"launch",{P,P,P,P},B}, + {"supports_files",{P},B}, + {"supports_uris",{P},B}, + {"launch_uris",{P,P,P,P},B}, + {"should_show",{P},B}, + {"can_delete",{P},B}, + {"delete",{P},B}, + {"set_as_default_for_type",{P,S,P},B}, + {"set_as_default_for_extension",{P,S,P},B}, + {"add_supports_type",{P,S,P},B}, + {"can_remove_supports_type",{P},B}, + {"remove_supports_type",{P,S,P},B}, + {"get_all",{},P,0,GList}, +"GAppInfo"} + +widget[GFile] = {"g_file", +{GObject}, + {"new",{P},-routine_id("newGFile")}, + {"get_parse_name",{P},S}, + {"parse_name",{S},P}, + {"equal",{P,P},B}, + {"get_basename",{P},S}, + {"get_path",{P},S}, + {"get_uri",{P},S}, + {"get_parse_name",{P},S}, + {"get_parent",{P},P,0,GFile}, + {"has_parent",{P,P},B}, + {"get_child",{P,S},P,0,GFile}, + {"get_child_for_display_name",{P,S,P},P,0,GFile}, + {"has_prefix",{P,P},B}, + {"get_relative_path",{P,P},S}, + {"resolve_relative_path",{P,S},P,0,GFile}, + {"is_native",{P},B}, + {"has_uri_scheme",{P,S},B}, + {"get_uri_scheme",{P},S}, + {"read",{P,P,P},P,0,GFileInputStream}, +"GFile"} + + -- create a GFile from a path or uri + function newGFile(object s) + if file_exists(canonical_path(locate_file(s))) then + return gtk_func("g_file_new_for_path",{P}, + {allocate_string(canonical_path(locate_file(s)),1)}) + else + return gtk_func("g_file_new_for_uri",{P}, + {allocate_string(s,1)}) + end if + return 0 + end function + +widget[GIcon] = {"g_icon", +{GObject}, + {"hash",{P},I}, + {"equal",{P,P},B}, + {"to_string",{P},S}, + {"new_for_string",{S,P},P}, + {"new",{S},-routine_id("newGIcon")}, + {"serialize",{P},P}, + {"deserialize",{P},P,0,GIcon}, +"GIcon"} + + function newGIcon(object s) + if string(s) then s = allocate_string(s,1) end if + return gtk_func("g_icon_new_for_string",{P,P},{s,0}) + end function + +widget[GFileIcon] = {"g_file_icon", +{GIcon,GObject}, + {"new",{P},P}, + {"get_file",{P},P}, +"GFileIcon"} + +widget[GFileInfo] = {"g_file_info", +{GObject}, + {"new",{},P}, + {"get_name",{P},S}, + {"get_display_name",{P},S}, + {"get_edit_name",{P},S}, + {"get_icon",{P},P,0,GIcon}, + {"get_symbolic_icon",{P},P,0,GIcon}, + {"get_content_type",{P},S}, + {"get_size",{P},I}, + {"get_modification_time",{P,P}}, + {"get_symlink_target",{P},S}, + {"get_etag",{P},S}, + {"get_sort_order",{P},I}, + {"get_deletion_date",{P},P,0,GDateTime}, + {"set_is_hidden",{P,B}}, + {"set_is_symlink",{P,B}}, + {"set_name",{P,S}}, + {"set_display_name",{P,S}}, + {"set_edit_name",{P,S}}, + {"set_icon",{P,P}}, + {"set_symbolic_icon",{P,P}}, + {"set_content_type",{P,S}}, + {"set_size",{P,I}}, +"GFileInfo"} + +widget[GList] = {"g_list", +{GObject}, + {"new",{},-routine_id("newGList")}, + {"append",{P,P},P}, + {"length",{P},I}, + {"nth_data",{P,I},P}, +"GList"} + + function newGList() + atom x = allocate(64) x = 0 -- keep; + return x + end function + +widget[GSList] = {"g_slist", +{GObject}, + {"length",{P},I}, +"GSList"} + + object temp_list + + export function unpack_gs_str_list(atom gs) + if gs = 0 then return 1 end if + atom fn = call_back(routine_id("gs_str_each")) + temp_list = {} + gtk_proc("g_slist_foreach",{P,P,P},{gs,fn,0}) + return temp_list + end function + + function gs_str_each(object x) + if x > 0 then + temp_list = append(temp_list,peek_string(x)) + end if + return 1 + end function + + export function unpack_gs_atom_list(object gs) + temp_list = {} + atom fn = call_back(routine_id("gs_atom_each")) + gtk_proc("g_slist_foreach",{P,P,P},{gs,fn,0}) + return temp_list + end function + + function gs_atom_each(object x) + temp_list = append(temp_list,x) + return 1 + end function + +widget[GdkDisplay] = {"gdk_display", +{GObject}, + {"new",{},-routine_id("newGdkDisplay")}, -- alias get_default; + {"open",{S},P,0,GdkDisplay}, + {"get_name",{P},S}, + {"get_n_screens",{P},I}, + {"get_screen",{P,I},P,0,GdkScreen}, + {"get_default_screen",{P},P,0,GdkScreen}, + {"get_device_manager",{P},P,0,GdkDeviceManager}, + {"device_is_grabbed",{P,P},B}, + {"beep",{P}}, + {"sync",{P}}, + {"flush",{P}}, + {"close",{P}}, + {"is_closed",{P},B}, + {"get_event",{P},P,0,GdkEvent}, + {"peek_event",{P},P,0,GdkEvent}, + {"put_event",{P,P}}, + {"has_pending",{P},B}, + {"set_double_click_time",{P,I}}, + {"set_double_click_distance",{P,I}}, + {"supports_cursor_color",{P},B}, + {"supports_cursor_alpha",{P},B}, + {"get_default_cursor_size",{P},I}, + {"get_maximal_cursor_size",{P,I,I}}, + {"get_default_group",{P},P,0,GdkWindow}, + {"supports_selection_notification",{P},B}, + {"request_selection_notification",{P,P},B}, + {"supports_clipboard_persistence",{P},B}, + {"store_clipboard",{P,P,I,P,I}}, + {"supports_shapes",{P},B}, + {"supports_input_shapes",{P},B}, + {"supports_composite",{P},B}, -- deprecated 3.16 + {"get_app_launch_context",{P},P,0,GtkAppLaunchContext}, + {"notify_startup_complete",{P,S}}, +"GdkDisplay"} + + function newGdkDisplay() -- alias; + return gtk_func("gdk_display_get_default",{}) + end function + +widget[GdkDevice] = {"gdk_device", +{GObject}, + {"get_name",{P},S}, + {"get_device_type",{P},I}, + {"get_display",{P},P,0,GdkDisplay}, + {"get_has_cursor",{P},B}, + {"get_n_axes",{P},I}, + {"get_n_keys",{P},I}, + {"warp",{P,P,I,I}}, + {"grab",{P,P,I,B,I,P,P},I}, + {"ungrab",{P,P}}, + {"get_state",{P,P,D,P}}, + {"get_position",{P,P,I,I}}, + {"get_position_double",{P,P,D,D}}, + {"get_window_at_position",{P,I,I},P,0,GdkWindow}, + {"get_window_at_position_double",{P,D,D},P,0,GdkWindow}, + {"get_history",{P,P,P,P,P,I},B}, + {"free_history",{P,I}}, + {"get_vendor_id",{P},S}, + {"get_product_id",{P},S}, + {"get_source",{P},P,0,GdkInputSource}, + {"set_mode",{P,I},B}, + {"get_mode",{P},I}, + {"set_key",{P,I,I,I}}, + {"get_key",{P,I,I,I},B}, + {"get_axis",{P,D,I,D},B}, + {"list_axes",{P},A,0,GList}, + {"get_axis_value",{P,D,P,D},B}, + {"get_last_event_window",{P},P,0,GdkWindow}, + {"set_axis_use",{P,I,I}}, + {"get_axis_use",{P,I},I}, + {"get_associated_device",{P},P,0,GdkDevice}, + {"list_slave_devices",{P},A,0,GList}, + {"get_position",{P,P,I,I}}, +"GdkDevice"} + +widget[GdkScreen] = {"gdk_screen", +{GdkDevice,GObject}, + {"new",{},-routine_id("newGdkScreen")}, -- alias get_default; + {"get_system_visual",{P},P,0,GdkVisual}, + {"get_rgba_visual",{P},P,0,GdkVisual}, + {"is_composited",{P},B}, + {"get_root_window",{P},P,0,GdkWindow}, + {"get_display",{P},P,0,GdkDisplay}, + {"get_number",{P},I}, + {"get_width",{P},I}, + {"get_height",{P},I}, + {"get_width_mm",{P},I}, + {"get_height_mm",{P},I}, + {"list_visuals",{P},P,0,GList}, + {"get_toplevel_windows",{P},P,0,GList}, + {"make_display_name",{P},S}, + {"get_n_monitors",{P},I}, + {"get_primary_monitor",{P},I}, + {"get_monitor_geometry",{P,I,P}}, + {"get_monitor_workarea",{P,I,P}}, + {"get_monitor_at_point",{P,I,I},I}, + {"get_monitor_at_window",{P,P},I}, + {"get_monitor_height_mm",{P,I},I}, + {"get_monitor_width_mm",{P,I},I}, + {"get_monitor_plug_name",{P,I},S}, + {"get_setting",{P,S,P},B}, + {"get_font_options",{P},P,0,CairoFontOptions}, + {"get_resolution",{P},D}, + {"set_resolution",{P,D}}, + {"get_active_window",{P},P,0,GdkWindow}, + {"get_window_stack",{P},P,0,GList}, +"GdkScreen"} + + function newGdkScreen() -- alias; + return gtk_func("gdk_screen_get_default",{}) + end function + +widget[GdkVisual] = {"gdk_visual", +{GObject}, +"GdkVisual"} + +widget[GThemedIcon] = {"g_themed_icon", +{GIcon,GObject}, + {"new",{S},P}, + {"new_with_default_fallbacks",{S},P}, + {"get_names",{P},P}, +"GThemedIcon"} + +widget[GtkThemedIcon] = {"gtk_themed_icon", +{GObject}, +"GtkThemedIcon"} + +widget[GEmblem] = {"g_emblem", +{GObject}, + {"new",{P},P}, + {"get_icon",{P},P,0,GIcon}, +"GEmblem"} + +widget[GEmblemedIcon] = {"g_emblemed_icon", +{GIcon,GObject}, + {"new",{P,P},P}, +"GEmblemedIcon"} + +widget[GdkDeviceManager] = {"gdk_device_manager", +{GObject}, + {"new",{P},-routine_id("newDeviceManager")}, + {"get_display",{P},P,0,GdkDisplay}, + {"list_devices",{P,I},X,0,GList}, + {"get_client_pointer",{P},P,0,GdkDevice}, +"GdkDeviceManager"} + + function newDeviceManager(atom disp=0) + if disp = 0 then + disp = gtk_func("gdk_display_get_default") + end if + return gtk_func("gdk_display_get_device_manager",{P},{disp}) + end function + +widget[GtkAppChooser] = {"gtk_app_chooser", +{GtkWidget}, + {"get_app_info",{P},P,0,GAppInfo}, + {"get_content_type",{P},S}, + {"refresh",{P}}, +"GtkAppChooser"} + +widget[GtkAppChooserButton] = {"gtk_app_chooser_button", +{GtkComboBox,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkCellLayout,GtkCellEditable,GObject}, + {"new",{S},P}, + {"append_custom_item",{P,S,S,P}}, + {"append_separator",{P}}, + {"set_active_custom_item",{P,S}}, + {"set_show_default_item",{P,B}}, + {"get_show_default_item",{P},B}, + {"set_show_dialog_item",{P,B}}, + {"get_show_dialog_item",{P},B}, + {"set_heading",{P,S}}, + {"get_heading",{P},S}, +"GtkAppChooserButton"} + +widget[GMenu] = {"g_menu", +{GObject}, + {"new",{},P}, + {"append",{P,S,S}}, +"GMenu"} + +widget[GSettings] = {"g_settings", +{GObject}, + {"new",{S},P}, + {"set_value",{P,S,P},B}, + {"get_value",{P},P}, + {"get_user_value",{P,S},P}, +"GSettings"} + +widget[GtkApplication] = {"gtk_application", +{GApplication,GObject}, + {"new",{S,I},-routine_id("newApplication")}, + {"add_window",{P,P}}, + {"remove_window",{P,P}}, + {"get_windows",{P},A,0,GList}, + {"get_window_by_id",{P,I},P,0,GtkWindow}, + {"get_active_window",{P},P,0,GtkWindow}, + {"inhibit",{P,P,I,S},I}, + {"uninhibit",{P,I}}, + {"is_inhibited",{P,I},B}, + {"get_app_menu",{P},P,0,GMenuModel}, + {"set_app_menu",{P,P}}, + {"get_menubar",{P},P,0,GMenuModel}, + {"set_menubar",{P,P}}, + {"add_accelerator",{P,S,S,P}}, + {"remove_accelerator",{P,S,P}}, + {"run",{P},-routine_id("app_run")}, + {"activate",{P},-routine_id("app_activate")}, + {"get_accels_for_action",{P,S},V}, -- 3.12 + {"set_accels_for_action",{P,S,S}}, -- 3.12 + {"list_action_descriptions",{P},V}, + {"get_actions_for_accel",{P,S},V}, -- 3.14 + {"get_menu_by_id",{P,S},P,0,GMenu}, -- 3.14 + {"prefers_app_menu",{},B}, -- 3.14 +"GtkApplication"} + + function app_activate(object x) + gtk_proc("g_application_activate",{P},{x}) + return 1 + end function + + function app_run(object x) + gtk_proc("g_application_run",{P,I,P},{x,0,0}) + return 1 + end function + + function newApplication(object id, object flags) + if string(id) then id = allocate_string(id,1) end if + if gtk_func("g_application_id_is_valid",{P},{id}) then + return gtk_func("gtk_application_new",{P,I},{id,flags}) + else + crash("Error: invalid application id!") + end if + return 0 + end function + +widget[GtkApplicationWindow] = {"gtk_application_window", +{GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{P},P}, + {"set_show_menubar",{P,B}}, + {"get_show_menubar",{P},B}, + {"set_help_overlay",{P,P}}, -- 3.20 + {"get_help_overlay",{P},P,0,GtkShortcutsWindow}, -- 3.20 + {"get_id",{P},I}, +"GtkApplicationWindow"} + +widget[GtkActionable] = {"gtk_actionable", +{GtkWidget}, + {"get_action_name",{P},S}, + {"set_action_name",{P,S}}, + {"get_action_target_value",{P},P}, + {"set_action_target_value",{P,P}}, + {"set_action_target",{P,S,P}}, + {"set_detailed_action_name",{P,S}}, +"GtkActionable"} + +-- Soon to be deprecated, but still used internally by Glade; +widget[GtkAlignment] = {"gtk_alignment", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{F,F,F,F},P}, + {"set",{P,F,F,F,F}}, + {"get_padding",{P,I,I,I,I}}, + {"set_padding",{P,I,I,I,I}}, +"GtkAlignment"} + +widget[GtkAppLaunchContext] = {"gdk_app_launch_context", +{GdkAppLaunchContext,GObject}, + {"set_screen",{P,P}}, + {"set_desktop",{P,I}}, + {"set_timestamp",{P,I}}, + {"set_icon",{P,P}}, + {"set_icon_name",{P,S}}, +"GtkAppLaunchContext"} + +widget[GtkAspectFrame] = {"gtk_aspect_frame", +{GtkFrame,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{S,F,F,F,B},P}, + {"set",{P,F,F,F,B}}, +"GtkAspectFrame"} + +widget[GtkAssistant] = {"gtk_assistant", +{GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"set_current_page",{P,I}}, + {"get_current_page",{P},I}, + {"get_n_pages",{P},I}, + {"get_nth_page",{P,I},P,0,GtkWidget}, + {"prepend_page",{P,P},I}, + {"append_page",{P,P},I}, + {"insert_page",{P,P,I},I}, + {"remove_page",{P,I}}, + {"set_forward_page_func",{P,P,P,P}}, + {"set_page_type",{P,P,P}}, + {"get_page_type",{P,P},I}, + {"set_page_title",{P,P,S}}, + {"get_page_title",{P,P},S}, + {"set_page_complete",{P,P,B}}, + {"get_page_complete",{P,P},B}, + {"add_action_widget",{P,P}}, + {"remove_action_widget",{P,P}}, + {"update_buttons_state",{P}}, + {"commit",{P}}, + {"next_page",{P}}, + {"previous_page",{P}}, + {"get_page_has_padding",{P,P},B}, -- 3.18 + {"set_page_has_padding",{P,P,B}}, -- 3.18 +"GtkAssistant"} + +widget[GtkDrag] = {"gtk_drag", +{0}, + {"get_data",{P,P,P,P}}, + {"get_source_widget",{P},P,0,GtkWidget}, + {"highlight",{P}}, + {"unhighlight",{P}}, + {"begin_with_coordinates",{P,P,P,I,P,I,I},P}, + {"finish",{P,B,B,P}}, + {"set_icon_widget",{P,P,I,I}}, + {"set_icon_pixbuf",{P,P,I,I}}, + {"set_icon_surface",{P,P}}, + {"set_icon_name",{P,P,I,I}}, + {"set_icon_gicon",{P,P,I,I}}, + {"set_icon_default",{P}}, + {"check_threshold",{P,I,I,I,I},B}, + {"cancel",{P}}, -- 3.16 +"GtkDrag"} + +widget[GtkDragSource] = {"gtk_drag_source", +{GtkDrag}, + {"set",{P,I,P,I,I}}, + {"set_icon_pixbuf",{P,P}}, + {"set_icon_name",{P,S}}, + {"set_icon_gicon",{P,P}}, + {"unset",{P}}, + {"set_target_list",{P,P}}, + {"get_target_list",{P},P,0,GtkTargetList}, + {"add_text_targets",{P}}, + {"add_image_targets",{P}}, + {"add_uri_targets",{P}}, +"GtkDragSource"} + +widget[GtkDragDest] = {"gtk_drag_dest", +{GtkDrag}, + {"set",{P,I,P,I,I}}, + {"set_proxy",{P,P,I,B}}, + {"unset",{P}}, + {"find_target",{P,P,P},P}, + {"get_target_list",{P},P,0,GtkTargetList}, + {"set_target_list",{P,P}}, + {"add_text_targets",{P}}, + {"add_image_targets",{P}}, + {"add_uri_targets",{P}}, + {"set_track_motion",{P,B}}, + {"get_track_motion",{P},B}, +"GtkDragDest"} + +widget[GtkCssProvider] = {"gtk_css_provider", +{GObject}, + {"new",{P},-routine_id("new_css_provider")}, + {"get_default",{},P,0,GtkCssProvider}, + {"get_named",{S,S},P,0,GtkCssProvider}, + {"load_from_data",{P,S,I,P},B}, + {"load_from_file",{P,S,P},B}, + {"load_from_path",{P,S,P},B}, + {"load_from_resource",{P,S}}, -- 3.16 + {"to_string",{P},S}, +"GtkCssProvider"} + + function new_css_provider(object name=0) + atom provider = gtk_func("gtk_css_provider_get_default") + atom style = create(GtkStyleContext) + atom screen = get(style,"screen") + + atom err = allocate(64,1) err = 0 + register(provider,GtkCssProvider) + + if atom(name) then + set(style,"add provider for screen",screen,provider,800) + return provider + end if + + if file_exists(canonical_path(locate_file(name))) then + if gtk_func("gtk_css_provider_load_from_path",{P,P,P}, + {provider,allocate_string(canonical_path(locate_file(name)),1),err}) then + set(style,"add provider for screen",screen,provider,800) + return provider + else + printf(1,"Error finding or parsing css from path: %s \n", + {canonical_path(locate_file(name))}) + end if + end if + + if string(name) then + integer len = length(name) + name = allocate_string(name,1) + if gtk_func("gtk_css_provider_load_from_data",{P,P,I,P},{provider,name,len,err}) then + set(style,"add provider for screen",screen,provider,800) + end if + end if + + return provider + end function + +widget[GtkCssSection] = {"gtk_css_section", +{GObject}, + {"get_end_line",{P},I}, + {"get_end_position",{P},I}, + {"get_file",{P},P,0,GFile}, + {"get_parent",{P},P,0,GtkCssSection}, + {"get_section_type",{P},I}, + {"get_start_line",{P},I}, + {"get_start_position",{P},I}, +"GtkCssSection"} + +widget[GtkStatusIcon] = {"gtk_status_icon", -- deprecated 3.14 +{GObject}, + {"new",{},P,0,GObject}, + {"new_from_pixbuf",{P},P}, + {"new_from_file",{S},P}, + {"new_from_icon_name",{S},P}, + {"new_from_gicon",{P},P}, + {"set_from_pixbuf",{P,P}}, + {"set_from_file",{P,S}}, + {"set_from_icon_name",{P,S}}, + {"set_from_gicon",{P,P}}, + {"get_storage_type",{P},I}, + {"get_pixbuf",{P},P,0,GdkPixbuf}, + {"get_icon_name",{P},S}, + {"get_gicon",{P},P}, + {"get_size",{P},I}, + {"set_screen",{P,P}}, + {"get_screen",{P},P,0,GdkScreen}, + {"set_tooltip_text",{P,S}}, + {"get_tooltip_text",{P},S}, + {"set_tooltip_markup",{P,S}}, + {"get_tooltip_markup",{P},S}, + {"set_has_tooltip",{P,B}}, + {"get_has_tooltip",{P},P}, + {"set_title",{P,S}}, + {"get_title",{P},S}, + {"set_name",{P,S}}, + {"set_visible",{P,B}}, + {"get_visible",{P},B}, + {"is_embedded",{P},B}, + {"get_geometry",{P,P,P,I},B}, + {"get_x11_window_id",{P},I}, + {"position_menu",{P,P,I,I,B},-routine_id("si_position_menu")}, +"GtkStatusIcon"} + + function si_position_menu(atom stat, atom menu, integer x, integer y, integer p) + atom fn = define_proc("gtk_status_icon_position_menu",{P,I,I,I,P}) + c_proc(fn,{menu,x,y,p,stat}) -- menu and status_icon params swapped; + return 1 + end function + +widget[GtkOffscreenWindow] = {"gtk_offscreen_window", +{GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"get_surface",{P},P,0,CairoSurface_t}, + {"get_pixbuf",{P},P,0,GdkPixbuf}, +"GtkOffscreenWindow"} + +widget[GtkComboBox] = {"gtk_combo_box", +{GtkBin,GtkContainer,GtkWidget,GtkCellLayout,GtkCellEditable,GtkBuildable,GObject}, + {"new",{P},-routine_id("newComboBox")}, + {"set_wrap_width",{P,I}}, + {"get_wrap_width",{P},I}, + {"set_row_span_column",{P,I}}, + {"get_row_span_column",{P},I}, + {"set_column_span_column",{P,I}}, + {"get_column_span_column",{P},I}, + {"set_active",{P,I}}, + {"get_active",{P},I}, + {"set_id_column",{P,I}}, + {"get_id_column",{P},I}, + {"set_active_id",{P,S},B}, + {"get_active_id",{P},S}, + {"set_model",{P,P}}, + {"get_model",{P},P,0,GtkTreeModel}, + {"popup_for_device",{P,P}}, + {"popup",{P}}, + {"popdown",{P}}, + {"set_row_separator_func",{P,P,P,P}}, + {"get_row_separator_func",{P},P}, + {"set_add_tearoffs",{P,B}}, -- deprecated 3.10 + {"get_add_tearoffs",{P},B}, -- deprecated 3.10 + {"set_title",{P,S}}, -- deprecated 3.10 + {"get_title",{P},S}, -- deprecated 3.10 + {"set_focus_on_click",{P,B}}, + {"get_focus_on_click",{P},B}, + {"set_button_sensitivity",{P,I}}, + {"get_button_sensitivity",{P},I}, + {"get_has_entry",{P},B}, + {"set_entry_text_column",{P,I}}, + {"get_entry_text_column",{P},I}, + {"set_popup_fixed_width",{P,B}}, + {"get_popup_fixed_width",{P},B}, + {"set_activates_default",{P,B},-routine_id("combo_set_activates_default")}, + {"get_entry",{P},-routine_id("combo_get_entry")}, +"GtkComboBox"} + + -- create a combo box either empty or from a model + function newComboBox(object x=0) + if x = 0 then + return gtk_func("gtk_combo_box_new",{},{}) + end if + if class_id(x) = GtkListStore then + return gtk_func("gtk_combo_box_new_with_model",{P},{x}) + end if + end function + + function combo_get_entry(atom box) + atom x = get(box,"child") + register(x,GtkEntry) + return x + end function + + function combo_set_activates_default(atom box, boolean z) + atom x = get(box,"child") + register(x,GtkEntry) + set(x,"property","activates-default",z) + return 1 + end function + +widget[GtkComboBoxText] = {"gtk_combo_box_text", +{GtkCellLayout,GtkCellEditable,GtkComboBox,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"new_with_entry",{},P}, + {"append",{P,S,S}}, + {"prepend",{P,S,S}}, + {"insert",{P,I,S,S}}, + {"append_text",{P,S}}, + {"prepend_text",{P,S}}, + {"insert_text",{P,I,S}}, + {"remove",{P,I}}, + {"remove_all",{P}}, + {"get_active_text",{P},S}, +"GtkComboBoxText"} + +widget[GtkComboBoxEntry] = {"gtk_combo_box_text", +{GtkComboBoxText,GtkComboBox,GtkBin,GtkContainer,GtkWidget,GObject}, + {"new",{},-routine_id("new_combo_box_entry")}, +"GtkComboBoxEntry"} + + function new_combo_box_entry() -- alias; + return gtk_func("gtk_combo_box_text_new_with_entry",{},{}) + end function + +widget[GtkFrame] = {"gtk_frame", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{S},P}, + {"set_label",{P,S}}, + {"get_label",{P},S}, + {"set_label_align",{P,F,F}}, + {"get_label_align",{P,F,F}}, + {"set_label_widget",{P,P}}, + {"get_label_widget",{P},P,0,GtkWidget}, + {"set_shadow_type",{P,I}}, + {"get_shadow_type",{P},I}, +"GtkFrame"} + +widget[GtkModelButton] = {"gtk_model_button", -- new in 3.16 +{GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GObject}, + {"new",{},P}, +"GtkModelButton"} + +widget[GtkButton] = {"gtk_button", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GObject}, + {"new",{P},-routine_id("newButton")}, + {"new_from_icon_name",{S,I},P,0,GtkWidget}, -- 3.10 + {"set_relief",{P,I}}, + {"get_relief",{P},I}, + {"set_label",{P,S}}, + {"get_label",{P},S}, + {"set_use_underline",{P,B}}, + {"get_use_underline",{P},B}, + {"set_focus_on_click",{P,B}}, + {"get_focus_on_click",{P},B}, + {"set_alignment",{P,F,F}}, -- deprecated 3.14 + {"get_alignment",{P,F,F}}, -- deprecated 3.15 + {"set_image",{P,P},-routine_id("setBtnImage")}, + {"get_image",{P},P,0,GtkImage}, + {"set_image_position",{P,I}}, + {"get_image_position",{P},I}, + {"set_always_show_image",{P,B}}, -- GTK 3.6+ + {"get_always_show_image",{P},B}, -- GTK 3.6+ + {"get_event_window",{P},P,0,GdkWindow}, +"GtkButton"} + + function setBtnImage(atom btn, object img) + ------------------------------------------ + if class_id(img) = GdkPixbuf then + img = create(GtkImage,img) + end if + if string(img) then + if file_exists(canonical_path(img)) then + img = canonical_path(img) + elsif file_exists(canonical_path("~" & img)) then + img = canonical_path("~" & img) + end if + img = create(GdkPixbuf,img,20,20,1) + img = create(GtkImage,img) + end if + if atom(img) then + gtk_proc("gtk_button_set_image",{P,P},{btn,img}) + end if + return 1 + end function + + -- handles creation of buttons with icons from various sources; + -- this function modified greatly from earlier versions, in order + -- to circumvent the misguided idea that buttons, menus, etc. should not have + -- icons (even though window managers have settings to show or hide these + -- icons as the USER prefers) + + function newButton(object cap = 0) + ---------------------------------- + atom btn = 0 + object tmp, t1, box, lbl = 0, icon = 0 + + if atom(cap) then + if cap = 0 then -- blank button; + btn = gtk_func("gtk_button_new",{}) + register(btn,GtkButton) + return btn + else + btn = gtk_func("gtk_button_new",{}) + register(btn,GtkButton) + set(btn,"use underline",TRUE) + + if class_id(cap) = GdkPixbuf then -- convert to image; + cap = create(GtkImage,cap) + end if + if class_id(cap) = GtkImage then + set(btn,"image",cap) -- add image to btn + set(btn,"always show image",BTN_SHOW_IMG) + end if + return btn + end if + end if + + if string(cap) then + if match("#",cap) = 0 then + btn = gtk_func("gtk_button_new_from_stock",{P},{allocate_string(cap)}) + register(btn,GtkButton) + set(btn,"always show image",BTN_SHOW_IMG) + set(btn,"use underline",TRUE) + return btn + end if + tmp = split(cap,'#') + btn = gtk_func("gtk_button_new_with_mnemonic",{P},{allocate_string(tmp[2],1)}) + register(btn,GtkButton) + set(btn,"use underline",TRUE) + + t1 = canonical_path(locate_file(tmp[1])) + + if match("gtk-",cap) = 1 then + btn = gtk_func("gtk_button_new") + register(btn,GtkButton) + box = create(GtkBox,0,5) + add(btn,box) + icon = create(GtkImage,tmp[1],ceil(BTN_ICON_SIZE/10)) + if icon > 0 then add(box,icon) end if + if length(tmp[2]) > 0 then + lbl = gtk_func("gtk_label_new_with_mnemonic",{P},{allocate_string(tmp[2])}) + register(lbl,GtkLabel) + set(lbl,"font",sprintf("%d",BTN_TEXT_SIZE)) + add(box,lbl) + end if + set(btn,"always show image",BTN_SHOW_IMG) + set(btn,"use underline",TRUE) + return btn + + elsif file_exists(t1) then + icon = create(GdkPixbuf,t1,BTN_ICON_SIZE,0,1) + + else + icon = create(GtkImage,tmp[1],BTN_ICON_SIZE,0,1) + end if + set(btn,"image",icon) + set(btn,"always show image",BTN_SHOW_IMG) + set(btn,"use underline",TRUE) + return btn + end if + + btn = gtk_func("gtk_button_new",{}) + register(btn,GtkButton) + + return btn + end function + +widget[GtkToggleButton] = {"gtk_toggle_button", +{GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GObject}, + {"new",{P},-routine_id("newToggleButton")}, + {"new_with_label",{S},P}, + {"new_with_mnemonic",{S},P}, + {"set_mode",{P,B}}, + {"get_mode",{P},B}, + {"toggled",{P}}, + {"set_active",{P,B}}, + {"get_active",{P},B}, + {"set_inconsistent",{P,B}}, + {"get_inconsistent",{P},B}, +"GtkToggleButton"} + + function newToggleButton(object cap = 0) + atom btn = 0 + object tmp, t1, icon = 0 + + if atom(cap) then + if cap = 0 then -- blank button; + btn = gtk_func("gtk_toggle_button_new",{}) + register(btn,GtkToggleButton) + return btn + else + btn = gtk_func("gtk_toggle_button_new",{}) + register(btn,GtkToggleButton) + if class_id(cap) = GdkPixbuf then -- convert to image; + cap = create(GtkImage,cap) + end if + if class_id(cap) = GtkImage then + set(btn,"image",cap) -- add image to btn + set(btn,"always show image",BTN_SHOW_IMG) + end if + return btn + end if + end if + + if string(cap) then + if match("#",cap) = 0 then + btn = gtk_func("gtk_toggle_button_new_with_mnemonic",{P},{allocate_string(cap)}) + register(btn,GtkToggleButton) + return btn + end if + tmp = split(cap,'#') + btn = gtk_func("gtk_toggle_button_new_with_mnemonic",{P},{allocate_string(tmp[2],1)}) + register(btn,GtkToggleButton) + + t1 = canonical_path(locate_file(tmp[1])) + + if match("gtk-",cap) = 1 then + icon = create(GtkImage,tmp[1],ceil(BTN_ICON_SIZE/5)) + + elsif file_exists(t1) then + icon = create(GdkPixbuf,t1,BTN_ICON_SIZE,0,1) + + else + icon = create(GtkImage,tmp[1],BTN_ICON_SIZE,0,1) + end if + set(btn,"image",icon) + set(btn,"always show image",BTN_SHOW_IMG) + return btn + end if + + btn = gtk_func("gtk_toggle_button_new",{}) + register(btn,GtkToggleButton) + + return btn + + end function + +widget[GtkCheckButton] = {"gtk_check_button", +{GtkToggleButton,GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GObject}, + {"new",{P},-routine_id("newCheckButton")}, + {"new_with_label",{S},P,0,GtkCheckButton}, + {"new_with_mnemonic",{S},P,0,GtkCheckButton}, +"GtkCheckButton"} + + function newCheckButton(object cap = 0) + atom btn = 0 + object tmp, t1, icon = 0 + + if atom(cap) then + if cap = 0 then -- blank button; + btn = gtk_func("gtk_check_button_new",{}) + register(btn,GtkCheckButton) + return btn + else + btn = gtk_func("gtk_check_button_new",{}) + register(btn,GtkCheckButton) + if class_id(cap) = GdkPixbuf then -- convert to image; + cap = create(GtkImage,cap) + end if + if class_id(cap) = GtkImage then + set(btn,"image",cap) -- add image to btn + set(btn,"always show image",BTN_SHOW_IMG) + end if + return btn + end if + end if + + if string(cap) then + if match("#",cap) = 0 then + btn = gtk_func("gtk_check_button_new_with_mnemonic",{P},{allocate_string(cap)}) + register(btn,GtkCheckButton) + return btn + end if + tmp = split(cap,'#') + btn = gtk_func("gtk_check_button_new_with_mnemonic",{P},{allocate_string(tmp[2],1)}) + register(btn,GtkCheckButton) + + t1 = canonical_path(locate_file(tmp[1])) + + if match("gtk-",cap) = 1 then + icon = create(GtkImage,tmp[1],ceil(BTN_ICON_SIZE/5)) + + elsif file_exists(t1) then + icon = create(GdkPixbuf,t1,BTN_ICON_SIZE,0,1) + + else + icon = create(GtkImage,tmp[1],BTN_ICON_SIZE,0,1) + end if + set(btn,"image",icon) + set(btn,"always show image",BTN_SHOW_IMG) + return btn + end if + + btn = gtk_func("gtk_check_button_new",{}) + register(btn,GtkCheckButton) + + return btn + end function + +widget[GtkRadioButton] = {"gtk_radio_button", +{GtkCheckButton,GtkToggleButton,GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GObject}, + {"new",{P,P},-routine_id("newRadioButton")}, + {"set_group",{P,P}}, + {"get_group",{P},P}, + {"join_group",{P,P}}, +"GtkRadioButton"} + + function newRadioButton(atom group=0, object cap = 0) + atom btn = 0 + object tmp, t1, icon = 0 + + if atom(cap) then + if cap = 0 then -- blank button; + btn = gtk_func("gtk_radio_button_new",{P},{group}) + register(btn,GtkRadioButton) + return btn + else + btn = gtk_func("gtk_radio_button_new",{P},{group}) + register(btn,GtkRadioButton) + if class_id(cap) = GdkPixbuf then -- convert to image; + cap = create(GtkImage,cap) + end if + if class_id(cap) = GtkImage then + set(btn,"image",cap) -- add image to btn + set(btn,"always show image",BTN_SHOW_IMG) + end if + return btn + end if + end if + + if string(cap) then + if match("#",cap) = 0 then + btn = gtk_func("gtk_radio_button_new_with_mnemonic_from_widget",{P,P},{group,cap}) + register(btn,GtkRadioButton) + return btn + end if + tmp = split(cap,'#') + btn = gtk_func("gtk_radio_button_new_with_mnemonic_from_widget",{P,P},{group,allocate_string(tmp[2],1)}) + register(btn,GtkRadioButton) + + t1 = canonical_path(locate_file(tmp[1])) + + if match("gtk-",cap) = 1 then + icon = create(GtkImage,tmp[1],ceil(BTN_ICON_SIZE/5)) + + elsif file_exists(t1) then + icon = create(GdkPixbuf,t1,BTN_ICON_SIZE,0,1) + + else + icon = create(GtkImage,tmp[1],BTN_ICON_SIZE,0,1) + end if + set(btn,"image",icon) + set(btn,"always show image",BTN_SHOW_IMG) + return btn + end if + + + btn = gtk_func("gtk_radio_button_new",{P},{group}) + register(btn,GtkRadioButton) + + return btn + end function + +widget[GtkColorButton] = {"gtk_color_button", +{GtkColorChooser,GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GObject}, + {"new",{P},-routine_id("newColorButton")}, + {"set_title",{P,S}}, + {"get_title",{P},S}, + {"show_editor",{P,B}}, -- 3.20 +"GtkColorButton"} + + function newColorButton(object c=0) + if string(c) then c = to_rgba(c) end if + if c=0 then return gtk_func("gtk_color_button_new") + else return gtk_func("gtk_color_button_new_with_rgba",{P},{c}) + end if + end function + +widget[GtkFontButton] = {"gtk_font_button", +{GtkFontChooser,GtkButton,GtkBin,GtkContainer,GtkWidget,GtkActionable,GtkBuildable,GObject}, + {"new",{P,P,P},-routine_id("newFontButton")}, + {"set_font_name",{P,S}}, + {"get_font_name",{P},S}, + {"set_show_style",{P,B}}, + {"get_show_style",{P},B}, + {"set_show_size",{P,B}}, + {"get_show_size",{P},B}, + {"set_use_font",{P,B}}, + {"get_use_font",{P},B}, + {"set_use_size",{P,B}}, + {"get_use_size",{P},B}, + {"set_title",{P,S}}, + {"get_title",{P},S}, +"GtkFontButton"} + + function newFontButton(object f=0, object fn=0, object data=0) + if string(f) then f = allocate_string(f,1) end if + atom fnt + if f = 0 then + fnt = gtk_func("gtk_font_button_new") + else fnt = gtk_func("gtk_font_button_new_with_font",{P},{f}) + end if + if string(fn) or fn > 0 then + connect(fnt,"font-set",fn,data) + end if + return fnt + end function + +widget[GtkLinkButton] = {"gtk_link_button", +{GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GObject}, + {"new",{S,S},-routine_id("newLinkButton")}, + {"set_uri",{P,S}}, + {"get_uri",{P},S}, + {"set_visited",{P,B}}, + {"get_visited",{P},B}, +"GtkLinkButton"} + + function newLinkButton(object link, object lbl=0) + if lbl = 0 then return gtk_func("gtk_link_button_new",{S},{link}) + else return gtk_func("gtk_link_button_new_with_label",{S,S},{link,lbl}) + end if + end function + +widget[GtkLockButton] = {"gtk_lock_button", -- unable to make this work! +{GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GObject}, + {"new",{P},P}, + {"set_permission",{P,P}}, + {"get_permission",{P},P,0,GPermission}, +"GtkLockButton"} + +widget[GPermission] = {"g_permission", +{GObject}, + {"get_allowed",{P},B}, + {"get_can_acquire",{P},B}, + {"get_can_release",{P},B}, + {"acquire",{P,P,P},B}, + {"acquire_async",{P,P,P,P}}, + {"acquire_finish",{P,P,P},B}, + {"release",{P,P,P},B}, + {"release_async",{P,P,P,P}}, + {"finish",{P,P,P},B}, + {"impl_update",{P,B,B,B}}, +"GPermission"} + +widget[GSimplePermission] = {"g_simple_permission", +{GPermission}, + {"new",{B},P}, +"GSimplePermission"} + +widget[GtkScaleButton] = {"gtk_scale_button", +{GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GtkActionable,GObject}, + {"new",{I,D,D,D,P},P}, + {"set_adjustment",{P,P}}, + {"get_adjustment",{P},P,0,GtkAdjustment}, + {"set_value",{P,D}}, + {"get_value",{P},D}, + {"get_popup",{P},P,0,GtkWidget}, + {"get_plus_button",{P},P,0,GtkButton}, + {"get_minus_button",{P},P,0,GtkButton}, + {"set_icons",{P,A}}, +"GtkScaleButton"} + +widget[GtkMenu] = {"gtk_menu", +{GtkMenuShell,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{P},-routine_id("newMenu")}, + {"attach",{P,P,I,I,I,I}}, + {"attach_to_widget",{P,P,P}}, + {"get_attach_widget",{P},P,0,GtkWidget}, + {"get_for_attach_widget",{P},P,0,GList}, + {"detach",{P}}, + {"popup",{P,P,P,P,P,I,I}}, + {"popdown",{P}}, + {"reposition",{P}}, + {"set_active",{P,I}}, + {"get_active",{P},P,0,GtkMenuItem}, + {"popup_for_device",{P,P,P,P,P,P,P,I,I}}, + {"set_accel_group",{P,P}}, + {"get_accel_group",{P},P,0,GtkAccelGroup}, + {"set_accel_path",{P,S}}, + {"get_accel_path",{P},S}, + {"set_title",{P,S}}, -- deprecated 3.10 + {"get_title",{P},S}, -- deprecated 3.10 + {"set_monitor",{P,I}}, + {"get_monitor",{P},I}, + {"set_tearoff_state",{P,B}}, -- deprecated 3.10 + {"get_tearoff_state",{P},B}, -- deprecated 3.10 + {"set_reserve_toggle_size",{P,B}}, + {"get_reserve_toggle_size",{P},B}, + {"set_screen",{P,P}}, + {"popup_at_pointer",{P,P}}, -- 3.22 + {"popup_at_rect",{P,P,P,I,I,P}}, -- 3.22 + {"popup_at_widget",{P,P,I,I,P}}, -- 3.22 +"GtkMenu"} + + function newMenu(object x=0) + if class_id(x) = GMenuModel then + return gtk_func("gtk_menu_new_from_model",{P},{x}) + else + return gtk_func("gtk_menu_new") + end if + end function + +widget[GtkMenuBar] = {"gtk_menu_bar", +{GtkMenuShell,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{P},-routine_id("newMenuBar")}, + {"set_pack_direction",{P,I}}, + {"get_pack_direction",{P},I}, + {"set_child_pack_direction",{P,I}}, + {"get_child_pack_direction",{P},I}, +"GtkMenuBar"} + + function newMenuBar(atom x=0) + if class_id(x) = GMenuModel then + return gtk_func("gtk_menu_bar_new_from_model",{P},{x}) + else + return gtk_func("gtk_menu_bar_new") + end if + end function + +widget[GMenu] = {"g_menu", +{GMenuModel,GObject}, + {"new",{},P}, + {"freeze",{P}}, + {"insert",{P,I,S,S}}, + {"prepend",{P,S,S}}, + {"append",{P,S,S}}, + {"insert_item",{P,I,P}}, + {"append_item",{P,P}}, + {"prepend_item",{P,P}}, + {"insert_section",{P,I,S,P}}, + {"prepend_section",{P,S,P}}, + {"append_section",{P,S,P}}, + {"append_submenu",{P,S,P}}, + {"insert_submenu",{P,I,S,P}}, + {"prepend_submenu",{P,S,P}}, + {"remove",{P,I}}, +"GMenu"} + +widget[GMenuModel] = {"g_menu_model", +{GObject}, + {"is_mutable",{P},B}, + {"get_n_items",{P},I}, + {"get_item_attribute",{P,I,S,S,P},B}, + {"get_item_link",{P,I,S},P,0,GMenuModel}, + {"items_changed",{P,I,I,I}}, +"GMenuModel"} + +widget[GMenuItem] = {"g_menu_item", +{GObject}, + {"new",{S,S},P}, + {"new_section",{S,P},P,0,GMenuItem}, + {"new_submenu",{S,P},P,0,GMenuItem}, + {"set_label",{P,S}}, + {"set_action_and_target_value",{P,S,P}}, + {"set_detailed_action",{P,S}}, + {"set_section",{P,P}}, + {"set_submenu",{P,P}}, + {"set_attribute_value",{P,P,P}}, + {"set_link",{P,S,P}}, +"GMenuItem"} + +widget[GtkMenuButton] = {"gtk_menu_button", --3.6 +{GtkToggleButton,GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GObject}, + {"new",{},P}, + {"set_popup",{P,P}}, + {"get_popup",{P},P,0,GtkMenu}, + {"set_menu_model",{P,P}}, + {"get_menu_model",{P},P,0,GMenuModel}, + {"set_direction",{P,I}}, + {"get_direction",{P},I}, + {"set_align_widget",{P,P}}, + {"get_align_widget",{P},P,0,GtkWidget}, + {"set_popover",{P,P}}, -- 3.12 + {"get_popover",{P},P,0,GtkPopover}, -- 3.12 + {"set_use_popover",{P,B}}, -- 3.12 + {"get_use_popover",{P},B}, -- 3.12 +"GtkMenuButton"} + +widget[GtkMenuItem] = {"gtk_menu_item", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GObject}, + {"new",{P,P,P,P},-routine_id("newMenuItem")}, + {"set_label",{P,S},-routine_id("mi_set_label")}, + {"get_label",{P},-routine_id("mi_get_label")}, + {"set_image",{P,P},-routine_id("mi_set_image")}, + {"get_image",{P},-routine_id("mi_get_image")}, + {"set_use_underline",{P,B}}, + {"get_use_underline",{P},B}, + {"set_submenu",{P,P}}, + {"get_submenu",{P},P,0,GtkWidget}, + {"select",{P}}, + {"deselect",{P}}, + {"activate",{P}}, + {"toggle_size_allocate",{P,I}}, + {"set_reserve_indicator",{P,B}}, + {"get_reserve_indicator",{P},B}, + {"add_accelerator",{P,P,P},-routine_id("mi_add_accelerator")}, +"GtkMenuItem"} + +-- all this just to allow images and accels on menu items! + +constant activate = allocate_string("activate") + + function newMenuItem(object stk=0, object fn=0, object data=0, object accels=0) + object item, img = 0 + + if match("#",stk) then + stk = split(stk,'#') + img = stk[1] + stk = stk[2] + goto "next" + end if + + if not match("#",stk) then + if match("gtk-",stk) then + img = stk + stk = "_" & proper(stk[5..$]) + end if + end if + + label "next" + + item = gtk_func("gtk_menu_item_new_with_mnemonic",{P},{allocate_string(stk,1)}) + register(item,GtkMenuItem) + + label "accels " + + if atom(img) and img = 0 then + item = mi_add_accelerator(item,accels) + else + item = mi_add_accelerator(item,accels,img) + end if + + return item + end function + + function mi_add_accelerator(atom item, object accels, object img = 0) + atom x = allocate(8,1) + integer key, mods + + object child = get(item,"child") + + if atom(img) and img = 0 then -- do nothing + else + img = get_icon_image(img,3) + end if + + if sequence(accels) then + gtk_proc("gtk_accelerator_parse", {P,P,P}, + {allocate_string(accels[2],1),x,x+4}) + + key = peek4u(x) mods = peek4u(x+4) + + gtk_proc("gtk_widget_add_accelerator",{P,P,P,I,I,I}, + {item,activate,accels[1],key,mods,GTK_ACCEL_VISIBLE}) + + if class_id(child) = -1 then + gtk_proc("gtk_accel_label_set_accel_widget",{P,P},{child,item}) + gtk_proc("gtk_accel_label_set_accel",{P,I,I},{child,key,mods}) + end if + end if + + gtk_proc("g_object_ref",{P},{child}) + gtk_proc("gtk_container_remove",{P,P},{item,child}) + + atom box = create(GtkButtonBox) + set(box,"margin left",0) + set(box,"layout",GTK_BUTTONBOX_START) + + if atom(img) and img > 0 then + add(box,img) + register(img,GtkImage) + set(box,"halign",0) + set(img,"margin left",0) + set(img,"margin right",0) + set(box,"child non_homogeneous",img,TRUE) + end if + + register(child,GtkAccelLabel) + pack_start(box,child,1,1) -- put the label back + + set(box,"child non_homogeneous",child,TRUE) + set(child,"halign",0) + set(child,"margin left",0) + + if sequence(accels) then + object txt = gtk_str_func("gtk_accelerator_get_label",{I,I},{key,mods}) + if string(txt) then + atom acc = create(GtkLabel) + set(acc,"padding",0,0) + set(acc,"markup",txt) + if sequence(ACCEL_FONT) then + set(acc,"font",ACCEL_FONT) + end if + add(box,acc) + set(box,"child secondary",acc,TRUE) + set(box,"child non_homogeneous",acc,TRUE) + end if + end if + + add(item,box) + + return item + end function + + function mi_set_label(atom item, object lbl) + if string(lbl) then lbl = allocate_string(lbl,1) end if + atom b = get(item,"child") + object list = get(b,"children") + if atom(list) then + list &= 0 + end if + + for i = 1 to length(list) do + if class_id(list[i]) = GtkAccelLabel then + gtk_proc("gtk_label_set_text",{P,P},{list[i],lbl}) + return 1 + end if + end for + + return 1 + end function + + export function mi_get_label(atom item) + atom b = get(item,"child") + object list = get(b,"children") + for i = 1 to length(list) do + if class_id(list[i]) = GtkAccelLabel then + return gtk_str_func("gtk_label_get_text",{P},{list[i]}) + end if + end for + return 0 + end function + + function mi_set_image(atom item, object img) + if string(img) then img = get_icon_image(img,GTK_ICON_SIZE_MENU) end if + img = get(img,"pixbuf") + atom b = get(item,"child") + object l = get(b,"children") + for i = 1 to length(l) do + if class_id(l[i]) = GtkImage then + gtk_proc("gtk_image_set_from_pixbuf",{P,P},{l[i],img}) + return 1 + end if + end for + return 1 + end function + + function gmi_get_image(atom item) + atom b = get(item,"child") + object l = get(b,"children") + for i = 1 to length(l) do + if class_id(l[i]) = GtkImage then + return l[i] + end if + end for + return 1 + end function + + function mi_set_use_underline(atom item, boolean use) + atom b = get(item,"child") + object l = get(b,"children") + for i = 1 to length(l) do + if class_id(l[i]) = GtkAccelLabel then + gtk_proc("gtk_label_set_use_underline",{P,B},{l[i],use}) + return 1 + end if + end for + return 1 + end function + + function mi_get_use_underline(atom item) + atom b = get(item,"child") + object l = get(b,"children") + l = to_sequence(l,1) + for i = 1 to length(l) do + if class_id(l[i]) = GtkAccelLabel then + return gtk_func("gtk_label_get_use_underline",{P},{l[i]}) + end if + end for + return 1 + end function + +widget[GtkImageMenuItem] = {"gtk_image_menu_item", +{GtkMenuItem,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{P,P,P,P},-routine_id("newMenuItem")}, +"GtkImageMenuItem"} + +widget[GtkRadioMenuItem] = {"gtk_radio_menu_item", +{GtkCheckMenuItem,GtkMenuItem,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GObject}, + {"new",{P,P,P,P,P},-routine_id("newRadioMenuItem")}, + {"set_group",{P,P}}, + {"get_group",{P},P}, + {"join_group",{P,P}}, -- 3.18 +"GtkRadioMenuItem"} + + function newRadioMenuItem(atom group, object stk, object fn, object data, object accels=0) + object item, img = 0 + + if match("#",stk) then + stk = split(stk,'#') + img = stk[1] + stk = stk[2] + goto "next" + end if + + if not match("#",stk) then + if match("gtk-",stk) then + img = stk + end if + end if + + label "next" + + if group = 0 then + item = gtk_func("gtk_radio_menu_item_new_with_mnemonic",{P,P}, + {group,allocate_string(stk,1)}) + else + item = gtk_func("gtk_radio_menu_item_new_with_mnemonic_from_widget", + {P,P},{group,allocate_string(stk,1)}) + end if + register(item,GtkMenuItem) + + if atom(img) and img = 0 then + item = mi_add_accelerator(item,accels) + else + item = mi_add_accelerator(item,accels,img) + end if + + return item + end function + +widget[GtkCheckMenuItem] = {"gtk_check_menu_item", +{GtkMenuItem,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GObject}, + {"new",{P,P,P,P},-routine_id("newCheckMenuItem")}, + {"set_active",{P,B}}, + {"get_active",{P},B}, + {"toggled",{P}}, + {"set_inconsistent",{P,B}}, + {"get_inconsistent",{P},B}, + {"set_draw_as_radio",{P,B}}, + {"get_draw_as_radio",{P},B}, +"GtkCheckMenuItem"} + + function newCheckMenuItem(object stk,object fn, object data, object accels=0) + object item, img = 0 + + if match("#",stk) then + stk = split(stk,'#') + img = stk[1] + stk = stk[2] + goto "next" + end if + + if not match("#",stk) then + if match("gtk-",stk) then + img = stk + end if + end if + + label "next" + + item = gtk_func("gtk_check_menu_item_new_with_mnemonic",{P},{allocate_string(stk,1)}) + register(item,GtkCheckMenuItem) + + if atom(img) and img = 0 then + item = mi_add_accelerator(item,accels) + else + item = mi_add_accelerator(item,accels,img) + end if + + return item + end function + +widget[GtkNumerableIcon] = {"gtk_numerable_icon", -- deprecated 3.14 +{GEmblemedIcon,GObject}, + {"new",{P},P,0,GIcon}, + {"new_with_style_context",{P,P},P,0,GIcon}, + {"get_background_gicon",{P},P,0,GIcon}, + {"set_background_gicon",{P,P}}, + {"get_background_icon_name",{P},S}, + {"set_background_icon_name",{P,S}}, + {"get_count",{P},I}, + {"set_count",{P,I}}, + {"get_label",{P},S}, + {"set_label",{P,S}}, + {"get_style_context",{P},P,0,GtkStyleContext}, + {"set_style_context",{P,P}}, +"GtkNumerableIcon"} + +widget[GtkEventBox] = {"gtk_event_box", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"set_above_child",{P,B}}, + {"get_above_child",{P},B}, + {"set_visible_window",{P,B}}, + {"get_visible_window",{P},B}, +"GtkEventBox"} + +widget[GtkExpander] = {"gtk_expander", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{P},-routine_id("newExpander")}, + {"set_spacing",{P,I}}, + {"get_spacing",{P},I}, + {"set_expanded",{P,B}}, + {"get_expanded",{P},B}, + {"set_label",{P,S}}, + {"get_label",{P},S}, + {"set_label_widget",{P,P}}, + {"get_label_widget",{P},P}, + {"set_label_fill",{P,B}}, + {"get_label_fill",{P},B}, + {"set_use_underline",{P,B}}, + {"get_use_underline",{P},B}, + {"set_use_markup",{P,B}}, + {"get_use_markup",{P},B}, + {"set_resize_toplevel",{P,B}}, + {"get_resize_toplevel",{P},B}, +"GtkExpander"} + + function newExpander(object caption="") + if string(caption) and match("_",caption) then + return gtk_func("gtk_expander_new_with_mnemonic",{P},{caption}) + else + return gtk_func("gtk_expander_new",{P},{caption}) + end if + end function + +widget[GtkToolItem] = {"gtk_tool_item", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"set_homogeneous",{P,B}}, + {"get_homogeneous",{P},B}, + {"set_expand",{P,B}}, + {"get_expand",{P},B}, + {"set_tooltip_text",{P,S}}, + {"set_tooltip_markup",{P,S}}, + {"set_use_drag_window",{P,B}}, + {"get_use_drag_window",{P},B}, + {"set_visible_horizontal",{P,B}}, + {"get_visible_horizontal",{P},B}, + {"set_visible_vertical",{P,B}}, + {"get_visible_vertical",{P},B}, + {"set_is_important",{P,B}}, + {"get_is_important",{P},B}, + {"get_ellipsize_mode",{P},I}, + {"get_icon_size",{P},I}, + {"get_orientation",{P},I}, + {"get_toolbar_style",{P},I}, + {"get_relief_style",{P},I}, + {"get_text_alignment",{P},F}, + {"get_text_orientation",{P},I}, + {"retrieve_proxy_menu_item",{P},P,0,GtkMenuItem}, + {"set_proxy_menu_item",{P,S,P}}, + {"get_proxy_menu_item",{P,S},P,0,GtkMenuItem}, + {"rebuild_menu",{P}}, + {"toolbar_reconfigured",{P}}, + {"get_text_size_group",{P},P,0,GtkSizeGroup}, +"GtkToolItem"} + +widget[GtkToolButton] = {"gtk_tool_button", +{GtkToolItem,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GObject}, + {"new",{P,P},-routine_id("newToolButton")}, + {"set_label",{P,S}}, + {"get_label",{P},S}, + {"set_use_underline",{P,B}}, + {"get_use_underline",{P},B}, + {"set_stock_id",{P,S}}, -- deprecated 3.10 + {"get_stock_id",{P},S}, -- deprecated 3.10 + {"set_icon_name",{P,S}}, + {"get_icon_name",{P},S}, + {"set_icon_widget",{P,P}}, + {"get_icon_widget",{P},P,0,GtkWidget}, + {"set_label_widget",{P,P}}, + {"get_label_widget",{P},P,0,GtkWidget}, +"GtkToolButton"} + + function newToolButton(object icn=0, object lbl=0) + -------------------------------------------------- + atom btn = 0 + if string(icn) then + if match("gtk-",icn) = 1 then + btn = gtk_func("gtk_tool_button_new_from_stock",{P},{allocate_string(icn,1)}) + set(btn,"always show icon",TRUE) + return btn + else + icn = create(GtkImage,icn) + end if + end if + + if string(lbl) then + lbl = allocate_string(lbl,1) + end if + + btn = gtk_func("gtk_tool_button_new",{P,P},{icn,lbl}) + + return btn + end function + +widget[GtkMenuToolButton] = {"gtk_menu_tool_button", +{GtkToolButton,GtkToolItem,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GObject}, + {"new",{P,P},-routine_id("newMenuToolButton")}, + {"set_menu",{P,P}}, + {"get_menu",{P},P,0,GtkMenu}, + {"set_arrow_tooltip_text",{P,S}}, + {"set_arrow_tooltip_markup",{P,S}}, +"GtkMenuToolButton"} + + function newMenuToolButton(object icn=0, object lbl=0) + if string(icn) then + icn = create(GtkImage,icn,1) + end if + if string(lbl) then + lbl = allocate_string(lbl,1) + end if + atom btn = gtk_func("gtk_menu_tool_button_new",{P,P},{icn,lbl}) + return btn + end function + +widget[GtkToggleToolButton] = {"gtk_toggle_tool_button", +{GtkToolButton,GtkToolItem,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GObject}, + {"new",{S},-routine_id("newToggleToolButton")}, + {"set_active",{P,B}}, + {"get_active",{P},B}, +"GtkToggleToolButton"} + + function newToggleToolButton(object x) + atom btn + if string(x) then + btn = gtk_func("gtk_toggle_tool_button_new_from_stock",{S},{x}) + elsif atom(x) then + btn = gtk_func("gtk_toggle_tool_button_new") + if class_id(btn) = GdkPixbuf then + set(btn,"image",create(GtkImage,btn)) + end if + end if + return btn + end function + +widget[GtkRadioToolButton] = {"gtk_radio_tool_button", +{GtkToggleToolButton,GtkToolButton,GtkToolItem,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GObject}, + {"new",{P},-routine_id("newRadioToolButton")}, + {"set_group",{P,P}}, + {"get_group",{P},P}, +"GtkRadioToolButton"} + + function newRadioToolButton(atom id) + if class_id(id) = GtkRadioToolButton then + return gtk_func("gtk_radio_tool_button_new_from_widget",{P},{id}) + else + return gtk_func("gtk_radio_tool_button_new",{P},{id}) + end if + end function + +widget[GtkSeparatorToolItem] = {"gtk_separator_tool_item", +{GtkToolItem,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"set_draw",{P,B}}, + {"get_draw",{P},B}, +"GtkSeparatorToolItem"} + +widget[GtkOverlay] = {"gtk_overlay", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"add_overlay",{P,P}}, + {"get_overlay_pass_through",{P,P},B}, -- 3.18 + {"set_overlay_pass_through",{P,P,B}}, -- 3.18 +"GtkOverlay"} + +widget[GtkScrollable] = {"gtk_scrollable", +{GObject}, + {"set_hadjustment",{P,P}}, + {"get_hadjustment",{P},P,0,GtkAdjustment}, + {"set_vadjustment",{P,P}}, + {"get_vadjustment",{P},P,0,GtkAdjustment}, + {"set_hscroll_policy",{P,I}}, + {"get_hscroll_policy",{P},I}, + {"set_vscroll_policy",{P,I}}, + {"get_vscroll_policy",{P},I}, + {"get_border",{P,P},B}, -- 3.16 +"GtkScrollable"} + +widget[GtkScrolledWindow] = {"gtk_scrolled_window", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{P,P},P}, + {"set_hadjustment",{P,P}}, + {"get_hadjustment",{P},P,0,GtkAdjustment}, + {"set_vadjustment",{P,P}}, + {"get_vadjustment",{P},P,0,GtkAdjustment}, + {"get_hscrollbar",{P},P,0,GtkWidget}, + {"get_vscrollbar",{P},P,0,GtkWidget}, + {"set_policy",{P,I,I}}, + {"get_policy",{P,I,I}}, + {"set_placement",{P,I}}, + {"unset_placement",{P}}, + {"set_shadow_type",{P,I}}, + {"get_shadow_type",{P},I}, + {"set_min_content_width",{P,I}}, + {"get_min_content_width",{P},I}, + {"set_min_content_height",{P,I}}, + {"get_min_content_height",{P},I}, + {"set_kinetic_scrolling",{P,B}}, + {"get_kinetic_scrolling",{P},B}, + {"set_capture_button_press",{P,B}}, + {"get_capture_button_press",{P},B}, + {"set_headers",{P,P}}, + {"add_with_viewport",{P,P}}, -- deprecated 3.8 + {"get_overlay_scrolling",{P},B}, -- 3.16 + {"set_overlay_scrolling",{P,B}}, -- 3.16 +"GtkScrolledWindow"} + +widget[GtkSidebar] = {"gtk_sidebar", -- 3.16 +{GtkBin,GtkContainer,GtkWidget,GObject}, + {"new",{},P}, + {"set_stack",{P,P}}, + {"get_stack",{P},P,0,GtkStack}, +"GtkSidebar"} + +widget[GtkTextBuffer] = {"gtk_text_buffer", +{GObject}, + {"new",{P},P}, + {"get_line_count",{P},I}, + {"get_char_count",{P},I}, + {"get_tag_table",{P},P,0,GtkTextTagTable}, + {"insert",{P,P,S,I}}, + {"insert_at_cursor",{P,S,I}}, + {"insert_interactive",{P,P,S,I,B},B}, + {"insert_interactive_at_cursor",{P,S,I,B},B}, + {"insert_range",{P,P,P,P}}, + {"insert_range_interactive",{P,P,P,P,B},B}, + {"insert_with_tags",{P,P,S,I,P,P}}, + {"insert_with_tags_by_name",{P,P,S,I,S}}, + {"insert_markup",{P,P,S,I}}, -- 3.16 + {"delete",{P,P,P}}, + {"delete_interactive",{P,P,P,B},B}, + {"backspace",{P,P,B,B},B}, + {"set_text",{P,P},-routine_id("setBufferText")}, + {"get_text",{P},-routine_id("getBufferText")}, + {"get_slice",{P,P,P,B},S}, + {"insert_pixbuf",{P,P,P}}, + {"insert_child_anchor",{P,P,P}}, + {"create_child_anchor",{P,P},P,0,GtkTextChildAnchor}, + {"create_mark",{P,S,P,B},P,0,GtkTextMark}, + {"move_mark",{P,P,P}}, + {"move_mark_by_name",{P,S,P}}, + {"add_mark",{P,P,P}}, + {"delete_mark",{P,P}}, + {"delete_mark_by_name",{P,S}}, + {"get_mark",{P,S},P,0,GtkTextMark}, + {"get_insert",{P},P,0,GtkTextMark}, + {"get_selection_bound",{P},P,0,GtkTextMark}, + {"get_selection_bounds",{P},-routine_id("getSelectionBounds")}, + {"get_has_selection",{P},B}, + {"place_cursor",{P,P}}, + {"select_range",{P,P,P}}, + {"apply_tag",{P,P,P,P}}, + {"remove_tag",{P,P,P,P}}, + {"apply_tag_by_name",{P,S,P,P}}, + {"remove_tag_by_name",{P,S,P,P}}, + {"remove_all_tags",{P,P,P}}, + {"create_tag",{P,S,S,S},P,0,GtkTextTag}, + {"get_iter_at_line_offset",{P,P,I,I}}, + {"get_iter_at_offset",{P,P,I}}, + {"get_iter_at_line",{P,P,I}}, + {"get_iter_at_line_index",{P,P,I,I}}, + {"get_iter_at_mark",{P,P,P}}, + {"get_iter_at_child_anchor",{P,P,P}}, + {"get_start_iter",{P,P}}, + {"get_end_iter",{P,P}}, + {"get_bounds",{P,P,P}}, + {"set_modified",{P,B}}, + {"get_modified",{P},B}, + {"delete_selection",{P,B,B},B}, + {"paste_clipboard",{P,P,P,B}}, + {"copy_clipboard",{P,P}}, + {"cut_clipboard",{P,P,B}}, + {"get_selection_bounds",{P,P,P},B}, + {"begin_user_action",{P}}, + {"end_user_action",{P}}, + {"add_selection_clipboard",{P,P}}, + {"remove_selection_clipboard",{P,P}}, + {"deserialize",{P,P,I,P,I,I,P},B}, + {"deserialize_set_can_create_tags",{P,I,B}}, + {"deserialize_get_can_create_tags",{P,I},B}, + {"get_copy_target_list",{P},P,0,GtkTargetList}, + {"get_deserialize_formats",{P,I},P}, + {"get_paste_target_list",{P},P,0,GtkTargetList}, + {"get_serialize_formats",{P,I},P}, + {"register_deserialize_format",{P,S,P,P,P},P}, + {"register_deserialize_tagset",{P,S},P}, + {"register_serialize_format",{P,S,P,P,P},P}, + {"register_serialize_tagset",{P,S},P}, + {"serialize",{P,P,P,P,P,I},I}, + {"unregister_deserialize_format",{P,P}}, + {"unregister_serialize_format",{P,P}}, + {"insert_markup",{P,P,S,I}}, -- 3.16 +"GtkTextBuffer"} + + export constant + fnBufStart = define_proc("gtk_text_buffer_get_start_iter",{P,P}), + fnBufEnd = define_proc("gtk_text_buffer_get_end_iter",{P,P}), + fnBufGet = define_func("gtk_text_buffer_get_text",{P,P,P,B},S), + fnBufSet = define_proc("gtk_text_buffer_set_text",{P,S,I}), + fnBufIns = define_func("gtk_text_buffer_get_insert",{P},P), + fnBufIter = define_proc("gtk_text_buffer_get_iter_at_mark",{P,P,P}), + fnBufBounds = define_func("gtk_text_buffer_get_selection_bounds",{P,P,P},B) + + function getBufferText(object buf) + atom start = allocate(64) c_proc(fnBufStart,{buf,start}) + atom fini = allocate(64) c_proc(fnBufEnd,{buf,fini}) + object result = c_func(fnBufGet,{buf,start,fini,1}) + return peek_string(result) + end function + + function getSelectionBounds(object buf) + atom start = allocate(100) + atom fini = allocate(100) + atom iter = allocate(100) + if c_func(fnBufBounds,{buf,start,fini}) then + return {start,fini} + else + start = c_func(fnBufIns,{buf}) + c_proc(fnBufIter,{buf,iter,start}) + return {iter,iter} + end if + end function + + function setBufferText(object buf, object txt) + object len + if atom(txt) then + len = peek_string(txt) + len = length(len) + else + len = length(txt) + txt = allocate_string(txt) + end if + c_proc(fnBufSet,{buf,txt,len}) + return 1 + end function + +widget[GtkClipboard] = {"gtk_clipboard", +{GObject}, + {"new",{I},-routine_id("newClipboard")}, + {"get_default",{P},P,0,GtkClipboard},-- 3.16 + {"get_for_display",{P,I},P,0,GtkClipboard}, + {"get_display",{P},P,0,GdkDisplay}, + {"set_with_data",{P,P,I,P,P,P},B}, + {"set_with_owner",{P,P,I,P,P,P},B}, + {"get_owner",{P},P,0,GObject}, + {"clear",{P}}, + {"set_text",{P,S,I}}, + {"set_image",{P,P}}, + {"request_contents",{P,I,P,P}}, + {"request_text",{P,P,P}}, + {"request_image",{P,P,P}}, + {"request_targets",{P,P,P}}, + {"request_rich_text",{P,P,P,P}}, + {"request_uris",{P,P,P}}, + {"wait_for_contents",{P,I},P,0,GtkSelectionData}, + {"wait_for_text",{P},S}, + {"wait_for_image",{P},P,0,GdkPixbuf}, + {"wait_for_rich_text",{P,P,I,I},I}, + {"wait_for_uris",{P},A}, + {"wait_is_text_available",{P},B}, + {"wait_is_image_available",{P},B}, + {"wait_is_rich_text_available",{P,P},B}, + {"wait_is_uris_available",{P},B}, + {"wait_for_targets",{P,P,I},B}, + {"wait_is_target_available",{P,I},B}, + {"set_can_store",{P,P,I}}, + {"store",{P}}, + {"get_selection",{P},P}, -- 3.22 +"GtkClipboard"} + + function newClipboard(integer i=0) -- just use default clipboard; + return gtk_func("gtk_clipboard_get",{I},{i}) + end function + +widget[GtkSelectionData] = {"gtk_selection_data", +{0}, + {"set",{P,I,I,S,I}}, + {"set_text",{P,S,I},B}, + {"get_text",{P},S}, + {"set_pixbuf",{P,P},B}, + {"get_pixbuf",{P},P,0,GdkPixbuf}, + {"set_uris",{P,S},B}, + {"get_uris",{P},A}, + {"get_targets",{P,P,I},B}, + {"targets_include_image",{P,B},B}, + {"targets_include_text",{P},B}, + {"targets_include_uri",{P},B}, + {"targets_include_rich_text",{P,P},B}, + {"get_selection",{P},P}, + {"get_data",{P},S}, + {"get_length",{P},I}, + {"get_data_with_length",{P,I},S}, + {"get_data_type",{P},I}, + {"get_display",{P},P,0,GdkDisplay}, + {"get_format",{P},I}, + {"get_target",{P},I}, +"GtkSelectionData"} + +widget[GtkCellArea] = {"gtk_cell_area", +{GtkCellLayout,GtkBuildable,GObject}, + {"add",{P,P}}, + {"remove",{P,P}}, + {"set_property",{P,P,S,P}}, + {"get_property",{P,P,S,P}}, + {"has_renderer",{P,P},B}, + {"foreach",{P,P}}, + {"foreach_alloc",{P,P,P,P,P,P,P}}, + {"event",{P,P,P,P,P,I},I}, + {"render",{P,P,P,P,P,P,I,B}}, + {"get_cell_allocation",{P,P,P,P,P,P}}, + {"get_cell_at_position",{P,P,P,P,I,I,P},P,0,GtkCellRenderer}, + {"create_context",{P},P,0,GtkCellAreaContext}, + {"copy_context",{P,P},P,0,GtkCellAreaContext}, + {"get_request_mode",{P},I}, + {"get_preferred_width",{P,P,P,I,I}}, + {"get_preferred_height_for_width",{P,P,P,I,I,I}}, + {"get_preferred_height",{P,P,P,I,I}}, + {"get_preferred_width_for_height",{P,P,P,I,I,I}}, + {"get_current_path",{P},S}, + {"apply_attributes",{P,P,P,B,B}}, + {"attribute_connect",{P,P,S,I}}, + {"attribute_disconnect",{P,P,S}}, + {"attribute_get_column",{P,P,S},I}, -- 3.14 + {"is_activatable",{P},B}, + {"activate",{P,P,P,P,I,B},B}, + {"activate_cell",{P,P,P,P,P,I},B}, + {"focus",{P,I},B}, + {"set_focus_cell",{P,P}}, + {"get_focus_cell",{P},P,0,GtkCellRenderer}, + {"add_focus_sibling",{P,P,P}}, + {"remove_focus_sibling",{P,P,P}}, + {"is_focus_sibling",{P,P,P},B}, + {"get_focus_siblings",{P,P},X,0,GList}, + {"get_focus_from_sibling",{P,P},P,0,GtkCellRenderer}, + {"get_edited_cell",{P},P,0,GtkCellRenderer}, + {"get_edit_widget",{P},P,0,GtkCellEditable}, + {"stop_editing",{P,B}}, + {"inner_cell_area",{P,P,P,P}}, + {"request_renderer",{P,P,P,P,I,I,I}}, + {"class_install_property",{P,I,P}}, + {"class_find_cell_property",{P,S},P}, + {"class_list_cell_properties",{P,I},P}, +"GtkCellArea"} + +widget[GtkCellAreaCell] = {"gtk_cell_area_cell", +{GtkCellArea}, + {"set_property",{P,P,S,P}}, + {"get_property",{P,P,S,P}}, +"GtkCellAreaCell"} + +widget[GtkCellAreaBox] = {"gtk_cell_area_box", +{GtkCellLayout,GtkCellArea,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"pack_start",{P,P,B,B,B}}, + {"pack_end",{P,P,B,B,B}}, + {"set_spacing",{P,I}}, + {"get_spacing",{P},I}, +"GtkCellAreaBox"} + +widget[GtkCellAreaContext] = {"gtk_cell_area_context", +{GObject}, + {"get_area",{P},P,0,GtkCellArea}, + {"allocate",{P,I,I}}, + {"reset",{P}}, + {"get_preferred_width",{P,I,I}}, + {"get_preferred_height",{P,I,I}}, + {"get_preferred_height_for_width",{P,I,I,I}}, + {"get_preferred_width_for_height",{P,I,I,I}}, + {"get_allocation",{P,I,I}}, + {"push_preferred_width",{P,I,I}}, + {"push_preferred_height",{P,I,I}}, +"GtkCellAreaContext"} + +widget[GtkCellEditable] = {"gtk_cell_editable", +{GtkWidget}, + {"start_editing",{P,P}}, + {"editing_done",{P}}, + {"remove_widget",{P}}, +"GtkCellEditable"} + +widget[GtkCellLayout] = {"gtk_cell_layout", +{GObject}, + {"pack_start",{P,P,B}}, + {"pack_end",{P,P,B}}, + {"get_area",{P},P,0,GtkCellArea}, + {"get_cells",{P},X,0,GList}, + {"reorder",{P,P,I}}, + {"clear",{P}}, + {"add_attribute",{P,P,S,I}}, + {"set_cell_data_func",{P,P,P,P,P}}, + {"clear_attributes",{P,P}}, +"GtkCellLayout"} + +widget[GtkCellRenderer] = {"gtk_cell_renderer", +{GObject}, + {"set_fixed_size",{P,I,I}}, + {"get_fixed_size",{P,I,I}}, + {"set_visible",{P,B}}, + {"get_visible",{P},B}, + {"set_sensitive",{P,B}}, + {"get_sensitive",{P},B}, + {"set_alignment",{P,F,F}}, + {"get_alignment",{P,F,F}}, + {"set_padding",{P,I,I}}, + {"get_padding",{P,I,I}}, + {"get_state",{P,P,I},I}, + {"is_activatable",{P},B}, + {"get_aligned_area",{P,P,I,P,P}}, + {"render",{P,P,P,P,P,I}}, + {"activate",{P,P,P,P,P,P,I},B}, + {"start_editing",{P,P,P,P,P,P,I},P,0,GtkCellEditable}, + {"stop_editing",{P,B}}, + {"get_preferred_height",{P,P,I,I}}, + {"get_preferred_width",{P,P,I,I}}, + {"get_preferred_height_for_width",{P,P,I,I,I}}, + {"get_preferred_width_for_height",{P,P,I,I,I}}, + {"get_preferred_size",{P,P,P,P}}, + {"get_request_mode",{P},I}, +"GtkCellRenderer"} + +-- Many properties exist for cell renderers, see GTK docs! + +widget[GtkCellRendererAccel] = {"gtk_cell_renderer_accel", +{GtkCellRendererText,GtkCellRenderer,GObject}, + {"new",{},P}, +"GtkCellRendererAccel"} + +widget[GtkCellRendererCombo] = {"gtk_cell_renderer_combo", +{GtkCellRendererText,GtkCellRenderer,GObject}, + {"new",{},P}, +"GtkCellRendererCombo"} + +widget[GtkCellRendererText] = {"gtk_cell_renderer_text", +{GtkCellRenderer,GObject}, + {"new",{},P}, + {"set_fixed_height_from_font",{P,I}}, +"GtkCellRendererText"} + +widget[GtkCellRendererPixbuf] = {"gtk_cell_renderer_pixbuf", +{GtkCellRenderer,GObject}, + {"new",{},P}, +"GtkCellRendererPixbuf"} + +widget[GtkCellRendererProgress] = {"gtk_cell_renderer_progress", +{GtkOrientable,GtkCellRenderer,GObject}, + {"new",{},P}, +"GtkCellRendererProgress"} + +widget[GtkCellRendererSpin] = {"gtk_cell_renderer_spin", +{GtkCellRendererText,GtkCellRenderer,GObject}, + {"new",{},P}, +"GtkCellRendererSpin"} + +widget[GtkCellRendererSpinner] = {"gtk_cell_renderer_spinner", +{GtkCellRenderer,GObject}, + {"new",{},P}, +"GtkCellRendererSpinner"} + +widget[GtkCellRendererToggle] = {"gtk_cell_renderer_toggle", +{GtkCellRenderer,GObject}, + {"new",{},P}, + {"set_radio",{P,B}}, + {"get_radio",{P},B}, + {"set_active",{P,B}}, + {"get_active",{P},B}, + {"set_activatable",{P,B}}, + {"get_activatable",{P},B}, +"GtkCellRendererToggle"} + +widget[GtkTreeModelFilter] = {"gtk_tree_model_filter", +{GtkTreeModel,GtkTreeDragSource,GObject}, + {"new",{P,P},P}, + {"set_visible_func",{P,P,P,P}}, + {"set_modify_func",{P,I,P,P,P,P}}, + {"set_visible_column",{P,I}}, + {"get_model",{P},P,0,GtkTreeModel}, + {"convert_child_iter_to_iter",{P,P,P},B}, + {"convert_iter_to_child_iter",{P,P,P},B}, + {"convert_child_path_to_path",{P,P},P,0,GtkTreePath}, + {"convert_path_to_child_path",{P,P},P,0,GtkTreePath}, + {"refilter",{P}}, + {"clear_cache",{P}}, +"GtkTreeModelFilter"} + +widget[GtkTreeModelSort] = {"gtk_tree_model_sort", +{GtkTreeSortable,GtkTreeModel,GtkTreeDragSource,GObject}, + {"new_with_model",{P},P}, + {"get_model",{P},P,0,GtkTreeModel}, + {"convert_child_path_to_path",{P,P},P,0,GtkTreePath}, + {"convert_child_iter_to_iter",{P,P,P},B}, + {"convert_path_to_child_path",{P,P},P,0,GtkTreePath}, + {"convert_iter_to_child_iter",{P,P,P}}, + {"reset_default_sort_func",{P}}, + {"clear_cache",{P}}, +"GtkTreeModelSort"} + +widget[GtkListStore] = {"gtk_list_store", +{GtkTreeModel,GtkTreeSortable,GtkTreeDragSource,GtkTreeDragDest,GtkBuildable,GObject}, + {"new",{P},-routine_id("newListStore")}, + {"clear",{P}}, + {"set_data",{P,P},-routine_id("ls_set_data")}, + {"get_data",{P},-routine_id("ls_get_data")}, + {"get_n_rows",{P},-routine_id("ls_get_n_rows")}, + {"get_n_cols",{P},-routine_id("ls_get_n_cols")}, + {"set_row_data",{P,I,P},-routine_id("ls_set_row_data")}, + {"get_row_data",{P,I},-routine_id("ls_get_row_data")}, + {"set_col_data",{P,I,I,P},-routine_id("ls_set_col_data")}, + {"get_col_data",{P,I,I},-routine_id("ls_get_col_data")}, + {"get_col_data_from_iter",{P,I,I},-routine_id("ls_get_col_data_from_iter")}, + {"remove_row",{P,I},-routine_id("ls_remove_row")}, + {"replace_row",{P,I,P},-routine_id("ls_replace_row")}, + {"insert_row",{P,I,P},-routine_id("ls_insert_row")}, + {"prepend_row",{P,P},-routine_id("ls_prepend_row")}, + {"append_row",{P,P},-routine_id("ls_append_row")}, + {"set_swap_rows",{P,I,I},-routine_id("ls_set_swap_rows")}, + {"set_move_before",{P,I,I},-routine_id("ls_set_move_before")}, + {"set_move_after",{P,I,I},-routine_id("ls_set_move_after")}, +"GtkListStore"} + +-- almost all calls to GtkListStore are overridden with Euphoria calls, +-- because the GTK versions are just too complex and tedious to set up, +-- making them impractical to use. + +constant + TM1 = define_func("gtk_tree_model_get_iter_first",{P,P},I), + TM2 = define_func("gtk_tree_model_iter_next",{P,P},I), + TM3 = define_func("gtk_tree_model_get_iter_from_string",{P,P,P},P), + TM4 = define_proc("gtk_tree_model_get",{P,P,I,P,I}), + TM5 = define_func("gtk_tree_model_get_column_type",{P,I},I), + LS0 = define_proc("gtk_list_store_clear",{P}), + LS1 = define_proc("gtk_list_store_insert",{P,P,I}), + LS2 = define_proc("gtk_list_store_append",{P,P}), + LS3 = define_proc("gtk_list_store_swap",{P,P,P}), + LS4 = define_proc("gtk_list_store_move_before",{P,P,P}), + LS5 = define_proc("gtk_list_store_move_after",{P,P,P}), + LS6 = define_func("gtk_list_store_iter_is_valid",{P,P},B) + + function newListStore(object params) + object proto = I & repeat(P,length(params)) + params = length(params) & params -- must build func params 'on the fly' + atom fn = define_func("gtk_list_store_new",proto,P) + return c_func(fn,params) + end function + + function ls_get_n_rows(object store) + return gtk_func("gtk_tree_model_iter_n_children",{P,P},{store,0}) + end function + + function ls_get_n_cols(object store) + return gtk_func("gtk_tree_model_get_n_columns",{P},{store}) + end function + + function ls_set_data(object store, object data) + atom iter = allocate(32,1) + for row = 1 to length(data) do + c_proc(LS1,{store,iter,length(data)}) -- new row + if string(data[row]) then + ls_set_row_data(store,row,{data[row]}) + else + ls_set_row_data(store,row,data[row]) + end if + end for + return 1 + end function + + function ls_set_row_data(atom store, integer row, object data) + integer max_col = ls_get_n_cols(store) + for col = 1 to math:min({length(data),max_col}) do + ls_set_col_data(store,row,col,data[col]) + end for + return 1 + end function + + function ls_set_col_data(object store, object row, integer col, object data) + integer max_col = ls_get_n_cols(store) + + if col < 1 or col > max_col then + crash("Invalid column #%d",col) + end if + + atom s = allocate_string(sprintf("%d",row-1),1) + atom iter = allocate(32,1) + if not c_func(TM3,{store,iter,s}) then + return -1 + end if + + object prototype = {P,P,I,P,I} + + integer col_type = c_func(TM5,{store,col-1}) + + switch col_type do + case gSTR then prototype = {P,P,I,S,I} + if atom(data) then data = sprintf("%2.2f",data) end if + case gDBL,gFLT then prototype = {P,P,I,D,I} + case gPIX then prototype = {P,P,I,P,I} + case gINT,gBOOL then prototype = {P,P,I,I,I} + case else + display("Error in []->ls_set_col_data: col [] type [] expects [], got []", + {get(store,"name"),col,col_type,vlookup(col_type,storage_types,1,2,"!"),data}) + ?1/0 + end switch + + if string(data) then + data = allocate_string(data) -- don't free these strings! + end if + + atom fn = define_proc("gtk_list_store_set",prototype) + object params = {store,iter,col-1,data,-1} + c_proc(fn,params) + + return 1 + end function + + function ls_get_data(object store) + object data = {} + for row = 1 to ls_get_n_rows(store) do + data = append(data,ls_get_row_data(store,row)) + end for + return data + end function + + function ls_get_row_data(object store, integer row) + object data = {} + + integer max_row = ls_get_n_rows(store) + if row > max_row then return -1 end if + + integer max_col = ls_get_n_cols(store) + for i = 1 to max_col do + data = append(data,ls_get_col_data(store,row,i)) + end for + if max_col = 1 then + return data[1] else return data + end if + end function + + function ls_get_col_data(atom store, integer row, integer col) + atom x = allocate(32,1) + object result + + ifdef LISTSTORE then + display("Get Col Data ~ row [] col []",{row,col}) + end ifdef + + integer col_type = c_func(TM5,{store,col-1}) + ifdef BITS64 then + poke8(x,col_type) + elsedef + poke4(x,col_type) + end ifdef + + atom iter = allocate(32,1) + + c_func(TM3,{store,iter,allocate_string(sprintf("%d",row-1),1)}) + if gtk_func("gtk_list_store_iter_is_valid",{P,P},{store,iter}) = 0 then + display("Error in ls_get_col_data 2 ") abort(0) end if + + c_proc(TM4,{store,iter,col-1,x,-1}) + if gtk_func("gtk_list_store_iter_is_valid",{P,P},{store,iter}) = 0 then + display("Error in ls_get_col_data 3") abort(0) end if + + switch col_type do + case gSTR then + ifdef BITS64 then -- thanks pete eberlein + result = peek8u(x) + elsedef + result = peek4u(x) + end ifdef + if result > 0 then + result = peek_string(result) + end if + case gINT then result = peek4u(x) + case gBOOL then result = peek(x) + case gDBL then result = float64_to_atom(peek({x,8})) + case gFLT then result = float32_to_atom(peek({x,4})) + case gPIX then result = peek4u(x) + case else display("Error in ls_get_col_data 4") abort(0) + end switch + ifdef LISTSTORE then + display("Result []",{result}) + end ifdef + return result + end function + + function ls_get_col_data_from_iter(atom store, atom iter, integer col) + atom x = allocate(64,1) + object result + + ifdef LISTSTORE then + display("Get Col Data from Iter ~ store [] iter [] col []\n",{store,iter,col}) + end ifdef + + integer col_type = c_func(TM5,{store,col-1}) + ifdef BITS64 then + poke8(x,col_type) + elsedef + poke4(x,col_type) + end ifdef + + if gtk_func("gtk_list_store_iter_is_valid",{P,P},{store,iter}) = 0 then + display("Error in ls_get_col_datafromiter 1 ") abort(0) end if + + c_proc(TM4,{store,iter,col-1,x,-1}) + + if gtk_func("gtk_list_store_iter_is_valid",{P,P},{store,iter}) = 0 then + display("Error in ls_get_col_datafromiter 2 ") abort(0) end if + + switch col_type do + case gSTR then + ifdef BITS64 then -- thanks pete eberlein + result = peek8u(x) + elsedef + result = peek4u(x) + end ifdef + if result > 0 then + result = peek_string(result) + end if + case gINT then result = peek4u(x) + case gBOOL then result = peek(x) + case gDBL then result = float64_to_atom(peek({x,8})) + case gFLT then result = float32_to_atom(peek({x,4})) + case gPIX then result = peek4u(x) + case else display("Error in ls_get_col_datafromiter 3") abort(0) + end switch + ifdef LISTSTORE then + display("Result []",{result}) + end ifdef + return result + end function + + function ls_insert_row(object store, object data, integer pos) + object tmp = ls_get_data(store) + tmp = insert(tmp,data,pos) + set(store,"clear") + ls_set_data(store,tmp) + return tmp + end function + + function ls_append_row(atom store, object data) + object tmp = ls_get_data(store) + tmp = append(tmp,data) + set(store,"clear") + set(store,"data",tmp) + return tmp + end function + + function ls_prepend_row(atom store, object data) + object tmp = ls_get_data(store) + tmp = prepend(tmp,data) + set(store,"clear") + set(store,"data",tmp) + return tmp + end function + + function ls_remove_row(atom store, integer row) + object tmp = ls_get_data(store) + tmp = remove(tmp,row) + set(store,"clear") + ls_set_data(store,tmp) + return tmp + end function + + function ls_replace_row(atom store, object data, integer row) + object tmp = ls_get_data(store) + set(store,"clear") + tmp = replace(tmp,{data},row) + ls_set_data(store,tmp) + return tmp + end function + + function ls_set_swap_rows(atom store, integer row_a, integer row_b) + if get(store,"is sorted") then + Warn(0,,"Can't move items in a sorted list!") + return -1 + end if + atom iter_a = allocate(32,1), iter_b = allocate(32,1) + c_func(TM3,{store,iter_a,allocate_string(sprintf("%d",row_a-1),1)}) + c_func(TM3,{store,iter_b,allocate_string(sprintf("%d",row_b-1),1)}) + c_proc(LS3,{store,iter_a,iter_b}) + return get(store,"data") + end function + + function ls_set_move_before(atom store, integer row_a, integer row_b) + if get(store,"is sorted") then + Error(0,,"Can't move items in a sorted list!") + return -1 + end if + atom iter_a = allocate(32,1), iter_b = allocate(32,1) + c_func(TM3,{store,iter_a,allocate_string(sprintf("%d",row_a-1),1)}) + c_func(TM3,{store,iter_b,allocate_string(sprintf("%d",row_b-1),1)}) + c_proc(LS4,{store,iter_b,iter_a}) + return get(store,"data") + end function + + function ls_set_move_after(atom store, integer row_a, integer row_b) + if get(store,"is sorted") then + Error(0,,"Can't move items in a sorted list!") + return -1 + end if + atom iter_a = allocate(32,1), iter_b = allocate(32,1) + c_func(TM3,{store,iter_a,allocate_string(sprintf("%d",row_a-1),1)}) + c_func(TM3,{store,iter_b,allocate_string(sprintf("%d",row_b-1),1)}) + c_proc(LS5,{store,iter_b,iter_a}) + return get(store,"data") + end function + +widget[GtkTreeStore] = {"gtk_tree_store", +{GtkTreeModel,GtkTreeDragSource,GtkTreeDragDest,GtkTreeSortable,GtkBuildable,GObject}, + {"new",{P},-routine_id("newTreeStore")}, + {"get_n_rows",{P},-routine_id("ts_get_n_rows")}, + {"get_n_cols",{P},-routine_id("ts_get_n_cols")}, + {"get_data",{P},-routine_id("ts_get_data")}, + {"set_data",{P,P},-routine_id("ts_set_data")}, + {"set_row_data",{P,P,P},-routine_id("ts_set_row_data")}, + {"remove_row",{P,I},-routine_id("ts_remove_row")}, + {"insert_row",{P,P,P,I}}, + {"insert_before",{P,P,P,P}}, + {"insert_after",{P,P,P,P}}, + {"prepend",{P,P,P}}, + {"append",{P,P,P}}, + {"is_ancestor",{P,P,P},B}, + {"iter_depth",{P,P},I}, + {"clear",{P}}, + {"swap",{P,P,P}}, + {"move_before",{P,P,P}}, + {"move_after",{P,P,P}}, +"GtkTreeStore"} + + function newTreeStore(object params) + object proto = I & repeat(P,length(params)) + params = length(params) & params -- must build func params 'on the fly' + atom fn = define_func("gtk_tree_store_new",proto,P) + return c_func(fn,params) + end function + + function ts_get_n_rows(object store) + return gtk_func("gtk_tree_model_iter_n_children",{P,P},{store,0}) + end function + + function ts_get_n_cols(object store) + return gtk_func("gtk_tree_model_get_n_columns",{P},{store}) + end function + + function ts_set_data(object store, object data) + atom iter = allocate(32,1) + for row = 1 to length(data) do + gtk_proc("gtk_tree_store_append",{P,P,P},{store,iter,0}) + ts_set_row_data(store,data[row],iter) + end for + return 1 + end function + + constant TSA = define_proc("gtk_tree_store_append",{P,P,P}) + + -- the following should really be recursive, but that's too complicated + -- for me to figure out! Anyway, four deep should be enough. + + function ts_set_row_data(atom store, object data, object parent = 0) + atom iter1 = allocate(32,1) + atom iter2 = allocate(32,1) + atom iter3 = allocate(32,1) + atom iter4 = allocate(32,1) + for i = 1 to length(data) do + if string(data[i]) then + ts_set_row_col_data(store,parent,i,data[i]) + else + for j = 1 to length(data[i]) do + if string(data[i][j]) then + c_proc(TSA,{store,iter1,parent}) + ts_set_row_col_data(store,iter1,1,data[i][j]) + else + for k = 1 to length(data[i][j]) do + if string(data[i][j][k]) then + c_proc(TSA,{store,iter2,iter1}) + ts_set_row_col_data(store,iter2,1,data[i][j][k]) + else + for l = 1 to length(data[i][j][k]) do + if string(data[i][j][k][l]) then + c_proc(TSA,{store,iter3,iter2}) + ts_set_row_col_data(store,iter3,1,data[i][j][k][l]) + else + for m = 1 to length(data[i][j][k][l]) do + c_proc(TSA,{store,iter4,iter3}) + ts_set_row_col_data(store,iter4,1,data[i][j][k][l][m]) + end for + end if + end for + end if + end for + end if + end for + end if + end for + return 1 + end function + + function ts_set_row_col_data(object store, object iter, integer col, object item) + integer max_col = ts_get_n_cols(store) + if col < 1 or col > max_col then + crash("Invalid column #%d",col) + end if + + object prototype = {P,P,I,P,I} + + integer col_type + + col_type = c_func(TM5,{store,col-1}) + switch col_type do + case gDBL,gFLT then prototype = {P,P,I,D,I} + case gSTR, gPIX then prototype = {P,P,I,P,I} + case gBOOL,gINT then prototype = {P,P,I,I,I} + if atom(item) then item = sprintf("%g",item) end if + case else Warn(,,"Unknown column type", + "Expecting gSTR, gBOOL, gINT, gDBL, gFLT, or gPIX") + end switch + + if string(item[1]) then item = item[1] end if + if string(item) then item = allocate_string(item,1) end if + + atom fn = define_proc("gtk_tree_store_set",prototype) + object params = {store,iter,col-1,item,-1} + c_proc(fn,params) + + return iter + end function + + function ts_get_data(atom store) + object rowdata = {} + object column = {} + for row = 1 to ts_get_n_rows(store) do + for col = 1 to ts_get_n_cols(store) do + column = append(column,get(store,"col data",col)) + end for + rowdata = append(rowdata,column) + column = {} + end for + return rowdata + end function + + function ts_remove_row(atom store, integer row) + object tmp = get(store,"data") + tmp = remove(tmp,row) + set(store,"data",tmp) + return tmp + end function + +widget[GtkTreeDragSource] = {"gtk_tree_drag_source", +{0}, +"GtkTreeDragSource"} + +widget[GtkTreeDragDest] = {"gtk_tree_drag_dest", +{0}, +"GtkTreeDragDest"} + +widget[GtkTreePath] = {"gtk_tree_path", +{GObject}, + {"new",{P},-routine_id("newTreePath")}, + {"to_string",{P},S}, + {"to_integer",{P},-routine_id("tp_to_integer")}, + {"new_first",{},P,0,GtkTreePath}, + {"append_index",{P,I}}, + {"prepend_index",{P,I}}, + {"get_depth",{P},I}, + {"get_indices",{P},A}, + {"get_indices_with_depth",{P,I},A}, + {"free",{P}}, + {"copy",{P},P,0,GtkTreePath}, + {"compare",{P,P},I}, + {"next",{P}}, + {"prev",{P},B}, + {"up",{P},B}, + {"down",{P}}, + {"is_ancestor",{P,P},B}, + {"is_descendant",{P,P},B}, +"GtkTreePath"} + + function newTreePath(object x=0) + if atom(x) and x > 0 then + x = sprintf("%d",x-1) + end if + if string(x) then + x = allocate_string(x,1) + end if + if x > 0 then + return gtk_func("gtk_tree_path_new_from_string",{P},{x}) + else + return gtk_func("gtk_tree_path_new",{},{}) + end if + end function + + function tp_to_integer(object x) + integer n = to_number(gtk_str_func("gtk_tree_path_to_string",{P},{x})) + return n+1 + end function + +widget[GtkTreeRowReference] = {"gtk_tree_row_reference", +{GObject}, + {"new",{P,P},P,0,GtkTreeRowReference}, + {"get_model",{P},P,0,GtkTreeModel}, + {"get_path",{P},P,0,GtkTreePath}, + {"valid",{P},B}, + {"free",{P}}, + {"copy",{P},P,0,GtkTreeRowReference}, + {"inserted",{P,P}}, + {"deleted",{P,P}}, + {"reordered",{P,P,P,A}}, +"GtkTreeRowReference"} + +widget[GtkTreeIter] = {"gtk_tree_iter", +{GObject}, + {"new",{},-routine_id("newTreeIter")}, + {"copy",{P},P,0,GtkTreeIter}, + {"free",{P}}, +"GtkTreeIter"} + + function newTreeIter() + return allocate(64) -- keep; + end function + +widget[GtkTreeModel] = {"gtk_tree_model", +{GObject}, + {"get_flags",{P},I}, + {"get_n_columns",{P},I}, + {"get_column_type",{P,I},I}, + {"get_iter",{P,P,P},B}, + {"get_iter_first",{P,P},B}, + {"get_path",{P,P},P,0,GtkTreePath}, + {"get_value",{P,P,I},-routine_id("tm_get_value")}, + {"set_value",{P,I,I,P},-routine_id("tm_set_value")}, + {"iter_next",{P,P},B}, + {"iter_previous",{P,P},B}, + {"iter_children",{P,P,P},B}, + {"iter_has_child",{P,P},B}, + {"iter_n_children",{P,P},I}, + {"iter_nth_child",{P,P,P,I},B}, + {"iter_parent",{P,P,P},B}, + {"get_string_from_iter",{P,P},-routine_id("tm_get_string_from_iter")}, + {"ref_node",{P,P}}, + {"unref_node",{P,P}}, + {"foreach",{P,P,P}}, + {"n_rows",{P},-routine_id("tm_get_n_rows")}, + {"row_changed",{P,P,P}}, + {"row_inserted",{P,P,P}}, + {"row_has_child_toggled",{P,P,P}}, + {"row_deleted",{P,P}}, + {"rows_reordered",{P,P,P,P}}, + {"get_iter_n",{P,I},-routine_id("tm_get_iter_n")}, + {"get_iter_from_string",{P,P},-routine_id("tm_get_iter_from_string")}, + {"get_iter_from_path",{P,P},-routine_id("tm_get_iter_from_path")}, + {"get_col_value",{P,P,I},-routine_id("tm_get_col_value")}, + {"get_row_values",{P,P},-routine_id("tm_get_row_values")}, + {"get_col_data",{P,P,P},-routine_id("tm_get_col_data")}, + {"get_row_data",{P,I},-routine_id("tm_get_row_values")}, +"GtkTreeModel"} + + constant + fntmget = define_proc("gtk_tree_model_get_value",{P,P,I,P}), + fncoltype = define_func("gtk_tree_model_get_column_type",{P,I},I), + gtvfn = define_proc("gtk_tree_model_get",{P,P,I,P,I}), + tmncol = define_func("gtk_tree_model_get_n_columns",{P},I) + + function tm_get_n_rows(atom model) + atom fn = define_func("gtk_tree_model_iter_n_children",{P,P},I) + return c_func(fn,{model,0}) + end function + + function tm_get_string_from_iter(atom model, atom iter) + atom fn = define_func("gtk_tree_model_get_string_from_iter",{P,P},P) + return peek_string(c_func(fn,{model,iter})) + end function + + function tm_get_iter_from_string(atom model, object str) + atom iter = allocate(64) + atom fn = define_func("gtk_tree_model_get_iter_from_string",{P,P,P},P) + if string(str) then str = allocate_string(str,1) end if + if c_func(fn,{model,iter,str}) then + return iter + end if + return 0 + end function + + function tm_get_iter_n(atom model, integer path) + return tm_get_iter_from_string(model,sprintf("%d",path-1)) + end function + + function tm_get_iter_from_path(atom model, object path) + return tm_get_iter_from_string(model,peek_string(path)) + end function + + function tm_get_value(atom mdl, atom iter, integer col) + atom x = allocate(64,1) + integer ct = c_func(fncoltype,{mdl,col-1}) + object result + + ifdef BITS64 then + poke8(x,ct) + elsedef + poke4(x,ct) + end ifdef + + c_proc(gtvfn,{mdl,iter,col-1,x,-1}) + switch ct do + case gSTR then + ifdef BITS64 then -- thanks pete eberlein + result = peek8u(x) + elsedef + result = peek4u(x) + end ifdef + if result > 0 then + return peek_string(result) + else + return sprintf("%d",result) + end if + case gBOOL,gINT then return peek4u(x) + case gFLT then return float32_to_atom(peek({x,4})) + case gPIX then return peek4u(x) + case else return sprintf("%d",x) + end switch + return sprintf("Oops %d",ct) + end function + + function tm_get_row_values(atom mdl, atom iter) + integer ncols = c_func(tmncol,{mdl}) + object results = repeat(0,ncols) + for n = 1 to ncols do + results[n] = tm_get_value(mdl,iter,n) + end for + return results + end function + + function tm_get_col_value(atom mdl, integer row, integer col) + atom iter = allocate(32,1) + object data = tm_get_row_values(mdl,iter) + return data[col] + end function + + function tm_set_col_value(atom mdl, integer row, integer col, object data) + atom iter = tm_get_iter_n(mdl,row) + atom fn = define_proc("gtk_list_store_set",{P,P,I,P,I}) + if string(data) then data = allocate_string(data,1) end if + c_proc(fn,{mdl,iter,col-1,data,-1}) + return 1 + end function + + function tm_get_col_data(atom mdl, integer row, integer col) + atom iter = tm_get_iter_n(mdl,row) + object data = tm_get_row_values(mdl,iter) + return data[col] + end function + +widget[GtkTreeSortable] = {"gtk_tree_sortable", +{GtkTreeModel,GObject}, + {"sort_column_changed",{P}}, + {"set_sort_column_id",{P,I,I}}, + {"get_sort_column_id",{P},-routine_id("ts_get_sort_col_id")}, + {"get_sort_order",{P},-routine_id("ts_get_sort_order")}, + {"is_sorted",{P},-routine_id("ts_is_sorted")}, + {"set_sort_func",{P,I,P,P,P}}, + {"set_default_sort_func",{P,P,P,P}}, + {"has_default_sort_func",{P},B}, +"GtkTreeSortable"} + + function ts_is_sorted(atom mdl) + return gtk_func("gtk_tree_sortable_get_sort_column_id",{P,P,P},{mdl,0,0}) + end function + + function ts_get_sort_col_id(atom mdl) + integer col = allocate(32,1), order = allocate(32,1) + if gtk_func("gtk_tree_sortable_get_sort_column_id",{P,P,P},{mdl,col,order}) then + return peek4u(col)+1 + else + return -1 + end if + end function + + function ts_get_sort_order(atom mdl) + integer col = allocate(32,1), order = allocate(32,1) + if gtk_func("gtk_tree_sortable_get_sort_column_id",{P,P,P},{mdl,col,order}) then + return peek4u(order) + else + return -1 + end if + end function + +widget[GtkViewport] = {"gtk_viewport", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkScrollable,GObject}, + {"new",{P,P},P}, + {"set_shadow_type",{P,I}}, + {"get_shadow_type",{P},I}, + {"get_bin_window",{P},P,0,GdkWindow}, + {"get_view_window",{P},P,0,GdkWindow}, +"GtkViewport"} + +widget[GtkAppChooserWidget] = {"gtk_app_chooser_widget", +{GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GtkAppChooser,GObject}, + {"new",{S},P}, + {"set_show_default",{P,B}}, + {"get_show_default",{P},B}, + {"set_show_recommended",{P,B}}, + {"get_show_recommended",{P},B}, + {"set_show_fallback",{P,B}}, + {"get_show_fallback",{P},B}, + {"set_show_other",{P,B}}, + {"get_show_other",{P},B}, + {"set_show_all",{P,B}}, + {"get_show_all",{P},B}, + {"set_default_text",{P,S}}, + {"get_default_text",{P},S}, +"GtkAppChooserWidget"} + +widget[GtkVolumeButton] = {"gtk_volume_button", +{GtkScaleButton,GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GtkActionable,GObject}, + {"new",{},P}, +"GtkVolumeButton"} + +widget[GtkColorChooserWidget] = {"gtk_color_chooser_widget", +{GtkColorChooser,GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, +"GtkColorChooserWidget"} + +widget[GtkColorChooser] = {"gtk_color_chooser", +{GObject}, + {"set_rgba",{P,P},-routine_id("cc_set_rgba")}, + {"get_rgba",{P,I},-routine_id("cc_get_rgba")}, + {"set_use_alpha",{P,B},-routine_id("cc_set_alpha")}, + {"get_use_alpha",{P},-routine_id("cc_get_alpha")}, + {"add_palette",{P,I,I,I,A}}, +"GtkColorChooser"} + + function cc_set_rgba(atom x, object c) + if string(c) then + c = to_rgba(c) + else + c = to_rgba(text:format("#[X]",c)) + end if + gtk_proc("gtk_color_chooser_set_rgba",{P,P},{x,c}) + return 1 + end function + + function cc_get_rgba(atom x, integer fmt) + atom fn = define_proc("gtk_color_chooser_get_rgba",{P,P}) + atom rgba = allocate(32,1) + c_proc(fn,{x,rgba}) + object c = gtk_func("gdk_rgba_to_string",{P},{rgba}) + return fmt_color(c,fmt) + end function + + function cc_set_alpha(atom x, integer b) + gtk_proc("gtk_color_chooser_set_use_alpha",{P,B},{x,b}) + return 1 + end function + + function cc_get_alpha(atom x) + atom fn = define_func("gtk_color_chooser_get_use_alpha",{P},B) + return c_func(fn,{x}) + end function + +widget[GtkColorSelection] = {"gtk_color_selection", -- deprecated +{GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"set_has_opacity_control",{P,B}}, + {"get_has_opacity_control",{P},B}, + {"set_has_palette",{P,B}}, + {"get_has_palette",{P},B}, + {"set_current_rgba",{P,S},-routine_id("cs_set_current_rgba")}, + {"get_current_rgba",{P,I},-routine_id("cs_get_current_rgba")}, + {"set_current_alpha",{P,I}}, + {"get_current_alpha",{P},I}, + {"set_previous_rgba",{P,S},-routine_id("cs_set_previous_rgba")}, + {"get_previous_rgba",{P,I},-routine_id("cs_get_previous_rgba")}, + {"set_previous_alpha",{P,I}}, + {"get_previous_alpha",{P},I}, + {"is_adjusting",{P},B}, +"GtkColorSelection"} + +------------------------------------------------------------------------ +-- following color functions make using RGB colors much easier, +-- converting automatically between various color notations +------------------------------------------------------------------------ + + function cs_set_current_rgba(atom x, object c) + c =peek_string(c) + gtk_proc("gtk_color_selection_set_current_rgba",{P,P},{x,to_rgba(c)}) + return 1 + end function + + function cs_set_previous_rgba(atom x, object c) + c = peek_string(c) + gtk_proc("gtk_color_selection_set_previous_rgba",{P,P},{x,to_rgba(c)}) + return 1 + end function + + function cs_get_current_rgba(atom x, integer fmt=0) + atom rgba = allocate(32,1) + atom fn = define_proc("gtk_color_selection_get_current_rgba",{P,P}) + c_proc(fn,{x,rgba}) + object c = gtk_func("gdk_rgba_to_string",{P},{rgba}) + return fmt_color(c,fmt) + end function + + function cs_get_previous_rgba(atom x, integer fmt=0) + atom rgba = allocate(32,1) + atom fn = define_proc("gtk_color_selection_get_previous_rgba",{P,P}) + c_proc(fn,{x,rgba}) + object c = gtk_func("gdk_rgba_to_string",{rgba}) + return fmt_color(c,fmt) + end function + +widget[GtkNativeDialog] = {"gtk_native_dialog", +{}, + {"show",{P}}, + {"hide",{P}}, + {"destroy",{P}}, + {"get_visible",{P},B}, + {"set_modal",{P,B}}, + {"get_modal",{P},B}, + {"set_title",{P,S}}, + {"get_title",{P},S}, + {"set_transient_for",{P,P}}, + {"get_transient_for",{P},P}, + {"run",{P}}, +"GtkNativeDialog"} + +widget[GtkFileChooserNative] = {"gtk_file_chooser_native", +{}, + {"new",{S,P,I,S,S},P}, + {"get_accept_label",{P},S}, + {"set_accept_label",{P,S}}, + {"get_cancel_label",{P},S}, + {"set_cancel_label",{P,S}}, +"GtkFileChooserNative"} + +widget[GtkFileChooser] = {"gtk_file_chooser", +{GtkWidget}, + {"set_action",{P,I}}, + {"get_action",{P},I}, + {"set_local_only",{P,B}}, + {"get_local_only",{P},B}, + {"set_select_multiple",{P,B}}, + {"get_select_multiple",{P},B}, + {"set_show_hidden",{P,B}}, + {"get_show_hidden",{P},B}, + {"set_do_overwrite_confirmation",{P,B}}, + {"get_do_overwrite_confirmation",{P},B}, + {"set_create_folders",{P,B}}, + {"get_create_folders",{P},B}, + {"get_current_name",{P},S}, --GTK3.10 + {"set_current_name",{P,S}}, + {"set_filename",{P,S}}, + {"get_filename",{P},S}, + {"get_filenames",{P},A,0,GSList}, + {"select_filename",{P,S}}, + {"unselect_filename",{P},S}, + {"select_all",{P}}, + {"unselect_all",{P}}, + {"set_current_folder",{P,S}}, + {"get_current_folder",{P},S}, + {"set_uri",{P,S}}, + {"get_uri",{P},S}, + {"select_uri",{P,S}}, + {"unselect_uri",{P,S}}, + {"get_uris",{P},A,0,GSList}, + {"set_current_folder_uri",{P,S}}, + {"get_current_folder_uri",{P},S}, + {"set_preview_widget",{P,P}}, + {"get_preview_widget",{P},P,0,GtkWidget}, + {"set_preview_widget_active",{P,B}}, + {"get_preview_widget_active",{P},B}, + {"set_use_preview_label",{P,B}}, + {"get_use_preview_label",{P},B}, + {"get_preview_filename",{P},S}, + {"get_preview_uri",{P},S}, + {"set_extra_widget",{P,P}}, + {"get_extra_widget",{P},P,0,GtkWidget}, + {"add_filter",{P,P}}, + {"remove_filter",{P,P}}, + {"list_filters",{P},X,0,GSList}, + {"set_filter",{P,P}}, + {"get_filter",{P},P,0,GtkFileFilter}, + {"add_shortcut_folder",{P,S,P},B}, + {"remove_shortcut_folder",{P,S,P},B}, + {"list_shortcut_folders",{P},A,0,GSList}, + {"add_shortcut_folder_uri",{P,S,P},B}, + {"remove_shortcut_folder_uri",{P,S,P},B}, + {"list_shortcut_folder_uris",{P},A,0,GSList}, + {"get_current_folder_file",{P},P,0,GFile}, + {"get_file",{P},P,0,GFile}, + {"get_files",{P},X,0,GFile}, + {"get_preview_file",{P},P,0,GFile}, + {"select_file",{P,P,P},B}, + {"set_current_folder_file",{P,P,P},B}, + {"set_file",{P,P,P},B}, + {"unselect_file",{P,P}}, +"GtkFileChooser"} + +widget[GtkFileChooserButton] = {"gtk_file_chooser_button", +{GtkFileChooser,GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{S,I},P}, + {"new_with_dialog",{P},P}, + {"set_title",{P,S}}, + {"get_title",{P},S}, + {"set_width_chars",{P,I}}, + {"get_width_chars",{P},I}, + {"set_focus_on_click",{P,B}}, + {"get_focus_on_click",{P},B}, +"GtkFileChooserButton"} + +widget[GtkFileChooserWidget] = {"gtk_file_chooser_widget", +{GtkFileChooser,GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{I},P}, +"GtkFileChooserWidget"} + +widget[GtkFileFilter] = {"gtk_file_filter", +{GtkBuildable,GObject}, + {"new",{},P}, + {"set_name",{P,S}}, + {"get_name",{P},S}, + {"add_mime_type",{P,S}}, + {"add_pattern",{P,S}}, + {"add_pixbuf_formats",{P}}, + {"add_custom",{P,I,P,P,P}}, + {"get_needed",{P},I}, + {"filter",{P,P},B}, +"GtkFileFilter"} + +widget[GtkFontChooser] = {"gtk_font_chooser", +{GObject}, + {"get_font_family",{P},P,0,PangoFontFamily}, + {"get_font_face",{P},P,0,PangoFontFace}, + {"get_font_size",{P},I}, + {"set_font",{P,S}}, + {"get_font",{P},S}, + {"set_font_desc",{P,P}}, + {"get_font_desc",{P},P,0,PangoFontDescription}, + {"set_preview_text",{P,S}}, + {"get_preview_text",{P},S}, + {"set_show_preview_entry",{P,B}}, + {"get_show_preview_entry",{P},B}, + {"set_filter_func",{P,P,P,P}}, + {"get_font_map",{P},P,0,PangoFontMap}, -- 3.18 + {"set_font_map",{P,P}}, -- 3.18 +"GtkFontChooser"} + +widget[GtkFontChooserWidget] = {"gtk_font_chooser_widget", +{GtkFontChooser,GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, +"GtkFontChooserWidget"} + +widget[GtkInfoBar] = {"gtk_info_bar", +{GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"add_action_widget",{P,P,I}}, + {"add_button",{P,S,I},P,0,GtkButton}, + {"set_response_sensitive",{P,I,B}}, + {"set_default_response",{P,I}}, + {"response",{P,I}}, + {"set_message_type",{P,I}}, + {"get_message_type",{P},I}, + {"get_action_area",{P},P,0,GtkWidget}, + {"get_content_area",{P},P,0,GtkWidget}, + {"set_show_close_button",{P,B}}, -- 3.10 + {"get_show_close_button",{P},B}, -- 3.10 +"GtkInfoBar"} + +widget[GtkRecentChooser] = {"gtk_recent_chooser", +{GObject}, + {"set_show_private",{P,B}}, + {"get_show_private",{P},B}, + {"set_show_not_found",{P,B}}, + {"get_show_not_found",{P},B}, + {"set_show_icons",{P,B}}, + {"get_show_icons",{P},B}, + {"set_select_multiple",{P,B}}, + {"get_select_multiple",{P},B}, + {"set_local_only",{P,B}}, + {"get_local_only",{P},B}, + {"set_limit",{P,I}}, + {"get_limit",{P},I}, + {"set_show_tips",{P,B}}, + {"get_show_tips",{P},B}, + {"set_sort_type",{P,I}}, + {"get_sort_type",{P},I}, + {"set_sort_func",{P,P,P,P}}, + {"set_current_uri",{P,S,P},B}, + {"get_current_uri",{P},S}, + {"get_current_item",{P},P,0,GtkRecentInfo}, + {"select_uri",{P,S,P},B}, + {"unselect_uri",{P,S}}, + {"select_all",{P}}, + {"unselect_all",{P}}, + {"get_items",{P},A,0,GSList}, + {"get_uris",{P},A}, + {"add_filter",{P,P}}, + {"remove_filter",{P,P}}, + {"list_filters",{P},X,0,GSList}, + {"set_filter",{P,P}}, + {"get_filter",{P},P,0,GtkRecentFilter}, +"GtkRecentChooser"} + +widget[GtkRecentChooserWidget] = {"gtk_recent_chooser_widget", +{GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GtkRecentChooser,GObject}, + {"new",{P},-routine_id("newRecentChooserWidget")}, +"GtkRecentChooserWidget"} + + function newRecentChooserWidget(atom x=0) + if class_id(x) = GtkRecentManager then + return gtk_func("gtk_recent_chooser_widget_new_for_manager",{P},{x}) + else + return gtk_func("gtk_recent_chooser_widget_new") + end if + end function + +widget[GtkStatusbar] = {"gtk_statusbar", +{GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"get_context_id",{P,S},I}, + {"push",{P,I,S},I}, + {"pop",{P,I}}, + {"remove",{P,I,I}}, + {"remove_all",{P,I}}, + {"get_message_area",{P},P}, +"GtkStatusBar"} + +widget[GtkFixed] = {"gtk_fixed", +{GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"put",{P,P,I,I}}, + {"move",{P,P,I,I}}, +"GtkFixed"} + +widget[GtkGrid] = {"gtk_grid", +{GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"attach",{P,P,I,I,I,I}}, + {"attach_next_to",{P,P,P,I,I,I}}, + {"get_child_at",{P,I,I},P,0,GtkWidget}, + {"insert_row",{P,I}}, + {"remove_row",{P,I}}, --3.10 + {"insert_column",{P,I}}, + {"remove_column",{P,I}}, --3.10 + {"insert_next_to",{P,P,I}}, + {"set_row_homogeneous",{P,B}}, + {"get_row_homogeneous",{P},B}, + {"set_column_homogeneous",{P,B}}, + {"get_column_homogeneous",{P},B}, + {"set_row_spacing",{P,I}}, + {"get_row_spacing",{P},I}, + {"set_column_spacing",{P,I}}, + {"get_column_spacing",{P},I}, + {"set_baseline_row",{P,I}}, --3.10 + {"get_baseline_row",{P},I}, --3.10 + {"set_row_baseline_position",{P,I,I}}, --3.10 + {"get_row_baseline_position",{P,I},I}, --3.10 +"GtkGrid"} + +widget[GtkPaned] = {"gtk_paned", +{GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{I},P}, + {"add1",{P,P}}, + {"add2",{P,P}}, + {"pack1",{P,P,B,B}}, + {"pack2",{P,P,B,B}}, + {"get_child1",{P},P,0,GtkWidget}, + {"get_child2",{P},P,0,GtkWidget}, + {"set_position",{P,I}}, + {"get_position",{P},I}, + {"get_handle_window",{P},P,0,GdkWindow}, + {"get_wide_handle",{P},B}, -- 3.16 + {"set_wide_handle",{P,B}}, -- 3.16 +"GtkPaned"} + +widget[GtkIconInfo] = {"gtk_icon_info", +{GObject}, + {"new",{P,P},-routine_id("newIconInfo")}, + {"get_base_size",{P},I}, + {"get_base_scale",{P},I}, --3.10 + {"get_filename",{P},S}, + {"get_display_name",{P},S}, -- deprecated 3.14 + {"get_builtin_pixbuf",{P},P,0,GdkPixbuf}, -- deprecated 3.14 + {"load_icon",{P},-routine_id("icon_info_load_icon")}, + {"load_surface",{P,P,P},P,0,CairoSurface_t}, + {"load_icon_async",{P,P,P,P}}, + {"load_icon_finish",{P,P,P},P,0,GdkPixbuf}, + {"load_symbolic",{P,P,P,P,P,B,P},P,0,GdkPixbuf}, + {"load_symbolic_async",{P,P,P,P,P,P,P,P}}, + {"load_symbolic_finish",{P,P,P,P},P,0,GdkPixbuf}, + {"load_symbolic_for_context",{P,P,P,P},P,0,GdkPixbuf}, + {"load_symbolic_for_context_async",{P,P,P,P,P}}, + {"load_symbolic_for_context_finish",{P,P,P,P},P,0,GdkPixbuf}, + {"set_raw_coordinates",{P,B}}, -- deprecated 3.14 + {"get_embedded_rect",{P,P},B}, -- deprecated 3.14 + {"get_attach_points",{P,A,P},B}, -- deprecated 3.14 + {"is_symbolic",{P},B}, -- 3.12 +"GtkIconInfo"} + + function newIconInfo(atom theme, atom pix) -- reorder params; + return gtk_func("gtk_icon_info_new_for_pixbuf",{P,P},{theme,pix}) + end function + + function icon_info_load_icon(atom info) -- allow for err, register object; + atom err = allocate(8,1) err = 0 + atom icn = gtk_func("gtk_icon_info_load_icon",{P,P},{info,err}) + register(icn,GdkPixbuf) + return icn + end function + +widget[GtkIconTheme] = {"gtk_icon_theme", +{GObject}, + {"new",{P},-routine_id("newIconTheme")}, + {"set_screen",{P,P}}, + {"set_search_path",{P,S,I}}, + {"get_search_path",{P,P,I}}, + {"append_search_path",{P,S}}, + {"prepend_search_path",{P,S}}, + {"set_custom_theme",{P,S}}, + {"has_icon",{P,S},B}, + {"lookup_icon",{P,P,I,I},P,0,GtkIconInfo}, + {"lookup_icon_for_scale",{P,P,I,I,I},P,0,GtkIconInfo}, + {"choose_icon",{P,A,I,I},P,0,GtkIconInfo}, + {"choose_icon_for_scale",{P,A,I,I,I},P,0,GtkIconInfo}, + {"lookup_by_gicon",{P,P,I,I},P,0,GtkIconInfo}, + {"load_icon",{P,S,I,I},-routine_id("icon_theme_load_icon")}, + {"load_icon_for_scale",{P,S,I,I,I,P},P,0,GdkPixbuf}, + {"load_surface",{P,S,I,I,P,I,P},P,0,CairoSurface_t}, + {"list_contexts",{P},-routine_id("icon_theme_list_contexts")}, + {"list_icons",{P,S},-routine_id("icon_theme_list_icons")}, + {"get_icon_sizes",{P,S},A}, + {"rescan_if_needed",{P},B}, + {"get_example_icon_name",{P},S}, + {"add_builtin_icon",{S,I,P}}, + {"add_resource_path",{P,S}}, -- 3.14 +"GtkIconTheme"} + + function newIconTheme(atom x=0) + if class_id(x) = GdkScreen then + return gtk_func("gtk_icon_theme_get_for_screen",{P},{x}) + else + return gtk_func("gtk_icon_theme_get_default") + end if + end function + + function icon_theme_load_icon(atom theme, object name, integer size, integer flags) + atom err = allocate(8,1) err = 0 + return gtk_func("gtk_icon_theme_load_icon",{P,P,I,I,P},{theme,name,size,flags,err}) + end function + + function icon_theme_list_contexts(atom theme) + object list = gtk_func("gtk_icon_theme_list_contexts",{P},{theme}) + return to_sequence(list) + end function + + function icon_theme_list_icons(atom theme, object context) + object list = gtk_func("gtk_icon_theme_list_icons",{P,P},{theme,context}) + return to_sequence(list) + end function + +widget[GtkIconView] = {"gtk_icon_view", +{GtkCellLayout,GtkScrollable,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"new_with_area",{P},P}, + {"new_with_model",{P},P}, + {"set_model",{P,P}}, + {"get_model",{P},P,0,GtkTreeModel}, + {"set_text_column",{P,I}}, + {"get_text_column",{P},I}, + {"set_markup_column",{P,I}}, + {"get_markup_column",{P},I}, + {"set_pixbuf_column",{P,I}}, + {"get_pixbuf_column",{P},I}, + {"get_visible_range",{P,I,I},B}, + {"get_path_at_pos",{P,I,I},P,0,GtkTreePath}, + {"get_item_at_pos",{P,I,I,I,I},B}, + {"convert_widget_to_bin_window_coords",{P,I,I,I,I}}, + {"set_cursor",{P,P,P,B}}, + {"get_cursor",{P,I,I},B}, + {"selected_foreach",{P,P,P}}, + {"set_selection_mode",{P,I}}, + {"get_selection_mode",{P},I}, + {"set_columns",{P,I}}, + {"get_columns",{P},I}, + {"set_spacing",{P,I}}, + {"get_spacing",{P},I}, + {"set_row_spacing",{P,I}}, + {"get_row_spacing",{P},I}, + {"set_column_spacing",{P,I}}, + {"get_column_spacing",{P},I}, + {"set_margin",{P,I}}, + {"get_margin",{P},I}, + {"set_item_padding",{P,I}}, + {"get_item_padding",{P},I}, + {"set_activate_on_single_click",{P,B}}, --3.8 + {"get_activate_on_single_click",{P},B}, --3.8 + {"get_cell_rect",{P,P,P,P},B}, --3.6 + {"select_path",{P,P}}, + {"unselect_path",{P,P}}, + {"path_is_selected",{P,P},B}, + {"get_selected_items",{P},X,0,GList}, + {"select_all",{P}}, + {"unselect_all",{P}}, + {"item_activated",{P,P}}, + {"scroll_to_path",{P,P,B,F,F}}, + {"get_visible_range",{P,I,I},B}, + {"set_tooltip_item",{P,P,P}}, + {"set_tooltip_cell",{P,P,P,P}}, + {"get_tooltip_context",{P,I,I,B,P,P,P},B}, + {"set_tooltip_column",{P,I}}, + {"get_tooltip_column",{P},I}, + {"get_item_row",{P,P},I}, + {"get_item_column",{P,P},I}, + {"enable_model_drag_source",{P,I,P,I,I}}, + {"enable_model_drag_dest",{P,P,I,I}}, + {"unset_model_drag_source",{P}}, + {"unset_model_drag_dest",{P}}, + {"set_reorderable",{P,B}}, + {"get_reorderable",{P},B}, + {"set_drag_dest_item",{P,I,I}}, + {"get_drag_dest_item",{P,I,I}}, + {"get_dest_item_at_pos",{P,I,I,I,I},B}, + {"create_drag_icon",{P,P},P,0,CairoSurface_t}, +"GtkIconView"} + +widget[GtkLayout] = {"gtk_layout", +{GtkContainer,GtkWidget,GtkBuildable,GtkScrollable,GObject}, + {"new",{P,P},P}, + {"put",{P,P,I,I}}, + {"move",{P,P,I,I}}, + {"set_size",{P,I,I}}, + {"get_size",{P,I,I}}, + {"get_bin_window",{P},P,0,GdkWindow}, +"GtkLayout"} + +widget[GtkSeparatorMenuItem] = {"gtk_separator_menu_item", +{GtkMenuItem,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GObject}, + {"new",{},P}, +"GtkSeparatorMenuItem"} + +widget[GtkRecentChooserMenu] = {"gtk_recent_chooser_menu", +{GtkMenu,GtkMenuShell,GtkContainer,GtkWidget,GtkBuildable,GtkRecentChooser,GObject}, + {"new",{},P}, + {"new_for_manager",{P},P}, + {"set_show_numbers",{P,B}}, + {"get_show_numbers",{P},B}, +"GtkRecentChooserMenu"} + +widget[GtkRecentFilter] = {"gtk_recent_filter", +{GtkBuildable,GObject}, + {"new",{},P}, + {"set_name",{P,S}}, + {"get_name",{P},S}, + {"add_mime_type",{P,S}}, + {"add_pattern",{P,S}}, + {"add_pixbuf_formats",{P}}, + {"add_group",{P,S}}, + {"add_age",{P,I}}, + {"add_application",{P,S}}, + {"add_custom",{P,I,P,P,P}}, + {"get_needed",{P},I}, + {"filter",{P,P},B}, +"GtkRecentFilter"} + +widget[GtkRecentInfo] = {"gtk_recent_info", +{GObject}, + {"get_uri",{P},S}, + {"get_display_name",{P},S}, + {"get_description",{P},S}, + {"get_mime_type",{P},S}, + {"get_added",{P},I}, + {"get_modified",{P},I}, + {"get_visited",{P},I}, + {"get_private_hint",{P},B}, + {"get_application_info",{P,S,S,I,I},B}, + {"get_applications",{P,I},V}, + {"last_application",{P},S}, + {"has_application",{P,S},B}, + {"create_app_info",{P,S,P},P,0,GAppInfo}, + {"get_groups",{P,I},A}, + {"has_group",{P,S},B}, + {"get_icon",{P,I},P,0,GdkPixbuf}, + {"get_gicon",{P},P,0,GIcon}, + {"get_short_name",{P},S}, + {"get_uri_display",{P},S}, + {"get_age",{P},I}, + {"is_local",{P},B}, + {"exists",{P},B}, + {"match",{P,P},B}, +"GtkRecentInfo"} + +widget[GtkSettings] = {"gtk_settings", +{GtkStyleProvider,GObject}, + {"new",{},-routine_id("newSettings")}, + {"reset_property",{P,S}}, -- 3.20 +"GtkSettings"} + + function newSettings(atom x=0) + if class_id(x) = GdkScreen then + return gtk_func("gtk_settings_get_for_screen",{P},{x}) + else + return gtk_func("gtk_settings_get_default") + end if + end function + +widget[GtkSizeGroup] = {"gtk_size_group", +{GtkBuildable,GObject}, + {"new",{I},P}, + {"set_mode",{P,I}}, + {"get_mode",{P},I}, + {"set_ignore_hidden",{P,B}}, + {"get_ignore_hidden",{P},B}, + {"add_widget",{P,P}}, + {"add_widgets",{P,P},-routine_id("sg_add_widgets")}, + {"remove_widget",{P,P}}, + {"get_widgets",{P},X,0,GSList}, +"GtkSizeGroup"} + + function sg_add_widgets(atom group, object widgets) -- allow {list} of widgets; + if atom(widgets) then + set(group,"add widget",widgets) + else + for i = 1 to length(widgets) do + set(group,"add widget",widgets[i]) + end for + end if + return 1 + end function + +widget[GtkTargetEntry] = {"gtk_target_entry", +{GObject}, + {"new",{S,I,I},P}, + {"copy",{P},P,0,GtkTargetEntry}, + {"free",{P}}, +"GtkTargetEntry"} + +widget[GtkTargetList] = {"gtk_target_list", +{GObject}, + {"new",{P,I},P}, + {"add",{P,P,I,I}}, + {"add_table",{P,P,I}}, + {"add_text_targets",{P,I}}, + {"add_image_targets",{P,I,B}}, + {"add_uri_targets",{P,I}}, + {"add_rich_text_targets",{P,I,B,P}}, + {"remove",{P,P}}, + {"find",{P,P,P},B}, +"GtkTargetList"} + +widget[GtkTextChildAnchor] = {"gtk_text_child_anchor", +{GObject}, + {"new",{},P}, + {"get_deleted",{P},B}, + {"get_widgets",{P},X,0,GList}, +"GtkTextChildAnchor"} + +widget[GtkTextMark] = {"gtk_text_mark", +{GObject}, + {"new",{S,B},P}, + {"set_visible",{P,B}}, + {"get_visible",{P},B}, + {"get_deleted",{P},B}, + {"get_name",{P},S}, + {"get_buffer",{P},P,0,GtkTextBuffer}, + {"get_left_gravity",{P},B}, +"GtkTextMark"} + +widget[GtkTextTag] = {"gtk_text_tag", +{GObject}, + {"new",{S},P}, + {"set_priority",{P,I}}, + {"get_priority",{P},I}, + {"event",{P,P,P,P},B}, + {"changed",{P,B}}, -- 3.20 +"GtkTextTag"} + +widget[GtkTextAttributes] = {"gtk_text_attributes", +{GObject}, + {"new",{},P}, + {"copy",{P},P,0,GtkTextAttributes}, + {"copy_values",{P,P}}, +"GtkTextAttributes"} + +widget[GtkTextTagTable] = {"gtk_text_tag_table", +{GtkBuildable,GObject}, + {"new",{},P}, + {"add",{P,P}}, + {"remove",{P,P}}, + {"lookup",{P,S},P,0,GtkTextTag}, + {"foreach",{P,P,P}}, + {"get_size",{P},I}, +"GtkTextTagTable"} + +widget[GtkMenuShell] = {"gtk_menu_shell", +{GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"append",{P,P},-routine_id("ms_append")}, + {"prepend",{P,P}}, + {"insert",{P,P,I}}, + {"deactivate",{P}}, + {"select_item",{P,P}}, + {"select_first",{P,B}}, + {"deselect",{P}}, + {"activate_item",{P,P,B}}, + {"cancel",{P}}, + {"set_take_focus",{P,B}}, + {"get_take_focus",{P},B}, + {"get_selected_item",{P},P,0,GtkWidget}, + {"get_parent_shell",{P},P,0,GtkWidget}, + {"bind_model",{P,P,S,B}}, --3.6 +"GtkMenuShell"} + + function ms_append(atom menu, object items) -- allow {list} of items; + if atom(items) then + gtk_proc("gtk_menu_shell_append",{P,P},{menu,items}) + else + for i = 1 to length(items) do + ms_append(menu,items[i]) + end for + end if + return 1 + end function + +widget[GtkNotebook] = {"gtk_notebook", +{GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"append_page",{P,P,P},I}, + {"append_page_menu",{P,P,P,P},I}, + {"prepend_page",{P,P,P},I}, + {"prepend_page_menu",{P,P,P,P},I}, + {"insert_page",{P,P,P,I},I}, + {"insert_page_menu",{P,P,P,P,I},I}, + {"remove_page",{P,I}}, + {"page_num",{P,I},I}, + {"next_page",{P}}, + {"prev_page",{P}}, + {"reorder_child",{P,P,I}}, + {"set_tab_pos",{P,I}}, + {"get_tab_pos",{P},I}, + {"set_show_tabs",{P,B}}, + {"get_show_tabs",{P},B}, + {"set_show_border",{P,B}}, + {"get_show_border",{P},B}, + {"set_scrollable",{P,B}}, + {"get_scrollable",{P},B}, + {"popup_enable",{P}}, + {"popup_disable",{P}}, + {"get_current_page",{P},I}, + {"set_menu_label",{P,P},0,GtkWidget}, + {"get_menu_label",{P,P},P}, + {"get_menu_label_text",{P,P},S}, + {"get_n_pages",{P},I}, + {"get_nth_page",{P,I},P,0,GtkWidget}, + {"set_tab_label",{P,P}}, + {"get_tab_label",{P,P},P,0,GtkWidget}, + {"set_tab_label_text",{P,P,S}}, + {"get_tab_label_text",{P,P},S}, + {"set_tab_detachable",{P,P,B}}, + {"get_tab_detachable",{P,P},B}, + {"set_current_page",{P,I}}, + {"set_group_name",{P,S}}, + {"get_group_name",{P},S}, + {"set_action_widget",{P,P,I}}, + {"get_action_widget",{P,I},P,0,GtkWidget}, + {"detach_tab",{P,P}}, -- 3.16 +"GtkNotebook"} + +widget[GtkSocket] = {"gtk_socket", +{GtkContainer,GtkWidget,GObject}, + {"new",{},P}, + {"add_id",{P,P}}, + {"get_id",{P},P}, + {"get_plug_window",{P},P,0,GdkWindow}, +"GtkSocket"} + +widget[GtkPlug] = {"gtk_plug", +{GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{I},P}, + {"get_id",{P},I}, + {"get_embedded",{P},B}, + {"get_socket_window",{P},P,0,GdkWindow}, +"GtkPlug"} + +widget[GtkToolPalette] = {"gtk_tool_palette", +{GtkScrollable,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"set_exclusive",{P,P,B}}, + {"get_exclusive",{P,P},B}, + {"set_expand",{P,P,B}}, + {"get_expand",{P,P},B}, + {"set_group_position",{P,P,I}}, + {"get_group_position",{P,P},I}, + {"set_icon_size",{P,I}}, + {"get_icon_size",{P},I}, + {"unset_icon_size",{P}}, + {"set_style",{P,I}}, + {"get_style",{P},I}, + {"unset_style",{P}}, + {"add_drag_dest",{P,P,I,I,I}}, + {"get_drag_item",{P,P},P,0,GtkWidget}, + {"get_drop_group",{P,I,I},P,0,GtkToolItemGroup}, + {"set_drag_source",{P,I}}, +"GtkToolPalette"} + +widget[GtkTextView] = {"gtk_text_view", +{GtkScrollable,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"new_with_buffer",{P},P}, + {"set_buffer",{P,P}}, + {"get_buffer",{P},P,0,GtkTextBuffer}, + {"scroll_to_mark",{P,P,D,B,D,D}}, + {"scroll_to_iter",{P,P,D,B,D,D},B}, + {"scroll_mark_onscreen",{P,P}}, + {"place_cursor_onscreen",{P},B}, + {"get_visible_rect",{P,P}}, + {"get_iter_location",{P,P,P}}, + {"get_cursor_locations",{P,P,P,P}}, + {"get_line_at_y",{P,P,I,I}}, + {"get_line_yrange",{P,P,I,I}}, + {"get_iter_at_location",{P,P,I,I}}, + {"get_iter_at_position",{P,P,I,I,I}}, + {"buffer_to_window_coords",{P,P,I,I,I,I}}, + {"window_to_buffer_coords",{P,P,I,I,I,I}}, + {"get_window",{P,I},P,0,GdkWindow}, + {"set_border_window_size",{P,I,I}}, + {"get_border_window_size",{P,P},I}, + {"forward_display_line",{P,P},B}, + {"backward_display_line",{P,P},B}, + {"forward_display_line_end",{P,P},B}, + {"backward_display_line_start",{P,P},B}, + {"starts_display_line",{P,P},B}, + {"move_visually",{P,P,I},B}, + {"add_child_at_anchor",{P,P,P}}, + {"add_child_in_window",{P,P,P,I,I}}, + {"move_child",{P,P,I,I}}, + {"set_wrap_mode",{P,I}}, + {"get_wrap_mode",{P},I}, + {"set_editable",{P,B}}, + {"get_editable",{P},B}, + {"set_cursor_visible",{P,B}}, + {"get_cursor_visible",{P},B}, + {"set_overwrite",{P,B}}, + {"get_overwrite",{P},B}, + {"set_pixels_above_lines",{P,I}}, + {"get_pixels_above_lines",{P},I}, + {"set_pixels_below_lines",{P,I}}, + {"get_pixels_below_lines",{P},I}, + {"set_pixels_inside_wrap",{P,I}}, + {"get_pixels_inside_wrap",{P},I}, + {"set_justification",{P,I}}, + {"get_justification",{P},I}, + {"set_left_margin",{P,I}}, + {"get_left_margin",{P},I}, + {"set_right_margin",{P,I}}, + {"get_right_margin",{P},I}, + {"set_indent",{P,I}}, + {"get_indent",{P},I}, + {"set_tabs",{P,A}}, + {"get_tabs",{P},A,0,PangoTabArray}, + {"set_accepts_tab",{P,B}}, + {"get_accepts_tab",{P},B}, + {"im_context_filter_keypress",{P,P},B}, + {"get_default_attributes",{P},P,0,GtkTextAttributes}, + {"reset_im_context",{P}}, + {"set_input_purpose",{P,I}}, -- 3.6+ + {"get_input_purpose",{P},I}, -- 3.6+ + {"set_input_hints",{P,I}}, -- 3.6+ + {"get_input_hints",{P},I}, -- 3.6+ + {"get_monospace",{P},B}, -- 3.16 + {"set_monospace",{P,B}}, -- 3.16 + {"get_bottom_margin",{P},I}, -- 3.18 + {"set_bottom_margin",{P,I}}, -- 3.18 + {"get_top_margin",{P},I}, -- 3.18 + {"set_top_margin",{P,I}}, -- 3.18 + {"reset_cursor_blink",{P}}, -- 3.20 +"GtkTextView"} + +widget[GtkToolShell] = {"gtk_tool_shell", -- WARNING! +{GtkWidget}, -- see GTK3 docs re: GtkToolShell functions + {"get_ellipsize_mode",{P},I}, + {"get_icon_size",{P},I}, + {"get_orientation",{P},I}, + {"get_relief_style",{P},I}, + {"get_style",{P},I}, + {"get_text_alignment",{P},F}, + {"get_text_orientation",{P},I}, + {"get_text_size_group",{P},P,0,GtkSizeGroup}, + {"rebuild_menu",{P}}, +"GtkToolShell"} + +widget[GtkToolbar] = {"gtk_toolbar", +{GtkToolShell,GtkContainer,GtkWidget,GtkOrientable,GtkBuildable,GObject}, + {"new",{},P}, + {"insert",{P,P,I}}, + {"get_item_index",{P,P},I}, + {"get_n_items",{P},I}, + {"get_nth_item",{P},P}, + {"get_drop_index",{P,I,I},I}, + {"set_drop_highlight_item",{P,P,I}}, + {"set_show_arrow",{P,B}}, + {"get_show_arrow",{P},B}, + {"set_icon_size",{P,I}}, + {"get_icon_size",{P},I}, + {"unset_icon_size",{P}}, + {"set_style",{P,I}}, + {"get_style",{P},I}, + {"unset_style",{P}}, +"GtkToolbar"} + +widget[GtkToolItemGroup] = {"gtk_tool_item_group", +{GtkToolShell,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{S},P}, + {"set_collapsed",{P,B}}, + {"get_collapsed",{P},B}, + {"set_ellipsize",{P,I}}, + {"get_ellipsize",{P},I}, + {"get_drop_item",{P,I,I},P,0,GtkToolItem}, + {"get_n_items",{P},I}, + {"get_nth_item",{P,I},P,0,GtkToolItem}, + {"set_label",{P,S}}, + {"get_label",{P},S}, + {"set_label_widget",{P,P}}, + {"get_label_widget",{P},P,0,GtkWidget}, + {"set_header_relief",{P,I}}, + {"get_header_relief",{P},I}, + {"insert",{P,P,I}}, + {"set_item_position",{P,P,I}}, +"GtkToolItemGroup"} + +widget[GtkTooltip] = {"gtk_tooltip", +{GObject}, + {"set_text",{P,S}}, + {"set_markup",{P,S}}, + {"set_icon",{P,P}}, + {"set_icon_from_icon_name",{P,S,I}}, + {"set_icon_from_gicon",{P,P,I}}, + {"set_custom",{P,P}}, + {"trigger_tooltip_query",{P}}, + {"set_tip_area",{P,P}}, +"GtkTooltip"} + +function newColumn(object params) + params = keyvalues(params) + atom c = create(GtkTreeViewColumn) + atom r = -1 + object t = vlookup("type",params,1,2) + + switch t do + case "text","markup" then r = create(GtkCellRendererText) + case "pixbuf" then r = create(GtkCellRendererPixbuf) + case "progress" then r = create(GtkCellRendererProgress) + case "spin" then r = create(GtkCellRendererSpin) + case "toggle" then r = create(GtkCellRendererToggle) + case "combo" then r = create(GtkCellRendererCombo) + case else display("Error specifying cell renderer type") + end switch + + if r = -1 then + Warn(,,"Create new column","Must specify a renderer type (i.e. type=text)") + abort(1) + end if + + set(c,{{"pack start",r,TRUE}}) + + for i = 1 to length(params) do + + if equal("TRUE",params[i][2]) then params[i][2] = 1 end if + if equal("FALSE",params[i][2]) then params[i][2] = 0 end if + if equal("1",params[i][2]) then params[i][2] = 1 end if + if equal("0",params[i][2]) then params[i][2] = 0 end if + + if match("column.",params[i][1]) then + set(c,params[i][1][8..$],params[i][2]) + + elsif match("renderer.",params[i][1]) then + set(r,params[i][1][10..$],params[i][2]) + + elsif equal("cell_data_func",params[i][1]) then + params[i][2] = to_number(params[i][2]) + set(c,"cell data func",r,params[i][2]) + + else + switch params[i][1] do + case "type" then break -- do nothing + case "title","sort_column_id" then set(c,params[i][1],params[i][2]) + case "toggled" then connect(r,"toggled",_(params[i][2])) + case "edited" then connect(r,"edited",_(params[i][2])) + --display("Connecting [] []",{params[i][2],_(params[i][2])}) + case else set(c,"add attribute",r,params[i][1],params[i][2]) + end switch + end if + + end for + + set(c,"data","renderer",sprintf("%d",r)) + + return c + end function + +widget[GtkTreeView] = {"gtk_tree_view", +{GtkContainer,GtkWidget,GtkBuildable,GtkScrollable,GObject}, + {"new",{P},-routine_id("newTreeView")}, + {"set_model",{P,P}}, + {"get_model",{P},P,0,GtkTreeModel}, + {"get_selection",{P},P,0,GtkTreeSelection}, + {"set_headers_visible",{P,B}}, + {"get_headers_visible",{P},B}, + {"set_headers_clickable",{P,B}}, + {"get_headers_clickable",{P},B}, + {"set_show_expanders",{P,B}}, + {"get_show_expanders",{P},B}, + {"set_expander_column",{P,P}}, + {"get_expander_column",{P},P,0,GtkTreeViewColumn}, + {"set_level_indentation",{P,I}}, + {"get_level_indentation",{P},I}, + {"columns_autosize",{P}}, + {"set_rules_hint",{P,B}}, -- deprecated 3.14 + {"get_rules_hint",{P},B}, -- deprecated 3.14 + {"set_activate_on_single_click",{P,B}}, -- GTK 3.8+ + {"get_activate_on_single_click",{P},B}, -- GTK 3.8+ + {"append_column",{P,P},I}, + {"append_columns",{P,P},-routine_id("tv_append_columns")}, + {"remove_column",{P,P,I}}, + {"insert_column",{P,P,I}}, + {"insert_column_with_attributes",{P,I,S,S,I,I}}, + {"insert_column_with_data_func",{P,I,S,P,P,P,P}}, + {"get_n_columns",{P},I}, + {"get_column",{P,I},P,0,GtkTreeViewColumn}, + {"get_columns",{P},X,0,GList}, + {"move_column_after",{P,P,P}}, + {"set_column_drag_function",{P,P,P,P}}, + {"scroll_to_point",{P,I,I}}, + {"scroll_to_cell",{P,P,P,P,F,F},-routine_id("tv_scroll_to_cell")}, + {"set_cursor",{P,P,P,B}}, + {"set_cursor_on_cell",{P,P,P,P,B}}, + {"get_cursor",{P,P,P}}, + {"row_activated",{P,P,P}}, + {"expand_row",{P,P,B},B}, + {"expand_all",{P}}, + {"expand_to_path",{P,P}}, + {"collapse_all",{P}}, + {"map_expanded_rows",{P,P,P}}, + {"row_expanded",{P,P},B}, + {"set_reorderable",{P,B}}, + {"get_reorderable",{P,B}}, + {"get_path_at_pos",{P,I,I,P,P,I,I},B}, + {"is_blank_at_pos",{P,I,I,P,P,I,I},B}, + {"get_cell_area",{P,P,P,P}}, + {"get_background_area",{P,P,P,P}}, + {"get_visible_rect",{P,P}}, + {"get_visible_range",{P,P,P},B}, + {"get_bin_window",{P},P,0,GdkWindow}, + {"convert_bin_window_to_tree_coords",{P,I,I,I,I}}, + {"convert_bin_window_to_widget_coords",{P,I,I,I,I}}, + {"convert_tree_to_bin_window_coords",{P,I,I,I,I}}, + {"convert_tree_to_widget_coords",{P,I,I,I,I}}, + {"convert_widget_to_bin_window_coords",{P,I,I,I,I}}, + {"convert_widget_to_tree_coords",{P,I,I,I,I}}, + {"enable_model_drag_dest",{P,P,I,I}}, + {"enable_model_drag_source",{P,I,P,I,I}}, + {"unset_rows_drag_source",{P}}, + {"unset_rows_drag_dest",{P}}, + {"set_drag_dest_row",{P,P,I}}, + {"get_drag_dest_row",{P,P,P}}, + {"get_drag_dest_row_at_pos",{P,I,I,P,P},B}, + {"create_row_drag_icon",{P,P},P,0,CairoSurface_t}, + {"set_enable_search",{P,B}}, + {"get_enable_search",{P},B}, + {"set_search_column",{P,I}}, + {"get_search_column",{P},I}, + {"set_search_equal_func",{P,P,P,P}}, + {"get_search_equal_func",{P},P}, + {"set_search_entry",{P,P}}, + {"get_search_entry",{P},P,0,GtkEntry}, + {"set_search_position_func",{P,P,P,P}}, + {"get_search_position_func",{P},P}, + {"set_fixed_height_mode",{P,B}}, + {"get_fixed_height_mode",{P},B}, + {"set_hover_selection",{P,B}}, + {"get_hover_selection",{P},B}, + {"set_hover_expand",{P,B}}, + {"get_hover_expand",{P},B}, + {"set_destroy_count_func",{P,P,P,P}}, + {"set_row_separator_func",{P,P,P,P}}, + {"get_row_separator_func",{P},P}, + {"set_rubber_banding",{P,B}}, + {"get_rubber_banding",{P},B}, + {"set_enable_tree_lines",{P,B}}, + {"get_enable_tree_lines",{P},B}, + {"set_grid_lines",{P,B}}, + {"get_grid_lines",{P},B}, + {"set_tooltip_row",{P,P,P}}, + {"set_tooltip_cell",{P,P,P,P,P}}, + {"set_tooltip_column",{P,I}}, + {"get_tooltip_column",{P},I}, + {"get_tooltip_context",{P,I,I,B,P,P,P},B}, + {"select_row",{P,P,D,D},-routine_id("tv_select_row")}, + {"get_selected_row_data",{P,P},-routine_id("tv_get_selected_row_data")}, + {"get_selected_col_data",{P,P,I},-routine_id("tv_get_selected_col_data")}, +"GtkTreeView"} + + function newTreeView(atom x=0) + if class_id(x) = GtkTreeModel then + return gtk_func("gtk_tree_view_new_with_model",{P},{x}) + else + return gtk_func("gtk_tree_view_new") + end if + end function + + constant sfn1 = define_func("gtk_tree_view_get_model",{P},P) + constant sfn2 = define_func("gtk_tree_model_get_n_columns",{P},I) + constant sfn3 = define_func("gtk_tree_model_get_iter",{P,P,P},B) + constant sfn4 = define_func("gtk_tree_model_get_column_type",{P,I},I) + constant sp1 = define_proc("gtk_tree_model_get",{P,P,I,P,I}) + + function tv_get_selected_col_data(atom view, atom path, integer col) + object data = tv_get_selected_row_data(view,path) + return data[col] + end function + + function tv_get_selected_row_data(atom view, atom path) + atom mdl = c_func(sfn1,{view}) + integer ncols = c_func(sfn2,{mdl}) + object data = repeat(0,ncols) + object types = repeat(0,ncols) + atom iter = allocate(32,1) + object result + + if c_func(sfn3,{mdl,iter,path}) then + for i = 1 to length(data) do + data[i] = allocate(32,1) + types[i] = c_func(sfn4,{mdl,i-1}) + c_proc(sp1,{mdl,iter,i-1,data[i],-1}) + end for + end if + + for i = 1 to length(data) do + switch types[i] do + case gSTR then + ifdef BITS64 then -- thanks pete eberlein + result = peek8u(data[i]) + elsedef + result = peek4u(data[i]) + end ifdef + if result > 0 then + result = peek_string(result) + end if + data[i] = result + + case else data[i] = peek4u(data[i]) + end switch + end for + + return data + end function + + function tv_scroll_to_cell(atom v, atom p, atom c=0, integer align=0, atom row=0, atom col=0) + gtk_proc("gtk_tree_view_scroll_to_cell",{P,P,P,I,F,F},{v,p,c,align,row,col}) + return 1 + end function + + function tv_append_columns(atom store, object cols) + if atom(cols) then + gtk_func("gtk_tree_view_append_column",{P,P},{store,cols}) + else + for i = 1 to length(cols) do + tv_append_columns(store,cols[i]) + end for + end if + return 1 + end function + + function tv_select_row(atom tv, object path, atom rowalign=0, atom colalign=0) + path = create(GtkTreePath,path) + gtk_func("gtk_tree_view_scroll_to_cell", + {P,P,I,I,F,F},{tv,path,0,1,rowalign,colalign}) + return 1 + end function + +widget[GtkTreeViewColumn] = {"gtk_tree_view_column", +{GtkCellLayout,GtkBuildable,GObject}, + {"new",{},P}, + {"set_title",{P,S}}, + {"get_title",{P},S}, + {"pack_start",{P,P,B}}, + {"pack_end",{P,P,B}}, + {"clear",{P}}, + {"clicked",{P}}, + {"add_attribute",{P,P,S,I}}, + {"set_spacing",{P,I}}, + {"get_spacing",{P},I}, + {"set_visible",{P,B}}, + {"get_visible",{P},B}, + {"set_resizable",{P,B}}, + {"get_resizable",{P},B}, + {"set_sizing",{P,I}}, + {"get_sizing",{P},I}, + {"set_fixed_width",{P,I}}, + {"get_fixed_width",{P},I}, + {"set_min_width",{P,I}}, + {"get_min_width",{P},I}, + {"set_max_width",{P,I}}, + {"get_max_width",{P},I}, + {"set_expand",{P,B}}, + {"get_expand",{P},B}, + {"set_clickable",{P,B}}, + {"get_clickable",{P},B}, + {"set_widget",{P,P}}, + {"get_widget",{P},P}, + {"get_button",{P},P,0,GtkWidget}, + {"set_alignment",{P,F}}, + {"get_alignment",{P},F}, + {"set_reorderable",{P,B}}, + {"get_reorderable",{P},B}, + {"set_sort_column_id",{P,I}}, + {"get_sort_column_id",{P},I}, + {"set_sort_indicator",{P,B}}, + {"get_sort_indicator",{P},B}, + {"set_sort_order",{P,I}}, + {"get_sort_order",{P},I}, + {"cell_set_cell_data",{P,P,P,B,B}}, + {"cell_get_size",{P,P,I,I,I,I}}, + {"cell_get_position",{P,P,I,I},B}, + {"cell_is_visible",{P},B}, + {"focus_cell",{P,P}}, + {"queue_resize",{P}}, + {"get_tree_view",{P},P,0,GtkTreeView}, + {"get_x_offset",{P},I}, +"GtkTreeViewColumn"} + +widget[GtkTreeSelection] = {"gtk_tree_selection", +{GObject}, + {"set_mode",{P,I}}, + {"get_mode",{P},I}, + {"set_select_function",{P,P,P,P}}, + {"get_select_function",{P},P}, + {"get_user_data",{P},P}, + {"get_tree_view",{P},P}, + {"get_selected",{P,P,P},B}, + {"selected_foreach",{P,P,P}}, + {"count_selected_rows",{P},I}, + {"select_path",{P,P}}, + {"unselect_path",{P,P}}, + {"path_is_selected",{P,P},B}, + {"select_iter",{P,P}}, + {"unselect_iter",{P,P}}, + {"iter_is_selected",{P,P},B}, + {"select_all",{P}}, + {"unselect_all",{P}}, + {"select_range",{P,P,P}}, + {"unselect_range",{P,P,P}}, + {"get_selected_row",{P,P},-routine_id("ts_get_selected_row")}, + {"get_selected_rows",{P,P},-routine_id("ts_get_selected_rows")}, + {"get_selected_row_data",{P},-routine_id("ts_get_selected_row_data")}, +"GtkTreeSelection"} + + function ts_get_selected_rows(atom selection, atom model) + object list = gtk_func("gtk_tree_selection_get_selected_rows", + {P,P},{selection,model}) + list = to_sequence(list,3) + return list +1 + end function + + function ts_get_selected_row(atom selection, atom model) + object result = ts_get_selected_rows(selection,model) + if equal({},result) then return 0 + else return result[1] + end if + end function + + function ts_get_selected_row_data(atom selection) + atom mdl = allocate(32), iter = allocate(32) + integer n + object x,t, val, result + if gtk_func("gtk_tree_selection_get_selected",{P,P,P},{selection,mdl,iter}) then + mdl = peek4u(mdl) + n = gtk_func("gtk_tree_model_get_n_columns",{P},{mdl}) + x = repeat(0,n) t = x + + for i = 1 to n do + val = allocate(32,1) + gtk_proc("gtk_tree_model_get",{P,P,I,P,I},{mdl,iter,i-1,val,-1}) + t[i] = gtk_func("gtk_tree_model_get_column_type",{P,I},{mdl,i-1}) + x[i] = val + end for + + for i = 1 to length(x) do + switch t[i] do + case gSTR then + ifdef BITS64 then -- thanks pete eberlein + result = peek8u(x[i]) + elsedef + result = peek4u(x[i]) + end ifdef + if result > 0 then + x[i] = peek_string(result) + end if + case gFLT then x[i] = float32_to_atom(peek({x[i],4})) + case gDBL then x[i] = float64_to_atom(peek({x[i],8})) + case else x[i] = peek4u(x[i]) + end switch + end for + return x + end if + + return -1 + end function + +widget[GtkActionBar] = {"gtk_action_bar", -- GTK 3.12 +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"pack_start",{P,P}}, + {"pack_end",{P,P}}, + {"get_center_widget",{P},P}, + {"set_center_widget",{P,P}}, +"GtkActionBar"} + +widget[GtkAccelLabel] = {"gtk_accel_label", +{GtkLabel,GtkMisc,GtkWidget,GtkBuildable,GObject}, + {"new",{S},P}, + {"get_accel",{P,I,I}}, -- 3.14 + {"set_accel",{P,I,I}}, + {"set_accel_closure",{P,P}}, + {"set_accel_widget",{P,P}}, + {"get_accel_widget",{P},P,0,GtkWidget}, + {"get_accel_width",{P},I}, + {"refetch",{P},B}, +"GtkAccelLabel"} + +widget[GtkAccelGroup] = {"gtk_accel_group", +{GObject}, + {"new",{},P}, + {"connect",{P,I,I,I,P}}, + {"connect_by_path",{P,S,P}}, + {"disconnect",{P,P},B}, + {"disconnect_key",{P,I,I},B}, + {"activate",{P,I,P,I,I},B}, + {"lock",{P}}, + {"unlock",{P}}, + {"get_is_locked",{P},B}, + {"from_accel_closure",{P},P,0,GtkAccelGroup}, + {"get_modifier_mask",{P},I}, + {"find",{P,P,P},P}, +"GtkAccelGroup"} + +widget[GtkArrow] = {"gtk_arrow", -- deprecated 3.14 +{GtkMisc,GtkWidget,GtkBuildable,GObject}, + {"new",{I,I},P}, + {"set",{P,I,I}}, +"GtkArrow"} + +widget[GtkCalendar] = {"gtk_calendar", +{GtkWidget,GtkBuildable,GObject}, + {"clear_marks",{P}}, + {"get_date",{P,I},-routine_id("cal_get_date")}, + {"get_ymd",{P,I},-routine_id("cal_get_ymd")}, + {"get_eu_date",{P},-routine_id("cal_get_eu_date")}, + {"get_day",{P},-routine_id("cal_get_day")}, + {"get_month",{P},-routine_id("cal_get_month")}, + {"get_year",{P},-routine_id("cal_get_year")}, + {"get_datetime",{P,I},-routine_id("cal_get_datetime")}, + {"get_day_is_marked",{P,I},B}, + {"get_display_options",{P},I}, + {"mark_day",{P,I},B}, + {"new",{P},-routine_id("newCalendar")}, + {"select_day",{P,I}}, + {"select_month",{P,I,I},-routine_id("cal_select_month")}, + {"set_display_options",{P,I}}, + {"unmark_day",{P,I},B}, + {"set_detail_func",{P,P,P,P}}, + {"set_detail_width_chars",{P,I}}, + {"get_detail_width_chars",{P},I}, + {"get_detail_height_rows",{P},I}, + {"set_detail_height_rows",{P,I}}, + {"set_date",{P,P},-routine_id("cal_set_date")}, + {"set_eu_date",{P,P},-routine_id("cal_set_date")}, + {"set_day",{P,I},-routine_id("cal_set_day")}, + {"set_month",{P,I},-routine_id("cal_set_month")}, + {"set_year",{P,I},-routine_id("cal_set_year")}, +"GtkCalendar"} + + function newCalendar(object d = 0) -- create calendar, set optional date; + object cal = gtk_func("gtk_calendar_new") + if atom(d) and d = 0 then return cal + else gtk_proc("gtk_calendar_select_month",{P,I,I},{cal,d[2]-1,d[1]}) + gtk_proc("gtk_calendar_select_day",{P,I},{cal,d[3]}) + return cal + end if + end function + +------------------------------------------------------------------------ +-- Calendar convenience functions +------------------------------------------------------------------------ +-- Handle odd month numbering scheme: +-- Q: If the first day of the month is 1, then why is the first month +-- of the year zero +-- A: Blame a C programmer! + +-- Here we fix that, plus change the set_date routine from two steps +-- to one; also, provide for standard formatting to be used when +-- getting the date. See std/datetime.e for the formats available. +------------------------------------------------------------------------ + + constant get_date = define_proc("gtk_calendar_get_date",{P,I,I,I}) + + function cal_select_month(atom handle, integer mo, integer yr=0) + while mo < 1 do yr -= 1 mo += 12 end while + while mo > 12 do yr += 1 mo -= 12 end while + gtk_proc("gtk_calendar_select_month",{P,I,I},{handle,mo-1,yr}) + return 1 + end function + + function cal_set_day(atom handle, integer day) + object curr = get(handle,"date") + curr[3] = day + cal_set_date(handle,curr) + return 1 + end function + + function cal_set_month(atom handle, integer month) + object curr = get(handle,"date") + curr[2] = month + cal_set_date(handle,curr) + return 1 + end function + + function cal_set_year(atom handle, integer year) + object curr = get(handle,"date") + curr[1] = year + cal_set_date(handle,curr) + return 1 + end function + + function cal_set_date(atom handle, object cdate) + object dt = 0 + integer yr, mo, da + + dt = datetime:parse(cdate,"%Y/%m/%d") + if atom(dt) then + dt = datetime:parse(cdate,"%Y,%m,%d") + end if + if atom(dt) then + dt = datetime:parse(cdate,"%m/%d/%y") + end if + if atom(dt) then + dt = datetime:parse(cdate,"%m/%d/%Y") + end if + if atom(dt) then + dt = datetime:parse(cdate,"%y/%m/%d") + end if + + if atom(dt) then + if cdate[1] > 31 then -- Y/M/D + yr = cdate[1] + mo = cdate[2] + da = cdate[3] + end if + if cdate[3] > 31 then -- M/D/Y + mo = cdate[1] + da = cdate[2] + yr = cdate[3] + end if + else + yr = dt[1] + mo = dt[2] + da = dt[3] + end if + + if yr < 1900 then yr += 1900 end if + gtk_proc("gtk_calendar_select_month",{P,I,I},{handle,mo-1,yr}) + gtk_proc("gtk_calendar_select_day",{P,I},{handle,da}) + return 1 + end function + + function setCalendarEuDate(atom handle, object edt) + edt[1] += 1900 + return cal_set_date(handle,edt) + end function + + function cal_get_date(atom handle, object fmt=0) + atom y = allocate(8,1), m = allocate(8,1), d = allocate(8,1) + object clock + if atom(fmt) and fmt = 0 then + fmt = "%A, %b %d, %Y" + else + fmt = peek_string(fmt) + end if + object result + c_proc(get_date,{handle,y,m,d}) + result = datetime:new(peek4u(y),peek4u(m)+1,peek4u(d)) + clock = datetime:now() + result = result[1..3] & clock[4..6] + result = datetime:format(result,fmt) + return result + end function + + function cal_get_datetime(atom handle, object fmt=1) + atom y = allocate(8,1), m = allocate(8,1), d = allocate(8,1) + object result + c_proc(get_date,{handle,y,m,d}) + result = datetime:now() -- for current hr,min,sec + result[1] = peek4u(y) + result[2] = peek4u(m)+1 + result[3] = peek4u(d) + if fmt = 0 then -- set hr,min,sec to zero; + result[4] = 0 + result[5] = 0 + result[6] = 0 + end if + return result + end function + + function cal_get_eu_date(atom handle) --returns {y,m,d} in Eu fmt. + atom y = allocate(8,1), m = allocate(8,1), d = allocate(8,1) + c_proc(get_date,{handle,y,m,d}) + sequence result = {peek4u(y)-1900,peek4u(m)+1,peek4u(d)} + return result + end function + + function cal_get_ymd(atom handle, integer full=0) + object clock + switch full do + case 0 then return cal_get_eu_date(handle) + {1900,0,0} + case 1 then return cal_get_eu_date(handle) + {1900,0,0} & {0,0,0} + case 2 then clock = datetime:now() + return cal_get_eu_date(handle) + {1900,0,0} & clock[4..6] + case else return cal_get_eu_date(handle) + {1900,0,0} + end switch + end function + + function cal_get_day(atom handle) + atom y = allocate(8,1), m = allocate(8,1), d = allocate(8,1) + c_proc(get_date,{handle,y,m,d}) + integer result = peek4u(d) + return result + end function + + function cal_get_month(atom handle) + atom y = allocate(8,1), m = allocate(8,1), d = allocate(8,1) + c_proc(get_date,{handle,y,m,d}) + integer result = peek4u(m) + return result+1 + end function + + function cal_get_year(atom handle) + atom y = allocate(8,1), m = allocate(8,1), d = allocate(8,1) + c_proc(get_date,{handle,y,m,d}) + integer result = peek4u(y) + return result + end function + +widget[GtkCellView] = {"gtk_cell_view", +{GtkCellLayout,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{P,P},-routine_id("newCellView")}, + {"set_model",{P,P}}, + {"get_model",{P},P}, + {"set_displayed_row",{P,P}}, + {"get_displayed_row",{P},P,0,GtkTreePath}, + {"set_draw_sensitive",{P,B}}, + {"get_draw_sensitive",{P},B}, + {"set_fit_model",{P,B}}, + {"get_fit_model",{P},B}, +"GtkCellView"} + + function newCellView(atom x=0, atom y=0) + if class_id(x) = GtkCellArea + and class_id(y) = GtkCellAreaContext then + return gtk_func("gtk_cell_view_new_with_context",{P,P},{x,y}) + elsif atom(x) and x > 0 then + if class_id(x) = GdkPixbuf then + return gtk_func("gtk_cell_view_new_with_pixbuf",{P},{x}) + end if + elsif string(x) then + return gtk_func("gtk_cell_view_new_with_markup",{P},{allocate_string(x)}) + end if + end function + +widget[GtkDrawingArea] = {"gtk_drawing_area", +{GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, +"GtkDrawingArea"} + +widget[GtkSearchEntry] = {"gtk_search_entry", --3.6 +{GtkEntry,GtkWidget,GtkBuildable,GtkEditable,GtkCellEditable,GObject}, + {"new",{},P}, + {"handle_event",{P,P},B}, +"GtkSearchEntry"} + +widget[GtkEntryBuffer] = {"gtk_entry_buffer", +{GObject}, + {"new",{S,I},P}, + {"get_text",{P},S}, + {"set_text",{P,S,I}}, + {"get_bytes",{P},I}, + {"get_length",{P},I}, + {"set_max_length",{P,I}}, + {"get_max_length",{P},I}, + {"insert_text",{P,I,S,I},I}, + {"delete_text",{P,I,I},I}, + {"emit_deleted_text",{P,I,I}}, + {"emit_inserted_text",{P,I,S,I}}, +"GtkEntryBuffer"} + +widget[GtkEntryCompletion] = {"gtk_entry_completion", +{GtkCellLayout,GtkBuildable,GObject}, + {"new",{P},-routine_id("newEntryCompletion")}, + {"get_entry",{P},P,0,GtkEntry}, + {"set_model",{P,P}}, + {"get_model",{P},P,0,GtkTreeModel}, + {"set_match_func",{P,P,P,P}}, + {"set_minimum_key_length",{P,I}}, + {"get_minimum_key_length",{P},I}, + {"compute_prefix",{P,S},S}, + {"get_completion_prefix",{P},S}, + {"insert_prefix",{P}}, + {"insert_action_text",{P,I,S}}, + {"insert_action_markup",{P,I,S}}, + {"delete_action",{P,I}}, + {"set_text_column",{P,I}}, + {"get_text_column",{P},I}, + {"set_inline_completion",{P,B}}, + {"get_inline_completion",{P},B}, + {"set_inline_selection",{P,B}}, + {"get_inline_selection",{P},B}, + {"set_popup_completion",{P,B}}, + {"get_popup_completion",{P},B}, + {"set_popup_set_width",{P,B}}, + {"get_popup_set_width",{P},B}, + {"set_popup_single_match",{P,B}}, + {"get_popup_single_match",{P},B}, + {"complete",{P}}, +"GtkEntryCompletion"} + + function newEntryCompletion(atom x=0) + if class_id(x) = GtkCellArea then + return gtk_func("gtk_entry_completion_new_with_area",{P},{x}) + else + return gtk_func("gtk_entry_completion_new") + end if + end function + +widget[GtkRevealer] = {"gtk_revealer", -- new in GTK 3.10 +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"set_reveal_child",{P,B}}, + {"get_reveal_child",{P},B}, + {"get_child_revealed",{P},B}, + {"set_transition_duration",{P,I}}, + {"get_transition_duration",{P},I}, + {"set_transition_type",{P,I}}, + {"get_transition_type",{P},I}, +"GtkRevealer"} + +widget[GtkSearchBar] = {"gtk_search_bar", -- new in GTK 3.10 +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"connect_entry",{P,P}}, + {"set_search_mode",{P,B}}, + {"get_search_mode",{P},B}, + {"set_show_close_button",{P,B}}, + {"get_show_close_button",{P},B}, + {"handle_event",{P,P},B}, +"GtkSearchBar"} + +widget[GtkStack] = {"gtk_stack", -- new in GTK 3.10 +{GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"add_named",{P,P,S}}, + {"add_titled",{P,P,S,S}}, + {"set_visible_child",{P,P}}, + {"get_visible_child",{P},P,0,GtkWidget}, + {"set_visible_child_name",{P,S}}, + {"get_visible_child_name",{P},S}, + {"set_visible_child_full",{P,S,I}}, + {"set_homogeneous",{P,B}}, + {"get_homogeneous",{P},B}, + {"set_transition_duration",{P,I}}, + {"get_transition_duration",{P},I}, + {"set_transition_type",{P,I}}, + {"get_transition_type",{P},I}, + {"get_child_by_name",{P,S},P,0,GtkWidget}, -- 3.12 + {"get_transition_running",{P},B}, -- 3.12 + {"get_hhomogeneous",{P},B}, -- 3.16 + {"set_hhomogeneous",{P,B}}, -- 3.16 + {"get_vhomogeneous",{P},B}, -- 3.16 + {"set_vhomogeneous",{P,B}}, -- 3.16 + {"get_interpolate_size",{P},B}, -- 3.18 + {"set_interpolate_size",{P,B}}, -- 3.18 +"GtkStack"} + +widget[GtkStackSidebar] = {"gtk_stack_sidebar", -- 3.16 +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"set_stack",{P,P}}, + {"get_stack",{P},P,0,GtkStack}, +"GtkStackSidebar"} + +widget[GtkStackSwitcher] = {"gtk_stack_switcher", +{GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"set_stack",{P,P}}, + {"get_stack",{P},P,0,GtkStack}, +"GtkStackSwitcher"} + +widget[GtkScrollbar] = {"gtk_scrollbar", +{GtkRange,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{I,P},P}, +"GtkScrollbar"} + +widget[GtkInvisible] = {"gtk_invisible", +{GtkWidget,GtkBuildable,GObject}, + {"new",{P},-routine_id("newInvisible")}, + {"set_screen",{P,P}}, + {"get_screen",{P},P,0,GdkScreen}, +"GtkInvisible"} + + function newInvisible(atom x=0) + if class_id(x) = GdkScreen then + return gtk_func("gtk_invisible_new_for_screen",{P},{x}) + else + return gtk_func("gtk_invisible_new") + end if + end function + +widget[GtkProgressBar] = {"gtk_progress_bar", +{GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"pulse",{P}}, + {"set_fraction",{P,D}}, + {"get_fraction",{P},D}, + {"set_inverted",{P,B}}, + {"get_inverted",{P},B}, + {"set_show_text",{P,B}}, + {"get_show_text",{P},B}, + {"set_text",{P,S}}, + {"get_text",{P},S}, + {"set_ellipsize",{P,B}}, + {"get_ellipsize",{P},B}, + {"set_pulse_step",{P,D}}, + {"get_pulse_step",{P},D}, +"GtkProgressBar"} + +widget[GtkSpinner] = {"gtk_spinner", +{GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"start",{P}}, + {"stop",{P}}, +"GtkSpinner"} + +widget[GtkSwitch] = {"gtk_switch", +{GtkWidget,GtkBuildable,GtkActionable,GObject}, + {"new",{},P}, + {"set_active",{P,B}}, + {"get_active",{P},B}, + {"get_state",{P},B}, -- GTK3.14 + {"set_state",{P,B}}, -- GTK3.14 +"GtkSwitch"} + +widget[GtkLevelBar] = {"gtk_level_bar",-- GTK3.6+ +{GtkWidget,GtkBuildable,GtkBuildable,GtkOrientable,GObject}, + {"new",{D,D},-routine_id("newLevelBar")}, + {"new_for_interval",{D,D},P}, + {"set_mode",{P,I}}, + {"get_mode",{P},I}, + {"set_value",{P,D}}, + {"get_value",{P},D}, + {"set_min_value",{P,D}}, + {"get_min_value",{P},D}, + {"set_max_value",{P,D}}, + {"get_max_value",{P},D}, + {"add_offset_value",{P,S,D}}, + {"remove_offset_value",{P,S}}, + {"get_offset_value",{P,S},D}, + {"get_inverted",{P},B}, --GTK3.8+ + {"set_inverted",{P,B}}, --GTK3.8+ +"GtkLevelBar"} + + function newLevelBar(atom x=0, atom y=0) + if x+y > 0 then + return gtk_func("gtk_level_bar_new_for_interval",{D,D},{x,y}) + else + return gtk_func("gtk_level_bar_new") + end if + end function + +widget[GtkAboutDialog] = {"gtk_about_dialog", +{GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"set_program_name",{P,S}}, + {"get_program_name",{P},S}, + {"set_version",{P,S}}, + {"get_version",{P},S}, + {"set_copyright",{P,S}}, + {"get_copyright",{P},S}, + {"set_comments",{P,S}}, + {"get_comments",{P},S}, + {"set_license",{P,S}}, + {"get_license",{P},S}, + {"set_wrap_license",{P,B}}, + {"get_wrap_license",{P},B}, + {"set_license_type",{P,I}}, + {"get_license_type",{P},I}, + {"set_website",{P,S}}, + {"get_website",{P},S}, + {"set_website_label",{P,S}}, + {"get_website_label",{P},S}, + {"set_authors",{P,A}}, + {"get_authors",{P},V}, + {"set_artists",{P,A}}, + {"get_artists",{P},V}, + {"set_documenters",{P,A}}, + {"get_documenters",{P},V}, + {"set_translator_credits",{P,S}}, + {"get_translator_credits",{P},S}, + {"set_logo",{P,P},-routine_id("setAboutLogo")}, + {"get_logo",{P},P,0,GdkPixbuf}, + {"set_logo_icon_name",{P,S}}, + {"get_logo_icon_name",{P},S}, + {"add_credit_section",{P,S,A}}, +"GtkAboutDialog"} + + function setAboutLogo(atom dlg, object logo) + if string(logo) then + logo = locate_file(logo) + if file_type(logo) = 0 then return 0 end if + end if + if atom(logo) and class_id(logo) = GdkPixbuf then + return 0 + else + logo = create(GdkPixbuf,logo) + end if + gtk_proc("gtk_about_dialog_set_logo",{P,P},{dlg,logo}) + return 1 + end function + +widget[GtkAppChooserDialog] = {"gtk_app_chooser_dialog", +{GtkAppChooser,GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{P,I,P},-routine_id("newAppChooserDialog")}, + {"get_widget",{P},P,0,GtkAppChooserWidget}, + {"set_heading",{P,S}}, + {"get_heading",{P},S}, +"GtkAppChooserDialog"} + + function newAppChooserDialog(atom parent, integer flags, object x) + if string(x) and file_exists(canonical_path(x)) then + x = allocate_string(canonical_path(x),1) + x = gtk_func("g_file_new_for_path",{P},{x}) + return gtk_func("gtk_app_chooser_dialog_new",{P,I,P},{parent,flags,x}) + else + if string(x) then + x = allocate_string(x,1) + end if + return gtk_func("gtk_app_chooser_dialog_new_for_content_type", + {P,I,P},{parent,flags,x}) + end if + end function + +widget[GtkColorChooserDialog] = {"gtk_color_chooser_dialog", +{GtkColorChooser,GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{S,P},P}, +"GtkColorChooserDialog"} + +widget[GtkColorSelectionDialog] = {"gtk_color_selection_dialog", +{GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{S},P}, + {"get_color_selection",{P},P,0,GtkColorSelection}, +"GtkColorSelectionDialog"} + +widget[GtkFileChooserDialog] = {"gtk_file_chooser_dialog", +{GtkFileChooser,GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{S,P,I,S},P}, +"GtkFileChooserDialog"} + +widget[GtkFontChooserDialog] = {"gtk_font_chooser_dialog", +{GtkFontChooser,GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{S,P},P}, +"GtkFontChooserDialog"} + +widget[GtkStyleProvider] = {"gtk_style_provider", +{0}, + {"get_style_property",{P,P,I,P,P},B}, +"GtkStyleProvider"} + +widget[GtkStyleContext] = {"gtk_style_context", +{GObject}, + {"new",{},P}, + {"add_provider",{P,P,I}}, + {"add_provider_for_screen",{P,P,P,I},-routine_id("sc_add_provider_for_screen")}, + {"get",{P,I,S,P,I}}, + {"get_junction_sides",{P},I}, + {"get_parent",{P},P,0,GtkStyleContext}, + {"get_path",{P},P,0,GtkWidgetPath}, + {"get_property",{P,S,I,P}}, + {"get_screen",{P},P,0,GdkScreen}, + {"get_frame_clock",{P},P,0,GdkFrameClock}, + {"get_state",{P},I}, + {"get_style",{P,S,P,I}}, + {"get_style_property",{P,S,P}}, + {"get_section",{P,S},P,0,GtkCssSection}, + {"get_color",{P,I,P}}, + {"get_background_color",{P,I,P}}, -- deprecated 3.16 + {"get_border_color",{P,I,P}}, -- deprecated 3.16 + {"get_border",{P,I,P}}, + {"get_padding",{P,I,P}}, + {"get_margin",{P,I,P}}, + {"invalidate",{P}}, + {"lookup_color",{P,S,P},B}, + {"remove_provider",{P,P}}, + {"remove_provider_for_screen",{P,P}}, + {"reset_widgets",{P}}, + {"set_background",{P,P}}, + {"restore",{P}}, + {"save",{P}}, + {"set_junction_sides",{P,I}}, + {"set_parent",{P,P}}, + {"set_path",{P,P}}, + {"add_class",{P,S}}, + {"remove_class",{P,S}}, + {"has_class",{P,S},B}, + {"list_classes",{P},P,0,GList}, + {"add_region",{P,S,I}}, -- deprecated 3.14 + {"remove_region",{P,S}}, -- deprecated 3.14 + {"has_region",{P,S,I},B}, -- deprecated 3.14 + {"list_regions",{P},P,0,GList}, -- deprecated 3.14 + {"get_screen",{P,P}}, + {"set_frame_clock",{P,P}}, + {"set_state",{P,I}}, + {"set_scale",{P,I}}, -- 3.10 + {"get_scale",{P},I}, -- 3.10 + {"to_string",{P,I},S}, -- 3.20 +"GtkStyleContext"} + + function sc_add_provider_for_screen(atom context, atom scrn, atom pro, integer pri) + gtk_proc("gtk_style_context_add_provider_for_screen",{P,P,I},{scrn,pro,pri}) + return 1 + end function + +widget[GtkRecentChooserDialog] = {"gtk_recent_chooser_dialog", +{GtkRecentChooser,GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{S,P,P},P}, + {"new_for_manager",{S,P,P,P},P}, +"GtkRecentChooserDialog"} + +widget[GtkPrintSettings] = {"gtk_print_settings", +{GObject}, + {"new",{P,P},-routine_id("newPrintSettings")}, + {"load_file",{P,S,P},B}, + {"to_file",{P,S,P},B}, + {"load_key_file",{P,P,S,P},B}, + {"to_key_file",{P,P,S}}, + {"copy",{P},P,0,GtkPrintSettings}, + {"has_key",{P,S},B}, + {"get",{P,S},S}, + {"set",{P,S,S}}, + {"unset",{P,S}}, + {"foreach",{P,P,P}}, + {"get_bool",{P,S},B}, + {"set_bool",{P,S,B}}, + {"get_double",{P,S},D}, + {"get_double_with_default",{P,S,D},D}, + {"set_double",{P,S,D}}, + {"get_length",{P,S,I},D}, + {"set_length",{P,S,D,I}}, + {"get_int",{P,S},I}, + {"get_int_with_default",{P,S,I},I}, + {"set_int",{P,S,I}}, + {"get_printer",{P},S}, + {"set_printer",{P,S}}, + {"get_orientation",{P},I}, + {"set_orientation",{P,I}}, + {"get_paper_size",{P},P,0,GtkPaperSize}, + {"set_paper_size",{P,P}}, + {"get_paper_width",{P,I},D}, + {"set_paper_width",{P,D,I}}, + {"get_paper_height",{P,I},D}, + {"set_paper_height",{P,D,I}}, + {"get_use_color",{P},B}, + {"set_use_color",{P,B}}, + {"get_collate",{P},B}, + {"set_collate",{P,B}}, + {"get_reverse",{P},B}, + {"set_reverse",{P,B}}, + {"get_duplex",{P},I}, + {"set_duplex",{P,I}}, + {"get_quality",{P},I}, + {"set_quality",{P,I}}, + {"get_n_copies",{P},I}, + {"set_n_copies",{P,I}}, + {"get_number_up",{P},I}, + {"set_number_up",{P,I}}, + {"get_number_up_layout",{P},I}, + {"set_number_up_layout",{P,I}}, + {"get_resolution",{P},I}, + {"set_resolution",{P,I}}, + {"get_resolution_x",{P},I}, + {"get_resolution_y",{P},I}, + {"get_printer_lpi",{P},D}, + {"set_printer_lpi",{P,D}}, + {"get_scale",{P},D}, + {"set_scale",{P,D}}, + {"get_print_pages",{P},I}, + {"set_print_pages",{P,I}}, + {"get_page_ranges",{P,I},P,0,GtkPageRange}, + {"set_page_ranges",{P,P},-routine_id("ps_set_page_ranges")}, + {"get_page_set",{P},I}, + {"set_page_set",{P,I}}, + {"get_default_source",{P},S}, + {"set_default_source",{P,S}}, + {"get_media_type",{P},S}, + {"set_media_type",{P,S}}, + {"get_dither",{P},S}, + {"set_dither",{P,S}}, + {"get_finishings",{P},S}, + {"set_finishings",{P,S}}, + {"get_output_bin",{P},S}, + {"set_output_bin",{P,S}}, +"GtkPrintSettings"} + + function newPrintSettings(object x=0, object y=0) + atom err=allocate(8,1) + if atom(x) and x = 0 then + return gtk_func("gtk_print_settings_new") + end if + if class_id(x) = GKeyFile then + y = allocate_string(y,1) + return gtk_func("gtk_print_settings_new_from_key_file",{P,P,P},{x,y,err}) + end if + if string(x) and file_exists(canonical_path(x)) then + x = allocate_string(canonical_path(x),1) + return gtk_func("gtk_print_settings_new_from_file",{P,P},{x,err}) + end if + end function + + function ps_set_page_ranges(atom x, object r) + atom m = allocate_data(8) + poke(m,r[1]) + poke(m+4,r[2]) + gtk_proc("gtk_print_settings_set_pages_ranges",{P,P,I},{x,m,2}) + return 1 + end function + +widget[GtkPaperSize] = {"gtk_paper_size", +{0}, + {"new",{P,P,D,D},-routine_id("newPaperSize")}, + {"new_from_ppd",{S,S,D,D},P}, + {"new_from_ipp",{S,D,D},P,0,GtkPaperSize}, -- 3.16 + {"new_custom",{S,S,D,D,I},P}, + {"copy",{P},P,0,GtkPaperSize}, + {"is_equal",{P,P},B}, + {"get_name",{P},S}, + {"get_display_name",{P},S}, + {"get_ppd_name",{P},S}, + {"get_width",{P,I},D}, + {"get_height",{P,I},D}, + {"is_custom",{P},B}, + {"set_size",{P,D,D,I}}, + {"get_default_top_margin",{P,I},D}, + {"get_default_bottom_margin",{P,I},D}, + {"get_default_left_margin",{P,I},D}, + {"get_default_right_margin",{P,I},D}, +"GtkPaperSize"} + + function newPaperSize(object a=0, object b=0, atom c=0, atom d=0) + if string(a) and atom(b) and b = 0 and c = 0 and d = 0 then + a = allocate_string(a,1) + return gtk_func("gtk_paper_size_new",{P},{a}) + end if + if string(a) and atom(b) and b > 0 and c > 0 then + a = allocate_string(a,1) + return gtk_func("gtk_paper_size_new_from_ipp",{P,D,D},{a,b,c}) + end if + if string(a) and string(b) and c > 0 and d > 0 then + a = allocate_string(a,1) + b = allocate_string(b,1) + return gtk_func("gtk_paper_size_new_from_ppd",{P,P,D,D},{a,b,c,d}) + end if + end function + +export function get_paper_sizes(integer cust=0) + object ps = gtk_func("gtk_paper_size_get_paper_sizes",{P},{cust}) + ps = unpack_gs_atom_list(ps) + return ps +end function + +export function get_paper_size_names(integer cust=0) + object ps = get_paper_sizes(cust) + for i = 1 to length(ps) do + ps[i] = gtk_str_func("gtk_paper_size_get_name",{P},{ps[i]}) + end for + return ps +end function + +widget[GtkPageSetup] = {"gtk_page_setup", +{GObject}, + {"new",{},P}, + {"copy",{P},P,0,GtkPageSetup}, + {"get_orientation",{P},I}, + {"set_orientation",{P,I}}, + {"get_paper_size",{P},P,0,GtkPaperSize}, + {"set_paper_size",{P,P}}, + {"get_top_margin",{P,I},D}, + {"set_top_margin",{P,D,I}}, + {"get_bottom_margin",{P,I},D}, + {"set_bottom_margin",{P,D,I}}, + {"get_left_margin",{P,I},D}, + {"set_left_margin",{P,D,I}}, + {"get_right_margin",{P,I},D}, + {"set_right_margin",{P,D,I}}, + {"set_paper_size_and_default_margins",{P,P}}, + {"get_paper_width",{P,I},D}, + {"get_paper_height",{P,I},D}, + {"get_page_width",{P,I},D}, + {"get_page_height",{P,I},D}, + {"new_from_file",{S,P},P,0,GtkPageSetup}, + {"load_file",{P,S,P},B}, + {"to_file",{P,S},-routine_id("ps_to_file")}, +"GtkPageSetup"} + + function ps_to_file(atom setup, object filename) + atom err = allocate(8,1) err = 0 + return gtk_func("gtk_page_setup_to_file",{P,P,P},{setup,filename,err}) + end function + +widget[GtkPageRange] = {"gtk_page_range", +{0}, +"GtkPageRange"} + +widget[GtkPrintOperation] = {"gtk_print_operation", +{GObject}, + {"new",{},P}, + {"set_allow_async",{P,B}}, + {"get_error",{P,P}}, + {"set_default_page_setup",{P,P}}, + {"get_default_page_setup",{P},P,0,GtkPageSetup}, + {"set_print_settings",{P,P}}, + {"get_print_settings",{P},P,0,GtkPrintSettings}, + {"set_job_name",{P,S}}, + {"get_job_name",{P},-routine_id("getPrintOpJobName")}, + {"set_n_pages",{P,I}}, + {"get_n_pages_to_print",{P},I}, + {"set_current_page",{P,I}}, + {"set_use_full_page",{P,B}}, + {"set_unit",{P,I}}, + {"set_export_filename",{P,S}}, + {"set_show_progress",{P,B}}, + {"set_track_print_status",{P,B}}, + {"set_custom_tab_label",{P,S}}, + {"run",{P,P,P,P},I}, + {"cancel",{P}}, + {"draw_page_finish",{P}}, + {"set_defer_drawing",{P}}, + {"get_status",{P},I}, + {"get_status_string",{P},S}, + {"is_finished",{P},B}, + {"set_support_selection",{P,B}}, + {"get_support_selection",{P},B}, + {"set_has_selection",{P,B}}, + {"get_has_selection",{P},B}, + {"set_embed_page_setup",{P,B}}, + {"get_embed_page_setup",{P},B}, +"GtkPrintOperation"} + + function getPrintOpJobName(atom op) + object job = allocate(32,1), err = allocate(32,1) err = 0 + gtk_func("g_object_get",{P,P,P,P},{op,"job name",job,err}) + object result + ifdef BITS64 then -- thanks pete eberlein + result = peek8u(job) + elsedef + result = peek4u(job) + end ifdef + if result > 0 then + result = peek_string(result) + end if + return result + end function + +widget[GtkPrintContext] = {"gtk_print_context", +{GObject}, + {"get_cairo_context",{P},P}, + {"set_cairo_context",{P,P,D,D}}, + {"get_page_setup",{P},P,0,GtkPageSetup}, + {"get_width",{P},D}, + {"get_height",{P},D}, + {"get_dpi_x",{P},D}, + {"get_dpi_y",{P},D}, + {"get_pango_fontmap",{P},P,0,PangoFontMap}, + {"create_pango_context",{P},P,0,PangoContext}, + {"create_pango_layout",{P},P,0,PangoLayout}, + {"get_hard_margins",{P,D,D,D,D},B}, +"GtkPrintContext"} + +widget[GtkPrintUnixDialog] = {"gtk_print_unix_dialog", +{GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{S,P},P}, + {"set_page_setup",{P,P}}, + {"get_page_setup",{P},P,0,GtkPageSetup}, + {"set_current_page",{P,I}}, + {"get_current_page",{P},I}, + {"set_settings",{P,P}}, + {"get_settings",{P},P,0,GtkPrintSettings}, + {"get_selected_printer",{P},P,0,GtkPrinter}, + {"add_custom_tab",{P,P,P}}, + {"set_support_selection",{P,B}}, + {"get_support_selection",{P},B}, + {"get_has_selection",{P},B}, + {"set_embed_page_setup",{P,B}}, + {"get_embed_page_setup",{P},B}, + {"set_manual_capabilities",{P,I}}, + {"get_manual_capabilities",{P},I}, +"GtkPrintUnixDialog"} + +widget[GtkPageSetupUnixDialog] = {"gtk_page_setup_unix_dialog", +{GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{S,P},P}, + {"set_page_setup",{P,P}}, + {"get_page_setup",{P},P,0,GtkPageSetup}, + {"set_print_settings",{P,P}}, + {"get_print_settings",{P},P,0,GtkPrintSettings}, +"GtkPageSetupUnixDialog"} + +widget[GtkListBox] = {"gtk_list_box", -- new in GTK 3.10 +{GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"prepend",{P,P}}, + {"insert",{P,P,I}}, + {"select_row",{P,P}}, + {"select_all",{P}}, -- 3.14 + {"unselect_all",{P}}, -- 3.14 + {"unselect_row",{P,P}}, -- 3.14 + {"get_selected_row",{P},P,0,GtkListBoxRow}, + {"get_selected_rows",{P},X,0,GList},-- 3.14 + {"row_is_selected",{P},B}, -- 3.14 + {"selected_foreach",{P,P,P}}, -- 3.14 + {"set_selection_mode",{P,I}}, + {"get_selection_mode",{P},I}, + {"set_activate_on_single_click",{P,B}}, + {"get_activate_on_single_click",{P},B}, + {"set_adjustment",{P,P}}, + {"get_adjustment",{P},P,0,GtkAdjustment}, + {"set_placeholder",{P,P}}, + {"get_row_at_index",{P,I},P,0,GtkListBoxRow}, + {"get_row_at_y",{P,I},P,0,GtkListBoxRow}, + {"invalidate_filter",{P}}, + {"invalidate_headers",{P}}, + {"invalidate_sort",{P}}, + {"set_filter_func",{P,P,P,P}}, + {"set_header_func",{P,P,P,P}}, + {"set_sort_func",{P,P,P,P}}, + {"drag_highlight_row",{P,P}}, + {"drag_unhighlight_row",{P}}, + {"bind_model",{P,P,P,P,P}}, -- 3.16 +"GtkListBox"} + +widget[GtkListBoxRow] = {"gtk_list_box_row", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"changed",{P}}, + {"get_header",{P},P,0,GtkWidget}, + {"get_type",{},I}, + {"set_header",{P,P}}, + {"get_index",{P},I}, + {"set_activatable",{P,B}}, + {"set_selectable",{P,B}}, + {"get_selectable",{P},B}, +"GtkListBoxRow"} + +widget[GtkPopover] = {"gtk_popover", -- new in GTK 3.12 +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{P,P},-routine_id("newPopover")}, + {"bind_model",{P,P,S}}, + {"set_relative_to",{P,P}}, + {"get_relative_to",{P},P,0,GtkWidget}, + {"set_pointing_to",{P,P}}, + {"get_pointing_to",{P,P},B}, + {"set_position",{P,I}}, + {"get_position",{P},I}, + {"set_modal",{P,B}}, + {"get_modal",{P},B}, + {"get_transitions_enabled",{P},B}, + {"set_transitions_enabled",{P,B}}, + {"get_default_widget",{P},P,0,GtkWidget}, -- 3.18 + {"set_default_widget",{P,P}}, -- 3.18 + {"get_constrain_to",{P},P}, -- 3.20 + {"set_constrain_to",{P,P}}, -- 3.20 + {"popup",{P}}, -- 3.21 + {"popdown",{P}}, -- 3.21 +"GtkPopover"} + + function newPopover(atom a=0, atom b=0) + if class_id(b) = GMenuModel then + return gtk_func("gtk_popover_new_from_model",{P,P},{a,b}) + else + return gtk_func("gtk_popover_new",{P},{a}) + end if + end function + +widget[GtkPopoverMenu] = {"gtk_popover_menu", -- 3.16 +{GtkPopover,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"open_submenu",{P,S}}, +"GtkPopoverMenu"} + +widget[GtkPlacesSidebar] = {"gtk_places_sidebar", -- new 3.10 +{GtkScrolledWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"set_open_flags",{P,I}}, + {"get_open_flags",{P},I}, + {"set_location",{P,P}}, + {"get_location",{P},P,0,GFile}, + {"set_show_desktop",{P,B}}, + {"get_show_desktop",{P},B}, + {"add_shortcut",{P,P}}, + {"remove_shortcut",{P,P}}, + {"list_shortcuts",{P},A,0,GSList}, + {"get_nth_bookmark",{P,I},P,0,GFile}, + {"get_show_connect_to_server",{P},B}, -- deprecated 3.18 + {"set_show_connect_to_server",{P,B}}, -- deprecated 3.18 + {"set_local_only",{P,B}}, -- 3.12 + {"get_local_only",{P},B}, -- 3.12 + {"get_show_enter_location",{P},B}, --3.14 + {"set_show_enter_location",{P,B}}, --3.14 + {"get_show_other_locations",{P},B}, -- 3.18 + {"set_show_other_locations",{P,B}}, -- 3.18 + {"get_show_recent",{P},B}, -- 3.18 + {"set_show_recent",{P,B}}, -- 3.18 + {"get_show_trash",{P},B}, -- 3.18 + {"set_show_trash",{P,B}}, -- 3.18 + {"set_drop_targets_visible",{P,B,P}}, -- 3.18 +"GtkPlacesSidebar"} + +widget[GtkHeaderBar] = {"gtk_header_bar", -- new in GTK 3.10 +{GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"set_title",{P,S}}, + {"get_title",{P},S}, + {"set_subtitle",{P,S}}, + {"get_subtitle",{P},S}, + {"set_has_subtitle",{P,B}}, -- 3.12 + {"get_has_subtitle",{P},B}, -- 3.12 + {"set_custom_title",{P,P}}, + {"get_custom_title",{P},P,0,GtkWidget}, + {"pack_start",{P,P}}, + {"pack_end",{P,P}}, + {"set_show_close_button",{P,B}}, + {"get_show_close_button",{P},B}, + {"set_decoration_layout",{P,S}}, -- 3.12 + {"get_decoration_layout",{P},S}, -- 3.12 +"GtkHeaderBar"} + +widget[GtkPrinter] = {"gtk_printer", +{GObject}, + {"new",{S,P,B},P}, + {"get_backend",{P},P}, + {"get_name",{P},S}, + {"get_state_message",{P},S}, + {"get_description",{P},S}, + {"get_location",{P},S}, + {"get_icon_name",{P},S}, + {"get_job_count",{P},I}, + {"is_active",{P},B}, + {"is_paused",{P},B}, + {"is_accepting_jobs",{P},B}, + {"is_virtual",{P},B}, + {"is_default",{P},B}, + {"accepts_ps",{P},B}, + {"accepts_pdf",{P},B}, + --{"list_papers",{P},X,0,GList}, -- buggy! + {"compare",{P,P},I}, + {"has_details",{P},B}, + {"request_details",{P}}, + {"get_capabilities",{P},I}, + {"get_default_page_size",{P},P,0,GtkPageSetup}, + {"get_hard_margins",{P,D,D,D,D},B}, +"GtkPrinter"} + +widget[GtkPrintJob] = {"gtk_print_job", +{GObject}, + {"new",{S,P,P,P},P}, + {"get_settings",{P},P,0,GtkPrintSettings}, + {"get_printer",{P},P,0,GtkPrinter}, + {"get_title",{P},S}, + {"get_status",{P},I}, + {"set_source_file",{P,S,P},B}, + {"get_surface",{P,P},P,0,CairoSurface_t}, + {"send",{P,P,P,P}}, + {"set_track_print_status",{P,B}}, + {"get_track_print_status",{P},B}, + {"get_pages",{P},I}, + {"set_pages",{P,I}}, + {"get_page_ranges",{P,I},P,0,GtkPageRange}, + {"set_page_ranges",{P,P},-routine_id("setPageRanges")}, + {"get_page_set",{P},I}, + {"set_page_set",{P,I}}, + {"get_num_copies",{P},I}, + {"set_num_copies",{P,I}}, + {"get_scale",{P},D}, + {"set_scale",{P,D}}, + {"get_n_up",{P},I}, + {"set_n_up",{P,I}}, + {"get_n_up_layout",{P},I}, + {"set_n_up_layout",{P,I}}, + {"get_rotate",{P},B}, + {"set_rotate",{P,B}}, + {"get_collate",{P},B}, + {"set_collate",{P,B}}, + {"get_reverse",{P},B}, + {"set_reverse",{P,B}}, +"GtkPrintJob"} + +widget[GtkFlowBox] = {"gtk_flow_box", -- GTK 3.12 +{GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"insert",{P,P,I}}, + {"get_child_at_index",{P,I},P,0,GtkFlowBoxChild}, + {"set_hadjustment",{P,P}}, + {"set_vadjustment",{P,P}}, + {"set_homogeneous",{P,B}}, + {"get_homogeneous",{P},B}, + {"set_row_spacing",{P,I}}, + {"get_row_spacing",{P},I}, + {"set_column_spacing",{P,I}}, + {"get_column_spacing",{P},I}, + {"set_min_children_per_line",{P,I}}, + {"get_min_children_per_line",{P},I}, + {"set_max_children_per_line",{P,I}}, + {"get_max_children_per_line",{P},I}, + {"set_activate_on_single_click",{P,B}}, + {"get_activate_on_single_click",{P},B}, + {"selected_foreach",{P,P,P}}, + {"get_selected_children",{P},X,0,GList}, + {"select_child",{P,P}}, + {"unselect_child",{P,P}}, + {"select_all",{P}}, + {"unselect_all",{P}}, + {"set_selection_mode",{P,I}}, + {"get_selection_mode",{P},I}, + {"set_filter_func",{P,P,P,P}}, + {"invalidate_filter",{P}}, + {"set_sort_func",{P,P,P,P}}, + {"invalidate_sort",{P}}, + {"bind_model",{P,P,P,P,P}}, -- 3.18 +"GtkFlowBox"} + +widget[GtkFlowBoxChild] = {"gtk_flow_box_child", -- GTK 3.12 +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"get_index",{P},I}, + {"is_selected",{P},B}, + {"changed",{P}}, +"GtkFlowBoxChild"} + +widget[GtkMountOperation] = {"gtk_mount_operation", +{GObject}, + {"new",{P},P}, + {"is_showing",{P},B}, + {"set_parent",{P,P}}, + {"get_parent",{P},P,0,GtkWindow}, + {"set_screen",{P,P}}, + {"get_screen",{P},P,0,GdkScreen}, +"GtkMountOperation"} + +---------------------------------------------------------------------- +-- stocklist is not a real GTK widget, we just fake it for convenience +---------------------------------------------------------------------- +widget[GtkStockList] = {"gtk_stocklist", -- deprecated in GTK 3.12+ +{0}, +"GtkStockList"} + + function newStockList() + object list = gtk_func("gtk_stock_list_ids") + return to_sequence(list) + end function + +---------------------------------------------------------------------- +-- Support for Gestures; +---------------------------------------------------------------------- + +widget[GtkEventController] = {"gtk_event_controller", +{GObject}, + {"get_propagation_phase",{P},I}, + {"set_propagation_phase",{P,I}}, + {"handle_event",{P,P},B}, + {"get_widget",{P},P,0,GtkWidget}, + {"reset",{P}}, +"GtkEventController"} + +widget[GdkFrameClock] = {"gdk_frame_clock", +{GObject}, + {"get_frame_time",{P},I}, + {"request_phase",{P,P}}, + {"begin_updating",{P}}, + {"end_updating",{P}}, + {"get_frame_counter",{P},I}, + {"get_history_start",{P},I}, + {"get_timings",{P,I},P}, + {"get_current_timings",{P},P,0,GdkFrameTimings}, + {"get_refresh_info",{P,I,I,I}}, +"GdkFrameClock"} + +widget[GdkFrameTimings] = {"gdk_frame_timings", +{GObject}, + {"get_frame_counter",{P},I}, + {"get_complete",{P},B}, + {"get_frame_time",{P},I}, + {"get_presentation_time",{P},I}, + {"get_refresh_interval",{P},I}, + {"get_predicted_presentation_time",{P},I}, +"GdkFrameTimings"} + +widget[GdkEvent] = {"gdk_event", +{GObject}, + {"new",{},P}, + {"peek",{},P,0,GdkEvent}, + {"get",{},P,0,GdkEvent}, + {"put",{P}}, + {"copy",{P},P,0,GdkEvent}, + {"get_axis",{P,I,D},B}, + {"get_button",{P,P},B}, + {"get_keycode",{P,P},B}, + {"get_keyval",{P,P},B}, + {"get_root_coords",{P,D,D},B}, + {"get_scroll_direction",{P,P},B}, + {"get_scroll_deltas",{P,D,D},B}, + {"get_state",{P,P},B}, + {"get_time",{P},I}, + {"get_window",{P},P,0,GdkWindow}, + {"get_event_type",{P},I}, + {"get_event_sequence",{P},P,0,GdkEventSequence}, + {"request_motions",{P}}, + {"get_click_count",{P,P},B}, + {"get_coords",{P,D,D},B}, + {"triggers_context_menu",{P},B}, + {"handler_set",{P,P,P}}, + {"set_screen",{P,P}}, + {"get_screen",{P},P,0,GdkScreen}, + {"set_device",{P,P}}, + {"get_device",{P},P,0,GdkDevice}, + {"set_source_device",{P,P}}, + {"get_source_device",{P},P,0,GdkDevice}, +"GdkEvent"} + +widget[GdkEventSequence] = {"gdk_event_sequence", +{GdkEvent}, +"GdkEventSequence"} + +widget[GtkGesture] = {"gtk_gesture", --GTK3.14 +{GtkEventController,GObject}, + {"get_device",{P},P}, + {"get_window",{P},P}, + {"set_window",{P,P}}, + {"is_active",{P},B}, + {"is_recognized",{P},B}, + {"get_sequence_state",{P,P},I}, + {"set_sequence_state",{P,P,I},B}, + {"set_state",{P,I},B}, + {"get_sequences",{P},A}, + {"handles_sequence",{P,P},B}, + {"get_last_updated_sequence",{P},P}, + {"get_last_event",{P,P},P}, + {"get_point",{P,P,D,D},B}, + {"get_bounding_box",{P,P},B}, + {"get_bounding_box_center",{P,D,D},B}, + {"group",{P,P}}, + {"ungroup",{P}}, + {"get_group",{P},A}, + {"is_grouped_with",{P,P},B}, +"GtkGesture"} + +widget[GtkGestureSingle] = {"gtk_gesture_single", +{GtkGesture,GtkEventController,GObject}, + {"get_exclusive",{P},B}, + {"set_exclusive",{P,B}}, + {"get_touch_only",{P},B}, + {"set_touch_only",{P,B}}, + {"get_button",{P},I}, + {"set_button",{P,I}}, + {"get_current_button",{P},I}, + {"get_current_sequence",{P},P}, +"GtkGestureSingle"} + +widget[GtkGestureRotate] = {"gtk_gesture_rotate", +{GtkGesture,GtkEventController,GObject}, + {"new",{P},P}, + {"get_angle_delta",{P},D}, +"GtkGestureRotate"} + +widget[GtkGestureZoom] = {"gtk_gesture_zoom", +{GtkGesture,GtkEventController,GObject}, + {"new",{P},P}, + {"get_scale_delta",{P},D}, +"GtkGestureZoom"} + +widget[GtkGestureDrag] = {"gtk_gesture_drag", -- 3.14 +{GtkGestureSingle,GtkGesture,GtkEventController,GObject}, + {"new",{P},P}, + {"get_start_point",{P,D,D},B}, + {"get_offset",{P,D,D},B}, +"GtkGestureDrag"} + +widget[GtkGesturePan] = {"gtk_gesture_pan", +{GtkGestureDrag,GtkGestureSingle,GtkGesture,GtkEventController,GObject}, + {"new",{P,I},P}, + {"get_orientation",{P},I}, + {"set_orientation",{P,I}}, +"GtkGesturePan"} + +widget[GtkGestureSwipe] = {"gtk_gesture_swipe", +{GtkGestureSingle,GtkGesture,GtkEventController,GObject}, + {"new",{P},P}, + {"get_velocity",{P,D,D},B}, +"GtkGestureSwipe"} + +widget[GtkGestureLongPress] = {"gtk_gesture_long_press", +{GtkGestureSingle,GtkGesture,GtkEventController,GObject}, + {"new",{P},P}, +"GtkGestureLongPress"} + +widget[GtkGestureMultiPress] = {"gtk_gesture_multi_press", +{GtkGestureSingle,GtkGesture,GtkEventController,GObject}, + {"new",{P},P}, + {"get_area",{P,P},B}, + {"set_area",{P,P}}, +"GtkGestureMultiPress"} + +widget[GtkPadController] = {"gtk_pad_controller", +{GtkEventController,GObject}, + {"new",{P,P,P},P}, + {"set_action_entries",{P,P,I}}, + {"set_action",{P,I,I,I,S,S}}, +"GtkPadController"} + +-------------------------------------------------------------------- +-- Support for openGL; +-------------------------------------------------------------------- + +widget[GdkGLProfile] = {"gdk_gl_profile", + {}, +"GdkGLProfile"} + +widget[GdkGLContext] = {"gdk_gl_context", +{GObject}, + {"new",{},-routine_id("newGLContext")}, + {"clear_current",{}}, + {"make_current",{P}}, + {"get_version",{P,I,I}}, + {"get_shared_context",{P},P,0,GdkGLContext}, + {"get_window",{P},P,0,GdkWindow}, + {"get_visual",{P},P,0,GdkVisual}, + {"get_display",{P},P,0,GdkDisplay}, + {"set_forward_compatible",{P,B}}, + {"get_forward_compatible",{P},B}, + {"set_debug_enabled",{P,B}}, + {"get_debug_enabled",{P},B}, + {"set_required_version",{P,I,I}}, + {"get_required_version",{P,I,I}}, +"GdkGLContext"} + + function newGLContext() -- alias for new; + return c_func("gdk_gl_context_get_current") + end function + +widget[GtkGLArea] = {"gtk_gl_area", -- GTK 3.16 +{GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"get_context",{P},P}, + {"set_has_alpha",{P,B}}, + {"get_has_alpha",{P},B}, + {"set_has_depth_buffer",{P,B}}, + {"get_has_depth_buffer",{P},B}, + {"make_current",{P}}, + {"get_auto_render",{P},B}, + {"set_auto_render",{P,B}}, + {"get_error",{P},P}, + {"set_error",{P,P}}, + {"queue_render",{P}}, + {"set_profile",{P,P}}, + {"get_profile",{P},P,0,GdkGLProfile}, + {"get_has_stencil_buffer",{P},B}, + {"set_has_stencil_buffer",{P,B}}, + {"attach_buffers",{P}}, + {"get_required_version",{P,I,I}}, + {"set_required_version",{P,I,I}}, + {"get_use_es",{P},B}, -- 3.22 + {"set_use_es",{P,B}}, -- 3.22 +"GtkGLArea"} + +---------------------------------------------------------------- +-- low-level x11 functions; +---------------------------------------------------------------- + +widget[GdkX11Display] = {"gdk_x11_display", +{GObject}, + {"get_user_time",{P},I}, + {"broadcast_startup_message",{P,S,S,I}}, + {"get_startup_notification_id",{P},S}, + {"set_startup_notification_id",{P,S}}, + {"get_xdisplay",{P},P}, + {"grab",{P}}, + {"ungrab",{P}}, + {"set_cursor_theme",{P,S,I}}, + {"set_window_scale",{P,I}}, + {"get_glx_version",{P,I,I}}, +"GdkX11Display"} + + +widget[GdkX11Screen] = {"gdk_x11_screen", +{GObject}, + {"get_screen_number",{P},I}, + {"get_xscreen",{P},P}, + {"get_window_manager_name",{P},S}, + {"get_monitor_output",{P,I},I}, + {"lookup_visual",{P,I},P,0,GdkVisual}, + {"get_number_of_desktops",{P},I}, + {"get_current_desktop",{P},I}, +"GdkX11Screen"} + +widget[GdkX11Window] = {"gdk_x11_window", +{GObject}, + {"lookup_for_display",{P,P},P,0,GdkWindow}, + {"get_xid",{P},P}, + {"move_to_current_desktop",{P}}, + {"move_to_desktop",{P,I}}, + {"get_desktop",{P},I}, +"GdkX11Window"} + +widget[GtkBindingSet] = {"gtk_binding_set", +{GObject}, + {"new",{S},P}, + {"by_class",{P},P}, + {"find",{S},P}, + {"activate",{P,I,I,P},B}, + {"add_path",{P,P,S,I}}, +"GtkBindingSet"} + +widget[GtkBindingEntry] = {"gtk_binding_entry", +{GtkBindingSet}, + {"add_signal",{P,I,I,S,P}}, + {"add_signal_from_string",{P,S},I}, + {"skip",{P,I,I}}, + {"remove",{P,I,I}}, +"GtkBindingEntry"} + +widget[GdkPixbufAnimation] = {"gdk_pixbuf_animation", +{GdkPixbuf,GObject}, + {"new",{P},-routine_id("newPixbufAnimation")}, + {"get_width",{P},I}, + {"get_height",{P},I}, + {"get_delay_time",{P},I}, + {"is_static_image",{P},B}, + {"get_static_image",{P},P,0,GdkPixbuf}, + {"get_iter",{P,P},P,0,GdkPixbufAnimationIter}, +"GdkPixbufAnimation"} + + function newPixbufAnimation(object name) + atom err = allocate(8,1) err = 0 + if string(name) + and file_exists(canonical_path(name)) then + name = allocate_string(canonical_path(name),1) + end if + return gtk_func("gdk_pixbuf_animation_new_from_file",{P,P},{name,err}) + end function + +widget[GdkPixbufAnimationIter] = {"gdk_pixbuf_animation_iter", +{GObject}, + {"get_pixbuf",{P},P,0,GdkPixbuf}, + {"advance",{P,P},B}, + {"get_delay_time",{P},I}, + {"on_currently_loading_frame",{P},B}, +"GdkPixbufAnimationIter"} + +widget[GtkRecentManager] = {"gtk_recent_manager", +{GObject}, + {"new",{},-routine_id("recent_manager_get_default")}, + {"add_item",{P,S},B}, + {"add_full",{P,S,P},B}, + {"remove_item",{P,S,P},B}, + {"lookup_item",{P,S,P},P,0,GtkRecentInfo}, + {"has_item",{P,S},B}, + {"move_item",{P,S,S,P},B}, + {"get_items",{P},X,0,GtkRecentInfo}, + {"purge_items",{P,P},I}, +"GtkRecentManager"} + + function recent_manager_get_default() + return gtk_func("gtk_recent_manager_get_default") + end function + +widget[GtkBuildable] = {"gtk_buildable", +{GObject}, + {"set_name",{P,S}}, + {"get_name",{P},S}, + {"add_child",{P,P,P,S}}, + {"set_buildable_property",{P,P,S,P}}, + {"construct_child",{P,P,S},P,0,GObject}, + {"custom_tag_start",{P,P,P,S,P,P},B}, + {"custom_tag_end",{P,P,P,S,P}}, + {"custom_finished",{P,P,P,S,P}}, + {"parser_finished",{P,P}}, + {"get_internal_child",{P,P,S},P,0,GObject}, +"GtkBuildable"} + +widget[GtkBuilder] = {"gtk_builder", +{GObject}, + {"new",{},P}, + {"add_callback_symbol",{P,S,P}}, -- 3.10 + {"lookup_callback_symbol",{P,S},P}, -- 3.10 + {"set_application",{P,P}}, -- 3.10 + {"get_application",{P},P,0,GtkApplication}, -- 3.10 + {"add_from_file",{P,S},-routine_id("addBuilderObjects")}, + {"add_from_string",{P,P},-routine_id("addBuilderObjectsStr")}, + {"get_object",{P,P},P}, + {"get_objects",{P},A,0,GSList}, + {"connect",{P},-routine_id("builder_connect")}, + {"set_translation_domain",{P,S}}, + {"get_translation_domain",{P},S}, + {"get_type_from_name",{P,S},I}, +"GtkBuilder"} + +export constant builder = create(GtkBuilder) +object current_builder_file = "" + +export function ID(atom ctl) -- retrieve the Glade ID property; + return vlookup(ctl,registry,1,4,"!") +end function + +export sequence class_name_index = repeat(0,length(widget)) + for i = 1 to length(widget) do + if sequence(widget[i]) then + class_name_index[i] = widget[i][$] + end if + end for + + constant bad_from_file = define_func("gtk_builder_add_from_file",{P,P,P},I) + constant bad_from_string = define_func("gtk_builder_add_from_string",{P,P,I,P},I) + + -- add objects from Glade XML file; + function addBuilderObjects(atom bld, object fname) + atom err = allocate(8,1) err = 0 + integer result = c_func(bad_from_file,{bld,fname,err}) + if result = 0 then + printf(1,"Error code %d loading Builder\n",err) + if err = 0 then + printf(1,"***** GTK version mismatch or other error in Glade.\n") + printf(1,"\t(remove or change the 'requires...' line)") + Error(,,"Error 8623 loading glade file",peek_string(fname)) + end if + abort(0) + end if + return result + end function + + -- add object from inline string or string variable; + function addBuilderObjectsStr(atom bld, object str) + current_builder_file = str + atom err = allocate(8,1) err = 0 + integer len = length(str) + str = allocate_string(str,1) + integer result = c_func(bad_from_string,{bld,str,len,err}) + if result = 0 then + printf(1,"Error 8638: loading Builder %s\n",{current_builder_file}) + if err = 0 then + printf(1,"***** GTK version mismatch or other error in Glade.\n") + printf(1,"\t(remove or change the 'requires...' line)") + end if + abort(0) + end if + return result + end function + + -- link signals defined in Glade, this starts a 'for' loop, + -- running the builder_connect_function for each control; + function builder_connect(atom bld) + gtk_func("gtk_builder_connect_signals_full",{P,P,P},{bld,builder_connect_func,0}) + return 1 + end function + + constant builder_connect_func = call_back(routine_id("builder_connect_function")) + + -- links Glade controls to user-written or Eu functions + + ----------------------------------------------------------------------------- + function builder_connect_function(atom bld, atom obj, object sig, object hdlr, atom cxo) + ----------------------------------------------------------------------------- + hdlr = peek_string(hdlr) + sig = peek_string(sig) + + if atom(current_builder_file) and (current_builder_file > 0) then + current_builder_file = peek_string(current_builder_file) + end if + + atom rid = routine_id(hdlr) + if rid = -1 then + printf(1,"-----------------------------------------------------------------------\n") + printf(1,"-- Undeclared function in %s\n",{current_builder_file}) + printf(1,"-----------------------------------------------------------------------\n") + show_template(hdlr) + abort(1) + else + rid = call_back(rid) + connect(obj,sig,rid,cxo) + end if + + return 1 + end function + + -------------------------------------------------------------------- + procedure load_builder(object parent, object child, object prefix=0) + -------------------------------------------------------------------- + object name, class, path + object x, tree + integer c,n + atom err = allocate(8,1) + + current_builder_file = canonical_path(child) + if file_exists(current_builder_file) then + set(parent,"add from file",current_builder_file,err) + set(parent,"connect") + prefix = filebase(child) + if match(prefix,filebase(prg_name)) then + prefix = 0 -- do not prefix main file objects + end if + x = read_lines(canonical_path(child)) + + elsif string(child) then + set(parent,"add from string",child,err) + set(parent,"connect") + x = split(child,'\n') + end if + + for i = 1 to length(x) do + if string(x[i]) and match("]",{class,name,n}) + end ifdef + + class = find(class,class_name_index) + if class < 1 then + display("Error finding class for []",{name}) + else + if not initialized[class] then + init(class) + end if + tree = widget[class][2] + for z = 1 to length(tree) do + init(tree[z]) + end for + register(n,class,name) + end if + end if +end for + +end procedure + + ------------------------------------------------------------------------------- + procedure show_template(object handlr) -- prompt for missing functions w/Glade; + ------------------------------------------------------------------------------- + printf(1,""" +________ + + ----------------------------------------------------------------------- + global function %s() + ----------------------------------------------------------------------- + + return 1 + end function + +""",{handlr}) + + end procedure + +------------------------------------------------------------------------ +-- Internet conveniences +------------------------------------------------------------------------ + +------------------------------------ +export function show_uri(object uri) +------------------------------------ + +if atom(uri) then + return 0 +end if + +display("URI: []\n",{uri}) + +integer x = find('#',uri) -- in case link to html section; +object tmp + +if x > 0 then + tmp = canonical_path(uri[1..x-1]) + if file_exists(tmp) then + uri = tmp & uri[x..$] + end if +else + tmp = canonical_path(uri) + if file_exists(tmp) then + uri = tmp + end if +end if + +ifdef WINDOWS then + system("explore " & uri,0) + return 1 +end ifdef + +atom err = allocate(8,1) err=0 + +object result = gtk_func("gtk_show_uri",{P,P,P,P}, + {0,allocate_string(uri,1),0,err}) + + return result + +end function + +--------------------------------------------------------------------------- +-- Icon functions +---------------------------- +export function list_icons() +---------------------------- + atom theme = gtk_func("gtk_icon_theme_get_default") + object list = gtk_func("gtk_icon_theme_list_icons",{P,P},{theme,0}) + return to_sequence(list) +end function + +---------------------------------------- +export function has_icon(object name) +---------------------------------------- + atom theme = gtk_func("gtk_icon_theme_get_default") + name = allocate_string(name,1) + return gtk_func("gtk_icon_theme_has_icon",{P,P},{theme,name}) +end function + +---------------------------------------------------------------- +export function valid_icon(object list) +---------------------------------------------------------------- +-- check a list of possible icon names + object result = 0 + if atom(list[1]) then + list = {list} + end if + for i = 1 to length(list) do + result = get_icon_image(list[i]) --display(result) + if string(result) then return 1 end if + end for + return result +end function + +--------------------------------------------------------------- +export function valid_icon_name(object list) +--------------------------------------------------------------- +-- check a list of possible icon names, +-- return string name of first valid + for i = 1 to length(list) do + if valid_icon({list[i]}) > 0 then + return list[i] + end if + if file_exists(locate_file(list[i])) then + return list[i] + end if + end for + return "gtk-missing-image" +end function + +-- get image from a variety of sources; +------------------------------------------------------------------------------------ + function get_icon_image(object icon, object sizex=0, object sizey=0, object sizez=1) +------------------------------------------------------------------------------------- + atom img = 0, ani = 0, default_theme, handle + handle = to_number(icon) + + if class_id(handle) = GdkPixbuf then + img = create(GtkImage,handle) + return img + end if + + if class_id(handle) = GtkImage then + return handle + end if + + if find(icon,stock_list) then + img = gtk_func("gtk_image_new_from_stock",{P,I}, + {allocate_string(icon,1),sizex}) + return img + end if + + default_theme = gtk_func("gtk_icon_theme_get_default",{}) + if gtk_func("gtk_icon_theme_has_icon",{P,P}, + {default_theme,allocate_string(icon,1)}) then + img = create(GdkPixbuf,icon,18,18,sizez) + img = create(GtkImage,img) + register(img,GtkImage) + --display("Has icon []",{icon}) + return img + end if + + icon = locate_file(icon) + + if file_type(icon) = 1 then -- image from file + ani = create(GdkPixbufAnimation,icon,sizex,sizey) + if gtk_func("gdk_pixbuf_animation_is_static_image",{P},{ani}) then + ani = create(GdkPixbuf,icon,sizex*6,sizey*6,sizez) + img = create(GtkImage,ani) + else + img = create(GtkImage) + set(img,"from animation",ani) + end if + return img + end if + + return 0 + end function + +-------------------------------------------------------- +export function icon_info(object name, integer size=6) +-------------------------------------------------------- + atom theme = gtk_func("gtk_icon_theme_get_default") + atom err = allocate(8,1) err = 0 + + atom icon_info = gtk_func("gtk_icon_theme_lookup_icon",{P,P,I,I}, + {theme,name,size,GTK_ICON_LOOKUP_USE_BUILTIN}) + + object results = repeat(0,5) + results = { + gtk_func("gtk_icon_info_load_icon",{P,P},{icon_info,err}), + gtk_func("gtk_icon_info_get_display_name",{P},{icon_info}), + gtk_str_func("gtk_icon_info_get_filename",{P},{icon_info}), + gtk_func("gtk_icon_info_get_base_size",{P},{icon_info}), + gtk_func("gtk_icon_info_get_base_scale",{P},{icon_info}) + } + return results +-- returns {1,2,3,4,5} +-- 1 = pointer to icon_info structure, +-- 2 = display name or null, +-- 3 = full path to icon file, +-- 4 = base size, +-- 5 = base scale +-- some entries missing in some cases +end function + +----------------------------------------------------------------------------------------- +export function xpm_to_pixbuf(object xpm, integer w=0, integer h=0, integer interp=2) +----------------------------------------------------------------------------------------- + atom x = gtk_func("gdk_pixbuf_new_from_xpm_data",{P}, + {allocate_string_pointer_array(xpm)}) + if w + h > 0 then + x = gtk_func("gdk_pixbuf_scale_simple",{P,I,I,I},{x,w,h,interp}) + end if + register(x,GdkPixbuf) + return x +end function + +------------------------------------------------------------------------ +-- Following 3 functions simplify method calls; used mostly internally, +-- but can also be called by the programmer to execute any GTK, GDK or +-- GLib function which has not been implemented in EuGTK. +------------------------------------------------------------------------- +export function gtk_func(object name, object params={}, object values={}) +------------------------------------------------------------------------- +-- syntax: result = gtk_func("gtk_*_*",{formal params},{values}) +-- where formal params might be {P,P,I} (function expects Ptr, Ptr, and Int) +-- and values are the values to be inserted into the formal params before +-- the function is called; + + name = '+' & name + + for i = 1 to length(params) do + if string(values[i]) then + values[i] = allocate_string(values[i],1) + end if + end for + + if atom(values) then + values = {values} + end if + + atom fn = define_func(name,params,P) + + if fn > 0 then + return c_func(fn,values) + else + return -1 + end if + +end function + +----------------------------------------------------------------------------- +export function gtk_str_func(object name, object params={}, object values={}) +----------------------------------------------------------------------------- +-- syntax: same as above, except a string result is returned + + for i = 1 to length(params) do + if string(values[i]) then + values[i] = allocate_string(values[i],1) + end if + end for + + name = '+' & name + + atom fn = define_func(name,params,P) + object result + + if fn > 0 then + if length(params) > 0 then + result = c_func(fn,values) + else + result = c_func(fn,{}) + end if + if result > 0 then + return peek_string(result) + end if + end if + + return 0 +end function + +-------------------------------------------------------------------------- +export function gtk_proc(object name, object params={}, object values={}) +-------------------------------------------------------------------------- +-- syntax: same as above, but no value is returned, used to call GTK procs +atom fn + + if string(values) then values = {values} end if + + name = '+' & name + + for i = 1 to length(params) do + if sequence(values) and string(values[i]) then + values[i] = allocate_string(values[i]) -- keep + end if + end for + + if length(params) = 0 then + fn = define_proc(name) + if fn > 0 then + c_proc(fn,{}) + end if + else + fn = define_proc(name,params) + if fn > 0 then + if atom(values) then values = {values} end if + c_proc(fn,values) + end if + end if +return values +end function + +-- The following 2 functions had to be added for Windows, so that we could search +-- a list of dlls until we find the function name requested. I'm not sure the '+' +-- is necessary for 32-bit Windows, since I don't have a 32-bit computer anymore. +---------------------------------------------------------------------------------------- +export function define_proc(object name, object params={}) +---------------------------------------------------------------------------------------- +atom x + + for i = 1 to length(LIBS) do + if atom(LIBS[i]) and LIBS[i] > 0 then + x = define_c_proc(LIBS[i],name,params) + if x > 0 then + return x + end if + end if + end for + + return -1 +end function + +--------------------------------------------------------------------------- +export function define_func(object name, object params={}, object values=P) +--------------------------------------------------------------------------- +atom x + + ifdef BITS32 and WINDOWS then name = '+' & name end ifdef + for i = 1 to length(LIBS) do + if atom(LIBS[i]) and LIBS[i] > 0 then + x = define_c_func(LIBS[i],name,params,values) + if x > 0 then + return x + end if + end if + end for + + return -1 +end function + +----------------------------------------------------------------------------------- +-- Color handling routines - most are used internally, but exported if you need 'em +----------------------------------------------------------------------------------- + +---------------------------------------- +export function to_rgba(object color) -- converts a color description to rgba ptr; +---------------------------------------- + atom rgba = allocate(32) -- keep; + object c = color + if string(c) then c = allocate_string(c,1) end if + if gtk_func("gdk_rgba_parse",{P,P},{rgba,c}) then + return rgba + else + printf(1,"\nError: invalid color '%s'\n******\n",{color}) + return 0 + end if + return rgba +end function + +------------------------------------------------------- +export function from_rgba(object rgba, object fmt=0) -- converts rgba ptr to description; +------------------------------------------------------- +object result = gtk_str_func("gdk_rgba_to_string",{P},{rgba}) + if fmt=0 then return result + else return fmt_color(result,fmt) + end if +end function + +---------------------------------------------- +function fmt_color(object s, integer fmt=0) -- Convert color to various formats; +---------------------------------------------- + if atom(s) then + if string(peek_string(s)) then + s = peek_string(s) + end if + end if +object w + w = split_any(s,"(,)") + if length(w[1]) = 3 then + w[5] = "1" + end if + for i = 2 to 5 do + w[i] = to_number(w[i]) + end for + if atom(w[5]) then + w[5] = round(w[5],100) + end if + switch fmt do + case 0 then return w[1..length(w[1])+1] + case 1 then return sprintf("#%02x%02x%02x",w[2..4]) + case 2 then return (256*256*w[2])+(256*w[3])+ w[4] + case 3 then return {w[2],w[3],w[4]} + case 4 then return {w[2],w[3],w[4],w[5]} + case 5 then return {w[2],w[3],w[4],256*w[5]} + case 6 then return sprintf("rgba(%d,%d,%d,%2.2f)",w[2..$]) + case 7 then return {w[2]/255,w[3]/255,w[4]/255,w[5]} + case 8 then return sprintf("r=#%x, g=#%x, b=#%x, alpha=#%x",w[2..5]) + case else -- do nothing + end switch +return s +end function + + + +------------------------------------------------------------------------ +-- Following are 5 pre-built, easy to use popup dialogs +-- which save you the trouble of writing tons of code! +-- Refer to documentation/dialogs.html for details. +-- Rewritten for 4.8.8 to preserve images on dialog buttons despite +-- GTK developers' bland, boring preferences :P +-- Beginning with EuGTK 4.9.3, dialogs can be non-modal if desired. +------------------------------------------------------------------------ + +public function Info(object parent=0, object title="Info", + object pri_txt="", object sec_txt="", + object btns=GTK_BUTTONS_OK, + object image="dialog-information", + object icon=0, + integer modal=1, + object addon=0, + integer x=-1, + integer y=-1, + object name="Info") + return Custom(parent,title,pri_txt,sec_txt,btns,image,icon,modal,addon,x,y,name) +end function + +public function Warn(object parent=0, object title="Warning", + object pri_txt="", object sec_txt="", + object btns=GTK_BUTTONS_CLOSE, + object image="dialog-warning", + object icon=0, + integer modal=1, + object addon=0, + integer x=-1, + integer y=-1, + object name="Warn") + return Custom(parent,title,pri_txt,sec_txt,btns,image,icon,modal,addon,x,y,name) +end function + +public function Error(object parent=0, object title="Error", + object pri_txt="", object sec_txt="", + object btns=GTK_BUTTONS_OK_CANCEL, + object image="dialog-error", + object icon=0, + integer modal=1, + object addon=0, + integer x=-1, + integer y=-1, + object name="Error") + return Custom(parent,title,pri_txt,sec_txt,btns,image,icon,modal,addon,x,y,name) +end function + +public function Question(object parent=0, object title="Question", + object pri_txt="", object sec_txt="", + object btns=GTK_BUTTONS_YES_NO, + object image="dialog-question", + object icon=0, + integer modal=1, + object addon=0, + integer x=-1, + integer y=-1, + object name="Question") + return Custom(parent,title,pri_txt,sec_txt,btns,image,icon,modal,addon,x,y,name) +end function + +integer closedlg = call_back(routine_id("close_dialog")) + +-------------------------------------------------------------- +public function Custom( + object parent=0, --1 + object title="Dialog", --2 + object pri_txt="", --3 + object sec_txt="", --4 + object btns=GTK_BUTTONS_OK, --5 + object image=0, --6 + object icon=0, --7 + integer modal=GTK_DIALOG_MODAL, --8 + object addon=0, --9 + integer x=-1, --10 + integer y=-1, --11 + object name="Custom") --12 +-------------------------------------------------------------- + atom dlg = create(GtkDialog) + atom btnbox = create(GtkButtonBox) + atom ca = 0 + atom top = 0, left = 0, right = 0 + atom lbl1 = 0 + atom capanel = create(GtkBox,VERTICAL) + object btn = repeat(0,2) + + if string(parent) then + parent = get(builder,"object",parent) + end if + + if parent = 0 then + for i = 1 to length(registry) do + if registry[i][2] = 293 then + parent = registry[i][1] + exit + end if + end for + end if + + if parent > 0 and atom(icon) and icon = 0 then + icon = get(parent,"icon name") + end if + + if atom(pri_txt) and pri_txt > 0 then pri_txt = unpack(pri_txt) end if + if atom(sec_txt) and sec_txt > 0 then sec_txt = unpack(sec_txt) end if + if class_id(addon) = GdkPixbuf then addon = create(GtkImage,addon) end if + + set(dlg,{ + {"transient for",parent}, + {"title"," " & title}, + {"border width",5}, + {"icon",icon}, + {"position",GTK_WIN_POS_MOUSE}}) + + if string(name) then + set(dlg,"name",name) + end if + + ca = get(dlg,"content area") + capanel = create(GtkBox,VERTICAL) + add(ca,capanel) + + top = create(GtkBox,HORIZONTAL,2) + add(capanel,top) + + left = create(GtkBox,VERTICAL,5) + right = create(GtkBox,VERTICAL,5) + add(top,{left,right}) + + if string(image) then + add(left,create(GtkImage,image,GTK_ICON_SIZE_DIALOG)) + + elsif image > 0 then + if class_id(image) = GdkPixbuf + or class_id(image) = GIcon then + image = create(GtkImage,image) + end if + add(left,image) + end if + + lbl1 = create(GtkLabel) + set(lbl1,"name",name & "_label") + set(lbl1,"markup",text:format("[]\n[]",{pri_txt,sec_txt})) + set(lbl1,"halign",0) + + add(right,lbl1) + + if atom(addon) and addon > 0 then + atom p2 = create(GtkBox,VERTICAL) + add(capanel,p2) + if get(addon,"parent") != 0 then + set(addon,"reparent",p2) + else + add(p2,addon) + end if + end if + + show_all(capanel) + + if integer(btns) then + + switch btns do + + case GTK_BUTTONS_NONE then break + + case GTK_BUTTONS_OK then + btn[1] = create(GtkButton,"gtk-ok") + set(dlg,"add action widget",btn[1],MB_OK) + show(btn[1]) + + case GTK_BUTTONS_OK_CANCEL then + btn[1] = create(GtkButton,"gtk-cancel") + btn[2] = create(GtkButton,"gtk-ok") + set(dlg,"add action widget",btn[1],MB_CANCEL) + set(dlg,"add action widget",btn[2],MB_OK) + show(btn[1]) show(btn[2]) + + case GTK_BUTTONS_CLOSE then + btn[1] = create(GtkButton,"gtk-close") + set(btn[1],"can default",TRUE) + set(dlg,"add action widget",btn[1],MB_CLOSE) + show(btn[1]) + + case GTK_BUTTONS_YES_NO then + btn[1] = create(GtkButton,"gtk-yes") + set(dlg,"add action widget",btn[1],MB_YES) + btn[2] = create(GtkButton,"gtk-no") + set(dlg,"add action widget",btn[2],MB_NO) + show(btn[1]) show(btn[2]) + + case else btn[1] = create(GtkButton,"gtk-ok") + set(btn[1],"can default",TRUE) + set(dlg,"add action widget",btn[1],MB_OK) + show(btn[1]) + + end switch + end if + + if sequence(btns) and not atom(btns[1]) then + set(btnbox,"margin top",5) + pack(capanel,-btnbox) + for i = 1 to length(btns) do + while length(btns[i]) < 3 do btns[i] &= 0 end while + if atom(btns[i][2]) and btns[i][2] = 0 then btns[i][2] = closedlg end if + if atom(btns[i][3]) and btns[i][3] = 0 then btns[i][3] = {dlg,MB_CANCEL} end if + btns[i] = create(GtkButton,btns[i][1],btns[i][2],btns[i][3]) + end for + add(btnbox,btns) + show_all(btnbox) + end if + + if x+y > 0 then + set(dlg,"move",x,y) + end if + + atom result = 0 + set(dlg,"modal",modal) + if modal = GTK_DIALOG_NON_MODAL then + return show_all(dlg) + else + result = get(dlg,"run") + destroy(dlg) + end if + + return result +end function + +------------------------------- +export function run(object dlg) +------------------------------- + if string(dlg) then + dlg = pointer(dlg) + end if + object result = get(dlg,"run") + return result +end function + +global integer dialog_return_value = 0 + +function close_dialog(object ctl, object dlg) + dlg = unpack(dlg) + dialog_return_value = dlg[2] + set(dlg[1],"hide") + return 1 +end function + +-------------------------------------------- +-- Nifty shortcut, thanks to Greg Haberek, +-- allows using local functions without +-- call_back(routine_id()) and scope issues: +-------------------------------------------- +export function _(sequence name, atom rid = routine_id(name)) + if rid > 0 then + return call_back(rid) + end if + return 0 +end function + +--------------------------------- +-- © 2016 by Irv Mullins +--------------------------------- diff --git a/eugtk/GtkEnums.e b/eugtk/GtkEnums.e new file mode 100644 index 0000000..741f014 --- /dev/null +++ b/eugtk/GtkEnums.e @@ -0,0 +1,1514 @@ + +---------------- +namespace enums +---------------- + +export constant version = "4.12.0" + +public include std/io.e +public include std/os.e +public include std/dll.e +public include std/text.e +public include std/math.e +public include std/error.e +public include std/text.e +public include std/types.e +public include std/search.e +public include std/convert.e +public include std/console.e +public include std/filesys.e +public include std/machine.e +public include std/sequence.e +public include std/serialize.e + +public constant LGPL = read_file(locate_file("resources/license.txt")) + +--------------------------------------------------------------------------------- +-- ListView/TreeView storage types. Use these when creating new +-- GtkListStores or GtkTreeStores +--------------------------------------------------------------------------------- +public enum + gCHAR = 12, gUCHAR = 16, gINT = 24, gUINT = 28, + gLONG = 32, gULONG = 36, gINT64 = 40, gUINT64 = 44, + gDBL = 60, gFLT = 56, gSTR = 64, gPTR = 68, gBOOL= 20, gDOL = 99 +-- plus gPIX and gCOMBO, which must be defined at run-time +-- by GtkEngine.e ... don't ask me why! + +public sequence storage_types = { + {12,"gCHAR"}, + {16,"gUCHAR"}, + {20,"gBOOL"}, + {24,"gINT"}, + {28,"gUINT", + {32,"gLONG"}, + {36,"gULONG"}, + {40,"gINT64"}, + {44,"gUINT64"}, + {56,"gFLT"}, + {60,"gDBL"}, + {64,"gSTR"}, + {68,"gPTR"}, + {99,"gDOL"} +}} +-- here's a list of GObject types; +public enum type OBJECT by 4 + void = 4, + GInterface, + gchar, + guchar, + gboolean, + gint, + guint, + glong, + gulong, + gint64, + guint64, + GEnum, + GFlags, + gfloat, + gdouble, + gchararray, + gpointer, + GBoxed, + GParam +end type + +------------------------------------------------------------------------ +-- These are the widget class names used to create GTK widgets; +-- GObject MUST be first on the list, and GtkFinal must be last! +-- Other than that, order is unimportant, but try to keep 'em in +-- alphabetical order just to be neat. +------------------------------------------------------------------------ +public enum type WIDGET + GObject, + GAction, + GActionGroup, + GActionMap, + GAppInfo, + GApplication, + GDateTime, + GEmblem, + GEmblemedIcon, + GFile, + GFileIcon, + GFileInfo, + GFileInputStream, + GIcon, + GIdle, + GInputStream, + GKeyFile, + GList, + GMenu, + GMenuItem, + GMenuModel, + GNotification, + GPermission, + GPropertyAction, + GSettings, + GSimpleAction, + GSimpleActionGroup, + GSimplePermission, + GSList, + GThemedIcon, + GTimeout, + Cairo_t, + CairoFontOptions, + CairoContent_t, + CairoLinearGradient, + CairoPattern, + CairoPattern_t, + CairoRadialGradient, + CairoRegion_t, + CairoImageSurface, + CairoStatus_t, + CairoSurface_t, + GdkAppLaunchContext, + GdkCairo_t, + GdkCursor, + GdkDevice, + GdkDeviceManager, + GdkDisplay, + GdkEvent, + GdkEventSequence, + GdkFrameClock, + GdkFrameTimings, + GdkGLContext, + GdkGLProfile, + GdkInputSource, + GdkKeymap, + GdkPixbuf, + GdkPixbufAnimation, + GdkPixbufAnimationIter, + GdkPixbufFormat, + GdkScreen, + GdkVisual, + GdkWindow, + GdkX11Display, + GdkX11Screen, + GdkX11Window, + GtkAboutDialog, + GtkAccelGroup, + GtkAccelLabel, + GtkActionable, + GtkActionBar, + GtkAdjustment, + GtkAlignment, + GtkAppChooser, + GtkAppChooserButton, + GtkAppChooserDialog, + GtkAppChooserWidget, + GtkAppLaunchContext, + GtkApplication, + GtkApplicationWindow, + GtkArrow, + GtkAspectFrame, + GtkAssistant, + GtkBin, + GtkBindingEntry, + GtkBindingSet, + GtkBox, + GtkBuildable, + GtkBuilder, + GtkButton, + GtkButtonBox, + GtkCalendar, + GtkCellArea, + GtkCellAreaBox, + GtkCellAreaCell, + GtkCellAreaContext, + GtkCellEditable, + GtkCellLayout, + GtkCellRenderer, + GtkCellRendererAccel, + GtkCellRendererCombo, + GtkCellRendererPixbuf, + GtkCellRendererProgress, + GtkCellRendererSpin, + GtkCellRendererSpinner, + GtkCellRendererText, + GtkCellRendererToggle, + GtkCellView, + GtkCheckButton, + GtkCheckMenuItem, + GtkClipboard, + GtkColorButton, + GtkColorChooser, + GtkColorChooserDialog, + GtkColorChooserWidget, + GtkColorSelection, + GtkColorSelectionDialog, + GtkColumn, Column, -- aliases for GtkTreeViewColumn.new function; + GtkComboBox, + GtkComboBoxEntry, + GtkComboBoxText, + GtkContainer, + GtkCssProvider, + GtkCssSection, + GtkDialog, + GtkDrag, + GtkDragDest, + GtkDragSource, + GtkDrawingArea, + GtkEditable, + GtkEntry, + GtkEntryBuffer, + GtkEntryCompletion, + GtkEventBox, + GtkEventController, + GtkExpander, + GtkFileChooser, + GtkFileChooserButton, + GtkFileChooserDialog, + GtkFileChooserNative, + GtkFileChooserWidget, + GtkFileFilter, + GtkFixed, + GtkFlowBox, + GtkFlowBoxChild, + GtkFontButton, + GtkFontChooser, + GtkFontChooserDialog, + GtkFontChooserWidget, + GtkFrame, + GtkGesture, + GtkGestureSingle, + GtkGestureDrag, + GtkGestureLongPress, + GtkGestureMultiPress, + GtkGesturePan, + GtkGestureRotate, + GtkGestureSwipe, + GtkGestureZoom, + GtkGLArea, + GtkGrid, + GtkHeaderBar, + GtkIconInfo, + GtkIconTheme, + GtkIconView, + GtkImage, + GtkImageMenuItem, + GtkInfoBar, + GtkInvisible, + GtkLabel, + GtkLayout, + GtkLevelBar, + GtkLinkButton, + GtkListBox, + GtkListBoxRow, + GtkListStore, + GtkLockButton, + GtkMenu, + GtkMenuBar, + GtkMenuButton, + GtkMenuItem, + GtkMenuShell, + GtkMenuToolButton, + GtkMessageDialog, + GtkMisc, + GtkModelButton, + GtkMountOperation, + GtkNativeDialog, + GtkNotebook, + GtkNumerableIcon, + GtkOffscreenWindow, + GtkOrientable, + GtkOverlay, + GtkPadController, + GtkPaperSize, + GtkPageRange, + GtkPageSetup, + GtkPageSetupUnixDialog, + GtkPaned, + GtkPlacesSidebar, + GtkPlug, + GtkPopover, + GtkPopoverMenu, + GtkPrinter, + GtkPrintContext, + GtkPrintJob, + GtkPrintSettings, + GtkPrintOperation, + GtkPrintUnixDialog, + GtkProgressBar, + GtkRadioButton, + GtkRadioMenuItem, + GtkRadioToolButton, + GtkRange, + GtkRecentChooser, + GtkRecentChooserDialog, + GtkRecentChooserMenu, + GtkRecentChooserWidget, + GtkRecentFilter, + GtkRecentInfo, + GtkRecentManager, + GtkRevealer, + GtkScale, + GtkScaleButton, + GtkScrollable, + GtkScrollbar, + GtkScrolledWindow, + GtkSearchBar, + GtkSearchEntry, + GtkSelectionData, + GtkSeparator, + GtkSeparatorMenuItem, + GtkSeparatorToolItem, + GtkSettings, + GtkShortcutsGesture, + GtkShortcutsGroup, + GtkShortcutsSection, + GtkShortcutsShortcut, + GtkShortcutsWindow, + GtkSocket, + GtkSidebar, + GtkSizeGroup, + GtkSpinButton, + GtkSpinner, + GtkStack, + GtkStackSidebar, + GtkStackSwitcher, + GtkStatusbar, + GtkStatusIcon, + GtkStockList, + GtkStyle, + GtkStyleContext, + GtkStyleProvider, + GtkSwitch, + GtkTargetEntry, + GtkTargetList, + GtkTextAttributes, + GtkTextBuffer, + GtkTextChildAnchor, + GtkTextIter, + GtkTextMark, + GtkTextTag, + GtkTextTagTable, + GtkTextView, + GtkThemedIcon, + GtkToggleButton, + GtkToggleToolButton, + GtkToolbar, + GtkToolButton, + GtkToolItem, + GtkToolItemGroup, + GtkToolPalette, + GtkToolShell, + GtkTooltip, + GtkTreeDragDest, + GtkTreeDragSource, + GtkTreeIter, + GtkTreeModel, + GtkTreeModelFilter, + GtkTreeModelSort, + GtkTreePath, + GtkTreeRowReference, + GtkTreeSelection, + GtkTreeSortable, + GtkTreeStore, + GtkTreeView, + GtkTreeViewColumn, + GtkViewport, + GtkVolumeButton, + GtkWidget, + GtkWidgetClass, + GtkWidgetPath, + GtkWindow, + GtkWindowGroup, + PangoAttrList, + PangoCairoLayout, + PangoContext, + PangoFont, + PangoFontSet, + PangoFontsetSimple, + PangoFontDescription, + PangoFontFace, + PangoFontFamily, + PangoFontMap, + PangoLanguage, + PangoLayout, + PangoLayoutIter, + PangoLayoutLine, + PangoLayoutRun, + PangoTabArray, + GtkFinal +end type + +------------------------------------------------------------------------ + +public enum -- Response codes returned by button presses, etc; + MB_YES = -8, + MB_NO = -9, + MB_OK = -5, + MB_CANCEL = -6, + MB_CLOSE = -7, + MB_ABORT = -4, + MB_NONE = -1, + MB_REJECT = -2, + MB_ACCEPT = -3, + MB_APPLY = -10, + MB_HELP = -11 + +----------------------------------------------------------------------------------------- +-- a zillion or so GTK_CONSTANTS used to make code clearer. See GTK docs. +----------------------------------------------------------------------------------------- + +public enum type Orientation + VERTICAL = 1, HORIZONTAL = 0 end type + +public enum type SortOrder + UNSORTED = -1, ASCENDING = 1, DESCENDING = 2 end type + +public enum by 2 -- Cursors: + GDK_X_CURSOR = 0, + GDK_ARROW, + GDK_BASED_ARROW_DOWN, + GDK_BASED_ARROW_UP, + GDK_BOAT, + GDK_BOGOSITY, + GDK_BOTTOM_LEFT_CORNER, + GDK_BOTTOM_RIGHT_CORNER, + GDK_BOTTOM_SIDE, + GDK_BOTTOM_TEE, + GDK_BOX_SPIRAL, + GDK_CENTER_PTR, + GDK_CIRCLE, + GDK_CLOCK, + GDK_COFFEE_MUG, + GDK_CROSS, + GDK_CROSS_REVERSE, + GDK_CROSSHAIR, + GDK_DIAMOND_CROSS, + GDK_DOT, + GDK_DOTBOX, + GDK_DOUBLE_ARROW, + GDK_DRAFT_LARGE, + GDK_DRAFT_SMALL, + GDK_DRAPED_BOX, + GDK_EXCHANGE, + GDK_FLEUR, + GDK_GOBBLER, + GDK_GUMBY, + GDK_HAND1, + GDK_HAND2, + GDK_HEART, + GDK_ICON, + GDK_IRON_CROSS, + GDK_LEFT_PTR, + GDK_LEFT_SIDE, + GDK_LEFT_TEE, + GDK_LEFTBUTTON, + GDK_LL_ANGLE, + GDK_LR_ANGLE, + GDK_MAN, + GDK_MIDDLEBUTTON, + GDK_MOUSE, + GDK_PENCIL, + GDK_PIRATE, --? + GDK_PLUS, + GDK_QUESTION_ARROW, + GDK_RIGHT_PTR, + GDK_RIGHT_SIDE, + GDK_RIGHT_TEE, + GDK_RIGHTBUTTON, + GDK_RTL_LOGO, + GDK_SAILBOAT, + GDK_SB_DOWN_ARROW, + GDK_SB_H_DOUBLE_ARROW, + GDK_SB_LEFT_ARROW, + GDK_SB_RIGHT_ARROW, + GDK_SB_UP_ARROW, + GDK_SB_V_DOUBLE_ARROW, + GDK_SHUTTLE, + GDK_SIZING, + GDK_SPIDER, + GDK_SPRAYCAN, + GDK_STAR, + GDK_TARGET, + GDK_TCROSS, + GDK_TOP_LEFT_ARROW, + GDK_TOP_LEFT_CORNER, + GDK_TOP_RIGHT_CORNER, + GDK_TOP_SIDE, + GDK_TOP_TEE, + GDK_TREK, + GDK_UL_ANGLE, + GDK_UMBRELLA, + GDK_UR_ANGLE, + GDK_WATCH, + GDK_XTERM, + GDK_LAST_CURSOR = 153, + GDK_BLANK_CURSOR = -2, + GDK_CURSOR_IS_PIXMAP = -1 + +public enum + GTK_LICENSE_UNKNOWN = 0, + GTK_LICENSE_CUSTOM, + GTK_LICENSE_GPL_2_0, + GTK_LICENSE_GPL_3_0, + GTK_LICENSE_LGPL_2_1, + GTK_LICENSE_LGPL_3_0, + GTK_LICENSE_BSD, + GTK_LICENSE_MIT_X11, + GTK_LICENSE_ARTISTIC, + GTK_LICENSE_GPL_2_0_ONLY, + GTK_LICENSE_GPL_3_0_ONLY, + GTK_LICENSE_LGPL_2_1_ONLY, + GTK_LICENSE_LGPL_3_0_ONLY, + + GTK_ACCEL_VISIBLE = 1, + GTK_ACCEL_LOCKED = 2, + GTK_ACCEL_MASK = 7, + + GTK_ALIGN_FILL = 0, + GTK_ALIGN_START, + GTK_ALIGN_END, + GTK_ALIGN_CENTER, + + GTK_ANCHOR_CENTER = 0, + GTK_ANCHOR_NORTH, + GTK_ANCHOR_NORTH_WEST, + GTK_ANCHOR_NORTH_EAST, + GTK_ANCHOR_SOUTH, + GTK_ANCHOR_SOUTH_WEST, + GTK_ANCHOR_SOUTH_EAST, + GTK_ANCHOR_WEST, + GTK_ANCHOR_EAST, + GTK_ANCHOR_N = 1, + GTK_ANCHOR_NW, + GTK_ANCHOR_NE, + GTK_ANCHOR_S, + GTK_ANCHOR_SW, + GTK_ANCHOR_SE, + GTK_ANCHOR_W, + GTK_ANCHOR_E, + + GTK_APPLICATION_INHIBIT_LOGOUT = 1, + GTK_APPLICATION_INHIBIT_SWITCH = 2, + GTK_APPLICATION_INHIBIT_SUSPEND = 4, + GTK_APPLICATION_INHIBIT_IDLE = 8, + + G_APPLICATION_FLAGS_NONE = 0, + G_APPLICATION_IS_SERVICE, + G_APPLICATION_IS_LAUNCHER, + G_APPLICATION_HANDLES_OPEN = 4, + G_APPLICATION_HANDLES_COMMAND_LINE = 8, + G_APPLICATION_SEND_ENVIRONMENT = 16, + G_APPLICATION_NON_UNIQUE = 32, + +-- arrows are deprecated + GTK_ARROWS_BOTH = 0, + GTK_ARROWS_START, + GTK_ARROWS_END, + + GTK_ARROW_UP = 0, + GTK_ARROW_DOWN, + GTK_ARROW_LEFT, + GTK_ARROW_RIGHT, + GTK_ARROW_NONE, + + GTK_ASSISTANT_PAGE_CONTENT = 0, + GTK_ASSISTANT_PAGE_INTRO, + GTK_ASSISTANT_PAGE_CONFIRM, + GTK_ASSISTANT_PAGE_SUMMARY, + GTK_ASSISTANT_PAGE_PROGRESS, + GTK_ASSISTANT_PAGE_CUSTOM, + + GTK_EXPAND = 1, + GTK_SHRINK = 2, + GTK_FILL = 4, + + GTK_BASELINE_POSITION_TOP = 0, + GTK_BASELINE_POSITION_CENTER, + GTK_BASELINE_POSITION_BOTTOM, + + GTK_BORDER_STYLE_NONE = 0, + GTK_BORDER_STYLE_SOLID, + GTK_BORDER_STYLE_INSET, + GTK_BORDER_STYLE_OUTSET, + GTK_BORDER_STYLE_HIDDEN, + GTK_BORDER_STYLE_DOTTED, + GTK_BORDER_STYLE_DASHED, + GTK_BORDER_STYLE_DOUBLE, + GTK_BORDER_STYLE_GROOVE, + GTK_BORDER_STYLE_RIDGE, + + GTK_BUTTON_ROLE_NORMAL = 0, + GTK_BUTTON_ROLE_CHECK, + GTK_BUTTON_ROLE_RADIO, + + GTK_BUTTONS_NONE = 0, + GTK_BUTTONS_OK, + GTK_BUTTONS_CLOSE, + GTK_BUTTONS_CANCEL, + GTK_BUTTONS_YES_NO, + GTK_BUTTONS_OK_CANCEL, + + GTK_BUTTONBOX_DEFAULT_STYLE = 0, + GTK_BUTTONBOX_SPREAD, + GTK_BUTTONBOX_EDGE, + GTK_BUTTONBOX_START, + GTK_BUTTONBOX_END, + GTK_BUTTONBOX_CENTER, + GTK_BUTTONBOX_EXPAND, + + GTK_CALENDAR_SHOW_HEADING = 1, + GTK_CALENDAR_SHOW_DAY_NAMES = 2, + GTK_CALENDAR_NO_MONTH_CHANGE = 4, + GTK_CALENDAR_SHOW_WEEK_NUMBERS = 8, + GTK_CALENDAR_SHOW_DETAILS = 16, + + GTK_CORNER_TOP_LEFT = 0, + GTK_CORNER_BOTTOM_LEFT, + GTK_CORNER_TOP_RIGHT, + GTK_CORNER_BOTTOM_RIGHT, + + GTK_CURVE_TYPE_LINEAR = 0, + GTK_CURVE_TYPE_SPLINE, + GTK_CURVE_TYPE_FREE, + + GTK_DELETE_CHARS = 0, + GTK_DELETE_WORD_ENDS, + GTK_DELETE_WORDS, + GTK_DELETE_DISPLAY_LINES, + GTK_DELETE_DISPLAY_LINE_ENDS, + GTK_DELETE_PARAGRAPH_ENDS, + GTK_DELETE_PARAGRAPHS, + GTK_DELETE_WHITESPACE, + + GTK_DIALOG_NON_MODAL = 0, + GTK_DIALOG_MODAL = 1, + GTK_DIALOG_DESTROY_WITH_PARENT = 2, + GTK_DIALOG_NO_SEPARATOR = 4, + + GTK_DIR_TAB_FORWARD = 0, + GTK_DIR_TAB_BACKWARD, + GTK_DIR_UP, + GTK_DIR_DOWN, + GTK_DIR_LEFT, + GTK_DIR_RIGHT, + + GTK_EVENT_SEQUENCE_NONE = 0, + GTK_EVENT_SEQUENCE_CLAIMED, + GTK_EVENT_SEQUENCE_DENIED, + + GTK_EXPANDER_COLLAPSED = 0, + GTK_EXPANDER_SEMI_COLLAPSED, + GTK_EXPANDER_SEMI_EXPANDED, + GTK_EXPANDER_EXPANDED, + + GTK_FILE_CHOOSER_ACTION_OPEN = 0, + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, + GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER, + + GTK_ICON_SIZE_INVALID = 0, + GTK_ICON_SIZE_MENU, + GTK_ICON_SIZE_SMALL_TOOLBAR, + GTK_ICON_SIZE_LARGE_TOOLBAR, + GTK_ICON_SIZE_BUTTON, + GTK_ICON_SIZE_DND, + GTK_ICON_SIZE_DIALOG, + + GTK_ICON_LOOKUP_NO_SVG = 1, + GTK_ICON_LOOKUP_FORCE_SVG = 2, + GTK_ICON_LOOKUP_USE_BUILTIN = 4, + GTK_ICON_LOOKUP_GENERIC_FALLBACK = 8, + GTK_ICON_LOOKUP_FORCE_SIZE = 16, + + GTK_IMAGE_EMPTY = 0, + GTK_IMAGE_PIXBUF, + GTK_IMAGE_STOCK, + GTK_IMAGE_ICON_SET, + GTK_IMAGE_ANIMATION, + GTK_IMAGE_ICON_NAME, + GTK_IMAGE_GICON, + + GTK_IM_PREEDIT_NOTHING = 0, + GTK_IM_PREEDIT_CALLBACK, + GTK_IM_PREEDIT_NONE, + + GTK_IM_STATUS_NOTHING = 0, + GTK_IM_STATUS_CALLBACK, + GTK_IM_STATUS_NONE, + + GTK_INPUT_HINT_NONE = 0, + GTK_INPUT_HINT_SPELLCHECK, + GTK_INPUT_HINT_NO_SPELLCHECK, + GTK_INPUT_HINT_WORD_COMPLETION = 4, + GTK_INPUT_HINT_LOWERCASE = 8, + GTK_INPUT_HINT_UPPERCASE_CHARS = 16, + GTK_INPUT_HINT_UPPERCASE_WORDS = 32, + GTK_INPUT_HINT_UPPERCASE_SENTENCES = 64, + + GTK_JUSTIFY_LEFT = 0, + GTK_JUSTIFY_RIGHT, + GTK_JUSTIFY_CENTER, + GTK_JUSTIFY_FILL, + + GTK_LEVEL_BAR_MODE_CONTINUOUS = 0, + GTK_LEVEL_BAR_MODE_DISCRETE, + + GTK_MATCH_ALL = 0, + GTK_MATCH_ALL_TAIL, + GTK_MATCH_HEAD, + GTK_MATCH_TAIL, + GTK_MATCH_EXACT, + GTK_MATCH_LAST, + + GTK_PIXELS = 0, + GTK_INCHES, + GTK_CENTIMETERS, + + GTK_MESSAGE_INFO = 0, + GTK_MESSAGE_WARNING, + GTK_MESSAGE_QUESTION, + GTK_MESSAGE_ERROR, + GTK_MESSAGE_OTHER, + + GTK_ICON_INFO = 0, + GTK_ICON_WARNING, + GTK_ICON_QUESTION, + GTK_ICON_ERROR, + GTK_ICON_OTHER, + + GTK_MOVEMENT_LOGICAL_POSITIONS = 0, + GTK_MOVEMENT_VISUAL_POSITIONS, + GTK_MOVEMENT_WORDS, + GTK_MOVEMENT_DISPLAY_LINES, + GTK_MOVEMENT_DISPLAY_LINE_ENDS, + GTK_MOVEMENT_PARAGRAPHS, + GTK_MOVEMENT_PARAGRAPH_ENDS, + GTK_MOVEMENT_PAGES, + GTK_MOVEMENT_BUFFER_ENDS, + GTK_MOVEMENT_HORIZONTAL_PAGES, + + GTK_ORIENTATION_HORIZONTAL = 0, + GTK_ORIENTATION_VERTICAL, + + GTK_PACK_START = 0, + GTK_PACK_END, + + GTK_PAN_DIRECTION_LEFT = 0, + GTK_PAN_DIRECTION_RIGHT, + GTK_PAN_DIRECTION_UP, + GTK_PAN_DIRECTION_DOWN, + + GTK_PATH_PRIO_LOWEST = 0, + GTK_PATH_PRIO_GTK = 4, + GTK_PATH_PRIO_APPLICATION = 8, + GTK_PATH_PRIO_THEME = 10, + GTK_PATH_PRIO_RC = 12, + GTK_PATH_PRIO_HIGHEST = 15, + + GTK_PATH_WIDGET = 0, + GTK_PATH_WIDGET_CLASS, + GTK_PATH_CLASS, + + GTK_PHASE_NONE = 0, + GTK_PHASE_CAPTURE, + GTK_PHASE_BUBBLE, + GTK_PHASE_TARGET, + + GTK_POLICY_ALWAYS = 0, + GTK_POLICY_AUTOMATIC, + GTK_POLICY_NEVER, + GTK_POLICY_EXTERNAL, + + GTK_POS_LEFT = 0, + GTK_POS_RIGHT, + GTK_POS_TOP, + GTK_POS_BOTTOM, + LEFT = 0, --aliases; + RIGHT, + TOP, + BOTTOM + +public enum by * 2 + GTK_PRINT_CAPABILITY_PAGE_SET = 0, + GTK_PRINT_CAPABILITY_COPIES = 2, + GTK_PRINT_CAPABILITY_COLLATE, + GTK_PRINT_CAPABILITY_REVERSE, + GTK_PRINT_CAPABILITY_SCALE, + GTK_PRINT_CAPABILITY_GENERATE_PDF, + GTK_PRINT_CAPABILITY_GENERATE_PS, + GTK_PRINT_CAPABILITY_PREVIEW, + GTK_PRINT_CAPABILITY_NUMBER_UP, + GTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT, + + GTK_REGION_EVEN = 0, + GTK_REGION_ODD = 1, + GTK_REGION_FIRST, + GTK_REGION_LAST, + GTK_REGION_ONLY, + GTK_REGION_SORTED, + + GTK_STATE_FLAG_NORMAL = 0, + GTK_STATE_FLAG_ACTIVE = 1, + GTK_STATE_FLAG_PRELIGHT, + GTK_STATE_FLAG_SELECTED, + GTK_STATE_FLAG_INSENSITIVE, + GTK_STATE_FLAG_INCONSISTENT, + GTK_STATE_FLAG_FOCUSED, + GTK_STATE_FLAG_BACKDROP, + GTK_STATE_FLAG_DIR_LTR , + GTK_STATE_FLAG_DIR_RTL, + GTK_STATE_FLAG_LINK, + GTK_STATE_FLAG_VISITED, + GTK_STATE_FLAG_CHECKED + +public enum + GTK_PROGRESS_LEFT_TO_RIGHT = 0, + GTK_PROGRESS_RIGHT_TO_LEFT, + GTK_PROGRESS_BOTTOM_TO_TOP, + GTK_PROGRESS_TOP_TO_BOTTOM, + + GTK_RELIEF_NORMAL = 0, + GTK_RELIEF_HALF, + GTK_RELIEF_NONE, + + GTK_RESIZE_PARENT = 0, + GTK_RESIZE_QUEUE, + GTK_RESIZE_IMMEDIATE, + + GTK_REVEALER_TRANSITION_TYPE_NONE = 0, + GTK_REVEALER_TRANSITION_TYPE_CROSSFADE, + GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT, + GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT, + GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP, + GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN, + + GTK_SCROLL_STEPS = 0, + GTK_SCROLL_PAGES, + GTK_SCROLL_ENDS, + GTK_SCROLL_HORIZONTAL_STEPS, + GTK_SCROLL_HORIZONTAL_PAGES, + GTK_SCROLL_HORIZONTAL_ENDS, + + GTK_SCROLL_NONE = 0, + GTK_SCROLL_JUMP, + GTK_SCROLL_STEP_BACKWARD, + GTK_SCROLL_STEP_FORWARD, + GTK_SCROLL_PAGE_BACKWARD, + GTK_SCROLL_PAGE_FORWARD, + GTK_SCROLL_STEP_UP, + GTK_SCROLL_STEP_DOWN, + GTK_SCROLL_PAGE_UP, + GTK_SCROLL_PAGE_DOWN, + GTK_SCROLL_STEP_LEFT, + GTK_SCROLL_STEP_RIGHT, + GTK_SCROLL_PAGE_LEFT, + GTK_SCROLL_PAGE_RIGHT, + GTK_SCROLL_START, + GTK_SCROLL_END, + + GTK_SELECTION_NONE = 0, + GTK_SELECTION_SINGLE, + GTK_SELECTION_BROWSE, + GTK_SELECTION_MULTIPLE, + + GTK_SHADOW_NONE = 0, + GTK_SHADOW_IN, + GTK_SHADOW_OUT, + GTK_SHADOW_ETCHED_IN, + GTK_SHADOW_ETCHED_OUT, + + GTK_STATE_NORMAL = 0, + GTK_STATE_ACTIVE, + GTK_STATE_PRELIGHT, + GTK_STATE_SELECTED, + GTK_STATE_INSENSITIVE, + GTK_STATE_INCONSISTENT, + GTK_STATE_FOCUSED, + GTK_STATE_PRESSED = 1, + GTK_STATE_MOUSEOVER, + + GTK_TEXT_DIR_NONE = 0, + GTK_TEXT_DIR_LTR, + GTK_TEXT_DIR_RTL, + + GTK_TEXT_EXTEND_SELECTION_WORD = 0, + GTK_TEXT_EXTEND_SELECTION_LINE, + + GTK_TOOLBAR_ICONS = 0, + GTK_TOOLBAR_TEXT, + GTK_TOOLBAR_BOTH, + GTK_TOOLBAR_BOTH_HORIZ, + + GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID = -1, + GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID = -2, + + GTK_UPDATE_CONTINUOUS = 0, + GTK_UPDATE_DISCONTINUOUS, + GTK_UPDATE_DELAYED, + + GTK_VISIBILITY_NONE = 0, + GTK_VISIBILITY_PARTIAL, + GTK_VISIBILITY_FULL, + + GTK_WIN_POS_NONE = 0, + GTK_WIN_POS_CENTER, + GTK_WIN_POS_MOUSE, + GTK_WIN_POS_CENTER_ALWAYS, + GTK_WIN_POS_CENTER_ON_PARENT, + + GTK_WINDOW_TOPLEVEL = 0, + GTK_WINDOW_POPUP, + + GTK_SORT_ASCENDING = 1, + GTK_SORT_DESCENDING, + + GTK_DRAG_RESULT_SUCCESS = 0, + GTK_DRAG_RESULT_NO_TARGET, + GTK_DRAG_RESULT_USER_CANCELLED, + GTK_DRAG_RESULT_TIMEOUT_EXPIRED, + GTK_DRAG_RESULT_GRAB_BROKEN, + GTK_DRAG_RESULT_ERROR, + + PANGO_ELLIPSIZE_NONE = 0, + PANGO_ELLIPSIZE_START, + PANGO_ELLIPSIZE_MIDDLE, + PANGO_ELLIPSIZE_END, + + GDK_SOLID = 0, + GDK_TILED, + GDK_STIPPLED, + GDK_OPAQUE_STIPPLED, + + GTK_RESPONSE_NONE = -1, + GTK_RESPONSE_REJECT = -2, + GTK_RESPONSE_ACCEPT = -3, + GTK_RESPONSE_DELETE_EVENT = -4, + GTK_RESPONSE_OK = -5, + GTK_RESPONSE_CANCEL = -6, + GTK_RESPONSE_CLOSE = -7, + GTK_RESPONSE_YES = -8, + GTK_RESPONSE_NO = -9, + GTK_RESPONSE_APPLY = -10, + GTK_RESPONSE_HELP = -11, + + GTK_TREE_VIEW_COLUMN_GROW_ONLY = 0, + GTK_TREE_VIEW_COLUMN_AUTOSIZE, + GTK_TREE_VIEW_COLUMN_FIXED, + + GTK_TREE_VIEW_GRID_LINES_NONE = 0, + GTK_TREE_VIEW_GRID_LINES_HORIZONTAL, + GTK_TREE_VIEW_GRID_LINES_VERTICAL, + GTK_TREE_VIEW_GRID_LINES_BOTH, + + GTK_TEXT_WINDOW_PRIVATE = 0, + GTK_TEXT_WINDOW_WIDGET, + GTK_TEXT_WINDOW_TEXT, + GTK_TEXT_WINDOW_LEFT, + GTK_TEXT_WINDOW_RIGHT, + GTK_TEXT_WINDOW_TOP, + GTK_TEXT_WINDOW_BOTTOM, + + G_NOTIFICATION_PRIORITY_NORMAL = 0, + G_NOTIFICATION_PRIORITY_LOW, + G_NOTIFICATION_PRIORITY_HIGH, + G_NOTIFICATION_PRIORITY_URGENT, + + G_USER_DIRECTORY_DESKTOP = 0, + G_USER_DIRECTORY_DOCUMENTS, + G_USER_DIRECTORY_DOWNLOAD, + G_USER_DIRECTORY_MUSIC, + G_USER_DIRECTORY_PICTURES, + G_USER_DIRECTORY_PUBLIC_SHARE, + G_USER_DIRECTORY_TEMPLATES, + G_USER_DIRECTORY_VIDEOS, + G_USER_N_DIRECTORIES, + + GTK_WRAP_NONE = 0, + GTK_WRAP_CHAR, + GTK_WRAP_WORD, + GTK_WRAP_WORD_CHAR, + + GDK_WINDOW_TYPE_HINT_NORMAL = 0, + GDK_WINDOW_TYPE_HINT_DIALOG, + GDK_WINDOW_TYPE_HINT_MENU, + GDK_WINDOW_TYPE_HINT_TOOLBAR, + GDK_WINDOW_TYPE_HINT_SPLASHSCREEN, + GDK_WINDOW_TYPE_HINT_UTILITY, + GDK_WINDOW_TYPE_HINT_DOCK, + GDK_WINDOW_TYPE_HINT_DESKTOP, + GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU, + GDK_WINDOW_TYPE_HINT_POPUP_MENU, + GDK_WINDOW_TYPE_HINT_TOOLTIP, + GDK_WINDOW_TYPE_HINT_NOTIFICATION, + GDK_WINDOW_TYPE_HINT_COMBO, + GDK_WINDOW_TYPE_HINT_DND, + + GDK_ACTION_DEFAULT = 0, + GDK_ACTION_COPY = 1, + GDK_ACTION_MOVE = 2, + GDK_ACTION_LINK = 4, + GDK_ACTION_PRIVATE = 8, + GDK_ACTION_ASK = 16, + + GTK_CELL_RENDERER_MODE_INERT = 0, + GTK_CELL_RENDERER_MODE_ACTIVATABLE, + GTK_CELL_RENDERER_MODE_EDITABLE, + + GTK_CELL_RENDERER_ACCEL_MODE_GTK = 0, + GTK_CELL_RENDERER_ACCEL_MODE_OTHER, + + GTK_DEST_DEFAULT_MOTION = 1, + GTK_DEST_DEFAULT_HIGHLIGHT = 2, + GTK_DEST_DEFAULT_DROP = 4, + GTK_DEST_DEFAULT_ALL = 0x07, + + GTK_TARGET_SAME_APP = 1, + GTK_TARGET_SAME_WIDGET = 2, + GTK_TARGET_OTHER_APP = 4, + GTK_TARGET_OTHER_WIDGET = 8, + + GTK_SIZE_GROUP_NONE = 0, + GTK_SIZE_GROUP_HORIZONTAL, + GTK_SIZE_GROUP_VERTICAL, + GTK_SIZE_GROUP_BOTH + +public enum + MOUSE_BUTTON1 = 1, + MOUSE_BUTTON2, + MOUSE_BUTTON3 + +public enum + PANGO_SCALE = 1000, + PANGO_STYLE_NORMAL= 0, + PANGO_STYLE_OBLIQUE, + PANGO_STYLE_ITALIC, + + PANGO_STRETCH_ULTRA_CONDENSED = 0, + PANGO_STRETCH_EXTRA_CONDENSED, + PANGO_STRETCH_CONDENSED, + PANGO_STRETCH_SEMI_CONDENSED, + PANGO_STRETCH_NORMAL, + PANGO_STRETCH_SEMI_EXPANDED, + PANGO_STRETCH_EXPANDED, + PANGO_STRETCH_EXTRA_EXPANDED, + PANGO_STRETCH_ULTRA_EXPANDED, + + PANGO_VARIANT_NORMAL=1, + PANGO_VARIANT_SMALL_CAPS, + + PANGO_WEIGHT_THIN = 100, + PANGO_WEIGHT_ULTRALIGHT = 200, + PANGO_WEIGHT_LIGHT = 300, + PANGO_WEIGHT_BOOK = 380, + PANGO_WEIGHT_NORMAL = 400, + PANGO_WEIGHT_MEDIUM = 500, + PANGO_WEIGHT_SEMIBOLD = 600, + PANGO_WEIGHT_BOLD = 700, + PANGO_WEIGHT_ULTRABOLD = 800, + PANGO_WEIGHT_HEAVY = 900, + PANGO_WEIGHT_ULTRAHEAVY = 1000, + PANGO_UNIT = 1024 + +public enum + GTK_RECENT_SORT_NONE = 0, + GTK_RECENT_SORT_MRU, + GTK_RECENT_SORT_LRU, + GTK_RECENT_SORT_CUSTOM + + public enum by * 2 -- GdkModifierTypes + GDK_SHIFT_MASK = 1, + GDK_LOCK_MASK, + GDK_CONTROL_MASK, + GDK_MOD1_MASK, -- Alt+ + GDK_MOD2_MASK, + GDK_MOD3_MASK, + GDK_MOD4_MASK, + GDK_MOD5_MASK, + GDK_BUTTON1_MASK, + GDK_BUTTON2_MASK, + GDK_BUTTON3_MASK, + GDK_BUTTON4_MASK, + GDK_BUTTON5_MASK, + SHFT = 1, -- 'shorthand' versions of above + LOCK, + CTL, + ALT + + public enum -- events + GDK_NOTHING = -1, + GDK_DELETE, + GDK_DESTROY, + GDK_EXPOSE, + GDK_MOTION_NOTIFY, + GDK_BUTTON_PRESS, + GDK_2BUTTON_PRESS, + GDK_3BUTTON_PRESS, + GDK_BUTTON_RELEASE, + GDK_KEY_PRESS, + GDK_KEY_RELEASE, + GDK_ENTER_NOTIFY, + GDK_LEAVE_NOTIFY, + GDK_FOCUS_CHANGE, + GDK_CONFIGURE, + GDK_MAP, + GDK_UNMAP + +public enum -- event masks + GDK_EXPOSURE_MASK = 2, + GDK_POINTER_MOTION_MASK = 4, + GDK_POINTER_MOTION_HINT_MASK = 8, + GDK_BUTTON_MOTION_MASK = 16, + GDK_BUTTON1_MOTION_MASK = #20, + GDK_BUTTON2_MOTION_MASK = #40, + GDK_BUTTON3_MOTION_MASK = #80, + GDK_BUTTON_PRESS_MASK = #100, + GDK_BUTTON_RELEASE_MASK = #200, + GDK_KEY_PRESS_MASK = #400, + GDK_KEY_RELEASE_MASK = #800, + GDK_ENTER_NOTIFY_MASK = #1000, + GDK_LEAVE_NOTIFY_MASK = #2000, + GDK_FOCUS_CHANGE_MASK = #4000, + GDK_STRUCTURE_MASK = #8000, + GDK_PROPERTY_CHANGE_MASK = #10000, + GDK_VISIBILITY_NOTIFY_MASK = #20000, + GDK_PROXIMITY_IN_MASK = #40000, + GDK_PROXIMITY_OUT_MASK = #80000, + GDK_SUBSTRUCTURE_MASK = #100000, + GDK_SCROLL_MASK = #200000, + GDK_ALL_EVENTS_MASK = #3FFFFE, + + GDK_PROPERTY_NOTIFY = 16, + GDK_SELECTION_CLEAR, + GDK_SELECTION_REQUEST, + GDK_SELECTION_NOTIFY, + GDK_PROXIMITY_IN, + GDK_PROXIMITY_OUT, + GDK_DRAG_ENTER, + GDK_DRAG_LEAVE, + GDK_DRAG_MOTION, + GDK_DRAG_STATUS, + GDK_DROP_START, + GDK_DROP_FINISHED, + GDK_CLIENT_EVENT, + GDK_VISIBILITY_NOTIFY, + GDK_NO_EXPOSE, + GDK_SCROLL, + GDK_WINDOW_STATE, + GDK_SETTING, + GDK_OWNER_CHANGE, + GDK_GRAB_BROKEN, + GDK_DAMAGE, + + GDK_FULLSCREEN_ON_CURRENT_MONITOR = 0, + GDK_FULLSCREEN_ON_ALL_MONITORS, + + GTK_PAGE_SET_ALL = 0, + GTK_PAGE_SET_EVEN, + GTK_PAGE_SET_ODD, + + GTK_PAGE_ORIENTATION_PORTRAIT = 0, + GTK_PAGE_ORIENTATION_LANDSCAPE, + GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT, + GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE, + + GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG = 0, + GTK_PRINT_OPERATION_ACTION_PRINT, + GTK_PRINT_OPERATION_ACTION_PREVIEW, + GTK_PRINT_OPERATION_ACTION_EXPORT, + + GTK_PRINT_OPERATION_RESULT_ERROR = 0, + GTK_PRINT_OPERATION_RESULT_APPLY, + GTK_PRINT_OPERATION_RESULT_CANCEL, + GTK_PRINT_OPERATION_RESULT_IN_PROGRESS, + + GTK_PRINT_STATUS_INITIAL = 0, + GTK_PRINT_STATUS_PREPARING, + GTK_PRINT_STATUS_GENERATING_DATA, + GTK_PRINT_STATUS_SENDING_DATA, + GTK_PRINT_STATUS_PENDING, + GTK_PRINT_STATUS_PENDING_ISSUE, + GTK_PRINT_STATUS_PRINTING, + GTK_PRINT_STATUS_FINISHED, + GTK_PRINT_STATUS_FINISHED_ABORTED, + + GTK_PRINT_DUPLEX_SIMPLE = 0, + GTK_PRINT_DUPLEX_HORIZONTAL, + GTK_PRINT_DUPLEX_VERTICAL, + + GTK_PRINT_PAGES_ALL = 0, + GTK_PRINT_PAGES_CURRENT, + GTK_PRINT_PAGES_RANGES, + GTK_PRINT_PAGES_SELECTION, + + GTK_PRINT_QUALITY_LOW = 0, + GTK_PRINT_QUALITY_NORMAL, + GTK_PRINT_QUALITY_HIGH, + GTK_PRINT_QUALITY_DRAFT, + + GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM = 0, + GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_BOTTOM_TO_TOP, + GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_TOP_TOP_BOTTOM, + GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_BOTTOM_TO_TOP, + GTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_LEFT_TO_RIGHT, + GTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_RIGHT_TO_LEFT, + GTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_LEFT_TO_RIGHT, + GTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_RIGHT_TO_LEFT, + + GTK_STYLE_PROVIDER_PRIORITY_FALLBACK = 1, + GTK_STYLE_PROVIDER_PRIORITY_THEME = 200, + GTK_STYLE_PROVIDER_PRIORITY_SETTINGS = 400, + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION = 600, + GTK_STYLE_PROVIDER_PRIORITY_USER = 800, + + GTK_UNIT_PIXEL = 0, + GTK_UNIT_POINTS, + GTK_UNIT_INCH, + GTK_UNIT_MM, + + GTK_STACK_TRANSITION_TYPE_NONE = 0, + GTK_STACK_TRANSITION_TYPE_CROSSFADE, + GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT, + GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT, + GTK_STACK_TRANSITION_TYPE_SLIDE_UP, + GTK_STACK_TRANSITION_TYPE_SLIDE_DOWN, + GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT, + GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN, + GTK_STACK_TRANSITION_TYPE_OVER_UP, -- GTK3.12 from here down + GTK_STACK_TRANSITION_TYPE_OVER_DOWN, + GTK_STACK_TRANSITION_TYPE_OVER_LEFT, + GTK_STACK_TRANSITION_TYPE_OVER_RIGHT, + GTK_STACK_TRANSITION_TYPE_UNDER_UP, + GTK_STACK_TRANSITION_TYPE_UNDER_DOWN, + GTK_STACK_TRANSITION_TYPE_UNDER_LEFT, + GTK_STACK_TRANSITION_TYPE_UNDER_RIGHT, + GTK_STACK_TRANSITION_TYPE_OVER_UP_DOWN, + GTK_STACK_TRANSITION_TYPE_OVER_DOWN_UP, + GTK_STACK_TRANSITION_TYPE_OVER_LEFT_RIGHT, + GTK_STACK_TRANSITION_TYPE_OVER_RIGHT_LEFT, + + GTK_PLACES_OPEN_NORMAL = 0, + GTK_PLACES_OPEN_NEW_TAB, + GTK_PLACES_OPEN_NEW_WINDOW, + + GDK_PIXBUF_ROTATE_NONE = 0, + GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE = 90, + GDK_PIXBUF_ROTATE_UPSIDEDOWN = 180, + GDK_PIXBUF_ROTATE_CLOCKWISE = 270, + + GDK_INTERP_NEAREST = 0, + GDK_INTERP_TILES, + GDK_INTERP_BILINEAR, + GDK_INTERP_HYPER, + + CAIRO_EXTEND_REPEAT = 1, + + CAIRO_FILL_RULE_EVEN_ODD = 1, + CAIRO_FILL_RULE_WINDING = 0, + + CAIRO_FONT_SLANT_NORMAL = 0, + CAIRO_FONT_SLANT_ITALIC, + CAIRO_FONT_SLANT_OBLIQUE, + + CAIRO_FONT_WEIGHT_NORMAL = 0, NORMAL = 0, + CAIRO_FONT_WEIGHT_BOLD, BOLD = 1, + + CAIRO_FORMAT_INVALID = -1, + CAIRO_FORMAT_ARGB32 = 0, + CAIRO_FORMAT_RGB24, + CAIRO_FORMAT_A8, + CAIRO_FORMAT_A1, + CAIRO_FORMAT_RGB16_565, + + CAIRO_LINE_CAP_BUTT = 0, + CAIRO_LINE_CAP_ROUND, + CAIRO_LINE_CAP_SQUARE, + + CAIRO_LINE_JOIN_MITER = 0, + CAIRO_LINE_JOIN_ROUND, + CAIRO_LINE_JOIN_BEVEL, + + CAIRO_OPERATOR_CLEAR = 0, + CAIRO_OPERATOR_SOURCE, + CAIRO_OPERATOR_OVER, + CAIRO_OPERATOR_IN, + CAIRO_OPERATOR_OUT, + CAIRO_OPERATOR_ATOP, + CAIRO_OPERATOR_DEST, + CAIRO_OPERATOR_DEST_OVER, + CAIRO_OPERATOR_DEST_IN, + CAIRO_OPERATOR_DEST_OUT, + CAIRO_OPERATOR_DEST_ATOP, + CAIRO_OPERATOR_XOR, + CAIRO_OPERATOR_ADD, + CAIRO_OPERATOR_SATURATE, + CAIRO_OPERATOR_MULTIPLY, + CAIRO_OPERATOR_SCREEN, + CAIRO_OPERATOR_OVERLAY, + CAIRO_OPERATOR_DARKEN, + CAIRO_OPERATOR_LIGHTEN, + CAIRO_OPERATOR_COLOR_DODGE, + CAIRO_OPERATOR_COLOR_BURN, + CAIRO_OPERATOR_HARD_LIGHT, + CAIRO_OPERATOR_SOFT_LIGHT, + CAIRO_OPERATOR_DIFFERENCE, + CAIRO_OPERATOR_EXCLUSION, + CAIRO_OPERATOR_HSL_HUE, + CAIRO_OPERATOR_HSL_SATURATION, + CAIRO_OPERATOR_HSL_COLOR, + CAIRO_OPERATOR_HSL_LUMINOSITY, + + CAIRO_PDF_VERSION_1_4 = 0, + CAIRO_PDF_VERSION_1_5, + + CAIRO_SVG_VERSION_1_1 = 0, + CAIRO_SVG_VERSION_1_2, + + CAIRO_SURFACE_TYPE_IMAGE = 0, + CAIRO_SURFACE_TYPE_PDF, + CAIRO_SURFACE_TYPE_PS, + CAIRO_SURFACE_TYPE_XLIB, + CAIRO_SURFACE_TYPE_XCB, + CAIRO_SURFACE_TYPE_GLITZ, + CAIRO_SURFACE_TYPE_QUARTZ, + CAIRO_SURFACE_TYPE_WIN32, + CAIRO_SURFACE_TYPE_BEOS, + CAIRO_SURFACE_TYPE_DIRECTFB, + CAIRO_SURFACE_TYPE_SVG, + CAIRO_SURFACE_TYPE_OS2, + CAIRO_SURFACE_TYPE_WIN32_PRINTING, + CAIRO_SURFACE_TYPE_QUARTZ_IMAGE, + CAIRO_SURFACE_TYPE_SCRIPT, + CAIRO_SURFACE_TYPE_QT, + CAIRO_SURFACE_TYPE_RECORDING, + CAIRO_SURFACE_TYPE_VG, + CAIRO_SURFACE_TYPE_GL, + CAIRO_SURFACE_TYPE_DRM, + CAIRO_SURFACE_TYPE_TEE, + CAIRO_SURFACE_TYPE_XML, + CAIRO_SURFACE_TYPE_SKIA, + CAIRO_SURFACE_TYPE_SUBSURFACE, + + CAIRO_FONT_TYPE_TOY = 0, + CAIRO_FONT_TYPE_FT, + CAIRO_FONT_TYPE_WIN32, + CAIRO_FONT_TYPE_QUARTZ, + CAIRO_FONT_TYPE_USER + +public enum + ICON_PIXBUF = 1, + ICON_DISPLAY_NAME, + ICON_FILENAME, + ICON_BASE_SIZE, + ICON_BASE_SCALE, + ICON_IS_SYMBOLIC, + + G_KEY_FILE_NONE = 0, + G_KEY_FILE_KEEP_COMMENTS, + G_KEY_FILE_KEEP_TRANSLATIONS + + +-- local function to implement widget types; +function _(atom x, integer t) +if x = 0 then + crash("Invalid type - pointer is null!") +end if +init(t) register(x,t) +return x +end function + +------------------------------------------------------------------------ +-- GTK Widget Types -- used rarely, with caution +------------------------------------------------------------------------ +global type Object(atom x)return _(x,GObject)end type +global type Window(atom x)return _(x,GtkWindow)end type +global type Dialog(atom x)return _(x,GtkDialog)end type +global type AboutDialog(atom x)return _(x,GtkAboutDialog)end type +global type Assistant(atom x)return _(x,GtkAssistant)end type +global type Box(atom x)return _(x,GtkBox)end type +global type Grid(atom x)return _(x,GtkGrid)end type +global type Revealer(atom x)return _(x,GtkRevealer)end type +global type ListBox(atom x)return _(x,GtkListBox)end type +global type FlowBox(atom x)return _(x,GtkFlowBox)end type +global type Stack(atom x)return _(x,GtkStack)end type +global type StackSwitcher(atom x)return _(x,GtkStackSwitcher)end type +global type Sidebar(atom x)return _(x,GtkSidebar)end type +global type ActionBar(atom x)return _(x,GtkActionBar)end type +global type HeaderBar(atom x)return _(x,GtkHeaderBar)end type +global type Overlay(atom x)return _(x,GtkOverlay)end type +global type ButtonBox(atom x)return _(x,GtkButtonBox)end type +global type Paned(atom x)return _(x,GtkPaned)end type +global type Layout(atom x)return _(x,GtkLayout)end type +global type Notebook(atom x)return _(x,GtkNotebook)end type +global type Expander(atom x)return _(x,GtkExpander)end type +global type AspectFrame(atom x)return _(x,GtkAspectFrame)end type +global type Label(atom x)return _(x,GtkLabel)end type +global type Image(atom x)return _(x,GtkImage)end type +global type Spinner(atom x)return _(x,GtkSpinner)end type +global type InfoBar(atom x)return _(x,GtkInfoBar)end type +global type ProgressBar(atom x)return _(x,GtkProgressBar)end type +global type LevelBar(atom x)return _(x,GtkLevelBar)end type +global type Statusbar(atom x)return _(x,GtkStatusbar)end type +global type AccelLabel(atom x)return _(x,GtkAccelLabel)end type +global type Button(atom x)return _(x,GtkButton)end type +global type CheckButton(atom x)return _(x,GtkCheckButton)end type +global type RadioButton(atom x)return _(x,GtkRadioButton)end type +global type ToggleButton(atom x)return _(x,GtkToggleButton)end type +global type LinkButton(atom x)return _(x,GtkLinkButton)end type +global type MenuButton(atom x)return _(x,GtkMenuButton)end type +global type Switch(atom x)return _(x,GtkSwitch)end type +global type ScaleButton(atom x)return _(x,GtkScaleButton)end type +global type VolumeButton(atom x)return _(x,GtkVolumeButton)end type +global type LockButton(atom x)return _(x,GtkLockButton)end type +global type Entry(atom x)return _(x,GtkEntry)end type +global type EntryBuffer(atom x)return _(x,GtkEntryBuffer)end type +global type EntryCompletion(atom x)return _(x,GtkEntryCompletion)end type +global type Scale(atom x)return _(x,GtkScale)end type +global type SpinButton(atom x)return _(x,GtkSpinButton)end type +global type SearchEntry(atom x)return _(x,GtkSearchEntry)end type +global type SearchBar(atom x)return _(x,GtkSearchBar)end type +global type Editable(atom x)return _(x,GtkEditable)end type +global type TextMark(atom x)return _(x,GtkTextMark)end type +global type TextBuffer(atom x)return _(x,GtkTextBuffer)end type +global type TextTag(atom x)return _(x,GtkTextTag)end type +global type TextTagTable(atom x)return _(x,GtkTextTagTable)end type +global type TextView(atom x)return _(x,GtkTextView)end type +global type TreeModel(atom x)return _(x,GtkTreeModel)end type +global type TreeModelSort(atom x)return _(x,GtkTreeModelSort)end type +global type TreeSelection(atom x)return _(x,GtkTreeSelection)end type +global type TreeViewColumn(atom x)return _(x,GtkTreeViewColumn)end type +global type TreeView(atom x)return _(x,GtkTreeView)end type +global type IconView(atom x)return _(x,GtkIconView)end type +global type CellRendererText(atom x)return _(x,GtkCellRendererText)end type +global type CellRendererAccel(atom x)return _(x,GtkCellRendererAccel)end type +global type CellRendererCombo(atom x)return _(x,GtkCellRendererCombo)end type +global type CellRendererPixbuf(atom x)return _(x,GtkCellRendererPixbuf)end type +global type CellRendererProgress(atom x)return _(x,GtkCellRendererProgress)end type +global type CellRendererSpin(atom x)return _(x,GtkCellRendererSpin)end type +global type CellRendererToggle(atom x)return _(x,GtkCellRendererToggle)end type +global type CellRendererSpinner(atom x)return _(x,GtkCellRendererSpinner)end type +global type ListStore(atom x)return _(x,GtkListStore)end type +global type TreeStore(atom x)return _(x,GtkTreeStore)end type +global type ComboBox(atom x)return _(x,GtkComboBox)end type +global type ComboBoxText(atom x)return _(x,GtkComboBoxText)end type +global type Menu(atom x)return _(x,GtkMenu)end type +global type MenuBar(atom x)return _(x,GtkMenuBar)end type +global type MenuItem(atom x)return _(x,GtkMenuItem)end type +global type RadioMenuItem(atom x)return _(x,GtkRadioMenuItem)end type +global type CheckMenuItem(atom x)return _(x,GtkCheckMenuItem)end type +global type SeparatorMenuItem(atom x)return _(x,GtkSeparatorMenuItem)end type +global type Toolbar(atom x)return _(x,GtkToolbar)end type +global type ToolItem(atom x)return _(x,GtkToolItem)end type +global type ToolPalette(atom x)return _(x,GtkToolPalette)end type +global type ToolButton(atom x)return _(x,GtkToolButton)end type +global type MenuToolButton(atom x)return _(x,GtkMenuToolButton)end type +global type ToggleToolButton(atom x)return _(x,GtkToggleToolButton)end type +global type RadioToolButton(atom x)return _(x,GtkRadioToolButton)end type +global type Popover(atom x)return _(x,GtkPopover)end type +global type PopoverMenu(atom x)return _(x,GtkPopoverMenu)end type +global type ColorChooser(atom x)return _(x,GtkColorChooser)end type +global type ColorButton(atom x)return _(x,GtkColorButton)end type +global type ColorChooserWidget(atom x)return _(x,GtkColorChooserWidget)end type +global type ColorChooserDialog(atom x)return _(x,GtkColorChooserDialog)end type +global type FileChooser(atom x)return _(x,GtkFileChooser)end type +global type FileChooserButton(atom x)return _(x,GtkFileChooserButton)end type +global type FileChooserDialog(atom x)return _(x,GtkFileChooserDialog)end type +global type FileChooserWidget(atom x)return _(x,GtkFileChooserWidget)end type +global type FileFilter(atom x)return _(x,GtkFileFilter)end type +global type FontChooser(atom x)return _(x,GtkFontChooser)end type +global type FontButton(atom x)return _(x,GtkFontButton)end type +global type FontChooserWidget(atom x)return _(x,GtkFontChooserWidget)end type +global type FontChooserDialog(atom x)return _(x,GtkFontChooserDialog)end type +global type PlacesSidebar(atom x)return _(x,GtkPlacesSidebar)end type +global type Frame(atom x)return _(x,GtkFrame)end type +global type Scrollbar(atom x)return _(x,GtkScrollbar)end type +global type ScrolledWindow(atom x)return _(x,GtkScrolledWindow)end type +global type Adjustment(atom x)return _(x,GtkAdjustment)end type +global type Calendar(atom x)return _(x,GtkCalendar)end type +global type GLArea(atom x)return _(x,GtkGLArea)end type +global type Tooltip(atom x)return _(x,GtkTooltip)end type +global type Viewport(atom x)return _(x,GtkViewport)end type +global type Widget(atom x)return _(x,GtkWidget)end type +global type Container(atom x)return _(x,GtkContainer)end type +global type Bin(atom x)return _(x,GtkBin)end type +global type Range(atom x)return _(x,GtkRange)end type +global type PrintContext(atom x)return _(x,GtkPrintContext)end type +global type ListBoxRow(atom x)return _(x,GtkListBoxRow)end type +global type FontFamily(atom x)return _(x,PangoFontFamily)end type +global type FontFace(atom x)return _(x,PangoFontFace)end type +global type FontDescription(atom x)return _(x,PangoFontDescription)end type +global type AppChooserDialog(atom x)return _(x,GtkAppChooserDialog)end type +global type PaperSize(atom x)return _(x,GtkPaperSize)end type +global type DrawingArea(atom x)return _(x,GtkDrawingArea)end type +global type RecentChooserDialog(atom x)return _(x,GtkRecentChooserDialog)end type +global type RecentChooserWidget(atom x)return _(x,GtkRecentChooserWidget)end type +global type RecentChooser(atom x)return _(x,GtkRecentChooser)end type +global type RecentFilter(atom x)return _(x,GtkRecentFilter)end type +global type RecentChooserMenu(atom x)return _(x,GtkRecentChooserMenu)end type +global type EventBox(atom x)return _(x,GtkEventBox)end type +global type TreeModelFilter(atom x)return _(x,GtkTreeModelFilter)end type +global type Application(atom x)return _(x,GtkApplication)end type +global type ApplicationWindow(atom x)return _(x,GtkApplicationWindow)end type +global type Pixbuf(atom x)return _(x,GdkPixbuf)end type +global type IconTheme(atom x)return _(x,GtkIconTheme)end type +global type Cairo_T(atom x)return _(x,Cairo_t)end type +global type CellArea(atom x)return _(x,GtkCellArea)end type + +----------------------------- +-- copyright 2016 Irv Mullins +----------------------------- + diff --git a/eugtk/GtkEvents.e b/eugtk/GtkEvents.e new file mode 100644 index 0000000..fde1785 --- /dev/null +++ b/eugtk/GtkEvents.e @@ -0,0 +1,277 @@ + +---------------- +namespace events +---------------- + +export constant version = "4.12.0" + +--Thanks to Pete Eberlein for helping with this! + +include GtkEngine.e +include std/convert.e + +if not equal(version,gtk:version) then + Error(,,"GtkEvents version mismatch","should be version " & gtk:version) +end if + +-- Maps keys from keypad to match same keys on keyboard, +-- maps control/arrow keys to negative numbers, so they +-- can be differentiated from the same ascii character +-- values; + +constant keyvalues = { +{8,-8}, -- bksp +{9,-9}, -- tab +{20,-20}, -- scroll lock +{27,27}, -- escape +{80,-80}, -- home 'P' +{81,-81}, -- left arrow 'Q' +{82,-82}, -- up arrow 'R' +{83,-83}, -- right arrow 'S' +{84,-84}, -- down arrow 'T' +{85,-85}, -- page up 'U' +{86,-86}, -- page dn 'V' +{87,-87}, -- end 'W' +{99,-99}, -- insert 'c' +{103,-103}, +{127,-127}, -- num lock + +{141,13}, -- keypad Enter, with or w/o numlock; + +-- keypad keys w/o numlock; +{149,-149}, -- keypad home +{150,-150}, -- keypad left +{151,-151}, -- keypad up +{152,-152}, -- keypad right +{153,-153}, -- keypad down +{154,-154}, -- keypad pg up +{155,-155}, -- keypad pg dn +{156,-156}, -- keypad end +{157,-157}, -- keypad 5 +{158,-158}, -- keypad ins +{159,-159}, -- keypad del + +-- keypad keys with numlock - return ascii 0..9 +{170,'*'},{171,'+'},{173,'-'},{175,'/'}, +{176,48},{177,49},{178,50},{179,51},{180,52}, -- keypad numbers 0..4 +{181,53},{182,54},{183,55},{184,56},{185,57}, -- keypad numbers 5..9 + +-- F keys; +{190,-190}, -- F1 +{191,-191}, -- F2 +{192,-192}, -- F3 +{193,-193}, -- F4 +{194,-194}, -- F5 +{195,-195}, -- F6 +{196,-196}, -- F7 +{197,-197}, -- F8 +{198,-198}, -- F9 +{199,-199}, -- F10 +{200,-200}, -- F11 +{201,-201}, -- F12 +{227,-227}, -- left ctl +{228,-228}, -- right ctl +{229,-229}, +{225,-225}, -- left shift +{226,-226}, -- right shift +{228,-228}, +{233,-233}, -- left alt +{234,-234}, -- right alt +{236,-236}, +{255,-255}, -- delete +$} + +constant shiftkeys = { +{32,-9}, -- shift tab +$} + +constant event_names = { + {3,"focus-in"}, + {11,"focus-out"} + } + +---------------------------------------------------------------------- +export function key(atom event) -- get key pressed; +---------------------------------------------------------------------- +if event = 0 then return 0 end if +integer k = peek(event+16) +integer z = peek(event+17) +integer s = state(event) +ifdef BITS64 then + k = peek(event+28) + z = peek(event+29) +end ifdef +switch z do + case 0 then return k + case 255 then return vlookup(k,keyvalues,1,2,k) + case 254 then return vlookup(k,shiftkeys,1,2,k) +end switch +return 0 +end function + +--(32/64)struct GdkEventButton +-- 0 0 GdkEventType type a.k.a. id +-- 4 8 GtkWindow *window +-- 8 16 gint8 send_event +-- 12 20 guint32 time +-- 16 24 gdouble x +-- 24 32 gdouble y +-- 32 40 gdouble *axes +-- 36 48 guint state +-- 40 52 guint button +-- 44 56 GdkDevice *device +-- 48 64 gdouble x_root, y_root + +--------------------------------------------------------------------- +export function id(atom event) +--------------------------------------------------------------------- +if event > 0 then return peek4u(event) else return event end if +end function + +--------------------------------------------------------------------- +export function name(atom event) +--------------------------------------------------------------------- +event = id(event) +for i = 1 to length(event_names) do + if event = event_names[i][1] then + return event_names[i][2] + end if +end for +return -1 +end function + +--------------------------------------------------------------------- +export function window(atom event) -- get event window +--------------------------------------------------------------------- +ifdef BITS64 then + return peek8u(event + 8) +end ifdef + return peek4u(event + 4) +end function + +--------------------------------------------------------------------- +export function time(atom event) -- get event time +--------------------------------------------------------------------- +ifdef BITS64 then + return peek4u(event + 20) +end ifdef + return peek4u(event + 12) +end function + +--------------------------------------------------------------------- +export function xy(atom event) -- get mouse button x y; +--------------------------------------------------------------------- +ifdef BITS64 then + return floor({ + float64_to_atom(peek({event + 24, 8})), + float64_to_atom(peek({event + 32, 8}))}) +end ifdef + return floor({ + float64_to_atom(peek({event + 16, 8})), + float64_to_atom(peek({event + 24, 8}))}) +end function + +--------------------------------------------------------------------- +export function axes(atom event) +--------------------------------------------------------------------- +ifdef BITS64 then + return float64_to_atom(peek({event + 40, 8})) +end ifdef + return float64_to_atom(peek({event + 32, 8})) +end function + +--------------------------------------------------------------------- +export function button(atom event) -- get mouse button clicked; +--------------------------------------------------------------------- +ifdef BITS64 then + return peek(event+52) +end ifdef +return peek(event+40) +end function + +---------------------------------------------------------------------- +export function state(atom event) +---------------------------------------------------------------------- +ifdef BITS64 then + return peek(event+48) +end ifdef +return peek(event+36) +end function + +---------------------------------------------------------------------- +export function device(atom event) +---------------------------------------------------------------------- +ifdef BITS64 then + return peek(event+56) +end ifdef +return peek(event+44) +end function + +--------------------------------------------------------------------- +export function clicks(atom event) +--------------------------------------------------------------------- +atom ct = allocate(64) +object result + if gtk_func("gdk_event_get_click_count",{P,I},{event,ct}) then + result = peek4u(ct) + else + result = -1 + end if + free(ct) +return result +end function + +--------------------------------------------------------------------- +export function scroll_dir(atom event) +--------------------------------------------------------------------- +atom dir = allocate(64) +object result + if gtk_func("gdk_event_get_scroll_direction",{P,I},{event,dir}) then + result = peek4u(dir) + else + result = -1 + end if + free(dir) +return result +end function + +--------------------------------------------------------------------------------- +export function pending() -- used sometimes when using timeout or eu tasks +--------------------------------------------------------------------------------- + return gtk_func("gtk_events_pending") +end function + +------------------------------------------------------------------------ +export procedure main_iteration() +------------------------------------------------------------------------ + gtk_proc("gtk_main_iteration") +end procedure + +----------------------------------------------------------------------------------- +export procedure main_iteration_do(integer i) -- used sometimes when multi-tasking; +----------------------------------------------------------------------------------- + gtk_proc("gtk_main_iteration_do",{I},i) +end procedure + +------------------------------------------------------------------------ +-- following routine traps the enter key when Entry is activated, +-- and uses it like the tab key - so it works like people expect. +-- When using Glade, connect each entry's 'activate' signal to +-- trap_enter_key +------------------------------------------------------------------------ +constant gsig = define_proc("g_signal_emit_by_name",{P,P,P}) +constant fsig = allocate_string("move-focus") +------------------------------------------------------------------------ +global function trap_enter_key(atom ctl, atom event) +----------------------------------------------------------------------- + if class_id(ctl) = GtkEntry then + if event = 0 then + c_proc(gsig,{ctl,allocate_string("move-focus"),0}) + return 1 + end if + end if +return 0 +end function + + + diff --git a/eugtk/GtkFileSelector.e b/eugtk/GtkFileSelector.e new file mode 100644 index 0000000..91959ac --- /dev/null +++ b/eugtk/GtkFileSelector.e @@ -0,0 +1,454 @@ + +------------------------- +namespace fileselector -- Generic file selection dialog; +------------------------- + +--# EXPORTS: +/* + -- functions: + fileselector:New() + fileselector:Open() + fileselector:Save() + fileselector:SaveAs() + fileselector:CreateFolder() + fileselector:SelectFolder() + + -- returns: + full file path if successful, e.g. "/home/irv/demos/test99.ex" + or an atom: + MB_ABORT when dialog is closed + MB_CANCEL when cancel button is clicked. +*/ + +include GtkEngine.e + +export constant version = "4.12.0" + +if not equal(version,gtk:version) then + Error(,,"GtkFileSelector version mismatch","should be version " & gtk:version) +end if + + +-- default settings, change before calling the dialog if required; +export boolean + create_folders = TRUE, + local_only = TRUE, + select_multiple = FALSE, + show_hidden = FALSE, + do_overwrite_confirmation = TRUE, + show_preview = FALSE, + preview_widget_active = TRUE + +export sequence preview_size = {200,200} + +export atom preview_max = 150 -- default size + +export object selected_filter=0, filters = {"euphoria","text"} + +-- may change filters before calling the dialog +-- (or every 5,000 miles, whichever comes first) + +-- IOW, to show only .css files, add the line: +-- fileselector:filters = {"css"} +-- before calling: +-- fileselector:Open("~/demos/*") + +-- note that the syntax of the parameter to Open() is important: +-- ~/demos or ~/demos/ will only cause the dialog to highlight the ~/demos folder, +-- ~/demos/* will open the demos folder and display the [filtered] file types +-- ~/demos/*.css will show folders and all *.css files + +-- combining filters with wildcards: +-- fileselector:filters = {"images"} +-- fileselector:Open("~/demos/glade/*") +-- the above will show all images in the specified directory, + +-- whereas: +-- fileselector:Open("~/demos/glade/*.png") +-- will show only .png images in the specified directory, +-- regardless of how the filters are set. + +-- below, only .png images will be shown, but drop-down options to show .html and .c files +-- will be available also: +-- fileselector:filters = {"html","c"} +-- fileselector:Open("~/demos/glade/*.png") + +-------------------------------------- +function generate_filter(object name) +-------------------------------------- +object filter = 0 + + switch name do + + case "images",".jpg",".gif",".png",".xpm" then filter = create(GtkFileFilter,{ + {"name","Images"},{"add mime type","image/*"}}) + + case "euphoria",".eu",".e",".exw" then filter = create(GtkFileFilter,{ + {"name","Euphoria files"},{"add pattern","*.e"}, + {"add pattern","*.ex"},{"add pattern","*.cfg"}}) + + case "text",".text",".txt" then filter = create(GtkFileFilter,{ + {"name","All text"},{"add mime type","text/plain"}}) + + case "c",".c",".h" then filter = create(GtkFileFilter,{ + {"name","C source code"},{"add mime type","text/x-c"}, + {"add pattern","*.c"},{"add pattern","*.h"}}) + + case "c++" then filter = create(GtkFileFilter,{ + {"name","C++ source code"},{"add pattern","*.c++"}}) + + case "css",".css" then filter = create(GtkFileFilter,{ + {"name","css markup"},{"add mime type","text/css"}, + {"add pattern","*.css"}}) + + case "python",".python",".py" then filter = create(GtkFileFilter,{ + {"name","Python"},{"add mime type","text/x-python"}}) + + case "html",".htm",".html" then filter = create(GtkFileFilter,{ + {"name","html source"},{"add mime type","text/html"}, + {"add pattern","*.html"}}) + + case "ini",".ini" then filter = create(GtkFileFilter,{ + {"name","ini"},{"add pattern","*.ini"}}) + + case "all" then filter = create(GtkFileFilter,{ + {"name","All files"},{"add pattern","*"}}) + + case "dir" then filter = create(GtkFileFilter,{ + {"name","Directories"},{"add mime type","inode/directory"}}) + + end switch + +return filter + +end function + +constant update_preview = call_back(routine_id("UpdatePreview")) + +---------------------------------------------------------- +export function New(object current=0) +---------------------------------------------------------- +object result=0 +atom dlg = create(GtkFileChooserDialog) + +set(dlg,{ + {"name","FileNew"}, + {"title","Create a new file"}, + {"action",GTK_FILE_CHOOSER_ACTION_SAVE}, + {"preview widget active",preview_widget_active}, + + {"add button","gtk-cancel",MB_CANCEL}, + {"add button","gtk-ok",MB_OK}, + {"create folders",create_folders}, + {"local only",local_only}, + {"select multiple",select_multiple}, + {"show hidden",show_hidden}, + {"do overwrite confirmation",do_overwrite_confirmation}}) + + for i = 1 to length(filters) do + set(dlg,"add filter",generate_filter(filters[i])) + end for + + if show_preview = TRUE then + atom preview = create(GtkImage) + set(dlg,"preview widget",preview) + connect(dlg,"update-preview",update_preview,preview) + end if + + if atom(current) and current > 0 then + set(dlg,"current name",unpack(current)) + end if + + result = get(dlg,"run") + if result = MB_OK then + result = get(dlg,"filename") + end if + +destroy(dlg) + +return result +end function +export constant new = call_back(routine_id("New")) + +---------------------------------------------------- +export function Open(object data=0, atom x=0) +---------------------------------------------------- +object result=0 +object filter=0 + +if atom(data) and data > 0 then data = unpack(data) end if +if string(data) and equal("*",filename(data)) then filters &= {"all"} end if + +atom dlg = create(GtkFileChooserDialog) + +set(dlg,{ + {"name","FileOpen"}, + {"title","Open a file"}, + {"action",GTK_FILE_CHOOSER_ACTION_OPEN}, + {"preview widget active",preview_widget_active}, + + {"add button","gtk-cancel",MB_CANCEL}, + {"add button","gtk-ok",MB_OK}, + {"create folders",create_folders}, + {"local only",local_only}, + {"select multiple",select_multiple}, + {"show hidden",show_hidden}, + {"do overwrite confirmation",do_overwrite_confirmation}}) + + for i = 1 to length(filters) do + set(dlg,"add filter",generate_filter(filters[i])) + end for + + if show_preview = TRUE then + atom preview = create(GtkImage) + set(dlg,"preview widget",preview) + connect(dlg,"update-preview",update_preview,preview) + end if + + if atom(data) and data > 0 then + data = unpack(data) + end if + + if string(data) then + if file_exists(canonical_path(data)) then + set(dlg,"filename",canonical_path(data)) + else + if not equal("*",filename(data)) then + filter = create(GtkFileFilter,{ -- build a custom filter; + {"name",filename(data) & " files"}, + {"add pattern",filename(data)}}) + set(dlg,"add filter",filter) + set(dlg,"filter",filter) + end if + set(dlg,"filename",canonical_path(data)) -- change to desired folder; + end if + end if + + result = get(dlg,"run") + + if result = MB_OK then + result = get(dlg,"filename") + end if + + destroy(dlg) + +return result +end function +export constant open = call_back(routine_id("Open")) + +---------------------------------------------------- +export function Save(object data, object x=0) +---------------------------------------------------- +object result=0 +atom dlg = create(GtkFileChooserDialog) +atom f + +set(dlg,{ + {"name","FileSave"}, + {"title","Save this file"}, + {"action",GTK_FILE_CHOOSER_ACTION_SAVE}, + + {"add button","gtk-cancel",MB_CANCEL}, + {"add button","gtk-ok",MB_OK}, + {"create folders",create_folders}, + {"local only",local_only}, + {"select multiple",select_multiple}, + {"show hidden",show_hidden}, + {"do overwrite confirmation",do_overwrite_confirmation}}) + + for i = 1 to length(filters) do + set(dlg,"add filter",generate_filter(filters[i])) + end for + + if show_preview = TRUE then + atom preview = create(GtkImage) + set(dlg,"preview widget",preview) + connect(dlg,"update-preview",update_preview,preview) + end if + + if atom(data) and data > 0 then + set(dlg,"current name",unpack(data)) + end if + + if string(data) then + set(dlg,"current name",data) + end if + + result = get(dlg,"run") + + if result = MB_OK then + result = get(dlg,"filename") + end if + +destroy(dlg) + +return result +end function +export constant save = call_back(routine_id("Save")) + +----------------------------------------------------------- +export function SaveAs(object data=0, object x=0) +----------------------------------------------------------- +object result=0 +atom dlg = create(GtkFileChooserDialog) + +set(dlg,{ + {"name=FileSaveAs"}, + {"title","Save this file with a new name"}, + {"action",GTK_FILE_CHOOSER_ACTION_SAVE}, + + {"add button","gtk-cancel",MB_CANCEL}, + {"add button","gtk-ok",MB_OK}, + {"create folders",create_folders}, + {"local only",local_only}, + {"select multiple",select_multiple}, + {"show hidden",show_hidden}, + {"do overwrite confirmation",do_overwrite_confirmation}}) + + for i = 1 to length(filters) do + set(dlg,"add filter",generate_filter(filters[i])) + end for + + if show_preview = TRUE then + atom preview = create(GtkImage) + set(dlg,"preview widget",preview) + connect(dlg,"update-preview",update_preview,preview) + end if + + if atom(data) and data > 0 then + set(dlg,"current name",unpack(data)) + elsif string(data) then + set(dlg,"current name",data) + end if + + result = get(dlg,"run") + + if result = MB_OK then + result = get(dlg,"filename") + end if + + destroy(dlg) + +return result +end function +export constant save_as = call_back(routine_id("SaveAs")) + +--------------------------------------------------------------- +export function CreateFolder(object data=0, object x=0) +--------------------------------------------------------------- +object result=0 +atom dlg = create(GtkFileChooserDialog) + +set(dlg,{ + {"name=NewFolder"}, + {"title","Create a new folder"}, + {"action",GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER}, + + {"add button","gtk-cancel",MB_CANCEL}, + {"add button","gtk-ok",MB_OK}, + {"create folders",create_folders}, + {"local only",local_only}, + {"select multiple",select_multiple}, + {"show hidden",show_hidden}, + {"do overwrite confirmation",do_overwrite_confirmation}}) + + for i = 1 to length(filters) do + set(dlg,"add filter",generate_filter(filters[i])) + end for + + if show_preview = TRUE then + atom preview = create(GtkImage) + set(dlg,"preview widget",preview) + connect(dlg,"update-preview",update_preview,preview) + end if + + if atom(data) and data > 0 then + set(dlg,"current name",unpack(data)) + end if + + result = get(dlg,"run") + + if result = MB_OK then + result = get(dlg,"filename") + end if + +destroy(dlg) + +return result +end function +export constant create_folder = call_back(routine_id("CreateFolder")) + +--------------------------------------------------------------- +export function SelectFolder(object data=0, object x=0) +--------------------------------------------------------------- +object result=0 +atom dlg = create(GtkFileChooserDialog) + +set(dlg,{ + {"name","SelectFolder"}, + {"title","Select a folder"}, + {"action",GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER}, + + {"add button","gtk-cancel",MB_CANCEL}, + {"add button","gtk-ok",MB_OK}, + {"create folders",create_folders}, + {"local only",local_only}, + {"select multiple",select_multiple}, + {"show hidden",show_hidden}, + {"do overwrite confirmation",do_overwrite_confirmation}}) + + for i = 1 to length(filters) do + set(dlg,"add filter",generate_filter(filters[i])) + end for + + if show_preview = TRUE then + atom preview = create(GtkImage) + set(dlg,"preview widget",preview) + connect(dlg,"update-preview",update_preview,preview) + end if + + if atom(data) and data > 0 then + data = unpack(data) + if string(data) then + if file_exists(canonical_path(data)) then + set(dlg,"filename",canonical_path(data)) + else + set(dlg,"filename",data) + end if + end if + end if + +result = get(dlg,"run") + +if result = MB_OK then + result = get(dlg,"filename") +end if + +destroy(dlg) + +return result +end function +export constant select_folder = call_back(routine_id("SelectFolder")) + +------------------------------------------------------------------------------ +function UpdatePreview(atom dlg, atom preview) -- local: follow focus changes; +------------------------------------------------------------------------------ +object pix +atom ratio +object dimensions +object fn = get(dlg,"filename") + +if string(fn) then -- avoid trying to preview a directory! + pix = create(GdkPixbuf,fn) + if pix > 0 then + dimensions = get(pix,"size") + ratio = preview_max / dimensions[1] + dimensions *= {ratio,ratio} + pix = get(pix,"scale simple",dimensions[1],dimensions[2],1) + set(preview,"from pixbuf",pix) + end if +end if + +return 0 +end function + diff --git a/eugtk/GtkFontSelector.e b/eugtk/GtkFontSelector.e new file mode 100644 index 0000000..dc5165f --- /dev/null +++ b/eugtk/GtkFontSelector.e @@ -0,0 +1,154 @@ + +---------------------- +namespace fontselector -- Generic font selector dialog +---------------------- + +--# EXPORTS +/* + -- functions -- callbacks + fontselector:Select() fontselector:select + fontselector:FilterFonts() fontselector:filter + +-- fontlist +*/ + +include GtkEngine.e +include GtkCairo.e +include std/wildcard.e +include std/hash.e + +export constant version = "4.12.0" + +if not equal(version,gtk:version) then + Error(,,"GtkFontSelector version mismatch","should be version " & gtk:version) +end if + +-- Optional parameter is preferred (default) font, the one to be +-- returned if the font dialog ok button is clicked without choosing +-- a different font. You can just specify a size here: "8" and that +-- will set only the dialog's size selector. +-- +-- You can specify a full font name and size: e.g. Purisa bold 16, +-- and that font will be the one highlighted for selection. +-- If you specify a font that doesn't exist: e.g. Bogus italic 18, +-- and then use the returned font, GTK will do the best it can, +-- which will be to set the existing font to italic in 18pt. +-- Fairly fail-safe, in other words. +-- +-- Setting this does not filter the list of fonts shown by the dialog. +-- to do this, you need to set the pattern. See below. +-- +-- To exclude unwanted (and unreadable) fonts, such as symbols and +-- dingbats, add them to the exclude sequence. See below. +-- +-- pattern can be set prior to the select() call +-- pattern can be an array of font names, wildcards are ok +-- e.g. {"Courier*","purisa"} +-- if you use, for example, just {"Courier"}, without the wildcard, +-- no fonts will be found. +-- +-- {"sans"}, {"*sans"}, or {"*sans*"} will each return a different +-- set of matching font names! trial and error may be required. +-- +-- if pattern is left unset, ALL fonts will be shown! + +export atom dlg = create(GtkFontChooserDialog,"name=FontSelector") + +export object + name = 0, -- font name + title = "Choose a font", -- dialog title + preview_text = "This is an EuGTK font selector", + description = 0, -- a PangoFontDescription + family = 0, -- font family + style = 0, -- normal, oblique, italic + variant = 0, + weight = PANGO_WEIGHT_NORMAL, + mono_filter = 0, + font_list = {} + +export atom size = 12*1024 +export integer points = 12 +export sequence pattern = {"*"} + +export sequence exclude = {"*symbol*","*dingbat*","*webdings","*wingdings*"} +-- above list filters out unusable fonts; + +------------------------------------------------------------------------ +export function Select(object curr_fnt=0) +------------------------------------------------------------------------ + set(dlg,"title","Select a font") + set(dlg,"preview text",preview_text) + if string(curr_fnt) then + set(dlg,"font",curr_fnt) + end if + pattern = lower(pattern) + exclude = lower(exclude) + + set(dlg,"filter func",filter) + + if get(dlg,"run") then + name = get(dlg,"font") + description = create(PangoFontDescription,name) + family = get(description,"family") + size = get(description,"size") + points = math:round(size/PANGO_UNIT) + variant = get(description,"variant") + style = get(description,"style") + weight = get(description,"weight") + end if + + hide(dlg) -- we keep it around, since it's likely to be used again :p + +return name +end function +export constant select = call_back(routine_id("Select")) + +------------------------------------------------------------------------ +export function FilterFonts(object family, object face, object data) +------------------------------------------------------------------------ +integer result = 0 + +if mono_filter then + if gtk_func("pango_font_family_is_monospace",{P},{family}) = FALSE then + return 0 + end if +end if + +object name = lower(gtk_str_func("pango_font_family_get_name",{P},{family})) + for i = 1 to length(pattern) do + result = is_match(pattern[i],name) > 0 + if result = 1 then + for x = 1 to length(exclude) do + if is_match(exclude[x],name) then + return 0 + end if + end for + end if + return result + end for +return result +end function +export constant filter = call_back(routine_id("FilterFonts")) + +sequence weight_names = +{"thin","ultralight","light","book","normal","medium", +"semibold","bold","ultrabold","heavy","ultraheavy"} + +/* -- reference; + PANGO_WEIGHT_THIN = 100, + PANGO_WEIGHT_ULTRALIGHT = 200, + PANGO_WEIGHT_LIGHT = 300, + PANGO_WEIGHT_BOOK = 380, + PANGO_WEIGHT_NORMAL = 400, + PANGO_WEIGHT_MEDIUM = 500, + PANGO_WEIGHT_SEMIBOLD = 600, + PANGO_WEIGHT_BOLD = 700, + PANGO_WEIGHT_ULTRABOLD = 800, + PANGO_WEIGHT_HEAVY = 900, + PANGO_WEIGHT_ULTRAHEAVY = 1000, + PANGO_UNIT = 1024 + + PANGO_STYLE_NORMAL = 0, + PANGO_STYLE_OBLIQUE = 1, + PANGO_STYLE_ITALIC = 2 +*/ diff --git a/eugtk/GtkPrinter.e b/eugtk/GtkPrinter.e new file mode 100644 index 0000000..972a083 --- /dev/null +++ b/eugtk/GtkPrinter.e @@ -0,0 +1,567 @@ + +-------------------- +namespace printer -- Utility to make printing easier +-------------------- + +export constant version = "4.12.0" + + -- EXPORTS: + -- functions callbacks + -- printer:PrintFile() printer:print_file + -- printer:PrintText() printer:print_text + +-- This version handles most common printing needs, but it will not yet respect +-- 'marked up' a.k.a. 'rich' text, i.e. text with colors and styles as produced +-- by GTK3's TextView widget. It just prints them as plain text. +-- +-- However, it DOES print text marked up with GTK's HTML subset, so you can use +-- , , , , ... etc. in your printouts! This includes various +-- imbedded font styles and colors. +-- +-- More documentation is found in ~/documentation/printing.html + +include GtkEngine.e +include GtkCairo.e +include std/datetime.e + +if not equal(version,gtk:version) then + Error(,,"GtkPrinter version mismatch","should be version " & gtk:version) +end if + +-- The following exported variables can be modified before calling the +-- print routine: + +public object header = "[1]\n" -- default is just the page title + +public object subheader = "[1] page [5]\n\n" -- format for headers on pg.2 ... n +-- default subheader (above) prints page title and pg #; + +public object footer = "\nPrinted by EuGTK [8] on [9]'s computer" +-- default footer (above) prints date and user name; + +-- Info ID's for use in header and footer; +-- 1 = page title (for first page) +-- 2 = sub title (for subsequent pages - leave null to use page title (1) on all pgs) +-- 3 = file name +-- 4 = short name (file name w/o path) +-- 5 = current page number +-- 6 = n_pages printed e.g. pg 1 of n +-- 7 = n_copies requested +-- 8 = today's date in date_format +-- 9 = user name +--10 = user's real name +--11 = font name used for this print job +--12 = file length in bytes +--13 = file timestamp +--14 = exported filename, if any + +export integer + n_pages = 0, -- number of pages to print (0=all) + n_copies = 1, + collate = FALSE, + duplex = 0, + number_up = 1, + number_up_layout = 1, + units = GTK_UNIT_INCH, + use_line_numbers = TRUE, + use_color = TRUE, -- print eu comments in red if true + lines_per_page = 60, + wrap_at = 0, + track_status = TRUE, + show_progress = TRUE, -- enable the built-in progressbar + embed_page_setup = TRUE, + orientation = 0, + order = 0, + confirm = FALSE, + sourcecode = TRUE, + plaintext = FALSE, + use_full_page = FALSE, -- ignore margins + has_selection = FALSE, + support_selection = FALSE, + quality = GTK_PRINT_QUALITY_DRAFT, + action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, + auto_lpp = TRUE + +export atom + scale = 100, + top_margin = 0.25, -- in inch units + left_margin = 0.25, + right_margin = 0.25, + bottom_margin = 0.25, + parent = 0, + + signal_status_changed = call_back(routine_id("show_status")), + signal_begin_print = call_back(routine_id("begin_print")), + signal_draw_page = call_back(routine_id("draw_page")), + signal_end_print = call_back(routine_id("end_print")), + signal_request_page_setup = 0, + signal_done = 0, + signal_ready = 0, + signal_got_page_size = 0 + +export object + name = 0, + font = "Ubuntu Mono 8", + jobname = 0, + settings_file = 0, + setup_file = 0, + export_file = 0, + page_ranges = 0, + page_set = GTK_PAGE_SET_ALL, + custom_tab_hook = 0, + custom_tab_label = 0, + custom_tab_func = 0 + +ifdef WINDOWS then font = "Courier New 16" end ifdef + +export object + line_number_format = "[:4] []\n", -- controls line # format AND code line! + paper_name = "na_letter", -- 8.5x11.0" + tabs = " ", -- replace tab chars with 8 spaces + file_name = 0, + short_name = 0, + page_title = 0, + sub_title = 0 + +export atom + progress = create(GtkProgressBar), + settings = create(GtkPrintSettings) + +-- use date and time formats in std/datetime.e; +export sequence date_format = "%A, %B %d %Y %l:%M %p" + +sequence user +ifdef WINDOWS then + user = "User" +elsedef + user = proper(getenv("USER")) +end ifdef + +-- for local use; +atom fontdesc +integer filesize = 0 +object timestamp = 0 +sequence text +sequence today = datetime:format(datetime:now(),date_format) + +export procedure reset() + n_pages = 0 + n_copies = 1 + collate = FALSE + duplex = 0 + number_up = 1 + number_up_layout = 1 + units = GTK_UNIT_INCH + use_line_numbers = TRUE + use_color = TRUE + lines_per_page = 60 + wrap_at = 0 + track_status = TRUE + show_progress = TRUE + embed_page_setup = TRUE + orientation = 0 + order = 0 + confirm = FALSE + sourcecode = TRUE + plaintext = FALSE + use_full_page = FALSE + has_selection = FALSE + support_selection = FALSE + quality = GTK_PRINT_QUALITY_DRAFT + action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG + auto_lpp = TRUE + + scale = 100 + top_margin = 0.25 + left_margin = 0.25 + right_margin = 0.25 + bottom_margin = 0.25 + parent = 0 + + name = 0 + paper_name = "na_letter" + font = "Ubuntu Mono 8" + jobname = 0 + settings_file = 0 + setup_file = 0 + export_file = 0 + page_ranges = 0 + page_set = GTK_PAGE_SET_ALL + custom_tab_hook = 0 + custom_tab_label = 0 + custom_tab_func = 0 + +end procedure + +------------------------------------------------------------------------ +export function PrintFile(object f=0, object x=0) +------------------------------------------------------------------------ + +if string(f) and string(x) then + page_title = f + file_name = canonical_path(x) + timestamp = file_timestamp(file_name) + filesize = file_length(file_name) + short_name = filebase(file_name) + text = read_file(file_name) + setup_printer() + return 1 +end if + +if string(f) and atom(x) and x = 0 then + f = canonical_path(f) + file_name = f + timestamp = file_timestamp(f) + filesize = file_length(f) + short_name = filebase(f) + page_title = filename(f) + text = read_file(f) + setup_printer() + return 1 +end if + +if string(f) and atom(x) and x < 100 then + page_title = f + short_name = f + file_name = f + text = read_file(x) + setup_printer() + return 1 +end if + +if atom(f) and atom(x) and x < 101 then + if atom(file_name) then + file_name = "" + end if + if atom(short_name) then + short_name = "" + end if + if atom(page_title) then + page_title = "" + end if + text = read_file(x) + setup_printer() + return 1 +end if + +if atom(f) and atom(x) then + x = unpack(x) + x = canonical_path(x) + file_name = x + short_name = filebase(x) + page_title = filename(x) + text = read_file(x) + setup_printer() + return 1 +end if + +return 1 +end function +export constant print_file = call_back(routine_id("PrintFile")) + +------------------------------------------------------------------------ +export function PrintText(object f=0, object x=0) +------------------------------------------------------------------------ + +if string(f) and string(x) then + page_title = f + text = x + setup_printer() + return 1 +end if + +if atom(f) and string(x) then + setup_printer() + text = x + return 1 +end if + +if atom(f) and atom(x) then + if atom(page_title) and page_title = 0 then + page_title = "" + end if + text = unpack(x) + setup_printer() + return 1 +end if + +return 0 +end function +export constant print_text = call_back(routine_id("PrintText")) + +integer status_code +sequence status_string + +----------------------------------------------- +export function show_status(atom op) +----------------------------------------------- +atom + fn1 = define_func("gtk_print_operation_get_status",{P},I), + fn2 = define_func("gtk_print_operation_get_status_string",{P},S) + +status_code = c_func(fn1,{op}) +status_string = peek_string(c_func(fn2,{op})) + +ifdef PRINT then display("Status [] []",{status_code,status_string}) end ifdef + +if show_progress then + set(progress,"text",status_string) +end if + +ifdef DELAY then sleep(0.15) end ifdef + +return 1 +end function + +------------------------------------------------------ +export function begin_print(atom op, atom context) +------------------------------------------------------ +ifdef PRINT then display("Begin printing [] pages ",length(text)) end ifdef + +fontdesc = create(PangoFontDescription,font) + +if auto_lpp then +atom setup = get(op,"default page setup") + atom pght = get(setup,"page height",GTK_UNIT_POINTS) + --display("Page height [] pt.",pght) + pght -= length(header) + pght -= length(footer) + atom fs = get(fontdesc,"size") / 1024 + --display("Font size []",fs) + fs = fs * (96/72) + integer lpp = 1 + while ((fs*lpp)) < pght do + lpp += 1 + --display("Text height [] lpp []",{(fs*lpp),lpp}) + end while + --display("New LPP []",lpp-1) + lines_per_page = lpp +end if + +text = process_text(text) + +set(op,"n pages",n_pages) + +-- important, as a new value for n_pages is computed +-- based on the length of the file being read, unless a set number +-- has been provided from the calling program. + +if show_progress then -- turn on the progress dialog in the calling program + show_all(progress) +end if + +return 1 +end function + +---------------------------------------------------------------------------- +export function draw_page(atom op, atom context, integer pg, atom data) +---------------------------------------------------------------------------- +atom fn6 = define_func("gtk_print_context_get_cairo_context",{P},P) + +atom cr = c_func(fn6,{context}) +atom pl = create(PangoCairoLayout,cr) + set(pl,"font description",fontdesc) + +pg += 1 +if pg > length(text) then + set(progress,"text","Printing complete") + return 0 +end if + +if show_progress then + set(progress,"text",sprintf("Printing page %d",pg)) + set(progress,"fraction",pg/n_pages) +end if + +ifdef DELAY then sleep(0.25) end ifdef + +object details = { + page_title,sub_title,file_name,short_name, + pg,n_pages,n_copies, + today,user,real_name,font,filesize,timestamp,export_file + } + +object page + +if atom(header) then header = "[1] page [5] of [6]\n\n" end if + +if pg = 1 or atom(subheader) then + page = text:format(header,details) + & flatten(text[pg]) + & text:format(footer,details) +else + page = text:format(subheader,details) + & flatten(text[pg]) + & text:format(footer,details) +end if + +if plaintext then + set(pl,"text",page,length(page)) +else + set(pl,"markup",page,length(page)) +end if + + set(pl,"update layout",cr) + set(pl,"show layout",cr) + +ifdef PRINT then printf(1,"Page %d\n",pg) end ifdef + +return 1 +end function + +------------------------------------------------------------------------ +function process_text(object txt) +------------------------------------------------------------------------ +txt = split(txt,'\n') +integer comment, n +object a,b +object test + + +for i = 1 to length(txt) do -- replace chars which will confuse markup + + txt[i] = join(split(txt[i],'&'),"&") + txt[i] = join(split(txt[i],"&amp;"),"&") + + if sourcecode then + txt[i] = join(split(txt[i],'<'),"<") + txt[i] = join(split(txt[i],'>'),">") + end if + + if use_color then + if match("--",txt[i]) then -- a comment; + txt[i] = split(txt[i],"--") + txt[i] = txt[i][1] & "-- " & txt[i][2] & "" + end if + end if + + if use_line_numbers then + txt[i] = text:format(line_number_format,{i,txt[i]}) + else + txt[i] &= '\n' + end if + +end for + +txt = breakup(txt,lines_per_page) + +if n_pages = 0 then -- no selection + n_pages = length(txt) +end if + +return txt +end function + +------------------------------------------------------------------------ +export function end_print() +------------------------------------------------------------------------ +status_string = "Printing complete" +ifdef PRINT then display(status_string) end ifdef +return 1 +end function + +--------------------------------------------------------------- +export function setup_printer() +--------------------------------------------------------------- +atom _size = create(GtkPaperSize,paper_name) +atom err = allocate(16) err = 0 +object results = 0 + +atom fn7 = define_func("gtk_print_operation_run",{P,I,P,P},I) +atom fn8 = define_func("gtk_print_run_page_setup_dialog",{P,P,P},P) + + set(settings,"paper size",_size,units) + set(settings,"n copies",n_copies) + set(settings,"collate",collate) + set(settings,"duplex",duplex) + set(settings,"reverse",order) + set(settings,"scale",scale) + set(settings,"quality",quality) + set(settings,"number up",number_up) + set(settings,"number up layout",number_up_layout) + + if string(name) then + set(settings,"printer",name) + end if + +atom setup = create(GtkPageSetup) + set(setup,"paper size",_size) + set(setup,"orientation",orientation) + set(setup,"left margin",left_margin,units) + set(setup,"right margin",right_margin,units) + set(setup,"top margin",top_margin,units) + set(setup,"bottom margin",bottom_margin,units) + +atom printop = create(GtkPrintOperation) + set(printop,"print settings",settings) + set(printop,"default page setup",setup) + set(printop,"show progress",show_progress) + set(printop,"track print status",track_status) + set(printop,"embed page setup",embed_page_setup) + set(printop,"support selection",support_selection) + set(printop,"has selection",has_selection) + set(printop,"use full page",use_full_page) + + if action = GTK_PRINT_OPERATION_ACTION_EXPORT then + export_file = canonical_path(export_file) + set(printop,"export filename",export_file) + end if + + if string(jobname) then + set(printop,"job name",jobname) + end if + + if custom_tab_hook != 0 then + set(printop,"custom tab label",custom_tab_label) + connect(printop,"create-custom-widget",custom_tab_func,printop) + connect(printop,"custom-widget-apply",custom_tab_hook) + end if + + connect(printop,"status-changed",signal_status_changed) + connect(printop,"begin-print",signal_begin_print) + connect(printop,"draw-page",signal_draw_page) + connect(printop,"end-print",signal_end_print) + connect(printop,"request-page-setup",signal_request_page_setup) + connect(printop,"done",signal_done) + connect(printop,"ready",signal_ready) + connect(printop,"got-page-size",signal_got_page_size) + + display(get(settings,"printer lpi")) + + c_func(fn7,{printop,action,parent,err}) -- start the print process; + + if string(setup_file) and file_exists(canonical_path(setup_file)) then + get(setup,"to file",canonical_path(setup_file)) + end if + +object jobname = get(printop,"job name") + if confirm then + if action = GTK_PRINT_OPERATION_ACTION_EXPORT then + if Question(0,"PDF Written", + sprintf("%s\nFolder: %s", + {filename(export_file),pathname(export_file)}), + sprintf("%s\nStatus: %d\n%s\nClick Yes to view",{jobname,status_code,status_string}) + ,,,"printer") then + show_uri(export_file) + end if + else + Info(0,"Print Job",jobname, + sprintf("Status: %d %s",{status_code,status_string}) + ,,"printer") + end if + end if + + page_title = 0 + n_pages = 0 + n_copies = 1 + action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG + +return 1 +end function + +header = "[1]\n\n" + +----------------------------- +-- copyright 2015 Irv Mullins +----------------------------- + diff --git a/eugtk/GtkSettings.e b/eugtk/GtkSettings.e new file mode 100644 index 0000000..033a31e --- /dev/null +++ b/eugtk/GtkSettings.e @@ -0,0 +1,305 @@ + +--------------------- +namespace settings -- functions to read and write config files (*.ini); +--------------------- + +export constant version = "4.12.0" + +--# EXPORTS +/* + --functions: + settings:Save() + settings:Load() + settings:Add() + + -- debug: + -d SETTINGS +*/ + +include GtkEngine.e + +if not equal(version,gtk:version) then + Error(,,"GtkSettings version mismatch","should be version " & gtk:version) +end if + +constant fmt = """[].[]=[]""" + +------------------------------------------------------------------------ +export function Save(sequence inifile, object ctl_list, integer debug=0) +------------------------------------------------------------------------ +-- writes an 'ini' type file (file name and extension are up to you) +-- with an entry for each control on ctl_list. The controls MUST have +-- been named, otherwise there's no way to save and retrieve the +-- value/setting for that control. +------------------------------------------------------------------------ +object comments = {} +object txt,line + +if file_exists(inifile) then + + txt = read_lines(inifile) + for i = 1 to length(txt) do -- extract the comments; + line = txt[i] + if match("--",line) = 1 + or match("!",line) = 1 + or match("+",line) = 1 + or equal("\n",line) + or equal({},line) then + comments = append(comments,line) + end if + end for + write_lines(inifile,comments) -- removing everything but the comments; +end if -- file exists + +object setting, tmp = 0, pos = {0,0} +object t1, name, prop +atom handle +integer class + +atom fn = open(inifile,"a") + +for x = 1 to length(ctl_list) do + + if string(ctl_list[x]) then + handle = pointer(ctl_list[x]) + else + handle = ctl_list[x] + end if + + name = get(handle,"name") + class = class_id(handle) + + if class=GtkWindow then -- special handling for multiple properties; + printf(fn,"%s\n",{get_setting(handle,"size")}) + pos = get(handle,"position") + printf(fn,"%s.position={%d,%d}\n",{name,pos[1],pos[2]}) + + else + setting = get_setting(handle) -- others have 1 obvious 'saveable' property + if length(setting) < 1 then + continue + end if + + if sequence(setting) then + printf(fn,"%s\n",{setting}) + end if + end if +end for + +flush(fn) +close(fn) + +-- if ! exists for this control:property, then ignore the updated setting; +tmp = read_lines(inifile) +for i = 1 to length(tmp) do + if match("--!",tmp[i]) = 1 then + t1 = split(tmp[i],"=") + t1 = t1[1][2..$] + end if +end for + +write_lines(inifile,tmp) + +return 1 +end function + +------------------------------------------------------------------------ +export function Load(sequence inifile, integer debug=0) +------------------------------------------------------------------------ +-- used to restore settings from the specified ini file. +-- this should be called after the controls are 'realized' + +object txt, line, obj, prop, val1=0, val2=0, val3=0, val4=0 + +if not(file_exists(inifile)) then + write_file(inifile,sprintf("--%s\n\n",{inifile}),TEXT_MODE) + display("Creating ini file: []",{inifile}) +else + if debug then display("Reading []",{inifile}) end if +end if + +txt = read_lines(inifile) + +integer err=0 +object a,b + +for i = 1 to length(txt) do + + line = txt[i] + + if match("--",line) > 2 then -- strip trailing comments; + line = line[1..match("--",line)-2] + end if + + if match("--!",line) = 1 then + line = line[4..$] -- keep it + end if + + if match("+",line) = 1 or match("!",line) then + line = line[2..$] -- dito + end if + + if match("--",line) or match(";",line) + or match("/*",line) then + continue -- a comment, do nothing with it + end if + + if length(line) > 0 then + line = split(line,'=') + a = line[1] b = line[2] + a = split(a,'.') + line = a & {b} + + if debug > 1 then display(line) end if + + if vlookup(line[1],registry,4,1,-1) = -1 then + err = i + Error(,"Ini Load Error", + sprintf("Invalid object name: %s",{line[1]}), + sprintf("Line #%d of %s",{i,filename(inifile)})) + else + if equal("data",line[2]) then + set(line[1],"data",line[3],line[4]) + else + set(line[1],line[2],line[3]) + end if + end if + end if +end for + +if debug = 1 then + for i = 1 to length(txt) do + if i = err then + display("ERROR:[:3]:[]",{i,txt[i]}) + else + display("[:3]:[]",{i,txt[i]}) + end if + end for +end if + +write_lines(inifile,txt) + +return 1 +end function + +------------------------------------------------------------------------------------------- +export function Add(object ini,object ctl, sequence prop, object v1=0, object v2=0) +------------------------------------------------------------------------------------------- +if atom(ctl) then ctl = get(ctl,"name") end if + +Delete(ini,ctl,prop) + +if equal("position",prop) or equal("size",prop) then +if string(v1) then v2 = v1[2] v1 = v1[1] end if +end if + +if atom(v2) and v2=0 then + writefln("+[].[]=[]",{ctl,prop,v1},{ini,"a"}) +else + writefln("+[].[]={[],[]}",{ctl,prop,v1,v2},{ini,"a"}) +end if + +return 1 +end function + +-------------------------------------------------------------------- +export function Delete(object ini,object ctl, sequence prop) +-------------------------------------------------------------------- +if atom(ctl) then ctl = get(ctl,"name") end if +object tmp = read_lines(ini) +object out = {} +object s1 = text:format("[].[]",{ctl,prop}) +for i = 1 to length(tmp) do + if match(s1,tmp[i]) then -- skip + else out &= {tmp[i]} + end if +end for +write_lines(ini,out) +return 1 +end function + +--------------------------------------------------------------------------------- +function get_setting(object self, object property = 0) +-- returns the 'important' value from a control +--------------------------------------------------------------------------------- +-- returns settings string +-- object must be a named object, e.g. MyButton + +-- MyButton.active=1 +-- My Calendar.date={YYYY,MM,DD} + +object name = 0 +object dt + +if string(self) then + name = self + self = vlookup(self,registry,4,1) +end if + +object val = 0 +object txt = {} + +integer x = find(self,vslice(registry,1)) + + ifdef SETTINGS then + display("SELF [] []",{x,self}) + display(registry[x]) + end ifdef + + switch class_id(self) do + -- this decides which value is the important one to save; + -- and stores the control's current value into the registry; + + case GtkEntry,GtkEntryBuffer then property = "text" + + case GtkCheckButton,GtkRadioButton, GtkToggleButton, + GtkSwitch,GtkComboBox,GtkComboBoxText, + GtkCheckMenuItem,GtkToggleToolButton, GtkSearchEntry + then property = "active" + + case GtkPopover then property = "position" + + case GtkFontButton then property = "font name" + + case GtkAdjustment,GtkSpinButton,GtkScaleButton,GtkVolumeButton, + GtkModelButton,GtkScale + then property = "value" + + case GtkEntryCompletion then property = "model" + + case GtkLinkButton then property = "uri" + + case GtkMenuItem then property = "sensitive" + + case GtkPaned then property = "position" + + case GtkFileChooser, GtkFileChooserButton, GtkFileChooserWidget, GtkFileChooserDialog + then property = "filename" + + case GtkFontChooser, GtkFontChooserWidget, GtkFontChooserDialog then + property = "font" + + case GtkCalendar then + dt = get(self,"datetime",0) + registry[x][5] = {"date",dt[1..3]} + txt &= text:format(fmt,{registry[x][4],"date",dt[1..3]}) + return txt + + case GtkColorButton,GtkColorChooser,GtkColorChooserWidget, + GtkColorChooserDialog then + registry[x][5] = {"rgba",get(self,"rgba",1)} + txt &= text:format(fmt,{registry[x][4],"rgba",get(self,"rgba",1)}) + return txt + + end switch + + if atom(property) then + return txt + end if + + val = get(self,property) + registry[x][5] = {property,val} + txt &= text:format(fmt,{registry[x][4],property,val}) + +return txt +end function diff --git a/mandy.exw b/mandy.exw new file mode 100644 index 0000000..f31fb31 --- /dev/null +++ b/mandy.exw @@ -0,0 +1,16 @@ +include "eugtk/GtkEngine.e" +include eugtk/GtkAboutDialog.e +include eugtk/GtkFileSelector.e +include eugtk/GtkEvents.e +include std/io.e + + +function nigger () + + atom clown1 = create(GdkPixbuf, 80,80,1) + Warn(0,,"You are getting a fucking warning from jitty", "but this is normal",,clown1,clown1) + + return 0 +end function + +nigger() diff --git a/tools/WEE/EuGTK/GtkEngine.e b/tools/WEE/EuGTK/GtkEngine.e new file mode 100644 index 0000000..8637eec --- /dev/null +++ b/tools/WEE/EuGTK/GtkEngine.e @@ -0,0 +1,8800 @@ + +------------- +namespace gtk +------------- + +------------------------------------------------------------------------ +-- This library is free software; you can redistribute it +-- and/or modify it under the terms of the GNU Lesser General +-- Public License as published by the Free Software Foundation; +-- either version 2 of the License, or (at your option) any later +-- version. + +-- This library is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +-- See the GNU Lesser General Public License for more details. + +-- You should have received a copy of the GNU Lesser General Public +-- License along with this library; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Pl, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------ + +export constant + version = "4.9.4", + release = "Apr 15, 2015", + copyright = "© 2015 by Irv Mullins" + +public include GtkEnums.e +-- GtkEnums includes most of Eu std libraries, making them available to your eu programs +-- without specifically including them. std/math, std/locale, and std/datetime aren't +-- public, because that would cause too many conflicting names, requiring you to use +-- namespaces everywhere. + +if not equal(gtk:version,enums:version) then + crash("Version mismatch: GtkEnums should be version %s",{version}) +end if + +include std/datetime.e +include std/math.e + +public constant -- 'shorthand' identifiers save space in method prototypes; + P = C_POINTER, I = C_INT, S = E_OBJECT, B = C_BYTE, + D = C_DOUBLE, F = C_FLOAT, A = E_SEQUENCE + +export object LIBS + +constant windll = "C:\\gtk\\bin\\" -- assume this is where you put your gtk3.dll's + +ifdef OSX then -- thanks to Pete Eberlein for testing with OSX! + LIBS = {open_dll("/opt/local/lib/libgtk-3.dylib" )} +elsifdef UNIX then -- Linux, BSD, etc. + LIBS = {open_dll("libgtk-3.so.0" )} +end ifdef + +ifdef WINDOWS then -- assuming you put the dlls in C:\\gtk... + LIBS = { + "libgtk-3-0.dll", + "libgdk-3-0.dll", + "libglib-2.0-0.dll", + "libgobject-2.0-0.dll", + "libgdk_pixbuf-2.0-0.dll", + "libpango-1.0-0.dll", + "libcairo-2.dll", + "libpangocairo-1.0-0.dll", + "libpng15-15.dll", + "librsvg-2-2.dll", + "libgio-2.0-0.dll" + } + atom x + chdir(windll) -- switch to dll folder so dll's can find other dll's + for i = 1 to length(LIBS) do + x = open_dll(windll & LIBS[i]) + if x = 0 then + display("Error loading []",{windll & LIBS[i]}) + else + LIBS[i] = x + end if + end for + +end ifdef + + if not object(LIBS) then + crash("GTK Libraries not found!") + end if + + for i = 1 to length(LIBS) do + if LIBS[i] = 0 then + crash("GTK Library %s not found!",{LIBS[i]}) + end if + end for + +constant cmd = command_line() -- used only to get program name + +if not gtk_func("gtk_init_check",{P,P},{0,0}) then -- initialize the GTK library; + crash("GTK Library error - cannot init GTK!") +else -- success! + gtk_proc("g_set_prgname",{S}," " & filename(cmd[2])) -- set default pgm name; + gtk_proc("g_type_init",{}) -- initialize normal GTK types; +end if + +public constant -- two special types must be initialized at run-time; ?? + gPIX = gtk_func("gdk_pixbuf_get_type"), + gCOMBO = gtk_func("gtk_combo_box_get_type") + +------------------------------------------------ +-- obtain a lot of sometimes useful system info; +------------------------------------------------ +include euphoria/info.e + +constant os_info = os:uname() + +export constant + major_version = gtk_func("gtk_get_major_version"), + minor_version = gtk_func("gtk_get_minor_version"), + micro_version = gtk_func("gtk_get_micro_version"), + user_name = gtk_str_func("g_get_user_name"), + real_name = gtk_str_func("g_get_real_name"), + host_name = gtk_str_func("g_get_host_name"), + home_dir = gtk_str_func("g_get_home_dir"), + temp_dir = gtk_str_func("g_get_tmp_dir"), + curr_dir = gtk_str_func("g_get_current_dir"), + data_dir = gtk_str_func("g_get_user_data_dir"), + conf_dir = gtk_str_func("g_get_user_config_dir"), + init_dir = init_curdir(), + runt_dir = gtk_str_func("g_get_user_runtime_dir"), + app_name = gtk_str_func("g_get_application_name"), + prg_name = gtk_str_func("g_get_prgname"), + os_pid = os:get_pid(), -- process id 1234 + os_name = os_info[1], -- e.g: Linux + os_distro = os_info[2], -- e.g: Mint17 + os_version = os_info[3], -- e.g: 3.13.0-24-generic + os_compiled = os_info[4] -- #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 + +ifdef UNIX then + export constant + host_addr = inet_address(), + os_architecture = os_info[5], -- e.g: x86_64 + os_shell = getenv("SHELL") -- e.g: /bin/bash +end ifdef + +ifdef WINDOWS then -- FIXME +export constant + host_addr = "localhost", + os_architecture = "unknown", + os_shell = "cmd.com" + end ifdef + +object os_term = getenv("TERM") + if atom(os_term) then os_term = "none" end if + +ifdef WINDOWS then os_term = "CMD.COM" end ifdef + +export constant info = { -- above system info in key/value form, sometimes more useful + "version=" & version, + "release=" & release, + "copyright=" & copyright, + "major=" & to_string(major_version), + "minor=" & to_string(minor_version), + "micro=" & to_string(micro_version), + "user_name=" & user_name, + "real_name=" & real_name, + "host_name=" & host_name, + "host_addr=" & host_addr, + "home_dir=" & home_dir, + "temp_dir=" & temp_dir, + "curr_dir=" & curr_dir, + "data_dir=" & data_dir, + "conf_dir=" & conf_dir, + "init_dir=" & init_dir, + "runt_dir=" & runt_dir, + "app_name=" & app_name, + "prg_name=" & prg_name, + "os_pid=" & to_string(os:get_pid()), + "os_name=" & os_info[1], + "os_distro=" & os_info[2], + "os_version=" & os_info[3], + "os_compiled=" & os_info[4], + "os_architecture=" & os_architecture, + "os_term=" & os_term, + "os_shell=" & os_shell, + "eu_version=" & version_string_short(), + "eu_revision=" & to_string(version_revision()), + "eu_date=" & version_date() + } + +ifdef WINDOWS then -- switch back from GTK3 dll folder + chdir(init_dir) +end ifdef + +enum NAME,PARAMS,RETVAL,VECTOR,CLASS +------------------------------------------------------------------------ +public function create(integer class, + object p1=0, object p2=0, object p3=0, object p4=0, + object p5=0, object p6=0, object p7=0, object p8=0) +------------------------------------------------------------------------ +-- This function does the following: +-- 1. initializes the class if not already initialized, +-- 2. creates a new instance of the class (returning a handle to that instance) +-- 3. links signals to your specified Eu function (for commonly-used widgets), +-- Widgets which have no default signal or which need to respond to a signal +-- other than the default must be linked manually, using connect(). +-- If no function is specified, no link will be created. +-- Immediately following the function identifier is an optional data item. +-- data item can contain anything - integer, atom, string, or mixed sequence. +------------------------------------------------------------------------------- + + if class = GtkStockList then -- GtkStock is not a real widget, + return newStockList() -- in addition, stock items are deprecated in 3.10+ + end if + + if not initialized[class] then -- create a routine_id for each 'method' in class + init(class) + end if + + object method = lookup("new",vslice(widget[class],1),widget[class],0) + if method[VECTOR] = -1 then -- if a 'new' method name not found, + puts(1,repeat('*',70)) + printf(1,"\nERROR 220: %s not implemented in this version of GTK!\n",widget[class]) + puts(1,repeat('*',70)) + puts(1,"\nPress any key ...") + wait_key() + abort(220) + end if + + object props = 0 + if sequence(p1) and sequence(p1[1]) then -- list of properties provided (new style) + props = p1 -- save until widget is created, then set them in one 'swell foop' + p1 = 0 + end if + + atom handle = 0 + object params = method[PARAMS] + object args = {p1,p2,p3,p4,p5,p6,p7,p8} + + args = args[1..length(params)] + + ifdef PARAMS then display(params) end ifdef -- debug + + for i = 1 to length(params) do + switch params[i] do + case S then -- convert string to pointer to cstring; + if string(args[i]) then + args[i] = allocate_string(args[i]) + end if + end switch + end for + + ifdef CREATE then -- debug + display(decode_method("Create",class,method)) + puts(1,"Args: ") display(args) + ifdef METHOD then display(method) end ifdef + end ifdef + + if method[RETVAL] > 0 then -- it's a GTK function (routine_id is positive) + handle = c_func(method[VECTOR],args) + end if + + if method[RETVAL] < -1 then -- it's a Eu func (a negated routine_id) + handle = call_func(-method[VECTOR],args) + end if + + if handle = 0 then + ifdef CREATE then + Warn(,,"Create failed for class",widget[class][$]) + crash("Create failed for class %s",{widget[class][$]}) + end ifdef + return handle + end if + + switch class do -- connect a default signal for some common controls; + case GtkButton then connect(handle,"clicked",p2,p3) + case GtkToolButton then connect(handle,"clicked",p3,p4) + case GtkRadioButton then connect(handle,"toggled",p3,p4) + case GtkRadioToolButton then connect(handle,"toggled",p3,p4) + case GtkRadioMenuItem then connect(handle,"toggled",p3,p4) + case GtkMenuItem then connect(handle,"activate",p2,p3) + case GtkCheckMenuItem then connect(handle,"toggled",p2,p3) + case GtkCellRendererToggle then connect(handle,"toggled",p1,p2) + case GtkFontButton then connect(handle,"font-set",p2,p3) + case GtkStatusIcon then connect(handle,"activate",p1,p2) + case GtkColorButton then connect(handle,"color-set",p2,p3) + case GtkCalendar then connect(handle,"day-selected-double-click",p2,p3) + case GtkComboBoxText, GtkComboBoxEntry then connect(handle,"changed",p1,p2) + case GtkCheckButton, GtkToggleButton, GtkToggleToolButton + then connect(handle,"toggled",p2,p3) + end switch + + ifdef CREATE then -- debug + display("\t[] => []\n",{widget[class][$],handle}) + end ifdef + + register(handle,class) + + if not atom(props) then -- set properties using new style; + for i = 1 to length(props) do + while length(props[i]) < 4 do props[i] &= 0 end while + set(handle,props[i][1],props[i][2],props[i][3],props[i][4]) + end for + end if + + return handle -- a pointer to the newly created instance + +end function /*create*/ + +------------------------------------------------------------------------ +public function set(object handle, sequence property, + object p1=0, object p2=0, object p3=0, object p4=0, + object p5=0, object p6=0, object p7=0, object p8=0) +------------------------------------------------------------------------ +-- This routine sets a property or sequence of properties +-- for the given widget handle. +-- In order to work with Glade, widget names in string form +-- may be used. +-- Property is always a string, p1...p8 are [optional] parameters. +-- Any parameter expected but not supplied is set to null, excess +-- parameters are discarded. +------------------------------------------------------------------------ +integer class=-1, x +object name + + name = handle + if string(handle) then handle = pointer(handle) end if + if handle = 0 then + crash("Fatal error 325 Can't obtain a handle for %s",{name}) + end if + + object prop = 0 + if sequence(property) -- new create format + and not string(property) then + for i = 1 to length(property) do + prop = property[i] + while length(prop) < 8 do prop &= 0 end while + set(handle,prop[1],prop[2],prop[3],prop[4],prop[5],prop[6],prop[7],prop[8]) + end for + return 0 + end if + + class = vlookup(handle,registry,1,2,-1) -- get widget's class; + + if class = -1 then + --display(registry) + display("Error 343 in set() - invalid handle [] []",{handle,prop}) + abort(1) + end if + + property = "set_" & lower(join(split(property,' '),'_')) -- conform; + ifdef SET then + display("Line 349 []->[]",{widget[class][$],property}) + end ifdef + + object method = lookup_method(class,property) + + ifdef METHOD then display(method) end ifdef + + if atom(method) then -- method not defined, try fallback to generic Object; + if not setProperty(handle,property[5..$],p1) then + ifdef SET then --debug + printf(1,"Caution: %s not found for class %d %s\n", + {property,class,classname(handle)}) + end ifdef + end if + return 0 + end if + + -- else, method was found; + + object params = method[PARAMS] + + switch method[1] do -- make life easier for a common operation; + case "set_from_file" then p1 = canonical_path(p1) + end switch + + object args = {handle,p1,p2,p3,p4,p5,p6,p7,p8} + + args = args[1..length(params)] -- match args to formal parameters; + for i = 2 to length(args) do + switch params[i] do + case A then -- array of strings; + if not atom(args[i]) then + args[i] = allocate_string_pointer_array(args[i]) + end if + case S then -- string; + if string(args[i]) then + args[i] = allocate_string(args[i]) + end if + case I,D then + if string(args[i]) then + args[i] = to_number(args[i]) + end if + -- apply patches for zero-based indexes; + switch method[1] do + case "add_attribute", + "set_active", + "set_text_column", + "set_pixbuf_column", + "set_tooltip_column", + "set_search_column", + "set_sort_column_id" then args[i]-=1 + end switch + end switch + end for + + ifdef SET then -- debug + display(decode_method("Set",class,method)) + puts(1,"\tArgs: ") display(decode_args(method,args), + {2,2,11,78,"%d","%2.22f",32,127,1,0}) + puts(1,"\n") + end ifdef + + if method[VECTOR] = -1 then -- GTK doesn't know about this method! + printf(1,` + Warning: %s->%s call is invalid, + ******** perhaps you need a later GTK version? + `,{widget[class][$],property}) + return 0 + end if + + if method[RETVAL] = 0 then -- it's a GTK proc + c_proc(method[VECTOR],args) + return 0 + end if + + if method[RETVAL] > 0 then -- it's a GTK func + return c_func(method[VECTOR],args) + end if + + if method[RETVAL] <-1 then -- it's a Eu func + return call_func(-method[VECTOR],args) + end if + + return 0 + +end function /*set*/ + +------------------------------------------------------------------------ +export function get(object handle, sequence property, + object p1=allocate(64), object p2=allocate(64), + object p3=allocate(64), object p4=allocate(64)) +------------------------------------------------------------------------ +-- This routine gets one or more values for a given property name. +-- Property name is always a string, handle is usually an atom, +-- but may sometimes be a string in order to work with Glade. +-- +-- parameters p1...p4 are normally not supplied when calling get() +-- but are there to store return values from the GTK function. +-- For example, get(win,"default size") will return with the +-- window width in p1, height in p2, which are converted by the get +-- function into a Euphoria tuple {w,h} before returning. +------------------------------------------------------------------------ +integer class, x +object name + + if string(handle) then handle = pointer(handle) end if + + class = vlookup(handle,registry,1,2,-1) -- get widget's class; + + if class = -1 then + crash("Error 459 - unregistered handle %d",handle) + end if + + property = "get_" & lower(join(split(property,' '),'_')) + + object method = lookup_method(class,property) + object result = 0 + + if atom(method) then -- not found, try fallback to Object; + result = getProperty(handle,property[5..$]) + return result + end if + + -- else, method found; + object params = method[PARAMS] + object args = {handle,p1,p2,p3,p4} + args = args[1..length(params)] + + ifdef GET then -- debug + display(decode_method("Get",class,method),0) + puts(1,"\tArgs: ") display(decode_args(method,args), + {2,2,11,78,"%d","%2.22f",32,127,4,-1}) + end ifdef + + if method[VECTOR] = -1 then + crash("\nERROR 478\n****** Invalid call: %s->%s",{widget[class][$],method[1]}) + end if + + for i = 2 to length(args) do -- convert args to pointers if necessary; + switch method[PARAMS][i] do + case S then + if string(args[i]) then args[i] = allocate_string(args[i]) end if + end switch + end for + + if method[RETVAL] = 0 then -- it's a GTK proc + c_proc(method[VECTOR],args) + + for i = 2 to length(method[PARAMS]) do -- convert returned values; + switch method[PARAMS][i] do + case D then args[i] = float64_to_atom(peek({args[i],8})) + case F then args[i] = float32_to_atom(peek({args[i],4})) + case S then if args[i] > 0 then args[i] = peek_string(args[i]) end if + case I then args[i] = peek4s(args[i]) + end switch + end for + result = args[2..$] + end if + + if method[RETVAL] > 0 then -- it's a GTK func + result = c_func(method[VECTOR],args) + switch method[RETVAL] do + case S then -- convert string pointer to string; + if result > 0 then + result = peek_string(result) + else + result = 0 + end if + case A then + result = to_sequence(result) + case I then + switch method[1] do -- patch for zero-based indexing + case "get_active", + "get_text_column", + "get_pixbuf_column", + "get_column", + "get_tooltip_column", + "get_search_column", + "get_sort_column_id" then result += 1 + end switch + end switch + end if + + if method[RETVAL] <-1 then -- it's a Eu func (negated routine_id) + result = call_func(-method[VECTOR],args) + end if + + if method[CLASS] != GSList then + if method[CLASS] != 0 then -- for widgets created 'internally' by GTK; + if not initialized[method[CLASS]] then init(method[CLASS]) end if + register(result,method[CLASS]) + end if + end if + + ifdef GET then -- debug + if string(result) then + display("\tReturns: '[]'",{result}) + else + display("\tReturns: []",{result}) + end if + end ifdef + + return result + +end function /*get*/ + +------------------------------------------------------------------------ +public function add(object parent, object child, object space = 0) +------------------------------------------------------------------------ +-- add a child widget or a {list} of child widgets to parent container +object name, class, handle + + if classid(child) = GdkPixbuf then -- issue a warning; + return Warn(,,"Cannot add a pixbuf to a container", + "Create an image from it first,\nthen add the image,\nor save it for later use!") + end if + + if classid(parent) = GtkBuilder then + load_builder(parent,child,space) + return 1 + end if + + if string(parent) then + parent = vlookup(parent,registry,4,1,-1) + end if + + if string(child) then + child = vlookup(child,registry,4,1,-1) + end if + + -- Switch below implements an easier-to-remember 'add' syntax + -- as an alias for the various calls shown. The GTK original is still available, + -- if you wish to use it. + + switch classid(parent) do + + case GtkComboBoxText, GtkComboBoxEntry then + for i = 1 to length(child) do + set(parent,"append text",child[i]) -- add is alias for "append text" + end for + + case GtkToolbar then + if atom(child) then + set(parent,"insert",child,-1) + else for i = 1 to length(child) do + add(parent,child[i]) + end for + end if + return child + + case GtkFileChooserDialog then + if atom(child) then + if classid(child) = GtkFileFilter then + set(parent,"add filter",child) + end if + else for i = 1 to length(child) do + add(parent,child[i]) + end for + end if + + case GtkSizeGroup then + set(parent,"add widgets",child) + return child + + case GtkTreeView then + set(parent,"append columns",child) + return child + + case GtkTreeViewColumn then + if child > 0 then + set(parent,"pack start",child) + else + set(parent,"pack end",-child) + end if + return child + + case else + + if atom(child) then + gtk_proc("gtk_container_add",{P,P},{parent,child}) + else + for i = 1 to length(child) do + gtk_proc("gtk_container_add",{P,P},{parent,child[i]}) + end for + + end if + + return child + + end switch +return -1 +end function /*add*/ + +------------------------------------------------------------------------ +public function pack(atom parent, object child, + integer expand=0, integer fill=0, integer padding=0) +------------------------------------------------------------------------ +-- pack a child widget or {list} of child widgets into parent container; +-- prepending a negative sign to the child pointer means +--'pack end'. this is an alias which is sometimes useful. +------------------------------------------------------------------------ + if atom(child) then + if child > 0 then + set(parent,"pack start",child,expand,fill,padding) + else + child = -child + set(parent,"pack end",child,expand,fill,padding) + end if + else + for i = 1 to length(child) do + pack(parent,child[i],expand,fill,padding) + end for + end if + return child +end function + +-- following 2 calls are supplied for completeness; +public function pack_start(atom parent, object child, -- original GTK call + boolean expand=0, boolean fill=0, integer padding=0) +return pack(parent,child,expand,fill,padding) +end function + +public function pack_end(atom parent, object child, -- orignal GTK call + boolean expand=0, boolean fill=0, integer padding=0) +return pack(parent,-child,expand,fill,padding) +end function + +------------------------------------------------------------------------ +public procedure show(object x) +------------------------------------------------------------------------ + if atom(x) then -- show widget x or a {list} of widgets + set(x,"show") + else + for i = 1 to length(x) do + show(x[i]) + end for + end if +end procedure + +------------------------------------------------------------------------ +public procedure show_all(object x) +------------------------------------------------------------------------ + if atom(x) then + set(x,"show all") -- show container x and all children + else + for i = 1 to length(x) do + set(x[i],"show all") + end for + end if +end procedure + +------------------------------------------------------------------------ +public procedure hide(object x) +------------------------------------------------------------------------ + if atom(x) then -- hide a widget or a {list} of widgets; + set(x,"hide") + else + for i = 1 to length(x) do + hide(x[i]) + end for + end if +end procedure + +------------------------------------------------------------------------ +public procedure hide_all(object x) +------------------------------------------------------------------------ + set(x,"hide all") -- hide container x and any children it contains +end procedure + +------------------------------------------------------------------------ +public function Destroy(object ctl, object data) +------------------------------------------------------------------------ +-- destroy a widget or {list} of widgets; +if atom(data) then + gtk_proc("gtk_widget_destroy",{P},{data}) +else + for i = 1 to length(data) do + Destroy(0,data[i]) + end for +end if +return 1 +end function +export constant destroy = call_back(routine_id("Destroy")) + +------------------------------------------------------------------------ +export procedure main() +------------------------------------------------------------------------ + gtk_proc("gtk_main") -- start the GTK engine; +end procedure + +--------------------------------------------------------------------------------- +export function events_pending() -- used sometimes when using timeout or eu tasks +--------------------------------------------------------------------------------- + return gtk_func("gtk_events_pending") +end function + +------------------------------------------------------------------------ +export procedure main_iteration() +------------------------------------------------------------------------ + gtk_proc("gtk_main_iteration") +end procedure + +----------------------------------------------------------------------------------- +export procedure main_iteration_do(integer i) -- used sometimes when multi-tasking; +----------------------------------------------------------------------------------- + gtk_proc("gtk_main_iteration_do",{I},i) +end procedure + +without warning {not_reached} + ------------------------------------------------------------------------ + export function Quit(atom ctl=0, object errcode=0) + ------------------------------------------------------------------------ + abort(errcode) -- kill the GTK engine; + return 0 + end function + export constant main_quit = call_back(routine_id("Quit")) + + global function gtk_main_quit() + abort(0) + return 0 + end function +with warning {not_reached} + +------------------------------------------------------------------------ +-- Following are 4 pre-built, easy to use popup dialogs +-- which save you the trouble of writing tons of code! +-- Refer to documentation/dialogs.html for details. +-- Rewritten for 4.8.8 to preserve images on dialog buttons despite +-- GTK developers' bland, boring preferences :P +-- Beginning with EuGTK 4.9.3, dialogs can be non-modal if desired. +------------------------------------------------------------------------ + +public function Info(object parent=0, object title="Info", + object pri_txt="", object sec_txt="", + object btns=GTK_BUTTONS_OK, + object image="dialog-information", + object icon="dialog-information", + integer modal=1) + return Dialog(parent,title,pri_txt,sec_txt,btns,image,icon,modal) +end function + +public function Warn(object parent=0, object title="Warning", + object pri_txt="", object sec_txt="", + object btns=GTK_BUTTONS_CLOSE, + object image="dialog-warning", + object icon="dialog-warning", + integer modal=1) + return Dialog(parent,title,pri_txt,sec_txt,btns,image,icon,modal) +end function + +public function Error(object parent=0, object title="Error", + object pri_txt="", object sec_txt="", + object btns=GTK_BUTTONS_OK_CANCEL, + object image="dialog-error", + object icon="dialog-error", + integer modal=1) + return Dialog(parent,title,pri_txt,sec_txt,btns,image,icon,modal) +end function + +public function Question(object parent=0, object title="Question", + object pri_txt="", object sec_txt="", + object btns=GTK_BUTTONS_YES_NO, + object image="dialog-question", + object icon="dialog-question", + integer modal=1) + return Dialog(parent,title,pri_txt,sec_txt,btns,image,icon,modal) +end function + +public function Dialog(object parent=0, object title="dialog", + object pri_txt="", object sec_txt="", + object btns=GTK_BUTTONS_OK, + object image=0, + object icon=0, + integer modal=1) + if modal = -1 then + return NonModalDialog(parent,title,pri_txt,sec_txt,btns,image,icon) + end if + + atom dlg = create(GtkDialog) + + if string(parent) then + parent = get(builder,"object",parent) + end if + + set(dlg,{ + {"transient for",parent}, + {"title",title}, + {"border width",10}, + {"position",GTK_WIN_POS_MOUSE}}) + + if atom(icon) and icon = 0 and parent > 0 then + icon = get(parent,"icon name") + end if + + if atom(icon) and icon > 0 then + set(dlg,"icon",icon) + end if + + if string(icon) then + set(dlg,"icon",icon) + end if + + object ca = get(dlg,"content area") + object panel = create(GtkBox,HORIZONTAL,10) + add(ca,panel) + object left = create(GtkBox,VERTICAL,5) + object right = create(GtkBox,VERTICAL,5) + add(panel,{left,right}) + + if string(image) then + add(left,create(GtkImage,image)) + elsif image > 0 then + if classid(image) = GdkPixbuf then + image = create(GtkImage,image) + end if + add(left,image) + end if + + if atom(modal) and modal > 1 then + atom addon = create(GtkButtonBox,HORIZONTAL) + add(ca,addon) + add(addon,modal) + show_all(addon) + end if + + object lbl1 = create(GtkLabel) + set(lbl1,"markup",text:format("[]\n[]",{pri_txt,sec_txt})) + set(lbl1,"halign",0) + + add(right,lbl1) + + show_all(panel) + + object btn = repeat(0,2) + + switch btns do + case GTK_BUTTONS_NONE then skip() -- do nothing + + case GTK_BUTTONS_OK then + btn[1] = create(GtkButton,"gtk-ok#_OK") + set(dlg,"add action widget",btn[1],MB_OK) + show(btn[1]) + + case GTK_BUTTONS_OK_CANCEL then + btn[1] = create(GtkButton,"gtk-cancel#_Cancel") + btn[2] = create(GtkButton,"gtk-ok#_OK") + set(dlg,"add action widget",btn[1],MB_CANCEL) + set(dlg,"add action widget",btn[2],MB_OK) + show(btn[1]) + show(btn[2]) + + case GTK_BUTTONS_CLOSE then + btn[1] = create(GtkButton,"gtk-close#_Close") + set(btn[1],"can default",TRUE) + set(dlg,"add action widget",btn[1],MB_CLOSE) + show(btn[1]) + + case GTK_BUTTONS_YES_NO then + btn[1] = create(GtkButton,"gtk-no#_No") + btn[2] = create(GtkButton,"gtk-yes#_Yes") + set(dlg,"add action widget",btn[1],MB_NO) + set(dlg,"add action widget",btn[2],MB_YES) + show(btn[1]) + show(btn[2]) + + case else btn[1] = create(GtkButton,"gtk-ok#_OK") + set(btn[1],"can default",TRUE) + show(btn[1]) + set(dlg,"add action widget",btn[1],MB_OK) + + end switch + + atom result = get(dlg,"run") set(dlg,"destroy") + + return result +end function + +global integer dialog_return_value = 0 + +function close_dialog(object ctl, object dlg) + dlg = unpack(dlg) + dialog_return_value = dlg[2] + set(dlg[1],"destroy") +return 1 +end function + +-------------------------------------------------------------------------------------------- +export function NonModalDialog(object parent=0, object title="?", + object pri_txt="", object sec_txt="", + object btns=0, + object image="dialog-info", + object icon="dialog-info", + object modal=0) +------------------------------------------------------------------------------------------- +atom dlg = create(GtkWindow) + + integer closedlg = call_back(routine_id("close_dialog")) + + set(dlg,"title",title) + set(dlg,"border width",10) + set(dlg,"position",GTK_WIN_POS_MOUSE) + + if atom(icon) and icon = 0 and parent > 0 then + icon = get(parent,"icon name") + end if + + if atom(icon) and icon > 0 then + set(dlg,"icon",icon) + end if + + if string(icon) then + set(dlg,"icon",icon) + end if + + object panel = create(GtkBox,VERTICAL) + add(dlg,panel) + + object ca = create(GtkBox,HORIZONTAL,10) + add(panel,ca) + + object left = create(GtkBox,VERTICAL,5) + object right = create(GtkBox,VERTICAL,5) + add(ca,{left,right}) + + if atom(modal) and modal > 1 then + if classid(modal) != GtkButtonBox then + atom addon = create(GtkButtonBox,HORIZONTAL) + pack(panel,addon) + add(addon,modal) + else + pack(panel,modal) + end if + end if + + object btnbox = create(GtkButtonBox) + pack(panel,-btnbox) + + if sequence(btns) and not atom(btns[1]) then + for i = 1 to length(btns) do + while length(btns[i]) < 3 do btns[i] &= 0 end while + if atom(btns[i][2]) and btns[i][2] = 0 then btns[i][2] = closedlg end if + if atom(btns[i][3]) and btns[i][3] = 0 then btns[i][3] = {dlg,MB_CANCEL} end if + btns[i] = create(GtkButton,btns[i][1],btns[i][2],btns[i][3]) + end for + add(btnbox,btns) + end if + + label "images" + if string(image) then + add(left,create(GtkImage,image)) + elsif image > 0 then + if classid(image) = GdkPixbuf then + image = create(GtkImage,image) + end if + add(left,image) + end if + + object lbl1 = create(GtkLabel) + set(lbl1,"markup",text:format("[]\n[]",{pri_txt,sec_txt})) + set(lbl1,"halign",0) + + add(right,lbl1) + + show_all(dlg) + +return 0 +end function + +------------------------------------------------------------------------ +-- Following functions register and initialize class methods +------------------------------------------------------------------------ +-- A class is initialized the first time a widget of that class is created. +-- This means the widget's method vectors are filled in with Eu routine_ids +-- generated by define_c_func or eu_define_c_proc as appropriate. + +-- When a subsequent call is made to a widget method, that vector is +-- used by calling c_func, c_proc, or call_func. + +-- If the call is to a method not implemented by the widget, but is +-- instead a method inherited from one of the widget's ancestors, +-- then the ancestor is initialized (if necessary). + +-- This scheme means that program startup isn't delayed as it would be +-- if all widgets and methods were to be initialized first, most of which +-- would likely not be used in any given program. + +------------------------------------------------------------------------ +global procedure init(integer class) +------------------------------------------------------------------------ +object name, params, retval + + ifdef INIT then + display("\nInit class:[] []",{class,widget[class][$]}) + display(widget[class]) + end ifdef + + if initialized[class] then return end if + + for method = 3 to length(widget[class])-1 do + + name = sprintf("%s_%s",{widget[class][NAME],widget[class][method][NAME]}) + widget[class][method] = pad_tail(widget[class][method],5,0) + params = widget[class][method][PARAMS] + retval = widget[class][method][RETVAL] + + for i = 1 to length(params) do + switch params[i] do + case A then params[i] = P + case D then + if equal("get_range",widget[class][method][NAME]) then + params[i] = P + end if + case F then + if class = GtkAspectFrame then -- do nothing + else switch widget[class][method][NAME] do + case "add_mark","set_fraction","set_alignment" then + skip() -- do nothing + case else params[i] = P + end switch + end if + case else -- do nothing + end switch + end for + + if widget[class][method][RETVAL] = 0 then -- it's a GTK proc + widget[class][method][VECTOR] = define_proc(name,params) + goto "init" + end if + + if widget[class][method][RETVAL] > 0 then -- it's a GTK func + widget[class][method][VECTOR] = define_func(name,params,retval) + goto "init" + end if + + if widget[class][method][RETVAL] < -1 then -- it's a Eu func + widget[class][method][VECTOR] = widget[class][method][RETVAL] + end if + + label "init" + + initialized[class] = TRUE + + ifdef INIT then + display("\tCLASS:[] METHOD:[] RID:[]", + {widget[class][$],widget[class][method][NAME],widget[class][method][VECTOR]}) + end ifdef + + ifdef INIT_ERR then + if widget[class][method][VECTOR] = -1 then -- function invalid! + display("\tINIT ERROR: CLASS:[] METHOD: [] ERR:[]", + {widget[class][$],widget[class][method][NAME],widget[class][method][VECTOR]}) + end if + end ifdef + + end for + +end procedure /*init*/ + +procedure skip() +end procedure + +export object registry = {} +------------------------------------------------------------------------ +-- The registry associates a control's handle with its class, +-- so that future calls to set or get that control's properties +-- can go directly to the correct set of functions stored in the +-- widget{} structure. +--------------------------------------------------------------------------------------------- +global function register(atom handle, integer class, object name="-nil-", object v=math:MINF) +--------------------------------------------------------------------------------------------- +integer x = find(handle,vslice(registry,1)) + + if x > 0 then -- handle already exists, + -- update it in case handle has been recycled. + ifdef REG_DUP then + display("Note: [] [] handle [] [] already registered to []", + {name,widget[class][$],handle,registry[x][3]}) + end ifdef + registry[x] = {handle,class,widget[class][$],name,v} + return 1 + end if + + -- else, add the widget to the registry; + registry = append(registry,{handle,class,widget[class][$],name,v}) + + -- initialize class if this is the first use of that class; + if not initialized[class] then init(class) end if + + ifdef REG then + printf(1,text:format("Registry + [3:20]\thandle: [1:10>]\tname: [4] [5]\n",registry[$])) + end ifdef + +return 1 +end function /*register*/ + +--------------------------------------- +procedure deregister(atom handle) +--------------------------------------- +integer x = find(handle,vslice(registry,1)) +if x > 0 then + ifdef REG then + printf(1,text:format("Registry - [3:16]\thandle: [1:12>]\t",registry[x])) + if string(registry[x][4]) then printf(1,"name: %s",{registry[x][4]}) end if + puts(1,"\n") + end ifdef + registry = remove(registry,x) +end if +end procedure + +-- Returns an integer corresponding with a enumerated widget class; +------------------------------------------------------------------------ +public function classid(object handle) +------------------------------------------------------------------------ + return vlookup(handle,registry,1,2,-1) +end function + +-- returns classname as a string (e.g. "GtkWindow") for a given handle; +------------------------------------------------------------------------ +public function classname(atom handle) +------------------------------------------------------------------------ + return vlookup(handle,registry,1,3,"?") +end function + +-- returns name of object from registry +------------------------------------------------------------------------ +public function objectname(atom handle) +------------------------------------------------------------------------ + return vlookup(handle,registry,1,4,"?") +end function + +-- returns handle (pointer) to object given name or namespace:name: +------------------------------------------------------------------------ +public function pointer(object name) +------------------------------------------------------------------------ +return vlookup(name,registry,4,1,0) +end function + +------------------------------------------------------------------------ +function lookup_method(integer class, sequence prop) +------------------------------------------------------------------------ +-- Finds the method to set or get a property for a given class, +-- if not found, ancestors of that class are checked until the method +-- is located. + + if class = -1 then return 0 end if + + ifdef LOOK then display("Look []->[]",{widget[class][$],prop}) end ifdef + object method = lookup(prop,vslice(widget[class],NAME),widget[class],0) + ifdef LOOKUP then display(widget[class][$]) end ifdef + + if atom(method) then -- try sans the set_ or get_ prefix; + method = lookup(prop[5..$],vslice(widget[class],NAME),widget[class],0) + end if + + if sequence(method) then -- method found in this class; + return method + end if + + object ancestor -- if not found, need to look for method in ancestors; + for i = 1 to length(widget[class][PARAMS]) do + ancestor = widget[class][PARAMS][i] + if ancestor = 0 then return 0 end if + + if not initialized[ancestor] then + init(ancestor) + end if + + ifdef LOOKUP then + display("trying ancestor: []",{widget[ancestor][$]}) + end ifdef + + method = lookup(prop,vslice(widget[ancestor],NAME),widget[ancestor],0) + if atom(method) then + method = lookup(prop[5..$],vslice(widget[ancestor],NAME),widget[ancestor],0) + end if + + if sequence(method) then + ifdef LOOKUP then display("\t []",{method[1]}) end ifdef + return method + end if + + end for + + return -1 +end function /*lookup*/ + +----------------------------------------------------------------------------- +public function connect(object ctl, object sig, object fn=0, object data=0, + atom closure=0, integer flags=0) +----------------------------------------------------------------------------- +-- tells control to call fn, sending data along for the ride, +-- whenever that control gets the signal 'sig' + + if string(ctl) then ctl = pointer(ctl) end if -- convert name to pointer + + if atom(fn) and fn = 0 then -- no point in calling null functions! + return 0 + end if + + if string(fn) then -- if interpreted, can call functions by name if in scope. + + ifdef COMPILE then -- do compile test if requested; + display("Connecting [] Signal '[]' Data []",{classname(ctl),sig,data}) + if not equal("Quit",fn) then + printf(1,"\n\tCaution: function %s will not link when compiled!\n\t********\n",{fn}) + end if + end ifdef + + atom rid = routine_id(fn) + if rid > 0 then -- named func is in scope; + fn = call_back(rid) -- so obtain a callback; + else + printf(1,"\n\tError: function %s is not in scope\n\t****** (make it global or link via routine_id)\n",{fn}) + end if + + end if + + sig = allocate_string(sig) + + if integer(data) then -- can be attached directly; + return gtk_func("g_signal_connect_data",{P,S,P,P,I,I},{ctl,sig,fn,data,closure,flags}) + end if + + if atom(data) then + data = prepend({data},"ATOM") -- must be serialized and unpacked later; + data = allocate_wstring(serialize(data)+1) + return gtk_func("g_signal_connect_data",{P,S,P,P,I,I},{ctl,sig,fn,data,closure,flags}) + end if + + if string(data) then + data = prepend({data},"STR") -- must be serialized and unpacked later; + data = allocate_wstring(serialize(data)+1) + return gtk_func("g_signal_connect_data",{P,S,P,P,I,I},{ctl,sig,fn,data,closure,flags}) + end if + + if sequence(data) then + data = prepend(data,"SEQ")-- must be serialized and unpacked later; + data = allocate_wstring(serialize(data)+1) + return gtk_func("g_signal_connect_data",{P,S,P,P,I,I},{ctl,sig,fn,data,closure,flags}) + end if + +end function /*connect*/ + +------------------------------------------------------------------------ +export procedure disconnect(atom ctl, integer sigid) +------------------------------------------------------------------------ +-- disconnect a signal from ctl; + gtk_proc("g_signal_handler_disconnect",{P,I},{ctl,sigid}) +end procedure + +------------------------------------------------------------------------ +export function unpack(object data) +------------------------------------------------------------------------ +-- retrieves data passed in a control's data space; + if atom(data) and data = 0 then return 0 end if + object result = deserialize(peek_wstring(data)-1) + switch result[1][1] do + case "ATOM","STR","INT" then return result[1][2] + case "SEQ" then return result[1][2..$] + case else return result + end switch +end function + +------------------------------------------------------------------------ +-- following 3 'decode' functions are for debugging purposes; +-- they make displays more readable +------------------------------------------------------------------------ +function decode_args(object method, object args) +------------------------------------------------------------------------ +for i = 1 to length(method[PARAMS]) do + switch method[PARAMS][i] do + case S then + if atom(args[i]) and args[i] > 0 then + args[i] = peek_string(args[i]) + if length(args[i]) > 40 then + args[i] = args[i][1..40] & "..." + end if + args[i] = args[i] + end if + case else -- do not convert + end switch +end for +return args +end function + +constant ptype = {0,P,I,D,F,S,B,A} +constant pname = {{},"None","Ptr ","Int ","Dbl ","Flt ","Str ","Bool ","Array "} +------------------------------------------------------------------------ +function decode_params(object params) +------------------------------------------------------------------------ +return transmute(params,ptype,pname) +end function + +------------------------------------------------------------------------ +function decode_method(sequence title, integer class, object method) +------------------------------------------------------------------------ +object z = {} +integer n + z = prepend(method,widget[class][$]) + z = prepend(z,title) + z[4] = decode_params(method[PARAMS]) + while length(z) < 5 do + z = append(z,0) + end while + if length(method) >= RETVAL then + n = find(method[RETVAL],ptype) + z[5] = pname[n+1] + end if +return text:format("\n[]\n\tCall: []->[]\n\tParams: []\n\tReturn type: []\n\tVector: []",z) +end function + +---------------------------------------------------------------- +export function valid_icon(object list) +---------------------------------------------------------------- +-- check a list of possible icon names, +-- return an image made from first one that is valid +object result = 0 +for i = 1 to length(list) do + result = get_icon_image(list[i]) + if result > 0 then return result end if +end for +return result +end function + +--------------------------------------------------------------- +export function valid_icon_name(object list) +--------------------------------------------------------------- +-- check a list of possible icon names, return name of first valid +for i = 1 to length(list) do + --display("Checking []",{list[i]}) + if valid_icon({list[i]}) > 0 then + return list[i] + end if +end for +return "gtk-missing-image" +end function + +------------------------------------------------------------------------ +function get_icon_image(object icon, integer size=6) +------------------------------------------------------------------------ +-- get image from a variety of sources; +atom img = 0, ani = 0, default_theme + + if string(icon) then + if find(icon,stock_list) then + img = gtk_func("gtk_image_new_from_stock",{P,I}, + {allocate_string(icon),size}) + return img + end if + end if + + if to_number(icon) > 0 then + icon = gtk_func("gdk_pixbuf_scale_simple",{P,I,I,I},{to_number(icon),30,30,GDK_INTERP_BILINEAR}) + img = create(GtkImage) + set(img,"from pixbuf",icon) + return img + end if + + img = 0 + default_theme = gtk_func("gtk_icon_theme_get_default",{}) + if gtk_func("gtk_icon_theme_has_icon",{P,P}, + {default_theme,allocate_string(icon)}) then + img = gtk_func("gtk_image_new_from_icon_name",{P,P}, + {allocate_string(icon),size}) + return img + end if + + img = 0 + icon = canonical_path(icon) + if file_exists(icon) then -- image from file + size *= 6 + img = create(GtkImage) + ani = create(GdkPixbufAnimation,icon) + if gtk_func("gdk_pixbuf_animation_is_static_image",{P},{ani}) then + ani = create(GdkPixbuf,icon,size,size) + set(img,"from pixbuf",ani) + else + set(img,"from animation",ani) + end if + return img + end if + +return -1 +end function + +------------------------------------------------------------------------ +public function to_sequence(atom glist, integer fmt=0) -- mostly internal +------------------------------------------------------------------------ +-- convert glist pointer back to a Euphoria sequence; +-- results are returned in a choice of formats; + integer len = gtk_func("g_list_length",{P},{glist}) + object s = {} + atom data + for i = 0 to len-1 do + data = gtk_func("g_slist_nth_data",{P,I},{glist,i}) + switch fmt do + case 0 then s = append(s,peek_string(data)) + ifdef TOSEQ then display(s) end ifdef + case 1 then s = append(s,data) + case 2 then s = append(s,gtk_str_func("gtk_tree_path_to_string",{P},{data})) + case 3 then s = append(s,to_number(gtk_str_func("gtk_tree_path_to_string",{P},{data}))) + case else Warn(,,"Converting glist to_sequence", + "invalid format supplied,\nvalues are 0 to 3") + end switch + end for +return s +end function + +------------------------------------------------------------------------ +-- Color handling routines - most are used internally +------------------------------------------------------------------------ + +---------------------------------------- +export function to_rgba(object color) +---------------------------------------- +-- converts a color description to rgba ptr; + atom rgba = allocate(32) + object c = color + if string(c) then c = allocate_string(c) end if + if gtk_func("gdk_rgba_parse",{P,P},{rgba,c}) then + return rgba + else + printf(1,"Error: invalid color '%s'\n******",{color}) + end if +return rgba +end function + +---------------------------------------------------- +export function from_rgba(object rgba, object fmt=0) +---------------------------------------------------- +-- converts rgba ptr to usable description; +object result = gtk_str_func("gdk_rgba_to_string",{P},{rgba}) + if fmt=0 then return result + else return fmt_color(result,fmt) + end if +end function + + +------------------------------------------------------------------------ +function fmt_color(object s, integer fmt=0) +------------------------------------------------------------------------ +-- Convert color to various usable formats - this can be used by the +-- programmer, refer to ~/demos/documentation/HowItWorks.html#colors + if atom(s) then + if string(peek_string(s)) then + s = peek_string(s) + end if + end if +object w + w = split_any(s,"(,)") + if length(w[1]) = 3 then + w[5] = "1" + end if + for i = 2 to 5 do + w[i] = to_number(w[i]) + end for + if atom(w[5]) then + w[5] = round(w[5],100) + end if + switch fmt do + case 0 then return w[1..length(w[1])+1] + case 1 then return sprintf("#%02x%02x%02x",w[2..4]) + case 2 then return (256*256*w[2])+(256*w[3])+ w[4] + case 3 then return {w[2],w[3],w[4]} + case 4 then return {w[2],w[3],w[4],w[5]} + case 5 then return {w[2],w[3],w[4],256*w[5]} + case 6 then return sprintf("rgba(%d,%d,%d,%2.2f)",w[2..$]) + case 7 then return {w[2]/255,w[3]/255,w[4]/255,w[5]} + case 8 then return sprintf("r=#%x, g=#%x, b=#%x, alpha=#%x",w[2..5]) + case else -- do nothing + end switch +return s +end function + +------------------------------------------------------------------------ +-- METHOD DECLARATIONS: +------------------------------------------------------------------------ + +sequence initialized = repeat(0,1000) +-- This is a set of flags which are set to 1 when a given widget has +-- been initialized. This prevents having to initialize a widget's +-- methods repeatedly. + +export sequence widget = repeat(0,GtkFinal) +-- This structure holds prototypes for each GTK method call, +-- organized by widget. When each widget is initialized, +-- vectors are added pointing to the routine_ids needed +-- to call the GTK functions that implement each method. + +-- The list below need not be in any specific order. +-- Widget names must also be added to the list in GtkEnums +------------------------------------------------------------------------ +sequence stock_list = create(GtkStockList) + +widget[GObject] = {"g_object", +{0}, -- {list of ancestors} + {"new",{I,S,S,I},P}, -- method,{formal params},return type + {"set",{P,S,P,P}}, + {"set_property",{P,S,P},-routine_id("setProperty")}, + {"get_property",{P,S},-routine_id("getProperty")}, + {"get_data",{P,S},S}, + {"set_data",{P,S,S}}, + {"set_data_full",{P,S,S,P}}, + {"steal_data",{P,S},P}, +"GObject"} -- human-readable name + + constant + fn1 = define_proc("g_object_get",{P,S,P,P}), + doubles = {"angle","climb-rate","fraction","max-value","min-value", + "scale","value","pulse-step","scale","size-points","text-xalign", + "text-yalign","xalign","yalign"} + + function setProperty(object handle, object a, object b) + -------------------------------------------------------------- + ifdef OBJ then + display("Handle []",handle) + display("Prop []",{a}) + display("Value []",b) + end ifdef + if find(a,doubles) then + if string(a) then a = allocate_string(a) end if + if string(b) then b = allocate_string(b) end if + gtk_proc("g_object_set",{P,P,D,P},{handle,a,b,0}) + else + if string(a) then a = allocate_string(a) end if + if string(b) then b = allocate_string(b) end if + gtk_proc("g_object_set",{P,P,P,P},{handle,a,b,0}) + end if + return 1 + end function + + function getProperty(atom handle, object p) + -------------------------------------------------- + atom x = allocate(32) + if string(p) then p = allocate_string(p) end if + c_proc(fn1,{handle,p,x,0}) + object result = peek4u(x) + free(x) + return result + end function + +widget[GtkAdjustment] = {"gtk_adjustment", +{GObject}, + {"new",{D,D,D,D,D,D},P}, + {"set_value",{P,D}}, + {"get_value",{P},D}, + {"clamp_page",{P,D,D}}, + {"value_changed",{P}}, + {"configure",{P,D,D,D,D,D,D}}, + {"get_lower",{P},D}, + {"get_page_increment",{P},D}, + {"get_step_increment",{P},D}, + {"get_minimum_increment",{P},D}, + {"set_upper",{P,D}}, + {"get_upper",{P},D}, + {"set_page_increment",{P,D}}, + {"set_page_size",{P,D}}, + {"set_step_increment",{P,D}}, + {"set_upper",{P,D}}, +"GtkAdjustment"} + +widget[GtkWidgetPath] = {"gtk_widget_path", +{GObject}, + {"new",{},P}, + {"append_type",{P,I},I}, + {"append_with_siblings",{P,P,I},I}, + {"append_for_widget",{P,P},I}, + {"copy",{P},P,0,GtkWidgetPath}, + {"get_object_type",{P},I}, + {"has_parent",{P,I},B}, + {"is_type",{P,I},B}, + {"iter_add_class",{P,I,S}}, + {"iter_add_region",{P,I,S,I}}, + {"iter_clear_classes",{P,I}}, + {"iter_clear_regions",{P,I}}, + {"iter_get_name",{P,I},S}, + {"iter_get_object_type",{P,I},I}, + {"iter_get_siblings",{P,I},P,0,GtkWidgetPath}, + {"iter_get_sibling_index",{P,I},I}, + {"iter_has_class",{P,I,S},B}, + {"iter_has_name",{P,I,S},B}, + {"iter_has_qclass",{P,I,P},B}, + {"iter_has_qname",{P,I,P},B}, + {"iter_has_qregion",{P,I,P,I},B}, + {"iter_has_region",{P,I,S,I},B}, + {"iter_list_classes",{P,I},P,0,GSList}, + {"iter_list_regions",{P,I},P,0,GSList}, + {"iter_remove_class",{P,I,S}}, + {"iter_remove_region",{P,I,S}}, + {"iter_set_name",{P,I,S}}, + {"iter_set_object_type",{P,I,I}}, + {"iter_get_state",{P,I},I}, -- GTK3.14 + {"iter_set_state",{P,I,I}}, -- GTK3.14 + {"length",{P},I}, + {"prepend_type",{P,I}}, + {"to_string",{P},S}, +"GtkWidgetPath"} + +widget[GtkWidget] = {"gtk_widget", +{GtkBuildable,GObject}, +-- aliases to fix awkward overrides; ordinarily you will use one of these 4; + {"set_font",{P,S},-routine_id("setFont")}, + {"set_color",{P,P},-routine_id("setFg")}, + {"set_foreground",{P,P},-routine_id("setFg")}, + {"set_background",{P,P},-routine_id("setBg")}, +-- only use following 2 versions when you need to change the color +-- of a control in a state other than normal; + {"override_background_color",{P,I,P},-routine_id("overrideBg")}, + {"override_color",{P,I,P},-routine_id("overrideFg")}, + {"new",{I},P}, + {"destroy",{P}}, + {"in_destruction",{P},B}, + {"destroyed",{P},B}, + {"unparent",{P}}, + {"show",{P}}, + {"show_now",{P}}, + {"hide",{P}}, + {"show_all",{P}}, + {"map",{P}}, + {"unmap",{P}}, + {"realize",{P}}, + {"unrealize",{P}}, + {"draw",{P}}, + {"queue_draw",{P}}, + {"queue_resize",{P}}, + {"queue_resize_no_redraw",{P}}, + {"get_frame_clock",{P},P,0,GdkFrameClock}, + {"add_tick_callback",{P,P,P,P},I}, + {"remove_tick_callback",{P,I}}, -- GTK 3.8+ + {"set_size_request",{P,I,I}}, + {"size_allocate",{P,P}}, + {"size_allocate_with_baseline",{P,P,I}}, + {"add_accelerator",{P,S,P,I,I}}, + {"remove_accelerator",{P,P,I,I},B}, + {"set_accel_path",{P,S,P}}, + {"can_activate_accel",{P,I},B}, + {"event",{P,P},B}, + {"activate",{P},B}, + {"reparent",{P,P}}, -- deprecated 3.14 + {"intersect",{P,P,P},B}, + {"is_focus",{P},B}, + {"grab_focus",{P},B}, + {"grab_default",{P}}, + {"set_name",{P,S},-routine_id("widget_set_name")}, + {"get_name",{P},S}, + {"set_sensitive",{P,B}}, + {"get_sensitive",{P},B}, + {"set_parent",{P,P}}, + {"get_parent",{P},P}, + {"set_parent_window",{P,P}}, + {"get_parent_window",{P},P}, + {"set_events",{P,I}}, + {"get_events",{P},I}, + {"add_events",{P,I}}, + {"set_device_events",{P,P,I}}, + {"get_device_events",{P,P,I},I}, + {"add_device_events",{P,P,I}}, + {"set_device_enabled",{P,P,B}}, + {"get_device_enabled",{P,P},B}, + {"get_toplevel",{P},P}, + {"get_ancestor",{P,I},P}, + {"is_ancestor",{P,P},B}, + {"set_visual",{P,P}}, + {"get_visual",{P},P,0,GdkVisual}, + {"get_pointer",{P,I,I}}, -- deprecated 3.4 + {"translate_coordinates",{P,P,I,I,I,I},B}, + {"hide_on_delete",{P},B}, + {"set_direction",{P,I}}, + {"get_direction",{P},I}, + {"set_default_direction",{I}}, + {"get_default_direction",{},I}, + {"shape_combine_region",{P,P}}, + {"create_pango_context",{P},P}, + {"get_pango_context",{P},P,0,PangoContext}, + {"create_pango_layout",{P,S},P}, + {"queue_draw_area",{P,I,I,I,I}}, + {"queue_draw_region",{P,P}}, + {"set_app_paintable",{P,B}}, + {"set_double_buffered",{P,B}}, -- deprecated 3.14 + {"set_redraw_on_allocate",{P,B}}, + {"mnemonic_activate",{P,B},B}, + {"send_expose",{P,P},I}, + {"send_focus_change",{P,P},B}, + {"get_accessible",{P},P}, + {"child_focus",{P,I},B}, + {"child_notify",{P,S}}, + {"freeze_child_notify",{P}}, + {"get_child_visible",{P},B}, + {"get_parent",{P},P}, + {"get_path",{P},P,0,GtkWidgetPath}, + {"get_settings",{P},P,0,GtkSettings}, + {"get_clipboard",{P,I},P,0,GtkClipboard}, + {"get_display",{P},P,0,GdkDisplay}, + {"get_root_window",{P},P,0,GdkWindow}, -- deprecated 3.12 + {"get_screen",{P},P,0,GdkScreen}, + {"has_screen",{P},B}, + {"get_size_request",{P,I,I}}, + {"set_child_visible",{P,B}}, + {"thaw_child_notify",{P}}, + {"set_no_show_all",{P,B}}, + {"get_no_show_all",{P},B}, + {"add_mnemonic_label",{P,P}}, + {"remove_mnemonic_label",{P,P}}, + {"is_compositied",{P},B}, + {"set_tooltip_markup",{P,S}}, + {"get_tooltip_markup",{P},S}, + {"set_tooltip_text",{P,S}}, + {"get_tooltip_text",{P},S}, + {"set_tooltip_window",{P,P}}, + {"get_tooltip_window",{P},P,0,GtkWindow}, + {"set_has_tooltip",{P,B}}, + {"get_has_tooltip",{P},B}, + {"trigger_tooltip_query",{P}}, + {"get_window",{P},P,0,GdkWindow}, + {"register_window",{P,P}}, -- GTK 3.8+ + {"unregister_window",{P,P}}, -- GTK 3.8+ + {"get_allocated_width",{P},I}, + {"get_allocated_height",{P},I}, + {"get_allocation",{P},-routine_id("getWidgetAllocation")}, + {"set_allocation",{P,P}}, + {"get_allocated_baseline",{P},I}, + {"get_app_paintable",{P},B}, + {"set_can_default",{P,B}}, + {"get_can_default",{P},B}, + {"get_can_focus",{P},B}, + {"get_double_buffered",{P},B}, -- deprecated 3.14 + {"get_has_window",{P},B}, + {"get_sensitive",{P},B}, + {"get_visible",{P},B}, + {"is_visible",{P},B}, -- GTK 3.8+ + {"set_visible",{P,B}}, + {"set_state_flags",{P,I,B}}, + {"unset_state_flags",{P,I}}, + {"get_state_flags",{P},I}, + {"has_default",{P},B}, + {"has_focus",{P},B}, + {"has_visible_focus",{P},B}, + {"has_grab",{P},B}, + {"is_drawable",{P},B}, + {"is_toplevel",{P},B}, + {"set_window",{P,P}}, + {"set_receives_default",{P,B}}, + {"get_receives_default",{P},B}, + {"set_support_multidevice",{P,B}}, + {"get_support_multidevice",{P},B}, + {"set_realized",{P,B}}, + {"get_realized",{P},B}, + {"set_mapped",{P,B}}, + {"get_mapped",{P},B}, + {"device_is_shadowed",{P,P},B}, + {"get_modifier_mask",{P,I},I}, + {"insert_action_group",{P,S,P}}, + {"get_opacity",{P},D}, -- GTK 3.8+ + {"set_opacity",{P,D}}, -- GTK 3.8+ + {"get_path",{P},P,0,GtkWidgetPath}, + {"get_style_context",{P},P,0,GtkStyleContext}, + {"reset_style",{P}}, + {"get_preferred_height",{P,I,I}}, + {"get_preferred_width",{P,I,I}}, + {"get_preferred_height_for_width",{P,I,I,I}}, + {"get_preferred_width_for_height",{P,I,I,I}}, + {"get_preferred_height_and_baseline_for_width",{P,I,I,I,I,I}}, + {"get_request_mode",{P},I}, + {"get_preferred_size",{P,P,P}}, + {"get_preferred_size_and_baseline",{P,P,I,I}}, + {"get_halign",{P},I}, + {"set_halign",{P,I}}, + {"get_valign",{P},I}, + {"set_valign",{P,I}}, + {"set_margin_left",{P,I}}, -- deprecated 3.12 + {"get_margin_left",{P},I}, -- deprecated 3.12 + {"set_margin_right",{P,I}}, -- deprecated 3.12 + {"get_margin_right",{P},I}, -- deprecated 3.12 + {"get_margin_end",{P},I}, -- new 3.12 + {"set_margin_end",{P,I}}, -- new 3.12 + {"get_margin_start",{P},I}, -- new 3.12 + {"set_margin_start",{P,I}}, -- new 3.12 + {"set_margin_top",{P,I}}, + {"get_margin_top",{P},I}, + {"set_margin_bottom",{P,I}}, + {"get_margin_bottom",{P},I}, + {"get_hexpand",{P},B}, + {"set_hexpand",{P,B}}, + {"get_hexpand_set",{P},B}, + {"set_hexpand_set",{P,B}}, + {"get_vexpand",{P},B}, + {"set_vexpand",{P,B}}, + {"get_vexpand_set",{P},B}, + {"set_vexpand_set",{P,B}}, + {"queue_compute_expand",{P}}, + {"compute_expand",{P,I},B}, + {"init_template",{P}}, + {"get_automated_child",{P,I,S},P,0,GObject}, + {"get_clip",{P,P}}, -- 3.14 + {"set_clip",{P},P}, -- 3.14 + {"get_action_group",{P,S},P,0,GActionGroup}, -- 3.16 + {"list_action_prefixes",{P},A}, -- 3.16 + {"signal",{P,P,P,P,P,P},-routine_id("connect")}, +"GtkWidget"} + + function getWidgetAllocation(atom obj) + atom al = allocate(4*4) + gtk_func("gtk_widget_get_allocation",{P,P},{obj,al}) + integer x,y,w,h + {x,y,w,h} = peek4u({al,4}) + free(al) + return {x,y,w,h} + end function + + function widget_set_name(atom ctl, object name) + gtk_proc("gtk_widget_set_name",{P,P},{ctl,name}) + integer x = find(ctl,vslice(registry,1)) + if x > 0 then + registry[x][4] = peek_string(name) + end if + return 1 + end function + + -- This allows specifying a font name, e.g. "Courier bold 12", instead of + -- as a pango font description object; + function setFont(atom x, object fnt) + ------------------------------------ + fnt = gtk_func("pango_font_description_from_string",{P},{fnt}) + gtk_proc("gtk_widget_override_font",{P,P},{x,fnt}) + return 1 + end function + +-- The functions below handle color conversion to/from rgba, +-- as well as supplying easier-to-use method names for setting background +-- and foreground. These methods are only used to set the colors of a widget +-- in the NORMAL state, whereas if you want to set the colors in +-- some other state, such as mouse-over, etc, you use the original +-- set(widget,"override background",STATE,"color") syntax. + + function setFg(atom x, object c) + -------------------------------- + return overrideFg(x,0,c) + end function + + function setBg(atom x, object c) + -------------------------------- + return overrideBg(x,0,c) + end function + + function overrideFg(atom x, integer state=0, object c) + ------------------------------------------------------ + if atom(c) then + c = text:format("#[:06X]",c) + end if + gtk_proc("gtk_widget_override_color",{P,I,P},{x,state,to_rgba(c)}) + return 1 + end function + + function overrideBg(atom x, integer state=0, object c) + ------------------------------------------------------ + if atom(c) then + c = text:format("#[:06X]",c) + end if + gtk_proc("gtk_widget_override_background_color",{P,I,P},{x,state,to_rgba(c)}) + return 1 + end function + +widget[GtkAccessible] = {"gtk_accessible", +{GObject}, + {"set_widget",{P,P}}, + {"get_widget",{P},P,0,GtkWidget}, +"GtkAccessible"} + +widget[GtkActivatable] = {"gtk_activatable", +{GObject}, +"GtkActivatable"} + +widget[GActionGroup] = {"g_action_group", +{0}, +"GActionGroup"} + +widget[GtkContainer] = {"gtk_container", +{GtkWidget,GtkBuildable,GObject}, + {"add",{P,P}}, + {"remove",{P,P}}, + {"check_resize",{P}}, + {"foreach",{P,P,P}}, + {"get_children",{P},P,0,GList}, + {"get_path_for_child",{P,P},P}, + {"set_focus_child",{P,P}}, + {"get_focus_child",{P},P}, + {"set_focus_vadjustment",{P,P}}, + {"get_focus_vadjustment",{P},P,0,GtkAdjustment}, + {"set_focus_hadjustment",{P,P}}, + {"get_focus_hadjustment",{P},P,0,GtkAdjustment}, + {"child_type",{P},I}, + {"forall",{P,P,P}}, + {"set_border_width",{P,I}}, + {"get_border_width",{P},I}, +"GtkContainer"} + +widget[GdkKeymap] = {"gdk_keymap", +{GObject}, + {"new",{},-routine_id("newKeymap")}, + {"get_default",{},-routine_id("newKeymap")}, + {"get_for_display",{P},P,0,GdkKeymap}, + {"get_capslock_state",{P},B}, + {"get_numlock_state",{P},B}, + {"get_modifier_state",{P},I}, + {"get_direction",{P},I}, + {"have_bidi_layouts",{P},B}, + {"lookup_key",{P,P},I}, +"GdkKeymap"} + + function newKeymap(atom disp=0) + if disp=0 then + return gtk_func("gdk_keymap_get_default") + else + return gtk_func("gdk_keymap_get_for_display",{P},P) + end if + end function + +widget[GdkKeyval] = {"gdk_keyval", +{GdkKeymap,GObject}, + {"name",{I},S}, + {"from_name",{S},I}, + {"to_unicode",{I},I}, +"GdkKeyval"} + +widget[GtkBin] = {"gtk_bin", +{GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"get_child",{P},P}, +"GtkBin"} + +widget[GtkModelButton] = {"gtk_model_button", -- new in 3.16 +{GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GtkActivatable,GObject}, + {"new",{},P}, +"GtkModelButton"} + +widget[GtkButton] = {"gtk_button", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GtkActivatable,GObject}, + {"new",{P},-routine_id("newBtn")}, + {"set_relief",{P,I}}, + {"get_relief",{P},I}, + {"set_label",{P,S}}, + {"get_label",{P},S}, + {"set_use_underline",{P,B}}, + {"get_use_underline",{P},B}, + {"set_focus_on_click",{P,B}}, + {"get_focus_on_click",{P},B}, + {"set_alignment",{P,F,F}}, -- Deprecated 3.14 + {"get_alignment",{P,F,F}}, -- Deprecated 3.15 + {"set_image",{P,P}}, + {"get_image",{P},P,0,GtkImage}, + {"set_image_position",{P,I}}, + {"get_image_position",{P},I}, + {"set_always_show_image",{P,B}}, -- GTK 3.6+ + {"get_always_show_image",{P},B}, -- GTK 3.6+ + {"get_event_window",{P},P,0,GdkWindow}, +"GtkButton"} + + function newBtn(object cap = 0) + --------------------------------------------------------------- + -- handles creation of buttons with icons from various sources; + -- this function modified greatly from earlier versions + --------------------------------------------------------------- + atom btn + object tmp, icon, title + atom child + + if atom(cap) and cap = 0 then + return gtk_func("gtk_button_new",{}) + end if + + if string(cap) then + + if match("#",cap) > 0 then + tmp = split(cap,'#') + icon = get_icon_image(tmp[1],GTK_ICON_SIZE_BUTTON) + title = tmp[2] + btn = gtk_func("gtk_button_new_with_mnemonic",{P},{title}) + register(btn,GtkButton) + if icon > 0 then + set(btn,"image",icon) + set(btn,"always show image",TRUE) + end if + return btn + end if + + if match("gtk-",cap) then + btn = gtk_func("gtk_button_new_with_mnemonic",{P}, + {allocate_string('_'&proper(cap[5..$]))}) + register(btn,GtkButton) + icon = get_icon_image(cap,GTK_ICON_SIZE_BUTTON) + if icon > 0 then set(btn,"image",icon) end if + set(btn,"always show image",TRUE) + return btn + end if + + btn = gtk_func("gtk_button_new_with_mnemonic",{P},{allocate_string(cap)}) + register(btn,GtkButton) + return btn + + else + + btn = gtk_func("gtk_button_new") + register(btn,GtkButton) + return btn + + end if + + return btn + end function + +widget[GtkBox] = {"gtk_box", +{GtkContainer,GtkWidget,GtkOrientable,GtkBuildable,GObject}, + {"new",{I,I},P}, + {"pack_start",{P,P,B,B,I}}, + {"pack_end",{P,P,B,B,I}}, + {"set_homogeneous",{P,B}}, + {"get_homogeneous",{P},B}, + {"set_spacing",{P,I}}, + {"get_spacing",{P},I}, + {"reorder_child",{P,P,I}}, + {"query_child_packing",{P,P,B,B,I,I}}, + {"set_child_packing",{P,P,B,B,I,I}}, + {"set_baseline_position",{P,I}}, + {"get_baseline_position",{P},I}, + {"get_center_widget",{P},P,0,GtkWidget}, -- GTK 3.12.1 + {"set_center_widget",{P,P}}, -- GTK 3.12.1 +"GtkBox"} + +widget[GtkButtonBox] = {"gtk_button_box", +{GtkBox,GtkContainer,GtkWidget,GtkBuilder,GtkOrientable,GObject}, + {"new",{I},P}, + {"set_layout",{P,I}}, + {"get_layout",{P},I}, + {"set_child_secondary",{P,P,B}}, + {"get_child_secondary",{P,P},B}, + {"set_child_non_homogeneous",{P,P,B}}, + {"get_child_non_homogeneous",{P,P},P}, +"GtkButtonBox"} + +widget[GtkWindowGroup] = {"gtk_window_group", +{GObject}, + {"new",{},P}, + {"add_window",{P,P}}, + {"remove_window",{P,P}}, + {"list_windows",{P},P,0,GList}, + {"get_current_grab",{P},P,0,GtkWidget}, + {"get_current_grab_device",{P,P},P,0,GtkWidget}, +"GtkWindowGroup"} + +widget[GtkWindow] = {"gtk_window", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{I},P}, + {"set_title",{P,S}}, + {"get_title",{P},S}, + {"set_resizable",{P,B}}, + {"get_resizable",{P},B}, + {"get_size",{P,I,I}}, + {"set_default",{P,P}}, + {"set_default_size",{P,I,I}}, + {"get_default_size",{P,I,I}}, + {"set_position",{P,I}}, + {"get_position",{P,I,I}}, + {"add_accel_group",{P,P}}, + {"remove_accel_group",{P,P}}, + {"activate_focus",{P},B}, + {"activate_default",{P},B}, + {"set_modal",{P,B}}, + {"get_modal",{P},B}, + {"set_default_geometry",{P,I,I}}, + {"set_geometry_hints",{P,P,P,I}}, + {"set_gravity",{P,I}}, + {"get_gravity",{P},I}, + {"set_transient_for",{P,P}}, + {"get_transient_for",{P},P,0,GtkWindow}, + {"set_attached_to",{P,P}}, + {"get_attached_to",{P},P,0,GtkWidget}, + {"set_destroy_with_parent",{P,B}}, + {"get_destroy_with_parent",{P},B}, + {"set_hide_titlebar_when_maximized",{P,B}}, + {"get_hide_titlebar_when_maximized",{P},B}, + {"set_screen",{P,P}}, + {"get_screen",{P},P,0,GdkScreen}, + {"is_active",{P},B}, + {"list_toplevels",{P},P,0,GSList}, + {"has_toplevel_focus",{P},B}, + {"add_mnemonic",{P,I,P}}, + {"remove_mnemonic",{P,I,P}}, + {"set_mnemonics_visible",{P,B}}, + {"get_mnemonics_visible",{P},B}, + {"mnemonic_activate",{P,I,I},B}, + {"activate_key",{P,P},B}, + {"propagate_key_event",{P,P},B}, + {"get_focus",{P},P,0,GtkWidget}, + {"set_focus",{P,P}}, + {"set_focus_visible",{P,B}}, + {"get_focus_visible",{P},B}, + {"get_default_widget",{P},P,0,GtkWidget}, + {"set_default",{P,P}}, + {"present",{P}}, + {"present_with_time",{P,P}}, + {"iconify",{P}}, + {"deiconify",{P}}, + {"stick",{P}}, + {"unstick",{P}}, + {"maximize",{P}}, + {"unmaximize",{P}}, + {"fullscreen",{P}}, + {"unfullscreen",{P}}, + {"set_keep_above",{P,B}}, + {"set_keep_below",{P,B}}, + {"begin_resize_drag",{P,I,I,I,I,I}}, + {"begin_move_drag",{P,I,I,I,I}}, + {"set_decorated",{P,B}}, + {"get_decorated",{P},B}, + {"set_deletable",{P,B}}, + {"get_deletable",{P},B}, + {"set_mnemonic_modifier",{P,I}}, + {"get_mnemonic_modifier",{P},I}, + {"set_type_hint",{P,I}}, + {"get_type_hint",{P},I}, + {"set_skip_taskbar_hint",{P,B}}, + {"get_skip_taskbar_hint",{P},B}, + {"set_skip_pager_hint",{P,B}}, + {"get_skip_pager_hint",{P},B}, + {"set_urgency_hint",{P,B}}, + {"get_urgency_hint",{P},B}, + {"set_accept_focus",{P,B}}, + {"get_accept_focus",{P},B}, + {"set_focus_on_map",{P,B}}, + {"get_focus_on_map",{P},B}, + {"set_startup_id",{P,S}}, + {"set_role",{P,S}}, + {"get_role",{P},S}, + {"get_icon",{P},P,0,GdkPixbuf}, + {"get_icon_name",{P},S}, + {"get_icon_list",{P},P,0,GList}, + {"get_default_icon_list",{P},P,0,GList}, + {"get_group",{P},P,0,GtkWindowGroup}, + {"has_group",{P},B}, + {"get_window_type",{P},I}, + {"move",{P,I,I}}, + {"parse_geometry",{P,S},B}, + {"resize",{P,I,I}}, + {"resize_to_geometry",{P,I,I}}, + {"set_has_resize_grip",{P,B}}, + {"get_has_resize_grip",{P},B}, + {"resize_grip_is_visible",{P},B}, -- Deprecated 3.14 + {"get_resize_grip_area",{P,P},B}, -- Deprecated 3.14 + {"set_titlebar",{P,P}}, -- 3.10 + {"get_titlebar",{P},P}, -- 3.16 + {"set_icon",{P,P},-routine_id("setWinIcon")}, + {"restore",{P},-routine_id("restoreWin")}, + {"close",{P}}, -- 3.10 + {"set_opacity",{P,D}}, + {"is_maximized",{P},B}, -- 3.12 + {"set_interactive_debugging",{B}}, -- 3.14 + {"get_application",{P},P,0,GtkApplication}, +"GtkWindow"} + + -- this replaces a handy but deprecated GTK function which + -- restores a window to its original size after being resized + -- to fit larger contents; + function restoreWin(atom win) + ----------------------------- + + set(win,"hide") + set(win,"unrealize") + set(win,"show") + return 1 + end function + + -- manages the creation of window icon from a variety of + -- source formats; makes life simpler for the programmer. + function setWinIcon(object win, object icon) + -------------------------------------------- + object path + + if string(icon) then + path = canonical_path(icon) + if file_exists(path) then + gtk_proc("gtk_window_set_icon_from_file",{P,P}, + {win,allocate_string(path)}) + return 1 + else + gtk_proc("gtk_window_set_icon_name",{P,P}, + {win,allocate_string(icon)}) + return 1 + end if + end if + + if atom(icon) then + if classid(icon) = GtkImage then + icon = get(icon,"pixbuf") + end if + if classid(icon) = GdkPixbuf then + gtk_proc("gtk_window_set_icon",{P,P},{win,icon}) + end if + return 1 + end if + + return 0 + end function + +widget[GtkMisc] = {"gtk_misc", -- deprecated 3.14 +{GtkWidget,GtkBuildable,GObject}, + {"set_alignment",{P,F,F}}, + {"get_alignment",{P,F,F}}, + {"set_padding",{P,I,I}}, + {"get_padding",{P,I,I}}, +"GtkMisc"} + +widget[GtkLabel] = {"gtk_label", +{GtkMisc,GtkWidget,GtkBuildable,GObject}, + {"new",{S},P}, + {"new_with_mnemonic",{S},P}, + {"set_text",{P,S}}, + {"get_text",{P},S}, + {"set_markup",{P,S}}, + {"set_text_with_mnemonic",{P,S}}, + {"set_markup_with_mnemonic",{P,S}}, + {"set_pattern",{P,S}}, + {"set_justify",{P,I}}, + {"get_justify",{P},I}, + {"set_ellipsize",{P,I}}, + {"get_ellipsize",{P},I}, + {"set_width_chars",{P,I}}, + {"get_width_chars",{P},I}, + {"set_max_width_chars",{P,I}}, + {"get_max_width_chars",{P},I}, + {"set_line_wrap",{P,B}}, + {"get_line_wrap",{P},B}, + {"set_line_wrap_mode",{P,I}}, + {"get_layout_offsets",{P,I,I}}, + {"get_mnemonic_keyval",{P},I}, + {"set_selectable",{P,B}}, + {"get_selectable",{P},B}, + {"select_region",{P,I,I}}, + {"get_selection_bounds",{P,I,I},B}, + {"set_mnemonic_widget",{P,P}}, + {"get_mnemonic_widget",{P},P,0,GtkWidget}, + {"get_label",{P},S}, + {"get_layout",{P},P,0,PangoLayout}, + {"get_line_wrap_mode",{P},I}, + {"set_use_markup",{P,B}}, + {"get_use_markup",{P},B}, + {"set_use_underline",{P,B}}, + {"get_use_underline",{P},B}, + {"set_single_line_mode",{P,B}}, + {"get_single_line_mode",{P},B}, + {"set_angle",{P,D}}, + {"get_current_uri",{P},S}, + {"set_track_visited_links",{P,B}}, + {"get_track_visited_links",{P},B}, + {"set_lines",{P,I}}, -- 3.10 + {"get_lines",{P},I}, -- 3.10 + {"get_xalign",{P},F}, -- 3.16 + {"get_yalign",{P},F}, -- 3.16 + {"set_xalign",{P,F}}, -- 3.16 + {"set_yalign",{P,F}}, -- 3.16 +"GtkLabel"} + +widget[GtkImage] = {"gtk_image", +{GtkMisc,GtkWidget,GtkBuildable,GObject}, + {"new",{P,I,I,I},-routine_id("newImage")}, + {"set_from_file",{P,S}}, + {"set_from_pixbuf",{P,P}}, + {"set_from_icon_name",{P,S,I}}, + {"set_from_animation",{P,P}}, + {"set_from_gicon",{P,P,I}}, + {"set_from_resource",{P,S}}, + {"set_from_surface",{P,P}}, -- 3.10 + {"clear",{P}}, + {"set_pixel_size",{P,I}}, + {"get_pixel_size",{P},I}, + {"get_pixbuf",{P},P,0,GdkPixbuf}, + {"get_animation",{P},P,0,GdkPixbufAnimation}, + {"get_storage_type",{P},I}, + {"get_icon_name",{P},-routine_id("getIconName")}, + {"get_icon_size",{P},-routine_id("getIconSize")}, +"GtkImage"} + + -- create an image from a variety of source formats + function newImage(object icon=0, integer size=6, integer h, integer w) + ------------------------------------------------------------- + atom img = 0 + IconTheme theme = create(GtkIconTheme) + atom err = allocate(32) + err = 0 + + if atom(icon) and icon = 0 then -- blank image + return gtk_func("gtk_image_new") + end if + + if size = 0 then size = 6 end if + if size > 6 then -- load icon from theme, sized + img = gtk_func("gtk_icon_theme_load_icon",{P,S,I,I,P}, + {theme,icon,size,GTK_ICON_LOOKUP_USE_BUILTIN,err}) + return gtk_func("gtk_image_new_from_pixbuf",{P},{img}) + end if + + if string(icon) then + if begins("gtk-",icon) then -- from stock (deprecated) + return gtk_func("gtk_image_new_from_icon_name",{P,I}, + {allocate_string(icon),size}) + end if + + if file_exists(canonical_path(icon)) then -- from file + if size+h+w < 7 then + return gtk_func("gtk_image_new_from_file",{P}, + {allocate_string(canonical_path(icon))}) + else + img = newPixbuf(icon,size,h,w) + return gtk_func("gtk_image_new_from_pixbuf",{P},{img}) + end if + end if + + + return gtk_func("gtk_image_new_from_icon_name",{P,I},{icon,size}) + + end if + + switch classid(icon) do + case GdkPixbuf then + img = gtk_func("gtk_image_new_from_pixbuf",{P},{icon}) + case GIcon then + img = gtk_func("gtk_image_new_from_gicon",{P,I},{icon,size}) + case CairoSurface_t then + img = gtk_func("gtk_image_new_from_surface",{P},{icon}) + case else -- no conversion needed + end switch + + return img + end function + + + constant fnImageInfo = define_proc("gtk_image_get_icon_name",{P,P,P}) + + function getIconName(atom img) + ------------------------------ + atom name = allocate(32), size = allocate(32) + c_proc(fnImageInfo,{img,name,size}) + name = peek4u(name) + if name > 0 then + return peek_string(name) + else return "?" + end if + end function + + function getIconSize(atom img) + ------------------------------ + atom name = allocate(32), size = allocate(32) + c_proc(fnImageInfo,{img,name,size}) + return peek4u(size) + end function + +widget[GdkCursor] = {"gdk_cursor", +{GObject}, + {"new",{P,P,I,I},-routine_id("newCur")}, + {"get_display",{P},P,0,GdkDisplay}, + {"get_image",{P},P,0,GdkPixbuf}, + {"get_surface",{P,D,D},P,0,CairoSurface_t}, + {"get_cursor_type",{P},I}, +"GdkCursor"} + + -- manages cursor creation from a variety of sources + function newCur(object a, object b=0, integer c=0, integer d=0) + --------------------------------------------------------------- + if string(b) then + return gtk_func("gdk_cursor_new_from_name",{P,S}, + {a,allocate_string(b)}) + end if + if classid(b) = GdkPixbuf then + return gtk_func("gdk_cursor_new_from_pixbuf",{P,P,I,I},{a,b,c,d}) + end if + if classid(b) = CairoSurface_t then + return gtk_func("gdk_cursor_new_from_surface",{P,P,D,D},{a,b,c,d}) + end if + if classid(a) = GdkDisplay then + return gtk_func("gdk_cursor_new_for_display",{P,I},{a,b}) + end if + return gtk_func("gdk_cursor_new",{I},{a}) + end function + +widget[GdkWindow] = {"gdk_window", +{GObject}, + {"new",{P,P,P},P}, + {"set_title",{P,S}}, + {"destroy",{P}}, + {"get_window_type",{P},I}, + {"get_display",{P},P,0,GdkDisplay}, + {"get_screen",{P},P,0,GdkScreen}, + {"get_visual",{P},P,0,GdkVisual}, + {"show",{P}}, + {"show_unraised",{P}}, + {"hide",{P}}, + {"is_destroyed",{P},B}, + {"is_visible",{P},B}, + {"is_viewable",{P},B}, + {"is_input_only",{P},B}, + {"is_shaped",{P},B}, + {"set_composited",{P,B}}, -- deprecated 3.16 + {"get_composited",{P},B}, -- deprecated 3.16 + {"set_opacity",{P,D}}, + {"set_cursor",{P,P}}, + {"get_cursor",{P},P}, + {"get_state",{P},I}, + {"scroll",{P,I,I}}, + {"move_region",{P,P,I,I}}, + {"shape_combine_region",{P,P,I,I}}, + {"set_child_shapes",{P}}, + {"merge_child_shapes",{P}}, + {"input_shape_combine_region",{P,P,I,I}}, + {"get_geometry",{P,I,I,I,I}}, + {"set_background_rgba",{P,P}}, + {"set_fullscreen_mode",{P,I}}, + {"get_fullscreen_mode",{P},I}, + {"get_scale_factor",{P},I}, + {"set_opaque_region",{P,P}}, + {"get_effective_parent",{P},P,0,GdkWindow}, + {"get_effective_toplevel",{P},P,0,GdkWindow}, + {"beep",{}}, + {"focus",{P,I}}, + {"restack",{P,P,B}}, + {"raise",{P}}, + {"lower",{P}}, + {"set_keep_above",{P,B}}, + {"set_keep_below",{P,B}}, + {"reparent",{P,P,I,I}}, + {"ensure_native",{P},B}, + {"has_native",{P},B}, + {"register_dnd",{P}}, + {"move",{P,I,I}}, + {"scroll",{P,I,I}}, + {"resize",{P,I,I}}, + {"move_resize",{P,I,I,I,I}}, + {"move_region",{P,P,I,I}}, + {"begin_resize_drag",{P,I,I,I,I,I}}, + {"begin_resize_drag_for_device",{P,I,P,I,I,I,I}}, + {"begin_move_drag",{P,I,I,I,I}}, + {"begin_move_drag_for_device",{P,P,I,I,I,I}}, + {"show_window_menu",{P,P},B}, + {"create_gl_context",{P,I,P},P,0,GdkGLContext}, -- 3.16 + {"mark_paint_from_clip",{P,P}}, -- 3.16 + {"get_clip_region",{P},P,0,CairoRegion_t}, + {"begin_paint_rect",{P,P}}, + {"begin_paint_region",{P,P}}, + {"end_paint",{P}}, + {"get_visible_region",{P},P,0,CairoRegion_t}, + {"set_invalidate_handler",{P,I}}, + {"invalidate_rect",{P,P,B}}, + {"invalidate_region",{P,P,B}}, + {"invalidate_maybe_recurse",{P,P,I,P}}, + {"get_update_area",{P},P,0,CairoRegion_t}, + {"freeze_updates",{P}}, + {"thaw_updates",{P}}, + {"process_all_updates",{P}}, + {"process_updates",{P,B}}, + {"get_frame_clock",{P},P,0,GdkFrameClock}, +"GdkWindow"} + +widget[GdkPixbuf] = {"gdk_pixbuf", +{GObject}, + {"new",{P,I,I,I},-routine_id("newPixbuf")}, + {"get_from_window",{P,I,I,I,I},P,0,GdkPixbuf}, + {"get_from_surface",{P,I,I,I,I},P,0,GdkPixbuf}, + {"flip",{P,I},P,0,GdkPixbuf}, + {"rotate_simple",{P,I},P,0,GdkPixbuf}, + {"scale_simple",{P,I,I,I},P,0,GdkPixbuf}, + {"add_alpha",{P,B,I,I,I},P,0,GdkPixbuf}, + {"copy_area",{P,I,I,I,I,P,I,I}}, + {"apply_embedded_orientation",{P},P,0,GdkPixbuf}, + {"fill",{P,P}}, + {"get_n_channels",{P},I}, + {"get_has_alpha",{P},B}, + {"get_colorspace",{P},I}, + {"get_bits_per_sample",{P},I}, + {"get_pixels_with_length",{P,I},P}, + {"get_width",{P},I}, + {"get_height",{P},I}, + {"get_size",{P},-routine_id("getPixbufSize")}, + {"get_rowstride",{P},I}, + {"get_byte_length",{P},I}, + {"get_option",{P,S},S}, + {"saturate_and_pixelate",{P,P,F,B},0,GdkPixbuf}, + {"composite_color_simple",{P,I,I,I,I,I,P,P},P,0,GdkPixbuf}, + {"save",{P,P,P,P},-routine_id("savePixbuf")}, +"GdkPixbuf"} + + -- creates a pixbuf from a variety of sources + function newPixbuf(object name, integer w=0, integer h=0, atom ratio=0) + -------------------------------------------------------------------------- + atom err = allocate(32) err = 0 + atom fn, fx + object path, pix + + if string(name) then + path = canonical_path(name) + if file_exists(path) then + path = allocate_string(path) + goto "build" + end if + + if has_icon(name) then + path = icon_info(name) + path = allocate_string(path[3]) + goto "build" + else return 0 + end if + end if -- string name; + + label "build" + + if h = 0 and w = 0 then -- return at original size; + return gtk_func("gdk_pixbuf_new_from_file",{P,P},{path,err}) + + else -- if one or other dimension given, scale it, otherwise size it; + if w > 0 and h = 0 then h = -1 end if + if w = 0 and h > 0 then w = -1 end if + return gtk_func("gdk_pixbuf_new_from_file_at_scale",{P,I,I,B,P}, + {path,w,h,ratio,err}) + end if + + return 0 + end function + + -- save a pixbuf in various formats based on file extension(.png, .jpg, etc) + function savePixbuf(atom handle, object fn, object ft, object params = 0) + ------------------------------------------------------------------------- + fn = allocate_string(fn) + ft = allocate_string(ft) + if string(params) then + params = split(params,'=') + for i = 1 to length(params) do + params[i] = allocate_string(params[i]) + end for + end if + + atom err = allocate(16) err = 0 + if atom(params) then + return gtk_func("gdk_pixbuf_save",{P,P,P,P,P},{handle,fn,ft,err,0}) + else + return gtk_func("gdk_pixbuf_save",{P,P,P,P,P,P,P},{handle,fn,ft,err,params[1],params[2],0}) + end if + end function + + function getPixbufSize(object pb) + --------------------------------------- + return {get(pb,"width"),get(pb,"height")} + end function + +widget[GtkDialog] = {"gtk_dialog", +{GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"run",{P},I}, + {"response",{P,I}}, + {"add_button",{P,S,I},P,0,GtkWidget}, + {"get_action_area",{P},P,0,GtkBox}, -- Deprecated 3.12 + {"add_action_widget",{P,P,I}}, + {"get_content_area",{P},P,0,GtkBox}, + {"set_default_response",{P,I}}, + {"set_response_sensitive",{P,I,B}}, + {"get_response_for_widget",{P,P},I}, + {"get_widget_for_response",{P,I},P,0,GtkWidget}, + {"get_header_bar",{P},P,0,GtkWidget},-- GTK 3.12 +"GtkDialog"} + +widget[GtkMessageDialog] = {"gtk_message_dialog", +{GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{P,I,I,I,S,S},P}, + {"new_with_markup",{P,I,I,I,S,S},P}, + {"set_markup",{P,S}}, + {"set_image",{P,P}}, -- Deprecated 3.12 + {"get_image",{P},P,0,GtkImage}, -- Deprecated 3.12 + {"format_secondary_text",{P,S,S}}, + {"format_secondary_markup",{P,S,S}}, + {"get_message_area",{P},P,0,GtkWidget}, +"GtkMessageDialog"} + +widget[GtkSeparator] = {"gtk_separator", +{GtkWidget,GObject,GtkBuildable,GtkOrientable}, + {"new",{I},P}, +"GtkSeparator"} + +widget[GtkEditable] = {"gtk_editable", +{0}, + {"select_region",{P,I,I}}, + {"get_selection_bounds",{P,I,I}}, + {"insert_text",{P,S,I,I}}, + {"delete_text",{P,I,I}}, + {"get_chars",{P,I,I},S}, + {"cut_clipboard",{P}}, + {"copy_clipboard",{P}}, + {"paste_clipboard",{P}}, + {"delete_selection",{P}}, + {"set_position",{P,I}}, + {"get_position",{P},I}, + {"set_editable",{P,B}}, + {"get_editable",{P},B}, +"GtkEditable"} + +widget[GtkEntry] = {"gtk_entry", +{GtkWidget,GtkEditable,GtkCellEditable,GtkBuildable,GObject}, + {"new",{},P}, + {"get_buffer",{P},P,0,GtkEntryBuffer}, + {"set_buffer",{P,P}}, + {"set_text",{P,S}}, + {"get_text",{P},S}, + {"get_text_length",{P},I}, + {"get_text_area",{P,P}}, + {"set_visibility",{P,B}}, + {"get_visibility",{P},B}, + {"set_invisible_char",{P,I}}, + {"get_invisible_char",{P},I}, + {"unset_invisible_char",{P}}, + {"set_max_length",{P,I}}, + {"get_max_length",{P},I}, + {"set_activates_default",{P,B}}, + {"get_activates_default",{P},B}, + {"set_has_frame",{P,B}}, + {"get_has_frame",{P},B}, + {"set_width_chars",{P,I}}, + {"get_width_chars",{P},I}, + {"set_alignment",{P,F}}, + {"get_alignment",{P},F}, + {"set_placeholder_text",{P,S}}, -- GTK 3.2+ + {"get_placeholder_text",{P},S}, -- GTK 3.2+ + {"set_overwrite_mode",{P,B}}, + {"get_overwrite_mode",{P},B}, + {"get_layout",{P},P,0,PangoLayout}, + {"set_completion",{P,P}}, + {"get_completion",{P},P,0,GtkEntryCompletion}, + {"set_progress_fraction",{P,D}}, + {"set_progress_pulse_step",{P,D}}, + {"progress_pulse",{P}}, + {"set_icon_from_stock",{P,I,S}}, -- deprecated 3.10 + {"set_icon_from_pixbuf",{P,I,P}}, + {"set_icon_from_icon_name",{P,I,S}}, + {"set_icon_from_gicon",{P,I,P}}, + {"get_icon_storage_type",{P,I},I}, + {"get_icon_pixbuf",{P,I},P,0,GdkPixbuf}, + {"get_icon_name",{P,I},S}, + {"get_icon_gicon",{P,I},P,0,GIcon}, + {"set_icon_activatable",{P,I,B}}, + {"set_icon_sensitive",{P,I,B}}, + {"get_icon_at_pos",{P,I,I},I}, + {"set_icon_tooltip_text",{P,I,S}}, + {"get_icon_tooltip_text",{P,I},S}, + {"set_icon_tooltip_markup",{P,I,S}}, + {"get_icon_tooltip_markup",{P,I},S}, + {"set_tabs",{P,P}}, -- 3.10 + {"get_tabs",{P},P,0,PangoTabArray}, -- 3.10 + {"get_max_width_chars",{P},I}, -- 3.12 + {"set_max_width_chars",{P,I}}, -- 3.12 + {"im_context_filter_keypress",{P,I},B}, + {"grab_focus_without_selecting",{P}}, --3.16 +"GtkEntry"} + +widget[GtkSpinButton] = {"gtk_spin_button", +{GtkEntry,GtkWidget,GtkEditable,GtkCellEditable,GtkOrientable,GtkBuildable,GObject}, + {"set_adjustment",{P,P}}, + {"get_adjustment",{P},P,0,GtkAdjustment}, + {"set_digits",{P,I}}, + {"get_digits",{P},I}, + {"set_range",{P,D,D}}, + {"get_range",{P,D,D}}, + {"set_value",{P,D}}, + {"get_value",{P},D}, + {"get_value_as_int",{P},I}, + {"set_update_policy",{P,I}}, + {"set_numeric",{P,B}}, + {"get_numeric",{P},B}, + {"set_wrap",{P,B}}, + {"get_wrap",{P},B}, + {"spin",{P,I,D}}, + {"update",{P}}, + {"get_increments",{P,D,D}}, + {"set_snap_to_ticks",{P,B}}, + {"get_snap_to_ticks",{P},B}, + {"configure",{P,P,D,I}}, + {"new",{D,D,D},-routine_id("newSpinBtn")}, +"GtkSpinButton"} + + constant + newsb1 = define_func("gtk_spin_button_new",{P,D,I},P), + newsb2 = define_func("gtk_spin_button_new_with_range",{D,D,D},P) + + -- create a spin button from an ajustment object or from a range of values + function newSpinBtn(atom a, atom b, atom c) + ------------------------------------------- + atom sb = 0 + if classid(a) = GtkAdjustment then + sb = c_func(newsb1,{a,b,c}) + else + sb = c_func(newsb2,{a,b,c}) + end if + return sb + end function + +widget[GtkOrientable] = {"gtk_orientable", +{GObject}, + {"set_orientation",{P,I}}, + {"get_orientation",{P},I}, +"GtkOrientable"} + +widget[GtkRange] = {"gtk_range", +{GtkWidget,GtkOrientable,GtkBuildable,GObject}, + {"set_fill_level",{P,D}}, + {"get_fill_level",{P},D}, + {"set_restrict_to_fill_level",{P,B}}, + {"get_restrict_to_fill_level",{P},B}, + {"set_show_fill_level",{P,B}}, + {"get_show_fill_level",{P},B}, + {"set_adjustment",{P,P}}, + {"get_adjustment",{P},P}, + {"set_inverted",{P,B}}, + {"get_inverted",{P},B}, + {"set_value",{P,D}}, + {"get_value",{P},D}, + {"set_increments",{P,D,D}}, + {"set_range",{P,D,D}}, + {"set_round_digits",{P,I}}, + {"get_round_digits",{P},I}, + {"set_lower_stepper_sensitivity",{P,I}}, + {"get_lower_stepper_sensitivity",{P},I}, + {"set_upper_stepper_sensitivity",{P,I}}, + {"get_upper_stepper_sensitivity",{P},I}, + {"set_flippable",{P,B}}, + {"get_flippable",{P},B}, + {"set_min_slider_size",{P,I}}, + {"get_min_slider_size",{P},I}, + {"get_slider_range",{P,I,I}}, + {"set_slider_size_fixed",{P,B}}, + {"get_slider_size_fixed",{P},B}, +"GtkRange"} + +widget[GtkScale] = {"gtk_scale", +{GtkRange,GtkWidget,GtkOrientable,GtkBuildable,GObject}, + {"set_digits",{P,I}}, + {"get_digits",{P},I}, + {"set_draw_value",{P,B}}, + {"get_draw_value",{P},B}, + {"set_has_origin",{P,B}}, + {"get_has_origin",{P},B}, + {"set_value_pos",{P,I}}, + {"get_value_pos",{P},I}, + {"get_layout",{P},P,0,PangoLayout}, + {"get_layout_offsets",{P,I,I}}, + {"add_mark",{P,D,I,S}}, + {"clear_marks",{P}}, + {"new",{P,P,P,P},-routine_id("newScale")}, +"GtkScale"} + + -- create scale from range or adjustment; + function newScale(integer orient, atom min=0, atom max=0, atom step=0) + ---------------------------------------------------------------------- + if orient = 0 and min = 0 and max = 0 and step = 0 then + return gtk_func("gtk_scale_new",{I,P},{0,0}) + end if + if classid(min) = GtkAdjustment then + return gtk_func("gtk_scale_new",{I,P},{orient,min}) + else + return gtk_func("gtk_scale_new_with_range",{I,D,D,D},{orient,min,max,step}) + end if + end function + +widget[GTimeout] = {"g_timeout", +{0}, + {"new",{I,P,P},-routine_id("newTimeout")}, +"GTimeout"} + + function newTimeout(integer ms, atom fn, atom data) + --------------------------------------------------- + return gtk_func("g_timeout_add",{I,P,P},{ms,fn,data}) + end function + +widget[GIdle] = {"g_idle", +{0}, + {"add",{P,P},-routine_id("newIdle")}, +"GIdle"} + + function newIdle(atom fn, atom data) + ------------------------------------ + return gtk_func("g_idle_add",{P,P},{fn,data}) + end function + +widget[GAppInfo] = {"g_app_info", +{0}, + {"get_name",{P},S}, + {"get_display_name",{P},S}, + {"get_description",{P},S}, + {"get_executable",{P},S}, + {"get_commandline",{P},S}, + {"get_icon",{P},P,0,GIcon}, + {"launch",{P,P,P,P},B}, + {"supports_files",{P},B}, + {"supports_uris",{P},B}, + {"launch_uris",{P,P,P,P},B}, + {"should_show",{P},B}, + {"can_delete",{P},B}, + {"delete",{P},B}, + {"set_as_default_for_type",{P,S,P},B}, + {"set_as_default_for_extension",{P,S,P},B}, + {"add_supports_type",{P,S,P},B}, + {"can_remove_supports_type",{P},B}, + {"remove_supports_type",{P,S,P},B}, + {"get_all",{},P,0,GList}, +"GAppInfo"} + +widget[GFile] = {"g_file", +{GObject}, + {"new",{P},-routine_id("newGFile")}, + {"get_parse_name",{P},S}, + {"parse_name",{S},P}, +"GFile"} + + -- create a GFile from a path or uri + function newGFile(object s) + --------------------------- + if file_exists(canonical_path(s)) then + return gtk_func("g_file_new_for_path",{S},{canonical_path(s)}) + else + return gtk_func("g_file_new_for_uri",{S},{s}) + end if + return 0 + end function + +widget[GIcon] = {"g_icon", +{GObject}, + {"hash",{P},I}, + {"equal",{P,P},B}, + {"to_string",{P},S}, + {"new_for_string",{S,P},P}, +"GIcon"} + +widget[GFileIcon] = {"g_file_icon", +{GIcon,GObject}, + {"new",{P},P}, + {"get_file",{P},P}, +"GFileIcon"} + +widget[GList] = {"g_list", +{GObject}, + {"new",{},-routine_id("newGList")}, + {"append",{P,P},P}, + {"length",{P},I}, + {"nth_data",{P,I},P}, +"GList"} + + function newGList() + ------------------- + atom x = allocate(64) x = 0 + return x + end function + +widget[GSList] = {"g_slist", +{GObject}, +"GSList"} + +widget[GdkDisplay] = {"gdk_display", +{GObject}, + {"new",{},-routine_id("getDisplay")}, + {"open",{S},P,0,GdkDisplay}, + {"get_default",{},P,0,GdkDisplay}, + {"get_name",{P},S}, + {"get_n_screens",{P},I}, + {"get_screen",{P,I},P,0,GdkScreen}, + {"get_default_screen",{P},P,0,GdkScreen}, + {"get_device_manager",{P},P,0,GdkDeviceManager}, + {"pointer_ungrab",{P,I}}, + {"pointer_is_grabbed",{P},B}, + {"device_is_grabbed",{P,P},B}, + {"beep",{P}}, + {"sync",{P}}, + {"flush",{P}}, + {"close",{P}}, + {"is_closed",{P},B}, + {"get_event",{P},P,0,GdkEvent}, + {"peek_event",{P},P,0,GdkEvent}, + {"put_event",{P,P}}, + {"has_pending",{P},B}, + {"set_double_click_time",{P,I}}, + {"set_double_click_distance",{P,I}}, + {"get_pointer",{P,S,I,I,I}}, + {"list_devices",{P},P,0,GList}, + {"get_window_at_pointer",{P,I,I},P,0,GdkWindow}, + {"warp_pointer",{P,S,I,I}}, + {"supports_cursor_color",{P},B}, + {"supports_cursor_alpha",{P},B}, + {"get_default_cursor_size",{P},I}, + {"get_maximal_cursor_size",{P,I,I}}, + {"get_default_group",{P},P,0,GdkWindow}, + {"supports_selection_notification",{P},B}, + {"request_selection_notification",{P,P},B}, + {"supports_clipboard_persistence",{P},B}, + {"store_clipboard",{P,P,I,P,I}}, + {"supports_shapes",{P},B}, + {"supports_input_shapes",{P},B}, + {"supports_composite",{P},B}, + {"get_app_launch_context",{P},P,0,GtkAppLaunchContext}, + {"notify_startup_complete",{P,S}}, +"GdkDisplay"} + + function getDisplay() + --------------------- + return gtk_func("gdk_display_get_default",{}) + end function + +widget[GdkDevice] = {"gdk_device", +{GObject}, + {"get_position",{P,P,I,I}}, +"GdkDevice"} + +widget[GdkScreen] = {"gdk_screen", +{GdkDevice,GObject}, + {"new",{},-routine_id("getDefScrn")}, + {"get_system_visual",{P},P,0,GdkVisual}, + {"get_rgba_visual",{P},P,0,GdkVisual}, + {"is_composited",{P},B}, + {"get_root_window",{P},P,0,GdkWindow}, + {"get_display",{P},P,0,GdkDisplay}, + {"get_number",{P},I}, + {"get_width",{P},I}, + {"get_height",{P},I}, + {"get_width_mm",{P},I}, + {"get_height_mm",{P},I}, + {"list_visuals",{P},P,0,GList}, + {"get_toplevel_windows",{P},P,0,GList}, + {"make_display_name",{P},S}, + {"get_n_monitors",{P},I}, + {"get_primary_monitor",{P},I}, + {"get_monitor_geometry",{P,I,P}}, + {"get_monitor_workarea",{P,I,P}}, + {"get_monitor_at_point",{P,I,I},I}, + {"get_monitor_at_window",{P,P},I}, + {"get_monitor_height_mm",{P,I},I}, + {"get_monitor_width_mm",{P,I},I}, + {"get_monitor_plug_name",{P,I},S}, + {"get_setting",{P,S,P},B}, + {"get_font_options",{P},P,0,CairoFontOptions}, + {"get_resolution",{P},D}, + {"set_resolution",{P,D}}, + {"get_active_window",{P},P,0,GdkWindow}, + {"get_window_stack",{P},P,0,GList}, +"GdkScreen"} + + function getDefScrn() + --------------------- + return gtk_func("gdk_screen_get_default",{}) + end function + +widget[GdkVisual] = {"gdk_visual", +{GObject}, +"GdkVisual"} + +widget[GThemedIcon] = {"g_themed_icon", +{GIcon,GObject}, + {"new",{S},P}, + {"new_with_default_fallbacks",{S},P}, + {"get_names",{P},P}, +"GThemedIcon"} + +widget[GtkThemedIcon] = {"gtk_themed_icon", +{GObject}, +"GtkThemedIcon"} + +widget[GEmblem] = {"g_emblem", +{GObject}, + {"new",{P},P}, + {"get_icon",{P},P,0,GIcon}, +"GEmblem"} + +widget[GEmblemedIcon] = {"g_emblemed_icon", +{GIcon,GObject}, + {"new",{P,P},P}, +"GEmblemedIcon"} + +widget[GdkDeviceManager] = {"gdk_device_manager", +{GObject}, + {"get_display",{P},P,0,GdkDisplay}, + {"list_devices",{P,I},P,0,GList}, + {"get_client_pointer",{P},P,0,GdkDevice}, +"GdkDeviceManager"} + +widget[GtkAppChooser] = {"gtk_app_chooser", +{GtkWidget}, + {"get_app_info",{P},P,0,GAppInfo}, + {"get_content_type",{P},S}, + {"refresh",{P}}, +"GtkAppChooser"} + +widget[GtkAppChooserButton] = {"gtk_app_chooser_button", +{GtkComboBox,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkCellLayout,GtkCellEditable,GObject}, + {"new",{S},P}, + {"append_custom_item",{P,S,S,P}}, + {"append_separator",{P}}, + {"set_active_custom_item",{P,S}}, + {"set_show_default_item",{P,B}}, + {"get_show_default_item",{P},B}, + {"set_show_dialog_item",{P,B}}, + {"get_show_dialog_item",{P},B}, + {"set_heading",{P,S}}, + {"get_heading",{P},S}, +"GtkAppChooserButton"} + +widget[GMenu] = {"g_menu", +{GObject}, + {"new",{},P}, + {"append",{P,S,S}}, +"GMenu"} + +widget[GtkApplication] = {"gtk_application", +{GObject}, + {"new",{S,I},-routine_id("newApp")}, + {"add_window",{P,P}}, + {"remove_window",{P,P}}, + {"get_windows",{P},P,0,GList}, + {"get_window_by_id",{P,I},P,0,GtkWindow}, + {"get_active_window",{P},P,0,GtkWindow}, + {"inhibit",{P,P,I,S},I}, + {"uninhibit",{P,I}}, + {"is_inhibited",{P,I},B}, + {"get_app_menu",{P},P,0,GMenuModel}, + {"set_app_menu",{P,P}}, + {"get_menubar",{P},P,0,GMenuModel}, + {"set_menubar",{P,P}}, + {"add_accelerator",{P,S,S,P}}, + {"remove_accelerator",{P,S,P}}, + {"run",{P},-routine_id("appRun")}, + {"activate",{P},-routine_id("appActivate")}, + {"get_accels_for_action",{P,S},P,0,GSList}, -- 3.12 + {"set_accels_for_action",{P,S,S}}, + {"list_action_descriptions",{P},P,0,GSList}, + {"get_actions_for_accel",{P,S},P}, -- 3.14 + {"get_menu_by_id",{P,S},P,0,GMenu}, -- 3.14 + {"prefers_app_menu",{},B}, -- 3.14 +"GtkApplication"} + + function appValid(object x) + --------------------------- + return gtk_func("g_application_id_is_valid",{S},{x}) + end function + + function appActivate(object x) + ------------------------------ + gtk_proc("g_application_activate",{P},{x}) + return 1 + end function + + function appRun(object x) + ------------------------- + gtk_proc("g_application_run",{P,I,P},{x,0,0}) + return 1 + end function + + function newApp(object id, object flags) + ---------------------------------------- + if string(id) then id = allocate_string(id) end if + if appValid(id) then + return gtk_func("gtk_application_new",{P,I},{id,flags}) + else + crash("Error: invalid application id!") + end if + return 0 + end function + +widget[GtkApplicationWindow] = {"gtk_application_window", +{GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{P},P}, + {"set_show_menubar",{P,B}}, + {"get_show_menubar",{P},B}, + {"get_id",{P},I}, +"GtkApplicationWindow"} + +widget[GtkActionable] = {"gtk_actionable", +{GtkWidget}, + {"get_action_name",{P},S}, + {"set_action_name",{P,S}}, + {"get_action_target_value",{P},P}, + {"set_action_target_value",{P,P}}, + {"set_action_target",{P,S,P}}, + {"set_detailed_action_name",{P,S}}, +"GtkActionable"} + +widget[GtkAppLaunchContext] = {"gtk_app_launch_context", +{0}, +"GtkAppLaunchContext"} + +widget[GtkAspectFrame] = {"gtk_aspect_frame", +{GtkFrame,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{S,F,F,F,B},P}, + {"set",{P,F,F,F,B}}, +"GtkAspectFrame"} + +widget[GtkAssistant] = {"gtk_assistant", +{GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"set_current_page",{P,I}}, + {"get_current_page",{P},I}, + {"get_n_pages",{P},I}, + {"get_nth_page",{P,I},P,0,GtkWidget}, + {"prepend_page",{P,P},I}, + {"append_page",{P,P},I}, + {"insert_page",{P,P,I},I}, + {"remove_page",{P,I}}, + {"set_forward_page_func",{P,P,P,P}}, + {"set_page_type",{P,P,P}}, + {"get_page_type",{P,P},I}, + {"set_page_title",{P,P,S}}, + {"get_page_title",{P,P},S}, + {"set_page_complete",{P,P,B}}, + {"get_page_complete",{P,P},B}, + {"add_action_widget",{P,P}}, + {"remove_action_widget",{P,P}}, + {"update_buttons_state",{P}}, + {"commit",{P}}, + {"next_page",{P}}, + {"previous_page",{P}}, +"GtkAssistant"} + +widget[GtkDrag] = {"gtk_drag", + {"cancel",{P}}, +"GtkDrag"} + +widget[GtkCssProvider] = {"gtk_css_provider", +{GObject}, + {"new",{P},-routine_id("newProvider")}, + {"get_default",{},P,0,GtkCssProvider}, + {"get_named",{S,S},P,0,GtkCssProvider}, + {"load_from_data",{P,S,I,P},B}, + {"load_from_string",{P,P},-routine_id("addCssfromString")}, + {"load_from_file",{P,P,P},B}, + {"load_from_path",{P,S,P},B}, + {"load_from_resource",{P,S}}, -- 3.16 + {"to_string",{P},S}, +"GtkCssProvider"} + + function newProvider(object name=0) + ----------------------------------- + atom provider = gtk_func("gtk_css_provider_get_default") + atom style = create(GtkStyleContext) + atom screen = get(style,"screen") + + atom err = allocate(64) err = 0 + register(provider,GtkCssProvider) + if atom(name) then + set(style,"add provider for screen",screen,provider,800) + return provider + end if + if get(provider,"load from path",canonical_path(name),err) then + set(style,"add provider for screen",screen,provider,800) + else + printf(1,"Error finding or parsing css %s \n",{name}) + end if + return provider + end function + + function addCssfromString(atom provider, object str) + display("Pro [] str []",{provider,str}) + return gtk_func("gtk_css_provider_load_from_data",{P,P,I,P}, + {provider,allocate_string(str),length(str),0}) + end function + +widget[GtkCssSection] = {"gtk_css_section", +{GObject}, + {"get_end_line",{P},I}, + {"get_end_position",{P},I}, + {"get_file",{P},P}, + {"get_parent",{P},P,0,GtkCssSection}, + {"get_section_type",{P},I}, + {"get_start_line",{P},I}, + {"get_start_position",{P},I}, + {"ref",{P},P,0,GtkCssSection}, + {"unref",{P}}, +"GtkCssSection"} + +widget[GtkStatusIcon] = {"gtk_status_icon", -- Deprecated 3.14 +{GObject}, + {"new",{},P}, + {"new_from_pixbuf",{P},P}, + {"new_from_file",{S},P}, + {"new_from_icon_name",{S},P}, + {"new_from_gicon",{P},P}, + {"set_from_pixbuf",{P,P}}, + {"set_from_file",{P,S}}, + {"set_from_icon_name",{P,S}}, + {"set_from_gicon",{P,P}}, + {"get_storage_type",{P},I}, + {"get_pixbuf",{P},P,0,GdkPixbuf}, + {"get_icon_name",{P},S}, + {"get_gicon",{P},P}, + {"get_size",{P},I}, + {"set_screen",{P,P}}, + {"get_screen",{P},P,0,GdkScreen}, + {"set_tooltip_text",{P,S}}, + {"get_tooltip_text",{P},S}, + {"set_tooltip_markup",{P,S}}, + {"get_tooltip_markup",{P},S}, + {"set_has_tooltip",{P,B}}, + {"get_has_tooltip",{P},P}, + {"set_title",{P,S}}, + {"get_title",{P},S}, + {"set_name",{P,S}}, + {"set_visible",{P,B}}, + {"get_visible",{P},B}, + {"is_embedded",{P},B}, + {"get_geometry",{P,P,P,I},B}, + {"get_x11_window_id",{P},I}, + {"position_menu",{P,P,I,I,B},-routine_id("StatIconPosMenu")}, +"GtkStatusIcon"} + + constant sipm = define_proc("gtk_status_icon_position_menu",{P,I,I,I,P}) + + function StatIconPosMenu(atom stat, atom menu, integer x, integer y, integer p) + display("Stat [] Menu []",{stat,menu}) + c_proc(sipm,{menu,x,y,p,stat}) + return 1 + end function + +widget[GtkOffscreenWindow] = {"gtk_offscreen_window", +{GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"get_surface",{P},P,0,CairoSurface_t}, + {"get_pixbuf",{P},P,0,GdkPixbuf}, +"GtkOffscreenWindow"} + +widget[GtkAlignment] = {"gtk_alignment", -- deprecated 3.14 +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{F,F,F,F},P}, + {"set",{P,F,F,F,F}}, + {"set_padding",{P,I,I,I,I}}, + {"get_padding",{P,I,I,I,I}}, +"GtkAlignment"} + +widget[GtkComboBox] = {"gtk_combo_box", +{GtkBin,GtkContainer,GtkWidget,GtkCellLayout,GtkCellEditable,GtkBuildable,GObject}, + {"new",{P},-routine_id("newComboBox")}, + {"set_wrap_width",{P,I}}, + {"get_wrap_width",{P},I}, + {"set_row_span_column",{P,I}}, + {"get_row_span_column",{P},I}, + {"set_column_span_column",{P,I}}, + {"get_column_span_column",{P},I}, + {"set_active",{P,I}}, + {"get_active",{P},I}, + {"set_id_column",{P,I}}, + {"get_id_column",{P},I}, + {"set_active_id",{P,S}}, + {"get_active_id",{P},S}, + {"set_model",{P,P}}, + {"get_model",{P},P,0,GtkTreeModel}, + {"popup_for_device",{P,P}}, + {"popup",{P}}, + {"popdown",{P}}, + {"get_popup_accessible",{P},P}, + {"set_row_separator_func",{P,P,P,P}}, + {"get_row_separator_func",{P},P}, + {"set_add_tearoffs",{P,B}}, -- Deprecated 3.10 + {"get_add_tearoffs",{P},B}, -- Deprecated 3.10 + {"set_title",{P,S}}, -- Deprecated 3.10 + {"get_title",{P},S}, -- Deprecated 3.10 + {"set_focus_on_click",{P,B}}, + {"get_focus_on_click",{P},B}, + {"set_button_sensitivity",{P,I}}, + {"get_button_sensitivity",{P},I}, + {"get_has_entry",{P},B}, + {"set_entry_text_column",{P,I}}, + {"get_entry_text_column",{P},I}, + {"set_popup_fixed_width",{P,B}}, + {"get_popup_fixed_width",{P},B}, + {"set_activates_default",{P,B},-routine_id("setActivatesDefault")}, +"GtkComboBox"} + + function setActivatesDefault(atom box, boolean z) + atom x = get(box,"child") + register(x,GtkEntry) + set(x,"property","activates-default",z) + return 1 + end function + + -- create a combo box either empty or from a model + function newComboBox(object x=0) + -------------------------------- + if x = 0 then + return gtk_func("gtk_combo_box_new",{},{}) + end if + if classid(x) = GtkListStore then + return gtk_func("gtk_combo_box_new_with_model",{P},{x}) + end if + end function + +widget[GtkComboBoxText] = {"gtk_combo_box_text", +{GtkComboBox,GtkBin,GtkContainer,GtkWidget,GtkCellLayout,GtkCellEditable,GtkBuildable,GObject}, + {"new",{},P}, + {"new_with_entry",{},P}, + {"append",{P,P},-routine_id("appComboBoxText")}, + {"prepend",{P,S,S}}, + {"insert",{P,I,S,S}}, + {"append_text",{P,S}}, + {"prepend_text",{P,S}}, + {"insert_text",{P,I,S}}, + {"remove",{P,I}}, + {"remove_all",{P}}, + {"get_active_text",{P},S}, + {"get_entry",{P},-routine_id("getComboEntry")}, +"GtkComboBoxText"} + + function getComboEntry(atom box) + atom x = get(box,"child") + register(x,GtkEntry) + return x + end function + + constant cbtadd = define_proc("gtk_combo_box_text_append",{P,P,P}) + + function appComboBoxText(object box, object txt) + if string(txt[1]) then + for i = 1 to length(txt) do + txt[i] = allocate_string(txt[i]) + c_proc(cbtadd,{box,txt[i],txt[i]}) + end for + else + c_proc(cbtadd,{box,allocate_string(txt)}) + end if + return 1 + end function + +widget[GtkComboBoxEntry] = {"gtk_combo_box_text", +{GtkComboBoxText,GtkComboBox,GtkBin,GtkContainer,GtkWidget,GObject}, + {"new",{},-routine_id("newComboBoxEntry")}, +"GtkComboBoxEntry"} + + function newComboBoxEntry() + --------------------------- + return gtk_func("gtk_combo_box_text_new_with_entry",{},{}) + end function + +widget[GtkFrame] = {"gtk_frame", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{S},P}, + {"set_label",{P,S}}, + {"get_label",{P},S}, + {"set_label_align",{P,F,F}}, + {"get_label_align",{P,F,F}}, + {"set_label_widget",{P,P}}, + {"get_label_widget",{P},P,0,GtkWidget}, + {"set_shadow_type",{P,I}}, + {"get_shadow_type",{P},I}, +"GtkFrame"} + +widget[GtkToggleButton] = {"gtk_toggle_button", +{GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GtkActivatable,GObject}, + {"new",{P},-routine_id("newToggleBtn")}, + {"new_with_label",{S},P}, + {"new_with_mnemonic",{S},P}, + {"set_mode",{P,B}}, + {"get_mode",{P},B}, + {"toggled",{P}}, + {"set_active",{P,B}}, + {"get_active",{P},B}, + {"set_inconsistent",{P,B}}, + {"get_inconsistent",{P},B}, +"GtkToggleButton"} + + -- handles creation of buttons with icons from various sources; + -- this function modified greatly from GTK versions prior to 10 + function newToggleBtn(object cap = 0) + --------------------------------------------------------------- + atom btn = 0, img = 0 + + if atom(cap) and cap = 0 then -- return a blank button; + return gtk_func("gtk_toggle_button_new") + end if + + object icon = 0, title = 0, tmp + if string(cap) then + if match("#",cap) then + tmp = split(cap,'#') + icon = tmp[1] + title = tmp[2] + else + icon = cap + title = cap + end if + end if + + btn = gtk_func("gtk_toggle_button_new_with_mnemonic",{P}, + {allocate_string(title)}) + + img = get_icon_image(icon,3) + if img > 0 then + title = allocate_string(title) + gtk_proc("gtk_button_set_image",{P,P},{btn,img}) + gtk_proc("gtk_button_set_label",{P,P},{btn,title}) + end if + + return btn + end function + +widget[GtkCheckButton] = {"gtk_check_button", +{GtkToggleButton,GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GtkActivatable,GObject}, + {"new",{P},-routine_id("newCheckBtn")}, + {"new_with_label",{S},P,0,GtkWidget}, + {"new_with_mnemonic",{S},P,0,GtkWidget}, +"GtkCheckButton"} + + function newCheckBtn(object cap = 0) +--------------------------------------------------------------- + atom btn = 0, img = 0 + + if atom(cap) and cap = 0 then -- return a blank button; + return gtk_func("gtk_check_button_new") + end if + + object icon = 0, title = 0, tmp + if string(cap) then + if match("#",cap) then + tmp = split(cap,'#') + icon = tmp[1] + title = tmp[2] + else + icon = cap + title = cap + end if + end if + + btn = gtk_func("gtk_check_button_new_with_mnemonic",{P}, + {allocate_string(title)}) + + img = get_icon_image(icon,GTK_ICON_SIZE_SMALL_TOOLBAR) + if img > 0 then + title = allocate_string(title) + gtk_proc("gtk_button_set_image",{P,P},{btn,img}) + gtk_proc("gtk_button_set_label",{P,P},{btn,title}) + end if + + return btn + end function + +widget[GtkRadioButton] = {"gtk_radio_button", +{GtkCheckButton,GtkToggleButton,GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GtkActivatable,GObject}, + {"new",{P,P},-routine_id("newRadioBtn")}, + {"set_group",{P,P}}, + {"get_group",{P},P,0,GSList}, + {"join_group",{P,P}}, +"GtkRadioButton"} + + function newRadioBtn(atom group, object cap = 0) +--------------------------------------------------------------- + atom btn = 0, img = 0 + + if atom(cap) and cap = 0 then -- return a blank button; + return gtk_func("gtk_radio_button_new_from_widget",{P},{group}) + end if + + object icon = 0, title = 0, tmp + if string(cap) then + if match("#",cap) then + tmp = split(cap,'#') + icon = tmp[1] + title = tmp[2] + else + icon = cap + title = cap + end if + end if + + btn = gtk_func("gtk_radio_button_new_with_mnemonic_from_widget",{P,P}, + {group,allocate_string(title)}) + + img = get_icon_image(icon,GTK_ICON_SIZE_BUTTON) + if img > 0 then + title = allocate_string(title) + gtk_proc("gtk_button_set_image",{P,P},{btn,img}) + gtk_proc("gtk_button_set_label",{P,P},{btn,title}) + end if + + return btn + end function + +widget[GtkColorButton] = {"gtk_color_button", +{GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkColorChooser,GtkActionable,GtkActivatable,GObject}, + {"new",{P},-routine_id("new_color_button")}, + {"set_title",{P,S}}, + {"get_title",{P},S}, +"GtkColorButton"} + + function new_color_button(object c=0) + if string(c) then c = to_rgba(c) end if + if c=0 then return gtk_func("gtk_color_button_new") + else return gtk_func("gtk_color_button_new_with_rgba",{P},{c}) + end if + end function + +widget[GtkFontButton] = {"gtk_font_button", +{GtkButton,GtkBin,GtkContainer,GtkWidget,GtkFontChooser,GtkActionable,GtkActivatable,GtkBuildable,GObject}, + {"new",{P,P,P},-routine_id("new_font_button")}, + {"set_font_name",{P,S}}, + {"get_font_name",{P},S}, + {"set_show_style",{P,B}}, + {"get_show_style",{P},B}, + {"set_show_size",{P,B}}, + {"get_show_size",{P},B}, + {"set_use_font",{P,B}}, + {"get_use_font",{P},B}, + {"set_use_size",{P,B}}, + {"get_use_size",{P},B}, + {"set_title",{P,S}}, + {"get_title",{P},S}, +"GtkFontButton"} + + function new_font_button(object f=0, object fn=0, object data=0) + if string(f) then f = allocate_string(f) end if + atom fnt + if f = 0 then + fnt = gtk_func("gtk_font_button_new") + else fnt = gtk_func("gtk_font_button_new_with_font",{P},{f}) + end if + if string(fn) or fn > 0 then connect(fnt,"font-set",fn,data) end if + return fnt + end function + +widget[GtkLinkButton] = {"gtk_link_button", +{GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GtkActivatable,GObject}, + {"new",{S,S},-routine_id("newLinkButton")}, + {"set_uri",{P,S}}, + {"get_uri",{P},S}, + {"set_visited",{P,B}}, + {"get_visited",{P},B}, +"GtkLinkButton"} + + function newLinkButton(object link, object lbl=0) + ------------------------------------------------- + if lbl = 0 then return gtk_func("gtk_link_button_new",{S},{link}) + else return gtk_func("gtk_link_button_new_with_label",{S,S},{link,lbl}) + end if + end function + +widget[GtkLockButton] = {"gtk_lock_button", -- unable to make this work! +{GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GtkActivatable,GObject}, + {"new",{P},P}, + {"set_permission",{P,P}}, + {"get_permission",{P},P}, +"GtkLockButton"} + +widget[GtkScaleButton] = {"gtk_scale_button", +{GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GtkActionable,GtkActivatable,GObject}, + {"new",{I,D,D,D,P},P}, + {"set_adjustment",{P,P}}, + {"get_adjustment",{P},P,0,GtkAdjustment}, + {"set_value",{P,D}}, + {"get_value",{P},D}, + {"get_popup",{P},P,0,GtkWidget}, + {"get_plus_button",{P},P,0,GtkWidget}, + {"get_minus_button",{P},P,0,GtkWidget}, + {"set_icons",{P,P},-routine_id("setScaleButtonIcons")}, +"GtkScaleButton"} + + function setScaleButtonIcons(atom btn, object icons) + ---------------------------------------------------- + gtk_proc("gtk_scale_button_set_icons",{P,P}, + {btn,allocate_string_pointer_array(icons)}) + return 1 + end function + +widget[GtkMenu] = {"gtk_menu", +{GtkMenuShell,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"new_from_model",{P},P}, + {"attach",{P,P,I,I,I,I}}, + {"attach_to_widget",{P,P,P}}, + {"get_attach_widget",{P},P,0,GtkWidget}, + {"get_for_attach_widget",{P},P,0,GSList}, + {"detach",{P}}, + {"popup",{P,P,P,P,P,I,I}}, + {"popdown",{P}}, + {"reposition",{P}}, + {"set_active",{P,I}}, + {"get_active",{P},P,0,GtkWidget}, + {"popup_for_device",{P,P,P,P,P,P,P,I,I}}, + {"set_accel_group",{P,P}}, + {"get_accel_group",{P},P,0,GtkAccelGroup}, + {"set_accel_path",{P,S}}, + {"get_accel_path",{P},S}, + {"set_title",{P,S}}, -- Deprecated 3.10 + {"get_title",{P},S}, -- Deprecated 3.10 + {"set_monitor",{P,I}}, + {"get_monitor",{P},I}, + {"set_tearoff_state",{P,B}}, -- Deprecated 3.10 + {"get_tearoff_state",{P},B}, -- Deprecated 3.10 + {"set_reserve_toggle_size",{P,B}}, + {"get_reserve_toggle_size",{P},B}, + {"set_screen",{P,P}}, +"GtkMenu"} + +widget[GtkMenuBar] = {"gtk_menu_bar", +{GtkMenuShell,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"new_from_model",{P},P}, + {"set_pack_direction",{P,I}}, + {"get_pack_direction",{P},I}, + {"set_child_pack_direction",{P,I}}, + {"get_child_pack_direction",{P},I}, +"GtkMenuBar"} + +widget[GMenu] = {"g_menu", +{GMenuModel,GObject}, + {"new",{},P}, + {"freeze",{P}}, + {"insert",{P,I,S,S}}, + {"prepend",{P,S,S}}, + {"append",{P,S,S}}, + {"insert_item",{P,I,P}}, + {"append_item",{P,P}}, + {"prepend_item",{P,P}}, + {"insert_section",{P,I,S,P}}, + {"prepend_section",{P,S,P}}, + {"append_section",{P,S,P}}, + {"append_submenu",{P,S,P}}, + {"insert_submenu",{P,I,S,P}}, + {"prepend_submenu",{P,S,P}}, + {"remove",{P,I}}, +"GMenu"} + +widget[GMenuModel] = {"g_menu_model", +{GObject}, + {"is_mutable",{P},B}, + {"get_n_items",{P},I}, + {"get_item_attribute",{P,I,S,S,P},B}, + {"get_item_link",{P,I,S},P,0,GMenuModel}, + {"items_changed",{P,I,I,I}}, +"GMenuModel"} + +widget[GMenuItem] = {"g_menu_item", +{GObject}, + {"new",{S,S},P}, + {"new_section",{S,P},P,0,GMenuItem}, + {"new_submenu",{S,P},P,0,GMenuItem}, + {"set_label",{P,S}}, + {"set_action_and_target_value",{P,S,P}}, + {"set_detailed_action",{P,S}}, + {"set_section",{P,P}}, + {"set_submenu",{P,P}}, + {"set_attribute_value",{P,P,P}}, + {"set_link",{P,S,P}}, +"GMenuItem"} + +widget[GtkMenuButton] = {"gtk_menu_button", --3.6 +{GtkToggleButton,GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActionable,GtkActivatable,GObject}, + {"new",{},P}, + {"set_popup",{P,P}}, + {"get_popup",{P},P,0,GtkMenu}, + {"set_menu_model",{P,P}}, + {"get_menu_model",{P},P,0,GMenuModel}, + {"set_direction",{P,I}}, + {"get_direction",{P},I}, + {"set_align_widget",{P,P}}, + {"get_align_widget",{P},P,0,GtkWidget}, + {"set_popover",{P,P}}, -- 3.12 + {"get_popover",{P},P,0,GtkPopover}, -- 3.12 + {"set_use_popover",{P,B}}, -- 3.12 + {"get_use_popover",{P},B}, -- 3.12 +"GtkMenuButton"} + +widget[GtkMenuItem] = {"gtk_menu_item", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActivatable,GtkActionable,GObject}, + {"new",{P,P,P,P},-routine_id("newMenuItem")}, + {"new_with_label",{S},P}, + {"new_with_mnemonic",{S},P}, + {"set_label",{P,S},-routine_id("setMenuItemLabel")}, + {"get_label",{P},-routine_id("getMenuItemLabel")}, + {"set_image",{P,P},-routine_id("setMenuItemImage")}, + {"get_image",{P},-routine_id("getMenuItemImage")}, + {"set_use_underline",{P,B},-routine_id("setMenuItemUseUnderline")}, + {"get_use_underline",{P},-routine_id("getMenuItemUseUnderline")}, + {"set_submenu",{P,P}}, + {"get_submenu",{P},P,0,GtkWidget}, + {"select",{P}}, + {"deselect",{P}}, + {"activate",{P}}, + {"toggle_size_allocate",{P,I}}, + {"set_reserve_indicator",{P,B}}, + {"get_reserve_indicator",{P},B}, + {"add_accelerator",{P,P,P},-routine_id("addMenuAccel")}, +"GtkMenuItem"} + + function addMenuAccel(atom item, object accels, object img = 0) + atom x = allocate(8) + integer key, mods + + object child = get(item,"child") + + if atom(img) and img = 0 then + -- do nothing + else + img = get_icon_image(img,4) + end if + + if sequence(accels) then + + gtk_proc("gtk_accelerator_parse", {P,P,P}, + {allocate_string(accels[2],1),x,x+4}) + + key = peek4u(x) mods = peek4u(x+4) + + gtk_proc("gtk_widget_add_accelerator",{P,P,P,I,I,I}, + {item,allocate_string("activate"),accels[1],key,mods,GTK_ACCEL_VISIBLE}) + + if classid(child) = -1 then + gtk_proc("gtk_accel_label_set_accel_widget",{P,P},{child,item}) + + gtk_proc("gtk_accel_label_set_accel",{P,I,I}, + {child,key,mods}) + end if + + end if + + gtk_proc("g_object_ref",{P},{child}) + gtk_proc("gtk_container_remove",{P,P},{item,child}) + + atom box = create(GtkButtonBox) + set(box,"layout",GTK_BUTTONBOX_START) + + if img > 0 then + add(box,img) + register(img,GtkImage) + set(box,"child non_homogeneous",img,TRUE) + end if + + register(child,GtkAccelLabel) + add(box,child) -- put the label back + set(box,"child non_homogeneous",child,TRUE) + + if sequence(accels) then + object txt = gtk_str_func("gtk_accelerator_get_label",{I,I},{key,mods}) + if string(txt) then + atom acc = create(GtkLabel) + set(acc,"font","italic 10") + set(acc,"text",txt) + add(box,acc) + set(box,"child secondary",acc,TRUE) + set(box,"child non_homogeneous",acc,TRUE) + end if + end if + + add(item,box) + + free(x) + + return item + end function + + ------------------------------------------------------------------------------- + function newMenuItem(object stk=0, object fn=0, object data=0, object accels=0) + ------------------------------------------------------------------------------- + object item, img = 0 + + if match("#",stk) then + stk = split(stk,'#') + img = stk[1] + stk = stk[2] + goto "next" + end if + + if not match("#",stk) then + if match("gtk-",stk) then + img = stk + stk = "_" & proper(stk[5..$]) + end if + end if + + label "next" + + item = gtk_func("gtk_menu_item_new_with_mnemonic",{P},{allocate_string(stk)}) + register(item,GtkRadioMenuItem) + + if atom(img) and img = 0 then + item = addMenuAccel(item,accels) + else + item = addMenuAccel(item,accels,img) + end if + + return item + end function + + function setMenuItemLabel(atom item, object lbl) + if string(lbl) then lbl = allocate_string(lbl) end if + atom b = get(item,"child") + object l = get(b,"children") + l = to_sequence(l,1) + for i = 1 to length(l) do + if classid(l[i]) = GtkAccelLabel then + gtk_proc("gtk_label_set_text",{P,P},{l[i],lbl}) + return 1 + end if + end for + return 1 + end function + + function getMenuItemLabel(atom item) + atom b = get(item,"child") + object l = get(b,"children") + l = to_sequence(l,1) + for i = 1 to length(l) do + if classid(l[i]) = GtkAccelLabel then + return gtk_str_func("gtk_label_get_text",{P},{l[i]}) + end if + end for + return 1 + end function + + function setMenuItemImage(atom item, object img) + if string(img) then img = get_icon_image(img) end if + img = get(img,"pixbuf") + atom b = get(item,"child") + object l = get(b,"children") + l = to_sequence(l,1) + for i = 1 to length(l) do + if classid(l[i]) = GtkImage then + gtk_proc("gtk_image_set_from_pixbuf",{P,P},{l[i],img}) + return 1 + end if + end for + return 1 + end function + + function getMenuItemImage(atom item) + atom b = get(item,"child") + object l = get(b,"children") + l = to_sequence(l,1) + for i = 1 to length(l) do + if classid(l[i]) = GtkImage then + return l[i] + end if + end for + return 1 + end function + + function setMenuItemUseUnderline(atom item, boolean use) + atom b = get(item,"child") + object l = get(b,"children") + l = to_sequence(l,1) + for i = 1 to length(l) do + if classid(l[i]) = GtkAccelLabel then + gtk_proc("gtk_label_set_use_underline",{P,B},{l[i],use}) + return 1 + end if + end for + return 1 + end function + + function getMenuItemUseUnderline(atom item) + atom b = get(item,"child") + object l = get(b,"children") + l = to_sequence(l,1) + for i = 1 to length(l) do + if classid(l[i]) = GtkAccelLabel then + return gtk_func("gtk_label_get_use_underline",{P},{l[i]}) + end if + end for + display(l) + return 1 + end function + +widget[GtkImageMenuItem] = {"gtk_image_menu_item", +{GtkMenuItem,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{P,P,P,P},-routine_id("newMenuItem")}, +"GtkImageMenuItem"} + +widget[GtkRadioMenuItem] = {"gtk_radio_menu_item", +{GtkCheckMenuItem,GtkMenuItem,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActivatable,GtkActionable,GObject}, + {"new",{P,P,P,P,P},-routine_id("newRadioMenuItem")}, + {"set_group",{P,P}}, + {"get_group",{P},P,0,GSList}, +"GtkRadioMenuItem"} + + -------------------------------------------------------------------------------------- + function newRadioMenuItem(atom group, object stk, object fn, object data, object accels=0) + -------------------------------------------------------------------------------------- + object item, img = 0 + + if match("#",stk) then + stk = split(stk,'#') + img = stk[1] + stk = stk[2] + goto "next" + end if + + if not match("#",stk) then + if match("gtk-",stk) then + img = stk + end if + end if + + label "next" + + if group = 0 then + item = gtk_func("gtk_radio_menu_item_new_with_mnemonic",{P,P}, + {group,allocate_string(stk)}) + else + item = gtk_func("gtk_radio_menu_item_new_with_mnemonic_from_widget", + {P,P},{group,allocate_string(stk)}) + end if + register(item,GtkMenuItem) + + if atom(img) and img = 0 then + item = addMenuAccel(item,accels) + else + item = addMenuAccel(item,accels,img) + end if + + return item + end function + +widget[GtkCheckMenuItem] = {"gtk_check_menu_item", +{GtkMenuItem,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActivatable,GtkActionable,GObject}, + {"new",{P,P,P,P},-routine_id("newCheckMenuItem")}, + {"set_active",{P,B}}, + {"get_active",{P},B}, + {"toggled",{P}}, + {"set_inconsistent",{P,B}}, + {"get_inconsistent",{P},B}, + {"set_draw_as_radio",{P,B}}, + {"get_draw_as_radio",{P},B}, +"GtkCheckMenuItem"} + + ------------------------------------------------------------------------------- + function newCheckMenuItem(object stk,object fn, object data, object accels=0) + ------------------------------------------------------------------------------- + object item, img = 0 + + if match("#",stk) then + stk = split(stk,'#') + img = stk[1] + stk = stk[2] + goto "next" + end if + + if not match("#",stk) then + if match("gtk-",stk) then + img = stk + end if + end if + + label "next" + + item = gtk_func("gtk_check_menu_item_new_with_mnemonic",{P},{allocate_string(stk)}) + register(item,GtkCheckMenuItem) + + if atom(img) and img = 0 then + item = addMenuAccel(item,accels) + else + item = addMenuAccel(item,accels,img) + end if + + return item + end function + +widget[GtkNumerableIcon] = {"gtk_numerable_icon", -- Deprecated 3.14 +{GEmblemedIcon,GObject}, + {"new",{P},P,0,GIcon}, + {"new_with_style_context",{P,P},P,0,GIcon}, + {"get_background_gicon",{P},P,0,GIcon}, + {"set_background_gicon",{P,P}}, + {"get_background_icon_name",{P},S}, + {"set_background_icon_name",{P,S}}, + {"get_count",{P},I}, + {"set_count",{P,I}}, + {"get_label",{P},S}, + {"set_label",{P,S}}, + {"get_style_context",{P},P,0,GtkStyleContext}, + {"set_style_context",{P,P}}, +"GtkNumerableIcon"} + +widget[GtkEventBox] = {"gtk_event_box", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"set_above_child",{P,B}}, + {"get_above_child",{P},B}, + {"set_visible_window",{P,B}}, + {"get_visible_window",{P},B}, +"GtkEventBox"} + +widget[GtkExpander] = {"gtk_expander", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{P},-routine_id("newExp")}, + {"set_spacing",{P,I}}, + {"get_spacing",{P},I}, + {"set_expanded",{P,B}}, + {"get_expanded",{P},B}, + {"set_label",{P,S}}, + {"get_label",{P},S}, + {"set_label_widget",{P,P}}, + {"get_label_widget",{P},P}, + {"set_label_fill",{P,B}}, + {"get_label_fill",{P},B}, + {"set_use_underline",{P,B}}, + {"get_use_underline",{P},B}, + {"set_use_markup",{P,B}}, + {"get_use_markup",{P},B}, + {"set_resize_toplevel",{P,B}}, + {"get_resize_toplevel",{P},B}, +"GtkExpander"} + + function newExp(sequence caption) + if match("_",caption) then + return gtk_func("gtk_expander_new_with_mnemonic",{P},{caption}) + else + return gtk_func("gtk_expander_new",{P},{caption}) + end if + end function + +widget[GtkToolItem] = {"gtk_tool_item", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActivatable,GObject}, + {"new",{},P}, + {"set_homogeneous",{P,B}}, + {"get_homogeneous",{P},B}, + {"set_expand",{P,B}}, + {"get_expand",{P},B}, + {"set_tooltip_text",{P,S}}, + {"set_tooltip_markup",{P,S}}, + {"set_use_drag_window",{P,B}}, + {"get_use_drag_window",{P},B}, + {"set_visible_horizontal",{P,B}}, + {"get_visible_horizontal",{P},B}, + {"set_visible_vertical",{P,B}}, + {"get_visible_vertical",{P},B}, + {"set_is_important",{P,B}}, + {"get_is_important",{P},B}, + {"get_ellipsize_mode",{P},I}, + {"get_icon_size",{P},I}, + {"get_orientation",{P},I}, + {"get_toolbar_style",{P},I}, + {"get_relief_style",{P},I}, + {"get_text_alignment",{P},F}, + {"get_text_orientation",{P},I}, + {"retrieve_proxy_menu_item",{P},P,0,GtkWidget}, + {"set_proxy_menu_item",{P,S,P}}, + {"get_proxy_menu_item",{P,S},P,0,GtkWidget}, + {"rebuild_menu",{P}}, + {"toolbar_reconfigured",{P}}, + {"get_text_size_group",{P},P,0,GtkSizeGroup}, +"GtkToolItem"} + +widget[GtkToolButton] = {"gtk_tool_button", +{GtkToolItem,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActivatable,GtkActionable,GObject}, + {"new",{P,P},-routine_id("newTB")}, + {"set_label",{P,S}}, + {"get_label",{P},S}, + {"set_use_underline",{P,B}}, + {"get_use_underline",{P},B}, + {"set_stock_id",{P,S}}, -- Deprecated 3.10 + {"get_stock_id",{P},S}, -- Deprecated 3.10 + {"set_icon_name",{P,S}}, + {"get_icon_name",{P},S}, + {"set_icon_widget",{P,P}}, + {"get_icon_widget",{P},P,0,GtkWidget}, + {"set_label_widget",{P,P}}, + {"get_label_widget",{P},P,0,GtkWidget}, +"GtkToolButton"} + + function newTB(object icn=0, object lbl=0) + -------------------------------------------------- + if string(icn) then + if match("gtk-",icn) = 1 then + return gtk_func("gtk_tool_button_new_from_stock",{P},{allocate_string(icn)}) + end if + icn = create(GtkImage,icn) + end if + if string(lbl) then + lbl = allocate_string(lbl) + end if + atom btn = gtk_func("gtk_tool_button_new",{P,P},{icn,lbl}) + return btn + end function + +widget[GtkMenuToolButton] = {"gtk_menu_tool_button", +{GtkToolButton,GtkToolItem,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActivatable,GtkActionable,GObject}, + {"new",{P,P},-routine_id("newMenuTB")}, + {"set_menu",{P,P}}, + {"get_menu",{P},P,0,GtkWidget}, + {"set_arrow_tooltip_text",{P,S}}, + {"set_arrow_tooltip_markup",{P,S}}, +"GtkMenuToolButton"} + + function newMenuTB(object icn=0, object lbl=0) + if string(icn) then + icn = create(GtkImage,icn,1) + end if + if string(lbl) then + lbl = allocate_string(lbl) + end if + atom btn = gtk_func("gtk_menu_tool_button_new",{P,P},{icn,lbl}) + return btn + end function + +widget[GtkToggleToolButton] = {"gtk_toggle_tool_button", +{GtkToolButton,GtkToolItem,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActivatable,GtkActionable,GObject}, + {"new",{S},-routine_id("newToggleToolButton")}, + {"set_active",{P,B}}, + {"get_active",{P},B}, +"GtkToggleToolButton"} + + function newToggleToolButton(object txt) + ---------------------------------------- + return gtk_func("gtk_toggle_tool_button_new_from_stock",{S},{txt}) + end function + +widget[GtkRadioToolButton] = {"gtk_radio_tool_button", +{GtkToggleToolButton,GtkToolButton,GtkToolItem,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActivatable,GtkActionable,GObject}, + {"new",{P},-routine_id("newRadioToolButton")}, + {"set_group",{P,P}}, + {"get_group",{P},P,0,GSList}, +"GtkRadioToolButton"} + + function newRadioToolButton(atom id) + ------------------------------------ + if classid(id) = GtkRadioToolButton then + return gtk_func("gtk_radio_tool_button_new_from_widget",{P},{id}) + else + return gtk_func("gtk_radio_tool_button_new",{P},{id}) + end if + end function + +widget[GtkSeparatorToolItem] = {"gtk_separator_tool_item", +{GtkToolItem,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActivatable,GObject}, + {"new",{},P}, + {"set_draw",{P,B}}, + {"get_draw",{P},B}, +"GtkSeparatorToolItem"} + +widget[GtkOverlay] = {"gtk_overlay", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"add_overlay",{P,P}}, +"GtkOverlay"} + +widget[GtkScrollable] = {"gtk_scrollable", +{GObject}, + {"set_hadjustment",{P,P}}, + {"get_hadjustment",{P},P,0,GtkAdjustment}, + {"set_vadjustment",{P,P}}, + {"get_vadjustment",{P},P,0,GtkAdjustment}, + {"set_hscroll_policy",{P,I}}, + {"get_hscroll_policy",{P},I}, + {"set_vscroll_policy",{P,I}}, + {"get_vscroll_policy",{P},I}, + {"get_border",{P,P},B}, -- 3.16 +"GtkScrollable"} + +widget[GtkScrolledWindow] = {"gtk_scrolled_window", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{P,P},P}, + {"set_hadjustment",{P,P}}, + {"get_hadjustment",{P},P,0,GtkAdjustment}, + {"set_vadjustment",{P,P}}, + {"get_vadjustment",{P},P,0,GtkAdjustment}, + {"get_hscrollbar",{P},P,0,GtkWidget}, + {"get_vscrollbar",{P},P,0,GtkWidget}, + {"set_policy",{P,I,I}}, + {"get_policy",{P,I,I}}, + {"set_placement",{P,I}}, + {"unset_placement",{P}}, + {"set_shadow_type",{P,I}}, + {"get_shadow_type",{P},I}, + {"set_min_content_width",{P,I}}, + {"get_min_content_width",{P},I}, + {"set_min_content_height",{P,I}}, + {"get_min_content_height",{P},I}, + {"set_kinetic_scrolling",{P,B}}, + {"get_kinetic_scrolling",{P},B}, + {"set_capture_button_press",{P,B}}, + {"get_capture_button_press",{P},B}, + {"set_headers",{P,P}}, + {"add_with_viewport",{P,P}}, -- Deprecated 3.8 + {"get_overlay_scrolling",{P},B}, -- 3.16 + {"set_overlay_scrolling",{P,B}}, -- 3.16 +"GtkScrolledWindow"} + +widget[GtkSidebar] = {"gtk_sidebar", -- 3.16 +{GtkBin,GtkContainer,GtkWidget,GObject}, + {"new",{},P}, + {"set_stack",{P,P}}, + {"get_stack",{P},P,0,GtkStack}, +"GtkSidebar"} + +widget[GtkTextBuffer] = {"gtk_text_buffer", +{GObject}, + {"new",{P},P}, + {"get_line_count",{P},I}, + {"get_char_count",{P},I}, + {"get_tag_table",{P},P,0,GtkTextTagTable}, + {"insert",{P,P,S,I}}, + {"insert_at_cursor",{P,S,I}}, + {"insert_interactive",{P,P,S,I,B},B}, + {"insert_interactive_at_cursor",{P,S,I,B},B}, + {"insert_range",{P,P,P,P}}, + {"insert_range_interactive",{P,P,P,P,B},B}, + {"insert_with_tags",{P,P,S,I,P,P}}, + {"insert_with_tags_by_name",{P,P,S,I,S}}, + {"insert_markup",{P,P,S,I}}, -- 3.16 + {"delete",{P,P,P}}, + {"delete_interactive",{P,P,P,B},B}, + {"backspace",{P,P,B,B},B}, + {"set_text",{P,P},-routine_id("setBufferText")}, + {"get_text",{P},-routine_id("getBufferText")}, + {"get_slice",{P,P,P,B},S}, + {"insert_pixbuf",{P,P,P}}, + {"insert_child_anchor",{P,P,P}}, + {"create_child_anchor",{P,P},P,0,GtkTextChildAnchor}, + {"create_mark",{P,S,P,B},P,0,GtkTextMark}, + {"move_mark",{P,P,P}}, + {"move_mark_by_name",{P,S,P}}, + {"add_mark",{P,P,P}}, + {"delete_mark",{P,P}}, + {"delete_mark_by_name",{P,S}}, + {"get_mark",{P,S},P,0,GtkTextMark}, + {"get_insert",{P},P,0,GtkTextMark}, + {"get_selection_bound",{P},P,0,GtkTextMark}, + {"get_selection_bounds",{P},-routine_id("getSelectionBounds")}, + {"get_has_selection",{P},B}, + {"place_cursor",{P,P}}, + {"select_range",{P,P,P}}, + {"apply_tag",{P,P,P,P}}, + {"remove_tag",{P,P,P,P}}, + {"apply_tag_by_name",{P,S,P,P}}, + {"remove_tag_by_name",{P,S,P,P}}, + {"remove_all_tags",{P,P,P}}, + {"create_tag",{P,S,S,S},P,0,GtkTextTag}, + {"get_iter_at_line_offset",{P,P,I,I}}, + {"get_iter_at_offset",{P,P,I}}, + {"get_iter_at_line",{P,P,I}}, + {"get_iter_at_line_index",{P,P,I,I}}, + {"get_iter_at_mark",{P,P,P}}, + {"get_iter_at_child_anchor",{P,P,P}}, + {"get_start_iter",{P,P}}, + {"get_end_iter",{P,P}}, + {"get_bounds",{P,P,P}}, + {"set_modified",{P,B}}, + {"get_modified",{P},B}, + {"delete_selection",{P,B,B},B}, + {"paste_clipboard",{P,P,P,B}}, + {"copy_clipboard",{P,P}}, + {"cut_clipboard",{P,P,B}}, + {"get_selection_bounds",{P,P,P},B}, + {"begin_user_action",{P}}, + {"end_user_action",{P}}, + {"add_selection_clipboard",{P,P}}, + {"remove_selection_clipboard",{P,P}}, + {"deserialize",{P,P,I,P,I,I,P},B}, + {"deserialize_set_can_create_tags",{P,I,B}}, + {"deserialize_get_can_create_tags",{P,I},B}, + {"get_copy_target_list",{P},P,0,GtkTargetList}, + {"get_deserialize_formats",{P,I},P}, + {"get_paste_target_list",{P},P,0,GtkTargetList}, + {"get_serialize_formats",{P,I},P}, + {"register_deserialize_format",{P,S,P,P,P},P}, + {"register_deserialize_tagset",{P,S},P}, + {"register_serialize_format",{P,S,P,P,P},P}, + {"register_serialize_tagset",{P,S},P}, + {"serialize",{P,P,P,P,P,I},I}, + {"unregister_deserialize_format",{P,P}}, + {"unregister_serialize_format",{P,P}}, + {"insert_markup",{P,P,S,I}}, +"GtkTextBuffer"} + + constant + fnBufStart = define_proc("gtk_text_buffer_get_start_iter",{P,P}), + fnBufEnd = define_proc("gtk_text_buffer_get_end_iter",{P,P}), + fnBufGet = define_func("gtk_text_buffer_get_text",{P,P,P,B},S), + fnBufSet = define_proc("gtk_text_buffer_set_text",{P,S,I}), + fnBufIns = define_func("gtk_text_buffer_get_insert",{P},P), + fnBufIter = define_proc("gtk_text_buffer_get_iter_at_mark",{P,P,P}), + fnBufBounds = define_func("gtk_text_buffer_get_selection_bounds",{P,P,P},B) + + function getBufferText(object buf) + ---------------------------------- + atom start = allocate(64) c_proc(fnBufStart,{buf,start}) + atom fini = allocate(64) c_proc(fnBufEnd,{buf,fini}) + object result = c_func(fnBufGet,{buf,start,fini,1}) + return peek_string(result) + end function + + function getSelectionBounds(object buf) + --------------------------------------- + atom start = allocate(100) + atom fini = allocate(100) + atom iter = allocate(100) + if c_func(fnBufBounds,{buf,start,fini}) then + return {start,fini} + else + start = c_func(fnBufIns,{buf}) + c_proc(fnBufIter,{buf,iter,start}) + return {iter,iter} + end if + end function + + function setBufferText(object buf, object txt) + object len + if atom(txt) then + len = peek_string(txt) + len = length(len) + else + len = length(txt) + txt = allocate_string(txt) + end if + c_proc(fnBufSet,{buf,txt,len}) + return 1 + end function + +widget[GtkClipboard] = {"gtk_clipboard", +{GObject}, + {"new",{I},-routine_id("newClipBoard")}, + {"get_default",{P},P,0,GtkClipboard}, + {"get_for_display",{P,I},P,0,GtkClipboard}, + {"get_display",{P},P,0,GdkDisplay}, + {"set_with_data",{P,P,I,P,P,P},B}, + {"set_with_owner",{P,P,I,P,P,P},B}, + {"get_owner",{P},P,0,GObject}, + {"clear",{P}}, + {"set_text",{P,S,I}}, + {"set_image",{P,P}}, + {"request_contents",{P,I,P,P}}, + {"request_text",{P,P,P}}, + {"request_image",{P,P,P}}, + {"request_targets",{P,P,P}}, + {"request_rich_text",{P,P,P,P}}, + {"request_uris",{P,P,P}}, + {"wait_for_contents",{P,I},P,0,GtkSelectionData}, + {"wait_for_text",{P},S}, + {"wait_for_image",{P},P,0,GdkPixbuf}, + {"wait_for_rich_text",{P,P,I,I},I}, + {"wait_for_uris",{P},A}, + {"wait_is_text_available",{P},B}, + {"wait_is_image_available",{P},B}, + {"wait_is_rich_text_available",{P,P},B}, + {"wait_is_uris_available",{P},B}, + {"wait_for_targets",{P,P,I},B}, + {"wait_is_target_available",{P,I},B}, + {"set_can_store",{P,P,I}}, + {"store",{P}}, +"GtkClipboard"} + + function newClipBoard(integer i) + -------------------------------- + return gtk_func("gtk_clipboard_get",{I},{i}) + end function + +widget[GtkSelectionData] = {"gtk_selection_data", +{0}, + {"set",{P,I,I,S,I}}, + {"set_text",{P,S,I},B}, + {"get_text",{P},S}, + {"set_pixbuf",{P,P},B}, + {"get_pixbuf",{P},P,0,GdkPixbuf}, + {"set_uris",{P,S},B}, + {"get_uris",{P},A}, + {"get_targets",{P,P,I},B}, + {"targets_include_image",{P,B},B}, + {"targets_include_text",{P},B}, + {"targets_include_uri",{P},B}, + {"targets_include_rich_text",{P,P},B}, + {"get_selection",{P},P}, + {"get_data",{P},S}, + {"get_length",{P},I}, + {"get_data_with_length",{P,I},S}, + {"get_data_type",{P},I}, + {"get_display",{P},P,0,GdkDisplay}, + {"get_format",{P},I}, + {"get_target",{P},I}, +"GtkSelectionData"} + +widget[GtkCellArea] = {"gtk_cell_area", +{GtkCellLayout,GtkBuildable,GObject}, + {"add",{P,P}}, + {"remove",{P,P}}, + {"has_renderer",{P,P},B}, + {"foreach",{P,P}}, + {"foreach_alloc",{P,P,P,P,P,P,P}}, + {"event",{P,P,P,P,P,I},I}, + {"render",{P,P,P,P,P,P,I,B}}, + {"get_cell_allocation",{P,P,P,P,P,P}}, + {"get_cell_at_position",{P,P,P,P,I,I,P},P,0,GtkCellRenderer}, + {"create_context",{P},P,0,GtkCellAreaContext}, + {"copy_context",{P,P},P,0,GtkCellAreaContext}, + {"get_request_mode",{P},I}, + {"get_preferred_width",{P,P,P,I,I}}, + {"get_preferred_height_for_width",{P,P,P,I,I,I}}, + {"get_preferred_height",{P,P,P,I,I}}, + {"get_preferred_width_for_height",{P,P,P,I,I,I}}, + {"get_current_path",{P},S}, + {"apply_attributes",{P,P,P,B,B}}, + {"attribute_connect",{P,P,S,I}}, + {"attribute_disconnect",{P,P,S}}, + {"is_activatable",{P},B}, + {"focus",{P,I},B}, + {"set_focus_cell",{P,P}}, + {"get_focus_cell",{P},P,0,GtkCellRenderer}, + {"add_focus_sibling",{P,P,P}}, + {"remove_focus_sibling",{P,P,P}}, + {"is_focus_sibling",{P,P,P},B}, + {"get_focus_siblings",{P,P},P,0,GSList}, + {"get_focus_from_sibling",{P,P},P,0,GtkCellRenderer}, + {"get_edited_cell",{P},P,0,GtkCellRenderer}, + {"get_edit_widget",{P},P,0,GtkCellEditable}, + {"stop_editing",{P,B}}, + {"request_renderer",{P,P,P,P,I,I,I}}, +"GtkCellArea"} + +widget[GtkCellAreaCell] = {"gtk_cell_area_cell", +{GtkCellArea}, + {"set_property",{P,P,S,P}}, + {"get_property",{P,P,S,P}}, +"GtkCellAreaCell"} + +widget[GtkCellAreaBox] = {"gtk_cell_area_box", +{GtkCellArea,GtkCellLayout,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"pack_start",{P,P,B,B,B}}, + {"pack_end",{P,P,B,B,B}}, + {"set_spacing",{P,I}}, + {"get_spacing",{P},I}, +"GtkCellAreaBox"} + +widget[GtkCellAreaContext] = {"gtk_cell_area_context", +{GObject}, + {"get_area",{P},P,0,GtkCellArea}, + {"allocate",{P,I,I}}, + {"reset",{P}}, + {"get_preferred_width",{P,I,I}}, + {"get_preferred_height",{P,I,I}}, + {"get_preferred_height_for_width",{P,I,I,I}}, + {"get_preferred_width_for_height",{P,I,I,I}}, + {"get_allocation",{P,I,I}}, + {"push_preferred_width",{P,I,I}}, + {"push_preferred_height",{P,I,I}}, +"GtkCellAreaContext"} + +widget[GtkCellEditable] = {"gtk_cell_editable", +{GtkWidget}, + {"start_editing",{P,P}}, + {"editing_done",{P}}, + {"remove_widget",{P}}, +"GtkCellEditable"} + +widget[GtkCellLayout] = {"gtk_cell_layout", +{GObject}, + {"pack_start",{P,P,B}}, + {"pack_end",{P,P,B}}, + {"get_area",{P},P,0,GtkCellArea}, + {"get_cells",{P},P,0,GList}, + {"reorder",{P,P,I}}, + {"clear",{P}}, + {"add_attribute",{P,P,S,I}}, + {"set_cell_data_func",{P,P,P,P,P}}, + {"clear_attributes",{P,P}}, +"GtkCellLayout"} + +widget[GtkCellRenderer] = {"gtk_cell_renderer", +{GObject}, + {"set_fixed_size",{P,I,I}}, + {"get_fixed_size",{P,I,I}}, + {"set_visible",{P,B}}, + {"get_visible",{P},B}, + {"set_sensitive",{P,B}}, + {"get_sensitive",{P},B}, + {"set_alignment",{P,F,F}}, + {"get_alignment",{P,F,F}}, + {"set_padding",{P,I,I}}, + {"get_padding",{P,I,I}}, + {"get_state",{P,P,I},I}, + {"is_activatable",{P},B}, + {"get_aligned_area",{P,P,I,P,P}}, + {"render",{P,P,P,P,P,I}}, + {"activate",{P,P,P,P,P,P,I},B}, + {"start_editing",{P,P,P,P,P,P,I},P,0,GtkCellEditable}, + {"stop_editing",{P,B}}, + {"get_preferred_height",{P,P,I,I}}, + {"get_preferred_width",{P,P,I,I}}, + {"get_preferred_height_for_width",{P,P,I,I,I}}, + {"get_preferred_width_for_height",{P,P,I,I,I}}, + {"get_preferred_size",{P,P,P,P}}, + {"get_request_mode",{P},I}, +"GtkCellRenderer"} + +widget[GtkCellRendererAccel] = {"gtk_cell_renderer_accel", +{GtkCellRendererText,GtkCellRenderer,GObject}, + {"new",{},P}, +"GtkCellRendererAccel"} + +widget[GtkCellRendererCombo] = {"gtk_cell_renderer_combo", +{GtkCellRendererText,GtkCellRenderer,GObject}, + {"new",{},P}, +"GtkCellRendererCombo"} + +widget[GtkCellRendererText] = {"gtk_cell_renderer_text", +{GtkCellRenderer,GObject}, + {"new",{},P}, + {"set_fixed_height_from_font",{P,I}}, +"GtkCellRendererText"} + +widget[GtkCellRendererPixbuf] = {"gtk_cell_renderer_pixbuf", +{GtkCellRenderer,GObject}, + {"new",{},P}, +"GtkCellRendererPixbuf"} + +widget[GtkCellRendererProgress] = {"gtk_cell_renderer_progress", +{GtkOrientable,GtkCellRenderer,GObject}, + {"new",{},P}, +"GtkCellRendererProgress"} + +widget[GtkCellRendererSpin] = {"gtk_cell_renderer_spin", +{GtkCellRendererText,GtkCellRenderer,GObject}, + {"new",{},P}, +"GtkCellRendererSpin"} + +widget[GtkCellRendererSpinner] = {"gtk_cell_renderer_spinner", +{GtkCellRenderer,GObject}, + {"new",{},P}, +"GtkCellRendererSpinner"} + +widget[GtkCellRendererToggle] = {"gtk_cell_renderer_toggle", +{GtkCellRenderer,GObject}, + {"new",{},P}, + {"set_radio",{P,B}}, + {"get_radio",{P},B}, + {"set_active",{P,B}}, + {"get_active",{P},B}, + {"set_activatable",{P,B}}, + {"get_activatable",{P},B}, +"GtkCellRendererToggle"} + +widget[GtkTreeModelFilter] = {"gtk_tree_model_filter", +{GtkTreeModel,GtkTreeDragSource,GObject}, + {"new",{P,P},P}, + {"set_visible_func",{P,P,P,P}}, + {"set_modify_func",{P,I,P,P,P,P}}, + {"set_visible_column",{P,I}}, + {"get_model",{P},P,0,GtkTreeModel}, + {"convert_child_iter_to_iter",{P,P,P},B}, + {"convert_iter_to_child_iter",{P,P,P},B}, + {"convert_child_path_to_path",{P,P},P,0,GtkTreePath}, + {"convert_path_to_child_path",{P,P},P,0,GtkTreePath}, + {"refilter",{P}}, + {"clear_cache",{P}}, +"GtkTreeModelFilter"} + +widget[GtkTreeModelSort] = {"gtk_tree_model_sort", +{GtkTreeModel,GtkTreeSortable,GtkTreeDragSource,GObject}, + {"new_with_model",{P},P}, + {"get_model",{P},P,0,GtkTreeModel}, + {"convert_child_path_to_path",{P,P},P,0,GtkTreePath}, + {"convert_child_iter_to_iter",{P,P,P},B}, + {"convert_path_to_child_path",{P,P},P,0,GtkTreePath}, + {"convert_iter_to_child_iter",{P,P,P}}, + {"reset_default_sort_func",{P}}, + {"clear_cache",{P}}, +"GtkTreeModelSort"} + +widget[GtkListStore] = {"gtk_list_store", -- HEAVILY-MODIFIED 4.8.2 +{GtkTreeModel,GtkTreeSortable,GtkTreeDragSource,GtkTreeDragDest,GtkBuildable,GObject}, + {"new",{P},-routine_id("newListStore")}, + {"clear",{P}}, + {"set_data",{P,P},-routine_id("setListData")}, + {"get_data",{P},-routine_id("getListData")}, + {"get_n_rows",{P},-routine_id("nListRows")}, + {"get_n_cols",{P},-routine_id("nListCols")}, + {"set_row_data",{P,I,P},-routine_id("setListRowData")}, + {"get_row_data",{P,I},-routine_id("getListRowData")}, + {"set_col_data",{P,I,I,P},-routine_id("setListColData")}, + {"get_col_data",{P,I,I},-routine_id("getListColData")}, + {"get_col_data_from_iter",{P,P,I},-routine_id("getListColDatafromIter")}, + {"remove_row",{P,I},-routine_id("removeListRow")}, + {"replace_row",{P,I,P},-routine_id("replaceListRow")}, + {"insert_row",{P,I,P},-routine_id("insertListRow")}, + {"prepend_row",{P,P},-routine_id("prependListRow")}, + {"append_row",{P,P},-routine_id("appendListRow")}, + {"set_swap_rows",{P,I,I},-routine_id("swapListRows")}, + {"set_move_before",{P,I,I},-routine_id("movebeforeListRows")}, + {"set_move_after",{P,I,I},-routine_id("moveafterListRows")}, + {"set_move_after",{P,I,I},-routine_id("moveafterListRows")}, +"GtkListStore"} + +-- almost all calls to GtkListStore are overridden with Euphoria calls, +-- because the GTK versions are just too complex and tedious to set up, +-- making them impractical to use. +constant + TM1 = define_func("gtk_tree_model_get_iter_first",{P,P},I), + TM2 = define_func("gtk_tree_model_iter_next",{P,P},I), + TM3 = define_func("gtk_tree_model_get_iter_from_string",{P,P,P},P), + TM4 = define_proc("gtk_tree_model_get",{P,P,I,P,I}), + TM5 = define_func("gtk_tree_model_get_column_type",{P,I},I), + LS0 = define_proc("gtk_list_store_clear",{P}), + LS1 = define_proc("gtk_list_store_insert",{P,P,I}), + LS2 = define_proc("gtk_list_store_append",{P,P}), + LS3 = define_proc("gtk_list_store_swap",{P,P,P}), + LS4 = define_proc("gtk_list_store_move_before",{P,P,P}), + LS5 = define_proc("gtk_list_store_move_after",{P,P,P}), + LS6 = define_func("gtk_list_store_iter_is_valid",{P,P},B), + $ + + function newListStore(object params) + ------------------------------------ + object proto = I & repeat(P,length(params)) + params = length(params) & params -- must build func params 'on the fly' + atom fn = define_func("gtk_list_store_new",proto,P) + return c_func(fn,params) + end function + + function nListRows(object store) + -------------------------------- + return gtk_func("gtk_tree_model_iter_n_children",{P,P},{store,0}) + end function + + function nListCols(object store) + -------------------------------- + return gtk_func("gtk_tree_model_get_n_columns",{P},{store}) + end function + + function setListData(object store, object data) + ----------------------------------------------- + atom iter = allocate(32) + integer len = length(data) + for row = 1 to len do + c_proc(LS1,{store,iter,len}) -- new row + if gtk_func("gtk_list_store_iter_is_valid",{P,P},{store,iter}) = 0 + then display("Error in setlistdata []",data[row]) abort(0) + end if + if string(data[row]) then + setListRowData(store,row,{data[row]}) + else + setListRowData(store,row,data[row]) + end if + end for + return 1 + end function + + function setListRowData(atom store, integer row, object data) + ----------------------------------------------------------- + integer max_col = nListCols(store) + for col = 1 to math:min({length(data),max_col}) do + setListColData(store,row,col,data[col]) + end for + return 1 + end function + + function setListColData(object store, object row, integer col, object data) + ---------------------------------------------------------------------------- + integer max_col = nListCols(store) + if col < 1 or col > max_col then + crash("Invalid column #%d",col) + end if + + atom iter = allocate(32) + if not c_func(TM3,{store,iter,allocate_string(sprintf("%d",row-1))}) then + return -1 + end if + + object prototype = {P,P,I,P,I} + + integer col_type = c_func(TM5,{store,col-1}) + + switch col_type do + case gSTR then prototype = {P,P,I,S,I} + case gDBL then prototype = {P,P,I,D,I} + case gFLT then prototype = {P,P,I,D,I} + case gPIX then prototype = {P,P,I,P,I} + case gINT then prototype = {P,P,I,I,I} + case gBOOL then prototype = {P,P,I,I,I} + case else display("Error in setlistcoldata 5 []",col_type) abort(0) + end switch + + if string(data) then data = allocate_string(data) end if + atom fn = define_proc("gtk_list_store_set",prototype) + object params = {store,iter,col-1,data,-1} + c_proc(fn,params) + + return 1 + end function + + function getListData(object store) + ---------------------------------- + object data = {} + for row = 1 to nListRows(store) do + data = append(data,getListRowData(store,row)) + end for + return data + end function + + function getListRowData(object store, integer row) + ------------------------------------------------ + object data = {} + integer max_row = nListRows(store) + if row > max_row then return -1 end if + + integer max_col = nListCols(store) + for i = 1 to max_col do + data = append(data,getListColData(store,row,i)) + end for + return data + end function + + function getListColData(atom store, integer row, integer col) + ----------------------------------------------------------- + atom x = allocate(64) + object result + + ifdef LISTSTORE then + if col = 2 then + display("Get Col Data ~ row [] col []",{row,col}) + end if + end ifdef + + integer col_type = c_func(TM5,{store,col-1}) + ifdef BITS64 then + poke8(x,col_type) + elsedef + poke4(x,col_type) + end ifdef + + atom iter = allocate(32) + + c_func(TM3,{store,iter,allocate_string(sprintf("%d",row-1))}) + if gtk_func("gtk_list_store_iter_is_valid",{P,P},{store,iter}) = 0 then + display("Error in getlistcoldata 2 ") abort(0) end if + + c_proc(TM4,{store,iter,col-1,x,-1}) + if gtk_func("gtk_list_store_iter_is_valid",{P,P},{store,iter}) = 0 then + display("Error in getlistcoldata 3") abort(0) end if + + switch col_type do + case gSTR then + ifdef BITS64 then -- thanks pete eberlein + result = peek8u(x) + elsedef + result = peek4u(x) + end ifdef + if result > 0 then + result = peek_string(result) + end if + case gINT then result = peek4u(x) + case gBOOL then result = peek(x) + case gDBL then result = float64_to_atom(peek({x,8})) + case gFLT then result = float32_to_atom(peek({x,4})) + case gPIX then result = peek4u(x) + case else display("Error in getlistcoldata 4") abort(0) + end switch + ifdef LISTSTORE then + if col = 2 then + display("Result [] getListColData",{result}) + end if + end ifdef + return result + end function + + function getListColDatafromIter(atom store, atom iter, integer col) + ------------------------------------------------------------------- + atom x = allocate(32) + object result + + ifdef LISTSTORE then + if col = 2 then + display("Get Col Data from Iter ~ store [] iter [] col []\n",{store,iter,col}) + end if + end ifdef + + integer col_type = c_func(TM5,{store,col-1}) + ifdef BITS64 then + poke8(x,col_type) + elsedef + poke4(x,col_type) + end ifdef + + if gtk_func("gtk_list_store_iter_is_valid",{P,P},{store,iter}) = 0 then + display("Error in getlistcoldatafromiter 1 ") abort(0) end if + + c_proc(TM4,{store,iter,col-1,x,-1}) + if gtk_func("gtk_list_store_iter_is_valid",{P,P},{store,iter}) = 0 then + display("Error in getlistcoldatafromiter 2 ") abort(0) end if + + switch col_type do + case gSTR then + if peek4u(x) > 0 then result = peek_string(peek4u(x)) + else result = "err 1" end if + case gINT then result = peek4u(x) + case gBOOL then result = peek(x) + case gDBL then result = float64_to_atom(peek({x,8})) + case gFLT then result = float32_to_atom(peek({x,4})) + case gPIX then result = peek4u(x) + case else display("Error in getlistcoldatafromiter 3") abort(0) + end switch + ifdef LISTSTORE then + if col = 2 then + display("Result [] getListColDataFromIter",{result}) + end if + end ifdef + return result + end function + + function insertListRow(object store, object data, integer pos) + -------------------------------------------------------------- + object tmp = getListData(store) + tmp = insert(tmp,data,pos) + set(store,"clear") + setListData(store,tmp) + return tmp + end function + + function appendListRow(atom store, object data) + ----------------------------------------------- + object tmp = getListData(store) + tmp = append(tmp,data) + set(store,"clear") + set(store,"data",tmp) + return tmp + end function + + function prependListRow(atom store, object data) + ------------------------------------------------ + object tmp = getListData(store) + tmp = prepend(tmp,data) + set(store,"clear") + set(store,"data",tmp) + return tmp + end function + + function removeListRow(atom store, integer row) + ----------------------------------------------- + object tmp = getListData(store) + tmp = remove(tmp,row) + set(store,"clear") + setListData(store,tmp) + return tmp + end function + + function replaceListRow(atom store, object data, integer row) + ------------------------------------------------------------- + object tmp = getListData(store) + set(store,"clear") + tmp = replace(tmp,{data},row) + setListData(store,tmp) + return tmp + end function + + function swapListRows(atom store, integer row_a, integer row_b) + --------------------------------------------------------------- + if get(store,"is sorted") then + Warn(0,,"Can't move items in a sorted list!") + return -1 + end if + atom iter_a = allocate(32), iter_b = allocate(32) + c_func(TM3,{store,iter_a,allocate_string(sprintf("%d",row_a-1))}) + c_func(TM3,{store,iter_b,allocate_string(sprintf("%d",row_b-1))}) + c_proc(LS3,{store,iter_a,iter_b}) + return get(store,"data") + end function + + function movebeforeListRows(atom store, integer row_a, integer row_b) + --------------------------------------------------------------------- + if get(store,"is sorted") then + Error(0,,"Can't move items in a sorted list!") + return -1 + end if + atom iter_a = allocate(32), iter_b = allocate(32) + c_func(TM3,{store,iter_a,allocate_string(sprintf("%d",row_a-1))}) + c_func(TM3,{store,iter_b,allocate_string(sprintf("%d",row_b-1))}) + c_proc(LS4,{store,iter_b,iter_a}) + return get(store,"data") + end function + + function moveafterListRows(atom store, integer row_a, integer row_b) + -------------------------------------------------------------------- + if get(store,"is sorted") then + Error(0,,"Can't move items in a sorted list!") + return -1 + end if + atom iter_a = allocate(32), iter_b = allocate(32) + c_func(TM3,{store,iter_a,allocate_string(sprintf("%d",row_a-1))}) + c_func(TM3,{store,iter_b,allocate_string(sprintf("%d",row_b-1))}) + c_proc(LS5,{store,iter_b,iter_a}) + return get(store,"data") + end function + +widget[GtkTreeStore] = {"gtk_tree_store", +{GtkTreeModel,GtkTreeDragSource,GtkTreeDragDest,GtkTreeSortable,GtkBuildable,GObject}, + {"new",{P},-routine_id("newTreeStore")}, + {"get_n_rows",{P},-routine_id("nTreeRows")}, + {"get_n_cols",{P},-routine_id("nTreeCols")}, + {"get_data",{P},-routine_id("getTreeData")}, + {"set_data",{P,P},-routine_id("setTreeData")}, + {"set_row_data",{P,P,P},-routine_id("setTreeRowData")}, + {"remove_row",{P,I},-routine_id("removeTreeRow")}, + {"insert_row",{P,P,P,I}}, + {"insert_before",{P,P,P,P}}, + {"insert_after",{P,P,P,P}}, + {"prepend",{P,P,P}}, + {"append",{P,P,P}}, + {"is_ancestor",{P,P,P},B}, + {"iter_depth",{P,P},I}, + {"clear",{P}}, + {"swap",{P,P,P}}, + {"move_before",{P,P,P}}, + {"move_after",{P,P,P}}, +"GtkTreeStore"} + + constant TSA = define_proc("gtk_tree_store_append",{P,P,P}) + constant TSX = define_proc("gtk_tree_store_insert",{P,P,P,I}) + + function newTreeStore(object params) + ------------------------------------ + object proto = I & repeat(P,length(params)) + params = length(params) & params -- must build func params 'on the fly' + atom fn = define_func("gtk_tree_store_new",proto,P) + return c_func(fn,params) + end function + + function nTreeRows(object store) + -------------------------------- + return gtk_func("gtk_tree_model_iter_n_children",{P,P},{store,0}) + end function + + function nTreeCols(object store) + -------------------------------- + return gtk_func("gtk_tree_model_get_n_columns",{P},{store}) + end function + + function setTreeData(object store, object data) + ----------------------------------------------- + atom iter = allocate(32) + puts(1,"\n") + for row = 1 to length(data) do + c_proc(TSA,{store,iter,0}) -- append new row + setTreeRowData(store,data[row],iter) + end for + return 1 + end function + + function setTreeRowData(atom store, object data, object parent = 0) + -------------------------------------------------------------------------- + atom iter1 = allocate(32) + atom iter2 = allocate(32) + atom iter3 = allocate(32) + atom iter4 = allocate(32) + for i = 1 to length(data) do + if string(data[i]) then + setTreeColData(store,parent,i,data[i]) + else + for j = 1 to length(data[i]) do + if string(data[i][j]) then + c_proc(TSA,{store,iter1,parent}) + setTreeColData(store,iter1,1,data[i][j]) + else + for k = 1 to length(data[i][j]) do + if string(data[i][j][k]) then + c_proc(TSA,{store,iter2,iter1}) + setTreeColData(store,iter2,1,data[i][j][k]) + else + for l = 1 to length(data[i][j][k]) do + if string(data[i][j][k][l]) then + c_proc(TSA,{store,iter3,iter2}) + setTreeColData(store,iter3,1,data[i][j][k][l]) + else + for m = 1 to length(data[i][j][k][l]) do + c_proc(TSA,{store,iter4,iter3}) + setTreeColData(store,iter4,1,data[i][j][k][l][m]) + end for + end if + end for + end if + end for + end if + end for + end if + end for + return 1 + end function + + function setTreeColData(object store, object iter, integer col, object item) + ---------------------------------------------------------------------------- + integer max_col = nTreeCols(store) + if col < 1 or col > max_col then + crash("Invalid column #%d",col) + end if + + object prototype = {P,P,I,P,I} + + integer col_type + + col_type = c_func(TM5,{store,col-1}) + switch col_type do + case gDBL then prototype = {P,P,I,D,I} + case gFLT then prototype = {P,P,I,D,I} + case gPIX then prototype = {P,P,I,P,I} + case gINT then prototype = {P,P,I,I,I} + case gBOOL then prototype = {P,P,I,I,I} + case gSTR then prototype = {P,P,I,P,I} + if atom(item) then item = sprintf("%g",item) end if + case else Warn(,,"Unknown column type", + "Expecting gSTR, gBOOL, gINT, gDBL, gFLT, or gPIX") + end switch + + if string(item[1]) then item = item[1] end if + if string(item) then item = allocate_string(item) end if + + atom fn = define_proc("gtk_tree_store_set",prototype) + object params = {store,iter,col-1,item,-1} + c_proc(fn,params) + + return iter + end function + + function getTreeData(atom store) + -------------------------------- + object rowdata = {} + object column = {} + for row = 1 to nTreeRows(store) do + for col = 1 to nTreeCols(store) do + column = append(column,get(store,"col data",col)) + end for + rowdata = append(rowdata,column) + column = {} + end for + return rowdata + end function + + function removeTreeRow(atom store, integer row) + ----------------------------------------------- + object tmp = get(store,"data") + tmp = remove(tmp,row) + set(store,"data",tmp) + return tmp + end function + +widget[GtkTreeDragSource] = {"gtk_tree_drag_source", +{0}, +"GtkTreeDragSource"} + +widget[GtkTreeDragDest] = {"gtk_tree_drag_dest", +{0}, +"GtkTreeDragDest"} + +widget[GtkTreePath] = {"gtk_tree_path", +{GObject}, + {"new",{P},-routine_id("newPath")}, + {"to_string",{P},S}, + {"to_integer",{P},-routine_id("pathtoNumber")}, + {"new_first",{},P,0,GtkTreePath}, + {"append_index",{P,I}}, + {"prepend_index",{P,I}}, + {"get_depth",{P},I}, + {"get_indices",{P},A}, + {"get_indices_with_depth",{P,I},A}, + {"free",{P}}, + {"copy",{P},P,0,GtkTreePath}, + {"compare",{P,P},I}, + {"next",{P}}, + {"prev",{P},B}, + {"up",{P},B}, + {"down",{P}}, + {"is_ancestor",{P,P},B}, + {"is_descendant",{P,P},B}, +"GtkTreePath"} + + function newPath(object x=0) + ---------------------------- + if atom(x) and x > 0 then + x = sprintf("%d",x-1) + end if + if string(x) then + x = allocate_string(x) + end if + if x > 0 then + return gtk_func("gtk_tree_path_new_from_string",{P},{x}) + else + return gtk_func("gtk_tree_path_new",{},{}) + end if + end function + + function pathtoNumber(object x) + ------------------------------- + integer n = to_number(gtk_str_func("gtk_tree_path_to_string",{P},{x})) + return n+1 + end function + +widget[GtkTreeRowReference] = {"gtk_tree_row_reference", +{GObject}, + {"new",{P,P},P,0,GtkTreeRowReference}, + {"get_model",{P},P,0,GtkTreeModel}, + {"get_path",{P},P,0,GtkTreePath}, + {"valid",{P},B}, + {"free",{P}}, + {"copy",{P},P,0,GtkTreeRowReference}, + {"inserted",{P,P}}, + {"deleted",{P,P}}, + {"reordered",{P,P,P,A}}, +"GtkTreeRowReference"} + +widget[GtkTreeIter] = {"gtk_tree_iter", +{GObject}, + {"new",{},-routine_id("newIter")}, + {"copy",{P},P,0,GtkTreeIter}, + {"free",{P}}, +"GtkTreeIter"} + + function newIter() + ------------------ + return allocate(64) + end function + +widget[GtkTreeModel] = {"gtk_tree_model", +{GObject}, + {"get_flags",{P},I}, + {"get_n_columns",{P},I}, + {"get_column_type",{P,I},I}, + {"get_iter",{P,P,P},B}, + {"get_iter_first",{P,P},B}, + {"get_path",{P,P},P,0,GtkTreePath}, + {"get_value",{P,P,I},-routine_id("getTMVal")}, + {"set_value",{P,I,I,P},-routine_id("setTMColVal")}, + {"iter_next",{P,P},B}, + {"iter_previous",{P,P},B}, + {"iter_children",{P,P,P},B}, + {"iter_has_child",{P,P},B}, + {"iter_n_children",{P,P},I}, + {"iter_nth_child",{P,P,P,I},B}, + {"iter_parent",{P,P,P},B}, + {"get_string_from_iter",{P,P},-routine_id("tmStrIter")}, + {"ref_node",{P,P}}, + {"unref_node",{P,P}}, + {"foreach",{P,P,P}}, + {"n_rows",{P},-routine_id("getTMnRows")}, + {"row_changed",{P,P,P}}, + {"row_inserted",{P,P,P}}, + {"row_has_child_toggled",{P,P,P}}, + {"row_deleted",{P,P}}, + {"rows_reordered",{P,P,P,P}}, + {"get_iter_n",{P,I},-routine_id("tmIterN")}, + {"get_iter_from_string",{P,S},-routine_id("tmIterStr")}, + {"get_iter_from_path",{P,P},-routine_id("tmIterPath")}, + {"get_col_value",{P,P,I},-routine_id("tmColVal")}, + {"get_row_values",{P,P},-routine_id("tmRowVals")}, + {"get_col_data",{P,P,I},-routine_id("getTreeModelCol")}, + {"get_row_data",{P,I},-routine_id("getTreeModelRow")}, +"GtkTreeModel"} + + constant + tmstriter = define_func("gtk_tree_model_get_string_from_iter",{P,P},P), + tmiterstr = define_func("gtk_tree_model_get_iter_from_string",{P,S,P},P), + tmcolset = define_proc("gtk_list_store_set",{P,P,I,P,I}), + tmnrows = define_func("gtk_tree_model_iter_n_children",{P,P},I) + + function getTMnRows(atom model) + return c_func(tmnrows,{model,0}) + end function + + function tmStrIter(atom model, atom iter) + return peek_string(c_func(tmstriter,{model,iter})) + end function + + function tmIterStr(atom model, object str) + ------------------------------------------ + atom iter = newIter() + if string(str) then str = allocate_string(str) end if + if c_func(tmiterstr,{model,iter,str}) then + return iter + end if + return 0 + end function + + function tmIterN(atom model, integer path) + ------------------------------------------ + return tmIterStr(model,sprintf("%d",path-1)) + end function + + function tmIterPath(atom model, object path) + -------------------------------------------- + return tmIterStr(model,peek_string(path)) + end function + + constant + fntmget = define_proc("gtk_tree_model_get_value",{P,P,I,P}), + fncoltype = define_func("gtk_tree_model_get_column_type",{P,I},I), + gtvfn = define_proc("gtk_tree_model_get",{P,P,I,P,I}), + tmncol = define_func("gtk_tree_model_get_n_columns",{P},I) + + function getTMVal(atom mdl, atom iter, integer col) + --------------------------------------------------- + atom x = allocate(64) + integer ct = c_func(fncoltype,{mdl,col-1}) + ifdef BITS64 then + poke8(x,ct) + elsedef + poke4(x,ct) + end ifdef + c_proc(gtvfn,{mdl,iter,col-1,x,-1}) + switch ct do + case gSTR then + if peek4u(x) != 0 then return peek_string(peek4u(x)) + else return sprintf("%d",peek4u(x)) + end if + case gINT then return peek4u(x) + case gBOOL then return peek4u(x) + case gFLT then return float32_to_atom(peek({x,4})) + case gPIX then return peek4u(x) + case else return sprintf("%d",x) + end switch + return sprintf("Oops %d",ct) + end function + + function tmRowVals(atom mdl, atom iter) + --------------------------------------- + integer ncols = c_func(tmncol,{mdl}) + object results = repeat(0,ncols) + for n = 1 to ncols do + results[n] = getTMVal(mdl,iter,n) + end for + return results + end function + + function tmColVal(atom mdl, integer row, integer col) + ----------------------------------------------------- + atom iter = allocate(32) + object data = tmRowVals(mdl,iter) + return data[col] + end function + + function setTMColVal(atom mdl, integer row, integer col, object data) + --------------------------------------------------------------------- + atom iter = tmIterN(mdl,row) + c_proc(tmcolset,{mdl,iter,col-1,allocate_string(data),-1}) + return 1 + end function + + function getTreeModelCol(atom mdl, integer row, integer col) + ------------------------------------------------------------ + object data = getTreeModelRow(mdl,row) + return data[col] + end function + + function getTreeModelRow(atom mdl, integer row) + ----------------------------------------------- + atom iter = tmIterN(mdl,row) + return tmRowVals(mdl,iter) + end function + +widget[GtkTreeSortable] = {"gtk_tree_sortable", +{GtkTreeModel,GObject}, + {"sort_column_changed",{P}}, + {"set_sort_column_id",{P,I,I}}, + {"get_sort_column_id",{P},-routine_id("TSgetSortColID")}, + {"get_sort_order",{P},-routine_id("TSgetSortOrder")}, + {"is_sorted",{P},-routine_id("TSisSorted")}, + {"set_sort_func",{P,I,P,P,P}}, + {"set_default_sort_func",{P,P,P,P}}, + {"has_default_sort_func",{P},B}, +"GtkTreeSortable"} + + constant TS1 = define_func("gtk_tree_sortable_get_sort_column_id",{P,P,P},B) + + function TSisSorted(atom mdl) + ----------------------------- + return gtk_func("gtk_tree_sortable_get_sort_column_id",{P,P,P},{mdl,0,0}) + end function + + function TSsetSortColID(atom mdl, integer col, integer order) + ------------------------------------------------------------- + gtk_proc("gtk_tree_sortable_set_sort_column_id",{P,I,I},{mdl,col-1,order}) + return 1 + end function + + function TSgetSortColID(atom mdl) + --------------------------------- + integer col = allocate(32), order = allocate(32) + if c_func(TS1,{mdl,col,order}) then + return peek4u(col)+1 + else + return 0 + end if + end function + + function TSgetSortOrder(atom mdl) + --------------------------------- + integer col = allocate(32), order = allocate(32) + if c_func(TS1,{mdl,col,order}) then + return peek4u(order) + else + return 0 + end if + end function + +widget[GtkViewport] = {"gtk_viewport", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkScrollable,GObject}, + {"new",{P,P},P}, + {"set_shadow_type",{P,I}}, + {"get_shadow_type",{P},I}, + {"get_bin_window",{P},P,0,GdkWindow}, + {"get_view_window",{P},P,0,GdkWindow}, +"GtkViewport"} + +widget[GtkAppChooserWidget] = {"gtk_app_chooser_widget", +{GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GtkAppChooser,GObject}, + {"new",{S},P}, + {"set_show_default",{P,B}}, + {"get_show_default",{P},B}, + {"set_show_recommended",{P,B}}, + {"get_show_recommended",{P},B}, + {"set_show_fallback",{P,B}}, + {"get_show_fallback",{P},B}, + {"set_show_other",{P,B}}, + {"get_show_other",{P},B}, + {"set_show_all",{P,B}}, + {"get_show_all",{P},B}, + {"set_default_text",{P,S}}, + {"get_default_text",{P},S}, +"GtkAppChooserWidget"} + +widget[GtkVolumeButton] = {"gtk_volume_button", +{GtkScaleButton,GtkButton,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GtkActionable,GtkActivatable,GObject}, + {"new",{},P}, +"GtkVolumeButton"} + +widget[GtkColorChooserWidget] = {"gtk_color_chooser_widget", +{GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GtkColorChooser,GObject}, + {"new",{},P}, +"GtkColorChooserWidget"} + +widget[GtkColorChooser] = {"gtk_color_chooser", +{GObject}, + {"set_rgba",{P,P},-routine_id("setccRGBA")}, + {"get_rgba",{P,I},-routine_id("getccRGBA")}, + {"set_use_alpha",{P,B},-routine_id("setccAlpha")}, + {"get_use_alpha",{P},-routine_id("getccAlpha")}, + {"add_palette",{P,I,I,I,A}}, +"GtkColorChooser"} + + constant + fngetccrgba = define_proc("gtk_color_chooser_get_rgba",{P,P}), + fngetccalpha = define_func("gtk_color_chooser_get_use_alpha",{P},B) + + function setccRGBA(atom x, object c) + ------------------------------------ + gtk_proc("gtk_color_chooser_set_rgba",{P,P},{x,to_rgba(c)}) + return 1 + end function + + function getccRGBA(atom x, integer fmt) + --------------------------------------- + atom rgba = allocate(32) + c_proc(fngetccrgba,{x,rgba}) + object c = gtk_func("gdk_rgba_to_string",{P},{rgba}) + return fmt_color(c,fmt) + end function + + function setccAlpha(atom x, integer b) + -------------------------------------- + gtk_proc("gtk_color_chooser_set_use_alpha",{P,B},{x,b}) + return 1 + end function + + function getccAlpha(atom x) + --------------------------- + return c_func(fngetccalpha,{x}) + end function + +widget[GtkColorSelection] = {"gtk_color_selection", -- Deprecated +{GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"set_has_opacity_control",{P,B}}, + {"get_has_opacity_control",{P},B}, + {"set_has_palette",{P,B}}, + {"get_has_palette",{P},B}, + {"set_current_rgba",{P,S},-routine_id("setCurrentRGBA")}, + {"get_current_rgba",{P,I},-routine_id("getCurrentRGBA")}, + {"set_current_alpha",{P,I}}, + {"get_current_alpha",{P},I}, + {"set_previous_rgba",{P,S},-routine_id("setPreviousRGBA")}, + {"get_previous_rgba",{P,I},-routine_id("getPreviousRGBA")}, + {"set_previous_alpha",{P,I}}, + {"get_previous_alpha",{P},I}, + {"is_adjusting",{P},B}, +"GtkColorSelection"} + +------------------------------------------------------------------------ +-- following color functions make using RGB colors much easier, +-- converting automatically between various color notations +------------------------------------------------------------------------ + constant + fngetCurCol = define_proc("gtk_color_selection_get_current_rgba",{P,P}), + fngetPrevCol = define_proc("gtk_color_selection_get_previous_rgba",{P,P}) + + function setCurrentRGBA(atom x, object c) + ----------------------------------------- + c =peek_string(c) + gtk_proc("gtk_color_selection_set_current_rgba",{P,P},{x,to_rgba(c)}) + return 1 + end function + + function setPreviousRGBA(atom x, object c) + ------------------------------------------ + c = peek_string(c) + gtk_proc("gtk_color_selection_set_previous_rgba",{P,P},{x,to_rgba(c)}) + return 1 + end function + + function getCurrentRGBA(atom x, integer fmt=0) + ---------------------------------------------- + atom rgba = allocate(32) + atom fn = define_func("gdk_rgba_to_string",{P},P) + c_proc(fngetCurCol,{x,rgba}) + object c = c_func(fn,{rgba}) + return fmt_color(c,fmt) + end function + + function getPreviousRGBA(atom x, integer fmt=0) + ----------------------------------------------- + atom rgba = allocate(32) + c_proc(fngetPrevCol,{x,rgba}) + object c = gtk_func("gdk_rgba_to_string",{rgba}) + return fmt_color(c,fmt) + end function + +widget[GtkFileChooser] = {"gtk_file_chooser", +{GtkWidget}, + {"set_action",{P,I}}, + {"get_action",{P},I}, + {"set_local_only",{P,B}}, + {"get_local_only",{P},B}, + {"set_select_multiple",{P,B}}, + {"get_select_multiple",{P},B}, + {"set_show_hidden",{P,B}}, + {"get_show_hidden",{P},B}, + {"set_do_overwrite_confirmation",{P,B}}, + {"get_do_overwrite_confirmation",{P},B}, + {"set_create_folders",{P,B}}, + {"get_create_folders",{P},B}, + {"get_current_name",{P},S}, --GTK3.10 + {"set_current_name",{P,S}}, + {"set_filename",{P,S}}, + {"get_filename",{P},S}, + {"get_filenames",{P},A,0,GSList}, + {"select_filename",{P,S}}, + {"unselect_filename",{P},S}, + {"select_all",{P}}, + {"unselect_all",{P}}, + {"set_current_folder",{P,S}}, + {"get_current_folder",{P},S}, + {"set_uri",{P,S}}, + {"get_uri",{P},S}, + {"select_uri",{P,S}}, + {"unselect_uri",{P,S}}, + {"get_uris",{P},P,0,GSList}, + {"set_current_folder_uri",{P,S}}, + {"get_current_folder_uri",{P},S}, + {"set_preview_widget",{P,P}}, + {"get_preview_widget",{P},P,0,GtkWidget}, + {"set_preview_widget_active",{P,B}}, + {"get_preview_widget_active",{P},B}, + {"set_use_preview_label",{P,B}}, + {"get_use_preview_label",{P},B}, + {"get_preview_filename",{P},S}, + {"get_preview_uri",{P},S}, + {"set_extra_widget",{P,P}}, + {"get_extra_widget",{P},P,0,GtkWidget}, + {"add_filter",{P,P}}, + {"remove_filter",{P,P}}, + {"list_filters",{P},A}, + {"set_filter",{P,P}}, + {"get_filter",{P},P,0,GtkFileFilter}, + {"add_shortcut_folder",{P,S,P},B}, + {"remove_shortcut_folder",{P,S,P},B}, + {"list_shortcut_folders",{P},P,0,GSList}, + {"add_shortcut_folder_uri",{P,S,P},B}, + {"remove_shortcut_folder_uri",{P,S,P},B}, + {"list_shortcut_folder_uris",{P},A}, + {"get_current_folder_file",{P},P,0,GFile}, + {"get_file",{P},P,0,GFile}, + {"get_files",{P},P,0,GSList}, + {"get_preview_file",{P},P,0,GFile}, + {"select_file",{P,P,P},B}, + {"set_current_folder_file",{P,P,P},B}, + {"set_file",{P,P,P},B}, + {"unselect_file",{P,P}}, +"GtkFileChooser"} + +widget[GtkFileChooserButton] = {"gtk_file_chooser_button", +{GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GtkFileChooser,GObject}, + {"new",{S,I},P}, + {"new_with_dialog",{P},P}, + {"set_title",{P,S}}, + {"get_title",{P},S}, + {"set_width_chars",{P,I}}, + {"get_width_chars",{P},I}, + {"set_focus_on_click",{P,B}}, + {"get_focus_on_click",{P},B}, +"GtkFileChooserButton"} + +widget[GtkFileChooserWidget] = {"gtk_file_chooser_widget", +{GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GtkFileChooser,GObject}, + {"new",{I},P}, +"GtkFileChooserWidget"} + +widget[GtkFileFilter] = {"gtk_file_filter", +{GtkBuildable,GObject}, + {"new",{},P}, + {"set_name",{P,S}}, + {"get_name",{P},S}, + {"add_mime_type",{P,S}}, + {"add_pattern",{P,S}}, + {"add_pixbuf_formats",{P}}, + {"add_custom",{P,I,P,P,P}}, + {"get_needed",{P},I}, + {"filter",{P,P},B}, +"GtkFileFilter"} + +widget[GtkFontChooser] = {"gtk_font_chooser", +{GObject}, + {"get_font_family",{P},P,0,PangoFontFamily}, + {"get_font_face",{P},P,0,PangoFontFace}, + {"get_font_size",{P},I}, + {"set_font",{P,S}}, + {"get_font",{P},S}, + {"set_font_desc",{P,P}}, + {"get_font_desc",{P},P,0,PangoFontDescription}, + {"set_preview_text",{P,S}}, + {"get_preview_text",{P},S}, + {"set_show_preview_entry",{P,B}}, + {"get_show_preview_entry",{P},B}, + {"set_filter_func",{P,P,P,P}}, +"GtkFontChooser"} + +widget[GtkFontChooserWidget] = {"gtk_font_chooser_widget", +{GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GtkFontChooser,GObject}, + {"new",{},P}, +"GtkFontChooserWidget"} + +widget[GtkInfoBar] = {"gtk_info_bar", +{GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"add_action_widget",{P,P,I}}, + {"add_button",{P,S,I},P,0,GtkWidget}, + {"set_response_sensitive",{P,I,B}}, + {"set_default_response",{P,I}}, + {"response",{P,I}}, + {"set_message_type",{P,I}}, + {"get_message_type",{P},I}, + {"get_action_area",{P},P,0,GtkWidget}, + {"get_content_area",{P},P,0,GtkWidget}, + {"set_show_close_button",{P,B}}, -- 3.10 + {"get_show_close_button",{P},B}, -- 3.10 +"GtkInfoBar"} + +widget[GtkRecentChooser] = {"gtk_recent_chooser", +{GObject}, + {"set_show_private",{P,B}}, + {"get_show_private",{P},B}, + {"set_show_not_found",{P,B}}, + {"get_show_not_found",{P},B}, + {"set_show_icons",{P,B}}, + {"get_show_icons",{P},B}, + {"set_select_multiple",{P,B}}, + {"get_select_multiple",{P},B}, + {"set_local_only",{P,B}}, + {"get_local_only",{P},B}, + {"set_limit",{P,I}}, + {"get_limit",{P},I}, + {"set_show_tips",{P,B}}, + {"get_show_tips",{P},B}, + {"set_sort_type",{P,I}}, + {"get_sort_type",{P},I}, + {"set_sort_func",{P,P,P,P}}, + {"set_current_uri",{P,S,P},B}, + {"get_current_uri",{P},S}, + {"get_current_item",{P},P,0,GtkRecentInfo}, + {"select_uri",{P,S,P},B}, + {"unselect_uri",{P,S}}, + {"select_all",{P}}, + {"unselect_all",{P}}, + {"get_items",{P},A,0,GSList}, + {"get_uris",{P},A}, + {"add_filter",{P,P}}, + {"remove_filter",{P,P}}, + {"list_filters",{P},A,0,GSList}, + {"set_filter",{P,P}}, + {"get_filter",{P},P,0,GtkRecentFilter}, +"GtkRecentChooser"} + +widget[GtkRecentChooserWidget] = {"gtk_recent_chooser_widget", +{GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GtkRecentChooser,GObject}, + {"new",{},P}, + {"new_for_manager",{P},P}, +"GtkRecentChooserWidget"} + +widget[GtkStatusbar] = {"gtk_statusbar", +{GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"get_context_id",{P,S},I}, + {"push",{P,I,S},I}, + {"pop",{P,I}}, + {"remove",{P,I,I}}, + {"remove_all",{P,I}}, + {"get_message_area",{P},P}, +"GtkStatusBar"} + +widget[GtkFixed] = {"gtk_fixed", +{GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"put",{P,P,I,I}}, + {"move",{P,P,I,I}}, +"GtkFixed"} + +widget[GtkGrid] = {"gtk_grid", +{GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"attach",{P,P,I,I,I,I}}, + {"attach_next_to",{P,P,P,I,I,I}}, + {"get_child_at",{P,I,I},P,0,GtkWidget}, + {"insert_row",{P,I}}, + {"remove_row",{P,I}}, --3.10 + {"insert_column",{P,I}}, + {"remove_column",{P,I}}, --3.10 + {"insert_next_to",{P,P,I}}, + {"set_row_homogeneous",{P,B}}, + {"get_row_homogeneous",{P},B}, + {"set_column_homogeneous",{P,B}}, + {"get_column_homogeneous",{P},B}, + {"set_row_spacing",{P,I}}, + {"get_row_spacing",{P},I}, + {"set_column_spacing",{P,I}}, + {"get_column_spacing",{P},I}, + {"set_baseline_row",{P,I}}, --3.10 + {"get_baseline_row",{P},I}, --3.10 + {"set_row_baseline_position",{P,I,I}}, --3.10 + {"get_row_baseline_position",{P,I},I}, --3.10 +"GtkGrid"} + +widget[GtkPaned] = {"gtk_paned", +{GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{I},P}, + {"add1",{P,P}}, + {"add2",{P,P}}, + {"pack1",{P,P,B,B}}, + {"pack2",{P,P,B,B}}, + {"get_child1",{P},P,0,GtkWidget}, + {"get_child2",{P},P,0,GtkWidget}, + {"set_position",{P,I}}, + {"get_position",{P},I}, + {"get_handle_window",{P},P,0,GdkWindow}, + {"get_wide_handle",{P},B}, -- 3.16 + {"set_wide_handle",{P,B}}, -- 3.16 +"GtkPaned"} + +widget[GtkIconInfo] = {"gtk_icon_info", +{GObject}, + {"new",{P,P},-routine_id("newIconInfo")}, + {"get_base_size",{P},I}, + {"get_base_scale",{P},I}, --3.10 + {"get_filename",{P},S}, + {"get_display_name",{P},S}, -- Deprecated 3.14 + {"get_builtin_pixbuf",{P},P,0,GdkPixbuf}, -- Deprecated 3.14 + {"load_icon",{P},-routine_id("iconinfoLoadIcon")}, + {"load_surface",{P,P,P},P,0,CairoSurface_t}, + {"load_icon_async",{P,P,P,P}}, + {"load_icon_finish",{P,P,P},P,0,GdkPixbuf}, + {"load_symbolic",{P,P,P,P,P,B,P},P,0,GdkPixbuf}, + {"load_symbolic_async",{P,P,P,P,P,P,P,P}}, + {"load_symbolic_finish",{P,P,P,P},P,0,GdkPixbuf}, + {"load_symbolic_for_context",{P,P,P,P},P,0,GdkPixbuf}, + {"load_symbolic_for_context_async",{P,P,P,P,P}}, + {"load_symbolic_for_context_finish",{P,P,P,P},P,0,GdkPixbuf}, + {"set_raw_coordinates",{P,B}}, -- Deprecated 3.14 + {"get_embedded_rect",{P,P},B}, -- Deprecated 3.14 + {"get_attach_points",{P,A,P},B}, -- Deprecated 3.14 + {"is_symbolic",{P},B}, -- 3.12 +"GtkIconInfo"} + + function iconinfoLoadIcon(atom info) + ------------------------------------ + atom err = allocate(8) err = 0 + atom icn = gtk_func("gtk_icon_info_load_icon",{P,P},{info,err}) + register(icn,GdkPixbuf) + return icn + end function + + function newIconInfo(atom theme, atom pix) + ------------------------------------------ + return gtk_func("gtk_icon_info_new_for_pixbuf",{P,P},{theme,pix}) + end function + +widget[GtkIconTheme] = {"gtk_icon_theme", +{GObject}, + {"new",{},-routine_id("getDefaultIconTheme")}, + {"get_for_screen",{P},P,0,GtkIconTheme}, + {"set_screen",{P,P}}, + {"set_search_path",{P,S,I}}, + {"get_search_path",{P,P,I}}, + {"append_search_path",{P,S}}, + {"prepend_search_path",{P,S}}, + {"set_custom_theme",{P,S}}, + {"has_icon",{P,S},B}, + {"lookup_icon",{P,S,I,I},P,0,GtkIconInfo}, + {"lookup_icon_for_scale",{P,P,I,I,I},P,0,GtkIconInfo}, + {"choose_icon",{P,A,I,I},P,0,GtkIconInfo}, + {"choose_icon_for_scale",{P,A,I,I,I},P,0,GtkIconInfo}, + {"lookup_by_gicon",{P,P,I,I},P,0,GtkIconInfo}, + {"load_icon",{P,S,I,I},-routine_id("iconthemeLoadIcon")}, + {"load_icon_for_scale",{P,S,I,I,I,P},P,0,GdkPixbuf}, + {"load_surface",{P,S,I,I,P,I,P},P,0,CairoSurface_t}, + {"list_contexts",{P},-routine_id("iconthemeListContexts")}, + {"list_icons",{P,S},-routine_id("iconthemeListIcons")}, + {"get_icon_sizes",{P,S},A}, + {"rescan_if_needed",{P},B}, + {"get_example_icon_name",{P},S}, + {"add_builtin_icon",{S,I,P}}, + {"add_resource_path",{P,S}}, -- 3.14 +"GtkIconTheme"} + + function iconthemeLoadIcon(atom theme, object name, integer size, integer flags) + -------------------------------------------------------------------------------- + atom err = allocate(8) err = 0 + return gtk_func("gtk_icon_theme_load_icon",{P,S,I,I,P},{theme,name,size,flags,err}) + end function + + function iconthemeListContexts(atom theme) + ------------------------------------------ + object list = gtk_func("gtk_icon_theme_list_contexts",{P},{theme}) + return to_sequence(list) + end function + + function iconthemeListIcons(atom theme, object context) + ------------------------------------------------------- + object list = gtk_func("gtk_icon_theme_list_icons",{P,S},{theme,context}) + return to_sequence(list) + end function + + function getDefaultIconTheme() + ------------------------------ + return gtk_func("gtk_icon_theme_get_default") + end function + +widget[GtkIconView] = {"gtk_icon_view", +{GtkContainer,GtkWidget,GtkBuildable,GtkCellLayout,GtkScrollable,GObject}, + {"new",{},P}, + {"new_with_area",{P},P}, + {"new_with_model",{P},P}, + {"set_model",{P,P}}, + {"get_model",{P},P,0,GtkTreeModel}, + {"set_text_column",{P,I}}, + {"get_text_column",{P},I}, + {"set_markup_column",{P,I}}, + {"get_markup_column",{P},I}, + {"set_pixbuf_column",{P,I}}, + {"get_pixbuf_column",{P},I}, + {"get_path_at_pos",{P,I,I},P,0,GtkTreePath}, + {"get_item_at_pos",{P,I,I,P,P},B}, + {"convert_widget_to_bin_window_coords",{P,I,I,I,I}}, + {"set_cursor",{P,P,P,B}}, + {"get_cursor",{P,P,P},B}, + {"selected_foreach",{P,P,P}}, + {"set_selection_mode",{P,I}}, + {"get_selection_mode",{P},I}, + {"set_columns",{P,I}}, + {"get_columns",{P},I}, + {"set_spacing",{P,I}}, + {"get_spacing",{P},I}, + {"set_row_spacing",{P,I}}, + {"get_row_spacing",{P},I}, + {"set_column_spacing",{P,I}}, + {"get_column_spacing",{P},I}, + {"set_margin",{P,I}}, + {"get_margin",{P},I}, + {"set_item_padding",{P,I}}, + {"get_item_padding",{P},I}, + {"set_activate_on_single_click",{P,B}}, --3.8 + {"get_activate_on_single_click",{P},B}, --3.8 + {"get_cell_rect",{P,P,P,P},B}, --3.6 + {"select_path",{P,P}}, + {"unselect_path",{P,P}}, + {"path_is_selected",{P,P},B}, + {"get_selected_items",{P},P,0,GSList}, + {"select_all",{P}}, + {"unselect_all",{P}}, + {"item_activated",{P,P}}, + {"scroll_to_path",{P,P,B,F,F}}, + {"get_visible_range",{P,P,P},B}, + {"set_tooltip_item",{P,P,P}}, + {"set_tooltip_cell",{P,P,P,P}}, + {"get_tooltip_context",{P,I,I,B,P,P,P},B}, + {"set_tooltip_column",{P,I}}, + {"get_tooltip_column",{P},I}, + {"get_item_row",{P,P},I}, + {"get_item_column",{P,P},I}, + {"enable_model_drag_source",{P,I,P,I,I}}, + {"enable_model_drag_dest",{P,P,I,I}}, + {"unset_model_drag_source",{P}}, + {"unset_model_drag_dest",{P}}, + {"set_reorderable",{P,B}}, + {"get_reorderable",{P},B}, + {"set_drag_dest_item",{P,P,I}}, + {"get_drag_dest_item",{P,P,I}}, + {"get_dest_item_at_pos",{P,I,I,P,I},B}, + {"create_drag_icon",{P,P},P,0,CairoSurface_t}, +"GtkIconView"} + +widget[GtkLayout] = {"gtk_layout", +{GtkContainer,GtkWidget,GtkBuildable,GtkScrollable,GObject}, + {"new",{P,P},P}, + {"put",{P,P,I,I}}, + {"move",{P,P,I,I}}, + {"set_size",{P,I,I}}, + {"get_size",{P,I,I}}, + {"get_bin_window",{P},P,0,GdkWindow}, +"GtkLayout"} + +widget[GtkSeparatorMenuItem] = {"gtk_separator_menu_item", +{GtkMenuItem,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkActivatable,GtkActionable,GObject}, + {"new",{},P}, +"GtkSeparatorMenuItem"} + +widget[GtkRecentChooserMenu] = {"gtk_recent_chooser_menu", +{GtkMenu,GtkMenuShell,GtkContainer,GtkWidget,GtkBuildable,GtkRecentChooser,GtkActivatable,GObject}, + {"new",{},P}, + {"new_for_manager",{P},P}, + {"set_show_numbers",{P,B}}, + {"get_show_numbers",{P},B}, +"GtkRecentChooserMenu"} + +widget[GtkRecentFilter] = {"gtk_recent_filter", +{GtkBuildable,GObject}, + {"new",{},P}, + {"set_name",{P,S}}, + {"get_name",{P},S}, + {"add_mime_type",{P,S}}, + {"add_pattern",{P,S}}, + {"add_pixbuf_formats",{P}}, + {"add_group",{P,S}}, + {"add_age",{P,I}}, + {"add_application",{P,S}}, + {"add_custom",{P,I,P,P,P}}, + {"get_needed",{P},I}, + {"filter",{P,P},B}, +"GtkRecentFilter"} + +widget[GtkRecentInfo] = {"gtk_recent_info", +{GObject}, + {"get_uri",{P},S}, + {"get_display_name",{P},S}, + {"get_description",{P},S}, + {"get_mime_type",{P},S}, + {"get_added",{P},I}, + {"get_modified",{P},I}, + {"get_visited",{P},I}, + {"get_private_hint",{P},B}, + {"get_application_info",{P,S,S,I,I},B}, + {"get_applications",{P,I},A}, + {"last_application",{P},S}, + {"has_application",{P,S},B}, + {"create_app_info",{P,S,P},P,0,GAppInfo}, + {"get_groups",{P,I},A}, + {"has_group",{P,S},B}, + {"get_icon",{P,I},P,0,GdkPixbuf}, + {"get_gicon",{P},P,0,GIcon}, + {"get_short_name",{P},S}, + {"get_uri_display",{P},S}, + {"get_age",{P},I}, + {"is_local",{P},B}, + {"exists",{P},B}, + {"match",{P,P},B}, +"GtkRecentInfo"} + +widget[GtkSettings] = {"gtk_settings", +{GtkStyleProvider,GObject}, + {"new",{},-routine_id("getDefaultSettings")}, +"GtkSettings"} + + function getDefaultSettings() + return gtk_func("gtk_settings_get_default",{}) + end function + +widget[GtkSizeGroup] = {"gtk_size_group", +{GtkBuildable,GObject}, + {"new",{I},P}, + {"set_mode",{P,I}}, + {"get_mode",{P},I}, + {"set_ignore_hidden",{P,B}}, + {"get_ignore_hidden",{P},B}, + {"add_widget",{P,P}}, + {"add_widgets",{P,P},-routine_id("addWidgets")}, + {"remove_widget",{P,P}}, + {"get_widgets",{P},P,0,GSList}, +"GtkSizeGroup"} + + function addWidgets(atom group, object widgets) + ----------------------------------------------- + if atom(widgets) then + set(group,"add widget",widgets) + else + for i = 1 to length(widgets) do + set(group,"add widget",widgets[i]) + end for + end if + return 1 + end function + +widget[GtkTargetEntry] = {"gtk_target_entry", +{GObject}, + {"new",{S,I,I},P}, + {"copy",{P},P,0,GtkTargetEntry}, + {"free",{P}}, +"GtkTargetEntry"} + +widget[GtkTargetList] = {"gtk_target_list", +{GObject}, + {"new",{P,I},P}, + {"add",{P,P,I,I}}, + {"add_table",{P,P,I}}, + {"add_text_targets",{P,I}}, + {"add_image_targets",{P,I,B}}, + {"add_uri_targets",{P,I}}, + {"add_rich_text_targets",{P,I,B,P}}, + {"remove",{P,P}}, + {"find",{P,P,P},B}, +"GtkTargetList"} + +widget[GtkTextChildAnchor] = {"gtk_text_child_anchor", +{GObject}, +"GtkTextChildAnchor"} + +widget[GtkTextMark] = {"gtk_text_mark", +{GObject}, + {"new",{S,B},P}, + {"set_visible",{P,B}}, + {"get_visible",{P},B}, + {"get_deleted",{P},B}, + {"get_name",{P},S}, + {"get_buffer",{P},P,0,GtkTextBuffer}, + {"get_left_gravity",{P},B}, +"GtkTextMark"} + +widget[GtkTextTag] = {"gtk_text_tag", +{GObject}, + {"new",{S},P}, + {"set_priority",{P,I}}, + {"get_priority",{P},I}, + {"event",{P,P,P,P},B}, +"GtkTextTag"} + +widget[GtkTextAttributes] = {"gtk_text_attributes", +{GObject}, + {"new",{},P}, + {"copy",{P},P,0,GtkTextAttributes}, + {"copy_values",{P,P}}, +"GtkTextAttributes"} + +widget[GtkTextTagTable] = {"gtk_text_tag_table", +{GtkBuildable,GObject}, + {"new",{},P}, + {"add",{P,P}}, + {"remove",{P,P}}, + {"lookup",{P,S},P,0,GtkTextTag}, + {"foreach",{P,P,P}}, + {"get_size",{P},I}, +"GtkTextTagTable"} + +widget[GtkMenuShell] = {"gtk_menu_shell", +{GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"append",{P,P},-routine_id("appendMenuShell")}, + {"prepend",{P,P}}, + {"insert",{P,P,I}}, + {"deactivate",{P}}, + {"select_item",{P,P}}, + {"select_first",{P,B}}, + {"deselect",{P}}, + {"activate_item",{P,P,B}}, + {"cancel",{P}}, + {"set_take_focus",{P,B}}, + {"get_take_focus",{P},B}, + {"get_selected_item",{P},P,0,GtkWidget}, + {"get_parent_shell",{P},P,0,GtkWidget}, + {"bind_model",{P,P,S,B}}, --3.6 +"GtkMenuShell"} + + function appendMenuShell(atom menu, object items) + ------------------------------------------------- + if atom(items) then + gtk_proc("gtk_menu_shell_append",{P,P},{menu,items}) + else + for i = 1 to length(items) do + appendMenuShell(menu,items[i]) + end for + end if + return 1 + end function + +widget[GtkNotebook] = {"gtk_notebook", +{GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"append_page",{P,P,P},I}, + {"append_page_menu",{P,P,P,P},I}, + {"prepend_page",{P,P,P},I}, + {"prepend_page_menu",{P,P,P,P},I}, + {"insert_page",{P,P,P,I},I}, + {"insert_page_menu",{P,P,P,P,I},I}, + {"remove_page",{P,I}}, + {"page_num",{P,P},I}, + {"next_page",{P}}, + {"prev_page",{P}}, + {"reorder_child",{P,P,I}}, + {"set_tab_pos",{P,I}}, + {"get_tab_pos",{P},I}, + {"set_show_tabs",{P,B}}, + {"get_show_tabs",{P},B}, + {"set_show_border",{P,B}}, + {"get_show_border",{P},B}, + {"set_scrollable",{P,B}}, + {"get_scrollable",{P},B}, + {"popup_enable",{P}}, + {"popup_disable",{P}}, + {"get_current_page",{P},I}, + {"set_menu_label",{P,P},0,GtkWidget}, + {"get_menu_label",{P,P},P}, + {"get_menu_label_text",{P,P},S}, + {"get_n_pages",{P},I}, + {"get_nth_page",{P,I},P,0,GtkWidget}, + {"set_tab_label",{P,P}}, + {"get_tab_label",{P,P},P,0,GtkWidget}, + {"set_tab_label_text",{P,P,S}}, + {"get_tab_label_text",{P,P},S}, + {"set_tab_detachable",{P,P,B}}, + {"get_tab_detachable",{P,P},B}, + {"set_current_page",{P,I}}, + {"set_group_name",{P,S}}, + {"get_group_name",{P},S}, + {"set_action_widget",{P,P,I}}, + {"get_action_widget",{P,I},P,0,GtkWidget}, + {"detach_tab",{P,P}}, +"GtkNotebook"} + +widget[GtkSocket] = {"gtk_socket", +{GtkContainer,GtkWidget,GObject}, + {"new",{},P}, + {"add_id",{P,P}}, + {"get_id",{P},P}, + {"get_plug_window",{P},P,0,GdkWindow}, +"GtkSocket"} + +widget[GtkPlug] = {"gtk_plug", +{GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{I},P}, + {"get_id",{P},I}, + {"get_embedded",{P},B}, + {"get_socket_window",{P},P,0,GdkWindow}, +"GtkPlug"} + +widget[GtkToolPalette] = {"gtk_tool_palette", +{GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GtkScrollable,GObject}, + {"new",{},P}, + {"set_exclusive",{P,P,B}}, + {"get_exclusive",{P,P},B}, + {"set_expand",{P,P,B}}, + {"get_expand",{P,P},B}, + {"set_group_position",{P,P,I}}, + {"get_group_position",{P,P},I}, + {"set_icon_size",{P,I}}, + {"get_icon_size",{P},I}, + {"unset_icon_size",{P}}, + {"set_style",{P,I}}, + {"get_style",{P},I}, + {"unset_style",{P}}, + {"add_drag_dest",{P,P,I,I,I}}, + {"get_drag_item",{P,P},P,0,GtkWidget}, + {"get_drop_group",{P,I,I},P,0,GtkToolItemGroup}, + {"set_drag_source",{P,I}}, +"GtkToolPalette"} + +widget[GtkTextView] = {"gtk_text_view", +{GtkContainer,GtkWidget,GtkBuildable,GtkScrollable,GObject}, + {"new",{},P}, + {"new_with_buffer",{P},P}, + {"set_buffer",{P,P}}, + {"get_buffer",{P},P,0,GtkTextBuffer}, + {"scroll_to_mark",{P,P,D,B,D,D}}, + {"scroll_to_iter",{P,P,D,B,D,D},B}, + {"scroll_mark_onscreen",{P,P}}, + {"place_cursor_onscreen",{P},B}, + {"get_visible_rect",{P,P}}, + {"get_iter_location",{P,P,P}}, + {"get_cursor_locations",{P,P,P,P}}, + {"get_line_at_y",{P,P,I,I}}, + {"get_line_yrange",{P,P,I,I}}, + {"get_iter_at_location",{P,P,I,I}}, + {"get_iter_at_position",{P,P,I,I,I}}, + {"buffer_to_window_coords",{P,P,I,I,I,I}}, + {"window_to_buffer_coords",{P,P,I,I,I,I}}, + {"get_window",{P,I},P,0,GdkWindow}, + {"set_border_window_size",{P,I,I}}, + {"get_border_window_size",{P,P},I}, + {"forward_display_line",{P,P},B}, + {"backward_display_line",{P,P},B}, + {"forward_display_line_end",{P,P},B}, + {"backward_display_line_start",{P,P},B}, + {"starts_display_line",{P,P},B}, + {"move_visually",{P,P,I},B}, + {"add_child_at_anchor",{P,P,P}}, + {"add_child_in_window",{P,P,P,I,I}}, + {"move_child",{P,P,I,I}}, + {"set_wrap_mode",{P,I}}, + {"get_wrap_mode",{P},I}, + {"set_editable",{P,B}}, + {"get_editable",{P},B}, + {"set_cursor_visible",{P,B}}, + {"get_cursor_visible",{P},B}, + {"set_overwrite",{P,B}}, + {"get_overwrite",{P},B}, + {"set_pixels_above_lines",{P,I}}, + {"get_pixels_above_lines",{P},I}, + {"set_pixels_below_lines",{P,I}}, + {"get_pixels_below_lines",{P},I}, + {"set_pixels_inside_wrap",{P,I}}, + {"get_pixels_inside_wrap",{P},I}, + {"set_justification",{P,I}}, + {"get_justification",{P},I}, + {"set_left_margin",{P,I}}, + {"get_left_margin",{P},I}, + {"set_right_margin",{P,I}}, + {"get_right_margin",{P},I}, + {"set_indent",{P,I}}, + {"get_indent",{P},I}, + {"set_tabs",{P,A}}, + {"get_tabs",{P},A,0,PangoTabArray}, + {"set_accepts_tab",{P,B}}, + {"get_accepts_tab",{P},B}, + {"im_context_filter_keypress",{P,P},B}, + {"reset_im_context",{P}}, + {"set_input_purpose",{P,I}}, -- GTK 3.6+ + {"get_input_purpose",{P},I}, -- GTK 3.6+ + {"set_input_hints",{P,I}}, -- GTK 3.6+ + {"get_input_hints",{P},I}, -- GTK 3.6+ + {"get_monospace",{P},B}, -- 3.16 + {"set_monospace",{P,B}}, -- 3.16 +"GtkTextView"} + +widget[GtkToolShell] = {"gtk_tool_shell", +{GtkWidget}, + {"get_ellipsize_mode",{P},I}, + {"get_icon_size",{P},I}, + {"get_orientation",{P},I}, + {"get_relief_style",{P},I}, + {"get_style",{P},I}, + {"get_text_alignment",{P},F}, + {"get_text_orientation",{P},I}, + {"get_text_size_group",{P},P,0,GtkSizeGroup}, + {"rebuild_menu",{P}}, +"GtkToolShell"} + +widget[GtkToolbar] = {"gtk_toolbar", +{GtkOrientable,GtkContainer,GtkWidget,GtkBuildable,GObject,GtkToolShell}, + {"new",{},P}, + {"insert",{P,P,I}}, + {"get_item_index",{P,P},I}, + {"get_n_items",{P},I}, + {"get_nth_item",{P},P}, + {"get_drop_index",{P,I,I},I}, + {"set_drop_highlight_item",{P,P,I}}, + {"set_show_arrow",{P,B}}, + {"get_show_arrow",{P},B}, + {"set_icon_size",{P,I}}, + {"get_icon_size",{P},I}, + {"unset_icon_size",{P}}, + {"set_style",{P,I}}, + {"get_style",{P},I}, + {"unset_style",{P}}, +"GtkToolbar"} + +widget[GtkToolItemGroup] = {"gtk_tool_item_group", +{GtkContainer,GtkWidget,GtkBuildable,GtkToolShell,GObject}, + {"new",{S},P}, + {"set_collapsed",{P,B}}, + {"get_collapsed",{P},B}, + {"set_ellipsize",{P,I}}, + {"get_ellipsize",{P},I}, + {"get_drop_item",{P,I,I},P,0,GtkToolItem}, + {"get_n_items",{P},I}, + {"get_nth_item",{P,I},P,0,GtkToolItem}, + {"set_label",{P,S}}, + {"get_label",{P},S}, + {"set_label_widget",{P,P}}, + {"get_label_widget",{P},P,0,GtkWidget}, + {"set_header_relief",{P,I}}, + {"get_header_relief",{P},I}, + {"insert",{P,P,I}}, + {"set_item_position",{P,P,I}}, +"GtkToolItemGroup"} + +widget[GtkTooltip] = {"gtk_tooltip", +{GObject}, + {"set_text",{P,S}}, + {"set_markup",{P,S}}, + {"set_icon",{P,P}}, + {"set_icon_from_icon_name",{P,S,I}}, + {"set_icon_from_gicon",{P,P,I}}, + {"set_custom",{P,P}}, + {"trigger_tooltip_query",{P}}, + {"set_tip_area",{P,P}}, +"GtkTooltip"} + +widget[GtkTreeView] = {"gtk_tree_view", +{GtkContainer,GtkWidget,GtkBuildable,GtkScrollable,GObject}, + {"new",{},P}, + {"new_with_model",{P},P}, + {"set_model",{P,P}}, + {"get_model",{P},P,0,GtkTreeModel}, + {"get_selection",{P},P,0,GtkTreeSelection}, + {"set_headers_visible",{P,B}}, + {"get_headers_visible",{P},B}, + {"set_headers_clickable",{P,B}}, + {"get_headers_clickable",{P},B}, + {"set_show_expanders",{P,B}}, + {"get_show_expanders",{P},B}, + {"set_expander_column",{P,P}}, + {"get_expander_column",{P},P,0,GtkTreeViewColumn}, + {"set_level_indentation",{P,I}}, + {"get_level_indentation",{P},I}, + {"columns_autosize",{P}}, + {"set_rules_hint",{P,B}}, -- Deprecated 3.14 + {"get_rules_hint",{P},B}, -- Deprecated 3.14 + {"set_activate_on_single_click",{P,B}}, -- GTK 3.8+ + {"get_activate_on_single_click",{P},B}, -- GTK 3.8+ + {"append_column",{P,P},I}, + {"append_columns",{P,P},-routine_id("tvAppendCols")}, + {"remove_column",{P,P,I}}, + {"insert_column",{P,P,I}}, + {"insert_column_with_attributes",{P,I,S,S,I,I}}, + {"insert_column_with_data_func",{P,I,S,P,P,P,P}}, + {"get_n_columns",{P},I}, + {"get_column",{P,I},P,0,GtkTreeViewColumn}, + {"get_columns",{P},A,0,GList}, + {"move_column_after",{P,P,P}}, + {"set_column_drag_function",{P,P,P,P}}, + {"scroll_to_point",{P,I,I}}, + {"scroll_to_cell",{P,P,P,P,F,F},-routine_id("tvScrol2Cel")}, + {"set_cursor",{P,P,P,B}}, + {"set_cursor_on_cell",{P,P,P,P,B}}, + {"get_cursor",{P,P,P}}, + {"row_activated",{P,P,P}}, + {"expand_row",{P,P,B},B}, + {"expand_all",{P}}, + {"expand_to_path",{P,P}}, + {"collapse_all",{P}}, + {"map_expanded_rows",{P,P,P}}, + {"row_expanded",{P,P},B}, + {"set_reorderable",{P,B}}, + {"get_reorderable",{P,B}}, + {"get_path_at_pos",{P,I,I,P,P,I,I},B}, + {"is_blank_at_pos",{P,I,I,P,P,I,I},B}, + {"get_cell_area",{P,P,P,P}}, + {"get_background_area",{P,P,P,P}}, + {"get_visible_rect",{P,P}}, + {"get_visible_range",{P,P,P},B}, + {"get_bin_window",{P},P,0,GdkWindow}, + {"convert_bin_window_to_tree_coords",{P,I,I,I,I}}, + {"convert_bin_window_to_widget_coords",{P,I,I,I,I}}, + {"convert_tree_to_bin_window_coords",{P,I,I,I,I}}, + {"convert_tree_to_widget_coords",{P,I,I,I,I}}, + {"convert_widget_to_bin_window_coords",{P,I,I,I,I}}, + {"convert_widget_to_tree_coords",{P,I,I,I,I}}, + {"enable_model_drag_dest",{P,P,I,I}}, + {"enable_model_drag_source",{P,I,P,I,I}}, + {"unset_rows_drag_source",{P}}, + {"unset_rows_drag_dest",{P}}, + {"set_drag_dest_row",{P,P,I}}, + {"get_drag_dest_row",{P,P,P}}, + {"get_drag_dest_row_at_pos",{P,I,I,P,P},B}, + {"create_row_drag_icon",{P,P},P,0,CairoSurface_t}, + {"set_enable_search",{P,B}}, + {"get_enable_search",{P},B}, + {"set_search_column",{P,I}}, + {"get_search_column",{P},I}, + {"set_search_equal_func",{P,P,P,P}}, + {"get_search_equal_func",{P},P}, + {"set_search_entry",{P,P}}, + {"get_search_entry",{P},P,0,GtkEntry}, + {"set_search_position_func",{P,P,P,P}}, + {"get_search_position_func",{P},P}, + {"set_fixed_height_mode",{P,B}}, + {"get_fixed_height_mode",{P},B}, + {"set_hover_selection",{P,B}}, + {"get_hover_selection",{P},B}, + {"set_hover_expand",{P,B}}, + {"get_hover_expand",{P},B}, + {"set_destroy_count_func",{P,P,P,P}}, + {"set_row_separator_func",{P,P,P,P}}, + {"get_row_separator_func",{P},P}, + {"set_rubber_banding",{P,B}}, + {"get_rubber_banding",{P},B}, + {"set_enable_tree_lines",{P,B}}, + {"get_enable_tree_lines",{P},B}, + {"set_grid_lines",{P,B}}, + {"get_grid_lines",{P},B}, + {"set_tooltip_row",{P,P,P}}, + {"set_tooltip_cell",{P,P,P,P,P}}, + {"set_tooltip_column",{P,I}}, + {"get_tooltip_column",{P},I}, + {"get_tooltip_context",{P,I,I,B,P,P,P},B}, + {"select_row",{P,P,D,D},-routine_id("tvSelectRow")}, + {"get_selected_row_data",{P,P},-routine_id("getSelectedRowData")}, + {"get_selected_col_data",{P,P,I},-routine_id("getSelectedColData")}, +"GtkTreeView"} + + constant sfn1 = define_func("gtk_tree_view_get_model",{P},P) + constant sfn2 = define_func("gtk_tree_model_get_n_columns",{P},I) + constant sfn3 = define_func("gtk_tree_model_get_iter",{P,P,P},B) + constant sfn4 = define_func("gtk_tree_model_get_column_type",{P,I},I) + constant sp1 = define_proc("gtk_tree_model_get",{P,P,I,P,I}) + + function getSelectedColData(atom view, atom path, integer col) + object data = getSelectedRowData(view,path) + return data[col] + end function + + function getSelectedRowData(atom view, atom path) + atom mdl = c_func(sfn1,{view}) + integer ncols = c_func(sfn2,{mdl}) + object data = repeat(0,ncols) + object types = repeat(0,ncols) + atom iter = allocate(32) + if c_func(sfn3,{mdl,iter,path}) then + for i = 1 to length(data) do + data[i] = allocate(32) + types[i] = c_func(sfn4,{mdl,i-1}) + c_proc(sp1,{mdl,iter,i-1,data[i],-1}) + end for + end if + for i = 1 to length(data) do + ? types[i] + switch types[i] do + case gSTR then data[i] = peek_string(peek4u(data[i])) + case else data[i] = peek4u(data[i]) + end switch + end for + return data + end function + + constant scrl2cell = define_proc("gtk_tree_view_scroll_to_cell",{P,P,P,I,F,F}) + + function tvScrol2Cel(atom v, atom p, atom c=0, integer align=0, atom row=0, atom col=0) + c_proc(scrl2cell,{v,p,c,align,row,col}) + return 1 + end function + + constant appcol = define_func("gtk_tree_view_append_column",{P,P},I) + function tvAppendCols(atom store, object cols) + --------------------------------------------------------------------------- + if atom(cols) then + c_func(appcol,{store,cols}) + else + for i = 1 to length(cols) do + c_func(appcol,{store,cols[i]}) + end for + end if + return 1 + end function + + function tvSelectRow(atom tv, object path, atom rowalign=0, atom colalign=0) + path = create(GtkTreePath,path) + gtk_func("gtk_tree_view_scroll_to_cell", + {P,P,I,I,F,F},{tv,path,0,1,rowalign,colalign}) + return 1 + end function + +widget[GtkTreeViewColumn] = {"gtk_tree_view_column", +{GtkCellLayout,GtkBuildable,GObject}, + {"new",{},P}, + {"set_title",{P,S}}, + {"get_title",{P},S}, + {"pack_start",{P,P,B}}, + {"pack_end",{P,P,B}}, + {"clear",{P}}, + {"clicked",{P}}, + {"add_attribute",{P,P,S,I}}, + {"set_spacing",{P,I}}, + {"get_spacing",{P},I}, + {"set_visible",{P,B}}, + {"get_visible",{P},B}, + {"set_resizable",{P,B}}, + {"get_resizable",{P},B}, + {"set_sizing",{P,I}}, + {"get_sizing",{P},I}, + {"set_fixed_width",{P,I}}, + {"get_fixed_width",{P},I}, + {"set_min_width",{P,I}}, + {"get_min_width",{P},I}, + {"set_max_width",{P,I}}, + {"get_max_width",{P},I}, + {"set_expand",{P,B}}, + {"get_expand",{P},B}, + {"set_clickable",{P,B}}, + {"get_clickable",{P},B}, + {"set_widget",{P,P}}, + {"get_widget",{P},P}, + {"get_button",{P},P,0,GtkWidget}, + {"set_alignment",{P,F}}, + {"get_alignment",{P},F}, + {"set_reorderable",{P,B}}, + {"get_reorderable",{P},B}, + {"set_sort_column_id",{P,I}}, + {"get_sort_column_id",{P},I}, + {"set_sort_indicator",{P,B}}, + {"get_sort_indicator",{P},B}, + {"set_sort_order",{P,I}}, + {"get_sort_order",{P},I}, + {"cell_set_cell_data",{P,P,P,B,B}}, + {"cell_get_size",{P,P,I,I,I,I}}, + {"cell_get_position",{P,P,I,I},B}, + {"cell_is_visible",{P},B}, + {"focus_cell",{P,P}}, + {"queue_resize",{P}}, + {"get_tree_view",{P},P,0,GtkWidget}, + {"get_x_offset",{P},I}, +"GtkTreeViewColumn"} + +widget[GtkTreeSelection] = {"gtk_tree_selection", +{GObject}, + {"set_mode",{P,I}}, + {"get_mode",{P},I}, + {"set_select_function",{P,P,P,P}}, + {"get_select_function",{P},P}, + {"get_user_data",{P},P}, + {"get_tree_view",{P},P}, + {"get_selected",{P,P,P},B}, + {"selected_foreach",{P,P,P}}, + {"count_selected_rows",{P},I}, + {"select_path",{P,P}}, + {"unselect_path",{P,P}}, + {"path_is_selected",{P,P},B}, + {"select_iter",{P,P}}, + {"unselect_iter",{P,P}}, + {"iter_is_selected",{P,P},B}, + {"select_all",{P}}, + {"unselect_all",{P}}, + {"select_range",{P,P,P}}, + {"unselect_range",{P,P,P}}, + {"get_selected_row",{P,P},-routine_id("getSelRow")}, + {"get_selected_rows",{P,P},-routine_id("getSelRows")}, + {"get_selected_row_data",{P},-routine_id("getSelRowData")}, + {"get_selected_row_col",{P,I},-routine_id("getSelRowCol")}, +"GtkTreeSelection"} + + constant + treeselection_fn1 = define_func("gtk_tree_selection_get_selected",{P,P,P},I), + treeselection_fn2 = define_func("gtk_tree_model_get_n_columns",{P},I), + treeselection_fn3 = define_func("gtk_tree_model_get_column_type",{P,I},I), + treeselection_p1 = define_proc("gtk_tree_model_get",{P,P,I,P,I}) + + function getSelRows(atom selection, atom model) + ------------------------------------------------- + object list = gtk_func("gtk_tree_selection_get_selected_rows",{P,P},{selection,model}) + list = to_sequence(list,3) + return list +1 + end function + + function getSelRow(atom selection, atom model) + ------------------------------------------------- + object result = getSelRows(selection,model) + if equal({},result) then + return 0 + else + return result[1] + end if + end function + + function getSelRowData(atom selection) + ------------------------------------------------- + atom mdl = allocate(32), iter = allocate(32) + integer n + object x,t, val + if c_func(treeselection_fn1,{selection,mdl,iter}) then + mdl = peek4u(mdl) + n = c_func(treeselection_fn2,{mdl}) + x = repeat(0,n) t = x + for i = 1 to n do + val = allocate(32) + c_proc(treeselection_p1,{mdl,iter,i-1,val,-1}) + t[i] = c_func(treeselection_fn3,{mdl,i-1}) + x[i] = val + end for + for i = 1 to length(x) do + switch t[i] do + case gSTR then + if peek4u(x[i]) > 0 then + x[i] = peek_string(peek4u(x[i])) + end if + case gFLT then x[i] = float32_to_atom(peek({x[i],4})) + case gDBL then x[i] = float64_to_atom(peek({x[i],8})) + case else x[i] = peek4u(x[i]) + end switch + end for + return x + end if + return -1 + end function + + function getSelRowCol(atom selection, integer col) + object x = getSelRowData(selection) + return x[col] + end function + +widget[GtkActionBar] = {"gtk_action_bar", -- GTK 3.12 +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"pack_start",{P,P}}, + {"pack_end",{P,P}}, + {"get_center_widget",{P},P}, + {"set_center_widget",{P,P}}, +"GtkActionBar"} + +widget[GtkAccelLabel] = {"gtk_accel_label", +{GtkLabel,GtkMisc,GtkWidget,GtkBuildable,GObject}, + {"new",{S},P}, + {"get_accel",{P,I,I}}, -- 3.14 + {"set_accel",{P,I,I}}, + {"set_accel_closure",{P,P}}, + {"set_accel_widget",{P,P}}, + {"get_accel_widget",{P},P,0,GtkWidget}, + {"get_accel_width",{P},I}, + {"refetch",{P},B}, +"GtkAccelLabel"} + +widget[GtkAccelGroup] = {"gtk_accel_group", +{GObject}, + {"new",{},P}, + {"connect",{P,I,I,I,P}}, + {"connect_by_path",{P,S,P}}, + {"disconnect",{P,P},B}, + {"disconnect_key",{P,I,I},B}, + {"activate",{P,I,P,I,I},B}, + {"lock",{P}}, + {"unlock",{P}}, + {"get_is_locked",{P},B}, + {"from_accel_closure",{P},P,0,GtkAccelGroup}, + {"get_modifier_mask",{P},I}, + {"find",{P,P,P},P}, +"GtkAccelGroup"} + +widget[GtkArrow] = {"gtk_arrow", -- Deprecated 3.14 +{GtkMisc,GtkWidget,GtkBuildable,GObject}, + {"new",{I,I},P}, + {"set",{P,I,I}}, +"GtkArrow"} + +widget[GtkCalendar] = {"gtk_calendar", +{GtkWidget,GtkBuildable,GObject}, + {"clear_marks",{P}}, + {"get_date",{P,P},-routine_id("getCalendarDate")}, + {"get_ymd",{P,I},-routine_id("getCalendarYMD")}, + {"get_y,m,d",{P,I},-routine_id("getCalendarYMD")}, + {"get_eu_date",{P},-routine_id("getCalendarEuDate")}, + {"get_day",{P},-routine_id("getCalendarDay")}, + {"get_month",{P},-routine_id("getCalendarMonth")}, + {"get_year",{P},-routine_id("getCalendarYear")}, + {"get_day_is_marked",{P,I},B}, + {"get_display_options",{P},I}, + {"mark_day",{P,I},B}, + {"new",{P},-routine_id("new_calendar")}, + {"select_day",{P,I}}, + {"select_month",{P,I,I},-routine_id("selectCalendarMonth")}, + {"set_display_options",{P,I}}, + {"unmark_day",{P,I},B}, + {"set_detail_func",{P,P,P,P}}, + {"set_detail_width_chars",{P,I}}, + {"get_detail_width_chars",{P},I}, + {"get_detail_height_rows",{P},I}, + {"set_detail_height_rows",{P,I}}, + {"set_date",{P,P},-routine_id("setCalendarDate")}, +"GtkCalendar"} + + function new_calendar(object d = 0) + object cal = gtk_func("gtk_calendar_new") + if atom(d) and d = 0 then return cal + else gtk_proc("gtk_calendar_select_month",{P,I,I},{cal,d[2]-1,d[1]}) + gtk_proc("gtk_calendar_select_day",{P,I},{cal,d[3]}) + return cal + end if + end function + +------------------------------------------------------------------------ +-- Calendar convenience functions +------------------------------------------------------------------------ +-- Handle odd month numbering scheme: +-- Q: If the first day of the month is 1, then why is the first month +-- of the year zero? +-- A: Blame a C programmer! + +-- Here we fix that, plus change the set_date routine from two steps +-- to one; also, provide for standard formatting to be used when +-- getting the date. See std/datetime.e for the formats available. +------------------------------------------------------------------------ + + constant get_date = define_proc("gtk_calendar_get_date",{P,I,I,I}) + + ------------------------------------------------------------------------ + function selectCalendarMonth(atom handle, integer mo, integer yr=0) + ------------------------------------------------------------------------ + while mo < 1 do yr -= 1 mo += 12 end while + while mo > 12 do yr += 1 mo -= 12 end while + gtk_proc("gtk_calendar_select_month",{P,I,I},{handle,mo-1,yr}) + return 1 + end function + + ------------------------------------------------------------------------ + function setCalendarDate(atom handle, object cdate) + ------------------------------------------------------------------------ + if string(cdate) then + cdate = split(cdate,',') + cdate[1] = to_number(cdate[1][2..$]) + cdate[2] = to_number(cdate[2]) + cdate[3] = to_number(cdate[3][1..$-1]) + end if + integer yr = cdate[1], mo = cdate[2], da = cdate[3] + gtk_proc("gtk_calendar_select_month",{P,I,I},{handle,mo-1,yr}) + gtk_proc("gtk_calendar_select_day",{P,I},{handle,da}) + return 1 + end function + + ------------------------------------------------------------------------ + function getCalendarDate(atom handle, object fmt=0) + ------------------------------------------------------------------------ + atom y = allocate(64) + atom m = allocate(64) + atom d = allocate(64) + object clock + if atom(fmt) then + fmt = "%A, %b %d, %Y" + end if + object result + c_proc(get_date,{handle,y,m,d}) + result = datetime:new(peek4u(y),peek4u(m)+1,peek4u(d)) + clock = datetime:now() + result = result[1..3] & clock[4..6] + result = datetime:format(result,fmt) + free(y) free(m) free(d) + return result + end function + + ------------------------------------------------------------------------ + function getCalendarEuDate(atom handle) --returns {y,m,d} in Eu fmt. + ------------------------------------------------------------------------ + atom y = allocate(64) + atom m = allocate(64) + atom d = allocate(64) + c_proc(get_date,{handle,y,m,d}) + sequence result = {peek4u(y)-1900,peek4u(m)+1,peek4u(d)} + free(y) free(m) free(d) + return result + end function + + ------------------------------------------------------------------------ + function getCalendarYMD(atom handle, integer full=0) + ------------------------------------------------------------------------ + object clock + switch full do + case 0 then return getCalendarEuDate(handle) + {1900,0,0} + case 1 then return getCalendarEuDate(handle) + {1900,0,0} & {0,0,0} + case 2 then clock = datetime:now() + return getCalendarEuDate(handle) + {1900,0,0} & clock[4..6] + case else return getCalendarEuDate(handle) + {1900,0,0} + end switch + end function + + ------------------------------------------------------------------------ + function getCalendarDay(atom handle) + ------------------------------------------------------------------------ + atom y = allocate(64) + atom m = allocate(64) + atom d = allocate(64) + c_proc(get_date,{handle,y,m,d}) + integer result = peek4u(d) + free(y) free(m) free(d) + return result + end function + + ------------------------------------------------------------------------ + function getCalendarMonth(atom handle) + ------------------------------------------------------------------------ + atom y = allocate(64) + atom m = allocate(64) + atom d = allocate(64) + c_proc(get_date,{handle,y,m,d}) + integer result = peek4u(m) + free(y) free(m) free(d) + return result+1 + end function + + ------------------------------------------------------------------------ + function getCalendarYear(atom handle) + ------------------------------------------------------------------------ + atom y = allocate(64) + atom m = allocate(64) + atom d = allocate(64) + c_proc(get_date,{handle,y,m,d}) + integer result = peek4u(y) + free(y) free(m) free(d) + return result + end function + +widget[GtkCellView] = {"gtk_cell_view", +{GtkWidget,GtkBuildable,GtkCellLayout,GtkOrientable,GObject}, + {"new",{},P}, + {"new_with_context",{P},P}, + {"new_with_text",{S},P}, + {"new_with_markup",{S},P}, + {"new_with_pixbuf",{P},P}, + {"set_model",{P,P}}, + {"get_model",{P},P}, + {"set_displayed_row",{P,P}}, + {"get_displayed_row",{P},P,0,GtkTreePath}, + {"set_draw_sensitive",{P,B}}, + {"get_draw_sensitive",{P},B}, + {"set_fit_model",{P,B}}, + {"get_fit_model",{P},B}, +"GtkCellView"} + +widget[GtkDrawingArea] = {"gtk_drawing_area", +{GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, +"GtkDrawingArea"} + +widget[GtkSearchEntry] = {"gtk_search_entry", --3.6 +{GtkEntry,GtkWidget,GtkBuildable,GtkEditable,GtkCellEditable,GObject}, + {"new",{},P}, + {"handle_event",{P,P},B}, +"GtkSearchEntry"} + +widget[GtkEntryBuffer] = {"gtk_entry_buffer", +{GObject}, + {"new",{S,I},P}, + {"get_text",{P},S}, + {"set_text",{P,S,I}}, + {"get_bytes",{P},I}, + {"get_length",{P},I}, + {"set_max_length",{P,I}}, + {"get_max_length",{P},I}, + {"insert_text",{P,I,S,I},I}, + {"delete_text",{P,I,I},I}, + {"emit_deleted_text",{P,I,I}}, + {"emit_inserted_text",{P,I,S,I}}, +"GtkEntryBuffer"} + +widget[GtkEntryCompletion] = {"gtk_entry_completion", +{GtkCellLayout,GtkBuildable,GObject}, + {"new",{},P}, + {"new_with_area",{P},P}, + {"get_entry",{P},P,0,GtkWidget}, + {"set_model",{P,P}}, + {"get_model",{P},P,0,GtkTreeModel}, + {"set_match_func",{P,P,P,P}}, + {"set_minimum_key_length",{P,I}}, + {"get_minimum_key_length",{P},I}, + {"compute_prefix",{P,S},S}, + {"get_completion_prefix",{P},S}, + {"insert_prefix",{P}}, + {"insert_action_text",{P,I,S}}, + {"insert_action_markup",{P,I,S}}, + {"delete_action",{P,I}}, + {"set_text_column",{P,I}}, + {"get_text_column",{P},I}, + {"set_inline_completion",{P,B}}, + {"get_inline_completion",{P},B}, + {"set_inline_selection",{P,B}}, + {"get_inline_selection",{P},B}, + {"set_popup_completion",{P,B}}, + {"get_popup_completion",{P},B}, + {"set_popup_set_width",{P,B}}, + {"get_popup_set_width",{P},B}, + {"set_popup_single_match",{P,B}}, + {"get_popup_single_match",{P},B}, + {"complete",{P}}, +"GtkEntryCompletion"} + +widget[GtkRevealer] = {"gtk_revealer", -- new in GTK 3.10 +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"set_reveal_child",{P,B}}, + {"get_reveal_child",{P},B}, + {"get_child_revealed",{P},B}, + {"set_transition_duration",{P,I}}, + {"get_transition_duration",{P},I}, + {"set_transition_type",{P,I}}, + {"get_transition_type",{P},I}, +"GtkRevealer"} + +widget[GtkSearchBar] = {"gtk_search_bar", -- new in GTK 3.10 +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"connect_entry",{P,P}}, + {"set_search_mode",{P,B}}, + {"get_search_mode",{P},B}, + {"set_show_close_button",{P,B}}, + {"get_show_close_button",{P},B}, + {"handle_event",{P,P},B}, +"GtkSearchBar"} + +widget[GtkStack] = {"gtk_stack", -- new in GTK 3.10 +{GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"add_named",{P,P,S}}, + {"add_titled",{P,P,S,S}}, + {"set_visible_child",{P,P}}, + {"get_visible_child",{P},P,0,GtkWidget}, + {"set_visible_child_name",{P,S}}, + {"get_visible_child_name",{P},S}, + {"set_visible_child_full",{P,S,I}}, + {"set_homogeneous",{P,B}}, + {"get_homogeneous",{P},B}, + {"set_transition_duration",{P,I}}, + {"get_transition_duration",{P},I}, + {"set_transition_type",{P,I}}, + {"get_transition_type",{P},I}, + {"get_child_by_name",{P,S},P,0,GtkWidget}, -- 3.12 + {"get_transition_running",{P},B}, -- 3.12 + {"get_hhomogeneous",{P},B}, -- 3.16 + {"set_hhomogeneous",{P,B}}, -- 3.16 + {"get_vhomogeneous",{P},B}, -- 3.16 + {"set_vhomogeneous",{P,B}}, -- 3.16 +"GtkStack"} + +widget[GtkStackSidebar] = {"gtk_stack_sidebar", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"set_stack",{P,P}}, + {"get_stack",{P},P,0,GtkStack}, +"GtkStackSidebar"} + +widget[GtkStackSwitcher] = {"gtk_stack_switcher", +{GtkBox,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"set_stack",{P,P}}, + {"get_stack",{P},P,0,GtkStack}, +"GtkStackSwitcher"} + +widget[GtkScrollbar] = {"gtk_scrollbar", +{GtkRange,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{I,P},P}, +"GtkScrollbar"} + +widget[GtkInvisible] = {"gtk_invisible", +{GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"new_for_screen",{P},P}, + {"set_screen",{P,P}}, + {"get_screen",{P},P,0,GdkScreen}, +"GtkInvisible"} + +widget[GtkProgressBar] = {"gtk_progress_bar", +{GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"pulse",{P}}, + {"set_fraction",{P,D}}, + {"get_fraction",{P},D}, + {"set_inverted",{P,B}}, + {"get_inverted",{P},B}, + {"set_show_text",{P,B}}, + {"get_show_text",{P},B}, + {"set_text",{P,S}}, + {"get_text",{P},S}, + {"set_ellipsize",{P,B}}, + {"get_ellipsize",{P},B}, + {"set_pulse_step",{P,D}}, + {"get_pulse_step",{P},D}, +"GtkProgressBar"} + +widget[GtkSpinner] = {"gtk_spinner", +{GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"start",{P}}, + {"stop",{P}}, +"GtkSpinner"} + +widget[GtkSwitch] = {"gtk_switch", +{GtkWidget,GtkBuildable,GtkActionable,GtkActivatable,GObject}, + {"new",{},P}, + {"set_active",{P,B}}, + {"get_active",{P},B}, + {"get_state",{P},B}, -- GTK3.14 + {"set_state",{P,B}}, -- GTK3.14 +"GtkSwitch"} + +widget[GtkLevelBar] = {"gtk_level_bar",-- GTK3.6+ +{GtkWidget,GtkBuildable,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"new_for_interval",{D,D},P}, + {"set_mode",{P,I}}, + {"get_mode",{P},I}, + {"set_value",{P,D}}, + {"get_value",{P},D}, + {"set_min_value",{P,D}}, + {"get_min_value",{P},D}, + {"set_max_value",{P,D}}, + {"get_max_value",{P},D}, + {"add_offset_value",{P,S,D}}, + {"remove_offset_value",{P,S}}, + {"get_offset_value",{P,S,D},B}, + {"get_inverted",{P},B}, --GTK3.8+ + {"set_inverted",{P,B}}, --GTK3.8+ +"GtkLevelBar"} + +widget[GtkAboutDialog] = {"gtk_about_dialog", +{GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"set_program_name",{P,S}}, + {"get_program_name",{P},S}, + {"set_version",{P,S}}, + {"get_version",{P},S}, + {"set_copyright",{P,S}}, + {"get_copyright",{P},S}, + {"set_comments",{P,S}}, + {"get_comments",{P},S}, + {"set_license",{P,S}}, + {"get_license",{P},S}, + {"set_wrap_license",{P,B}}, + {"get_wrap_license",{P},B}, + {"set_license_type",{P,I}}, + {"get_license_type",{P},I}, + {"set_website",{P,S}}, + {"get_website",{P},S}, + {"set_website_label",{P,S}}, + {"get_website_label",{P},S}, + {"set_authors",{P,A}}, + {"get_authors",{P},A}, + {"set_artists",{P,A}}, + {"get_artists",{P},A}, + {"set_documenters",{P,A}}, + {"get_documenters",{P},A}, + {"set_translator_credits",{P,S}}, + {"get_translator_credits",{P},S}, + {"set_logo",{P,P}}, + {"get_logo",{P},P,0,GdkPixbuf}, + {"set_logo_icon_name",{P,S}}, + {"get_logo_icon_name",{P},S}, + {"add_credit_section",{P,S,A}}, +"GtkAboutDialog"} + +widget[GtkAppChooserDialog] = {"gtk_app_chooser_dialog", +{GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkAppChooser,GObject}, + {"new",{P,I,P},-routine_id("newforURI")}, + {"new_for_uri",{P,I,S},-routine_id("newforURI")}, + {"new_for_file",{P,I,P},-routine_id("newforFIL")}, + {"new_for_content_type",{P,I,S},P}, + {"get_widget",{P},P,0,GtkAppChooserWidget}, + {"set_heading",{P,S}}, + {"get_heading",{P},S}, +"GtkAppChooserDialog"} + + function newforURI(atom parent, integer flags, object uri) + ---------------------------------------------------------- + return gtk_func("gtk_app_chooser_dialog_new_for_content_type",{P,I,P}, + {parent,flags,uri}) + end function + + function newforFIL(atom parent, integer flags, object fil) + ---------------------------------------------------------- + fil = allocate_string(canonical_path(fil)) + fil = gtk_func("g_file_new_for_path",{S},{fil}) + return gtk_func("gtk_app_chooser_dialog_new",{P,I,P}) + end function + +widget[GtkColorChooserDialog] = {"gtk_color_chooser_dialog", +{GtkColorChooser,GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{S,P},P}, +"GtkColorChooserDialog"} + +widget[GtkColorSelectionDialog] = {"gtk_color_selection_dialog", +{GtkColorSelection,GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{S},P}, + {"get_color_selection",{P},P,0,GtkColorSelection}, +"GtkColorSelectionDialog"} + +widget[GtkFileChooserDialog] = {"gtk_file_chooser_dialog", +{GtkFileChooser,GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{S,P,I,S},P}, +"GtkFileChooserDialog"} + +widget[GtkFontChooserDialog] = {"gtk_font_chooser_dialog", +{GtkFontChooser,GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{S,P},P}, +"GtkFontChooserDialog"} + +widget[GtkStock] = {"gtk_stock", +{GObject}, +"GtkStock"} + +widget[GtkStyleProvider] = {"gtk_style_provider", +{0}, + {"get_style_property",{P,P,I,P,P},B}, +"GtkStyleProvider"} + +widget[GtkStyleContext] = {"gtk_style_context", +{GObject}, + {"new",{},P}, + {"add_provider",{P,P,I}}, + {"add_provider_for_screen",{P,P,P,I},-routine_id("addProvider")}, + {"get",{P,I,S,P,I}}, + {"get_junction_sides",{P},I}, + {"get_parent",{P},P,0,GtkStyleContext}, + {"get_path",{P},P,0,GtkWidgetPath}, + {"get_property",{P,S,I,P}}, + {"get_screen",{P},P,0,GdkScreen}, + {"get_frame_clock",{P},P,0,GdkFrameClock}, + {"get_state",{P},I}, + {"get_style",{P,S,P,I}}, + {"get_style_property",{P,S,P}}, + {"get_section",{P,S},P,0,GtkCssSection}, + {"get_color",{P,I,P}}, + {"get_background_color",{P,I,P}}, -- Deprecated 3.16 + {"get_border_color",{P,I,P}}, -- Deprecated 3.16 + {"get_border",{P,I,P}}, + {"get_padding",{P,I,P}}, + {"get_margin",{P,I,P}}, + {"invalidate",{P}}, + {"lookup_color",{P,S,P},B}, + {"remove_provider",{P,P}}, + {"remove_provider_for_screen",{P,P}}, + {"reset_widgets",{P}}, + {"set_background",{P,P}}, + {"restore",{P}}, + {"save",{P}}, + {"set_junction_sides",{P,I}}, + {"set_parent",{P,P}}, + {"set_path",{P,P}}, + {"add_class",{P,S}}, + {"remove_class",{P,S}}, + {"has_class",{P,S},B}, + {"list_classes",{P},P,0,GList}, + {"add_region",{P,S,I}}, -- Deprecated 3.14 + {"remove_region",{P,S}}, -- Deprecated 3.14 + {"has_region",{P,S,I},B}, -- Deprecated 3.14 + {"list_regions",{P},P,0,GList}, -- Deprecated 3.14 + {"get_screen",{P,P}}, + {"set_frame_clock",{P,P}}, + {"set_state",{P,I}}, + {"set_scale",{P,I}}, -- GTK3.10 + {"get_scale",{P},I}, -- GTK3.10 +"GtkStyleContext"} + + function addProvider(atom context, atom scrn, atom provider, integer priority) + ------------------------------------------------------------------------------ + gtk_proc("gtk_style_context_add_provider_for_screen",{P,P,I},{scrn,provider,priority}) + return 1 + end function + +widget[GtkRecentChooserDialog] = {"gtk_recent_chooser_dialog", +{GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkRecentChooser,GObject}, + {"new",{S,P,P},P}, + {"new_for_manager",{S,P,P,P},P}, +"GtkRecentChooserDialog"} + +widget[GtkPrintSettings] = {"gtk_print_settings", +{GObject}, + {"new",{},P}, + {"new_from_file",{S,P},P,0,GtkPrintSettings}, + {"new_from_key_file",{S,P},P,0,GtkPrintSettings}, + {"load_file",{P,S,P},B}, + {"to_file",{P,S,P},B}, + {"load_key_file",{P,P,S,P},B}, + {"to_key_file",{P,P,S}}, + {"copy",{P},P,0,GtkPrintSettings}, + {"has_key",{P,S},B}, + {"get",{P,S},S}, + {"set",{P,S,S}}, + {"unset",{P,S}}, + {"foreach",{P,P,P}}, + {"get_bool",{P,S},B}, + {"set_bool",{P,S,B}}, + {"get_double",{P,S},D}, + {"get_double_with_default",{P,S,D},D}, + {"set_double",{P,S,D}}, + {"get_length",{P,S,I},D}, + {"set_length",{P,S,D,I}}, + {"get_int",{P,S},I}, + {"get_int_with_default",{P,S,I},I}, + {"set_int",{P,S,I}}, + {"get_printer",{P},S}, + {"set_printer",{P,S}}, + {"get_orientation",{P},I}, + {"set_orientation",{P,I}}, + {"get_paper_size",{P},P,0,GtkPaperSize}, + {"set_paper_size",{P,P}}, + {"get_paper_width",{P,I},D}, + {"set_paper_width",{P,D,I}}, + {"get_paper_height",{P,I},D}, + {"set_paper_height",{P,D,I}}, + {"get_use_color",{P},B}, + {"set_use_color",{P,B}}, + {"get_collate",{P},B}, + {"set_collate",{P,B}}, + {"get_reverse",{P},B}, + {"set_reverse",{P,B}}, + {"get_duplex",{P},I}, + {"set_duplex",{P,I}}, + {"get_quality",{P},I}, + {"set_quality",{P,I}}, + {"get_n_copies",{P},I}, + {"set_n_copies",{P,I}}, + {"get_number_up",{P},I}, + {"set_number_up",{P,I}}, + {"get_number_up_layout",{P},I}, + {"set_number_up_layout",{P,I}}, + {"get_resolution",{P},I}, + {"set_resolution",{P,I}}, + {"get_resolution_x",{P},I}, + {"get_resolution_y",{P},I}, + {"get_printer_lpi",{P},D}, + {"set_printer_lpi",{P,D}}, + {"get_scale",{P},D}, + {"set_scale",{P,D}}, + {"get_print_pages",{P},I}, + {"set_print_pages",{P,I}}, + {"get_page_ranges",{P,I},P,0,GtkPageRange}, + {"set_page_ranges",{P,P},-routine_id("setPageRanges")}, + {"get_page_set",{P},I}, + {"set_page_set",{P,I}}, + {"get_default_source",{P},S}, + {"set_default_source",{P,S}}, + {"get_media_type",{P},S}, + {"set_media_type",{P,S}}, + {"get_dither",{P},S}, + {"set_dither",{P,S}}, + {"get_finishings",{P},S}, + {"set_finishings",{P,S}}, + + {"get_output_bin",{P},S}, + {"set_output_bin",{P,S}}, +"GtkPrintSettings"} + + function setPageRanges(atom x, object r) + ---------------------------------------- + atom m = allocate_data(8) + poke(m,r[1]) + poke(m+4,r[2]) + + gtk_proc("gtk_print_settings_set_pages_ranges",{P,P,I},{x,m,2}) + return 1 + end function + +widget[GtkPaperSize] = {"gtk_paper_size", +{0}, + {"new",{S},P}, + {"new_from_ppd",{S,S,D,D},P}, + {"new_from_ipp",{S,D,D},P,0,GtkPaperSize}, -- 3.16 + {"new_custom",{S,S,D,D,I},P}, + {"copy",{P},P,0,GtkPaperSize}, + {"is_equal",{P,P},B}, + {"get_name",{P},S}, + {"get_display_name",{P},S}, + {"get_ppd_name",{P},S}, + {"get_width",{P,I},D}, + {"get_height",{P,I},D}, + {"is_custom",{P},B}, + {"set_size",{P,D,D,I}}, + {"get_default_top_margin",{P,I},D}, + {"get_default_bottom_margin",{P,I},D}, + {"get_default_left_margin",{P,I},D}, + {"get_default_right_margin",{P,I},D}, +"GtkPaperSize"} + +widget[GtkPageSetup] = {"gtk_page_setup", +{GObject}, + {"new",{},P}, + {"copy",{P},P,0,GtkPageSetup}, + {"get_orientation",{P},I}, + {"set_orientation",{P,I}}, + {"get_paper_size",{P},P,0,GtkPaperSize}, + {"set_paper_size",{P,P}}, + {"get_top_margin",{P,I},D}, + {"set_top_margin",{P,D,I}}, + {"get_bottom_margin",{P,I},D}, + {"set_bottom_margin",{P,D,I}}, + {"get_left_margin",{P,I},D}, + {"set_left_margin",{P,D,I}}, + {"get_right_margin",{P,I},D}, + {"set_right_margin",{P,D,I}}, + {"set_paper_size_and_default_margins",{P,P}}, + {"get_paper_width",{P,I},D}, + {"get_paper_height",{P,I},D}, + {"get_page_width",{P,I},D}, + {"get_page_height",{P,I},D}, + {"new_from_file",{S,P},P,0,GtkPageSetup}, + {"load_file",{P,S,P},B}, + {"to_file",{P,S},-routine_id("setPgSetupToFile")}, +"GtkPageSetup"} + + function setPgSetupToFile(atom setup, object filename) + ------------------------------------------------------ + atom err = allocate(8) err = 0 + return gtk_func("gtk_page_setup_to_file",{P,P,P},{setup,filename,err}) + end function + +widget[GtkPrintOperation] = {"gtk_print_operation", +{GObject}, + {"new",{},P}, + {"set_allow_async",{P,B}}, + {"get_error",{P,P}}, + {"set_default_page_setup",{P,P}}, + {"get_default_page_setup",{P},P,0,GtkPageSetup}, + {"set_print_settings",{P,P}}, + {"get_print_settings",{P},P,0,GtkPrintSettings}, + {"set_job_name",{P,S}}, + {"get_job_name",{P},-routine_id("getPrintOpJobName")}, + {"set_n_pages",{P,I}}, + {"get_n_pages_to_print",{P},I}, + {"set_current_page",{P,I}}, + {"set_use_full_page",{P,B}}, + {"set_unit",{P,I}}, + {"set_export_filename",{P,S}}, + {"set_show_progress",{P,B}}, + {"set_track_print_status",{P,B}}, + {"set_custom_tab_label",{P,S}}, + {"run",{P,P,P,P},I}, + {"cancel",{P}}, + {"draw_page_finish",{P}}, + {"set_defer_drawing",{P}}, + {"get_status",{P},I}, + {"get_status_string",{P},S}, + {"is_finished",{P},B}, + {"set_support_selection",{P,B}}, + {"get_support_selection",{P},B}, + {"set_has_selection",{P,B}}, + {"get_has_selection",{P},B}, + {"set_embed_page_setup",{P,B}}, + {"get_embed_page_setup",{P},B}, +"GtkPrintOperation"} + + function getPrintOpJobName(atom op) + ----------------------------------- + object job = allocate(32), err = allocate(32) err = 0 + gtk_func("g_object_get",{P,S,P,P},{op,"job name",job,err}) + return peek_string(peek4u(job)) + end function + +widget[GtkPrintContext] = {"gtk_print_context", +{GObject}, + {"get_cairo_context",{P},P}, + {"set_cairo_context",{P,P,D,D}}, + {"get_page_setup",{P},P,0,GtkPageSetup}, + {"get_width",{P},D}, + {"get_height",{P},D}, + {"get_dpi_x",{P},D}, + {"get_dpi_y",{P},D}, + {"get_pango_fontmap",{P},P,0,PangoFontMap}, + {"create_pango_context",{P},P,0,PangoContext}, + {"create_pango_layout",{P},P,0,PangoLayout}, + {"get_hard_margins",{P,D,D,D,D},B}, +"GtkPrintContext"} + +widget[GtkPrintUnixDialog] = {"gtk_print_unix_dialog", +{GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{S,P},P}, + {"set_page_setup",{P,P}}, + {"get_page_setup",{P},P,0,GtkPageSetup}, + {"set_current_page",{P,I}}, + {"get_current_page",{P},I}, + {"set_settings",{P,P}}, + {"get_settings",{P},P,0,GtkPrintSettings}, + {"get_selected_printer",{P},P,0,GtkPrinter}, + {"add_custom_tab",{P,P,P}}, + {"set_support_selection",{P,B}}, + {"get_support_selection",{P},B}, + {"get_has_selection",{P},B}, + {"set_embed_page_setup",{P,B}}, + {"get_embed_page_setup",{P},B}, + {"set_manual_capabilities",{P,I}}, + {"get_manual_capabilities",{P},I}, +"GtkPrintUnixDialog"} + +widget[GtkPageSetupUnixDialog] = {"gtk_page_setup_unix_dialog", +{GtkDialog,GtkWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{S,P},P}, + {"set_page_setup",{P,P}}, + {"get_page_setup",{P},P,0,GtkPageSetup}, + {"set_print_settings",{P,P}}, + {"get_print_settings",{P},P,0,GtkPrintSettings}, +"GtkPageSetupUnixDialog"} + +widget[GtkListBox] = {"gtk_list_box", -- new in GTK 3.10 +{GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"prepend",{P,P}}, + {"insert",{P,P,I}}, + {"select_row",{P,P}}, + {"select_all",{P}}, -- 3.14 + {"unselect_all",{P}}, -- 3.14 + {"unselect_row",{P,P}}, -- 3.14 + {"get_selected_row",{P},P}, + {"get_selected_rows",{P},A},-- 3.14 + {"row_is_selected",{P},B}, -- 3.14 + {"selected_foreach",{P,P,P}}, -- 3.14 + {"set_selection_mode",{P,I}}, + {"get_selection_mode",{P},I}, + {"set_activate_on_single_click",{P,B}}, + {"get_activate_on_single_click",{P},B}, + {"set_adjustment",{P,P}}, + {"get_adjustment",{P},P,0,GtkAdjustment}, + {"set_placeholder",{P,P}}, + {"get_row_at_index",{P,I},P,0,GtkListBoxRow}, + {"get_row_at_y",{P,I},P,0,GtkListBoxRow}, + {"invalidate_filter",{P}}, + {"invalidate_headers",{P}}, + {"invalidate_sort",{P}}, + {"set_filter_func",{P,P,P,P}}, + {"set_header_func",{P,P,P,P}}, + {"set_sort_func",{P,P,P,P}}, + {"drag_highlight_row",{P,P}}, + {"drag_unhighlight_row",{P}}, + {"bind_model",{P,P,P,P,P}}, +"GtkListBox"} + +widget[GtkListBoxRow] = {"gtk_list_box_row", +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"changed",{P}}, + {"get_header",{P},P,0,GtkWidget}, + {"get_type",{},I}, + {"set_header",{P,P}}, + {"get_index",{P},I}, + {"set_activatable",{P,B}}, + {"set_selectable",{P,B}}, + {"get_selectable",{P},B}, +"GtkListBoxRow"} + +widget[GtkPopover] = {"gtk_popover", -- new in GTK 3.12 +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{P},P}, + {"new_from_model",{P,P},P}, + {"bind_model",{P,P,S}}, + {"set_relative_to",{P,P}}, + {"get_relative_to",{P},P,0,GtkWidget}, + {"set_pointing_to",{P,P}}, + {"get_pointing_to",{P,P},B}, + {"set_position",{P,I}}, + {"get_position",{P},I}, + {"set_modal",{P,B}}, + {"get_modal",{P},B}, + {"get_transitions_enabled",{P},B}, + {"set_transitions_enabled",{P,B}}, +"GtkPopover"} + +widget[GtkPopoverMenu] = {"gtk_popover_menu", -- 3.16 +{GtkPopover,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"open_submenu",{P,S}}, +"GtkPopoverMenu"} + +widget[GtkPlacesSidebar] = {"gtk_places_sidebar", -- new 3.10 +{GtkScrolledWindow,GtkBin,GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"set_open_flags",{P,I}}, + {"get_open_flags",{P},I}, + {"set_location",{P,P}}, + {"get_location",{P},P,0,GFile}, + {"set_show_desktop",{P,B}}, + {"get_show_desktop",{P},B}, + {"add_shortcut",{P,P}}, + {"remove_shortcut",{P,P}}, + {"list_shortcuts",{P},P,0,GSList}, + {"get_nth_bookmark",{P,I},P,0,GFile}, + {"get_show_connect_to_server",{P},B}, + {"set_show_connect_to_server",{P,B}}, + {"set_local_only",{P,B}}, -- 3.12 + {"get_local_only",{P},B}, -- 3.12 + {"get_show_enter_location",{P},B}, --3.14 + {"set_show_enter_location",{P,B}}, --3.14 +"GtkPlacesSidebar"} + +widget[GtkHeaderBar] = {"gtk_header_bar", -- new in GTK 3.10 +{GtkContainer,GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"set_title",{P,S}}, + {"get_title",{P},S}, + {"set_subtitle",{P,S}}, + {"get_subtitle",{P},S}, + {"set_has_subtitle",{P,B}}, -- 3.12 + {"get_has_subtitle",{P},B}, -- 3.12 + {"set_custom_title",{P,P}}, + {"get_custom_title",{P},P,0,GtkWidget}, + {"pack_start",{P,P}}, + {"pack_end",{P,P}}, + {"set_show_close_button",{P,B}}, + {"get_show_close_button",{P},B}, + {"set_decoration_layout",{P,S}}, -- 3.12 + {"get_decoration_layout",{P},S}, -- 3.12 +"GtkHeaderBar"} + +widget[GtkPrinter] = {"gtk_printer", +{GObject}, + {"new",{S,P,B},P}, + {"get_backend",{P},P}, + {"get_name",{P},S}, + {"get_state_message",{P},S}, + {"get_description",{P},S}, + {"get_location",{P},S}, + {"get_icon_name",{P},S}, + {"get_job_count",{P},I}, + {"is_active",{P},B}, + {"is_paused",{P},B}, + {"is_accepting_jobs",{P},B}, + {"is_virtual",{P},B}, + {"is_default",{P},B}, + {"accepts_ps",{P},B}, + {"accepts_pdf",{P},B}, + {"list_papers",{P},P,0,GList}, + {"compare",{P,P},I}, + {"has_details",{P},B}, + {"request_details",{P}}, + {"get_capabilities",{P},I}, + {"get_default_page_size",{P},P,0,GtkPageSetup}, + {"get_hard_margins",{P,D,D,D,D},B}, +"GtkPrinter"} + +widget[GtkPrintJob] = {"gtk_print_job", +{GObject}, + {"new",{S,P,P,P},P}, + {"get_settings",{P},P,0,GtkPrintSettings}, + {"get_printer",{P},P,0,GtkPrinter}, + {"get_title",{P},S}, + {"get_status",{P},I}, + {"set_source_file",{P,S,P},B}, + {"get_surface",{P,P},P,0,CairoSurface_t}, + {"send",{P,P,P,P}}, + {"set_track_print_status",{P,B}}, + {"get_track_print_status",{P},B}, + {"get_pages",{P},I}, + {"set_pages",{P,I}}, + {"get_page_ranges",{P,I},P,0,GtkPageRange}, + {"set_page_ranges",{P,P},-routine_id("setPageRanges")}, + {"get_page_set",{P},I}, + {"set_page_set",{P,I}}, + {"get_num_copies",{P},I}, + {"set_num_copies",{P,I}}, + {"get_scale",{P},D}, + {"set_scale",{P,D}}, + {"get_n_up",{P},I}, + {"set_n_up",{P,I}}, + {"get_n_up_layout",{P},I}, + {"set_n_up_layout",{P,I}}, + {"get_rotate",{P},B}, + {"set_rotate",{P,B}}, + {"get_collate",{P},B}, + {"set_collate",{P,B}}, + {"get_reverse",{P},B}, + {"set_reverse",{P,B}}, +"GtkPrintJob"} + +widget[GtkFlowBox] = {"gtk_flow_box", -- GTK 3.12 +{GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"insert",{P,P,I}}, + {"get_child_at_index",{P,I},P,0,GtkFlowBoxChild}, + {"set_hadjustment",{P,P}}, + {"set_vadjustment",{P,P}}, + {"set_homogeneous",{P,B}}, + {"get_homogeneous",{P},B}, + {"set_row_spacing",{P,I}}, + {"get_row_spacing",{P},I}, + {"set_column_spacing",{P,I}}, + {"get_column_spacing",{P},I}, + {"set_min_children_per_line",{P,I}}, + {"get_min_children_per_line",{P},I}, + {"set_max_children_per_line",{P,I}}, + {"get_max_children_per_line",{P},I}, + {"set_activate_on_single_click",{P,B}}, + {"get_activate_on_single_click",{P},B}, + {"selected_foreach",{P,P,P}}, + {"get_selected_children",{P},P,0,GList}, + {"select_child",{P,P}}, + {"unselect_child",{P,P}}, + {"select_all",{P}}, + {"unselect_all",{P}}, + {"set_selection_mode",{P,I}}, + {"get_selection_mode",{P},I}, + {"set_filter_func",{P,P,P,P}}, + {"invalidate_filter",{P}}, + {"set_sort_func",{P,P,P,P}}, + {"invalidate_sort",{P}}, +"GtkFlowBox"} + +widget[GtkFlowBoxChild] = {"gtk_flow_box_child", -- GTK 3.12 +{GtkBin,GtkContainer,GtkWidget,GtkBuildable,GtkOrientable,GObject}, + {"new",{},P}, + {"get_index",{P},I}, + {"is_selected",{P},B}, + {"changed",{P}}, +"GtkFlowBoxChild"} + +widget[GtkMountOperation] = {"gtk_mount_operation", +{GObject}, + {"new",{P},P}, + {"is_showing",{P},B}, + {"set_parent",{P,P}}, + {"get_parent",{P},P,0,GtkWindow}, + {"set_screen",{P,P}}, + {"get_screen",{P},P,0,GdkScreen}, +"GtkMountOperation"} + +-- stocklist is not a GTK widget, we just fake it for convenience +widget[GtkStockList] = {"gtk_stocklist", -- deprecated in GTK 3.12+ +{0}, +"GtkStockList"} + + function newStockList() + ----------------------- + object list = gtk_func("gtk_stock_list_ids") + return to_sequence(list) + end function + +widget[GtkEventController] = {"gtk_event_controller", +{GObject}, + {"get_propagation_phase",{P},I}, + {"set_propagation_phase",{P,I}}, + {"handle_event",{P,P},B}, + {"get_widget",{P},P,0,GtkWidget}, + {"reset",{P}}, +"GtkEventController"} + +widget[GtkGesture] = {"gtk_gesture", --GTK3.14 +{GtkEventController,GObject}, + {"get_device",{P},P}, + {"get_window",{P},P}, + {"set_window",{P,P}}, + {"is_active",{P},B}, + {"is_recognized",{P},B}, + {"get_sequence_state",{P,P},I}, + {"set_sequence_state",{P,P,I},B}, + {"set_state",{P,I},B}, + {"get_sequences",{P},A}, + {"handles_sequence",{P,P},B}, + {"get_last_updated_sequence",{P},P}, + {"get_last_event",{P,P},P}, + {"get_point",{P,P,D,D},B}, + {"get_bounding_box",{P,P},B}, + {"get_bounding_box_center",{P,D,D},B}, + {"group",{P,P}}, + {"ungroup",{P}}, + {"get_group",{P},A}, + {"is_grouped_with",{P,P},B}, +"GtkGesture"} + +widget[GtkGestureSingle] = {"gtk_gesture_single", +{GtkGesture,GtkEventController,GObject}, + {"get_exclusive",{P},B}, + {"set_exclusive",{P,B}}, + {"get_touch_only",{P},B}, + {"set_touch_only",{P,B}}, + {"get_button",{P},I}, + {"set_button",{P,I}}, + {"get_current_button",{P},I}, + {"get_current_sequence",{P},P}, +"GtkGestureSingle"} + +widget[GtkGestureRotate] = {"gtk_gesture_rotate", +{GtkGesture,GtkEventController,GObject}, + {"new",{P},P}, + {"get_angle_delta",{P},D}, +"GtkGestureRotate"} + +widget[GtkGestureZoom] = {"gtk_gesture_zoom", +{GtkGesture,GtkEventController,GObject}, + {"new",{P},P}, + {"get_scale_delta",{P},D}, +"GtkGestureZoom"} + +widget[GtkGestureDrag] = {"gtk_gesture_drag", -- 3.14 +{GtkGestureSingle,GtkGesture,GtkEventController,GObject}, + {"new",{P},P}, + {"get_start_point",{P,D,D},B}, + {"get_offset",{P,D,D},B}, +"GtkGestureDrag"} + +widget[GtkGesturePan] = {"gtk_gesture_pan", +{GtkGestureDrag,GtkGestureSingle,GtkGesture,GtkEventController,GObject}, + {"new",{P,I},P}, + {"get_orientation",{P},I}, + {"set_orientation",{P,I}}, +"GtkGesturePan"} + +widget[GtkGestureSwipe] = {"gtk_gesture_swipe", +{GtkGestureSingle,GtkGesture,GtkEventController,GObject}, + {"new",{P},P}, + {"get_velocity",{P,D,D},B}, +"GtkGestureSwipe"} + +widget[GtkGestureLongPress] = {"gtk_gesture_long_press", +{GtkGestureSingle,GtkGesture,GtkEventController,GObject}, + {"new",{P},P}, +"GtkGestureLongPress"} + +widget[GtkGestureMultiPress] = {"gtk_gesture_multi_press", +{GtkGestureSingle,GtkGesture,GtkEventController,GObject}, + {"new",{P},P}, + {"get_area",{P,P},B}, + {"set_area",{P,P}}, +"GtkGestureMultiPress"} + +widget[GdkGLProfile] = {"gdk_gl_profile", + {}, +"GdkGLProfile"} + +widget[GtkGLArea] = {"gtk_gl_area", -- GTK 3.16 +{GtkWidget,GtkBuildable,GObject}, + {"new",{},P}, + {"get_context",{P},P}, + {"set_has_alpha",{P,B}}, + {"get_has_alpha",{P},B}, + {"set_has_depth_buffer",{P,B}}, + {"get_has_depth_buffer",{P},B}, + {"make_current",{P}}, + {"get_auto_render",{P},B}, + {"set_auto_render",{P,B}}, + {"get_error",{P},P}, + {"set_error",{P,P}}, + {"queue_render",{P}}, + {"set_profile",{P,P}}, + {"get_profile",{P},P,0,GdkGLProfile}, + {"get_has_stencil_buffer",{P},B}, + {"set_has_stencil_buffer",{P,B}}, + {"attach_buffers",{P}}, + {"get_required_version",{P,I,I}}, + {"set_required_version",{P,I,I}}, +"GtkGLArea"} + +widget[GdkFrameClock] = {"gdk_frame_clock", +{GObject}, + {"get_frame_time",{P},I}, + {"request_phase",{P,P}}, + {"begin_updating",{P}}, + {"end_updating",{P}}, + {"get_frame_counter",{P},I}, + {"get_history_start",{P},I}, + {"get_timings",{P,I},P}, + {"get_current_timings",{P},P,0,GdkFrameTimings}, + {"get_refresh_info",{P,I,I,I}}, +"GdkFrameClock"} + +widget[GdkFrameTimings] = {"gdk_frame_timings", +{GObject}, + {"get_frame_counter",{P},I}, + {"get_complete",{P},B}, + {"get_frame_time",{P},I}, + {"get_presentation_time",{P},I}, + {"get_refresh_interval",{P},I}, + {"get_predicted_presentation_time",{P},I}, +"GdkFrameTimings"} + +widget[GdkEvent] = {"gdk_event", +{GObject}, + {"new",{},P}, + {"peek",{},P,0,GdkEvent}, + {"get",{},P,0,GdkEvent}, + {"put",{P}}, + {"copy",{P},P,0,GdkEvent}, + {"get_axis",{P,I,D},B}, + {"get_button",{P,P},B}, + {"get_keycode",{P,P},B}, + {"get_keyval",{P,P},B}, + {"get_root_coords",{P,D,D},B}, + {"get_scroll_direction",{P,P},B}, + {"get_scroll_deltas",{P,D,D},B}, + {"get_state",{P,P},B}, + {"get_time",{P},I}, + {"get_window",{P},P,0,GdkWindow}, + {"get_event_type",{P},I}, + {"get_event_sequence",{P},P,0,GdkEventSequence}, + {"request_motions",{P}}, + {"get_click_count",{P,P},B}, + {"get_coords",{P,D,D},B}, + {"triggers_context_menu",{P},B}, + {"handler_set",{P,P,P}}, + {"set_screen",{P,P}}, + {"get_screen",{P},P,0,GdkScreen}, + {"set_device",{P,P}}, + {"get_device",{P},P,0,GdkDevice}, + {"set_source_device",{P,P}}, + {"get_source_device",{P},P,0,GdkDevice}, +"GdkEvent"} + +widget[GdkEventSequence] = {"gdk_event_sequence", +{GdkEvent}, +"GdkEventSequence"} + +widget[GdkX11Display] = {"gdk_x11_display", +{GObject}, + {"get_user_time",{P},I}, + {"broadcase_startup_message",{P,S,S,I}}, + {"get_startup_notification_id",{P},S}, + {"set_startup_notification_id",{P,S}}, + {"get_xdisplay",{P},P}, + {"grab",{P}}, + {"ungrab",{P}}, + {"set_cursor_theme",{P,S,I}}, + {"set_window_scale",{P,I}}, + {"get_glx_version",{P,I,I},B}, +"GdkX11Display"} + +widget[GdkX11Screen] = {"gdk_x11_screen", +{GObject}, + {"get_screen_number",{P},I}, + {"get_xscreen",{P},P}, + {"get_window_manager_name",{P},S}, + {"get_monitor_output",{P,I},I}, + {"lookup_visual",{P,I},P,0,GdkVisual}, + {"get_number_of_desktops",{P},I}, + {"get_current_desktop",{P},I}, +"GdkX11Screen"} + +widget[GdkX11Window] = {"gdk_x11_window", +{GObject}, + {"lookup_for_display",{P,P},P,0,GdkWindow}, + {"get_xid",{P},P}, + {"move_to_current_desktop",{P}}, + {"move_to_desktop",{P,I}}, + {"get_desktop",{P},I}, +"GdkX11Window"} + +widget[GdkGLContext] = {"gdk_gl_context", +{GObject}, + {"new",{},-routine_id("glContext")}, + {"get_current",{},-routine_id("glContext")}, + {"clear_current",{}}, + {"make_current",{P}}, + {"get_window",{P},P,0,GdkWindow}, + {"get_visual",{P},P,0,GdkVisual}, +"GdkGLContext"} + + function glContext() + return c_func("gdk_gl_context_get_current") + end function + +widget[GtkBindingSet] = {"gtk_binding_set", +{GObject}, + {"new",{S},P}, + {"by_class",{P},P}, + {"find",{S},P}, + {"activate",{P,I,I,P},B}, + {"add_path",{P,P,S,I}}, +"GtkBindingSet"} + +widget[GtkBindingEntry] = {"gtk_binding_entry", +{GtkBindingSet}, + {"add_signal",{P,I,I,S,P}}, + {"add_signal_from_string",{P,S},I}, + {"skip",{P,I,I}}, + {"remove",{P,I,I}}, +"GtkBindingEntry"} + +widget[GdkPixbufAnimation] = {"gdk_pixbuf_animation", +{GdkPixbuf,GObject}, + {"new",{P},-routine_id("newPixbufAni")}, +"GdkPixbufAnimation"} + + function newPixbufAni(object name) + atom err = allocate(32) err = 0 + return gtk_func("gdk_pixbuf_animation_new_from_file",{P,P}, + {allocate_string(name),err}) + end function + +widget[PangoFont] = {"pango_font", +{0}, + {"get_metrics",{P,P},P}, + {"get_font_map",{P},P,0,PangoFontMap}, +"PangoFont"} + +widget[PangoFontDescription] = {"pango_font_description", +{PangoFont}, + {"new",{P},-routine_id("newPangoFontDescription")}, + {"set_family",{P,S}}, + {"get_family",{P},S}, + {"set_style",{P,I}}, + {"get_style",{P},I}, + {"set_variant",{P,I}}, + {"get_variant",{P},P}, + {"set_weight",{P,I}}, + {"get_weight",{P},I}, + {"set_stretch",{P,I}}, + {"get_stretch",{P},I}, + {"set_size",{P,I}}, + {"get_size",{P},I}, + {"set_absolute_size",{P,D}}, + {"get_size_is_absolute",{P},B}, + {"set_gravity",{P,I}}, + {"get_gravity",{P},I}, + {"to_string",{P},-routine_id("pfdtoStr")}, + {"to_filename",{P},S}, +"PangoFontDescription"} + + function newPangoFontDescription(object name=0) + ----------------------------------------------- + if atom(name) then + return gtk_func("pango_font_description_new") + end if + return gtk_func("pango_font_description_from_string",{S},{name}) + end function + + function pfdtoStr(atom fd) + -------------------------- + return gtk_str_func("pango_font_description_to_string",{P},{fd}) + end function + +widget[PangoContext] = {"pango_context", +{GObject}, + {"new",{},P}, + {"load_font",{P,P},P}, + {"load_fontset",{P,P,P},P}, + {"get_metrics",{P,P,P},P}, + {"list_families",{P,A,I}}, + {"set_font_description",{P,P}}, + {"get_font_description",{P},P}, + {"set_font_map",{P,P}}, + {"get_font_map",{P},P}, + {"set_base_gravity",{P,I}}, + {"get_language",{P},P}, + {"set_language",{P,P}}, + {"get_layout",{P},P}, + {"get_base_dir",{P},I}, + {"set_base_dir",{P,I}}, + {"get_base_gravity",{P},I}, + {"set_base_gravity",{P,I}}, + {"get_gravity",{P},I}, + {"get_gravity_hint",{P},I}, + {"set_gravity_hint",{P,I}}, + {"get_matrix",{P},P}, + {"set_matrix",{P,P}}, +"PangoContext"} + +widget[PangoFontsetSimple] = {"pango_fontset_simple", +{GObject}, + {"new",{P},P}, + {"append",{P,P}}, + {"size",{P},I}, +"PangoFontsetSimple"} + +widget[PangoFontSet] = {"pango_fontset", +{PangoFontsetSimple}, + {"get_font",{P,I},P,0,PangoFont}, + {"get_metrics",{P},P}, + {"foreach",{P,P,P}}, +"PangoFontSet"} + +widget[PangoFontMap] = {"pango_font_map", +{PangoFontSet}, + {"create_context",{P},P}, + {"load_font",{P,P,S},P}, + {"load_fontset",{P,P,S,P},P}, + {"list_families",{P,A,I}}, + {"get_shape_engine_type",{P},S}, +"PangoFontMap"} + + +widget[PangoFontFace] = {"pango_font_face", +{PangoFontMap}, + {"get_face_name",{P},-routine_id("getFaceName")}, + {"list_sizes",{P,P,I}}, + {"describe",{P},P,0,PangoFontDescription}, + {"is_synthesized",{P},B}, +"PangoFontFace"} + + function getFaceName(atom x) + ----------------------------- + return gtk_str_func("pango_font_face_get_face_name",{P},{x}) + end function + +widget[PangoFontFamily] = {"pango_font_family", +{PangoFontFace}, + {"get_name",{P},-routine_id("getFamilyName")}, + {"is_monospace",{P},B}, +"PangoFontFamily"} + + function getFamilyName(atom x) + ------------------------------ + return gtk_str_func("pango_font_family_get_name",{P},{x}) + end function + +widget[PangoLayout] = {"pango_layout", +{GObject}, + {"new",{P},P}, + {"set_text",{P,P},-routine_id("plSetTxt")}, + {"get_text",{P},S}, + {"set_markup",{P,S,I}}, + {"set_font_description",{P,P}}, + {"get_font_description",{P},P}, + {"set_width",{P,I}}, + {"get_width",{P},I}, + {"set_height",{P,I}}, + {"get_height",{P},I}, + {"set_wrap",{P,I}}, + {"get_wrap",{P},I}, + {"is_wrapped",{P},B}, + {"set_ellipsize",{P,I}}, + {"get_ellipsize",{P},I}, + {"is_ellipsized",{P},B}, + {"set_indent",{P,I}}, + {"get_extents",{P,P,P}}, + {"get_indent",{P},I}, + {"get_pixel_size",{P,I,I}}, + {"get_size",{P,I,I}}, + {"set_spacing",{P,I}}, + {"get_spacing",{P},I}, + {"set_justify",{P,B}}, + {"get_justify",{P},B}, + {"set_auto_dir",{P,B}}, + {"get_auto_dir",{P},B}, + {"set_alignment",{P,P}}, + {"get_alignment",{P},P}, + {"set_tabs",{P,A}}, + {"get_tabs",{P},A}, + {"set_single_paragraph_mode",{P,B}}, + {"get_single_paragraph_mode",{P},B}, + {"get_unknown_glyphs_count",{P},I}, + {"get_log_attrs",{P,P,I}}, + {"get_log_attrs_readonly",{P,I},P}, + {"index_to_pos",{P,I,P}}, + {"index_to_line",{P,I,B,I,I}}, + {"xy_to_line",{P,I,I,I,I},B}, + {"get_cursor_pos",{P,I,P,P}}, + {"move_cursor_visually",{P,B,I,I,I,I,I}}, + {"get_extents",{P,P,P}}, + {"get_pixel_extents",{P,P,P}}, + {"get_size",{P,I,I}}, + {"get_pixel_size",{P,I,I}}, + {"get_baseline",{P},I}, + {"get_line_count",{P},I}, + {"get_line",{P,I},P,0,PangoLayoutLine}, + {"get_line_readonly",{P,I},P,0,PangoLayoutLine}, + {"get_lines",{P},P,0,GSList}, + {"get_lines_readonly",{P},P,0,GSList}, + {"get_iter",{P},P,0,PangoLayoutIter}, +"PangoLayout"} + + function plSetTxt(atom layout, object txt) + gtk_proc("pango_layout_set_text",{P,P,I},{layout,allocate_string(txt),length(txt)}) + return 1 + end function + +widget[PangoLayoutLine] = {"pango_layout_line", +{0}, + {"ref",{P},P}, + {"unref",{P}}, + {"get_extents",{P,P,P}}, + {"get_pixel_extents",{P,P,P}}, + {"index_to_x",{P,I,B,I}}, + {"x_to_index",{P,I,I,I},B}, +"PangoLayoutLine"} + +widget[PangoLayoutIter] = {"pango_layout_iter", +{0}, + {"copy",{P},P,0,PangoLayoutIter}, + {"free",{P}}, + {"next_run",{P},B}, + {"next_char",{P},B}, + {"next_cluster",{P},B}, + {"next_line",{P},B}, + {"at_last_line",{P},B}, + {"get_index",{P},I}, + {"get_baseline",{P},I}, + {"get_run",{P},P,0,PangoLayoutRun}, + {"get_run_readonly",{P},P,0,PangoLayoutRun}, + {"get_line",{P},P,0,PangoLayoutLine}, + {"get_line_readonly",{P},P,0,PangoLayoutLine}, + {"get_layout",{P},P,0,PangoLayout}, + {"get_char_extents",{P,P}}, + {"get_cluster_extents",{P,P,P}}, + {"get_run_extents",{P,P,P}}, + {"get_line_yrange",{P,I,I}}, + {"get_line_extents",{P,P,P}}, + {"get_layout_extents",{P,P,P}}, +"PangoLayoutIter"} + +widget[PangoLayoutRun] = {"pango_layout_run", +{0}, +"PangoLayoutRun"} + +widget[PangoTabArray] = {"pango_tab_array", +{0}, +"PangoTabArray"} + +widget[PangoLanguage] = {"pango_language", +{GObject}, + {"new",{S},-routine_id("newPangoLanguage")}, + {"get_default",{P},-routine_id("getDefaultLanguage")}, + {"get_sample_string",{P},-routine_id("getSampleStr")}, + {"to_string",{P},S}, + {"matches",{P,S},B}, + {"includes_script",{P,P},B}, +"PangoLanguage"} + + function newPangoLanguage(object s) + ----------------------------------- + return gtk_func("pango_language_from_string",{S},{s}) + end function + + function getDefaultLanguage(object junk) + ---------------------------------------- + return gtk_str_func("pango_language_get_default") + end function + + function getSampleStr(object x) + ------------------------------- + return gtk_str_func("pango_language_get_sample_string",{P},{x}) + end function + +widget[PangoLayout] = {"pango_layout", +{GObject}, + {"new",{P},P}, + {"set_text",{P,P},-routine_id("plSetTxt")}, + {"get_text",{P},S}, + {"set_markup",{P,S,I}}, + {"set_font_description",{P,P}}, + {"get_font_description",{P},P}, + {"set_width",{P,I}}, + {"get_width",{P},I}, + {"set_height",{P,I}}, + {"get_height",{P},I}, + {"set_wrap",{P,I}}, + {"get_wrap",{P},I}, + {"is_wrapped",{P},B}, + {"set_ellipsize",{P,I}}, + {"get_ellipsize",{P},I}, + {"is_ellipsized",{P},B}, + {"set_indent",{P,I}}, + {"get_extents",{P,P,P}}, + {"get_indent",{P},I}, + {"get_pixel_size",{P,I,I}}, + {"get_size",{P,I,I}}, + {"set_spacing",{P,I}}, + {"get_spacing",{P},I}, + {"set_justify",{P,B}}, + {"get_justify",{P},B}, + {"set_auto_dir",{P,B}}, + {"get_auto_dir",{P},B}, + {"set_alignment",{P,P}}, + {"get_alignment",{P},P}, + {"set_tabs",{P,A}}, + {"get_tabs",{P},A}, + {"set_single_paragraph_mode",{P,B}}, + {"get_single_paragraph_mode",{P},B}, + {"get_unknown_glyphs_count",{P},I}, + {"get_log_attrs",{P,P,I}}, + {"get_log_attrs_readonly",{P,I},P}, + {"index_to_pos",{P,I,P}}, + {"index_to_line",{P,I,B,I,I}}, + {"xy_to_line",{P,I,I,I,I},B}, + {"get_cursor_pos",{P,I,P,P}}, + {"move_cursor_visually",{P,B,I,I,I,I,I}}, + {"get_extents",{P,P,P}}, + {"get_pixel_extents",{P,P,P}}, + {"get_size",{P,I,I}}, + {"get_pixel_size",{P,I,I}}, + {"get_baseline",{P},I}, + {"get_line_count",{P},I}, + {"get_line",{P,I},P,0,PangoLayoutLine}, + {"get_line_readonly",{P,I},P,0,PangoLayoutLine}, + {"get_lines",{P},P,0,GSList}, + {"get_lines_readonly",{P},P,0,GSList}, + {"get_iter",{P},P,0,PangoLayoutIter}, +"PangoLayout"} + +widget[GdkCairo_t] = {"gdk_cairo", +{Cairo_t}, + {"new",{P},-routine_id("newGdkCairo")}, + {"draw_from_gl",{P,P,I,I,I,I,I,I,I}}, -- 3.16 + {"get_clip_rectangle",{P,P},B}, + {"set_source_pixbuf",{P,P,D,D}}, + {"set_source_window",{P,P,D,D}}, + {"region",{P,P}}, + {"region_create_from_surface",{P},P}, + {"surface_create_from_pixbuf",{P,I,P},P,0,CairoSurface_t}, + {"set_source_rgba",{P,I,I,I,D},-routine_id("setCairoRGBA")}, + {"set_color",{P,P},-routine_id("setCairoColor")}, +"GdkCairo_t"} + + function newGdkCairo(atom win) + ------------------------------ + return gtk_func("gdk_cairo_create",{P},{win}) + end function + + ---------------------------------------------------------------- + -- to use the Cairo color specs, where colors are 0.0 => 1.0 + ---------------------------------------------------------------------- + function setCairoRGBA(atom cr, atom r, atom g, atom b, atom a=1) + gtk_proc("cairo_set_source_rgba",{P,D,D,D,D},{cr,r,g,b,a}) + return 1 + end function + + -------------------------------------------- + -- it's easier to use named colors + -------------------------------------------- + function setCairoColor(atom cr, object color) + if atom(color) then color = sprintf("#%06x",color) end if + color = to_rgba(color) + color = from_rgba(color,7) + setCairoRGBA(cr,color[1],color[2],color[3],color[4]) + return 1 + end function + +widget[Cairo_t] = {"cairo", +{GObject}, + {"create",{P},P}, + {"reference",{P},P}, + {"destroy",{P}}, + {"status",{P},I}, + {"save",{P}}, + {"restore",{P}}, + {"get_target",{P},P,0,CairoSurface_t}, + {"push_group",{P}}, + {"push_group_with_content",{P,P}}, + {"pop_group",{P},P}, + {"pop_group_to_source",{P}}, + {"get_group_target",{P},P}, + {"set_source_rgb",{P,D,D,D}}, + {"set_source",{P,P}}, + {"get_source",{P},P}, + {"set_source_surface",{P,P,D,D}}, + {"set_antialias",{P,I}}, + {"get_antialias",{P},I}, + {"set_dash",{P,P,I,D}}, + {"get_dash_count",{P},I}, + {"get_dash",{P,D,D}}, + {"set_fill_rule",{P,I}}, + {"get_fill_rule",{P},I}, + {"set_line_cap",{P,I}}, + {"get_line_cap",{P},I}, + {"set_line_join",{P,I}}, + {"get_line_join",{P},I}, + {"set_line_width",{P,D}}, + {"get_line_width",{P},D}, + {"set_miter_limit",{P,I}}, + {"get_miter_limit",{P},I}, + {"set_operator",{P,I}}, + {"get_operator",{P},I}, + {"set_tolerance",{P,D}}, + {"get_tolerance",{P},D}, + {"clip",{P}}, + {"clip_preserve",{P}}, + {"clip_extents",{P,D,D,D,D}}, + {"in_clip",{P,D,D},B}, + {"reset_clip",{P}}, + {"rectangle_list_destroy",{P}}, + {"fill",{P}}, + {"fill_preserve",{P}}, + {"fill_extents",{P,D,D,D,D}}, + {"in_fill",{P,D,D},B}, + {"mask",{P,P}}, + {"mask_surface",{P,P,D,D}}, + {"paint",{P}}, + {"paint_with_alpha",{P,D}}, + {"stroke",{P}}, + {"stroke_preserve",{P}}, + {"stroke_extents",{P,D,D,D,D}}, + {"in_stroke",{P,D,D},B}, + {"copy_page",{P}}, + {"show_page",{P}}, + {"copy_path",{P},P}, + {"copy_path_flat",{P},P}, + {"path_destroy",{P}}, + {"append_path",{P,P}}, + {"has_current_point",{P},B}, + {"get_current_point",{P,D,D}}, + {"new_path",{P}}, + {"new_sub_path",{P}}, + {"close_path",{P}}, + {"set_user_data",{P,S,P,P},I}, + {"get_user_data",{P,S}}, + {"arc",{P,D,D,D,D,D}}, + {"arc_negative",{P,D,D,D,D,D}}, + {"move_to",{P,D,D}}, + {"rel_move_to",{P,D,D}}, + {"line_to",{P,D,D}}, + {"rel_line_to",{P,D,D}}, + {"rectangle",{P,D,D,D,D}}, + {"glyph_path",{P,I,I}}, + {"text_path",{P,S}}, + {"curve_to",{P,D,D,D,D,D,D}}, + {"rel_curve_to",{P,D,D,D,D,D,D}}, + {"path_extents",{P,D,D,D,D}}, + {"set_font_face",{P,S}}, + {"device_get_type",{P},I}, + {"device_status",{P},I}, + {"status_to_string",{I},S}, + {"translate",{P,D,D}}, + {"scale",{P,D,D}}, + {"rotate",{P,D}}, + {"transform",{P,P}}, + {"translate",{P,D,D}}, + {"scale",{P,D,D}}, + {"rotate",{P,D}}, + {"transform",{P,P}}, + {"set_matrix",{P,P}}, + {"get_matrix",{P,P}}, + {"identity_matrix",{P}}, + {"user_to_device",{P,D,D}}, + {"user_to_device_distance",{P,D,D}}, + {"device_to_user",{P,D,D}}, + {"device_to_user_distance",{P,D,D}}, + {"version",{},I}, + {"version_string",{},S}, + {"set_font_size",{P,D}}, + {"set_font_matrix",{P,P}}, + {"get_font_matrix",{P,P}}, + {"set_font_options",{P,P}}, + {"get_font_options",{P,P}}, + {"select_font_face",{P,S,I,I}}, + {"get_font_face",{P},P}, + {"set_scaled_font",{P,P}}, + {"get_scaled_font",{P},P}, + {"show_glyphs",{P,P}}, + {"show_text_glyphs",{P,S,I,P,I,P,I,I}}, + {"font_extents",{P,P}}, + {"text_extents",{P,S,P}}, + {"glyph_extents",{P,P,I,P}}, + {"toy_font_face_create",{S,I,I},P}, + {"toy_font_face_get_slant",{P},I}, + {"toy_font_face_get_weight",{P},I}, + {"glyph_allocate",{I},P}, + {"glyph_free",{P}}, + {"text_cluster_allocate",{I},P}, + {"text_cluster_free",{P}}, + {"show_text",{P,S}}, + {"set_source_rgba",{P,D,D,D,D},-routine_id("setCairoRGBA")}, + {"set_color",{P,S},-routine_id("setCairoColor")}, +"Cairo_t"} + +widget[CairoPattern_t] = {0, +{Cairo_t}, +"CairoPattern_t"} + +widget[CairoPattern] = {"cairo_pattern", +{CairoPattern_t}, + {"new",{P},-routine_id("newCairoPattern")}, + {"add_color_stop_rgb",{P,D,D,D,D}}, + {"add_color_stop_rgba",{P,D,D,D,D,D}}, + {"get_color_stop_count",{P,I},P,0,CairoStatus_t}, + {"get_color_stop_rgba",{P,I,D,D,D,D,D},P,0,CairoStatus_t}, + {"create_rgb",{D,D,D},P,0,CairoPattern_t}, + {"create_rgba",{D,D,D,D},P,0,CairoPattern_t}, + {"get_rgba",{P,D,D,D,D},P,0,CairoPattern_t}, + {"create_for_surface",{P},P,0,CairoPattern_t}, + {"reference",{P},P,0,CairoPattern_t}, + {"destroy",{P}}, + {"status",{P},P,0,CairoStatus_t}, + {"set_extend",{P,I}}, + {"get_extent",{P},I}, + {"set_filter",{P,I}}, + {"get_filter",{P},I}, + {"set_matrix",{P,P}}, + {"get_matrix",{P,P}}, + {"get_type",{P},I}, + {"get_reference_count",{P},I}, +"CairoPattern"} + + function newCairoPattern(atom surf) + ----------------------------------- + return gtk_func("cairo_pattern_create_for_surface",{P},{surf}) + end function + +widget[CairoLinearGradient] = {"cairo_pattern", +{CairoPattern}, + {"new",{D,D,D,D},-routine_id("newLinearGradient"),0,CairoPattern_t}, + {"get_linear_points",{P,D,D,D,D},P,0,CairoStatus_t}, +"CairoLinearGradient"} + + function newLinearGradient(atom a, atom b, atom c, atom d) + ---------------------------------------------------------- + return gtk_func("cairo_pattern_create_linear",{D,D,D,D},{a,b,c,d}) + end function + +widget[CairoRadialGradient] = {"cairo_pattern", +{CairoPattern}, + {"new",{D,D,D,D,D,D},-routine_id("newRadialGradient"),0,CairoPattern_t}, + {"get_radial_circles",{P,D,D,D,D,D,D},P,0,CairoStatus_t}, +"CairoRadialGradient"} + + function newRadialGradient(atom a, atom b, atom c, atom d, atom e, atom f) + -------------------------------------------------------------------------- + return gtk_func("cairo_pattern_create_radial",{D,D,D,D,D,D},{a,b,c,d,e,f}) + end function + +widget[CairoRegion_t] = {"cairo_region_t", +{Cairo_t}, +"CairoRegion_t"} + +widget[CairoSurface_t] = {"cairo_surface_t", +{Cairo_t}, + {"get_write_to_png",{P,S},-routine_id("writetoPNG")}, + {"create_similar",{P,P,I,I},P,0,CairoSurface_t}, + {"create_for_rectangle",{P,D,D,D,D},P,0,CairoSurface_t}, + {"reference",{P},P,0,CairoSurface_t}, + {"destroy",{P}}, + {"finish",{P}}, + {"flush",{P}}, + {"get_font_options",{P,P}}, + {"mark_dirty",{P}}, + {"mark_dirty_rectangle",{P,I,I,I,I}}, + {"show_page",{P}}, +"CairoSurface_t"} + + function writetoPNG(atom surf, object name) + ------------------------------------------- + return gtk_func("cairo_surface_write_to_png",{P,S},{surf,name}) + end function + +widget[CairoImageSurface] = {"cairo_image_surface", +{CairoSurface_t}, + {"new",{P},-routine_id("newCairoImageSurface")}, + {"get_format",{P},I}, + {"get_width",{P},P}, + {"get_height",{P},P}, + {"get_stride",{P},I}, +"CairoImageSurface"} + + function newCairoImageSurface(object png) + ----------------------------------------- + if string(png) then + png = allocate_string(canonical_path(png)) + end if + return gtk_func("cairo_image_surface_create_from_png",{S},{png}) + end function + +widget[PangoCairoLayout] = {"pango_cairo", +{PangoLayout}, + {"new",{P},-routine_id("newPangoCairoLayout"),0,PangoLayout}, + {"update_layout",{P,P},-routine_id("updateLayout")}, + {"show_glyph_string",{P,P,P}}, + {"show_glyph_item",{P,S,P}}, + {"show_layout",{P,P},-routine_id("showLayout")}, + {"show_layout_line",{P,P}}, + {"layout_line_path",{P,P}}, + {"layout_path",{P,P}}, +"PangoCairoLayout"} + + function newPangoCairoLayout(atom cr) + ------------------------------------- + return gtk_func("pango_cairo_create_layout",{P},{cr}) + end function + + function updateLayout(atom pl, atom cr) + --------------------------------------- + gtk_proc("pango_cairo_update_layout",{P,P},{cr,pl}) + return 1 + end function + + function showLayout(atom pl, atom cr) + ------------------------------------- + gtk_proc("pango_cairo_show_layout",{P,P},{cr,pl}) + return 1 + end function + +--TODO: these are not yet implemented; +widget[CairoFontOptions] = {0,{0},"CairoFontOptions"} +widget[CairoContent_t] = {0,{0},"CairoContent_t"} +widget[CairoStatus_t] = {0,{0},"CairoStatus_t"} +widget[CairoSurfaceType_t] = {0,{0},"CairoSurfaceType_t"} +widget[GtkPrintOperationPreview] = {0,{0},"GtkPrintOperationPreview"} +widget[GtkPageRange] = {0,{0},"GtkPageRange"} +widget[GdkPixbufAnimationIter] = {0,{0},"GdkPixbufAnimationIter"} + +widget[GtkBuildable] = {"gtk_buildable", +{GObject}, + {"set_name",{P,S}}, + {"get_name",{P},S}, + {"add_child",{P,P,P,S}}, + {"set_buildable_property",{P,P,S,P}}, + {"construct_child",{P,P,S},P,0,GObject}, + {"custom_tag_start",{P,P,P,S,P,P},B}, + {"custom_tag_end",{P,P,P,S,P}}, + {"custom_finished",{P,P,P,S,P}}, + {"parser_finished",{P,P}}, + {"get_internal_child",{P,P,S},P,0,GObject}, +"GtkBuildable"} + +widget[GtkBuilder] = {"gtk_builder", +{GObject}, + {"new",{},P}, + {"add_callback_symbol",{P,S,P}}, -- 3.10 + {"lookup_callback_symbol",{P,S},P}, -- 3.10 + {"add_from_file",{P,S},-routine_id("addBuilderObjects")}, + {"add_from_string",{P,P},-routine_id("addBuilderObjectsStr")}, + {"get_object",{P,S},P}, + {"get_objects",{P},P,0,GSList}, + {"set_application",{P,P}}, -- 3.10 + {"get_application",{P},P}, -- 3.10 + {"connect",{P},-routine_id("builder_connect")}, + {"set_translation_domain",{P,S}}, + {"get_translation_domain",{P},S}, + {"set_application",{P,P}}, + {"get_application",{P},P,0,GtkApplication}, + {"get_type_from_name",{P,S},I}, +"GtkBuilder"} + +export constant builder = create(GtkBuilder) +object current_builder_file = "" + +export sequence class_name_index = repeat(0,length(widget)) + for i = 1 to length(widget) do + if sequence(widget[i]) then + class_name_index[i] = widget[i][$] + end if + end for + + constant bad_from_file = define_func("gtk_builder_add_from_file",{P,P,P},I) + constant bad_from_string = define_func("gtk_builder_add_from_string",{P,P,I,P},I) + + -- add objects from Glade XML file; + function addBuilderObjects(atom bld, object fname) + current_builder_file = fname + atom err = allocate(32) err = 0 + integer result = c_func(bad_from_file,{bld,fname,err}) + if result = 0 then + printf(1,"Error loading Builder from file: %s \n",{current_builder_file}) + printf(1,"Possible GTK version mismatch or other error in Glade.\n\n") + ? 1/0 + end if + return result + end function + + -- add object from string or include-file contents; + function addBuilderObjectsStr(atom bld, object str) + current_builder_file = str + atom err = allocate(32) err = 0 + integer len = length(str) + str = allocate_string(str) + integer result = c_func(bad_from_string,{bld,str,len,err}) + if result = 0 then + printf(1,"Error %d loading Builder from string or include: %s!\n", + {err,current_builder_file}) + printf(1,"\tGTK version mismatch or other error in Glade.\n\n") + end if + return result + end function + + -- link signals defined in Glade, this starts a 'for' loop, + -- running the builder_connect_function for each control; + function builder_connect(atom bld) + --------------------------------- + gtk_func("gtk_builder_connect_signals_full",{P,P,P},{bld,builder_connect_func,0}) + return 1 + end function + + constant builder_connect_func = call_back(routine_id("builder_connect_function")) + + -- links Glade controls to user-written or Eu functions + function builder_connect_function(atom bld, atom obj, object sig, object hdlr, atom cxo, atom flags, atom data) + ----------------------------------------------------------------------------------------- + hdlr = peek_string(hdlr) + sig = peek_string(sig) + if atom(current_builder_file) and (current_builder_file > 0) then + current_builder_file = peek_string(current_builder_file) + end if + + atom rid = routine_id(hdlr) + if rid = -1 then + printf(1,"---------------------------------------------------------------------\n") + printf(1,"-- Undeclared function in %s\n",{current_builder_file}) + printf(1,"---------------------------------------------------------------------\n") + show_template(hdlr) + abort(1) + else + rid = call_back(rid) + connect(obj,sig,rid,cxo) + end if + + return 1 + end function + +-------------------------------------------------------------------- +procedure load_builder(object parent, object child, object prefix=0) +-------------------------------------------------------------------- +object name, class +object x, tree +integer c,n +atom err = allocate(32) + + if file_exists(canonical_path(child)) then + set(parent,"add from file",canonical_path(child),err) + set(parent,"connect") + prefix = filebase(child) + if match(prefix,filebase(prg_name)) then + prefix = 0 -- do not prefix main file objects + end if + x = read_lines(canonical_path(child)) + + elsif string(child) then + set(parent,"add from string",child,err) + set(parent,"connect") + x = split(child,'\n') + end if + +for i = 1 to length(x) do + + if string(x[i]) and match("]",{class,name,n}) + end ifdef + class = find(class,class_name_index) + if not initialized[class] then init(class) end if + tree = widget[class][2] + for z = 1 to length(tree) do + init(tree[z]) + end for + register(n,class,name) + end if +end for + +end procedure + +-------------------------------------------------------------------------------------------- +procedure show_template(object handlr) -- used with Glade and GtkBuilder to prompt for missing functions +-------------------------------------------------------------------------------------------- +printf(1,""" +________ + + ----------------------------------------------------------------------- + global function %s() + ----------------------------------------------------------------------- + + return 1 + end function + +""",{handlr}) + +end procedure + +------------------------------------------------------------------------ +-- Internet conveniences +------------------------------------------------------------------------ +------------------------------------ +export function show_uri(object uri) +------------------------------------ +if atom(uri) then + return 0 +end if +integer x = find('#',uri) +object tmp +if x > 0 then + tmp = canonical_path(uri[1..x-1]) + if file_exists(tmp) then + uri = "file:///" & tmp & uri[x..$] + end if +else + tmp = canonical_path(uri) + if file_exists(tmp) then + uri = "file:///" & tmp + end if +end if + +atom err = allocate(100) err = 0 +object result = gtk_func("gtk_show_uri",{P,P,P,P}, + {0,allocate_string(uri),0,err}) + free(err) + +return result +end function + +-------------------------------- +export function inet_address() -- only works on linux; +-------------------------------- +object ip +sequence tmp = temp_file(,"MYIP-") +if system_exec(sprintf("ifconfig | grep 'inet addr:' | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}' > %s ",{tmp}),0) = 0 then + ip = read_lines(tmp) + if length(ip) = 0 then + return "127.0.0.1" + else + return ip[1] + end if +end if +return -1 +end function + +--------------------------------- +export function inet_connected() +--------------------------------- +return not equal("127.0.0.1",inet_address()) +end function + +-------------------------------------------------------------------------------------------- +-- Icon functions +-------------------------------------------------------------------------------------------- +---------------------------- +export function list_icons() +---------------------------- +atom theme = gtk_func("gtk_icon_theme_get_default") +object list = gtk_func("gtk_icon_theme_list_icons",{P,P},{theme,0}) +return to_sequence(list) +end function + +---------------------------------------- +export function has_icon(object name) +---------------------------------------- +atom theme = gtk_func("gtk_icon_theme_get_default") + name = allocate_string(name) +return gtk_func("gtk_icon_theme_has_icon",{P,P},{theme,name}) +end function + +-------------------------------------------------------- +export function icon_info(object name, integer size=6) +-------------------------------------------------------- +atom theme = gtk_func("gtk_icon_theme_get_default") +atom err = allocate(32) err = 0 + +atom icon_info = gtk_func("gtk_icon_theme_lookup_icon",{P,P,I,I}, + {theme,name,size,GTK_ICON_LOOKUP_USE_BUILTIN}) + +object results = repeat(0,5) + results = { + gtk_func("gtk_icon_info_load_icon",{P,P},{icon_info,err}), + gtk_func("gtk_icon_info_get_display_name",{P},{icon_info}), + gtk_str_func("gtk_icon_info_get_filename",{P},{icon_info}), + gtk_func("gtk_icon_info_get_base_size",{P},{icon_info}), + gtk_func("gtk_icon_info_get_base_scale",{P},{icon_info}) + } +return results +-- returns {1,2,3,4,5} +-- 1 = pointer to icon_info structure, +-- 2 = display name or null, +-- 3 = full path to icon file, +-- 4 = base size, +-- 5 = base scale +end function + +------------------------------------------------------------------------ +-- Following 3 functions simplify method calls; used mostly internally, +-- but can also be called by the programmer to execute any GTK, GDK or +-- GLib function which has not been implemented in EuGTK. +------------------------------------------------------------------------- +export function gtk_func(object name, object params={}, object values={}) +------------------------------------------------------------------------- +-- syntax: result = gtk_func("gtk_*_*",{formal params},{values}) +-- where formal params might be {P,P,I} (function expects Ptr, Ptr, and Int) +-- and values are the values to be inserted into the formal params before +-- the function named is called; + for i = 1 to length(params) do + if string(values[i]) then + values[i] = allocate_string(values[i]) + end if + end for +atom fn = define_func(name,params,P) +if fn > 0 then +return c_func(fn,values) +else return -1 +end if +end function + +----------------------------------------------------------------------------- +export function gtk_str_func(object name, object params={}, object values={}) +----------------------------------------------------------------------------- +-- syntax: same as above, except a string result is returned, so no +-- conversion from a pointer is needed; + for i = 1 to length(params) do + if string(values[i]) then + values[i] = allocate_string(values[i]) + end if + end for + atom fn = define_func(name,params,P) + object result + if fn > 0 then + if length(params) > 0 then + result = c_func(fn,values) + else + result = c_func(fn,{}) + end if + if result > 0 then + return peek_string(result) + end if + end if + return "unknown" +end function + +-------------------------------------------------------------------------- +export procedure gtk_proc(object name, object params={}, object values={}) +-------------------------------------------------------------------------- +-- syntax: same as above, but no value is returned, used to call GTK procs +atom fn + + if string(values) then values = {values} end if + for i = 1 to length(params) do + if not atom(values) and string(values[i]) then + values[i] = allocate_string(values[i]) + end if + end for + + if length(params) = 0 then + fn = define_proc(name) + if fn > 0 then + c_proc(fn,{}) + end if + else + fn = define_proc(name,params) + if fn > 0 then + if atom(values) then values = {values} end if + c_proc(fn,values) + end if + end if + +end procedure + +-- The following 2 functions had to be added for Windows, so that we could search +-- a list of dlls until we find the function name requested. +---------------------------------------------------------------------------------------- +export function define_proc(object name, object params={}) +---------------------------------------------------------------------------------------- +atom x + for i = 1 to length(LIBS) do + x = define_c_proc(LIBS[i],name,params) + if x > 0 then + return x + end if + end for + ifdef GTK_ERR then + display("? 9045 Proc []",{name}) + end ifdef + return -1 +end function + +-------------------------------------------------------------------- +export function define_func(object name, object params={}, object values=P) +-------------------------------------------------------------------- +atom x + for i = 1 to length(LIBS) do + x = define_c_func(LIBS[i],name,params,values) + if x > 0 then + return x + end if + end for + ifdef GTK_ERR then + display("? 9061 Func []",{name}) + end ifdef + return -1 +end function + +------------------------- +-- © 2015 by Irv Mullins +------------------------- diff --git a/tools/WEE/EuGTK/GtkEnums.e b/tools/WEE/EuGTK/GtkEnums.e new file mode 100644 index 0000000..227fd3c --- /dev/null +++ b/tools/WEE/EuGTK/GtkEnums.e @@ -0,0 +1,1441 @@ +---------------- +namespace enums +---------------- +export constant version = "4.9.4" + +public include std/io.e +public include std/os.e +public include std/dll.e +public include std/text.e +public include std/math.e +public include std/error.e +public include std/types.e +public include std/search.e +public include std/convert.e +public include std/console.e +public include std/filesys.e +public include std/machine.e +public include std/sequence.e +public include std/serialize.e + +public constant LGPL = read_file(canonical_path("~/demos/license.txt")) + +--------------------------------------------------------------------------------- +-- ListView/TreeView storage types. Use these when creating new +-- GtkListStores or GtkTreeStores +--------------------------------------------------------------------------------- +public enum + gCHAR = 12, gUCHAR = 16, gINT = 24, gUINT = 28, + gLONG = 32, gULONG = 36, gINT64 = 40, gUINT64 = 44, + gDBL = 60, gFLT = 56, + gSTR = 64, gPTR = 68, gBOOL= 20 +-- plus gPIX and gCOMBO, which must be defined at run-time +-- by GtkEngine.e ... don't ask me why! + +-- here's a list of GObject types; +public enum type OBJECT by 4 + void = 4, + GInterface, + gchar, + guchar, + gboolean, + gint, + guint, + glong, + gulong, + gint64, + guint64, + GEnum, + GFlags, + gfloat, + gdouble, + gchararray, + gpointer, + GBoxed, + GParam +end type + +------------------------------------------------------------------------ +-- These are the widget names used to create GTK widgets; +-- GObject MUST be first on the list. +-- Other than that, order is unimportant, but try to keep 'em in +-- alphabetical order just to be neat. +------------------------------------------------------------------------ +public enum type WIDGET + GObject, + GActionGroup, + GAppInfo, + GEmblem, + GEmblemedIcon, + GFile, + GFileIcon, + GIcon, + GIdle, + GList, + GMenu, + GMenuItem, + GMenuModel, + GSList, + GThemedIcon, + GTimeout, + Cairo_t, + CairoFontOptions, + CairoContent_t, + CairoLinearGradient, + CairoPattern, + CairoPattern_t, + CairoRadialGradient, + CairoRegion_t, + CairoImageSurface, + CairoStatus_t, + CairoSurface_t, + CairoSurfaceType_t, + GdkCairo_t, + GdkCursor, + GdkDevice, + GdkDeviceManager, + GdkDisplay, + GdkEvent, + GdkEventSequence, + GdkFrameClock, + GdkFrameTimings, + GdkGLContext, + GdkGLProfile, + GdkKeymap, + GdkKeyval, + GdkPixbuf, + GdkPixbufAnimation, + GdkPixbufAnimationIter, + GdkScreen, + GdkVisual, + GdkWindow, + GdkX11Display, + GdkX11Screen, + GdkX11Window, + GtkAboutDialog, + GtkAccelGroup, + GtkAccelLabel, + GtkAccessible, + GtkActionable, + GtkActionBar, + GtkActivatable, + GtkAdjustment, + GtkAlignment, + GtkAppChooser, + GtkAppChooserButton, + GtkAppChooserDialog, + GtkAppChooserWidget, + GtkAppLaunchContext, + GtkApplication, + GtkApplicationWindow, + GtkArrow, + GtkAspectFrame, + GtkAssistant, + GtkBin, + GtkBindingEntry, + GtkBindingSet, + GtkBox, + GtkBuildable, + GtkBuilder, + GtkButton, + GtkButtonBox, + GtkCalendar, + GtkCellArea, + GtkCellAreaBox, + GtkCellAreaCell, + GtkCellAreaContext, + GtkCellEditable, + GtkCellLayout, + GtkCellRenderer, + GtkCellRendererAccel, + GtkCellRendererCombo, + GtkCellRendererPixbuf, + GtkCellRendererProgress, + GtkCellRendererSpin, + GtkCellRendererSpinner, + GtkCellRendererText, + GtkCellRendererToggle, + GtkCellView, + GtkCheckButton, + GtkCheckMenuItem, + GtkClipboard, + GtkColorButton, + GtkColorChooser, + GtkColorChooserDialog, + GtkColorChooserWidget, + GtkColorSelection, + GtkColorSelectionDialog, + GtkComboBox, + GtkComboBoxEntry, + GtkComboBoxText, + GtkContainer, + GtkCssProvider, + GtkCssSection, + GtkDialog, + GtkDrag, + GtkDrawingArea, + GtkEditable, + GtkEntry, + GtkEntryBuffer, + GtkEntryCompletion, + GtkEventBox, + GtkEventController, + GtkExpander, + GtkFileChooser, + GtkFileChooserButton, + GtkFileChooserDialog, + GtkFileChooserWidget, + GtkFileFilter, + GtkFixed, + GtkFlowBox, + GtkFlowBoxChild, + GtkFontButton, + GtkFontChooser, + GtkFontChooserDialog, + GtkFontChooserWidget, + GtkFrame, + GtkGesture, + GtkGestureSingle, + GtkGestureDrag, + GtkGestureLongPress, + GtkGestureMultiPress, + GtkGesturePan, + GtkGestureRotate, + GtkGestureSwipe, + GtkGestureZoom, + GtkGLArea, + GtkGrid, + GtkHeaderBar, + GtkIconInfo, + GtkIconTheme, + GtkIconView, + GtkImage, + GtkImageMenuItem, + GtkInfoBar, + GtkInvisible, + GtkLabel, + GtkLayout, + GtkLevelBar, + GtkLinkButton, + GtkListBox, + GtkListBoxRow, + GtkListStore, + GtkLockButton, + GtkMenu, + GtkMenuBar, + GtkMenuButton, + GtkMenuItem, + GtkMenuShell, + GtkMenuToolButton, + GtkMessageDialog, + GtkMisc, + GtkModelButton, + GtkMountOperation, + GtkNotebook, + GtkNumerableIcon, + GtkOffscreenWindow, + GtkOrientable, + GtkOverlay, + GtkPaperSize, + GtkPageRange, + GtkPageSetup, + GtkPageSetupUnixDialog, + GtkPaned, + GtkPlacesSidebar, + GtkPlug, + GtkPopover, + GtkPopoverMenu, + GtkPrinter, + GtkPrintContext, + GtkPrintJob, + GtkPrintSettings, + GtkPrintOperation, + GtkPrintOperationPreview, + GtkPrintUnixDialog, + GtkProgressBar, + GtkRadioButton, + GtkRadioMenuItem, + GtkRadioToolButton, + GtkRange, + GtkRcStyle, + GtkRecentChooser, + GtkRecentChooserDialog, + GtkRecentChooserMenu, + GtkRecentChooserWidget, + GtkRecentFilter, + GtkRecentInfo, + GtkRevealer, + GtkScale, + GtkScaleButton, + GtkScrollable, + GtkScrollbar, + GtkScrolledWindow, + GtkSearchBar, + GtkSearchEntry, + GtkSelectionData, + GtkSeparator, + GtkSeparatorMenuItem, + GtkSeparatorToolItem, + GtkSettings, + GtkSocket, + GtkSidebar, + GtkSizeGroup, + GtkSpinButton, + GtkSpinner, + GtkStack, + GtkStackSidebar, + GtkStackSwitcher, + GtkStatusbar, + GtkStatusIcon, + GtkStock, + GtkStockList, + GtkStyle, + GtkStyleContext, + GtkStyleProvider, + GtkSwitch, + GtkTargetEntry, + GtkTargetList, + GtkTextAttributes, + GtkTextBuffer, + GtkTextChildAnchor, + GtkTextMark, + GtkTextTag, + GtkTextTagTable, + GtkTextView, + GtkThemedIcon, + GtkToggleButton, + GtkToggleToolButton, + GtkToolbar, + GtkToolButton, + GtkToolItem, + GtkToolItemGroup, + GtkToolPalette, + GtkToolShell, + GtkTooltip, + GtkTreeDragDest, + GtkTreeDragSource, + GtkTreeIter, + GtkTreeModel, + GtkTreeModelFilter, + GtkTreeModelSort, + GtkTreePath, + GtkTreeRowReference, + GtkTreeSelection, + GtkTreeSortable, + GtkTreeStore, + GtkTreeView, + GtkTreeViewColumn, + GtkViewport, + GtkVolumeButton, + GtkWidget, + GtkWidgetPath, + GtkWindow, + GtkWindowGroup, + PangoCairoLayout, + PangoContext, + PangoFont, + PangoFontSet, + PangoFontsetSimple, + PangoFontDescription, + PangoFontFace, + PangoFontFamily, + PangoFontMap, + PangoLanguage, + PangoLayout, + PangoLayoutIter, + PangoLayoutLine, + PangoLayoutRun, + PangoTabArray +end type + +global integer GtkFinal = PangoTabArray + 1 + +------------------------------------------------------------------------ + +public enum -- Response codes returned by button presses, etc; + MB_YES = -8, + MB_NO = -9, + MB_OK = -5, + MB_CANCEL = -6, + MB_CLOSE = -7, + MB_ABORT = -4, + MB_NONE = -1, + MB_REJECT = -2, + MB_ACCEPT = -3, + MB_APPLY = -10, + MB_HELP = -11 + +public enum -- Orientation: + VERTICAL = 1, HORIZONTAL = 0 + +public enum -- Sort Order: + UNSORTED = -1, ASCENDING = 1, DESCENDING = 2 + +public enum by 2 -- Cursors: + GDK_X_CURSOR = 0, + GDK_ARROW, + GDK_BASED_ARROW_DOWN, + GDK_BASED_ARROW_UP, + GDK_BOAT, + GDK_BOGOSITY, + GDK_BOTTOM_LEFT_CORNER, + GDK_BOTTOM_RIGHT_CORNER, + GDK_BOTTOM_SIDE, + GDK_BOTTOM_TEE, + GDK_BOX_SPIRAL, + GDK_CENTER_PTR, + GDK_CIRCLE, + GDK_CLOCK, + GDK_COFFEE_MUG, + GDK_CROSS, + GDK_CROSS_REVERSE, + GDK_CROSSHAIR, + GDK_DIAMOND_CROSS, + GDK_DOT, + GDK_DOTBOX, + GDK_DOUBLE_ARROW, + GDK_DRAFT_LARGE, + GDK_DRAFT_SMALL, + GDK_DRAPED_BOX, + GDK_EXCHANGE, + GDK_FLEUR, + GDK_GOBBLER, + GDK_GUMBY, + GDK_HAND1, + GDK_HAND2, + GDK_HEART, + GDK_ICON, + GDK_IRON_CROSS, + GDK_LEFT_PTR, + GDK_LEFT_SIDE, + GDK_LEFT_TEE, + GDK_LEFTBUTTON, + GDK_LL_ANGLE, + GDK_LR_ANGLE, + GDK_MAN, + GDK_MIDDLEBUTTON, + GDK_MOUSE, + GDK_PENCIL, + GDK_PIRATE, + GDK_PLUS, + GDK_QUESTION_ARROW, + GDK_RIGHT_PTR, + GDK_RIGHT_SIDE, + GDK_RIGHT_TEE, + GDK_RIGHTBUTTON, + GDK_RTL_LOGO, + GDK_SAILBOAT, + GDK_SB_DOWN_ARROW, + GDK_SB_H_DOUBLE_ARROW, + GDK_SB_LEFT_ARROW, + GDK_SB_RIGHT_ARROW, + GDK_SB_UP_ARROW, + GDK_SB_V_DOUBLE_ARROW, + GDK_SHUTTLE, + GDK_SIZING, + GDK_SPIDER, + GDK_SPRAYCAN, + GDK_STAR, + GDK_TARGET, + GDK_TCROSS, + GDK_TOP_LEFT_ARROW, + GDK_TOP_LEFT_CORNER, + GDK_TOP_RIGHT_CORNER, + GDK_TOP_SIDE, + GDK_TOP_TEE, + GDK_TREK, + GDK_UL_ANGLE, + GDK_UMBRELLA, + GDK_UR_ANGLE, + GDK_WATCH, + GDK_XTERM, + GDK_LAST_CURSOR = 153, + GDK_BLANK_CURSOR = -2, + GDK_CURSOR_IS_PIXMAP = -1 + +public enum + + GTK_LICENSE_UNKNOWN = 0, + GTK_LICENSE_CUSTOM, + GTK_LICENSE_GPL_2_0, + GTK_LICENSE_GPL_3_0, + GTK_LICENSE_LGPL_2_1, + GTK_LICENSE_LGPL_3_0, + GTK_LICENSE_BSD, + GTK_LICENSE_MIT_X11, + GTK_LICENSE_ARTISTIC, + + GTK_ACCEL_VISIBLE = 1, + GTK_ACCEL_LOCKED = 2, + GTK_ACCEL_MASK = 7, + + GTK_ALIGN_FILL = 0, + GTK_ALIGN_START, + GTK_ALIGN_END, + GTK_ALIGN_CENTER, + + GTK_ANCHOR_CENTER = 0, + GTK_ANCHOR_NORTH, + GTK_ANCHOR_NORTH_WEST, + GTK_ANCHOR_NORTH_EAST, + GTK_ANCHOR_SOUTH, + GTK_ANCHOR_SOUTH_WEST, + GTK_ANCHOR_SOUTH_EAST, + GTK_ANCHOR_WEST, + GTK_ANCHOR_EAST, + GTK_ANCHOR_N = 1, + GTK_ANCHOR_NW, + GTK_ANCHOR_NE, + GTK_ANCHOR_S, + GTK_ANCHOR_SW, + GTK_ANCHOR_SE, + GTK_ANCHOR_W, + GTK_ANCHOR_E, + + GTK_APPLICATION_INHIBIT_LOGOUT = 1, + GTK_APPLICATION_INHIBIT_SWITCH = 2, + GTK_APPLICATION_INHIBIT_SUSPEND = 4, + GTK_APPLICATION_INHIBIT_IDLE = 8, + + G_APPLICATION_FLAGS_NONE = 0, + G_APPLICATION_IS_SERVICE, + G_APPLICATION_IS_LAUNCHER, + G_APPLICATION_HANDLES_OPEN = 4, + G_APPLICATION_HANDLES_COMMAND_LINE = 8, + G_APPLICATION_SEND_ENVIRONMENT = 16, + G_APPLICATION_NON_UNIQUE = 32, + +-- arrows are deprecated + GTK_ARROWS_BOTH = 0, + GTK_ARROWS_START, + GTK_ARROWS_END, + + GTK_ARROW_UP = 0, + GTK_ARROW_DOWN, + GTK_ARROW_LEFT, + GTK_ARROW_RIGHT, + GTK_ARROW_NONE, + + GTK_ASSISTANT_PAGE_CONTENT = 0, + GTK_ASSISTANT_PAGE_INTRO, + GTK_ASSISTANT_PAGE_CONFIRM, + GTK_ASSISTANT_PAGE_SUMMARY, + GTK_ASSISTANT_PAGE_PROGRESS, + GTK_ASSISTANT_PAGE_CUSTOM, + + GTK_EXPAND = 1, + GTK_SHRINK = 2, + GTK_FILL = 4, + + GTK_BASELINE_POSITION_TOP = 0, + GTK_BASELINE_POSITION_CENTER, + GTK_BASELINE_POSITION_BOTTOM, + + GTK_BORDER_STYLE_NONE = 0, + GTK_BORDER_STYLE_SOLID, + GTK_BORDER_STYLE_INSET, + GTK_BORDER_STYLE_OUTSET, + GTK_BORDER_STYLE_HIDDEN, + GTK_BORDER_STYLE_DOTTED, + GTK_BORDER_STYLE_DASHED, + GTK_BORDER_STYLE_DOUBLE, + GTK_BORDER_STYLE_GROOVE, + GTK_BORDER_STYLE_RIDGE, + + GTK_BUTTON_ROLE_NORMAL = 0, + GTK_BUTTON_ROLE_CHECK, + GTK_BUTTON_ROLE_RADIO, + + GTK_BUTTONS_NONE = 0, + GTK_BUTTONS_OK, + GTK_BUTTONS_CLOSE, + GTK_BUTTONS_CANCEL, + GTK_BUTTONS_YES_NO, + GTK_BUTTONS_OK_CANCEL, + + GTK_BUTTONBOX_DEFAULT_STYLE = 0, + GTK_BUTTONBOX_SPREAD, + GTK_BUTTONBOX_EDGE, + GTK_BUTTONBOX_START, + GTK_BUTTONBOX_END, + GTK_BUTTONBOX_CENTER, + GTK_BUTTONBOX_EXPAND, + + GTK_CALENDAR_SHOW_HEADING = 1, + GTK_CALENDAR_SHOW_DAY_NAMES = 2, + GTK_CALENDAR_NO_MONTH_CHANGE = 4, + GTK_CALENDAR_SHOW_WEEK_NUMBERS = 8, + GTK_CALENDAR_SHOW_DETAILS = 16, + + GTK_CORNER_TOP_LEFT = 0, + GTK_CORNER_BOTTOM_LEFT, + GTK_CORNER_TOP_RIGHT, + GTK_CORNER_BOTTOM_RIGHT, + + GTK_CURVE_TYPE_LINEAR = 0, + GTK_CURVE_TYPE_SPLINE, + GTK_CURVE_TYPE_FREE, + + GTK_DELETE_CHARS = 0, + GTK_DELETE_WORD_ENDS, + GTK_DELETE_WORDS, + GTK_DELETE_DISPLAY_LINES, + GTK_DELETE_DISPLAY_LINE_ENDS, + GTK_DELETE_PARAGRAPH_ENDS, + GTK_DELETE_PARAGRAPHS, + GTK_DELETE_WHITESPACE, + + GTK_DIALOG_NON_MODAL = 0, + GTK_DIALOG_MODAL = 1, + GTK_DIALOG_DESTROY_WITH_PARENT = 2, + GTK_DIALOG_NO_SEPARATOR = 4, + + NON_MODAL = -1, -- for EuGTK + + GTK_DIR_TAB_FORWARD = 0, + GTK_DIR_TAB_BACKWARD, + GTK_DIR_UP, + GTK_DIR_DOWN, + GTK_DIR_LEFT, + GTK_DIR_RIGHT, + + GTK_EVENT_SEQUENCE_NONE = 0, + GTK_EVENT_SEQUENCE_CLAIMED, + GTK_EVENT_SEQUENCE_DENIED, + + GTK_EXPANDER_COLLAPSED = 0, + GTK_EXPANDER_SEMI_COLLAPSED, + GTK_EXPANDER_SEMI_EXPANDED, + GTK_EXPANDER_EXPANDED, + + GTK_FILE_CHOOSER_ACTION_OPEN = 0, + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, + GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER, + + GTK_ICON_SIZE_INVALID = 0, + GTK_ICON_SIZE_MENU, + GTK_ICON_SIZE_SMALL_TOOLBAR, + GTK_ICON_SIZE_LARGE_TOOLBAR, + GTK_ICON_SIZE_BUTTON, + GTK_ICON_SIZE_DND, + GTK_ICON_SIZE_DIALOG, + + GTK_ICON_LOOKUP_NO_SVG = 1, + GTK_ICON_LOOKUP_FORCE_SVG = 2, + GTK_ICON_LOOKUP_USE_BUILTIN = 4, + GTK_ICON_LOOKUP_GENERIC_FALLBACK = 8, + GTK_ICON_LOOKUP_FORCE_SIZE = 16, + + GTK_IMAGE_EMPTY = 0, + GTK_IMAGE_PIXBUF, + GTK_IMAGE_STOCK, + GTK_IMAGE_ICON_SET, + GTK_IMAGE_ANIMATION, + GTK_IMAGE_ICON_NAME, + GTK_IMAGE_GICON, + + GTK_IM_PREEDIT_NOTHING = 0, + GTK_IM_PREEDIT_CALLBACK, + GTK_IM_PREEDIT_NONE, + + GTK_IM_STATUS_NOTHING = 0, + GTK_IM_STATUS_CALLBACK, + GTK_IM_STATUS_NONE, + + GTK_INPUT_HINT_NONE = 0, + GTK_INPUT_HINT_SPELLCHECK, + GTK_INPUT_HINT_NO_SPELLCHECK, + GTK_INPUT_HINT_WORD_COMPLETION = 4, + GTK_INPUT_HINT_LOWERCASE = 8, + GTK_INPUT_HINT_UPPERCASE_CHARS = 16, + GTK_INPUT_HINT_UPPERCASE_WORDS = 32, + GTK_INPUT_HINT_UPPERCASE_SENTENCES = 64, + + GTK_JUSTIFY_LEFT = 0, + GTK_JUSTIFY_RIGHT, + GTK_JUSTIFY_CENTER, + GTK_JUSTIFY_FILL, + + GTK_LEVEL_BAR_MODE_CONTINUOUS = 0, + GTK_LEVEL_BAR_MODE_DISCRETE, + + GTK_MATCH_ALL = 0, + GTK_MATCH_ALL_TAIL, + GTK_MATCH_HEAD, + GTK_MATCH_TAIL, + GTK_MATCH_EXACT, + GTK_MATCH_LAST, + + GTK_PIXELS = 0, + GTK_INCHES, + GTK_CENTIMETERS, + + GTK_MESSAGE_INFO = 0, + GTK_MESSAGE_WARNING, + GTK_MESSAGE_QUESTION, + GTK_MESSAGE_ERROR, + GTK_MESSAGE_OTHER, + + GTK_ICON_INFO = 0, + GTK_ICON_WARNING, + GTK_ICON_QUESTION, + GTK_ICON_ERROR, + GTK_ICON_OTHER, + + GTK_MOVEMENT_LOGICAL_POSITIONS = 0, + GTK_MOVEMENT_VISUAL_POSITIONS, + GTK_MOVEMENT_WORDS, + GTK_MOVEMENT_DISPLAY_LINES, + GTK_MOVEMENT_DISPLAY_LINE_ENDS, + GTK_MOVEMENT_PARAGRAPHS, + GTK_MOVEMENT_PARAGRAPH_ENDS, + GTK_MOVEMENT_PAGES, + GTK_MOVEMENT_BUFFER_ENDS, + GTK_MOVEMENT_HORIZONTAL_PAGES, + + GTK_ORIENTATION_HORIZONTAL = 0, + GTK_ORIENTATION_VERTICAL, + + GTK_PACK_START = 0, + GTK_PACK_END, + + GTK_PAN_DIRECTION_LEFT = 0, + GTK_PAN_DIRECTION_RIGHT, + GTK_PAN_DIRECTION_UP, + GTK_PAN_DIRECTION_DOWN, + + GTK_PATH_PRIO_LOWEST = 0, + GTK_PATH_PRIO_GTK = 4, + GTK_PATH_PRIO_APPLICATION = 8, + GTK_PATH_PRIO_THEME = 10, + GTK_PATH_PRIO_RC = 12, + GTK_PATH_PRIO_HIGHEST = 15, + + GTK_PATH_WIDGET = 0, + GTK_PATH_WIDGET_CLASS, + GTK_PATH_CLASS, + + GTK_PHASE_NONE = 0, + GTK_PHASE_CAPTURE, + GTK_PHASE_BUBBLE, + GTK_PHASE_TARGET, + + GTK_POLICY_ALWAYS = 0, + GTK_POLICY_AUTOMATIC, + GTK_POLICY_NEVER, + + GTK_POS_LEFT = 0, + GTK_POS_RIGHT, + GTK_POS_TOP, + GTK_POS_BOTTOM, + LEFT = 0, --aliases; + RIGHT, + TOP, + BOTTOM + +public enum by * 2 + GTK_PRINT_CAPABILITY_PAGE_SET = 0, + GTK_PRINT_CAPABILITY_COPIES = 2, + GTK_PRINT_CAPABILITY_COLLATE, + GTK_PRINT_CAPABILITY_REVERSE, + GTK_PRINT_CAPABILITY_SCALE, + GTK_PRINT_CAPABILITY_GENERATE_PDF, + GTK_PRINT_CAPABILITY_GENERATE_PS, + GTK_PRINT_CAPABILITY_PREVIEW, + GTK_PRINT_CAPABILITY_NUMBER_UP, + GTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT, + + GTK_REGION_EVEN = 0, + GTK_REGION_ODD = 1, + GTK_REGION_FIRST, + GTK_REGION_LAST, + GTK_REGION_ONLY, + GTK_REGION_SORTED, + + GTK_STATE_FLAG_NORMAL = 0, + GTK_STATE_FLAG_ACTIVE = 1, + GTK_STATE_FLAG_PRELIGHT, + GTK_STATE_FLAG_SELECTED, + GTK_STATE_FLAG_INSENSITIVE, + GTK_STATE_FLAG_INCONSISTENT, + GTK_STATE_FLAG_FOCUSED, + GTK_STATE_FLAG_BACKDROP, + GTK_STATE_FLAG_DIR_LTR , + GTK_STATE_FLAG_DIR_RTL, + GTK_STATE_FLAG_LINK, + GTK_STATE_FLAG_VISITED, + GTK_STATE_FLAG_CHECKED + +public enum + GTK_PROGRESS_LEFT_TO_RIGHT = 0, + GTK_PROGRESS_RIGHT_TO_LEFT, + GTK_PROGRESS_BOTTOM_TO_TOP, + GTK_PROGRESS_TOP_TO_BOTTOM, + + GTK_RELIEF_NORMAL = 0, + GTK_RELIEF_HALF, + GTK_RELIEF_NONE, + + GTK_RESIZE_PARENT = 0, + GTK_RESIZE_QUEUE, + GTK_RESIZE_IMMEDIATE, + + GTK_REVEALER_TRANSITION_TYPE_NONE = 0, + GTK_REVEALER_TRANSITION_TYPE_CROSSFADE, + GTK_REVEALER_TRANSITION_TYPE_SLIDE_RIGHT, + GTK_REVEALER_TRANSITION_TYPE_SLIDE_LEFT, + GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP, + GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN, + + GTK_SCROLL_STEPS = 0, + GTK_SCROLL_PAGES, + GTK_SCROLL_ENDS, + GTK_SCROLL_HORIZONTAL_STEPS, + GTK_SCROLL_HORIZONTAL_PAGES, + GTK_SCROLL_HORIZONTAL_ENDS, + + GTK_SCROLL_NONE = 0, + GTK_SCROLL_JUMP, + GTK_SCROLL_STEP_BACKWARD, + GTK_SCROLL_STEP_FORWARD, + GTK_SCROLL_PAGE_BACKWARD, + GTK_SCROLL_PAGE_FORWARD, + GTK_SCROLL_STEP_UP, + GTK_SCROLL_STEP_DOWN, + GTK_SCROLL_PAGE_UP, + GTK_SCROLL_PAGE_DOWN, + GTK_SCROLL_STEP_LEFT, + GTK_SCROLL_STEP_RIGHT, + GTK_SCROLL_PAGE_LEFT, + GTK_SCROLL_PAGE_RIGHT, + GTK_SCROLL_START, + GTK_SCROLL_END, + + GTK_SELECTION_NONE = 0, + GTK_SELECTION_SINGLE, + GTK_SELECTION_BROWSE, + GTK_SELECTION_MULTIPLE, + + GTK_SHADOW_NONE = 0, + GTK_SHADOW_IN, + GTK_SHADOW_OUT, + GTK_SHADOW_ETCHED_IN, + GTK_SHADOW_ETCHED_OUT, + + GTK_STATE_NORMAL = 0, + GTK_STATE_ACTIVE, + GTK_STATE_PRELIGHT, + GTK_STATE_SELECTED, + GTK_STATE_INSENSITIVE, + GTK_STATE_INCONSISTENT, + GTK_STATE_FOCUSED, + GTK_STATE_PRESSED = 1, + GTK_STATE_MOUSEOVER, + + GTK_TEXT_DIR_NONE = 0, + GTK_TEXT_DIR_LTR, + GTK_TEXT_DIR_RTL, + + GTK_TOOLBAR_ICONS = 0, + GTK_TOOLBAR_TEXT, + GTK_TOOLBAR_BOTH, + GTK_TOOLBAR_BOTH_HORIZ, + + GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID = -1, + GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID = -2, + + GTK_UPDATE_CONTINUOUS = 0, + GTK_UPDATE_DISCONTINUOUS, + GTK_UPDATE_DELAYED, + + GTK_VISIBILITY_NONE = 0, + GTK_VISIBILITY_PARTIAL, + GTK_VISIBILITY_FULL, + + GTK_WIN_POS_NONE = 0, + GTK_WIN_POS_CENTER, + GTK_WIN_POS_MOUSE, + GTK_WIN_POS_CENTER_ALWAYS, + GTK_WIN_POS_CENTER_ON_PARENT, + + GTK_WINDOW_TOPLEVEL = 0, + GTK_WINDOW_POPUP, + + GTK_SORT_ASCENDING = 1, + GTK_SORT_DESCENDING, + + GTK_DRAG_RESULT_SUCCESS = 0, + GTK_DRAG_RESULT_NO_TARGET, + GTK_DRAG_RESULT_USER_CANCELLED, + GTK_DRAG_RESULT_TIMEOUT_EXPIRED, + GTK_DRAG_RESULT_GRAB_BROKEN, + GTK_DRAG_RESULT_ERROR, + + PANGO_ELLIPSIZE_NONE = 0, + PANGO_ELLIPSIZE_START, + PANGO_ELLIPSIZE_MIDDLE, + PANGO_ELLIPSIZE_END, + + GDK_SOLID = 0, + GDK_TILED, + GDK_STIPPLED, + GDK_OPAQUE_STIPPLED, + + GTK_RESPONSE_NONE = -1, + GTK_RESPONSE_REJECT = -2, + GTK_RESPONSE_ACCEPT = -3, + GTK_RESPONSE_DELETE_EVENT = -4, + GTK_RESPONSE_OK = -5, + GTK_RESPONSE_CANCEL = -6, + GTK_RESPONSE_CLOSE = -7, + GTK_RESPONSE_YES = -8, + GTK_RESPONSE_NO = -9, + GTK_RESPONSE_APPLY = -10, + GTK_RESPONSE_HELP = -11, + + GTK_TREE_VIEW_COLUMN_GROW_ONLY = 0, + GTK_TREE_VIEW_COLUMN_AUTOSIZE, + GTK_TREE_VIEW_COLUMN_FIXED, + + GTK_TREE_VIEW_GRID_LINES_NONE = 0, + GTK_TREE_VIEW_GRID_LINES_HORIZONTAL, + GTK_TREE_VIEW_GRID_LINES_VERTICAL, + GTK_TREE_VIEW_GRID_LINES_BOTH, + + GTK_TEXT_WINDOW_PRIVATE = 0, + GTK_TEXT_WINDOW_WIDGET, + GTK_TEXT_WINDOW_TEXT, + GTK_TEXT_WINDOW_LEFT, + GTK_TEXT_WINDOW_RIGHT, + GTK_TEXT_WINDOW_TOP, + GTK_TEXT_WINDOW_BOTTOM, + + G_USER_DIRECTORY_DESKTOP = 0, + G_USER_DIRECTORY_DOCUMENTS, + G_USER_DIRECTORY_DOWNLOAD, + G_USER_DIRECTORY_MUSIC, + G_USER_DIRECTORY_PICTURES, + G_USER_DIRECTORY_PUBLIC_SHARE, + G_USER_DIRECTORY_TEMPLATES, + G_USER_DIRECTORY_VIDEOS, + G_USER_N_DIRECTORIES, + + GTK_WRAP_NONE = 0, + GTK_WRAP_CHAR, + GTK_WRAP_WORD, + GTK_WRAP_WORD_CHAR, + + GDK_WINDOW_TYPE_HINT_NORMAL = 0, + GDK_WINDOW_TYPE_HINT_DIALOG, + GDK_WINDOW_TYPE_HINT_MENU, + GDK_WINDOW_TYPE_HINT_TOOLBAR, + GDK_WINDOW_TYPE_HINT_SPLASHSCREEN, + GDK_WINDOW_TYPE_HINT_UTILITY, + GDK_WINDOW_TYPE_HINT_DOCK, + GDK_WINDOW_TYPE_HINT_DESKTOP, + GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU, + GDK_WINDOW_TYPE_HINT_POPUP_MENU, + GDK_WINDOW_TYPE_HINT_TOOLTIP, + GDK_WINDOW_TYPE_HINT_NOTIFICATION, + GDK_WINDOW_TYPE_HINT_COMBO, + GDK_WINDOW_TYPE_HINT_DND, + + GDK_ACTION_DEFAULT = 0, + GDK_ACTION_COPY = 1, + GDK_ACTION_MOVE = 2, + GDK_ACTION_LINK = 4, + GDK_ACTION_PRIVATE = 8, + GDK_ACTION_ASK = 16, + + GTK_CELL_RENDERER_MODE_INERT = 0, + GTK_CELL_RENDERER_MODE_ACTIVATABLE, + GTK_CELL_RENDERER_MODE_EDITABLE, + + GTK_CELL_RENDERER_ACCEL_MODE_GTK = 0, + GTK_CELL_RENDERER_ACCEL_MODE_OTHER, + + GTK_DEST_DEFAULT_MOTION = 1, + GTK_DEST_DEFAULT_HIGHLIGHT = 2, + GTK_DEST_DEFAULT_DROP = 4, + GTK_DEST_DEFAULT_ALL = 0x07, + + GTK_SIZE_GROUP_NONE = 0, + GTK_SIZE_GROUP_HORIZONTAL, + GTK_SIZE_GROUP_VERTICAL, + GTK_SIZE_GROUP_BOTH + +public enum + MOUSE_BUTTON1 = 1, + MOUSE_BUTTON2, + MOUSE_BUTTON3 + +public enum + PANGO_SCALE = 1000, + PANGO_STYLE_NORMAL= 0, + PANGO_STYLE_OBLIQUE, + PANGO_STYLE_ITALIC, + + PANGO_STRETCH_ULTRA_CONDENSED = 0, + PANGO_STRETCH_EXTRA_CONDENSED, + PANGO_STRETCH_CONDENSED, + PANGO_STRETCH_SEMI_CONDENSED, + PANGO_STRETCH_NORMAL, + PANGO_STRETCH_SEMI_EXPANDED, + PANGO_STRETCH_EXPANDED, + PANGO_STRETCH_EXTRA_EXPANDED, + PANGO_STRETCH_ULTRA_EXPANDED, + + PANGO_VARIANT_NORMAL=1, + PANGO_VARIANT_SMALL_CAPS, + + PANGO_WEIGHT_THIN = 100, + PANGO_WEIGHT_ULTRALIGHT = 200, + PANGO_WEIGHT_LIGHT = 300, + PANGO_WEIGHT_BOOK = 380, + PANGO_WEIGHT_NORMAL = 400, + PANGO_WEIGHT_MEDIUM = 500, + PANGO_WEIGHT_SEMIBOLD = 600, + PANGO_WEIGHT_BOLD = 700, + PANGO_WEIGHT_ULTRABOLD = 800, + PANGO_WEIGHT_HEAVY = 900, + PANGO_WEIGHT_ULTRAHEAVY = 1000, + PANGO_UNIT = 1024 + +public enum + GTK_RECENT_SORT_NONE = 0, + GTK_RECENT_SORT_MRU, + GTK_RECENT_SORT_LRU, + GTK_RECENT_SORT_CUSTOM + + public enum by * 2 -- GdkModifierTypes + GDK_SHIFT_MASK = 1, + GDK_LOCK_MASK, + GDK_CONTROL_MASK, + GDK_MOD1_MASK, -- Alt+ + GDK_MOD2_MASK, + GDK_MOD3_MASK, + GDK_MOD4_MASK, + GDK_MOD5_MASK, + GDK_BUTTON1_MASK, + GDK_BUTTON2_MASK, + GDK_BUTTON3_MASK, + GDK_BUTTON4_MASK, + GDK_BUTTON5_MASK, + SHFT = 1, -- 'shorthand' versions of above + LOCK, + CTL, + ALT + + public enum -- events + GDK_NOTHING = -1, + GDK_DELETE, + GDK_DESTROY, + GDK_EXPOSE, + GDK_MOTION_NOTIFY, + GDK_BUTTON_PRESS, + GDK_2BUTTON_PRESS, + GDK_3BUTTON_PRESS, + GDK_BUTTON_RELEASE, + GDK_KEY_PRESS, + GDK_KEY_RELEASE, + GDK_ENTER_NOTIFY, + GDK_LEAVE_NOTIFY, + GDK_FOCUS_CHANGE, + GDK_CONFIGURE, + GDK_MAP, + GDK_UNMAP + +public enum -- event masks + GDK_EXPOSURE_MASK = 2, + GDK_POINTER_MOTION_MASK = 4, + GDK_POINTER_MOTION_HINT_MASK = 8, + GDK_BUTTON_MOTION_MASK = 16, + GDK_BUTTON1_MOTION_MASK = #20, + GDK_BUTTON2_MOTION_MASK = #40, + GDK_BUTTON3_MOTION_MASK = #80, + GDK_BUTTON_PRESS_MASK = #100, + GDK_BUTTON_RELEASE_MASK = #200, + GDK_KEY_PRESS_MASK = #400, + GDK_KEY_RELEASE_MASK = #800, + GDK_ENTER_NOTIFY_MASK = #1000, + GDK_LEAVE_NOTIFY_MASK = #2000, + GDK_FOCUS_CHANGE_MASK = #4000, + GDK_STRUCTURE_MASK = #8000, + GDK_PROPERTY_CHANGE_MASK = #10000, + GDK_VISIBILITY_NOTIFY_MASK = #20000, + GDK_PROXIMITY_IN_MASK = #40000, + GDK_PROXIMITY_OUT_MASK = #80000, + GDK_SUBSTRUCTURE_MASK = #100000, + GDK_SCROLL_MASK = #200000, + GDK_ALL_EVENTS_MASK = #3FFFFE, + + GDK_PROPERTY_NOTIFY = 16, + GDK_SELECTION_CLEAR, + GDK_SELECTION_REQUEST, + GDK_SELECTION_NOTIFY, + GDK_PROXIMITY_IN, + GDK_PROXIMITY_OUT, + GDK_DRAG_ENTER, + GDK_DRAG_LEAVE, + GDK_DRAG_MOTION, + GDK_DRAG_STATUS, + GDK_DROP_START, + GDK_DROP_FINISHED, + GDK_CLIENT_EVENT, + GDK_VISIBILITY_NOTIFY, + GDK_NO_EXPOSE, + GDK_SCROLL, + GDK_WINDOW_STATE, + GDK_SETTING, + GDK_OWNER_CHANGE, + GDK_GRAB_BROKEN, + GDK_DAMAGE, + + GDK_FULLSCREEN_ON_CURRENT_MONITOR = 0, + GDK_FULLSCREEN_ON_ALL_MONITORS, + + GTK_PAGE_SET_ALL = 0, + GTK_PAGE_SET_EVEN, + GTK_PAGE_SET_ODD, + + GTK_PAGE_ORIENTATION_PORTRAIT = 0, + GTK_PAGE_ORIENTATION_LANDSCAPE, + GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT, + GTK_PAGE_ORIENTATION_REVERSE_LANDSCAPE, + + GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG = 0, + GTK_PRINT_OPERATION_ACTION_PRINT, + GTK_PRINT_OPERATION_ACTION_PREVIEW, + GTK_PRINT_OPERATION_ACTION_EXPORT, + + GTK_PRINT_OPERATION_RESULT_ERROR = 0, + GTK_PRINT_OPERATION_RESULT_APPLY, + GTK_PRINT_OPERATION_RESULT_CANCEL, + GTK_PRINT_OPERATION_RESULT_IN_PROGRESS, + + GTK_PRINT_STATUS_INITIAL = 0, + GTK_PRINT_STATUS_PREPARING, + GTK_PRINT_STATUS_GENERATING_DATA, + GTK_PRINT_STATUS_SENDING_DATA, + GTK_PRINT_STATUS_PENDING, + GTK_PRINT_STATUS_PENDING_ISSUE, + GTK_PRINT_STATUS_PRINTING, + GTK_PRINT_STATUS_FINISHED, + GTK_PRINT_STATUS_FINISHED_ABORTED, + + GTK_PRINT_DUPLEX_SIMPLE = 0, + GTK_PRINT_DUPLEX_HORIZONTAL, + GTK_PRINT_DUPLEX_VERTICAL, + + GTK_PRINT_PAGES_ALL = 0, + GTK_PRINT_PAGES_CURRENT, + GTK_PRINT_PAGES_RANGES, + GTK_PRINT_PAGES_SELECTION, + + GTK_PRINT_QUALITY_LOW = 0, + GTK_PRINT_QUALITY_NORMAL, + GTK_PRINT_QUALITY_HIGH, + GTK_PRINT_QUALITY_DRAFT, + + GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_TOP_TO_BOTTOM = 0, + GTK_NUMBER_UP_LAYOUT_LEFT_TO_RIGHT_BOTTOM_TO_TOP, + GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_TOP_TOP_BOTTOM, + GTK_NUMBER_UP_LAYOUT_RIGHT_TO_LEFT_BOTTOM_TO_TOP, + GTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_LEFT_TO_RIGHT, + GTK_NUMBER_UP_LAYOUT_TOP_TO_BOTTOM_RIGHT_TO_LEFT, + GTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_LEFT_TO_RIGHT, + GTK_NUMBER_UP_LAYOUT_BOTTOM_TO_TOP_RIGHT_TO_LEFT, + + GTK_STYLE_PROVIDER_PRIORITY_FALLBACK = 1, + GTK_STYLE_PROVIDER_PRIORITY_THEME = 200, + GTK_STYLE_PROVIDER_PRIORITY_SETTINGS = 400, + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION = 600, + GTK_STYLE_PROVIDER_PRIORITY_USER = 800, + + GTK_UNIT_PIXEL = 0, + GTK_UNIT_POINTS, + GTK_UNIT_INCH, + GTK_UNIT_MM, + + GTK_STACK_TRANSITION_TYPE_NONE = 0, + GTK_STACK_TRANSITION_TYPE_CROSSFADE, + GTK_STACK_TRANSITION_TYPE_SLIDE_RIGHT, + GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT, + GTK_STACK_TRANSITION_TYPE_SLIDE_UP, + GTK_STACK_TRANSITION_TYPE_SLIDE_DOWN, + GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT, + GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN, + GTK_STACK_TRANSITION_TYPE_OVER_UP, -- GTK3.12 from here down + GTK_STACK_TRANSITION_TYPE_OVER_DOWN, + GTK_STACK_TRANSITION_TYPE_OVER_LEFT, + GTK_STACK_TRANSITION_TYPE_OVER_RIGHT, + GTK_STACK_TRANSITION_TYPE_UNDER_UP, + GTK_STACK_TRANSITION_TYPE_UNDER_DOWN, + GTK_STACK_TRANSITION_TYPE_UNDER_LEFT, + GTK_STACK_TRANSITION_TYPE_UNDER_RIGHT, + GTK_STACK_TRANSITION_TYPE_OVER_UP_DOWN, + GTK_STACK_TRANSITION_TYPE_OVER_DOWN_UP, -- GTK3.14 from here down + GTK_STACK_TRANSITION_TYPE_OVER_LEFT_RIGHT, + GTK_STACK_TRANSITION_TYPE_OVER_RIGHT_LEFT, + + GTK_PLACES_OPEN_NORMAL = 0, + GTK_PLACES_OPEN_NEW_TAB, + GTK_PLACES_OPEN_NEW_WINDOW, + + GDK_PIXBUF_ROTATE_NONE = 0, + GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE = 90, + GDK_PIXBUF_ROTATE_UPSIDEDOWN = 180, + GDK_PIXBUF_ROTATE_CLOCKWISE = 270, + + GDK_INTERP_NEAREST = 0, + GDK_INTERP_TILES, + GDK_INTERP_BILINEAR, + GDK_INTERP_HYPER, + + CAIRO_EXTEND_REPEAT = 1, + + CAIRO_FILL_RULE_EVEN_ODD = 1, + CAIRO_FILL_RULE_WINDING = 0, + + CAIRO_FONT_SLANT_NORMAL = 0, + CAIRO_FONT_SLANT_ITALIC, + CAIRO_FONT_SLANT_OBLIQUE, + + CAIRO_FONT_WEIGHT_NORMAL = 0, NORMAL = 0, + CAIRO_FONT_WEIGHT_BOLD, BOLD = 1, + + CAIRO_FORMAT_INVALID = -1, + CAIRO_FORMAT_ARGB32 = 0, + CAIRO_FORMAT_RGB24, + CAIRO_FORMAT_A8, + CAIRO_FORMAT_A1, + CAIRO_FORMAT_RGB16_565, + + CAIRO_LINE_CAP_BUTT = 0, + CAIRO_LINE_CAP_ROUND, + CAIRO_LINE_CAP_SQUARE, + + CAIRO_LINE_JOIN_MITER = 0, + CAIRO_LINE_JOIN_ROUND, + CAIRO_LINE_JOIN_BEVEL, + + CAIRO_OPERATOR_CLEAR = 0, + CAIRO_OPERATOR_SOURCE, + CAIRO_OPERATOR_OVER, + CAIRO_OPERATOR_IN, + CAIRO_OPERATOR_OUT, + CAIRO_OPERATOR_ATOP, + CAIRO_OPERATOR_DEST, + CAIRO_OPERATOR_DEST_OVER, + CAIRO_OPERATOR_DEST_IN, + CAIRO_OPERATOR_DEST_OUT, + CAIRO_OPERATOR_DEST_ATOP, + CAIRO_OPERATOR_XOR, + CAIRO_OPERATOR_ADD, + CAIRO_OPERATOR_SATURATE, + CAIRO_OPERATOR_MULTIPLY, + CAIRO_OPERATOR_SCREEN, + CAIRO_OPERATOR_OVERLAY, + CAIRO_OPERATOR_DARKEN, + CAIRO_OPERATOR_LIGHTEN, + CAIRO_OPERATOR_COLOR_DODGE, + CAIRO_OPERATOR_COLOR_BURN, + CAIRO_OPERATOR_HARD_LIGHT, + CAIRO_OPERATOR_SOFT_LIGHT, + CAIRO_OPERATOR_DIFFERENCE, + CAIRO_OPERATOR_EXCLUSION, + CAIRO_OPERATOR_HSL_HUE, + CAIRO_OPERATOR_HSL_SATURATION, + CAIRO_OPERATOR_HSL_COLOR, + CAIRO_OPERATOR_HSL_LUMINOSITY, + + CAIRO_PDF_VERSION_1_4 = 0, + CAIRO_PDF_VERSION_1_5, + + CAIRO_SVG_VERSION_1_1 = 0, + CAIRO_SVG_VERSION_1_2, + + CAIRO_SURFACE_TYPE_IMAGE = 0, + CAIRO_SURFACE_TYPE_PDF, + CAIRO_SURFACE_TYPE_PS, + CAIRO_SURFACE_TYPE_XLIB, + CAIRO_SURFACE_TYPE_XCB, + CAIRO_SURFACE_TYPE_GLITZ, + CAIRO_SURFACE_TYPE_QUARTZ, + CAIRO_SURFACE_TYPE_WIN32, + CAIRO_SURFACE_TYPE_BEOS, + CAIRO_SURFACE_TYPE_DIRECTFB, + CAIRO_SURFACE_TYPE_SVG, + CAIRO_SURFACE_TYPE_OS2, + CAIRO_SURFACE_TYPE_WIN32_PRINTING, + CAIRO_SURFACE_TYPE_QUARTZ_IMAGE, + CAIRO_SURFACE_TYPE_SCRIPT, + CAIRO_SURFACE_TYPE_QT, + CAIRO_SURFACE_TYPE_RECORDING, + CAIRO_SURFACE_TYPE_VG, + CAIRO_SURFACE_TYPE_GL, + CAIRO_SURFACE_TYPE_DRM, + CAIRO_SURFACE_TYPE_TEE, + CAIRO_SURFACE_TYPE_XML, + CAIRO_SURFACE_TYPE_SKIA, + CAIRO_SURFACE_TYPE_SUBSURFACE, + + CAIRO_FONT_TYPE_TOY = 0, + CAIRO_FONT_TYPE_FT, + CAIRO_FONT_TYPE_WIN32, + CAIRO_FONT_TYPE_QUARTZ, + CAIRO_FONT_TYPE_USER + +public enum ICON_PIXBUF = 1, + ICON_DISPLAY_NAME, + ICON_FILENAME, + ICON_BASE_SIZE, + ICON_BASE_SCALE, + ICON_IS_SYMBOLIC + +function _(atom x, integer t) +if x = 0 then + crash("Invalid type - pointer is null!") +end if +init(t) register(x,t) +return x +end function + +------------------------------------------------------------------------ +-- GTK Widget Types -- used rarely, with caution +------------------------------------------------------------------------ +global type Object(atom x)return _(x,GObject)end type +global type Window(atom x)return _(x,GtkWindow)end type +global type Dialog(atom x)return _(x,GtkDialog)end type +global type AboutDialog(atom x)return _(x,GtkAboutDialog)end type +global type Assistant(atom x)return _(x,GtkAssistant)end type +global type Box(atom x)return _(x,GtkBox)end type +global type Grid(atom x)return _(x,GtkGrid)end type +global type Revealer(atom x)return _(x,GtkRevealer)end type +global type ListBox(atom x)return _(x,GtkListBox)end type +global type FlowBox(atom x)return _(x,GtkFlowBox)end type +global type Stack(atom x)return _(x,GtkStack)end type +global type StackSwitcher(atom x)return _(x,GtkStackSwitcher)end type +global type Sidebar(atom x)return _(x,GtkSidebar)end type +global type ActionBar(atom x)return _(x,GtkActionBar)end type +global type HeaderBar(atom x)return _(x,GtkHeaderBar)end type +global type Overlay(atom x)return _(x,GtkOverlay)end type +global type ButtonBox(atom x)return _(x,GtkButtonBox)end type +global type Paned(atom x)return _(x,GtkPaned)end type +global type Layout(atom x)return _(x,GtkLayout)end type +global type Notebook(atom x)return _(x,GtkNotebook)end type +global type Expander(atom x)return _(x,GtkExpander)end type +global type AspectFrame(atom x)return _(x,GtkAspectFrame)end type +global type Label(atom x)return _(x,GtkLabel)end type +global type Image(atom x)return _(x,GtkImage)end type +global type Spinner(atom x)return _(x,GtkSpinner)end type +global type InfoBar(atom x)return _(x,GtkInfoBar)end type +global type ProgressBar(atom x)return _(x,GtkProgressBar)end type +global type LevelBar(atom x)return _(x,GtkLevelBar)end type +global type Statusbar(atom x)return _(x,GtkStatusbar)end type +global type AccelLabel(atom x)return _(x,GtkAccelLabel)end type +global type Button(atom x)return _(x,GtkButton)end type +global type CheckButton(atom x)return _(x,GtkCheckButton)end type +global type RadioButton(atom x)return _(x,GtkRadioButton)end type +global type ToggleButton(atom x)return _(x,GtkToggleButton)end type +global type LinkButton(atom x)return _(x,GtkLinkButton)end type +global type MenuButton(atom x)return _(x,GtkMenuButton)end type +global type Switch(atom x)return _(x,GtkSwitch)end type +global type ScaleButton(atom x)return _(x,GtkScaleButton)end type +global type VolumeButton(atom x)return _(x,GtkVolumeButton)end type +global type LockButton(atom x)return _(x,GtkLockButton)end type +global type Entry(atom x)return _(x,GtkEntry)end type +global type EntryBuffer(atom x)return _(x,GtkEntryBuffer)end type +global type EntryCompletion(atom x)return _(x,GtkEntryCompletion)end type +global type Scale(atom x)return _(x,GtkScale)end type +global type SpinButton(atom x)return _(x,GtkSpinButton)end type +global type SearchEntry(atom x)return _(x,GtkSearchEntry)end type +global type SearchBar(atom x)return _(x,GtkSearchBar)end type +global type Editable(atom x)return _(x,GtkEditable)end type +global type TextMark(atom x)return _(x,GtkTextMark)end type +global type TextBuffer(atom x)return _(x,GtkTextBuffer)end type +global type TextTag(atom x)return _(x,GtkTextTag)end type +global type TextTagTable(atom x)return _(x,GtkTextTagTable)end type +global type TextView(atom x)return _(x,GtkTextView)end type +global type TreeModel(atom x)return _(x,GtkTreeModel)end type +global type TreeModelSort(atom x)return _(x,GtkTreeModelSort)end type +global type TreeSelection(atom x)return _(x,GtkTreeSelection)end type +global type TreeViewColumn(atom x)return _(x,GtkTreeViewColumn)end type +global type TreeView(atom x)return _(x,GtkTreeView)end type +global type IconView(atom x)return _(x,GtkIconView)end type +global type CellRendererText(atom x)return _(x,GtkCellRendererText)end type +global type CellRendererAccel(atom x)return _(x,GtkCellRendererAccel)end type +global type CellRendererCombo(atom x)return _(x,GtkCellRendererCombo)end type +global type CellRendererPixbuf(atom x)return _(x,GtkCellRendererPixbuf)end type +global type CellRendererProgress(atom x)return _(x,GtkCellRendererProgress)end type +global type CellRendererSpin(atom x)return _(x,GtkCellRendererSpin)end type +global type CellRendererToggle(atom x)return _(x,GtkCellRendererToggle)end type +global type CellRendererSpinner(atom x)return _(x,GtkCellRendererSpinner)end type +global type ListStore(atom x)return _(x,GtkListStore)end type +global type TreeStore(atom x)return _(x,GtkTreeStore)end type +global type ComboBox(atom x)return _(x,GtkComboBox)end type +global type ComboBoxText(atom x)return _(x,GtkComboBoxText)end type +global type Menu(atom x)return _(x,GtkMenu)end type +global type MenuBar(atom x)return _(x,GtkMenuBar)end type +global type MenuItem(atom x)return _(x,GtkMenuItem)end type +global type RadioMenuItem(atom x)return _(x,GtkRadioMenuItem)end type +global type CheckMenuItem(atom x)return _(x,GtkCheckMenuItem)end type +global type SeparatorMenuItem(atom x)return _(x,GtkSeparatorMenuItem)end type +global type Toolbar(atom x)return _(x,GtkToolbar)end type +global type ToolItem(atom x)return _(x,GtkToolItem)end type +global type ToolPalette(atom x)return _(x,GtkToolPalette)end type +global type ToolButton(atom x)return _(x,GtkToolButton)end type +global type MenuToolButton(atom x)return _(x,GtkMenuToolButton)end type +global type ToggleToolButton(atom x)return _(x,GtkToggleToolButton)end type +global type RadioToolButton(atom x)return _(x,GtkRadioToolButton)end type +global type Popover(atom x)return _(x,GtkPopover)end type +global type PopoverMenu(atom x)return _(x,GtkPopoverMenu)end type +global type ColorChooser(atom x)return _(x,GtkColorChooser)end type +global type ColorButton(atom x)return _(x,GtkColorButton)end type +global type ColorChooserWidget(atom x)return _(x,GtkColorChooserWidget)end type +global type ColorChooserDialog(atom x)return _(x,GtkColorChooserDialog)end type +global type FileChooser(atom x)return _(x,GtkFileChooser)end type +global type FileChooserButton(atom x)return _(x,GtkFileChooserButton)end type +global type FileChooserDialog(atom x)return _(x,GtkFileChooserDialog)end type +global type FileChooserWidget(atom x)return _(x,GtkFileChooserWidget)end type +global type FileFilter(atom x)return _(x,GtkFileFilter)end type +global type FontChooser(atom x)return _(x,GtkFontChooser)end type +global type FontButton(atom x)return _(x,GtkFontButton)end type +global type FontChooserWidget(atom x)return _(x,GtkFontChooserWidget)end type +global type FontChooserDialog(atom x)return _(x,GtkFontChooserDialog)end type +global type PlacesSidebar(atom x)return _(x,GtkPlacesSidebar)end type +global type Frame(atom x)return _(x,GtkFrame)end type +global type Scrollbar(atom x)return _(x,GtkScrollbar)end type +global type ScrolledWindow(atom x)return _(x,GtkScrolledWindow)end type +global type Adjustment(atom x)return _(x,GtkAdjustment)end type +global type Calendar(atom x)return _(x,GtkCalendar)end type +global type GLArea(atom x)return _(x,GtkGLArea)end type +global type Tooltip(atom x)return _(x,GtkTooltip)end type +global type Viewport(atom x)return _(x,GtkViewport)end type +global type Widget(atom x)return _(x,GtkWidget)end type +global type Container(atom x)return _(x,GtkContainer)end type +global type Bin(atom x)return _(x,GtkBin)end type +global type Range(atom x)return _(x,GtkRange)end type +global type PrintContext(atom x)return _(x,GtkPrintContext)end type +global type ListBoxRow(atom x)return _(x,GtkListBoxRow)end type +global type FontFamily(atom x)return _(x,PangoFontFamily)end type +global type FontDescription(atom x)return _(x,PangoFontDescription)end type +global type AppChooserDialog(atom x)return _(x,GtkAppChooserDialog)end type +global type PaperSize(atom x)return _(x,GtkPaperSize)end type +global type DrawingArea(atom x)return _(x,GtkDrawingArea)end type +global type RecentChooserDialog(atom x)return _(x,GtkRecentChooserDialog)end type +global type RecentChooserWidget(atom x)return _(x,GtkRecentChooserWidget)end type +global type RecentChooser(atom x)return _(x,GtkRecentChooser)end type +global type RecentFilter(atom x)return _(x,GtkRecentFilter)end type +global type RecentChooserMenu(atom x)return _(x,GtkRecentChooserMenu)end type +global type EventBox(atom x)return _(x,GtkEventBox)end type +global type TreeModelFilter(atom x)return _(x,GtkTreeModelFilter)end type +global type Application(atom x)return _(x,GtkApplication)end type +global type ApplicationWindow(atom x)return _(x,GtkApplicationWindow)end type +global type Pixbuf(atom x)return _(x,GdkPixbuf)end type +global type IconTheme(atom x)return _(x,GtkIconTheme)end type +global type Cairo_T(atom x)return _(x,Cairo_t)end type +------------------------- +-- © 2015 by Irv Mullins +------------------------- diff --git a/tools/WEE/EuGTK/GtkEvents.e b/tools/WEE/EuGTK/GtkEvents.e new file mode 100644 index 0000000..6ff271d --- /dev/null +++ b/tools/WEE/EuGTK/GtkEvents.e @@ -0,0 +1,222 @@ + +namespace events + +--Thanks to Pete Eberlein for helping with this! + +include GtkEngine.e +include std/convert.e + +-- Maps keys from keypad to match same keys on keyboard, +-- maps control/arrow keys to negative numbers, so they +-- can be differentiated from the same ascii character +-- values; + +constant keyvalues = { +{8,-8}, -- bksp +{9,-9}, -- tab +{20,-20}, -- scroll lock +{27,27}, -- escape +{80,-80}, -- home 'P' +{81,-81}, -- left arrow 'Q' +{82,-82}, -- up arrow 'R' +{83,-83}, -- right arrow 'S' +{84,-84}, -- down arrow 'T' +{85,-85}, -- page up 'U' +{86,-86}, -- page dn 'V' +{87,-87}, -- end 'W' +{99,-99}, -- insert 'c' +{103,-103}, +{127,-127}, -- num lock + +{141,13}, -- keypad Enter, with or w/o numlock; + +-- keypad keys w/o numlock; +{149,-149}, -- keypad home +{150,-150}, -- keypad left +{151,-151}, -- keypad up +{152,-152}, -- keypad right +{153,-153}, -- keypad down +{154,-154}, -- keypad pg up +{155,-155}, -- keypad pg dn +{156,-156}, -- keypad end +{157,-157}, -- keypad 5 +{158,-158}, -- keypad ins +{159,-159}, -- keypad del + +-- keypad keys with numlock - return ascii 0..9 +{170,'*'},{171,'+'},{173,'-'},{175,'/'}, +{176,48},{177,49},{178,50},{179,51},{180,52}, -- keypad numbers 0..4 +{181,53},{182,54},{183,55},{184,56},{185,57}, -- keypad numbers 5..9 + +-- F keys; +{190,-190}, -- F1 +{191,-191}, -- F2 +{192,-192}, -- F3 +{193,-193}, -- F4 +{194,-194}, -- F5 +{195,-195}, -- F6 +{196,-196}, -- F7 +{197,-197}, -- F8 +{198,-198}, -- F9 +{199,-199}, -- F10 +{200,-200}, -- F11 +{201,-201}, -- F12 +{227,-227}, -- left ctl +{228,-228}, -- right ctl +{229,-229}, +{225,-225}, -- left shift +{226,-226}, -- right shift +{228,-228}, +{233,-233}, -- left alt +{234,-234}, -- right alt +{236,-236}, +{255,-255}, -- delete +$} + +constant shiftkeys = { +{32,-9}, -- shift tab +$} + +---------------------------------------------------------------------- +export function key(atom event) -- get key pressed; +---------------------------------------------------------------------- +integer k = peek(event+16) +integer z = peek(event+17) +integer s = state(event) +ifdef BITS64 then + k = peek(event+28) + z = peek(event+29) +end ifdef +switch z do + case 0 then return k + case 255 then return vlookup(k,keyvalues,1,2,k) + case 254 then return vlookup(k,shiftkeys,1,2,k) +end switch +return 0 +end function + +--------------------------------------------------------------------- +export function id(atom event) +--------------------------------------------------------------------- +return peek4u(event) +end function + +---------------------------------------------------------------------- +export function state(atom event) +---------------------------------------------------------------------- +ifdef BITS64 then + return peek(event+24) +end ifdef +return peek(event+12) +end function + +---------------------------------------------------------------------- +export function hwcode(atom event) +---------------------------------------------------------------------- +ifdef BITS64 then + return peek({event+28,2}) +end ifdef +return peek({event+16,2}) +end function + +--------------------------------------------------------------------- +export function button(atom event) -- get mouse button clicked; +--------------------------------------------------------------------- +ifdef BITS64 then + return peek(event+52) +end ifdef +return peek(event+40) +end function + +--(32/64)struct GdkEventButton +-- 0 0 GdkEventType type +-- 4 8 GtkWindow *window +-- 8 16 gint8 send_event +-- 12 20 guint32 time +-- 16 24 gdouble x +-- 24 32 gdouble y +-- 32 40 gdouble *axes +-- 36 48 guint state +-- 40 52 guint button +-- 44 56 GdkDevice *device +-- 48 64 gdouble x_root, y_root + +--------------------------------------------------------------------- +export function window(atom event) -- get event window +--------------------------------------------------------------------- +ifdef BITS64 then + return peek8u(event + 8) +end ifdef + return peek4u(event + 4) +end function + +--------------------------------------------------------------------- +export function time(atom event) -- get event time +--------------------------------------------------------------------- +ifdef BITS64 then + return peek4u(event + 20) +end ifdef + return peek4u(event + 12) +end function + + +--------------------------------------------------------------------- +export function xy(atom event) -- get mouse button x y; +--------------------------------------------------------------------- +ifdef BITS64 then + return { + float64_to_atom(peek({event + 24, 8})), + float64_to_atom(peek({event + 32, 8}))} +end ifdef + return { + float64_to_atom(peek({event + 16, 8})), + float64_to_atom(peek({event + 24, 8}))} +end function + +--------------------------------------------------------------------- +export function clicks(atom event) +--------------------------------------------------------------------- +atom ct = allocate(64) +object result + if gtk_func("gdk_event_get_click_count",{P,I},{event,ct}) then + result = peek4u(ct) + else + result = -1 + end if + free(ct) +return result +end function + +--------------------------------------------------------------------- +export function scroll_dir(atom event) +--------------------------------------------------------------------- +atom dir = allocate(64) +object result + if gtk_func("gdk_event_get_scroll_direction",{P,I},{event,dir}) then + result = peek4u(dir) + else + result = -1 + end if + free(dir) +return result +end function + +------------------------------------------------------------------------ +-- following routine traps the enter key when Entry is activated, +-- and uses it like the tab key - so it works like people expect. +-- in Glade, connect each entry's 'activate' signal to +-- trap_enter_key +------------------------------------------------------------------------ +constant gsig = define_proc("g_signal_emit_by_name",{P,P,P}) +constant fsig = allocate_string("move-focus") +------------------------------------------------------------------------ +global function trap_enter_key(atom ctl, atom event) +----------------------------------------------------------------------- + if classid(ctl) = GtkEntry then + if event = 0 then + c_proc(gsig,{ctl,allocate_string("move-focus"),0}) + return 1 + end if + end if +return 0 +end function diff --git a/tools/WEE/EuGTK/GtkPrinter.e b/tools/WEE/EuGTK/GtkPrinter.e new file mode 100644 index 0000000..d738116 --- /dev/null +++ b/tools/WEE/EuGTK/GtkPrinter.e @@ -0,0 +1,487 @@ +------------------ +namespace printer +------------------ +constant version = "4.9.4" + +include GtkEngine.e +include std/datetime.e + +-------------------------------------------------------------------------------- +-- This version handles most common printing needs, but it will not yet respect +-- 'marked up' a.k.a. 'rich' text, i.e. text with colors and styles such as +-- set by test59. It just prints them as plain text. +-- However, it DOES print text marked up with GTK's HTML subset, so you can use +-- , , , length(text) then + set(progress,"text","Printing complete") + return 0 +end if + +if show_progress then + set(progress,"text",sprintf("Printing page %d",pg)) + set(progress,"fraction",pg/n_pages) +end if + +ifdef DELAY then sleep(0.25) end ifdef + +object details = { + page_title,sub_title,file_name,short_name, + pg,n_pages,n_copies, + today,user,real_name,font,filesize,timestamp,export_file + } + +object page + +if atom(header) then header = "[1] page [5] of [6]\n\n" end if + +if pg = 1 or atom(subheader) then + page = text:format(header,details) + & flatten(text[pg]) + & text:format(footer,details) +else + page = text:format(subheader,details) + & flatten(text[pg]) + & text:format(footer,details) +end if + + set(pl,"markup",page,length(page)) + set(pl,"update layout",cr) + set(pl,"show layout",cr) + +ifdef PRINT then printf(1,"Page %d\n",pg) end ifdef + +return 1 +end function + +------------------------------------------------------------------------ +function process_text(object txt) +------------------------------------------------------------------------ +txt = split(txt,'\n') +integer comment +object a,b +object test + + +for i = 1 to length(txt) do -- replace chars which will confuse markup + + txt[i] = join(split(txt[i],'&'),"&") + txt[i] = join(split(txt[i],"&amp;"),"&") + + if sourcecode then + txt[i] = join(split(txt[i],'<'),"<") + txt[i] = join(split(txt[i],'>'),">") + end if + + if use_color then + comment = match("--",txt[i]) + if comment then + comment -=1 + txt[i] = txt[i][1..comment] & "" & txt[i][comment+1..$] & "" + end if + end if + + if use_line_numbers then + txt[i] = text:format(line_number_format,{i,txt[i]}) + else + txt[i] &= '\n' + end if + +end for + +txt = breakup(txt,lines_per_page) +if n_pages = 0 then -- no selection + n_pages = length(txt) +end if + +return txt +end function + +------------------------------------------------------------------------ +export function end_print() +------------------------------------------------------------------------ +status_string = "Printing complete" +ifdef PRINT then display(status_string) end ifdef +return 1 +end function + +--------------------------------------------------------------- +export function setup_printer() +--------------------------------------------------------------- +atom _size = create(GtkPaperSize,paper_name) +atom err = allocate(16) err = 0 +object results = 0 + +atom fn7 = define_func("gtk_print_operation_run",{P,I,P,P},I) +atom fn8 = define_func("gtk_print_run_page_setup_dialog",{P,P,P},P) + + set(settings,"paper size",_size,units) + set(settings,"n copies",n_copies) + set(settings,"collate",collate) + set(settings,"duplex",duplex) + set(settings,"reverse",order) + set(settings,"scale",scale) + set(settings,"quality",quality) + set(settings,"number up",number_up) + set(settings,"number up layout",number_up_layout) + + if string(name) then + set(settings,"printer",name) + end if + +atom setup = create(GtkPageSetup) + set(setup,"paper size",_size) + set(setup,"orientation",orientation) + set(setup,"left margin",left_margin,units) + set(setup,"right margin",right_margin,units) + set(setup,"top margin",top_margin,units) + set(setup,"bottom margin",bottom_margin,units) + +atom printop = create(GtkPrintOperation) + set(printop,"print settings",settings) + set(printop,"default page setup",setup) + set(printop,"show progress",show_progress) + set(printop,"track print status",track_status) + set(printop,"embed page setup",embed_page_setup) + set(printop,"support selection",support_selection) + set(printop,"has selection",has_selection) + set(printop,"use full page",use_full_page) + + if action = GTK_PRINT_OPERATION_ACTION_EXPORT then + export_file = canonical_path(export_file) + set(printop,"export filename",export_file) + end if + + if string(jobname) then + set(printop,"job name",jobname) + end if + + if custom_tab_hook != 0 then + set(printop,"custom tab label",custom_tab_label) + connect(printop,"create-custom-widget",custom_tab_func,printop) + connect(printop,"custom-widget-apply",custom_tab_hook) + end if + + connect(printop,"status-changed",signal_status_changed) + connect(printop,"begin-print",signal_begin_print) + connect(printop,"draw-page",signal_draw_page) + connect(printop,"end-print",signal_end_print) + connect(printop,"request-page-setup",signal_request_page_setup) + connect(printop,"done",signal_done) + connect(printop,"ready",signal_ready) + connect(printop,"got-page-size",signal_got_page_size) + + c_func(fn7,{printop,action,parent,err}) -- start the print process; + + if string(settings_file) then + get(settings,"to file",settings_file) + end if + if string(setup_file) then + get(setup,"to file",setup_file) + end if + +object jobname = get(printop,"job name") + if confirm then + if action = GTK_PRINT_OPERATION_ACTION_EXPORT then + if Question(0,"PDF Written", + sprintf("%s\nFolder: %s", + {filename(export_file),pathname(export_file)}), + sprintf("%s\nStatus: %d\n%s\nClick Yes to view",{jobname,status_code,status_string}) + ,,,"cups") then + show_uri(export_file) + end if + else + Info(0,"Print Job",jobname, + sprintf("Status: %d %s",{status_code,status_string}) + ,,"cups") + end if + end if + + page_title = 0 + n_pages = 0 + n_copies = 1 + action = GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG + +return 1 +end function + +header = "[1]\n\n" + +------------------------- +-- © 2015 by Irv Mullins +------------------------- diff --git a/tools/WEE/EuGTK/README.txt b/tools/WEE/EuGTK/README.txt new file mode 100644 index 0000000..4a8a2bf --- /dev/null +++ b/tools/WEE/EuGTK/README.txt @@ -0,0 +1,4 @@ +GTK Library for Euphoria 4.0 +by Irv Mullins + +https://sites.google.com/site/euphoriagtk/Home diff --git a/tools/WEE/EuGTK/license.txt b/tools/WEE/EuGTK/license.txt new file mode 100644 index 0000000..cb50219 --- /dev/null +++ b/tools/WEE/EuGTK/license.txt @@ -0,0 +1,17 @@ + +LGPL ~ GNU Lesser General Public License version 3.0 + +This library is free software; you can redistribute it +and/or modify it under the terms of the GNU Lesser General +Public License as published by the Free Software Foundation; +either version 2 of the License, or (at your option) any later +version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, write to the Free Software +Foundation, Inc., 59 Temple Pl, Suite 330, Boston, MA 02111-1307 USA diff --git a/tools/WEE/LICENSE b/tools/WEE/LICENSE new file mode 100644 index 0000000..81d84c0 --- /dev/null +++ b/tools/WEE/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 peberlein + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/tools/WEE/README.md b/tools/WEE/README.md new file mode 100644 index 0000000..bcba757 --- /dev/null +++ b/tools/WEE/README.md @@ -0,0 +1,21 @@ +# WEE +A small code-aware editor for Euphoria programming + +### Featuring +* [Scintilla](http://www.scintilla.org/) editor control with syntax highlighting +* subroutines list +* automatic if/while/for/procedure/function expansion +* code identifier completion +* jump to subroutine declaration +* ex.err monitoring +* show subroutine arguments + +Supports Windows + +Supports Linux and Mac OS using [EuGTK](https://sites.google.com/site/euphoriagtk/Home) + +Requires [Euphoria 4.1.0 Beta 2](http://openeuphoria.org/wiki/view/DownloadEuphoria.wc) or later. + +### How to Get It + +Create a folder called "Wee" and download [updater.ex](https://github.com/peberlein/WEE/raw/master/updater.ex). Run "eui updater.ex" to download/update the files for your platform. Run "eui wee" to run the editor, or compile/bind/shroud it for convenience. diff --git a/tools/WEE/manifest.ex b/tools/WEE/manifest.ex new file mode 100644 index 0000000..11c4b65 --- /dev/null +++ b/tools/WEE/manifest.ex @@ -0,0 +1,66 @@ +include std/pretty.e +include std/io.e +include std/hash.e +include std/os.e +include std/pipeio.e + + +sequence files +files = { +-- platform independent + {"wee.exw", 0, 0, 0}, + {"scintilla.e", 0, 0, 0}, + {"parser.e", 0, 0, 0}, + {"updater.ex", 0, 0, 0}, + {"weeicon.e", 0, 0, 0}, +-- windows + {"ui_win.e", 0, 0, 0, WINDOWS}, + {"window.ew", 0, 0, 0, WINDOWS}, +-- GTK + {"ui_gtk.e", 0, 0, 0, LINUX, OSX}, + {"EuGTK/GtkEngine.e", 0, 0, 0, LINUX, OSX}, + {"EuGTK/GtkEnums.e", 0, 0, 0, LINUX, OSX}, + {"EuGTK/GtkPrinter.e", 0, 0, 0, LINUX, OSX}, + {"EuGTK/GtkEvents.e", 0, 0, 0, LINUX, OSX}, + {"EuGTK/README.txt", 0, 0, 0, LINUX, OSX}, + {"EuGTK/license.txt", 0, 0, 0, LINUX, OSX}, +-- scintilla + {"scintilla/SciLexer.dll", 0, 0, 32, WINDOWS}, + {"scintilla/SciLexer64.dll", 0, 0, 64, WINDOWS}, + {"scintilla/scintilla32.so", 0, 0, 32, LINUX}, + {"scintilla/scintilla64.so", 0, 0, 64, LINUX}, + {"scintilla/scintillaOSX.dylib", 0, 0, 64, OSX}, + {"scintilla/scintilla32armhf.so", 0, 0, 32, LINUX}, + {"scintilla/License.txt", 0, 0, 0} +} + +object file, p + +-- returns +function read_until_eof(object pipe) + sequence result = {} + object o = pipeio:read(pipe, 1024) + while sequence(o) and length(o) do + result &= o + o = pipeio:read(pipe, 1024) + end while + return result +end function + +for i = 1 to length(files) do + files[i][2] = hash(read_file(files[i][1]), HSIEH30) + -- git log -n 1 --format=oneline -- ui_gtk.e + p = pipeio:exec("git log -n1 --format=oneline -- "&files[i][1], pipeio:create()) + files[i][3] = pipeio:read(p[pipeio:STDOUT], 10) + pipeio:kill(p) + + p = pipeio:exec("git show "&files[i][3]&":"&files[i][1], pipeio:create()) + object h = hash(read_until_eof(p[pipeio:STDOUT]), HSIEH30) + pipeio:kill(p) + + printf(1, "%s %s %d %d\n", {files[i][1], files[i][3], files[i][2], h}) + files[i][2] = h +end for + +--display(files) +? write_file("manifest.json", pretty_sprint(files, {2})) diff --git a/tools/WEE/manifest.json b/tools/WEE/manifest.json new file mode 100644 index 0000000..7d4b309 --- /dev/null +++ b/tools/WEE/manifest.json @@ -0,0 +1,150 @@ +{ + { + "wee.exw", + 334537086, + "0dcf6d4cb0", + 0 + }, + { + "scintilla.e", + 13846666, + "e3cc5860ac", + 0 + }, + { + "parser.e", + 215958451, + "87365ad72b", + 0 + }, + { + "updater.ex", + 273638869, + "befd7e9c4a", + 0 + }, + { + "weeicon.e", + 39797371, + "fdc3db69d4", + 0 + }, + { + "ui_win.e", + 740860035, + "839c798be8", + 0, + 2 + }, + { + "window.ew", + 904400105, + "87365ad72b", + 0, + 2 + }, + { + "ui_gtk.e", + 59538677, + "839c798be8", + 0, + 3, + 4 + }, + { + "EuGTK/GtkEngine.e", + 132693288, + "4df40ce0cd", + 0, + 3, + 4 + }, + { + "EuGTK/GtkEnums.e", + 202551058, + "506cdc498b", + 0, + 3, + 4 + }, + { + "EuGTK/GtkPrinter.e", + 443615540, + "506cdc498b", + 0, + 3, + 4 + }, + { + "EuGTK/GtkEvents.e", + 1050187785, + "506cdc498b", + 0, + 3, + 4 + }, + { + "EuGTK/README.txt", + 332011652, + "04aa6ff6c9", + 0, + 3, + 4 + }, + { + "EuGTK/license.txt", + 70721840, + "506cdc498b", + 0, + 3, + 4 + }, + { + "scintilla/SciLexer.dll", + 376057439, + "b6035dbac0", + 32, + 2 + }, + { + "scintilla/SciLexer64.dll", + 971949613, + "683bd7ddbf", + 64, + 2 + }, + { + "scintilla/scintilla32.so", + 794231462, + "b6035dbac0", + 32, + 3 + }, + { + "scintilla/scintilla64.so", + 778289070, + "b6035dbac0", + 64, + 3 + }, + { + "scintilla/scintillaOSX.dylib", + 510448282, + "b6035dbac0", + 64, + 4 + }, + { + "scintilla/scintilla32armhf.so", + 572289041, + "e3cc5860ac", + 32, + 3 + }, + { + "scintilla/License.txt", + 662502963, + "b6035dbac0", + 0 + } +} \ No newline at end of file diff --git a/tools/WEE/mongoose-wee.ico b/tools/WEE/mongoose-wee.ico new file mode 100644 index 0000000..48e56fc Binary files /dev/null and b/tools/WEE/mongoose-wee.ico differ diff --git a/tools/WEE/parser.e b/tools/WEE/parser.e new file mode 100644 index 0000000..cc7c8c2 --- /dev/null +++ b/tools/WEE/parser.e @@ -0,0 +1,2959 @@ +-- parser.e +-- +-- Copyright (c) 2015 Pete Eberlein +-- +-- Permission is hereby granted, free of charge, to any person obtaining a copy +-- of this software and associated documentation files (the "Software"), to deal +-- in the Software without restriction, including without limitation the rights +-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +-- copies of the Software, and to permit persons to whom the Software is +-- furnished to do so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in +-- all copies or substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +-- THE SOFTWARE. + +-- todo: +-- OE4 while "with entry" and "label" +-- OE4 loop until +-- OE4 labels and goto +-- get_declarations with namespace shouldn't include local symbols + +include std/filesys.e +include std/os.e +include std/text.e +include std/map.e + + +constant + OE4 = 1, -- enable OpenEuphoria 4 syntax + ERROR_ABORT = 0, -- enable abort on errors? + ERROR_PRINT = 0 -- enable printing errors? +sequence defined_words +defined_words = {"OE", "OE4"} +if platform() = WIN32 then + defined_words &= {"WINDOWS", "WIN32"} +elsif platform() = LINUX then + defined_words &= {"LINUX", "UNIX"} +elsif platform() = OSX then + defined_words &= {"OSX", "UNIX"} +end if + +ifdef WINDOWS then +-- don't try to open these as files +constant dos_devices = {"CON","PRN","AUX","CLOCK$","NUL","COM1","LPT1","LPT2","LPT3","COM2","COM3","COM4"} +end ifdef + +-- where to search for standard include files +global sequence include_search_paths +include_search_paths = include_paths(0) +if sequence(getenv("EUDIR")) then + include_search_paths = append(include_search_paths, getenv("EUDIR") & SLASH & "include") +end if + +-- ast node types that are also opcodes +global constant + END = 0, + LOAD = 1, + LOADHI = 2, + MOV = 3, + ADD = 4, + ADDU8 = 5, + MUL = 6, + DIV = 7, + REM = 8, + JL = 9, + JLE = 10, + JE = 11, + JNE = 12, + JMP = 13, + EQ = 14, + NEQ = 15, + LT = 16, + GTE = 17, + LTE = 18, + GT = 19, + QPRINT = 20, + SUB = 21, + SUBU8 = 22, + NOT = 23, + NEG = 24, + AND = 25, + OR = 26, + XOR = 27, + CAT = 28 -- {CAT, expr, expr} + +global constant + DECL_ATOM = 1, + DECL_CONSTANT = 2, + DECL_ENUM = 3, + DECL_FUNCTION = 4, + DECL_INTEGER = 5, + DECL_NAMESPACE = 6, + DECL_OBJECT = 7, + DECL_PROCEDURE = 8, + DECL_SEQUENCE = 9, + DECL_TYPE = 10 + +-- ast node types that are not opcodes +global constant + VAR_DECL = 256, -- {VAR_DECL, "type", pos, {"name", pos, scope-start, [expr]}...} + ASSIGN = 257, -- {ASSIGN, "name", pos, expr} + FUNC = 258, -- {FUNC, "name", pos, [args...]} + PROC = 259, -- {PROC, "name", pos, [args...]} + VARIABLE = 260, -- {VARIABLE, "name", pos} + SUBSCRIPT = 261, -- {SUBSCRIPT, expr, index-expr} + SLICE = 262, -- {SLICE, expr, start-expr, end-expr} + CONST_DECL = 263, -- {CONST_DECL, {"name", pos, scope-start, expr}... } + RETURN = 265, -- {RETURN, [expr]} + EXIT = 266, -- {EXIT} + SEQ = 267, -- {SEQ, [expr,]...} + NUMBER = 268, + WHILE = 269, -- {WHILE, expr, scope-start, scope-end, stmts...} + IF = 270, -- {IF, expr, {scope-start, scope-end, stmts...}, + -- [expr, {scope-start, scope-end, elsif-stmts...},]... + -- [{scope-start, scope-end, else-stmts...}]} + ELSE = 271, + FOR = 272, -- {FOR, name, pos, expr, expr, by, scope-start, scope-end, stmts...} + FUNC_DECL = 273, -- {FUNC_DECL, "name", pos, + -- {{"arg-type", "arg-name", pos, scope-start, [expr]}...}, + -- scope-start, scope-end, stmts...} + PROC_DECL = 274, -- {PROC_DECL, ...} + TYPE_DECL = 275, -- {TYPE_DECL, ...} + SEQ_ASSIGN = 276, -- {SEQ_ASSIGN, ["name1", pos1,]... expr} + ADDTO = 277, -- {ADDTO, "name", pos, expr} + SUBTO = 278, + MULTO = 279, + DIVTO = 280, + CATTO = 281, + STRING = 282, -- {STRING, "string-literal"} + SUB_ASSIGN = 283, -- {SUB_ASSIGN, "name", pos, index-expr..., expr} + SUB_ADDTO = 284, + SUB_SUBTO = 285, + SUB_MULTO = 286, + SUB_DIVTO = 287, + SUB_CATTO = 288, + SLICE_ASSIGN = 289, -- {SLICE_ASSIGN, "name", pos, index-expr..., start-expr, end-expr, expr} + SLICE_ADDTO = 290, + SLICE_SUBTO = 291, + SLICE_MULTO = 292, + SLICE_DIVTO = 293, + SLICE_CATTO = 294, + SEQ_LEN = 295, -- {SEQ_LEN}, shorthand for length of enclosing sequence in SUBSCRIPT, SLICE, SUB_*, SLICE_* + ENUM_DECL = 296, -- {ENUM_DECL, "typename"|"", pos, '+'|'-'|'*'|'/', expr, + -- {"name", pos, scope-start, [expr]}...} + INCLUDE = 297, -- {INCLUDE, includes-idx, scope-start, ["namespace"]} + GLOBAL = 298, -- {GLOBAL, decl...} + PUBLIC = 299, -- {PUBLIC, decl...} + EXPORT = 300, -- {EXPORT, decl...} + NAMESPACE = 301, -- {NAMESPACE, "name"} + IFDEF = 302, -- same layout as IF + ELSEDEF = 303, + SWITCH = 304, -- {SWITCH, expr, bool-fallthru, label-string, + -- [{case-values...}, {scope-start, scope-end, stmts...},]... } + -- ("case else" will have case-values={} ) + BREAK = 305, -- {BREAK, [label-string]} + CONTINUE = 306, -- {CONTINUE, [label-string]} + DEFAULT = 307, -- {DEFAULT}, used for default arguments in subroutine calls + ENTRY = 308, -- {ENTRY}, used with while loops + RETRY = 309, -- {RETRY}, used with while loops + LABEL = 310, -- {LABEL, "label"} + GOTO = 311, -- {GOTO, "label"} + ELSIF = 312, -- only for lookup table + ELSIFDEF = 313, -- only for lookup table + CASE = 314, -- {CASE, prev-scope-end, scope-start, [values, ...]} (case else will have no values) + KEYWORD = 315, + WITH = 316, + WITHOUT = 317, + SYNTAX_ERROR = 318, -- {SYNTAX_ERROR, pos, len, "message"} + LOOP = 319, -- {LOOP, scope-start, scope-end, stmts...} + UNTIL = 320 -- {UNTIL, expr} + +-- keep a copy of parsed files, reparsing if timestamp changes +sequence cache -- { {"path", timestamp, stmts...} ...} +cache = {} + +-- a sequence of maps makes identifier lookups fast +sequence maps -- map "decl-name" -> { locator... } +maps = {} +-- functions, procedures, types, enum types, namespace, include-as: +-- locator = ast-index +-- variables, constants, enum values: +-- locator = { ast-index, pos, scope-start, [scope-end] } + +-- returns a if test is true, otherwise b +function choose(integer test, object a, object b) + if test then + return a + end if + return b +end function + +-- use lookup table for faster keyword checking +map:map lookup_table = map:new_from_kvpairs({ + {"?", QPRINT}, {"&", CAT}, {"+", ADD}, {"-",SUB}, {"*", MUL}, {"/", DIV}, + {"=", EQ}, {"!=", NEQ}, {"<", LT}, {"<=", LTE}, {">", GT}, {">=", GTE}, + {"not", NOT}, {"or", OR}, {"and", AND}, {"xor", XOR}, + {"global", GLOBAL}, {"constant", CONST_DECL}, {"return", RETURN}, + {"while", WHILE}, {"if", IF}, {"else", ELSE}, {"elsif", ELSIF}, {"end", END}, + {"for", FOR}, {"to", KEYWORD}, {"by", KEYWORD}, {"do", KEYWORD}, {"exit", EXIT}, + {"function", FUNC_DECL}, {"procedure", PROC_DECL}, {"type", TYPE_DECL}, + {"+=", ADDTO}, {"-=", SUBTO}, {"*=", MULTO}, {"/=", DIVTO}, {"&=", CATTO}, + {"\"", '"'}, {"$", '$'}, {"'", '\''}, {"(", '('}, {"{", '{'}, + {"include", INCLUDE}, {"with", WITH}, {"without", WITHOUT} +} & choose(OE4, { + {"namespace", NAMESPACE}, {"public", PUBLIC}, {"export", EXPORT}, + {"ifdef", IFDEF}, {"elsifdef", ELSIFDEF}, {"elsedef", ELSEDEF}, + {"switch", SWITCH}, {"case", CASE}, {"break", BREAK}, + {"continue", CONTINUE}, {"as", KEYWORD}, {"enum", ENUM_DECL}, + {"default", DEFAULT}, {"entry", ENTRY}, {"retry", RETRY}, {"label", LABEL}, + {"goto", GOTO}, {"routine", KEYWORD}, {"fallthru", KEYWORD}, {"`", '`'} +},{})) + +-- returns text from file, else -1 +function read_file(sequence file_name) + integer f + object line + sequence text + + ifdef WINDOWS then + if find(upper(filename(file_name)), dos_devices) then + return -1 + end if + end ifdef + + f = open(file_name, "rb") + if f = -1 then + return -1 + end if + line = gets(f) + text = {} + while sequence(line) do + text &= line + line = gets(f) + end while + close(f) + return text +end function + +sequence text, source_filename, tok, errors +text = "" +source_filename = "" +tok = "" +errors = {} -- { {SYNTAX_ERROR, pos, len, msg}... } + +integer idx, tok_idx, ifdef_ok, ast_idx +idx = 1 +tok_idx = 1 +ifdef_ok = 1 +ast_idx = 1 -- current top-level ast index used for declaring stuff + +map:map cur_map -- the current maps[] during parsing + + +-- declare name, with name = "name" or {"name", pos, scope-start, [scope-end]} +procedure declare(sequence name) + object loc = ast_idx + + if length(name) = 0 or length(name[1]) = 0 then + return + end if + + if sequence(name[1]) then + loc = name +-- if length(value) < 3 or +-- not sequence(value[1]) or +-- not atom(value[2]) or +-- not atom(value[3]) or +-- (length(value) >= 4 and (not atom(value[4]) or value[4] <= value[3])) then +-- puts(1, "invalid declaration\n") +-- pretty_print(1, value) +-- return +-- end if + name = name[1] + loc[1] = ast_idx + end if + + map:put(cur_map, name, append(map:get(cur_map, name, {}), loc)) +end procedure + +function prefixed(sequence s) + return s[1] = GLOBAL or s[1] = PUBLIC or s[1] = EXPORT +end function + +-- update the declarations in this ast to the end of scope +procedure declare_ast(sequence ast, integer start_idx, integer scope_end, integer top = 0) + + for j = start_idx to length(ast) do + sequence s = ast[j] + integer n = prefixed(s) + integer decl = s[n+1] + + if top then + ast_idx = j + + if decl = NAMESPACE then + -- {NAMESPACE, "name"} + declare(s[n+2]) + + elsif decl = INCLUDE and n+4 <= length(s) then + -- {INCLUDE, includes-idx, scope-start, ["namespace"]} + declare(s[n+4]) -- include as + + elsif decl = FUNC_DECL or decl = PROC_DECL or decl = TYPE_DECL then + -- {FUNC_DECL, "name", pos, + -- {{"arg-type", "arg-name", pos, scope-start, [expr]}...}, + -- scope-start, scope-end, stmts...} + declare(s[n+2]) + sequence args = s[n+4] + integer sub_scope_end = s[n+6] + for i = 1 to length(args) do + declare(args[i][2..4] & sub_scope_end) + end for + declare_ast(s, n+7, sub_scope_end) + + elsif decl = CONST_DECL then + -- {CONST_DECL, {"name", pos, scope-start, expr}... } + for i = n+2 to length(s) do + declare(s[i][1..3] & scope_end) + end for + + elsif decl = ENUM_DECL then + -- {ENUM_DECL, "typename"|"", pos, '+'|'-'|'*'|'/', expr, + -- {"name", pos, scope-start, [expr]}...} + if length(s[n+2]) then + declare(s[n+2]) + end if + for i = n+6 to length(s) do + declare(s[i][1..3] & scope_end) + end for + elsif decl = NAMESPACE then + declare({s[1],1,1}) + end if + + end if + + if decl = VAR_DECL then + -- {VAR_DECL, "type", pos, {"name", pos, scope-start, [expr]}...} + for i = n+4 to length(s) do + declare(s[i][1..3] & scope_end) + end for + + elsif decl = WHILE then + -- {WHILE, expr, scope-start, scope-end, stmts...} + declare_ast(s, n+5, s[n+4]) + + elsif decl = IF then + -- {IF, expr, {scope-start, scope-end, stmts...}, + -- [expr, {scope-start, scope-end, elsif-stmts...},]... + -- [{scope-start, scope-end, else-stmts...}]} + for i = n+2 to length(s) by 2 do + if i = length(s) then + declare_ast(s[i], 3, s[i][2]) + else + declare_ast(s[i+1], 3, s[i+1][2]) + end if + end for + + elsif decl = FOR then + -- {FOR, "name", pos, expr, expr, by, scope-start, scope-end, stmts...} + declare(s[n+2..n+3] & s[n+7..n+8]) + declare_ast(s, n+9, s[n+8]) + + elsif decl = SWITCH then + -- {SWITCH, expr, bool-fallthru, label-string, + -- [{case-values...}, {scope-start, scope-end, stmts...},]... } + -- ("case else" will have case-values={} ) + for i = n+6 to length(s) by 2 do + declare_ast(s[i], 3, s[i][2]) + end for + + elsif decl = LOOP then + -- {LOOP, scope-start, scope-end, stmts...} + declare_ast(s, n+4, s[n+3]) + + end if + end for +end procedure + + +-- prints an error message indicated at tok_idx +procedure error(sequence msg) + integer line, start + + if length(tok) then + errors = append(errors, {SYNTAX_ERROR, tok_idx, length(tok), msg}) + end if + + if not ERROR_PRINT then return end if + + line = 1 + start = 1 + + if tok_idx > length(text) then + tok_idx = length(text) + end if + + for i = 1 to tok_idx do + if text[i] = '\n' then + line += 1 + start = i+1 + end if + end for + for i = tok_idx to length(text) do + if text[i] = '\n' then + --? {start, idx, tok_idx} + printf(2, "%s:%d\n%s\n%s%s\n", { + source_filename, + line, + msg, + text[start..i], + repeat(' ', tok_idx - start) & '^'}) + if ERROR_ABORT then abort(1) end if + --wait_key() + return + end if + end for + puts(2, "unexpected end of file\n") + if ERROR_ABORT then abort(1) end if +end procedure + +constant ALPHA = 1, NUM = 2, HEX = 4, WS = 8, PUNCT = 16, ALPHANUM = 32 +sequence chars = repeat(0, 255) +chars['A'..'Z'] = ALPHA + ALPHANUM +chars['a'..'z'] = ALPHA + ALPHANUM +chars['_'] = ALPHA + choose(OE4, NUM + HEX + ALPHANUM, 0) +chars['0'..'9'] = NUM + HEX + ALPHANUM +chars['A'..'F'] += HEX +chars['a'..'f'] += choose(OE4, HEX, 0) +chars[':'] = choose(OE4, ALPHANUM, 0) +chars['\n'] = WS +chars['\t'] = WS +chars['\r'] = WS +chars[' '] = WS +chars['<'] = PUNCT +chars['>'] = PUNCT +chars['+'] = PUNCT +chars['-'] = PUNCT +chars['*'] = PUNCT +chars['/'] = PUNCT +chars['&'] = PUNCT +chars['!'] = PUNCT + + +procedure skip_hashbang() + integer c = 0 + if length(text) >= 2 and text[1] = '#' and text[2] = '!' then + -- skip special comment for shell interpreter + while not find(c, "\r\n") do + idx += 1 + if idx > length(text) then return end if + c = text[idx] + end while + end if +end procedure + +procedure skip_whitespace() + integer c + if idx > length(text) then return end if + c = text[idx] + while find(c, "\t\r\n -") or (OE4 and c='/') do + if c = '-' then + if idx >= length(text) or text[idx+1] != '-' then + exit + end if + -- skip comment + while not find(c, "\r\n") do + idx += 1 + if idx > length(text) then return end if + c = text[idx] + end while + elsif OE4 and c = '/' then + if idx >= length(text) or text[idx+1] != '*' then + return + end if + idx += 2 + -- skip multiline comment + while idx <= length(text) and not equal(text[idx-1..idx], "*/") do + idx += 1 + end while + end if + idx += 1 + if idx > length(text) then return end if + c = text[idx] + end while +end procedure + + +function isalpha(integer c) + return and_bits(chars[c], ALPHA) + --return (c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z') or (OE4 and c = '_') +end function + +function isnum(integer c) + return and_bits(chars[c], NUM) + --return (c >= '0' and c <= '9') or (OE4 and c = '_') +end function + +function isalphanum(integer c) + return and_bits(chars[c], ALPHANUM) + --return isalpha(c) or isnum(c) or c = '_' or (OE4 and c = ':') +end function + +function ishex(integer c) + return and_bits(chars[c], HEX) + --return isnum(c) or (c >= 'A' and c <= 'F') +end function + +function ispunct(integer c) + return and_bits(chars[c], PUNCT) +end function + +procedure num_token() + -- parse new hex/binary/octal format + if OE4 and idx <= length(text) and text[tok_idx] = '0' and + idx = tok_idx+1 and find(text[idx], "xXbBoO") then + idx += 1 + while idx <= length(text) and ishex(text[idx]) do + idx += 1 + end while + return + end if + + -- parse digits if not starting with '.' + if text[tok_idx] != '.' then + while idx <= length(text) and isnum(text[idx]) do + idx += 1 + end while + if idx < length(text) and text[idx] = '.' and text[idx+1] != '.' then + idx += 1 + end if + end if + + -- parse fractional digits + while idx <= length(text) and isnum(text[idx]) do + idx += 1 + end while + + -- parse exponent + if idx <= length(text) and (text[idx] = 'e' or text[idx] = 'E') then + idx += 1 + while idx <= length(text) and isnum(text[idx]) do + idx += 1 + end while + end if +end procedure + +function token(sequence try) + if length(tok) = 0 then + skip_whitespace() + if idx > length(text) then + return equal(tok, try) + end if + tok_idx = idx + idx += 1 + switch text[tok_idx] do + case 'a','b','c','d','e','f','g','h','i','j','k','l','m','n', + 'o','p','q','r','s','t','u','v','w','x','y','z','_', + 'A','B','C','D','E','F','G','H','I','J','K','L','M','N', + 'O','P','Q','R','S','T','U','V','W','X','Y','Z' then + while idx <= length(text) and (isalphanum(text[idx]) or (OE4 and text[idx] = ':')) do + idx += 1 + end while + case '0','1','2','3','4','5','6','7','8','9' then + num_token() + case '.' then + if idx <= length(text) and text[idx] = '.' then + idx += 1 + else + num_token() + end if + case '+','-','*','/','&','<','>','!' then + if idx <= length(text) and text[idx] = '=' then + idx += 1 + end if + case '#' then + while idx <= length(text) and ishex(text[idx]) do + idx += 1 + end while + end switch + tok = text[tok_idx..idx-1] + -- printf(1, "token: %s\n", {tok}) + end if + if equal(tok, try) then + tok = "" + return 1 + end if + return 0 +end function + +procedure expect(sequence try) + if not token(try) then + error("expected '" & try & "', not '"&tok&"'") + tok = "" + end if +end procedure + +function identifier() + if length(tok) = 0 then + if token("") then + return 0 + end if + end if + -- note: namespace is the only keyword than can also be used as an identifier + return isalpha(tok[1]) and map:get(lookup_table, tok, NAMESPACE) = NAMESPACE +end function + +function get_token() + sequence result + if length(tok) = 0 then + token("") + end if + result = tok + tok = "" + return result +end function + + +function escape_character(integer c) + integer i + sequence s + i = find(c, "trn\\\'\"") + if i = 0 then + error("unknown escape character") + return c + end if + s = "\t\r\n\\\'\"" + return s[i] +end function + +function string_literal() + sequence s + s = "" + + -- check for triple-quoted string + if idx+1 <= length(text) and text[idx] = '"' and text[idx+1] = '"' then + -- triple-quoted string + integer start_idx = idx+2 + idx += 2 + while text[idx] != '"' or text[idx+1] != '"' or text[idx+2] != '"' do + idx += 1 + if idx+2 > length(text) then + error("unexpected end of file") + exit + end if + end while + idx += 3 + return text[start_idx..idx-4] + end if + + while idx <= length(text) and text[idx] != '"' do + if text[idx] = '\n' or text[idx] = '\r' then + error("unterminated string literal") + return s + end if + if text[idx] = '\\' then + idx += 1 + if idx <= length(text) then + s &= escape_character(text[idx]) + end if + else + s &= text[idx] + end if + idx += 1 + if idx > length(text) then + error("unexpected end of file") + return s + end if + end while + idx += 1 + return s +end function + +function multiline_string_literal() + integer start_idx + + start_idx = idx + while text[idx] != '`' do + idx += 1 + if idx > length(text) then + error("unexpected end of file") + return text[start_idx..idx-1] + end if + end while + idx += 1 + return text[start_idx..idx-2] +end function + +function character_literal() + integer c = 0 + if idx <= length(text) then + c = text[idx] + if c = '\n' or c = '\r' then + error("unterminated character literal") + end if + idx += 1 + if c = '\\' and idx <= length(text) then + c = escape_character(text[idx]) + idx += 1 + end if + end if + if idx > length(text) then + error("unexpected end of file") + return c + end if + if text[idx] != '\'' then + tok_idx = idx + error("expected '''") + end if + idx += 1 + return c +end function + +-- returns a bare or quoted filename following an include statement +-- when quoted, backslashes must be escaped +function include_filename() + sequence s + skip_whitespace() + if idx <= length(text) and text[idx] = '\"' then + idx += 1 + tok_idx = idx + return string_literal() + end if + s = "" + tok_idx = idx + while idx <= length(text) and not find(text[idx], "\t\r\n ") do + s &= text[idx] + idx += 1 + end while + return s +end function + + +-- returns a sequence of paths from the eu.cfg +-- name is path to eu.cfg file, mode can be "interpret", "translate", "bind" +global function parse_eu_cfg(sequence name, sequence mode = "interpret") + integer fd, section_ok = 1 + object line + sequence result = {} + sequence allowed_sections = {"[all]", "["&mode&"]"} + ifdef WINDOWS then + allowed_sections &= {"[windows]", "["&mode&":windows]"} + end ifdef + ifdef UNIX then + allowed_sections &= {"[unix]", "["&mode&":unix]"} + end ifdef + + fd = open(name, "r") + if fd = -1 then return {} end if + line = gets(fd) + while sequence(line) do + line = trim(line) + if length(line) then + if line[1] = '-' then + -- comment or compiler option, ignore it + elsif line[1] = '[' then + -- section + section_ok = find(line, allowed_sections) + elsif section_ok then + result = append(result, line) + end if + end if + line = gets(fd) + end while + close(fd) + return result +end function + +-- returns a unique timestamp for filename, or -1 if doesn't exist or is a directory +global function get_timestamp(sequence file_name) + object info + + ifdef WINDOWS then + if find(upper(filename(file_name)), dos_devices) then + return -1 + end if + end ifdef + + info = dir(file_name) + if atom(info) or length(info) = 0 or length(info[1]) < 9 then + return -1 + end if + info = info[1] + if find('d', info[D_ATTRIBUTES]) or find('D', info[D_ATTRIBUTES]) then + return -1 -- don't work on directories or devices + end if + -- timestamp is contrived (unlike seconds since epoch) + -- just needs to be unique so we can tell if a file was changed. + -- there will be gaps since not all months have 31 days. + return info[D_SECOND] + 60 * ( + info[D_MINUTE] + 60 * ( + info[D_HOUR] + 24 * ( + info[D_DAY] + 31 * ( + info[D_MONTH] + 12 * + info[D_YEAR])))) +end function + +-- returns index of new/existing cache entry +function cache_entry(sequence filename) + object tmp + integer f + + -- find an existing entry + for i = 1 to length(cache) do + if equal(cache[i][1], filename) then + return i + end if + end for + + -- create new cache and map entries + cache = append(cache, {filename, 0}) + maps = append(maps, map:new()) + return length(cache) +end function + +-- returns -1 if not found, or index of cache entry +function include_file(sequence filename) + sequence state, tmp, paths + atom ts = -1 + integer f + + tmp = filename + ts = get_timestamp(tmp) + if ts = -1 and not equal(source_filename, "") then + -- checks for the include file in the same directory as the parent + tmp = dirname(source_filename) & SLASH & tmp + ts = get_timestamp(tmp) + --printf(1, "%s %d\n", {tmp, ts}) + if ts = -1 then + -- search for a eu.cfg in the same directory as the parent? + tmp = dirname(source_filename) & SLASH & "eu.cfg" + paths = parse_eu_cfg(tmp) + for i = 1 to length(paths) do + tmp = paths[i] + if tmp[$] != SLASH then + tmp &= SLASH + end if + tmp &= filename + ts = get_timestamp(tmp) + if ts != -1 then + exit + end if + end for + end if + end if + if ts = -1 then + -- search standard include paths (of the editor interpreter instance) + paths = include_search_paths + -- try EUDIR too + for i = 1 to length(paths) do + tmp = paths[i] + if tmp[$] != SLASH then + tmp &= SLASH + end if + tmp &= filename + ts = get_timestamp(tmp) + --printf(1, "%s %d\n", {tmp, ts}) + if ts != -1 then + exit + end if + end for + end if + if ts = -1 then + return -1 -- file not found + end if + + filename = canonical_path(tmp, 0, CORRECT) + + -- verify that the file can be opened + f = open(filename, "rb") + if f = -1 then + puts(2, "Warning: unable to read file: "&filename&"\n") + return -1 -- unable to read file + end if + close(f) + + --printf(1, "%s %d\n", {tmp, ts}) + return cache_entry(filename) +end function + + +function to_number(sequence s) + atom x, y + integer base, start + + x = 0 + y = 0 + base = 10 + start = 1 + + if s[1] = '#' then + base = 16 + start = 2 + elsif OE4 and length(s) >= 2 and s[1] = '0' then + if s[2] = 'b' or s[2] = 'B' then + base = 2 + start = 2 + elsif s[2] = 'x' or s[2] = 'X' then + base = 16 + start = 2 + elsif s[2] = 'o' or s[2] = 'O' then + base = 8 + start = 2 + end if + end if + + for i = start to length(s) do + if s[i] = '.' then + y = 1 + elsif s[i] != '_' then + if y = 0 then + x = x * base + (s[i] - '0') + if s[i] >= 'A' then + x += (10 - 'A') + end if + else + -- fractional part + y /= base + x += y * (s[i] - '0') + -- FIXME, this is probably not accurate + if s[i] >= 'A' then + x += y * (10 - 'A') + end if + end if + end if + end for + return x +end function + +function variable_or_function_call() + sequence e = {VARIABLE, get_token(), tok_idx} + --printf(1, "identifier %s\n", {e[2]}) + if token("(") then + -- function call + e[1] = FUNC + if not token(")") then + --printf(1, "function call %s\n", {e[2]}) + integer ok = 1 + while ok do + if OE4 and token(",") then + e = append(e, {DEFAULT}) + else + e = append(e, expr(1)) + ok = token(",") + end if + end while + expect(")") + end if + else + while token("[") do + e = {SUBSCRIPT, e, expr(1)} + if token("..") then + e[1] = SLICE + e = append(e, expr(1)) + expect("]") + exit + end if + expect("]") + end while + end if + return e +end function + +constant precedence = { + 0, -- LOAD + 0, -- LOADHI + 0, -- MOV + 4, -- ADD + 0, -- ADDU8 + 5, -- MUL + 5, -- DIV + 0, -- REM + 2, -- JL + 2, -- JLE + 2, -- JE + 2, -- JNE + 0, -- JMP + 2, -- EQ + 2, -- NEQ + 2, -- LT + 2, -- GTE + 2, -- LTE + 2, -- GT + 0, -- QPRINT + 4, -- SUB + 0, -- SUBU8 + 0, -- NOT + 0, -- NEG + 1, -- AND + 1, -- OR + 1, -- XOR + 3 -- CAT +} + +function expr(integer depth) + sequence e, t + + t = get_token() + switch t do + case "not" then + e = {NOT, expr(100)} + case "(" then + e = expr(1) + expect(")") + case "-" then + e = {NEG, expr(100)} + if length(e[2]) and e[2][1] = NUMBER then + e = {NUMBER, -e[2][2]} + end if + case "+" then + e = expr(100) + case "\"" then + e = {STRING, string_literal()} + case "`" then + e = {STRING, multiline_string_literal()} + case "'" then + e = {NUMBER, character_literal()} + case "$" then + e = {SEQ_LEN} + case "{" then + e = {SEQ} + if not token("}") then + e = append(e, expr(1)) + while token(",") do + if OE4 and token("$") then exit end if + e = append(e, expr(1)) + end while + expect("}") + end if + + case else + tok = t + if identifier() then + e = variable_or_function_call() + elsif length(tok) and (isnum(tok[1]) or tok[1] = '#' or tok[1] = '.') then + e = {NUMBER, to_number(get_token())} + else + return {SYNTAX_ERROR, tok_idx, length(tok), "expected an expression"} + end if + end switch + + while 1 do + t = get_token() + switch t do + case "and","or","xor","<","<=",">",">=","=","!=","&","+","-","*","/" then + integer op = map:get(lookup_table, t) + if depth > precedence[op] then + exit + end if + e = {op, e, expr(precedence[op])} + case else + exit + end switch + end while + + tok = t + return e +end function + +-- returns a boolean +function ifdef_reduce(sequence e) + if length(e) = 0 then + return 0 + elsif e[1] = AND then + return ifdef_reduce(e[2]) and ifdef_reduce(e[3]) + elsif e[1] = OR then + return ifdef_reduce(e[2]) or ifdef_reduce(e[3]) + elsif e[1] = XOR then + return ifdef_reduce(e[2]) xor ifdef_reduce(e[3]) + elsif e[1] = NOT then + return not ifdef_reduce(e[2]) + elsif e[1] = VARIABLE then + return find(e[2], defined_words) != 0 + end if + return 0 +end function + +function variable_declaration() + sequence result, tmp + integer save_idx + + save_idx = idx + result = {VAR_DECL, get_token(), tok_idx} + if not identifier() then + -- restore the last token + tok = result[2] + tok_idx = result[3] + idx = save_idx + return {} + end if + + while 1 do + tmp = {get_token(), tok_idx, 0} + if OE4 and token("=") then + tmp = append(tmp, expr(1)) + end if + tmp[3] = tok_idx -- scope-start + result = append(result, tmp) + if not token(",") or (OE4 and token("$")) then + exit + end if + if not identifier() then + error("expected an identifier") + exit + end if + end while + + return result +end function + +function constant_declaration() + sequence result, tmp + + result = {CONST_DECL} + while identifier() do + tmp = {get_token(), tok_idx, 0, 0} + expect("=") + tmp[4] = expr(1) + tmp[3] = tok_idx -- scope-start + result = append(result, tmp) + if not token(",") or (OE4 and token("$")) then + return result + end if + end while + error("expected an identifier name") + return result +end function + +function assignment_or_procedure_call() + sequence result, ops + integer ok, save_idx = idx + + if not identifier() then + return {} + end if + + result = {0, get_token(), tok_idx} + if token("(") then + -- procedure call + result[1] = PROC + if not token(")") then + ok = 1 + while ok do + if OE4 and token(",") then + result = append(result, {DEFAULT}) + else + result = append(result, expr(1)) + ok = token(",") + end if + end while + expect(")") + end if + return result + + elsif token("[") then + ops = {SUB_ASSIGN, SUB_ADDTO, SUB_SUBTO, SUB_MULTO, SUB_DIVTO, SUB_CATTO} + tok = "[" + while token("[") do + result = append(result, expr(1)) + if token("..") then + result = append(result, expr(1)) + expect("]") + ops = {SLICE_ASSIGN, SLICE_ADDTO, SLICE_SUBTO, SLICE_MULTO, SLICE_DIVTO, SLICE_CATTO} + exit + end if + expect("]") + end while + else + ops = {ASSIGN, ADDTO, SUBTO, MULTO, DIVTO, CATTO} + end if + + if token("=") then + result[1] = ops[1] + elsif token("+=") then + result[1] = ops[2] + elsif token("-=") then + result[1] = ops[3] + elsif token("*=") then + result[1] = ops[4] + elsif token("/=") then + result[1] = ops[5] + elsif token("&=") then + result[1] = ops[6] + else + tok = result[2] + tok_idx = result[3] + idx = save_idx + return {} + end if + return append(result, expr(1)) +end function + +function subroutine_declaration(integer subroutine) + sequence result, args, tmp + result = {subroutine, "", 0} + if identifier() then + result[2] = get_token() + result[3] = tok_idx + else + error("expected an identifier name") + end if + expect("(") + args = {} + while not token(")") do + if length(args) and not token(",") then + error("expected ',' or ')'") + exit + end if + if identifier() then + tmp = {get_token(), 0, 0, 0} + else + error("expected a type name") + exit + end if + if identifier() then + tmp[2] = get_token() + tmp[3] = tok_idx + else + error("expected an argument name") + exit + end if + if OE4 and token("=") then + tmp = append(tmp, expr(1)) + end if + tmp[4] = tok_idx -- scope-start + args = append(args, tmp) + end while + result = append(result, args) + return result +end function + +function enum_declaration() + sequence result, tmp + + result = {ENUM_DECL, "", 0, '+', {NUMBER, 1}} + if token("type") then + if identifier() then + result[2] = get_token() + result[3] = tok_idx -- scope-start + else + error("expected an identifier name") + end if + end if + if token("by") then + if token("+") then + elsif token("-") then + result[4] = '-' + elsif token("*") then + result[4] = '*' + elsif token("/") then + result[4] = '/' + else + error("expected one of: + - * /") + end if + result[5] = expr(1) + end if + while identifier() do + tmp = {get_token(), tok_idx, 0} + if token("=") then + tmp = append(tmp, expr(1)) + end if + tmp[3] = tok_idx -- scope-start + result = append(result, tmp) + if not token(",") or (OE4 and token("$")) then + exit + end if + end while + if length(result[2]) then + expect("end") + expect("type") + end if + return result +end function + +function for_declaration() + sequence result + result = {FOR, "", 0} + if identifier() then + result[2] = get_token() + result[3] = tok_idx + else + error("expected an identifier name") + end if + expect("=") + result = append(result, expr(1)) + expect("to") + result = append(result, expr(1)) + if token("by") then + result = append(result, expr(1)) + else + result = append(result, {NUMBER, 1}) + end if + if OE4 and token("label") then + if token("\"") and length(string_literal()) then + else + error("expected a label string") + end if + end if + expect("do") + return result +end function + + +function filter_case_statements(sequence result, sequence ast) + -- {SWITCH, expr, bool-fallthru, label-string, + -- [{case-values...}, {scope-start, scope-end, stmts...},]... } + -- ("case else" will have case-values={} ) + integer case_idx = 0, scope_start, scope_end + + scope_start = ast[1] + for i = 3 to length(ast) do + sequence s = ast[i] + if s[1] = CASE then + scope_end = s[2] + if case_idx then + result = append(result, scope_start & scope_end & ast[case_idx+1..i-1]) + end if + result = append(result, s[4..$]) + case_idx = i + scope_start = s[3] + end if + end for + if case_idx then + scope_end = ast[2] + result = append(result, scope_start & scope_end & ast[case_idx+1..$]) + end if + return result +end function + +procedure with_or_without(integer mode) + if token("type_check") then + elsif token("warning") then + if not OE4 then return end if + if token("save") or token("restore") or token("strict") then + return + end if + if token("=") or token("&=") or token("+=") then + end if + if token("{") then + while tok_idx < length(text) and not token("}") do + get_token() + end while + end if + elsif token("trace") then + elsif token("profile") then + elsif token("profile_time") then + elsif OE4 and token("batch") then + elsif OE4 and token("indirect_includes") then + elsif OE4 and token("inline") then + else + error("unknown with/without option") + end if +end procedure + + +constant NONE = 0 + +function check_mode(integer mode, sequence token) + if mode = NONE then + return 0 + elsif mode = IF then + tok = "if" + elsif mode = WHILE then + tok = "while" + elsif mode = FOR then + tok = "for" + elsif mode = SWITCH then + tok = "switch" + elsif mode = FUNC_DECL then + tok = "function" + elsif mode = PROC_DECL then + tok = "procedure" + elsif mode = TYPE_DECL then + tok = "type" + elsif mode = IFDEF or mode = ELSEDEF then + return 0 + else + tok = "unknown" + end if + error("expected 'end "&tok&"' not '"&token&"'") + tok = token + return 1 +end function + +constant + PROC_FLAG = 1, -- return is allowed + FUNC_FLAG = 2, -- return with expr is allowed + LOOP_FLAG = 4, -- exit is allowed + CASE_FLAG = 8, -- case statement allowed + UNTIL_FLAG = 16 -- until statement is allowed + +function return_statement(integer flags) + if and_bits(flags, FUNC_FLAG) then + return {RETURN, expr(1)} + elsif and_bits(flags, PROC_FLAG) then + return {RETURN} + end if + error("'return' is not allowed here") + return {} +end function + + +-- mode is NONE, FUNC_DEC, PROC_DECL, TYPE_DECL, IF, IFDEF, SWITCH, WHILE, FOR +-- sub is 0, FUNC, PROC (used to determine if return needs expr) +function statements(integer mode, integer flags) + sequence ast, s, t + integer var_decl_ok, prefix, prefix_idx, saved_ifdef_ok + integer case_ok = and_bits(flags, CASE_FLAG) + + flags -= case_ok -- clear CASE_FLAG if set + s = {} + ast = {idx, 0} -- scope-start, scope-end + var_decl_ok = OE4 or find(mode, {NONE,FUNC_DECL,PROC_DECL,TYPE_DECL}) + prefix = 0 + while idx <= length(text) do + t = get_token() + switch t do + case "elsif", "else" then + tok = t + exit + + case "elsifdef", "elsedef" then + tok = t + exit + + case "end" then + if mode != NONE then + exit + end if + + case "global" then + prefix = GLOBAL + prefix_idx = tok_idx + case "public" then + prefix = PUBLIC + prefix_idx = tok_idx + case "export" then + prefix = EXPORT + prefix_idx = tok_idx + + case "while" then + s = {WHILE, expr(1)} + if OE4 and token("with") then + expect("entry") + elsif OE4 and token("entry") then + -- weird early syntax? appears in std includes + end if + if OE4 and token("label") then + if token("\"") and length(string_literal()) then + -- optional label string + else + error("expected a label string") + end if + end if + expect("do") + s &= statements(WHILE, or_bits(flags, LOOP_FLAG)) + expect("while") + + case "loop" then + s = {LOOP} + if OE4 and token("with") then + expect("entry") + end if + if OE4 and token("label") then + if token("\"") and length(string_literal()) then + -- optional label string + else + error("expected a label string") + end if + end if + expect("do") + s &= statements(LOOP, or_bits(flags, LOOP_FLAG + UNTIL_FLAG)) + expect("loop") + + case "until" then + if not and_bits(flags, LOOP_FLAG + UNTIL_FLAG) = LOOP_FLAG + UNTIL_FLAG then + error("until must be inside a loop") + end if + s = {UNTIL, expr(1)} + + case "entry" then + if not and_bits(flags, LOOP_FLAG) then + error("entry must be inside a loop") + end if + s = {ENTRY} + + case "label" then + if token("\"") then + s = {LABEL, string_literal()}-- optional label string + else + error("expected a label string") + end if + + case "for" then + s = for_declaration() + s &= statements(FOR, or_bits(flags, LOOP_FLAG)) + -- {FOR, name, pos, expr, expr, by, scope-start, scope-end, stmts...} + expect("for") + + case "exit" then + if not and_bits(flags, LOOP_FLAG) then + tok = t + error("'exit' must be inside a loop") + tok = "" + end if + s = {EXIT} + if OE4 and token("\"") then + s &= {string_literal()} -- optional label string + end if + + case "if" then + s = {IF, expr(1)} + expect("then") + s = append(s, statements(IF, flags)) + while token("elsif") do + s = append(s, expr(1)) + expect("then") + s = append(s, statements(IF, flags)) + end while + if token("else") then + s = append(s, statements(ELSE, flags)) + end if + expect("if") + + case "ifdef" then + saved_ifdef_ok = ifdef_ok + flags += case_ok + ifdef_ok = ifdef_reduce(expr(1)) and saved_ifdef_ok + expect("then") + s = choose(ifdef_ok, statements(IFDEF, flags), {}) + while token("elsifdef") do + ifdef_ok = ifdef_reduce(expr(1)) and length(s) = 0 and saved_ifdef_ok + expect("then") + s = choose(ifdef_ok, statements(IFDEF, flags), s) + end while + if token("elsedef") then + ifdef_ok = length(s) = 0 and saved_ifdef_ok + s = choose(ifdef_ok, statements(ELSEDEF, flags), s) + end if + expect("ifdef") + ifdef_ok = saved_ifdef_ok + flags -= case_ok + if length(s) then + -- splice statements into ast + ast &= s[3..$] + s = {} + end if + + case "switch" then + s = {SWITCH, expr(1), 0, ""} + if token("with") then + expect("fallthru") + s[3] = 1 -- enable fallthru + end if + if token("label") then + if token("\"") then + s[4] = string_literal() -- optional label string + else + error("expected a label string") + end if + end if + expect("do") + s = filter_case_statements(s, statements(SWITCH, or_bits(flags, CASE_FLAG))) + expect("switch") + + case "case" then + s = {CASE, tok_idx, 0} + if not case_ok then + tok = t + error("'case' must be inside 'switch'") + tok = "" + end if + if not token("else") then + while identifier() or find(tok[1], "\"'0123456789#") do + if token("\"") then + s = append(s, '"'&string_literal()&'"') -- case values + elsif token("'") then + s = append(s, '\''&character_literal()&'\'') -- case values + else + s = append(s, get_token()) -- case values + end if + if not token(",") then exit end if + end while + expect("then") + end if + s[3] = tok_idx -- scope-start + + case "break" then + s = {BREAK} + if token("\"") then + s = append(s, string_literal()) -- optional label string + end if + + case "continue" then + s = {CONTINUE} + if token("\"") then + s = append(s, string_literal()) -- optional label string + end if + + case "goto" then + s = {GOTO} + expect("\"") + s = append(s, string_literal()) -- label string + + case "?" then + s = {QPRINT, expr(1)} + + case "with" then + if check_mode(mode, "with") then exit end if + with_or_without(1) + + case "without" then + if check_mode(mode, "without") then exit end if + with_or_without(0) + + case "include" then + if check_mode(mode, "include") then exit end if + tok = include_filename() + s = {INCLUDE, -1, idx} + if ifdef_ok then + s[2] = include_file(tok) + if s[2] = -1 then + error("can't find '"&tok&"'") + end if + end if + tok = "" + + if OE4 and token("as") then + if identifier() then + s = append(s, get_token()) + s[3] = tok_idx + else + error("expected an identifier") + end if + end if + if prefix = PUBLIC then + s = PUBLIC & s + prefix = 0 + end if + if not ifdef_ok then + s = {} + end if + + case "constant" then + if check_mode(mode, "constant") then exit end if + s = constant_declaration() + + case "function" then + if check_mode(mode, "function") then exit end if + s = subroutine_declaration(FUNC_DECL) + s &= statements(FUNC_DECL, or_bits(flags, FUNC_FLAG)) + expect("function") + + case "procedure" then + if check_mode(mode, "procedure") then exit end if + s = subroutine_declaration(PROC_DECL) + s &= statements(PROC_DECL, or_bits(flags, PROC_FLAG)) + expect("procedure") + + case "type" then + if check_mode(mode, "type") then exit end if + s = subroutine_declaration(TYPE_DECL) + s &= statements(TYPE_DECL, or_bits(flags, FUNC_FLAG)) + expect("type") + + case "return" then + s = return_statement(flags) + + case "enum" then + if check_mode(mode, "enum") then exit end if + s = enum_declaration() + + case "namespace" then + if mode != NONE or length(ast) > 2 then + error("namespace must be the first statement") + elsif not identifier() then + error("expected namespace identifier") + end if + s = {NAMESPACE, get_token()} + + case "{" then + s = {SEQ_ASSIGN} + while identifier() do + s &= {get_token(), tok_idx} + if not token(",") then + exit + end if + end while + expect("}") + expect("=") + s &= {expr(1)} + + case else + tok = t + if identifier() then + if var_decl_ok then + s = variable_declaration() + end if + if length(s) = 0 then + s = assignment_or_procedure_call() + end if + if length(s) = 0 then + error("expected statement, not '"&tok&"'") + tok = "" + end if + + elsif length(tok) then + error("expected statement, not '"&tok&"'") + tok = "" + end if + end switch + + if length(s) then + if prefix then + if (length(s) > 0 and find(s[1], {VAR_DECL, CONST_DECL, ENUM_DECL, + PROC_DECL, FUNC_DECL, TYPE_DECL})) then + s = prefix & s + prefix = 0 + else + tok_idx = prefix_idx + error("scope prefix wasn't expected here") + tok = "" + end if + end if + ast = append(ast, s) + s = {} + end if + if length(errors) then + ast &= errors + errors = {} + end if + + end while + ast[2] = idx -- scope-end + return ast +end function + +global function parse(sequence source_text, sequence file_name) + integer cache_idx + sequence ast + + file_name = canonical_path(file_name, 0, CORRECT) + cache_idx = cache_entry(file_name) + + source_filename = file_name + text = source_text + idx = 1 + tok_idx = 1 + tok = "" + ifdef_ok = 1 + ast_idx = 3 + cur_map = maps[cache_idx] + map:clear(cur_map) + skip_hashbang() + ast = statements(NONE, 0) + declare_ast(ast, 3, length(text), 1) + ast[1..2] = cache[cache_idx][1..2] + cache[cache_idx] = ast + + return ast +end function + +global function parse_file(sequence file_name) + object text = read_file(file_name) + if atom(text) then + return {} -- unable to read file + end if + return parse(text, file_name) +end function + +-- during get_decls we might need to reparse a file if its timestamp changed +procedure check_cache_timestamp(integer idx) + sequence ast, file_name + atom ts + file_name = cache[idx][1] + ts = get_timestamp(file_name) + if cache[idx][2] != ts then + cache[idx][2] = ts + ast = parse_file(file_name) + if length(ast) >= 2 then + ast[1] = file_name + ast[2] = ts + cache[idx] = ast + end if + end if +end procedure + + + +constant + F = "function", + P = "procedure", + T = "type", + I = "integer", + O = "object", + S = "sequence", + A = "atom", + builtins = { + {F, "abort", I, "errcode", 0}, + {F, "and_bits", O, "a", 0, O, "b", 0}, + {F, "append", S, "target", 0, O, "x", 0}, + {F, "arctan", O, "tangent", 0}, + {T, A, O, "x", 0}, + {F, "c_func", I, "rid", 0, S, "args", 1}, + {P, "c_proc", I, "rid", 0, S, "args", 1}, + {F, "call", I, "id", 0, S, "args", 1}, + {F, "call_func", I, "id", 0, S, "args", 1}, + {P, "call_proc", I, "id", 0, S, "args", 1}, + {P, "clear_screen"}, + {P, "close", A, "fn", 0}, + {F, "command_line"}, + {F, "compare", O, "compared", 0, O, "reference", 0}, + {F, "cos", O, "angle", 0}, + {F, "date"}, + {P, "delete", O, "x", 0}, + {F, "delete_routine", O, "x", 0, I, "rid", 0}, + {F, "equal", O, "left", 0, O, "right", 0}, + {F, "find", O, "needle", 0, S, "haystack", 0, I, "start", 1}, + {F, "floor", O, "value", 0}, + {F, "get_key"}, + {F, "getc", I, "fn", 0}, + {F, "getenv", S, "var_name", 0}, + {F, "gets", I, "fn", 0}, + {F, "hash", O, "source", 0, A, "algo", 0}, + {F, "head", S, "source", 0, A, "size", 1}, + {F, "include_paths", I, "convert", 0}, + {F, "insert", S, "target", 0, O, "what", 0, I, "index", 0}, + {T, I, O, "x", 0}, + {F, "length", O, "target", 0}, + {F, "log", O, "value", 0}, + {F, "machine_func", I, "machine_id", 0, O, "args", 1}, + {P, "machine_proc", I, "machine_id", 0, O, "args", 1}, + {F, "match", S, "needle", 0, S, "haystack", 0, I, "start", 1}, + {P, "mem_copy", A, "destination", 0, A, "origin", 0, I, "len", 0}, + {P, "mem_set", A, "destination", 0, I, "byte_value", 0, I, "how_many", 0}, + {F, "not_bits", O, "a", 0}, + {T, O, O, "x", 0}, + {F, "open", S, "path", 0, S, "mode", 0, I, "cleanup", 1}, + {F, "option_switches"}, + {F, "or_bits", O, "a", 0, O, "b", 0}, + {F, "peek", O, "addr_n_length", 0}, + {F, "peek2s", O, "addr_n_length", 0}, + {F, "peek2u", O, "addr_n_length", 0}, + {F, "peek4s", O, "addr_n_length", 0}, + {F, "peek4u", O, "addr_n_length", 0}, + {F, "peek8s", O, "addr_n_length", 0}, + {F, "peek8u", O, "addr_n_length", 0}, + {F, "peek_string", A, "addr", 0}, + {F, "peeks", O, "addr_n_length", 0}, + {F, "pixel"}, + {F, "platform"}, + {P, "poke", A, "addr", 0, O, "x", 0}, + {P, "poke2", A, "addr", 0, O, "x", 0}, + {P, "poke4", A, "addr", 0, O, "x", 0}, + {P, "poke8", A, "addr", 0, O, "x", 0}, + {P, "position", I, "row", 0, I, "column", 0}, + {F, "power", O, "base", 0, O, "exponent", 0}, + {F, "prepend", S, "target", 0, O, "x", 0}, + {P, "print", I, "fn", 0, O, "x", 0}, + {P, "printf", I, "fn", 0, S, "format", 0, O, "values", 0}, + {P, "puts", I, "fn", 0, O, "text", 0}, + {F, "rand", O, "maximum", 0}, + {F, "remainder", O, "dividend", 0, O, "divisor", 0}, + {F, "remove", S, "target", 0, A, "start", 0, A, "stop", 1}, + {F, "repeat", O, "item", 0, A, "count", 0}, + {F, "replace", S, "target", 0, O, "replacement", 0, I, "start", 0, I, "stop", 1}, + {F, "routine_id", S, "routine_name", 0}, + {T, S, O, "x", 0}, + {F, "sin", O, "angle", 0}, + {F, "splice", S, "target", 0, O, "what", 0, I, "index", 0}, + {F, "sprintf", S, "format", 0, O, "values", 0}, + {F, "sqrt", O, "value", 0}, + {P, "system", S, "command", 0, I, "mode", 1}, + {F, "system_exec", S, "command", 0, I, "mode", 1}, + {F, "tail", S, "source", 0, A, "size", 1}, + {F, "tan", O, "angle", 0}, + {P, "task_clock_start"}, + {P, "task_clock_stop"}, + {F, "task_create", I, "rid", 0, S, "args", 0}, + {F, "task_list"}, + {F, "task_schedule", A, "task_id", 0, O, "schedule", 0}, + {F, "task_self"}, + {F, "task_schedule", A, "task_id", 0}, + {F, "task_suspend", A, "task_id", 0}, + {F, "task_yield"}, + {F, "time"}, + {P, "trace", I, "mode", 0}, + {F, "xor_bits", O, "a", 0, O, "b", 0} + } + +map:map builtins_map = map:new() +for i = 1 to length(builtins) do + +end for + +global function get_builtins() + sequence s + s = {} + for i = 1 to length(builtins) do + if i > 1 then s &= ' ' end if + s &= builtins[i][2] + end for + return s +end function + + +function is_namespace(sequence ast, sequence name_space) + if length(ast) >= 3 and ast[3][1] = NAMESPACE and equal(ast[3][2], name_space) then + return 1 + end if + return 0 +end function + + +sequence include_ids, include_flags +constant + FILTER_LOCAL = 1, -- #01 + FILTER_GLOBAL = 2, -- #02 + FILTER_PUBLIC = 4, -- #04 + FILTER_EXPORT = 8, -- #08 + FILTER_INCLUDE = 16, -- #10 + FILTER_INCLUDE_AS = 32, -- #20 + FILTER_ALL = 63 -- #3F + + +function get_include_filter(sequence s, sequence name_space, integer filter, integer prefix) + integer idx, include_filter + + idx = s[2] -- cache[] index + check_cache_timestamp(idx) + if length(name_space) then + --if length(s) >= 3 then + -- printf(1, "filter=%x namespace=%s include as %s\n", {filter, name_space, s[3]}) + --end if + if filter = FILTER_GLOBAL + FILTER_PUBLIC + FILTER_EXPORT then + -- include as namespace -> include + include_filter = FILTER_PUBLIC + elsif and_bits(filter, FILTER_PUBLIC) and prefix = FILTER_PUBLIC then + -- a public include from nested include + include_filter = FILTER_PUBLIC + elsif and_bits(filter, FILTER_INCLUDE_AS) and length(cache[idx]) >= 3 and + equal(cache[idx][3], {NAMESPACE, name_space}) then + -- include has same namespace + include_filter = FILTER_GLOBAL + FILTER_PUBLIC + FILTER_EXPORT + + else + include_filter = 0 + end if + elsif and_bits(filter, FILTER_INCLUDE_AS) then + -- top-level include + include_filter = FILTER_GLOBAL + FILTER_PUBLIC + FILTER_EXPORT + elsif and_bits(filter, FILTER_PUBLIC) and prefix = FILTER_PUBLIC then + -- public sub-include + include_filter = FILTER_GLOBAL + FILTER_PUBLIC + else + -- sub-include + include_filter = FILTER_GLOBAL + end if + idx = find(s[2], include_ids) + if idx = 0 then + -- new entry + include_ids &= s[2] + include_flags &= 0 + idx = length(include_ids) + elsif and_bits(include_flags[idx], include_filter) = include_filter then + -- avoid adding the same symbols again + return -1 + end if + + include_filter = and_bits(include_filter, not_bits(include_flags[idx])) + include_flags[idx] = or_bits(include_flags[idx], include_filter) + + return include_filter + FILTER_INCLUDE +end function + + +-- returns {{"subroutine-type", "name", ["arg1-type", "arg1-name", is_default]... }... } +function get_args(sequence ast, sequence word, sequence name_space, integer filter) + sequence result, s + integer x, decl, prefix, include_filter + + if length(name_space) and is_namespace(ast, name_space) then + filter = and_bits(filter, FILTER_INCLUDE + FILTER_INCLUDE_AS + FILTER_PUBLIC) + if filter = 0 then + return {} -- no namespace or mismatch + end if + end if + + result = {} + for i = 3 to length(ast) do + s = ast[i] + + prefix = power(2, find(s[1], {GLOBAL, PUBLIC, EXPORT})) + if prefix > 1 then + s = s[2..$] -- remove prefix + end if + decl = s[1] + if and_bits(filter, prefix) = 0 and decl != INCLUDE then + decl = 0 + end if + + if decl = INCLUDE and and_bits(filter, FILTER_INCLUDE) then + -- {INCLUDE, includes-index, scope-start, ["namespace"]} + x = s[2] + if x != -1 and and_bits(filter, FILTER_INCLUDE) then + include_filter = get_include_filter(s, name_space, filter, prefix) + if include_filter != -1 then + result &= get_args(cache[x], word, name_space, include_filter) + end if + end if + + elsif decl = FUNC_DECL or decl = PROC_DECL or decl = TYPE_DECL and equal(s[2], word) then + -- {FUNC_DECL, "name", pos, + -- {{"arg-type", "arg-name", pos, scope-start, [expr]}...}, + -- scope-start, scope-end, stmts...} + if decl = FUNC_DECL then + result &= {{"function", s[2]}} + elsif decl = PROC_DECL then + result &= {{"procedure", s[2]}} + elsif decl = TYPE_DECL then + result &= {{"type", s[2]}} + end if + for j = 1 to length(s[4]) do -- display arguments + result[$] &= {s[4][j][1], s[4][j][2], length(s[4][j]) = 5} -- {"type", "name", has-default} + end for + + end if + end for + -- scan builtins + if length(result) = 0 then + for i = 1 to length(builtins) do + if equal(word, builtins[i][2]) then + result &= {builtins[i]} + exit + end if + end for + end if + return result +end function + +function type_to_decl(sequence name) + if equal(name, "atom") then + return DECL_ATOM + elsif equal(name, "sequence") then + return DECL_SEQUENCE + elsif equal(name, "integer") then + return DECL_INTEGER + end if + return DECL_OBJECT +end function + +-- to prevent recursion, symbols may be included from a file +-- only once for each type of flag: global, public, export + +-- namespace matches: +-- top-level file has same namespace +-- top-level file has include as same namespace +-- included file has same namespace +-- included file is publicly included by file with same namespace + +-- get a list of declarations from ast in scope at pos +-- returns {{"name1", pos1, type1}, {"name2", pos2, type2}...} +-- pos may be be an integer for the position in the current file, +-- or {pos, "include-path"} for included files. + +function get_decls(sequence ast, integer pos, sequence name_space, integer filter) + sequence result, s + integer x, decl, prefix, include_filter + + if length(name_space) and is_namespace(ast, name_space) then + filter = and_bits(filter, FILTER_INCLUDE + FILTER_INCLUDE_AS + FILTER_PUBLIC) + if filter = 0 then + return {} -- no namespace or mismatch + end if + end if + + result = {} + + if length(name_space) = 0 and length(ast) >= 3 and ast[3][1] = NAMESPACE then + if and_bits(filter, FILTER_PUBLIC) then + result = {{ast[3][2] & ':', 1, DECL_NAMESPACE}} + end if + end if + + for i = 3 to length(ast) do + s = ast[i] + + prefix = power(2, find(s[1], {GLOBAL, PUBLIC, EXPORT})) + if prefix > 1 then + s = s[2..$] -- remove prefix + end if + decl = s[1] + if and_bits(prefix, filter) = 0 and decl != INCLUDE then + -- the scope modifier didn't pass the filter + decl = 0 + end if + + if decl = INCLUDE and and_bits(filter, FILTER_INCLUDE) then + -- {INCLUDE, includes-index, scope-start, ["namespace"]} + x = s[2] -- includes-index into cache + if x != -1 then + --printf(1, "include %s filter=%x\n", {cache[x][1], filter}) + if length(name_space) and and_bits(filter, FILTER_INCLUDE_AS) and + length(s) >= 4 and equal(s[4], name_space) and pos >= s[3] then + -- found a matching "include as" + filter = 0 + include_filter = FILTER_GLOBAL+FILTER_PUBLIC+FILTER_EXPORT+FILTER_INCLUDE + result = {} + name_space = {} + else + include_filter = get_include_filter(s, name_space, filter, prefix) + end if + if include_filter != -1 then + check_cache_timestamp(x) + s = get_decls(cache[x], 0, name_space, include_filter) + --printf(1, "%s: %d\n", {cache[x][1], length(cache[x])}) + for j = 1 to length(s) do + --printf(1, "%s: %d\n", {s[j-1], s[j]}) + if not sequence(s[j][2]) then + s[j][2] = {cache[x][1], s[j][2]} -- is {filename, pos} + end if + end for + result &= s + end if + end if + + elsif decl = CONST_DECL then + -- {CONST_DECL, {"name", pos, scope-start, expr}... } + --printf(1, "constant\n", {}) + for j = 2 to length(s) do + --printf(1, " %s: %d\n", {s[j][1], s[j][2]}) + if length(s[j]) >= 3 and (pos >= s[j][3] or filter) then -- in scope? + result = append(result, {s[j][1], s[j][2], DECL_CONSTANT}) + end if + end for + + elsif decl = VAR_DECL then + -- {VAR_DECL, "type", pos, {"name", pos, scope-start, [expr]}...} + --printf(1, s[2] & "\n", {}) + for j = 4 to length(s) do + --printf(1, " %s: %d\n", {s[j][1], s[j][2]}) + if length(s[j]) >= 3 and (pos >= s[j][3] or filter) then -- in scope? + result = append(result, {s[j][1], s[j][2], type_to_decl(s[2])}) + end if + end for + + elsif decl = FUNC_DECL or decl = PROC_DECL or decl = TYPE_DECL then + -- {FUNC_DECL, "name", pos, + -- {{"arg-type", "arg-name", pos, scope-start, [expr]}...}, + -- scope-start, scope-end, stmts...} + if decl = FUNC_DECL then + --printf(1, "function %s: %d scope=%d..%d\n", {s[2], s[3], s[5], s[6]}) + result = append(result, {s[2], s[3], DECL_FUNCTION}) + elsif decl = PROC_DECL then + --printf(1, "procedure %s: %d scope=%d..%d\n", {s[2], s[3], s[5], s[6]}) + result = append(result, {s[2], s[3], DECL_PROCEDURE}) + elsif decl = TYPE_DECL then + --printf(1, "type %s: %d scope=%d..%d\n", {s[2], s[3], s[5], s[6]}) + result = append(result, {s[2], s[3], DECL_TYPE}) + end if + if length(s) >= 6 and pos >= s[5] and pos <= s[6] then -- in scope? + for j = 1 to length(s[4]) do -- display arguments + if length(s[4][j]) >= 4 and pos >= s[4][j][4] then + --printf(1, " %s %s: %d\n", {s[4][j][1], s[4][j][2], s[4][j][3]}) + result = append(result, {s[4][j][2], s[4][j][3], type_to_decl(s[4][j][1])}) + end if + end for + result &= get_decls(s[5..$], pos, name_space, filter) + end if + + elsif decl = FOR then + -- {FOR, name, pos, expr, expr, by, scope-start, scope-end, stmts...} + if length(s) >= 8 and pos >= s[7] and pos <= s[8] then -- in scope? + --printf(1, "for %s: %d\n", {s[2], s[3]}) + result = append(result, {s[2], s[3], DECL_ATOM}) + result &= get_decls(s[7..$], pos, name_space, filter) + end if + + elsif decl = WHILE then + -- {WHILE, expr, scope-start, scope-end, stmts...} + if length(s) >= 4 and pos >= s[3] and pos <= s[4] then -- in scope? + result &= get_decls(s[3..$], pos, name_space, filter) + end if + + elsif decl = LOOP then + -- {LOOP, scope-start, scope-end, stmts...} + if length(s) >= 3 and pos >= s[2] and pos <= s[3] then -- in scope? + result &= get_decls(s[2..$], pos, name_space, filter) + end if + + elsif decl = IF then + -- {IF, expr, {scope-start, scope-end, stmts...}, + -- [expr, {scope-start, scope-end, elsif-stmts...},]... + -- [{scope-start, scope-end, else-stmts...}]} + for j = 2 to length(s) by 2 do + x = (j != length(s)) + if length(s[j+x]) >= 2 and pos >= s[j+x][1] and pos <= s[j+x][2] then -- in scope? + result &= get_decls(s[j+x], pos, name_space, filter) + end if + end for + + elsif decl = ENUM_DECL then + -- {ENUM_DECL, "typename"|"", pos, '+'|'-'|'*'|'/', expr, + -- {"name", pos, scope-start, [expr]}...} + if length(s[2]) then -- has typename + result = append(result, {s[2], s[3], DECL_TYPE}) + end if + for j = 6 to length(s) do + if length(s[j]) >= 3 and pos >= s[j][3] then -- in scope? + result = append(result, {s[j][1], s[j][2], DECL_ENUM}) + end if + end for + + end if + end for + return result +end function + +global function get_declarations(sequence ast, integer pos, sequence name_space) + include_ids = {} + include_flags = {} + return get_decls(ast, pos, name_space, choose(length(name_space), FILTER_INCLUDE + FILTER_INCLUDE_AS, FILTER_ALL)) +end function + +global function get_subroutines(sequence ast) + sequence result, s + integer decl, n + + result = {} + for i = 3 to length(ast) do + s = ast[i] + n = prefixed(s) + decl = s[n+1] + + if decl = FUNC_DECL or decl = PROC_DECL or decl = TYPE_DECL then + -- {FUNC_DECL, "name", pos, + -- {{"arg-type", "arg-name", pos, scope-start, [expr]}...}, + -- scope-start, scope-end, stmts...} + result = append(result, {s[n+2], s[n+3]}) + end if + end for + return result +end function + +-- returns {["subroutine-type", {["arg1-type", "arg1-name", has-default]...}, ]...} +global function get_subroutine_arguments(sequence ast, sequence word, sequence namespace) + include_ids = {} + include_flags = {} + return get_args(ast, word, namespace, FILTER_ALL) +end function + + + +-- returns {word, namespace, start, end} otherwise {""} +global function word_pos(sequence text, integer pos) + if pos > length(text) then + return {""} + end if + for i = pos+1 to 1 by -1 do + -- find the start of the word + if i = 1 or not isalphanum(text[i-1]) then + -- find the end of the word + while pos < length(text) and isalphanum(text[pos+1]) do + pos += 1 + end while + -- words must start with a letter + if i <= length(text) and isalpha(text[i]) then + -- look for a colon + for j = i to pos do + if text[j] = ':' then + -- found namespace and word + return {text[j+1..pos], text[i..j-1], j+1, pos} + end if + end for + -- found word only + return {text[i..pos], "", i, pos} + end if + exit + end if + end for + return {""} +end function + + +sequence suggested_includes, suggested_word, suggested_namespace, suggested_path + +function walk_include(sequence path_name, sequence dirent) + sequence decls + + path_name &= SLASH & dirent[D_NAME] + if length(path_name) < 2 or (path_name[$] != 'e' and path_name[$] != 'E') or path_name[$-1] != '.' then + -- path_name doesn't end with .e or .E + return 0 + end if + integer cache_idx = cache_entry(canonical_path(path_name, 0, CORRECT)) + if cache_idx > 0 then + check_cache_timestamp(cache_idx) + + include_ids = {} + include_flags = {} + sequence ast = cache[cache_idx] + if length(suggested_namespace) = 0 or is_namespace(ast, suggested_namespace) then + integer filter = FILTER_GLOBAL + FILTER_PUBLIC + FILTER_EXPORT + if length(suggested_namespace) then + filter += FILTER_INCLUDE + end if + decls = get_decls(ast, 0, suggested_namespace, filter) + for i = 1 to length(decls) do + --puts(1, " "&decls[i]&"\n") + if length(decls[i][1]) >= length(suggested_word) and + equal(decls[i][1][1..length(suggested_word)], suggested_word) then + --puts(1, dirent[D_NAME]&" matched!\n") + suggested_includes = append(suggested_includes, + {decls[i][1] & " --include "& path_name[length(suggested_path)+2..$], + {ast[1], decls[i][2]}, decls[i][3]}) + end if + end for + end if + end if + + return 0 -- keep searching all files +end function + +constant walk_include_id = routine_id("walk_include") + +-- returns a list of include files which contain a declaration decl +global function suggest_includes(sequence word, sequence name_space) + sequence paths, path, result + + suggested_includes = {} + suggested_word = word + suggested_namespace = name_space + paths = include_search_paths + for i = 1 to length(paths) do + path = paths[i] + --puts(1, "include_dir="&paths[i]&"\n") + if path[$] = SLASH then + path = path[1..$-1] + end if + if length(path) > 8 and equal(path[$-7..$], SLASH & "include") then + suggested_path = path + if walk_dir(path, walk_include_id, 1) = 0 then + -- success! + end if + end if + end for + result = suggested_includes + suggested_includes = {} + return result +end function + +-- parse argument expressions, returning the last argument position +global function parse_argument_position(sequence source_text) + integer arg, old_idx + sequence e + + text = source_text + idx = 1 + tok_idx = 1 + tok = "" + arg = 1 + for i = 1 to 1000 do + if tok_idx > length(text) then + return arg + end if + if token(")") then + return 0 + end if + if token(",") then + arg += 1 + end if + old_idx = tok_idx + e = expr(1) + --? {e, tok, tok_idx} + --if length(e) = 0 and length(tok) = 0 then + if old_idx = tok_idx then + return arg + end if + end for + printf(1, "stuck parsing argument position for \"%s\"\n", {text}) + ? e + ? tok + return arg +end function + +-- cur_ast: {cache-idx...} +-- cur_scope: {FILTER_* or'd...} +sequence cur_ast, cur_scope, check_result = {} +integer cur_sub = 0 -- whether or not inside subroutine + +-- scan ast for a declaration at pos, returns 0 if not found, otherwise +-- one of FUNC_DECL, PROC_DECL, TYPE_DEC, VAR_DECL, CONST_DECL or FOR +function decl_kind(sequence ast, integer start_idx, integer pos) + for j = start_idx to length(ast) do + sequence s = ast[j] + integer decl = s[1] + + if decl = FUNC_DECL or decl = PROC_DECL or decl = TYPE_DECL then + -- {FUNC_DECL, "name", pos, + -- {{"arg-type", "arg-name", pos, scope-start, [expr]}...}, + -- scope-start, scope-end, stmts...} + if pos = s[3] then + return decl + end if + sequence args = s[4] + for i = 1 to length(args) do + if pos = args[i][3] then + return VAR_DECL + end if + end for + decl = decl_kind(s, 7, pos) + if decl then + return decl + end if + + elsif decl = VAR_DECL then + -- {VAR_DECL, "type", pos, {"name", pos, scope-start, [expr]}...} + for i = 4 to length(s) do + if pos = s[i][2] then + return decl + end if + end for + + elsif decl = CONST_DECL then + -- {CONST_DECL, {"name", pos, scope-start, expr}... } + for i = 2 to length(s) do + if pos = s[i][2] then + return decl + end if + end for + + elsif decl = WHILE then + -- {WHILE, expr, scope-start, scope-end, stmts...} + if pos >= s[3] and pos <= s[4] then + decl = decl_kind(s, 5, pos) + if decl then + return decl + end if + end if + + elsif decl = LOOP then + -- {LOOP, scope-start, scope-end, stmts...} + if pos >= s[2] and pos <= s[3] then + decl = decl_kind(s, 4, pos) + if decl then + return decl + end if + end if + + elsif decl = IF then + -- {IF, expr, {scope-start, scope-end, stmts...}, + -- [expr, {scope-start, scope-end, elsif-stmts...},]... + -- [{scope-start, scope-end, else-stmts...}]} + decl = 0 + for i = 2 to length(s) by 2 do + if i = length(s) then + if pos >= s[i][1] and pos <= s[i][2] then + decl = decl_kind(s[i], 3, pos) + end if + else + if pos >= s[i+1][1] and pos <= s[i+1][2] then + decl = decl_kind(s[i+1], 3, pos) + end if + end if + if decl then + return decl + end if + end for + + elsif decl = FOR then + -- {FOR, "name", pos, expr, expr, by, scope-start, scope-end, stmts...} + if pos = s[3] then + return decl + end if + if pos >= s[7] and pos <= s[8] then + decl = decl_kind(s, 9, pos) + if decl then + return decl + end if + end if + + elsif decl = ENUM_DECL then + -- {ENUM_DECL, "typename"|"", pos, '+'|'-'|'*'|'/', expr, + -- {"name", pos, scope-start, [expr]}...} + if pos = s[3] then + return TYPE_DECL + end if + for i = 6 to length(s) do + if pos = s[i][2] then + return CONST_DECL + end if + end for + + elsif decl = SWITCH then + -- {SWITCH, expr, bool-fallthru, label-string, + -- [{case-values...}, {scope-start, scope-end, stmts...},]... } + -- ("case else" will have case-values={} ) + for i = 6 to length(s) by 2 do + if pos >= s[i][1] and pos <= s[i][2] then + decl = decl_kind(s[i], 3, pos) + if decl then + return decl + end if + end if + end for + end if + end for + return 0 +end function + +-- returns the decl kind if pos in scope of loc d, otherwise 0 +function decl_check(sequence ast, object d, integer pos, integer filter) + sequence s + if sequence(d) then + -- variable, constant, enum value or for-variable declaration + s = ast[d[1]] + else + -- function, procedure, type or enum-type declaration + s = ast[d] + end if + -- get scope modifier bits + integer prefix = power(2, find(s[1], {GLOBAL, PUBLIC, EXPORT})) + if and_bits(prefix, filter) = 0 then + return 0 + end if + if prefix > 1 then + s = s[2..$] -- remove scope modifier + end if + if atom(d) then + return s[1] + end if + -- d: { ast-index, pos, scope-start, [scope-end] } + if s[1] = VAR_DECL or s[1] = CONST_DECL or s[1] = ENUM_DECL then + -- top level always in scope + if and_bits(filter, FILTER_LOCAL) and cur_sub = 0 and pos < d[3] and cur_ast[1] = d[1] then + -- euphoria currently doesn't allow top-level forward references in the same file + return 0 + end if + return s[1] + end if + if and_bits(filter, FILTER_LOCAL) and pos >= d[3] and (length(d) < 4 or pos <= d[4]) then + -- in scope + return decl_kind({s}, 1, d[2]) + end if + return 0 +end function + +-- return a sequence of cache_idx +function public_includes(integer cache_idx, sequence result) + sequence ast = cache[cache_idx] + if cache_idx > 0 and not find(cache_idx, result) then + result &= cache_idx + for i = 3 to length(ast) do + sequence s = ast[i] + if s[1] = PUBLIC and s[2] = INCLUDE and s[3] != -1 then + result = public_includes(s[3], result) + end if + end for + end if + return result +end function + +-- returns 1 if the type of declaration "name" at pos is in the list of decls +-- otherwise 0 +function check_name(sequence name, integer pos, sequence decls) + integer ns = find(':', name) + sequence asts = cur_ast + sequence name_space = "" + if ns then + name_space = name[1..ns-1] + name = name[ns+1..$] + asts = {} + + sequence ast = cache[cur_ast[1]] + -- scan for include as + for i = 3 to length(ast) do + sequence s = ast[i] + integer n = prefixed(s) + if s[n+1] = INCLUDE and s[n+2] != -1 and length(s) >= n+4 and equal(s[n+4], name_space) and pos >= s[n+3] then + asts = public_includes(s[n+2], asts) + exit + end if + end for + + if length(asts) = 0 then + if equal(name_space, "eu") then + ns = 0 -- special builtins namespace + else + -- search includes for a matching namespace + for i = 1 to length(cur_ast) do + integer cache_idx = cur_ast[i] + ast = cache[cache_idx] + -- does it have a matching namespace at the top + if and_bits(cur_scope[i], FILTER_PUBLIC) and is_namespace(ast, name_space) then + asts = public_includes(cache_idx, asts) + end if + end for + end if + end if + + end if + for j = 1 to length(asts) do + integer cache_idx = asts[j] + sequence entries = map:get(maps[cache_idx], name, {}) + sequence ast = cache[cache_idx] + integer filter = cur_scope[find(asts[j], cur_ast)] + for i = 1 to length(entries) do + integer decl = decl_check(ast, entries[i], pos, filter) + if find(decl, decls) then + return 1 + end if + end for + end for + if ns = 0 then + sequence sub_decls = {PROC_DECL, FUNC_DECL, TYPE_DECL} + -- check builtins + for i = 1 to length(builtins) do + if equal(builtins[i][2], name) then + return find(sub_decls[find(builtins[i][1], {P, F, T})], decls) + end if + end for + end if + return 0 +end function + + +-- scan for variables only, which may be used for assignment +procedure check_var(sequence name, integer pos) + if not check_name(name, pos, {VAR_DECL}) then + check_result &= {pos, length(name), "variable '"&name&"' has not been declared"} + end if +end procedure + +-- scan for variables, constants, enum values, or for-variables +procedure check_identifier(sequence name, integer pos) + if not check_name(name, pos, {VAR_DECL, CONST_DECL, ENUM_DECL, FOR}) then + check_result &= {pos, length(name), "identifier '"&name&"' has not been declared"} + end if +end procedure + +-- scan for functions or types, used for function call +procedure check_func(sequence name, integer pos) + if not check_name(name, pos, {FUNC_DECL, TYPE_DECL, ENUM_DECL}) then + check_result &= {pos, length(name), "function '"&name&"' has not been declared"} + end if +end procedure + +-- scan for types or typed enum, used for variable declaration +procedure check_type(sequence name, integer pos) + if not check_name(name, pos, {TYPE_DECL, ENUM_DECL}) then + check_result &= {pos, length(name), "type '"&name&"' has not been declared"} + end if +end procedure + +constant proc_list = choose(OE4, {PROC_DECL, FUNC_DECL, TYPE_DECL, ENUM_DECL}, {PROC_DECL}) + +-- scan for procedures (OE4: or functions or types) +procedure check_proc(sequence name, integer pos) + if not check_name(name, pos, proc_list) then + check_result &= {pos, length(name), "procedure '"&name&"' has not been declared"} + end if +end procedure + +procedure check_expr(sequence expr) + integer decl + + if length(expr) = 0 then return end if + + decl = expr[1] + if decl = VARIABLE then + -- {VARIABLE, "name", pos} + check_identifier(expr[2], expr[3]) + + elsif decl = FUNC then + -- {FUNC, "name", pos, [args...]} + check_func(expr[2], expr[3]) + for i = 4 to length(expr) do + check_expr(expr[i]) + end for + + elsif find(decl, {ADD, SUB, MUL, DIV, NEG, NOT, GT, LT, GTE, LTE, EQ, + NEQ, OR, XOR, AND, SUBSCRIPT, CAT, SLICE, SEQ}) then + for i = 2 to length(expr) do + check_expr(expr[i]) + end for + + elsif decl = SYNTAX_ERROR then + -- {SYNTAX_ERROR, pos, len, "message"} + check_result &= expr[2..4] + + end if +end procedure + +procedure attempt_redefine(sequence name, integer pos) + check_result &= {pos, length(name), "attempt to redefine '"&name&"'"} +end procedure + +-- scan "name" at pos for redefinitions +procedure check_redefinition(sequence name, integer pos) + integer cache_idx = cur_ast[1] + sequence ast = cache[cache_idx] + sequence entries = map:get(maps[cache_idx], name, {}) + + for i = 1 to length(entries) do + object d = entries[i] + if atom(d) then + sequence s = ast[d] + -- d: ast-index (func/proc/type/enum-type) + if not cur_sub then + integer n = prefixed(s) + if find(s[n+1], {NAMESPACE, INCLUDE}) then + -- it must be a namespace or include-as + if s[n+1] = NAMESPACE or s[n+3] < pos then + -- check if pos is another include-as with the same name + for j = i+1 to length(entries) do + if atom(entries[j]) then + s = ast[entries[j]] + n = prefixed(s) + if s[n+1] = INCLUDE and n+3 <= length(s) and s[n+3] = pos then + attempt_redefine(name, pos) + return + end if + end if + end for + end if + elsif not find(s[n+1], {FUNC_DECL, PROC_DECL, TYPE_DECL, ENUM_DECL}) then + -- not a subroutine? something is wrong with the parser + printf(1, "%s %d %d\n", {name, s[n+1], d}) + ? entries + elsif n+3 <= length(s) and s[n+3] < pos then + --printf(1, "%s at %d with %d\n", {name, pos, s[n+3]}) + attempt_redefine(name, pos) + return + end if + end if + elsif d[2] < pos then + -- d: {ast-index, pos, scope-start, [scope-end]} + sequence s = ast[d[1]] + integer n = prefixed(s) + integer top_level = 1 + if find(s[n+1], {FUNC_DECL, PROC_DECL, TYPE_DECL}) and s[n+3] != d[2] then + top_level = 0 + end if + if cur_sub != top_level and decl_check(ast, d, pos, FILTER_LOCAL) then + attempt_redefine(name, pos) + return + end if + end if + end for +end procedure + +-- add an include to the cur_ast and calculate it's visibility/scope +procedure check_include(sequence s, integer filter) + integer n = s[1] != INCLUDE + integer cache_idx = s[n+2] + integer cur_idx = find(cache_idx, cur_ast) + + if cache_idx = -1 then + return + end if + + if cur_idx = 0 then + -- create a new entry + check_cache_timestamp(cache_idx) + cur_ast = append(cur_ast, cache_idx) + cur_scope = append(cur_scope, filter) + else + -- existing entry, filter bits already set? + if and_bits(cur_scope[cur_idx], filter) = filter then + return + end if + -- update the filter bits and rescan the ast + cur_scope[cur_idx] = or_bits(cur_scope[cur_idx], filter) + end if + + -- scan the ast for sub-includes + sequence ast = cache[cache_idx] + for i = 3 to length(ast) do + s = ast[i] + if s[1] = INCLUDE then + if and_bits(filter, FILTER_LOCAL) then + check_include(s, FILTER_GLOBAL+FILTER_PUBLIC+FILTER_EXPORT) + else + check_include(s, FILTER_GLOBAL) + end if + elsif s[1] = PUBLIC and s[2] = INCLUDE then + if and_bits(filter, FILTER_LOCAL) then + check_include(s, FILTER_GLOBAL+FILTER_PUBLIC+FILTER_EXPORT) + else + check_include(s, and_bits(filter, FILTER_GLOBAL+FILTER_PUBLIC)) + end if + end if + end for +end procedure + +procedure check_ast(sequence ast, integer start_idx) + + for j = start_idx to length(ast) do + sequence s = ast[j] + integer n = prefixed(s) + integer decl = s[n+1] + + if decl = INCLUDE then + -- {INCLUDE, includes-idx, scope-start, ["namespace"]} + if n+4 <= length(s) then + check_redefinition(s[n+4], s[n+3]) + end if + + elsif decl = FUNC_DECL or decl = PROC_DECL or decl = TYPE_DECL then + -- {FUNC_DECL, "name", pos, + -- {{"arg-type", "arg-name", pos, scope-start, [expr]}...}, + -- scope-start, scope-end, stmts...} + sequence args = s[n+4] + check_redefinition(s[n+2], s[n+3]) + cur_sub = 1 + for i = 1 to length(args) do + check_redefinition(args[i][2], args[i][3]) + if length(args[i]) >= 5 then + check_expr(args[i][5]) + end if + end for + check_ast(s, n+7) + cur_sub = 0 + + elsif decl = PROC then + -- {PROC, "name", pos, [args...]} + check_proc(s[n+2], s[n+3]) + for i = n+4 to length(s) do + check_expr(s[i]) + end for + + elsif decl = VAR_DECL then + -- {VAR_DECL, "type", pos, {"name", pos, scope-start, [expr]}...} + check_type(s[n+2], s[n+3]) + for i = n+4 to length(s) do + check_redefinition(s[i][1], s[i][2]) + if length(s[i]) >= 4 then + check_expr(s[i][4]) + end if + end for + + elsif decl = CONST_DECL then + -- {CONST_DECL, {"name", pos, scope-start, expr}... } + for i = n+2 to length(s) do + check_redefinition(s[i][1], s[i][2]) + check_expr(s[i][4]) + end for + + elsif decl = WHILE then + -- {WHILE, expr, scope-start, scope-end, stmts...} + check_expr(s[n+2]) + check_ast(s, n+5) + + elsif decl = LOOP then + -- {LOOP, scope-start, scope-end, stmts...} + check_ast(s, n+4) + + elsif decl = IF then + -- {IF, expr, {scope-start, scope-end, stmts...}, + -- [expr, {scope-start, scope-end, elsif-stmts...},]... + -- [{scope-start, scope-end, else-stmts...}]} + for i = n+2 to length(s) by 2 do + if i = length(s) then + check_ast(s[i], 3) + else + check_expr(s[i]) + check_ast(s[i+1], 3) + end if + end for + + elsif decl = FOR then + -- {FOR, "name", pos, expr, expr, by, scope-start, scope-end, stmts...} + check_redefinition(s[n+2], s[n+3]) + check_expr(s[n+4]) -- first + check_expr(s[n+5]) -- last + check_expr(s[n+6]) -- by + check_ast(s, n+9) + + elsif decl = ENUM_DECL then + -- {ENUM_DECL, "typename"|"", pos, '+'|'-'|'*'|'/', expr, + -- {"name", pos, scope-start, [expr]}...} + if length(s[n+2]) then + check_redefinition(s[n+2], s[n+3]) + end if + check_expr(s[n+5]) + for i = n+6 to length(s) do + check_redefinition(s[i][1], s[i][2]) + if length(s[i]) >= 4 then + check_expr(s[i][4]) + end if + end for + + elsif decl = SWITCH then + -- {SWITCH, expr, bool-fallthru, label-string, + -- [{case-values...}, {scope-start, scope-end, stmts...},]... } + -- ("case else" will have case-values={} ) + check_expr(s[n+2]) + for i = n+6 to length(s) by 2 do + check_ast(s[i], 3) + end for + + elsif find(decl, {ASSIGN, SUB_ASSIGN, SUB_ADDTO, SUB_SUBTO, SUB_MULTO, + SUB_DIVTO, SUB_CATTO, SLICE_ASSIGN, SLICE_ADDTO, + SLICE_SUBTO, SLICE_MULTO, SLICE_DIVTO, SLICE_CATTO}) then + -- {ASSIGN, "name", pos, expr} + -- {SUB_ASSIGN, "name", pos, index-expr..., expr} + -- {SLICE_ASSIGN, "name", pos, index-expr..., start-expr, end-expr, expr} + check_var(s[n+2], s[n+3]) + for i = n+4 to length(s) do + check_expr(s[i]) + end for + + elsif decl = SEQ_ASSIGN then + -- {SEQ_ASSIGN, ["name1", pos1,]... expr} + for i = n+2 to length(s)-1 by 2 do + check_var(s[i], s[i+1]) + end for + check_expr(s[$]) + + elsif decl = QPRINT or decl = UNTIL then + check_expr(s[2]) + + elsif decl = SYNTAX_ERROR then + -- {SYNTAX_ERROR, pos, len, "message"} + check_result &= s[2..4] + end if + + end for +end procedure + +-- returns sequence of error positions, lengths, and messages: +-- {pos1, len1, msg1, pos2, len2, msg2, ...} +global function parse_errors(sequence source_text, sequence file_name) + integer cache_idx + sequence result, ast + + file_name = canonical_path(file_name, 0, CORRECT) +--atom t0 = time() + ast = parse(source_text, file_name) +--? time() - t0 + cache_idx = cache_entry(file_name) + cur_ast = {} + cur_scope = {} + -- check includes up front, so forward references work + check_include({INCLUDE, cache_idx}, FILTER_ALL) + check_ast(ast, 3) + result = check_result + cur_ast = {} + cur_scope = {} + check_result = {} + return result +end function + diff --git a/tools/WEE/scintilla.e b/tools/WEE/scintilla.e new file mode 100644 index 0000000..eec7c63 --- /dev/null +++ b/tools/WEE/scintilla.e @@ -0,0 +1,2802 @@ +-- scintilla.e + +-- Scintilla Documentation: +-- www.scintilla.org/ScintillaDoc.html + + +include std/dll.e +include std/machine.e +include std/error.e +include std/filesys.e + +sequence dll, send_message +ifdef WINDOWS then + ifdef BITS64 then + dll = "scintilla\\SciLexer64.dll" + elsedef + dll = "scintilla\\SciLexer.dll" + end ifdef + send_message = "Scintilla_DirectFunction" +elsedef + ifdef OSX then + dll = "scintilla/scintillaOSX.dylib" + elsifdef BITS64 then + dll = "scintilla/scintilla64.so" + elsifdef ARM then + dll = "scintilla/scintilla32armhf.so" + elsedef + dll = "scintilla/scintilla32.so" + end ifdef + send_message = "scintilla_send_message" +end ifdef + +constant cmd_line = command_line() + +atom scintilla +scintilla = open_dll(dirname(cmd_line[1]) & SLASH & dll) +if scintilla = 0 and length(cmd_line) >= 2 then + scintilla = open_dll(dirname(cmd_line[2]) & SLASH & dll) +end if +if scintilla = 0 then + scintilla = open_dll(dll) +end if + +constant + scintilla_new_ = define_c_func(scintilla, "scintilla_new", {}, C_POINTER), + scintilla_send_message_ = define_c_func(scintilla, send_message, {C_POINTER, C_LONG, C_LONG, C_LONG}, C_LONG) + +--? {scintilla, scintilla_new_, scintilla_send_message_} + +if scintilla = 0 or scintilla_send_message_ = -1 then + crash("failed to open scintilla DLL "&dll&"\n") +end if + + +global function scintilla_new() + return c_func(scintilla_new_, {}) +end function + +global function scintilla_send_message(atom hwnd, atom m, object w, object l) + if sequence(w) then w = allocate_string(w) end if + if sequence(l) then l = allocate_string(l) end if + return c_func(scintilla_send_message_, {hwnd, m, w, l}) +end function + +global function SSM(atom hwnd, atom m, object w=0, object l=0) + if sequence(w) then w = allocate_string(w) end if + if sequence(l) then l = allocate_string(l) end if + return c_func(scintilla_send_message_, {hwnd, m, w, l}) +end function + +-- To create the list of constants from the scintilla header files: +-- awk '/#define/ { sub(/^0x/,"#",$3); print " "$2" = "$3"," }' Scintilla.h + +-- Scintilla.h +global constant + INVALID_POSITION = -1, + SCI_START = 2000, + SCI_OPTIONAL_START = 3000, + SCI_LEXER_START = 4000, + SCI_ADDTEXT = 2001, + SCI_ADDSTYLEDTEXT = 2002, + SCI_INSERTTEXT = 2003, + SCI_CHANGEINSERTION = 2672, + SCI_CLEARALL = 2004, + SCI_DELETERANGE = 2645, + SCI_CLEARDOCUMENTSTYLE = 2005, + SCI_GETLENGTH = 2006, + SCI_GETCHARAT = 2007, + SCI_GETCURRENTPOS = 2008, + SCI_GETANCHOR = 2009, + SCI_GETSTYLEAT = 2010, + SCI_REDO = 2011, + SCI_SETUNDOCOLLECTION = 2012, + SCI_SELECTALL = 2013, + SCI_SETSAVEPOINT = 2014, + SCI_GETSTYLEDTEXT = 2015, + SCI_CANREDO = 2016, + SCI_MARKERLINEFROMHANDLE = 2017, + SCI_MARKERDELETEHANDLE = 2018, + SCI_GETUNDOCOLLECTION = 2019, + SCWS_INVISIBLE = 0, + SCWS_VISIBLEALWAYS = 1, + SCWS_VISIBLEAFTERINDENT = 2, + SCI_GETVIEWWS = 2020, + SCI_SETVIEWWS = 2021, + SCI_POSITIONFROMPOINT = 2022, + SCI_POSITIONFROMPOINTCLOSE = 2023, + SCI_GOTOLINE = 2024, + SCI_GOTOPOS = 2025, + SCI_SETANCHOR = 2026, + SCI_GETCURLINE = 2027, + SCI_GETENDSTYLED = 2028, + SC_EOL_CRLF = 0, + SC_EOL_CR = 1, + SC_EOL_LF = 2, + SCI_CONVERTEOLS = 2029, + SCI_GETEOLMODE = 2030, + SCI_SETEOLMODE = 2031, + SCI_STARTSTYLING = 2032, + SCI_SETSTYLING = 2033, + SCI_GETBUFFEREDDRAW = 2034, + SCI_SETBUFFEREDDRAW = 2035, + SCI_SETTABWIDTH = 2036, + SCI_GETTABWIDTH = 2121, + SCI_CLEARTABSTOPS = 2675, + SCI_ADDTABSTOP = 2676, + SCI_GETNEXTTABSTOP = 2677, + SC_CP_UTF8 = 65001, + SCI_SETCODEPAGE = 2037, + SC_IME_WINDOWED = 0, + SC_IME_INLINE = 1, + SCI_GETIMEINTERACTION = 2678, + SCI_SETIMEINTERACTION = 2679, + MARKER_MAX = 31, + SC_MARK_CIRCLE = 0, + SC_MARK_ROUNDRECT = 1, + SC_MARK_ARROW = 2, + SC_MARK_SMALLRECT = 3, + SC_MARK_SHORTARROW = 4, + SC_MARK_EMPTY = 5, + SC_MARK_ARROWDOWN = 6, + SC_MARK_MINUS = 7, + SC_MARK_PLUS = 8, + SC_MARK_VLINE = 9, + SC_MARK_LCORNER = 10, + SC_MARK_TCORNER = 11, + SC_MARK_BOXPLUS = 12, + SC_MARK_BOXPLUSCONNECTED = 13, + SC_MARK_BOXMINUS = 14, + SC_MARK_BOXMINUSCONNECTED = 15, + SC_MARK_LCORNERCURVE = 16, + SC_MARK_TCORNERCURVE = 17, + SC_MARK_CIRCLEPLUS = 18, + SC_MARK_CIRCLEPLUSCONNECTED = 19, + SC_MARK_CIRCLEMINUS = 20, + SC_MARK_CIRCLEMINUSCONNECTED = 21, + SC_MARK_BACKGROUND = 22, + SC_MARK_DOTDOTDOT = 23, + SC_MARK_ARROWS = 24, + SC_MARK_PIXMAP = 25, + SC_MARK_FULLRECT = 26, + SC_MARK_LEFTRECT = 27, + SC_MARK_AVAILABLE = 28, + SC_MARK_UNDERLINE = 29, + SC_MARK_RGBAIMAGE = 30, + SC_MARK_BOOKMARK = 31, + SC_MARK_CHARACTER = 10000, + SC_MARKNUM_FOLDEREND = 25, + SC_MARKNUM_FOLDEROPENMID = 26, + SC_MARKNUM_FOLDERMIDTAIL = 27, + SC_MARKNUM_FOLDERTAIL = 28, + SC_MARKNUM_FOLDERSUB = 29, + SC_MARKNUM_FOLDER = 30, + SC_MARKNUM_FOLDEROPEN = 31, + SC_MASK_FOLDERS = #FE000000, + SCI_MARKERDEFINE = 2040, + SCI_MARKERSETFORE = 2041, + SCI_MARKERSETBACK = 2042, + SCI_MARKERSETBACKSELECTED = 2292, + SCI_MARKERENABLEHIGHLIGHT = 2293, + SCI_MARKERADD = 2043, + SCI_MARKERDELETE = 2044, + SCI_MARKERDELETEALL = 2045, + SCI_MARKERGET = 2046, + SCI_MARKERNEXT = 2047, + SCI_MARKERPREVIOUS = 2048, + SCI_MARKERDEFINEPIXMAP = 2049, + SCI_MARKERADDSET = 2466, + SCI_MARKERSETALPHA = 2476, + SC_MAX_MARGIN = 4, + SC_MARGIN_SYMBOL = 0, + SC_MARGIN_NUMBER = 1, + SC_MARGIN_BACK = 2, + SC_MARGIN_FORE = 3, + SC_MARGIN_TEXT = 4, + SC_MARGIN_RTEXT = 5, + SCI_SETMARGINTYPEN = 2240, + SCI_GETMARGINTYPEN = 2241, + SCI_SETMARGINWIDTHN = 2242, + SCI_GETMARGINWIDTHN = 2243, + SCI_SETMARGINMASKN = 2244, + SCI_GETMARGINMASKN = 2245, + SCI_SETMARGINSENSITIVEN = 2246, + SCI_GETMARGINSENSITIVEN = 2247, + SCI_SETMARGINCURSORN = 2248, + SCI_GETMARGINCURSORN = 2249, + STYLE_DEFAULT = 32, + STYLE_LINENUMBER = 33, + STYLE_BRACELIGHT = 34, + STYLE_BRACEBAD = 35, + STYLE_CONTROLCHAR = 36, + STYLE_INDENTGUIDE = 37, + STYLE_CALLTIP = 38, + STYLE_LASTPREDEFINED = 39, + STYLE_MAX = 255, + SC_CHARSET_ANSI = 0, + SC_CHARSET_DEFAULT = 1, + SC_CHARSET_BALTIC = 186, + SC_CHARSET_CHINESEBIG5 = 136, + SC_CHARSET_EASTEUROPE = 238, + SC_CHARSET_GB2312 = 134, + SC_CHARSET_GREEK = 161, + SC_CHARSET_HANGUL = 129, + SC_CHARSET_MAC = 77, + SC_CHARSET_OEM = 255, + SC_CHARSET_RUSSIAN = 204, + SC_CHARSET_CYRILLIC = 1251, + SC_CHARSET_SHIFTJIS = 128, + SC_CHARSET_SYMBOL = 2, + SC_CHARSET_TURKISH = 162, + SC_CHARSET_JOHAB = 130, + SC_CHARSET_HEBREW = 177, + SC_CHARSET_ARABIC = 178, + SC_CHARSET_VIETNAMESE = 163, + SC_CHARSET_THAI = 222, + SC_CHARSET_8859_15 = 1000, + SCI_STYLECLEARALL = 2050, + SCI_STYLESETFORE = 2051, + SCI_STYLESETBACK = 2052, + SCI_STYLESETBOLD = 2053, + SCI_STYLESETITALIC = 2054, + SCI_STYLESETSIZE = 2055, + SCI_STYLESETFONT = 2056, + SCI_STYLESETEOLFILLED = 2057, + SCI_STYLERESETDEFAULT = 2058, + SCI_STYLESETUNDERLINE = 2059, + SC_CASE_MIXED = 0, + SC_CASE_UPPER = 1, + SC_CASE_LOWER = 2, + SCI_STYLEGETFORE = 2481, + SCI_STYLEGETBACK = 2482, + SCI_STYLEGETBOLD = 2483, + SCI_STYLEGETITALIC = 2484, + SCI_STYLEGETSIZE = 2485, + SCI_STYLEGETFONT = 2486, + SCI_STYLEGETEOLFILLED = 2487, + SCI_STYLEGETUNDERLINE = 2488, + SCI_STYLEGETCASE = 2489, + SCI_STYLEGETCHARACTERSET = 2490, + SCI_STYLEGETVISIBLE = 2491, + SCI_STYLEGETCHANGEABLE = 2492, + SCI_STYLEGETHOTSPOT = 2493, + SCI_STYLESETCASE = 2060, + SC_FONT_SIZE_MULTIPLIER = 100, + SCI_STYLESETSIZEFRACTIONAL = 2061, + SCI_STYLEGETSIZEFRACTIONAL = 2062, + SC_WEIGHT_NORMAL = 400, + SC_WEIGHT_SEMIBOLD = 600, + SC_WEIGHT_BOLD = 700, + SCI_STYLESETWEIGHT = 2063, + SCI_STYLEGETWEIGHT = 2064, + SCI_STYLESETCHARACTERSET = 2066, + SCI_STYLESETHOTSPOT = 2409, + SCI_SETSELFORE = 2067, + SCI_SETSELBACK = 2068, + SCI_GETSELALPHA = 2477, + SCI_SETSELALPHA = 2478, + SCI_GETSELEOLFILLED = 2479, + SCI_SETSELEOLFILLED = 2480, + SCI_SETCARETFORE = 2069, + SCI_ASSIGNCMDKEY = 2070, + SCI_CLEARCMDKEY = 2071, + SCI_CLEARALLCMDKEYS = 2072, + SCI_SETSTYLINGEX = 2073, + SCI_STYLESETVISIBLE = 2074, + SCI_GETCARETPERIOD = 2075, + SCI_SETCARETPERIOD = 2076, + SCI_SETWORDCHARS = 2077, + SCI_GETWORDCHARS = 2646, + SCI_BEGINUNDOACTION = 2078, + SCI_ENDUNDOACTION = 2079, + INDIC_PLAIN = 0, + INDIC_SQUIGGLE = 1, + INDIC_TT = 2, + INDIC_DIAGONAL = 3, + INDIC_STRIKE = 4, + INDIC_HIDDEN = 5, + INDIC_BOX = 6, + INDIC_ROUNDBOX = 7, + INDIC_STRAIGHTBOX = 8, + INDIC_DASH = 9, + INDIC_DOTS = 10, + INDIC_SQUIGGLELOW = 11, + INDIC_DOTBOX = 12, + INDIC_SQUIGGLEPIXMAP = 13, + INDIC_COMPOSITIONTHICK = 14, + INDIC_IME = 32, + INDIC_IME_MAX = 35, + INDIC_MAX = 35, + INDIC_CONTAINER = 8, + INDIC0_MASK = #20, + INDIC1_MASK = #40, + INDIC2_MASK = #80, + INDICS_MASK = #E0, + SCI_INDICSETSTYLE = 2080, + SCI_INDICGETSTYLE = 2081, + SCI_INDICSETFORE = 2082, + SCI_INDICGETFORE = 2083, + SCI_INDICSETUNDER = 2510, + SCI_INDICGETUNDER = 2511, + SCI_SETWHITESPACEFORE = 2084, + SCI_SETWHITESPACEBACK = 2085, + SCI_SETWHITESPACESIZE = 2086, + SCI_GETWHITESPACESIZE = 2087, + SCI_SETSTYLEBITS = 2090, + SCI_GETSTYLEBITS = 2091, + SCI_SETLINESTATE = 2092, + SCI_GETLINESTATE = 2093, + SCI_GETMAXLINESTATE = 2094, + SCI_GETCARETLINEVISIBLE = 2095, + SCI_SETCARETLINEVISIBLE = 2096, + SCI_GETCARETLINEBACK = 2097, + SCI_SETCARETLINEBACK = 2098, + SCI_STYLESETCHANGEABLE = 2099, + SCI_AUTOCSHOW = 2100, + SCI_AUTOCCANCEL = 2101, + SCI_AUTOCACTIVE = 2102, + SCI_AUTOCPOSSTART = 2103, + SCI_AUTOCCOMPLETE = 2104, + SCI_AUTOCSTOPS = 2105, + SCI_AUTOCSETSEPARATOR = 2106, + SCI_AUTOCGETSEPARATOR = 2107, + SCI_AUTOCSELECT = 2108, + SCI_AUTOCSETCANCELATSTART = 2110, + SCI_AUTOCGETCANCELATSTART = 2111, + SCI_AUTOCSETFILLUPS = 2112, + SCI_AUTOCSETCHOOSESINGLE = 2113, + SCI_AUTOCGETCHOOSESINGLE = 2114, + SCI_AUTOCSETIGNORECASE = 2115, + SCI_AUTOCGETIGNORECASE = 2116, + SCI_USERLISTSHOW = 2117, + SCI_AUTOCSETAUTOHIDE = 2118, + SCI_AUTOCGETAUTOHIDE = 2119, + SCI_AUTOCSETDROPRESTOFWORD = 2270, + SCI_AUTOCGETDROPRESTOFWORD = 2271, + SCI_REGISTERIMAGE = 2405, + SCI_CLEARREGISTEREDIMAGES = 2408, + SCI_AUTOCGETTYPESEPARATOR = 2285, + SCI_AUTOCSETTYPESEPARATOR = 2286, + SCI_AUTOCSETMAXWIDTH = 2208, + SCI_AUTOCGETMAXWIDTH = 2209, + SCI_AUTOCSETMAXHEIGHT = 2210, + SCI_AUTOCGETMAXHEIGHT = 2211, + SCI_SETINDENT = 2122, + SCI_GETINDENT = 2123, + SCI_SETUSETABS = 2124, + SCI_GETUSETABS = 2125, + SCI_SETLINEINDENTATION = 2126, + SCI_GETLINEINDENTATION = 2127, + SCI_GETLINEINDENTPOSITION = 2128, + SCI_GETCOLUMN = 2129, + SCI_COUNTCHARACTERS = 2633, + SCI_SETHSCROLLBAR = 2130, + SCI_GETHSCROLLBAR = 2131, + SC_IV_NONE = 0, + SC_IV_REAL = 1, + SC_IV_LOOKFORWARD = 2, + SC_IV_LOOKBOTH = 3, + SCI_SETINDENTATIONGUIDES = 2132, + SCI_GETINDENTATIONGUIDES = 2133, + SCI_SETHIGHLIGHTGUIDE = 2134, + SCI_GETHIGHLIGHTGUIDE = 2135, + SCI_GETLINEENDPOSITION = 2136, + SCI_GETCODEPAGE = 2137, + SCI_GETCARETFORE = 2138, + SCI_GETREADONLY = 2140, + SCI_SETCURRENTPOS = 2141, + SCI_SETSELECTIONSTART = 2142, + SCI_GETSELECTIONSTART = 2143, + SCI_SETSELECTIONEND = 2144, + SCI_GETSELECTIONEND = 2145, + SCI_SETEMPTYSELECTION = 2556, + SCI_SETPRINTMAGNIFICATION = 2146, + SCI_GETPRINTMAGNIFICATION = 2147, + SC_PRINT_NORMAL = 0, + SC_PRINT_INVERTLIGHT = 1, + SC_PRINT_BLACKONWHITE = 2, + SC_PRINT_COLOURONWHITE = 3, + SC_PRINT_COLOURONWHITEDEFAULTBG = 4, + SCI_SETPRINTCOLOURMODE = 2148, + SCI_GETPRINTCOLOURMODE = 2149, + SCFIND_WHOLEWORD = #2, + SCFIND_MATCHCASE = #4, + SCFIND_WORDSTART = #00100000, + SCFIND_REGEXP = #00200000, + SCFIND_POSIX = #00400000, + SCFIND_CXX11REGEX = #00800000, + SCI_FINDTEXT = 2150, + SCI_FORMATRANGE = 2151, + SCI_GETFIRSTVISIBLELINE = 2152, + SCI_GETLINE = 2153, + SCI_GETLINECOUNT = 2154, + SCI_SETMARGINLEFT = 2155, + SCI_GETMARGINLEFT = 2156, + SCI_SETMARGINRIGHT = 2157, + SCI_GETMARGINRIGHT = 2158, + SCI_GETMODIFY = 2159, + SCI_SETSEL = 2160, + SCI_GETSELTEXT = 2161, + SCI_GETTEXTRANGE = 2162, + SCI_HIDESELECTION = 2163, + SCI_POINTXFROMPOSITION = 2164, + SCI_POINTYFROMPOSITION = 2165, + SCI_LINEFROMPOSITION = 2166, + SCI_POSITIONFROMLINE = 2167, + SCI_LINESCROLL = 2168, + SCI_SCROLLCARET = 2169, + SCI_SCROLLRANGE = 2569, + SCI_REPLACESEL = 2170, + SCI_SETREADONLY = 2171, + SCI_NULL = 2172, + SCI_CANPASTE = 2173, + SCI_CANUNDO = 2174, + SCI_EMPTYUNDOBUFFER = 2175, + SCI_UNDO = 2176, + SCI_CUT = 2177, + SCI_COPY = 2178, + SCI_PASTE = 2179, + SCI_CLEAR = 2180, + SCI_SETTEXT = 2181, + SCI_GETTEXT = 2182, + SCI_GETTEXTLENGTH = 2183, + SCI_GETDIRECTFUNCTION = 2184, + SCI_GETDIRECTPOINTER = 2185, + SCI_SETOVERTYPE = 2186, + SCI_GETOVERTYPE = 2187, + SCI_SETCARETWIDTH = 2188, + SCI_GETCARETWIDTH = 2189, + SCI_SETTARGETSTART = 2190, + SCI_GETTARGETSTART = 2191, + SCI_SETTARGETEND = 2192, + SCI_GETTARGETEND = 2193, + SCI_REPLACETARGET = 2194, + SCI_REPLACETARGETRE = 2195, + SCI_SEARCHINTARGET = 2197, + SCI_SETSEARCHFLAGS = 2198, + SCI_GETSEARCHFLAGS = 2199, + SCI_CALLTIPSHOW = 2200, + SCI_CALLTIPCANCEL = 2201, + SCI_CALLTIPACTIVE = 2202, + SCI_CALLTIPPOSSTART = 2203, + SCI_CALLTIPSETPOSSTART = 2214, + SCI_CALLTIPSETHLT = 2204, + SCI_CALLTIPSETBACK = 2205, + SCI_CALLTIPSETFORE = 2206, + SCI_CALLTIPSETFOREHLT = 2207, + SCI_CALLTIPUSESTYLE = 2212, + SCI_CALLTIPSETPOSITION = 2213, + SCI_VISIBLEFROMDOCLINE = 2220, + SCI_DOCLINEFROMVISIBLE = 2221, + SCI_WRAPCOUNT = 2235, + SC_FOLDLEVELBASE = #400, + SC_FOLDLEVELWHITEFLAG = #1000, + SC_FOLDLEVELHEADERFLAG = #2000, + SC_FOLDLEVELNUMBERMASK = #0FFF, + SCI_SETFOLDLEVEL = 2222, + SCI_GETFOLDLEVEL = 2223, + SCI_GETLASTCHILD = 2224, + SCI_GETFOLDPARENT = 2225, + SCI_SHOWLINES = 2226, + SCI_HIDELINES = 2227, + SCI_GETLINEVISIBLE = 2228, + SCI_GETALLLINESVISIBLE = 2236, + SCI_SETFOLDEXPANDED = 2229, + SCI_GETFOLDEXPANDED = 2230, + SCI_TOGGLEFOLD = 2231, + SC_FOLDACTION_CONTRACT = 0, + SC_FOLDACTION_EXPAND = 1, + SC_FOLDACTION_TOGGLE = 2, + SCI_FOLDLINE = 2237, + SCI_FOLDCHILDREN = 2238, + SCI_EXPANDCHILDREN = 2239, + SCI_FOLDALL = 2662, + SCI_ENSUREVISIBLE = 2232, + SC_AUTOMATICFOLD_SHOW = #0001, + SC_AUTOMATICFOLD_CLICK = #0002, + SC_AUTOMATICFOLD_CHANGE = #0004, + SCI_SETAUTOMATICFOLD = 2663, + SCI_GETAUTOMATICFOLD = 2664, + SC_FOLDFLAG_LINEBEFORE_EXPANDED = #0002, + SC_FOLDFLAG_LINEBEFORE_CONTRACTED = #0004, + SC_FOLDFLAG_LINEAFTER_EXPANDED = #0008, + SC_FOLDFLAG_LINEAFTER_CONTRACTED = #0010, + SC_FOLDFLAG_LEVELNUMBERS = #0040, + SC_FOLDFLAG_LINESTATE = #0080, + SCI_SETFOLDFLAGS = 2233, + SCI_ENSUREVISIBLEENFORCEPOLICY = 2234, + SCI_SETTABINDENTS = 2260, + SCI_GETTABINDENTS = 2261, + SCI_SETBACKSPACEUNINDENTS = 2262, + SCI_GETBACKSPACEUNINDENTS = 2263, + SC_TIME_FOREVER = 10000000, + SCI_SETMOUSEDWELLTIME = 2264, + SCI_GETMOUSEDWELLTIME = 2265, + SCI_WORDSTARTPOSITION = 2266, + SCI_WORDENDPOSITION = 2267, + SC_WRAP_NONE = 0, + SC_WRAP_WORD = 1, + SC_WRAP_CHAR = 2, + SC_WRAP_WHITESPACE = 3, + SCI_SETWRAPMODE = 2268, + SCI_GETWRAPMODE = 2269, + SC_WRAPVISUALFLAG_NONE = #0000, + SC_WRAPVISUALFLAG_END = #0001, + SC_WRAPVISUALFLAG_START = #0002, + SC_WRAPVISUALFLAG_MARGIN = #0004, + SCI_SETWRAPVISUALFLAGS = 2460, + SCI_GETWRAPVISUALFLAGS = 2461, + SC_WRAPVISUALFLAGLOC_DEFAULT = #0000, + SC_WRAPVISUALFLAGLOC_END_BY_TEXT = #0001, + SC_WRAPVISUALFLAGLOC_START_BY_TEXT = #0002, + SCI_SETWRAPVISUALFLAGSLOCATION = 2462, + SCI_GETWRAPVISUALFLAGSLOCATION = 2463, + SCI_SETWRAPSTARTINDENT = 2464, + SCI_GETWRAPSTARTINDENT = 2465, + SC_WRAPINDENT_FIXED = 0, + SC_WRAPINDENT_SAME = 1, + SC_WRAPINDENT_INDENT = 2, + SCI_SETWRAPINDENTMODE = 2472, + SCI_GETWRAPINDENTMODE = 2473, + SC_CACHE_NONE = 0, + SC_CACHE_CARET = 1, + SC_CACHE_PAGE = 2, + SC_CACHE_DOCUMENT = 3, + SCI_SETLAYOUTCACHE = 2272, + SCI_GETLAYOUTCACHE = 2273, + SCI_SETSCROLLWIDTH = 2274, + SCI_GETSCROLLWIDTH = 2275, + SCI_SETSCROLLWIDTHTRACKING = 2516, + SCI_GETSCROLLWIDTHTRACKING = 2517, + SCI_TEXTWIDTH = 2276, + SCI_SETENDATLASTLINE = 2277, + SCI_GETENDATLASTLINE = 2278, + SCI_TEXTHEIGHT = 2279, + SCI_SETVSCROLLBAR = 2280, + SCI_GETVSCROLLBAR = 2281, + SCI_APPENDTEXT = 2282, + SCI_GETTWOPHASEDRAW = 2283, + SCI_SETTWOPHASEDRAW = 2284, + SC_PHASES_ONE = 0, + SC_PHASES_TWO = 1, + SC_PHASES_MULTIPLE = 2, + SCI_GETPHASESDRAW = 2673, + SCI_SETPHASESDRAW = 2674, + SC_EFF_QUALITY_MASK = #F, + SC_EFF_QUALITY_DEFAULT = 0, + SC_EFF_QUALITY_NON_ANTIALIASED = 1, + SC_EFF_QUALITY_ANTIALIASED = 2, + SC_EFF_QUALITY_LCD_OPTIMIZED = 3, + SCI_SETFONTQUALITY = 2611, + SCI_GETFONTQUALITY = 2612, + SCI_SETFIRSTVISIBLELINE = 2613, + SC_MULTIPASTE_ONCE = 0, + SC_MULTIPASTE_EACH = 1, + SCI_SETMULTIPASTE = 2614, + SCI_GETMULTIPASTE = 2615, + SCI_GETTAG = 2616, + SCI_TARGETFROMSELECTION = 2287, + SCI_LINESJOIN = 2288, + SCI_LINESSPLIT = 2289, + SCI_SETFOLDMARGINCOLOUR = 2290, + SCI_SETFOLDMARGINHICOLOUR = 2291, + SCI_LINEDOWN = 2300, + SCI_LINEDOWNEXTEND = 2301, + SCI_LINEUP = 2302, + SCI_LINEUPEXTEND = 2303, + SCI_CHARLEFT = 2304, + SCI_CHARLEFTEXTEND = 2305, + SCI_CHARRIGHT = 2306, + SCI_CHARRIGHTEXTEND = 2307, + SCI_WORDLEFT = 2308, + SCI_WORDLEFTEXTEND = 2309, + SCI_WORDRIGHT = 2310, + SCI_WORDRIGHTEXTEND = 2311, + SCI_HOME = 2312, + SCI_HOMEEXTEND = 2313, + SCI_LINEEND = 2314, + SCI_LINEENDEXTEND = 2315, + SCI_DOCUMENTSTART = 2316, + SCI_DOCUMENTSTARTEXTEND = 2317, + SCI_DOCUMENTEND = 2318, + SCI_DOCUMENTENDEXTEND = 2319, + SCI_PAGEUP = 2320, + SCI_PAGEUPEXTEND = 2321, + SCI_PAGEDOWN = 2322, + SCI_PAGEDOWNEXTEND = 2323, + SCI_EDITTOGGLEOVERTYPE = 2324, + SCI_CANCEL = 2325, + SCI_DELETEBACK = 2326, + SCI_TAB = 2327, + SCI_BACKTAB = 2328, + SCI_NEWLINE = 2329, + SCI_FORMFEED = 2330, + SCI_VCHOME = 2331, + SCI_VCHOMEEXTEND = 2332, + SCI_ZOOMIN = 2333, + SCI_ZOOMOUT = 2334, + SCI_DELWORDLEFT = 2335, + SCI_DELWORDRIGHT = 2336, + SCI_DELWORDRIGHTEND = 2518, + SCI_LINECUT = 2337, + SCI_LINEDELETE = 2338, + SCI_LINETRANSPOSE = 2339, + SCI_LINEDUPLICATE = 2404, + SCI_LOWERCASE = 2340, + SCI_UPPERCASE = 2341, + SCI_LINESCROLLDOWN = 2342, + SCI_LINESCROLLUP = 2343, + SCI_DELETEBACKNOTLINE = 2344, + SCI_HOMEDISPLAY = 2345, + SCI_HOMEDISPLAYEXTEND = 2346, + SCI_LINEENDDISPLAY = 2347, + SCI_LINEENDDISPLAYEXTEND = 2348, + SCI_HOMEWRAP = 2349, + SCI_HOMEWRAPEXTEND = 2450, + SCI_LINEENDWRAP = 2451, + SCI_LINEENDWRAPEXTEND = 2452, + SCI_VCHOMEWRAP = 2453, + SCI_VCHOMEWRAPEXTEND = 2454, + SCI_LINECOPY = 2455, + SCI_MOVECARETINSIDEVIEW = 2401, + SCI_LINELENGTH = 2350, + SCI_BRACEHIGHLIGHT = 2351, + SCI_BRACEHIGHLIGHTINDICATOR = 2498, + SCI_BRACEBADLIGHT = 2352, + SCI_BRACEBADLIGHTINDICATOR = 2499, + SCI_BRACEMATCH = 2353, + SCI_GETVIEWEOL = 2355, + SCI_SETVIEWEOL = 2356, + SCI_GETDOCPOINTER = 2357, + SCI_SETDOCPOINTER = 2358, + SCI_SETMODEVENTMASK = 2359, + EDGE_NONE = 0, + EDGE_LINE = 1, + EDGE_BACKGROUND = 2, + SCI_GETEDGECOLUMN = 2360, + SCI_SETEDGECOLUMN = 2361, + SCI_GETEDGEMODE = 2362, + SCI_SETEDGEMODE = 2363, + SCI_GETEDGECOLOUR = 2364, + SCI_SETEDGECOLOUR = 2365, + SCI_SEARCHANCHOR = 2366, + SCI_SEARCHNEXT = 2367, + SCI_SEARCHPREV = 2368, + SCI_LINESONSCREEN = 2370, + SCI_USEPOPUP = 2371, + SCI_SELECTIONISRECTANGLE = 2372, + SCI_SETZOOM = 2373, + SCI_GETZOOM = 2374, + SCI_CREATEDOCUMENT = 2375, + SCI_ADDREFDOCUMENT = 2376, + SCI_RELEASEDOCUMENT = 2377, + SCI_GETMODEVENTMASK = 2378, + SCI_SETFOCUS = 2380, + SCI_GETFOCUS = 2381, + SC_STATUS_OK = 0, + SC_STATUS_FAILURE = 1, + SC_STATUS_BADALLOC = 2, + SC_STATUS_WARN_START = 1000, + SC_STATUS_WARN_REGEX = 1001, + SCI_SETSTATUS = 2382, + SCI_GETSTATUS = 2383, + SCI_SETMOUSEDOWNCAPTURES = 2384, + SCI_GETMOUSEDOWNCAPTURES = 2385, + SC_CURSORNORMAL = -1, + SC_CURSORARROW = 2, + SC_CURSORWAIT = 4, + SC_CURSORREVERSEARROW = 7, + SCI_SETCURSOR = 2386, + SCI_GETCURSOR = 2387, + SCI_SETCONTROLCHARSYMBOL = 2388, + SCI_GETCONTROLCHARSYMBOL = 2389, + SCI_WORDPARTLEFT = 2390, + SCI_WORDPARTLEFTEXTEND = 2391, + SCI_WORDPARTRIGHT = 2392, + SCI_WORDPARTRIGHTEXTEND = 2393, + VISIBLE_SLOP = #01, + VISIBLE_STRICT = #04, + SCI_SETVISIBLEPOLICY = 2394, + SCI_DELLINELEFT = 2395, + SCI_DELLINERIGHT = 2396, + SCI_SETXOFFSET = 2397, + SCI_GETXOFFSET = 2398, + SCI_CHOOSECARETX = 2399, + SCI_GRABFOCUS = 2400, + CARET_SLOP = #01, + CARET_STRICT = #04, + CARET_JUMPS = #10, + CARET_EVEN = #08, + SCI_SETXCARETPOLICY = 2402, + SCI_SETYCARETPOLICY = 2403, + SCI_SETPRINTWRAPMODE = 2406, + SCI_GETPRINTWRAPMODE = 2407, + SCI_SETHOTSPOTACTIVEFORE = 2410, + SCI_GETHOTSPOTACTIVEFORE = 2494, + SCI_SETHOTSPOTACTIVEBACK = 2411, + SCI_GETHOTSPOTACTIVEBACK = 2495, + SCI_SETHOTSPOTACTIVEUNDERLINE = 2412, + SCI_GETHOTSPOTACTIVEUNDERLINE = 2496, + SCI_SETHOTSPOTSINGLELINE = 2421, + SCI_GETHOTSPOTSINGLELINE = 2497, + SCI_PARADOWN = 2413, + SCI_PARADOWNEXTEND = 2414, + SCI_PARAUP = 2415, + SCI_PARAUPEXTEND = 2416, + SCI_POSITIONBEFORE = 2417, + SCI_POSITIONAFTER = 2418, + SCI_POSITIONRELATIVE = 2670, + SCI_COPYRANGE = 2419, + SCI_COPYTEXT = 2420, + SC_SEL_STREAM = 0, + SC_SEL_RECTANGLE = 1, + SC_SEL_LINES = 2, + SC_SEL_THIN = 3, + SCI_SETSELECTIONMODE = 2422, + SCI_GETSELECTIONMODE = 2423, + SCI_GETLINESELSTARTPOSITION = 2424, + SCI_GETLINESELENDPOSITION = 2425, + SCI_LINEDOWNRECTEXTEND = 2426, + SCI_LINEUPRECTEXTEND = 2427, + SCI_CHARLEFTRECTEXTEND = 2428, + SCI_CHARRIGHTRECTEXTEND = 2429, + SCI_HOMERECTEXTEND = 2430, + SCI_VCHOMERECTEXTEND = 2431, + SCI_LINEENDRECTEXTEND = 2432, + SCI_PAGEUPRECTEXTEND = 2433, + SCI_PAGEDOWNRECTEXTEND = 2434, + SCI_STUTTEREDPAGEUP = 2435, + SCI_STUTTEREDPAGEUPEXTEND = 2436, + SCI_STUTTEREDPAGEDOWN = 2437, + SCI_STUTTEREDPAGEDOWNEXTEND = 2438, + SCI_WORDLEFTEND = 2439, + SCI_WORDLEFTENDEXTEND = 2440, + SCI_WORDRIGHTEND = 2441, + SCI_WORDRIGHTENDEXTEND = 2442, + SCI_SETWHITESPACECHARS = 2443, + SCI_GETWHITESPACECHARS = 2647, + SCI_SETPUNCTUATIONCHARS = 2648, + SCI_GETPUNCTUATIONCHARS = 2649, + SCI_SETCHARSDEFAULT = 2444, + SCI_AUTOCGETCURRENT = 2445, + SCI_AUTOCGETCURRENTTEXT = 2610, + SC_CASEINSENSITIVEBEHAVIOUR_RESPECTCASE = 0, + SC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE = 1, + SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR = 2634, + SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR = 2635, + SC_MULTIAUTOC_ONCE = 0, + SC_MULTIAUTOC_EACH = 1, + SCI_AUTOCSETMULTI = 2636, + SCI_AUTOCGETMULTI = 2637, + SC_ORDER_PRESORTED = 0, + SC_ORDER_PERFORMSORT = 1, + SC_ORDER_CUSTOM = 2, + SCI_AUTOCSETORDER = 2660, + SCI_AUTOCGETORDER = 2661, + SCI_ALLOCATE = 2446, + SCI_TARGETASUTF8 = 2447, + SCI_SETLENGTHFORENCODE = 2448, + SCI_ENCODEDFROMUTF8 = 2449, + SCI_FINDCOLUMN = 2456, + SCI_GETCARETSTICKY = 2457, + SCI_SETCARETSTICKY = 2458, + SC_CARETSTICKY_OFF = 0, + SC_CARETSTICKY_ON = 1, + SC_CARETSTICKY_WHITESPACE = 2, + SCI_TOGGLECARETSTICKY = 2459, + SCI_SETPASTECONVERTENDINGS = 2467, + SCI_GETPASTECONVERTENDINGS = 2468, + SCI_SELECTIONDUPLICATE = 2469, + SC_ALPHA_TRANSPARENT = 0, + SC_ALPHA_OPAQUE = 255, + SC_ALPHA_NOALPHA = 256, + SCI_SETCARETLINEBACKALPHA = 2470, + SCI_GETCARETLINEBACKALPHA = 2471, + CARETSTYLE_INVISIBLE = 0, + CARETSTYLE_LINE = 1, + CARETSTYLE_BLOCK = 2, + SCI_SETCARETSTYLE = 2512, + SCI_GETCARETSTYLE = 2513, + SCI_SETINDICATORCURRENT = 2500, + SCI_GETINDICATORCURRENT = 2501, + SCI_SETINDICATORVALUE = 2502, + SCI_GETINDICATORVALUE = 2503, + SCI_INDICATORFILLRANGE = 2504, + SCI_INDICATORCLEARRANGE = 2505, + SCI_INDICATORALLONFOR = 2506, + SCI_INDICATORVALUEAT = 2507, + SCI_INDICATORSTART = 2508, + SCI_INDICATOREND = 2509, + SCI_SETPOSITIONCACHE = 2514, + SCI_GETPOSITIONCACHE = 2515, + SCI_COPYALLOWLINE = 2519, + SCI_GETCHARACTERPOINTER = 2520, + SCI_GETRANGEPOINTER = 2643, + SCI_GETGAPPOSITION = 2644, + SCI_SETKEYSUNICODE = 2521, + SCI_GETKEYSUNICODE = 2522, + SCI_INDICSETALPHA = 2523, + SCI_INDICGETALPHA = 2524, + SCI_INDICSETOUTLINEALPHA = 2558, + SCI_INDICGETOUTLINEALPHA = 2559, + SCI_SETEXTRAASCENT = 2525, + SCI_GETEXTRAASCENT = 2526, + SCI_SETEXTRADESCENT = 2527, + SCI_GETEXTRADESCENT = 2528, + SCI_MARKERSYMBOLDEFINED = 2529, + SCI_MARGINSETTEXT = 2530, + SCI_MARGINGETTEXT = 2531, + SCI_MARGINSETSTYLE = 2532, + SCI_MARGINGETSTYLE = 2533, + SCI_MARGINSETSTYLES = 2534, + SCI_MARGINGETSTYLES = 2535, + SCI_MARGINTEXTCLEARALL = 2536, + SCI_MARGINSETSTYLEOFFSET = 2537, + SCI_MARGINGETSTYLEOFFSET = 2538, + SC_MARGINOPTION_NONE = 0, + SC_MARGINOPTION_SUBLINESELECT = 1, + SCI_SETMARGINOPTIONS = 2539, + SCI_GETMARGINOPTIONS = 2557, + SCI_ANNOTATIONSETTEXT = 2540, + SCI_ANNOTATIONGETTEXT = 2541, + SCI_ANNOTATIONSETSTYLE = 2542, + SCI_ANNOTATIONGETSTYLE = 2543, + SCI_ANNOTATIONSETSTYLES = 2544, + SCI_ANNOTATIONGETSTYLES = 2545, + SCI_ANNOTATIONGETLINES = 2546, + SCI_ANNOTATIONCLEARALL = 2547, + ANNOTATION_HIDDEN = 0, + ANNOTATION_STANDARD = 1, + ANNOTATION_BOXED = 2, + ANNOTATION_INDENTED = 3, + SCI_ANNOTATIONSETVISIBLE = 2548, + SCI_ANNOTATIONGETVISIBLE = 2549, + SCI_ANNOTATIONSETSTYLEOFFSET = 2550, + SCI_ANNOTATIONGETSTYLEOFFSET = 2551, + SCI_RELEASEALLEXTENDEDSTYLES = 2552, + SCI_ALLOCATEEXTENDEDSTYLES = 2553, + UNDO_MAY_COALESCE = 1, + SCI_ADDUNDOACTION = 2560, + SCI_CHARPOSITIONFROMPOINT = 2561, + SCI_CHARPOSITIONFROMPOINTCLOSE = 2562, + SCI_SETMOUSESELECTIONRECTANGULARSWITCH = 2668, + SCI_GETMOUSESELECTIONRECTANGULARSWITCH = 2669, + SCI_SETMULTIPLESELECTION = 2563, + SCI_GETMULTIPLESELECTION = 2564, + SCI_SETADDITIONALSELECTIONTYPING = 2565, + SCI_GETADDITIONALSELECTIONTYPING = 2566, + SCI_SETADDITIONALCARETSBLINK = 2567, + SCI_GETADDITIONALCARETSBLINK = 2568, + SCI_SETADDITIONALCARETSVISIBLE = 2608, + SCI_GETADDITIONALCARETSVISIBLE = 2609, + SCI_GETSELECTIONS = 2570, + SCI_GETSELECTIONEMPTY = 2650, + SCI_CLEARSELECTIONS = 2571, + SCI_SETSELECTION = 2572, + SCI_ADDSELECTION = 2573, + SCI_DROPSELECTIONN = 2671, + SCI_SETMAINSELECTION = 2574, + SCI_GETMAINSELECTION = 2575, + SCI_SETSELECTIONNCARET = 2576, + SCI_GETSELECTIONNCARET = 2577, + SCI_SETSELECTIONNANCHOR = 2578, + SCI_GETSELECTIONNANCHOR = 2579, + SCI_SETSELECTIONNCARETVIRTUALSPACE = 2580, + SCI_GETSELECTIONNCARETVIRTUALSPACE = 2581, + SCI_SETSELECTIONNANCHORVIRTUALSPACE = 2582, + SCI_GETSELECTIONNANCHORVIRTUALSPACE = 2583, + SCI_SETSELECTIONNSTART = 2584, + SCI_GETSELECTIONNSTART = 2585, + SCI_SETSELECTIONNEND = 2586, + SCI_GETSELECTIONNEND = 2587, + SCI_SETRECTANGULARSELECTIONCARET = 2588, + SCI_GETRECTANGULARSELECTIONCARET = 2589, + SCI_SETRECTANGULARSELECTIONANCHOR = 2590, + SCI_GETRECTANGULARSELECTIONANCHOR = 2591, + SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE = 2592, + SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE = 2593, + SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE = 2594, + SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE = 2595, + SCVS_NONE = 0, + SCVS_RECTANGULARSELECTION = 1, + SCVS_USERACCESSIBLE = 2, + SCI_SETVIRTUALSPACEOPTIONS = 2596, + SCI_GETVIRTUALSPACEOPTIONS = 2597, + SCI_SETRECTANGULARSELECTIONMODIFIER = 2598, + SCI_GETRECTANGULARSELECTIONMODIFIER = 2599, + SCI_SETADDITIONALSELFORE = 2600, + SCI_SETADDITIONALSELBACK = 2601, + SCI_SETADDITIONALSELALPHA = 2602, + SCI_GETADDITIONALSELALPHA = 2603, + SCI_SETADDITIONALCARETFORE = 2604, + SCI_GETADDITIONALCARETFORE = 2605, + SCI_ROTATESELECTION = 2606, + SCI_SWAPMAINANCHORCARET = 2607, + SCI_CHANGELEXERSTATE = 2617, + SCI_CONTRACTEDFOLDNEXT = 2618, + SCI_VERTICALCENTRECARET = 2619, + SCI_MOVESELECTEDLINESUP = 2620, + SCI_MOVESELECTEDLINESDOWN = 2621, + SCI_SETIDENTIFIER = 2622, + SCI_GETIDENTIFIER = 2623, + SCI_RGBAIMAGESETWIDTH = 2624, + SCI_RGBAIMAGESETHEIGHT = 2625, + SCI_RGBAIMAGESETSCALE = 2651, + SCI_MARKERDEFINERGBAIMAGE = 2626, + SCI_REGISTERRGBAIMAGE = 2627, + SCI_SCROLLTOSTART = 2628, + SCI_SCROLLTOEND = 2629, + SC_TECHNOLOGY_DEFAULT = 0, + SC_TECHNOLOGY_DIRECTWRITE = 1, + SC_TECHNOLOGY_DIRECTWRITERETAIN = 2, + SC_TECHNOLOGY_DIRECTWRITEDC = 3, + SCI_SETTECHNOLOGY = 2630, + SCI_GETTECHNOLOGY = 2631, + SCI_CREATELOADER = 2632, + SCI_FINDINDICATORSHOW = 2640, + SCI_FINDINDICATORFLASH = 2641, + SCI_FINDINDICATORHIDE = 2642, + SCI_VCHOMEDISPLAY = 2652, + SCI_VCHOMEDISPLAYEXTEND = 2653, + SCI_GETCARETLINEVISIBLEALWAYS = 2654, + SCI_SETCARETLINEVISIBLEALWAYS = 2655, + SC_LINE_END_TYPE_DEFAULT = 0, + SC_LINE_END_TYPE_UNICODE = 1, + SCI_SETLINEENDTYPESALLOWED = 2656, + SCI_GETLINEENDTYPESALLOWED = 2657, + SCI_GETLINEENDTYPESACTIVE = 2658, + SCI_SETREPRESENTATION = 2665, + SCI_GETREPRESENTATION = 2666, + SCI_CLEARREPRESENTATION = 2667, + SCI_STARTRECORD = 3001, + SCI_STOPRECORD = 3002, + SCI_SETLEXER = 4001, + SCI_GETLEXER = 4002, + SCI_COLOURISE = 4003, + SCI_SETPROPERTY = 4004, + KEYWORDSET_MAX = 8, + SCI_SETKEYWORDS = 4005, + SCI_SETLEXERLANGUAGE = 4006, + SCI_LOADLEXERLIBRARY = 4007, + SCI_GETPROPERTY = 4008, + SCI_GETPROPERTYEXPANDED = 4009, + SCI_GETPROPERTYINT = 4010, + SCI_GETSTYLEBITSNEEDED = 4011, + SCI_GETLEXERLANGUAGE = 4012, + SCI_PRIVATELEXERCALL = 4013, + SCI_PROPERTYNAMES = 4014, + SC_TYPE_BOOLEAN = 0, + SC_TYPE_INTEGER = 1, + SC_TYPE_STRING = 2, + SCI_PROPERTYTYPE = 4015, + SCI_DESCRIBEPROPERTY = 4016, + SCI_DESCRIBEKEYWORDSETS = 4017, + SCI_GETLINEENDTYPESSUPPORTED = 4018, + SCI_ALLOCATESUBSTYLES = 4020, + SCI_GETSUBSTYLESSTART = 4021, + SCI_GETSUBSTYLESLENGTH = 4022, + SCI_GETSTYLEFROMSUBSTYLE = 4027, + SCI_GETPRIMARYSTYLEFROMSTYLE = 4028, + SCI_FREESUBSTYLES = 4023, + SCI_SETIDENTIFIERS = 4024, + SCI_DISTANCETOSECONDARYSTYLES = 4025, + SCI_GETSUBSTYLEBASES = 4026, + SC_MOD_INSERTTEXT = #1, + SC_MOD_DELETETEXT = #2, + SC_MOD_CHANGESTYLE = #4, + SC_MOD_CHANGEFOLD = #8, + SC_PERFORMED_USER = #10, + SC_PERFORMED_UNDO = #20, + SC_PERFORMED_REDO = #40, + SC_MULTISTEPUNDOREDO = #80, + SC_LASTSTEPINUNDOREDO = #100, + SC_MOD_CHANGEMARKER = #200, + SC_MOD_BEFOREINSERT = #400, + SC_MOD_BEFOREDELETE = #800, + SC_MULTILINEUNDOREDO = #1000, + SC_STARTACTION = #2000, + SC_MOD_CHANGEINDICATOR = #4000, + SC_MOD_CHANGELINESTATE = #8000, + SC_MOD_CHANGEMARGIN = #10000, + SC_MOD_CHANGEANNOTATION = #20000, + SC_MOD_CONTAINER = #40000, + SC_MOD_LEXERSTATE = #80000, + SC_MOD_INSERTCHECK = #100000, + SC_MOD_CHANGETABSTOPS = #200000, + SC_MODEVENTMASKALL = #3FFFFF, + SC_UPDATE_CONTENT = #1, + SC_UPDATE_SELECTION = #2, + SC_UPDATE_V_SCROLL = #4, + SC_UPDATE_H_SCROLL = #8, + SCEN_CHANGE = 768, + SCEN_SETFOCUS = 512, + SCEN_KILLFOCUS = 256, + SCK_DOWN = 300, + SCK_UP = 301, + SCK_LEFT = 302, + SCK_RIGHT = 303, + SCK_HOME = 304, + SCK_END = 305, + SCK_PRIOR = 306, + SCK_NEXT = 307, + SCK_DELETE = 308, + SCK_INSERT = 309, + SCK_ESCAPE = 7, + SCK_BACK = 8, + SCK_TAB = 9, + SCK_RETURN = 13, + SCK_ADD = 310, + SCK_SUBTRACT = 311, + SCK_DIVIDE = 312, + SCK_WIN = 313, + SCK_RWIN = 314, + SCK_MENU = 315, + SCMOD_NORM = 0, + SCMOD_SHIFT = 1, + SCMOD_CTRL = 2, + SCMOD_ALT = 4, + SCMOD_SUPER = 8, + SCMOD_META = 16, + SCN_STYLENEEDED = 2000, + SCN_CHARADDED = 2001, + SCN_SAVEPOINTREACHED = 2002, + SCN_SAVEPOINTLEFT = 2003, + SCN_MODIFYATTEMPTRO = 2004, + SCN_KEY = 2005, + SCN_DOUBLECLICK = 2006, + SCN_UPDATEUI = 2007, + SCN_MODIFIED = 2008, + SCN_MACRORECORD = 2009, + SCN_MARGINCLICK = 2010, + SCN_NEEDSHOWN = 2011, + SCN_PAINTED = 2013, + SCN_USERLISTSELECTION = 2014, + SCN_URIDROPPED = 2015, + SCN_DWELLSTART = 2016, + SCN_DWELLEND = 2017, + SCN_ZOOM = 2018, + SCN_HOTSPOTCLICK = 2019, + SCN_HOTSPOTDOUBLECLICK = 2020, + SCN_CALLTIPCLICK = 2021, + SCN_AUTOCSELECTION = 2022, + SCN_INDICATORCLICK = 2023, + SCN_INDICATORRELEASE = 2024, + SCN_AUTOCCANCELLED = 2025, + SCN_AUTOCCHARDELETED = 2026, + SCN_HOTSPOTRELEASECLICK = 2027, + SCN_FOCUSIN = 2028, + SCN_FOCUSOUT = 2029, + SC_CP_DBCS = 1, + SCI_SETUSEPALETTE = 2039, + SCI_GETUSEPALETTE = 2139 + +-- SciLexer.h +global constant + SCLEX_CONTAINER = 0, + SCLEX_NULL = 1, + SCLEX_PYTHON = 2, + SCLEX_CPP = 3, + SCLEX_HTML = 4, + SCLEX_XML = 5, + SCLEX_PERL = 6, + SCLEX_SQL = 7, + SCLEX_VB = 8, + SCLEX_PROPERTIES = 9, + SCLEX_ERRORLIST = 10, + SCLEX_MAKEFILE = 11, + SCLEX_BATCH = 12, + SCLEX_XCODE = 13, + SCLEX_LATEX = 14, + SCLEX_LUA = 15, + SCLEX_DIFF = 16, + SCLEX_CONF = 17, + SCLEX_PASCAL = 18, + SCLEX_AVE = 19, + SCLEX_ADA = 20, + SCLEX_LISP = 21, + SCLEX_RUBY = 22, + SCLEX_EIFFEL = 23, + SCLEX_EIFFELKW = 24, + SCLEX_TCL = 25, + SCLEX_NNCRONTAB = 26, + SCLEX_BULLANT = 27, + SCLEX_VBSCRIPT = 28, + SCLEX_BAAN = 31, + SCLEX_MATLAB = 32, + SCLEX_SCRIPTOL = 33, + SCLEX_ASM = 34, + SCLEX_CPPNOCASE = 35, + SCLEX_FORTRAN = 36, + SCLEX_F77 = 37, + SCLEX_CSS = 38, + SCLEX_POV = 39, + SCLEX_LOUT = 40, + SCLEX_ESCRIPT = 41, + SCLEX_PS = 42, + SCLEX_NSIS = 43, + SCLEX_MMIXAL = 44, + SCLEX_CLW = 45, + SCLEX_CLWNOCASE = 46, + SCLEX_LOT = 47, + SCLEX_YAML = 48, + SCLEX_TEX = 49, + SCLEX_METAPOST = 50, + SCLEX_POWERBASIC = 51, + SCLEX_FORTH = 52, + SCLEX_ERLANG = 53, + SCLEX_OCTAVE = 54, + SCLEX_MSSQL = 55, + SCLEX_VERILOG = 56, + SCLEX_KIX = 57, + SCLEX_GUI4CLI = 58, + SCLEX_SPECMAN = 59, + SCLEX_AU3 = 60, + SCLEX_APDL = 61, + SCLEX_BASH = 62, + SCLEX_ASN1 = 63, + SCLEX_VHDL = 64, + SCLEX_CAML = 65, + SCLEX_BLITZBASIC = 66, + SCLEX_PUREBASIC = 67, + SCLEX_HASKELL = 68, + SCLEX_PHPSCRIPT = 69, + SCLEX_TADS3 = 70, + SCLEX_REBOL = 71, + SCLEX_SMALLTALK = 72, + SCLEX_FLAGSHIP = 73, + SCLEX_CSOUND = 74, + SCLEX_FREEBASIC = 75, + SCLEX_INNOSETUP = 76, + SCLEX_OPAL = 77, + SCLEX_SPICE = 78, + SCLEX_D = 79, + SCLEX_CMAKE = 80, + SCLEX_GAP = 81, + SCLEX_PLM = 82, + SCLEX_PROGRESS = 83, + SCLEX_ABAQUS = 84, + SCLEX_ASYMPTOTE = 85, + SCLEX_R = 86, + SCLEX_MAGIK = 87, + SCLEX_POWERSHELL = 88, + SCLEX_MYSQL = 89, + SCLEX_PO = 90, + SCLEX_TAL = 91, + SCLEX_COBOL = 92, + SCLEX_TACL = 93, + SCLEX_SORCUS = 94, + SCLEX_POWERPRO = 95, + SCLEX_NIMROD = 96, + SCLEX_SML = 97, + SCLEX_MARKDOWN = 98, + SCLEX_TXT2TAGS = 99, + SCLEX_A68K = 100, + SCLEX_MODULA = 101, + SCLEX_COFFEESCRIPT = 102, + SCLEX_TCMD = 103, + SCLEX_AVS = 104, + SCLEX_ECL = 105, + SCLEX_OSCRIPT = 106, + SCLEX_VISUALPROLOG = 107, + SCLEX_LITERATEHASKELL = 108, + SCLEX_STTXT = 109, + SCLEX_KVIRC = 110, + SCLEX_RUST = 111, + SCLEX_DMAP = 112, + SCLEX_AS = 113, + SCLEX_DMIS = 114, + SCLEX_REGISTRY = 115, + SCLEX_BIBTEX = 116, + SCLEX_AUTOMATIC = 1000, + SCE_P_DEFAULT = 0, + SCE_P_COMMENTLINE = 1, + SCE_P_NUMBER = 2, + SCE_P_STRING = 3, + SCE_P_CHARACTER = 4, + SCE_P_WORD = 5, + SCE_P_TRIPLE = 6, + SCE_P_TRIPLEDOUBLE = 7, + SCE_P_CLASSNAME = 8, + SCE_P_DEFNAME = 9, + SCE_P_OPERATOR = 10, + SCE_P_IDENTIFIER = 11, + SCE_P_COMMENTBLOCK = 12, + SCE_P_STRINGEOL = 13, + SCE_P_WORD2 = 14, + SCE_P_DECORATOR = 15, + SCE_C_DEFAULT = 0, + SCE_C_COMMENT = 1, + SCE_C_COMMENTLINE = 2, + SCE_C_COMMENTDOC = 3, + SCE_C_NUMBER = 4, + SCE_C_WORD = 5, + SCE_C_STRING = 6, + SCE_C_CHARACTER = 7, + SCE_C_UUID = 8, + SCE_C_PREPROCESSOR = 9, + SCE_C_OPERATOR = 10, + SCE_C_IDENTIFIER = 11, + SCE_C_STRINGEOL = 12, + SCE_C_VERBATIM = 13, + SCE_C_REGEX = 14, + SCE_C_COMMENTLINEDOC = 15, + SCE_C_WORD2 = 16, + SCE_C_COMMENTDOCKEYWORD = 17, + SCE_C_COMMENTDOCKEYWORDERROR = 18, + SCE_C_GLOBALCLASS = 19, + SCE_C_STRINGRAW = 20, + SCE_C_TRIPLEVERBATIM = 21, + SCE_C_HASHQUOTEDSTRING = 22, + SCE_C_PREPROCESSORCOMMENT = 23, + SCE_C_PREPROCESSORCOMMENTDOC = 24, + SCE_C_USERLITERAL = 25, + SCE_C_TASKMARKER = 26, + SCE_C_ESCAPESEQUENCE = 27, + SCE_D_DEFAULT = 0, + SCE_D_COMMENT = 1, + SCE_D_COMMENTLINE = 2, + SCE_D_COMMENTDOC = 3, + SCE_D_COMMENTNESTED = 4, + SCE_D_NUMBER = 5, + SCE_D_WORD = 6, + SCE_D_WORD2 = 7, + SCE_D_WORD3 = 8, + SCE_D_TYPEDEF = 9, + SCE_D_STRING = 10, + SCE_D_STRINGEOL = 11, + SCE_D_CHARACTER = 12, + SCE_D_OPERATOR = 13, + SCE_D_IDENTIFIER = 14, + SCE_D_COMMENTLINEDOC = 15, + SCE_D_COMMENTDOCKEYWORD = 16, + SCE_D_COMMENTDOCKEYWORDERROR = 17, + SCE_D_STRINGB = 18, + SCE_D_STRINGR = 19, + SCE_D_WORD5 = 20, + SCE_D_WORD6 = 21, + SCE_D_WORD7 = 22, + SCE_TCL_DEFAULT = 0, + SCE_TCL_COMMENT = 1, + SCE_TCL_COMMENTLINE = 2, + SCE_TCL_NUMBER = 3, + SCE_TCL_WORD_IN_QUOTE = 4, + SCE_TCL_IN_QUOTE = 5, + SCE_TCL_OPERATOR = 6, + SCE_TCL_IDENTIFIER = 7, + SCE_TCL_SUBSTITUTION = 8, + SCE_TCL_SUB_BRACE = 9, + SCE_TCL_MODIFIER = 10, + SCE_TCL_EXPAND = 11, + SCE_TCL_WORD = 12, + SCE_TCL_WORD2 = 13, + SCE_TCL_WORD3 = 14, + SCE_TCL_WORD4 = 15, + SCE_TCL_WORD5 = 16, + SCE_TCL_WORD6 = 17, + SCE_TCL_WORD7 = 18, + SCE_TCL_WORD8 = 19, + SCE_TCL_COMMENT_BOX = 20, + SCE_TCL_BLOCK_COMMENT = 21, + SCE_H_DEFAULT = 0, + SCE_H_TAG = 1, + SCE_H_TAGUNKNOWN = 2, + SCE_H_ATTRIBUTE = 3, + SCE_H_ATTRIBUTEUNKNOWN = 4, + SCE_H_NUMBER = 5, + SCE_H_DOUBLESTRING = 6, + SCE_H_SINGLESTRING = 7, + SCE_H_OTHER = 8, + SCE_H_COMMENT = 9, + SCE_H_ENTITY = 10, + SCE_H_TAGEND = 11, + SCE_H_XMLSTART = 12, + SCE_H_XMLEND = 13, + SCE_H_SCRIPT = 14, + SCE_H_ASP = 15, + SCE_H_ASPAT = 16, + SCE_H_CDATA = 17, + SCE_H_QUESTION = 18, + SCE_H_VALUE = 19, + SCE_H_XCCOMMENT = 20, + SCE_H_SGML_DEFAULT = 21, + SCE_H_SGML_COMMAND = 22, + SCE_H_SGML_1ST_PARAM = 23, + SCE_H_SGML_DOUBLESTRING = 24, + SCE_H_SGML_SIMPLESTRING = 25, + SCE_H_SGML_ERROR = 26, + SCE_H_SGML_SPECIAL = 27, + SCE_H_SGML_ENTITY = 28, + SCE_H_SGML_COMMENT = 29, + SCE_H_SGML_1ST_PARAM_COMMENT = 30, + SCE_H_SGML_BLOCK_DEFAULT = 31, + SCE_HJ_START = 40, + SCE_HJ_DEFAULT = 41, + SCE_HJ_COMMENT = 42, + SCE_HJ_COMMENTLINE = 43, + SCE_HJ_COMMENTDOC = 44, + SCE_HJ_NUMBER = 45, + SCE_HJ_WORD = 46, + SCE_HJ_KEYWORD = 47, + SCE_HJ_DOUBLESTRING = 48, + SCE_HJ_SINGLESTRING = 49, + SCE_HJ_SYMBOLS = 50, + SCE_HJ_STRINGEOL = 51, + SCE_HJ_REGEX = 52, + SCE_HJA_START = 55, + SCE_HJA_DEFAULT = 56, + SCE_HJA_COMMENT = 57, + SCE_HJA_COMMENTLINE = 58, + SCE_HJA_COMMENTDOC = 59, + SCE_HJA_NUMBER = 60, + SCE_HJA_WORD = 61, + SCE_HJA_KEYWORD = 62, + SCE_HJA_DOUBLESTRING = 63, + SCE_HJA_SINGLESTRING = 64, + SCE_HJA_SYMBOLS = 65, + SCE_HJA_STRINGEOL = 66, + SCE_HJA_REGEX = 67, + SCE_HB_START = 70, + SCE_HB_DEFAULT = 71, + SCE_HB_COMMENTLINE = 72, + SCE_HB_NUMBER = 73, + SCE_HB_WORD = 74, + SCE_HB_STRING = 75, + SCE_HB_IDENTIFIER = 76, + SCE_HB_STRINGEOL = 77, + SCE_HBA_START = 80, + SCE_HBA_DEFAULT = 81, + SCE_HBA_COMMENTLINE = 82, + SCE_HBA_NUMBER = 83, + SCE_HBA_WORD = 84, + SCE_HBA_STRING = 85, + SCE_HBA_IDENTIFIER = 86, + SCE_HBA_STRINGEOL = 87, + SCE_HP_START = 90, + SCE_HP_DEFAULT = 91, + SCE_HP_COMMENTLINE = 92, + SCE_HP_NUMBER = 93, + SCE_HP_STRING = 94, + SCE_HP_CHARACTER = 95, + SCE_HP_WORD = 96, + SCE_HP_TRIPLE = 97, + SCE_HP_TRIPLEDOUBLE = 98, + SCE_HP_CLASSNAME = 99, + SCE_HP_DEFNAME = 100, + SCE_HP_OPERATOR = 101, + SCE_HP_IDENTIFIER = 102, + SCE_HPHP_COMPLEX_VARIABLE = 104, + SCE_HPA_START = 105, + SCE_HPA_DEFAULT = 106, + SCE_HPA_COMMENTLINE = 107, + SCE_HPA_NUMBER = 108, + SCE_HPA_STRING = 109, + SCE_HPA_CHARACTER = 110, + SCE_HPA_WORD = 111, + SCE_HPA_TRIPLE = 112, + SCE_HPA_TRIPLEDOUBLE = 113, + SCE_HPA_CLASSNAME = 114, + SCE_HPA_DEFNAME = 115, + SCE_HPA_OPERATOR = 116, + SCE_HPA_IDENTIFIER = 117, + SCE_HPHP_DEFAULT = 118, + SCE_HPHP_HSTRING = 119, + SCE_HPHP_SIMPLESTRING = 120, + SCE_HPHP_WORD = 121, + SCE_HPHP_NUMBER = 122, + SCE_HPHP_VARIABLE = 123, + SCE_HPHP_COMMENT = 124, + SCE_HPHP_COMMENTLINE = 125, + SCE_HPHP_HSTRING_VARIABLE = 126, + SCE_HPHP_OPERATOR = 127, + SCE_PL_DEFAULT = 0, + SCE_PL_ERROR = 1, + SCE_PL_COMMENTLINE = 2, + SCE_PL_POD = 3, + SCE_PL_NUMBER = 4, + SCE_PL_WORD = 5, + SCE_PL_STRING = 6, + SCE_PL_CHARACTER = 7, + SCE_PL_PUNCTUATION = 8, + SCE_PL_PREPROCESSOR = 9, + SCE_PL_OPERATOR = 10, + SCE_PL_IDENTIFIER = 11, + SCE_PL_SCALAR = 12, + SCE_PL_ARRAY = 13, + SCE_PL_HASH = 14, + SCE_PL_SYMBOLTABLE = 15, + SCE_PL_VARIABLE_INDEXER = 16, + SCE_PL_REGEX = 17, + SCE_PL_REGSUBST = 18, + SCE_PL_LONGQUOTE = 19, + SCE_PL_BACKTICKS = 20, + SCE_PL_DATASECTION = 21, + SCE_PL_HERE_DELIM = 22, + SCE_PL_HERE_Q = 23, + SCE_PL_HERE_QQ = 24, + SCE_PL_HERE_QX = 25, + SCE_PL_STRING_Q = 26, + SCE_PL_STRING_QQ = 27, + SCE_PL_STRING_QX = 28, + SCE_PL_STRING_QR = 29, + SCE_PL_STRING_QW = 30, + SCE_PL_POD_VERB = 31, + SCE_PL_SUB_PROTOTYPE = 40, + SCE_PL_FORMAT_IDENT = 41, + SCE_PL_FORMAT = 42, + SCE_PL_STRING_VAR = 43, + SCE_PL_XLAT = 44, + SCE_PL_REGEX_VAR = 54, + SCE_PL_REGSUBST_VAR = 55, + SCE_PL_BACKTICKS_VAR = 57, + SCE_PL_HERE_QQ_VAR = 61, + SCE_PL_HERE_QX_VAR = 62, + SCE_PL_STRING_QQ_VAR = 64, + SCE_PL_STRING_QX_VAR = 65, + SCE_PL_STRING_QR_VAR = 66, + SCE_RB_DEFAULT = 0, + SCE_RB_ERROR = 1, + SCE_RB_COMMENTLINE = 2, + SCE_RB_POD = 3, + SCE_RB_NUMBER = 4, + SCE_RB_WORD = 5, + SCE_RB_STRING = 6, + SCE_RB_CHARACTER = 7, + SCE_RB_CLASSNAME = 8, + SCE_RB_DEFNAME = 9, + SCE_RB_OPERATOR = 10, + SCE_RB_IDENTIFIER = 11, + SCE_RB_REGEX = 12, + SCE_RB_GLOBAL = 13, + SCE_RB_SYMBOL = 14, + SCE_RB_MODULE_NAME = 15, + SCE_RB_INSTANCE_VAR = 16, + SCE_RB_CLASS_VAR = 17, + SCE_RB_BACKTICKS = 18, + SCE_RB_DATASECTION = 19, + SCE_RB_HERE_DELIM = 20, + SCE_RB_HERE_Q = 21, + SCE_RB_HERE_QQ = 22, + SCE_RB_HERE_QX = 23, + SCE_RB_STRING_Q = 24, + SCE_RB_STRING_QQ = 25, + SCE_RB_STRING_QX = 26, + SCE_RB_STRING_QR = 27, + SCE_RB_STRING_QW = 28, + SCE_RB_WORD_DEMOTED = 29, + SCE_RB_STDIN = 30, + SCE_RB_STDOUT = 31, + SCE_RB_STDERR = 40, + SCE_RB_UPPER_BOUND = 41, + SCE_B_DEFAULT = 0, + SCE_B_COMMENT = 1, + SCE_B_NUMBER = 2, + SCE_B_KEYWORD = 3, + SCE_B_STRING = 4, + SCE_B_PREPROCESSOR = 5, + SCE_B_OPERATOR = 6, + SCE_B_IDENTIFIER = 7, + SCE_B_DATE = 8, + SCE_B_STRINGEOL = 9, + SCE_B_KEYWORD2 = 10, + SCE_B_KEYWORD3 = 11, + SCE_B_KEYWORD4 = 12, + SCE_B_CONSTANT = 13, + SCE_B_ASM = 14, + SCE_B_LABEL = 15, + SCE_B_ERROR = 16, + SCE_B_HEXNUMBER = 17, + SCE_B_BINNUMBER = 18, + SCE_B_COMMENTBLOCK = 19, + SCE_B_DOCLINE = 20, + SCE_B_DOCBLOCK = 21, + SCE_B_DOCKEYWORD = 22, + SCE_PROPS_DEFAULT = 0, + SCE_PROPS_COMMENT = 1, + SCE_PROPS_SECTION = 2, + SCE_PROPS_ASSIGNMENT = 3, + SCE_PROPS_DEFVAL = 4, + SCE_PROPS_KEY = 5, + SCE_L_DEFAULT = 0, + SCE_L_COMMAND = 1, + SCE_L_TAG = 2, + SCE_L_MATH = 3, + SCE_L_COMMENT = 4, + SCE_L_TAG2 = 5, + SCE_L_MATH2 = 6, + SCE_L_COMMENT2 = 7, + SCE_L_VERBATIM = 8, + SCE_L_SHORTCMD = 9, + SCE_L_SPECIAL = 10, + SCE_L_CMDOPT = 11, + SCE_L_ERROR = 12, + SCE_LUA_DEFAULT = 0, + SCE_LUA_COMMENT = 1, + SCE_LUA_COMMENTLINE = 2, + SCE_LUA_COMMENTDOC = 3, + SCE_LUA_NUMBER = 4, + SCE_LUA_WORD = 5, + SCE_LUA_STRING = 6, + SCE_LUA_CHARACTER = 7, + SCE_LUA_LITERALSTRING = 8, + SCE_LUA_PREPROCESSOR = 9, + SCE_LUA_OPERATOR = 10, + SCE_LUA_IDENTIFIER = 11, + SCE_LUA_STRINGEOL = 12, + SCE_LUA_WORD2 = 13, + SCE_LUA_WORD3 = 14, + SCE_LUA_WORD4 = 15, + SCE_LUA_WORD5 = 16, + SCE_LUA_WORD6 = 17, + SCE_LUA_WORD7 = 18, + SCE_LUA_WORD8 = 19, + SCE_LUA_LABEL = 20, + SCE_ERR_DEFAULT = 0, + SCE_ERR_PYTHON = 1, + SCE_ERR_GCC = 2, + SCE_ERR_MS = 3, + SCE_ERR_CMD = 4, + SCE_ERR_BORLAND = 5, + SCE_ERR_PERL = 6, + SCE_ERR_NET = 7, + SCE_ERR_LUA = 8, + SCE_ERR_CTAG = 9, + SCE_ERR_DIFF_CHANGED = 10, + SCE_ERR_DIFF_ADDITION = 11, + SCE_ERR_DIFF_DELETION = 12, + SCE_ERR_DIFF_MESSAGE = 13, + SCE_ERR_PHP = 14, + SCE_ERR_ELF = 15, + SCE_ERR_IFC = 16, + SCE_ERR_IFORT = 17, + SCE_ERR_ABSF = 18, + SCE_ERR_TIDY = 19, + SCE_ERR_JAVA_STACK = 20, + SCE_ERR_VALUE = 21, + SCE_ERR_GCC_INCLUDED_FROM = 22, + SCE_BAT_DEFAULT = 0, + SCE_BAT_COMMENT = 1, + SCE_BAT_WORD = 2, + SCE_BAT_LABEL = 3, + SCE_BAT_HIDE = 4, + SCE_BAT_COMMAND = 5, + SCE_BAT_IDENTIFIER = 6, + SCE_BAT_OPERATOR = 7, + SCE_TCMD_DEFAULT = 0, + SCE_TCMD_COMMENT = 1, + SCE_TCMD_WORD = 2, + SCE_TCMD_LABEL = 3, + SCE_TCMD_HIDE = 4, + SCE_TCMD_COMMAND = 5, + SCE_TCMD_IDENTIFIER = 6, + SCE_TCMD_OPERATOR = 7, + SCE_TCMD_ENVIRONMENT = 8, + SCE_TCMD_EXPANSION = 9, + SCE_TCMD_CLABEL = 10, + SCE_MAKE_DEFAULT = 0, + SCE_MAKE_COMMENT = 1, + SCE_MAKE_PREPROCESSOR = 2, + SCE_MAKE_IDENTIFIER = 3, + SCE_MAKE_OPERATOR = 4, + SCE_MAKE_TARGET = 5, + SCE_MAKE_IDEOL = 9, + SCE_DIFF_DEFAULT = 0, + SCE_DIFF_COMMENT = 1, + SCE_DIFF_COMMAND = 2, + SCE_DIFF_HEADER = 3, + SCE_DIFF_POSITION = 4, + SCE_DIFF_DELETED = 5, + SCE_DIFF_ADDED = 6, + SCE_DIFF_CHANGED = 7, + SCE_CONF_DEFAULT = 0, + SCE_CONF_COMMENT = 1, + SCE_CONF_NUMBER = 2, + SCE_CONF_IDENTIFIER = 3, + SCE_CONF_EXTENSION = 4, + SCE_CONF_PARAMETER = 5, + SCE_CONF_STRING = 6, + SCE_CONF_OPERATOR = 7, + SCE_CONF_IP = 8, + SCE_CONF_DIRECTIVE = 9, + SCE_AVE_DEFAULT = 0, + SCE_AVE_COMMENT = 1, + SCE_AVE_NUMBER = 2, + SCE_AVE_WORD = 3, + SCE_AVE_STRING = 6, + SCE_AVE_ENUM = 7, + SCE_AVE_STRINGEOL = 8, + SCE_AVE_IDENTIFIER = 9, + SCE_AVE_OPERATOR = 10, + SCE_AVE_WORD1 = 11, + SCE_AVE_WORD2 = 12, + SCE_AVE_WORD3 = 13, + SCE_AVE_WORD4 = 14, + SCE_AVE_WORD5 = 15, + SCE_AVE_WORD6 = 16, + SCE_ADA_DEFAULT = 0, + SCE_ADA_WORD = 1, + SCE_ADA_IDENTIFIER = 2, + SCE_ADA_NUMBER = 3, + SCE_ADA_DELIMITER = 4, + SCE_ADA_CHARACTER = 5, + SCE_ADA_CHARACTEREOL = 6, + SCE_ADA_STRING = 7, + SCE_ADA_STRINGEOL = 8, + SCE_ADA_LABEL = 9, + SCE_ADA_COMMENTLINE = 10, + SCE_ADA_ILLEGAL = 11, + SCE_BAAN_DEFAULT = 0, + SCE_BAAN_COMMENT = 1, + SCE_BAAN_COMMENTDOC = 2, + SCE_BAAN_NUMBER = 3, + SCE_BAAN_WORD = 4, + SCE_BAAN_STRING = 5, + SCE_BAAN_PREPROCESSOR = 6, + SCE_BAAN_OPERATOR = 7, + SCE_BAAN_IDENTIFIER = 8, + SCE_BAAN_STRINGEOL = 9, + SCE_BAAN_WORD2 = 10, + SCE_LISP_DEFAULT = 0, + SCE_LISP_COMMENT = 1, + SCE_LISP_NUMBER = 2, + SCE_LISP_KEYWORD = 3, + SCE_LISP_KEYWORD_KW = 4, + SCE_LISP_SYMBOL = 5, + SCE_LISP_STRING = 6, + SCE_LISP_STRINGEOL = 8, + SCE_LISP_IDENTIFIER = 9, + SCE_LISP_OPERATOR = 10, + SCE_LISP_SPECIAL = 11, + SCE_LISP_MULTI_COMMENT = 12, + SCE_EIFFEL_DEFAULT = 0, + SCE_EIFFEL_COMMENTLINE = 1, + SCE_EIFFEL_NUMBER = 2, + SCE_EIFFEL_WORD = 3, + SCE_EIFFEL_STRING = 4, + SCE_EIFFEL_CHARACTER = 5, + SCE_EIFFEL_OPERATOR = 6, + SCE_EIFFEL_IDENTIFIER = 7, + SCE_EIFFEL_STRINGEOL = 8, + SCE_NNCRONTAB_DEFAULT = 0, + SCE_NNCRONTAB_COMMENT = 1, + SCE_NNCRONTAB_TASK = 2, + SCE_NNCRONTAB_SECTION = 3, + SCE_NNCRONTAB_KEYWORD = 4, + SCE_NNCRONTAB_MODIFIER = 5, + SCE_NNCRONTAB_ASTERISK = 6, + SCE_NNCRONTAB_NUMBER = 7, + SCE_NNCRONTAB_STRING = 8, + SCE_NNCRONTAB_ENVIRONMENT = 9, + SCE_NNCRONTAB_IDENTIFIER = 10, + SCE_FORTH_DEFAULT = 0, + SCE_FORTH_COMMENT = 1, + SCE_FORTH_COMMENT_ML = 2, + SCE_FORTH_IDENTIFIER = 3, + SCE_FORTH_CONTROL = 4, + SCE_FORTH_KEYWORD = 5, + SCE_FORTH_DEFWORD = 6, + SCE_FORTH_PREWORD1 = 7, + SCE_FORTH_PREWORD2 = 8, + SCE_FORTH_NUMBER = 9, + SCE_FORTH_STRING = 10, + SCE_FORTH_LOCALE = 11, + SCE_MATLAB_DEFAULT = 0, + SCE_MATLAB_COMMENT = 1, + SCE_MATLAB_COMMAND = 2, + SCE_MATLAB_NUMBER = 3, + SCE_MATLAB_KEYWORD = 4, + SCE_MATLAB_STRING = 5, + SCE_MATLAB_OPERATOR = 6, + SCE_MATLAB_IDENTIFIER = 7, + SCE_MATLAB_DOUBLEQUOTESTRING = 8, + SCE_SCRIPTOL_DEFAULT = 0, + SCE_SCRIPTOL_WHITE = 1, + SCE_SCRIPTOL_COMMENTLINE = 2, + SCE_SCRIPTOL_PERSISTENT = 3, + SCE_SCRIPTOL_CSTYLE = 4, + SCE_SCRIPTOL_COMMENTBLOCK = 5, + SCE_SCRIPTOL_NUMBER = 6, + SCE_SCRIPTOL_STRING = 7, + SCE_SCRIPTOL_CHARACTER = 8, + SCE_SCRIPTOL_STRINGEOL = 9, + SCE_SCRIPTOL_KEYWORD = 10, + SCE_SCRIPTOL_OPERATOR = 11, + SCE_SCRIPTOL_IDENTIFIER = 12, + SCE_SCRIPTOL_TRIPLE = 13, + SCE_SCRIPTOL_CLASSNAME = 14, + SCE_SCRIPTOL_PREPROCESSOR = 15, + SCE_ASM_DEFAULT = 0, + SCE_ASM_COMMENT = 1, + SCE_ASM_NUMBER = 2, + SCE_ASM_STRING = 3, + SCE_ASM_OPERATOR = 4, + SCE_ASM_IDENTIFIER = 5, + SCE_ASM_CPUINSTRUCTION = 6, + SCE_ASM_MATHINSTRUCTION = 7, + SCE_ASM_REGISTER = 8, + SCE_ASM_DIRECTIVE = 9, + SCE_ASM_DIRECTIVEOPERAND = 10, + SCE_ASM_COMMENTBLOCK = 11, + SCE_ASM_CHARACTER = 12, + SCE_ASM_STRINGEOL = 13, + SCE_ASM_EXTINSTRUCTION = 14, + SCE_ASM_COMMENTDIRECTIVE = 15, + SCE_F_DEFAULT = 0, + SCE_F_COMMENT = 1, + SCE_F_NUMBER = 2, + SCE_F_STRING1 = 3, + SCE_F_STRING2 = 4, + SCE_F_STRINGEOL = 5, + SCE_F_OPERATOR = 6, + SCE_F_IDENTIFIER = 7, + SCE_F_WORD = 8, + SCE_F_WORD2 = 9, + SCE_F_WORD3 = 10, + SCE_F_PREPROCESSOR = 11, + SCE_F_OPERATOR2 = 12, + SCE_F_LABEL = 13, + SCE_F_CONTINUATION = 14, + SCE_CSS_DEFAULT = 0, + SCE_CSS_TAG = 1, + SCE_CSS_CLASS = 2, + SCE_CSS_PSEUDOCLASS = 3, + SCE_CSS_UNKNOWN_PSEUDOCLASS = 4, + SCE_CSS_OPERATOR = 5, + SCE_CSS_IDENTIFIER = 6, + SCE_CSS_UNKNOWN_IDENTIFIER = 7, + SCE_CSS_VALUE = 8, + SCE_CSS_COMMENT = 9, + SCE_CSS_ID = 10, + SCE_CSS_IMPORTANT = 11, + SCE_CSS_DIRECTIVE = 12, + SCE_CSS_DOUBLESTRING = 13, + SCE_CSS_SINGLESTRING = 14, + SCE_CSS_IDENTIFIER2 = 15, + SCE_CSS_ATTRIBUTE = 16, + SCE_CSS_IDENTIFIER3 = 17, + SCE_CSS_PSEUDOELEMENT = 18, + SCE_CSS_EXTENDED_IDENTIFIER = 19, + SCE_CSS_EXTENDED_PSEUDOCLASS = 20, + SCE_CSS_EXTENDED_PSEUDOELEMENT = 21, + SCE_CSS_MEDIA = 22, + SCE_CSS_VARIABLE = 23, + SCE_POV_DEFAULT = 0, + SCE_POV_COMMENT = 1, + SCE_POV_COMMENTLINE = 2, + SCE_POV_NUMBER = 3, + SCE_POV_OPERATOR = 4, + SCE_POV_IDENTIFIER = 5, + SCE_POV_STRING = 6, + SCE_POV_STRINGEOL = 7, + SCE_POV_DIRECTIVE = 8, + SCE_POV_BADDIRECTIVE = 9, + SCE_POV_WORD2 = 10, + SCE_POV_WORD3 = 11, + SCE_POV_WORD4 = 12, + SCE_POV_WORD5 = 13, + SCE_POV_WORD6 = 14, + SCE_POV_WORD7 = 15, + SCE_POV_WORD8 = 16, + SCE_LOUT_DEFAULT = 0, + SCE_LOUT_COMMENT = 1, + SCE_LOUT_NUMBER = 2, + SCE_LOUT_WORD = 3, + SCE_LOUT_WORD2 = 4, + SCE_LOUT_WORD3 = 5, + SCE_LOUT_WORD4 = 6, + SCE_LOUT_STRING = 7, + SCE_LOUT_OPERATOR = 8, + SCE_LOUT_IDENTIFIER = 9, + SCE_LOUT_STRINGEOL = 10, + SCE_ESCRIPT_DEFAULT = 0, + SCE_ESCRIPT_COMMENT = 1, + SCE_ESCRIPT_COMMENTLINE = 2, + SCE_ESCRIPT_COMMENTDOC = 3, + SCE_ESCRIPT_NUMBER = 4, + SCE_ESCRIPT_WORD = 5, + SCE_ESCRIPT_STRING = 6, + SCE_ESCRIPT_OPERATOR = 7, + SCE_ESCRIPT_IDENTIFIER = 8, + SCE_ESCRIPT_BRACE = 9, + SCE_ESCRIPT_WORD2 = 10, + SCE_ESCRIPT_WORD3 = 11, + SCE_PS_DEFAULT = 0, + SCE_PS_COMMENT = 1, + SCE_PS_DSC_COMMENT = 2, + SCE_PS_DSC_VALUE = 3, + SCE_PS_NUMBER = 4, + SCE_PS_NAME = 5, + SCE_PS_KEYWORD = 6, + SCE_PS_LITERAL = 7, + SCE_PS_IMMEVAL = 8, + SCE_PS_PAREN_ARRAY = 9, + SCE_PS_PAREN_DICT = 10, + SCE_PS_PAREN_PROC = 11, + SCE_PS_TEXT = 12, + SCE_PS_HEXSTRING = 13, + SCE_PS_BASE85STRING = 14, + SCE_PS_BADSTRINGCHAR = 15, + SCE_NSIS_DEFAULT = 0, + SCE_NSIS_COMMENT = 1, + SCE_NSIS_STRINGDQ = 2, + SCE_NSIS_STRINGLQ = 3, + SCE_NSIS_STRINGRQ = 4, + SCE_NSIS_FUNCTION = 5, + SCE_NSIS_VARIABLE = 6, + SCE_NSIS_LABEL = 7, + SCE_NSIS_USERDEFINED = 8, + SCE_NSIS_SECTIONDEF = 9, + SCE_NSIS_SUBSECTIONDEF = 10, + SCE_NSIS_IFDEFINEDEF = 11, + SCE_NSIS_MACRODEF = 12, + SCE_NSIS_STRINGVAR = 13, + SCE_NSIS_NUMBER = 14, + SCE_NSIS_SECTIONGROUP = 15, + SCE_NSIS_PAGEEX = 16, + SCE_NSIS_FUNCTIONDEF = 17, + SCE_NSIS_COMMENTBOX = 18, + SCE_MMIXAL_LEADWS = 0, + SCE_MMIXAL_COMMENT = 1, + SCE_MMIXAL_LABEL = 2, + SCE_MMIXAL_OPCODE = 3, + SCE_MMIXAL_OPCODE_PRE = 4, + SCE_MMIXAL_OPCODE_VALID = 5, + SCE_MMIXAL_OPCODE_UNKNOWN = 6, + SCE_MMIXAL_OPCODE_POST = 7, + SCE_MMIXAL_OPERANDS = 8, + SCE_MMIXAL_NUMBER = 9, + SCE_MMIXAL_REF = 10, + SCE_MMIXAL_CHAR = 11, + SCE_MMIXAL_STRING = 12, + SCE_MMIXAL_REGISTER = 13, + SCE_MMIXAL_HEX = 14, + SCE_MMIXAL_OPERATOR = 15, + SCE_MMIXAL_SYMBOL = 16, + SCE_MMIXAL_INCLUDE = 17, + SCE_CLW_DEFAULT = 0, + SCE_CLW_LABEL = 1, + SCE_CLW_COMMENT = 2, + SCE_CLW_STRING = 3, + SCE_CLW_USER_IDENTIFIER = 4, + SCE_CLW_INTEGER_CONSTANT = 5, + SCE_CLW_REAL_CONSTANT = 6, + SCE_CLW_PICTURE_STRING = 7, + SCE_CLW_KEYWORD = 8, + SCE_CLW_COMPILER_DIRECTIVE = 9, + SCE_CLW_RUNTIME_EXPRESSIONS = 10, + SCE_CLW_BUILTIN_PROCEDURES_FUNCTION = 11, + SCE_CLW_STRUCTURE_DATA_TYPE = 12, + SCE_CLW_ATTRIBUTE = 13, + SCE_CLW_STANDARD_EQUATE = 14, + SCE_CLW_ERROR = 15, + SCE_CLW_DEPRECATED = 16, + SCE_LOT_DEFAULT = 0, + SCE_LOT_HEADER = 1, + SCE_LOT_BREAK = 2, + SCE_LOT_SET = 3, + SCE_LOT_PASS = 4, + SCE_LOT_FAIL = 5, + SCE_LOT_ABORT = 6, + SCE_YAML_DEFAULT = 0, + SCE_YAML_COMMENT = 1, + SCE_YAML_IDENTIFIER = 2, + SCE_YAML_KEYWORD = 3, + SCE_YAML_NUMBER = 4, + SCE_YAML_REFERENCE = 5, + SCE_YAML_DOCUMENT = 6, + SCE_YAML_TEXT = 7, + SCE_YAML_ERROR = 8, + SCE_YAML_OPERATOR = 9, + SCE_TEX_DEFAULT = 0, + SCE_TEX_SPECIAL = 1, + SCE_TEX_GROUP = 2, + SCE_TEX_SYMBOL = 3, + SCE_TEX_COMMAND = 4, + SCE_TEX_TEXT = 5, + SCE_METAPOST_DEFAULT = 0, + SCE_METAPOST_SPECIAL = 1, + SCE_METAPOST_GROUP = 2, + SCE_METAPOST_SYMBOL = 3, + SCE_METAPOST_COMMAND = 4, + SCE_METAPOST_TEXT = 5, + SCE_METAPOST_EXTRA = 6, + SCE_ERLANG_DEFAULT = 0, + SCE_ERLANG_COMMENT = 1, + SCE_ERLANG_VARIABLE = 2, + SCE_ERLANG_NUMBER = 3, + SCE_ERLANG_KEYWORD = 4, + SCE_ERLANG_STRING = 5, + SCE_ERLANG_OPERATOR = 6, + SCE_ERLANG_ATOM = 7, + SCE_ERLANG_FUNCTION_NAME = 8, + SCE_ERLANG_CHARACTER = 9, + SCE_ERLANG_MACRO = 10, + SCE_ERLANG_RECORD = 11, + SCE_ERLANG_PREPROC = 12, + SCE_ERLANG_NODE_NAME = 13, + SCE_ERLANG_COMMENT_FUNCTION = 14, + SCE_ERLANG_COMMENT_MODULE = 15, + SCE_ERLANG_COMMENT_DOC = 16, + SCE_ERLANG_COMMENT_DOC_MACRO = 17, + SCE_ERLANG_ATOM_QUOTED = 18, + SCE_ERLANG_MACRO_QUOTED = 19, + SCE_ERLANG_RECORD_QUOTED = 20, + SCE_ERLANG_NODE_NAME_QUOTED = 21, + SCE_ERLANG_BIFS = 22, + SCE_ERLANG_MODULES = 23, + SCE_ERLANG_MODULES_ATT = 24, + SCE_ERLANG_UNKNOWN = 31, + SCE_MSSQL_DEFAULT = 0, + SCE_MSSQL_COMMENT = 1, + SCE_MSSQL_LINE_COMMENT = 2, + SCE_MSSQL_NUMBER = 3, + SCE_MSSQL_STRING = 4, + SCE_MSSQL_OPERATOR = 5, + SCE_MSSQL_IDENTIFIER = 6, + SCE_MSSQL_VARIABLE = 7, + SCE_MSSQL_COLUMN_NAME = 8, + SCE_MSSQL_STATEMENT = 9, + SCE_MSSQL_DATATYPE = 10, + SCE_MSSQL_SYSTABLE = 11, + SCE_MSSQL_GLOBAL_VARIABLE = 12, + SCE_MSSQL_FUNCTION = 13, + SCE_MSSQL_STORED_PROCEDURE = 14, + SCE_MSSQL_DEFAULT_PREF_DATATYPE = 15, + SCE_MSSQL_COLUMN_NAME_2 = 16, + SCE_V_DEFAULT = 0, + SCE_V_COMMENT = 1, + SCE_V_COMMENTLINE = 2, + SCE_V_COMMENTLINEBANG = 3, + SCE_V_NUMBER = 4, + SCE_V_WORD = 5, + SCE_V_STRING = 6, + SCE_V_WORD2 = 7, + SCE_V_WORD3 = 8, + SCE_V_PREPROCESSOR = 9, + SCE_V_OPERATOR = 10, + SCE_V_IDENTIFIER = 11, + SCE_V_STRINGEOL = 12, + SCE_V_USER = 19, + SCE_KIX_DEFAULT = 0, + SCE_KIX_COMMENT = 1, + SCE_KIX_STRING1 = 2, + SCE_KIX_STRING2 = 3, + SCE_KIX_NUMBER = 4, + SCE_KIX_VAR = 5, + SCE_KIX_MACRO = 6, + SCE_KIX_KEYWORD = 7, + SCE_KIX_FUNCTIONS = 8, + SCE_KIX_OPERATOR = 9, + SCE_KIX_COMMENTSTREAM = 10, + SCE_KIX_IDENTIFIER = 31, + SCE_GC_DEFAULT = 0, + SCE_GC_COMMENTLINE = 1, + SCE_GC_COMMENTBLOCK = 2, + SCE_GC_GLOBAL = 3, + SCE_GC_EVENT = 4, + SCE_GC_ATTRIBUTE = 5, + SCE_GC_CONTROL = 6, + SCE_GC_COMMAND = 7, + SCE_GC_STRING = 8, + SCE_GC_OPERATOR = 9, + SCE_SN_DEFAULT = 0, + SCE_SN_CODE = 1, + SCE_SN_COMMENTLINE = 2, + SCE_SN_COMMENTLINEBANG = 3, + SCE_SN_NUMBER = 4, + SCE_SN_WORD = 5, + SCE_SN_STRING = 6, + SCE_SN_WORD2 = 7, + SCE_SN_WORD3 = 8, + SCE_SN_PREPROCESSOR = 9, + SCE_SN_OPERATOR = 10, + SCE_SN_IDENTIFIER = 11, + SCE_SN_STRINGEOL = 12, + SCE_SN_REGEXTAG = 13, + SCE_SN_SIGNAL = 14, + SCE_SN_USER = 19, + SCE_AU3_DEFAULT = 0, + SCE_AU3_COMMENT = 1, + SCE_AU3_COMMENTBLOCK = 2, + SCE_AU3_NUMBER = 3, + SCE_AU3_FUNCTION = 4, + SCE_AU3_KEYWORD = 5, + SCE_AU3_MACRO = 6, + SCE_AU3_STRING = 7, + SCE_AU3_OPERATOR = 8, + SCE_AU3_VARIABLE = 9, + SCE_AU3_SENT = 10, + SCE_AU3_PREPROCESSOR = 11, + SCE_AU3_SPECIAL = 12, + SCE_AU3_EXPAND = 13, + SCE_AU3_COMOBJ = 14, + SCE_AU3_UDF = 15, + SCE_APDL_DEFAULT = 0, + SCE_APDL_COMMENT = 1, + SCE_APDL_COMMENTBLOCK = 2, + SCE_APDL_NUMBER = 3, + SCE_APDL_STRING = 4, + SCE_APDL_OPERATOR = 5, + SCE_APDL_WORD = 6, + SCE_APDL_PROCESSOR = 7, + SCE_APDL_COMMAND = 8, + SCE_APDL_SLASHCOMMAND = 9, + SCE_APDL_STARCOMMAND = 10, + SCE_APDL_ARGUMENT = 11, + SCE_APDL_FUNCTION = 12, + SCE_SH_DEFAULT = 0, + SCE_SH_ERROR = 1, + SCE_SH_COMMENTLINE = 2, + SCE_SH_NUMBER = 3, + SCE_SH_WORD = 4, + SCE_SH_STRING = 5, + SCE_SH_CHARACTER = 6, + SCE_SH_OPERATOR = 7, + SCE_SH_IDENTIFIER = 8, + SCE_SH_SCALAR = 9, + SCE_SH_PARAM = 10, + SCE_SH_BACKTICKS = 11, + SCE_SH_HERE_DELIM = 12, + SCE_SH_HERE_Q = 13, + SCE_ASN1_DEFAULT = 0, + SCE_ASN1_COMMENT = 1, + SCE_ASN1_IDENTIFIER = 2, + SCE_ASN1_STRING = 3, + SCE_ASN1_OID = 4, + SCE_ASN1_SCALAR = 5, + SCE_ASN1_KEYWORD = 6, + SCE_ASN1_ATTRIBUTE = 7, + SCE_ASN1_DESCRIPTOR = 8, + SCE_ASN1_TYPE = 9, + SCE_ASN1_OPERATOR = 10, + SCE_VHDL_DEFAULT = 0, + SCE_VHDL_COMMENT = 1, + SCE_VHDL_COMMENTLINEBANG = 2, + SCE_VHDL_NUMBER = 3, + SCE_VHDL_STRING = 4, + SCE_VHDL_OPERATOR = 5, + SCE_VHDL_IDENTIFIER = 6, + SCE_VHDL_STRINGEOL = 7, + SCE_VHDL_KEYWORD = 8, + SCE_VHDL_STDOPERATOR = 9, + SCE_VHDL_ATTRIBUTE = 10, + SCE_VHDL_STDFUNCTION = 11, + SCE_VHDL_STDPACKAGE = 12, + SCE_VHDL_STDTYPE = 13, + SCE_VHDL_USERWORD = 14, + SCE_VHDL_BLOCK_COMMENT = 15, + SCE_CAML_DEFAULT = 0, + SCE_CAML_IDENTIFIER = 1, + SCE_CAML_TAGNAME = 2, + SCE_CAML_KEYWORD = 3, + SCE_CAML_KEYWORD2 = 4, + SCE_CAML_KEYWORD3 = 5, + SCE_CAML_LINENUM = 6, + SCE_CAML_OPERATOR = 7, + SCE_CAML_NUMBER = 8, + SCE_CAML_CHAR = 9, + SCE_CAML_WHITE = 10, + SCE_CAML_STRING = 11, + SCE_CAML_COMMENT = 12, + SCE_CAML_COMMENT1 = 13, + SCE_CAML_COMMENT2 = 14, + SCE_CAML_COMMENT3 = 15, + SCE_HA_DEFAULT = 0, + SCE_HA_IDENTIFIER = 1, + SCE_HA_KEYWORD = 2, + SCE_HA_NUMBER = 3, + SCE_HA_STRING = 4, + SCE_HA_CHARACTER = 5, + SCE_HA_CLASS = 6, + SCE_HA_MODULE = 7, + SCE_HA_CAPITAL = 8, + SCE_HA_DATA = 9, + SCE_HA_IMPORT = 10, + SCE_HA_OPERATOR = 11, + SCE_HA_INSTANCE = 12, + SCE_HA_COMMENTLINE = 13, + SCE_HA_COMMENTBLOCK = 14, + SCE_HA_COMMENTBLOCK2 = 15, + SCE_HA_COMMENTBLOCK3 = 16, + SCE_HA_PRAGMA = 17, + SCE_HA_PREPROCESSOR = 18, + SCE_HA_STRINGEOL = 19, + SCE_HA_RESERVED_OPERATOR = 20, + SCE_HA_LITERATE_COMMENT = 21, + SCE_HA_LITERATE_CODEDELIM = 22, + SCE_T3_DEFAULT = 0, + SCE_T3_X_DEFAULT = 1, + SCE_T3_PREPROCESSOR = 2, + SCE_T3_BLOCK_COMMENT = 3, + SCE_T3_LINE_COMMENT = 4, + SCE_T3_OPERATOR = 5, + SCE_T3_KEYWORD = 6, + SCE_T3_NUMBER = 7, + SCE_T3_IDENTIFIER = 8, + SCE_T3_S_STRING = 9, + SCE_T3_D_STRING = 10, + SCE_T3_X_STRING = 11, + SCE_T3_LIB_DIRECTIVE = 12, + SCE_T3_MSG_PARAM = 13, + SCE_T3_HTML_TAG = 14, + SCE_T3_HTML_DEFAULT = 15, + SCE_T3_HTML_STRING = 16, + SCE_T3_USER1 = 17, + SCE_T3_USER2 = 18, + SCE_T3_USER3 = 19, + SCE_T3_BRACE = 20, + SCE_REBOL_DEFAULT = 0, + SCE_REBOL_COMMENTLINE = 1, + SCE_REBOL_COMMENTBLOCK = 2, + SCE_REBOL_PREFACE = 3, + SCE_REBOL_OPERATOR = 4, + SCE_REBOL_CHARACTER = 5, + SCE_REBOL_QUOTEDSTRING = 6, + SCE_REBOL_BRACEDSTRING = 7, + SCE_REBOL_NUMBER = 8, + SCE_REBOL_PAIR = 9, + SCE_REBOL_TUPLE = 10, + SCE_REBOL_BINARY = 11, + SCE_REBOL_MONEY = 12, + SCE_REBOL_ISSUE = 13, + SCE_REBOL_TAG = 14, + SCE_REBOL_FILE = 15, + SCE_REBOL_EMAIL = 16, + SCE_REBOL_URL = 17, + SCE_REBOL_DATE = 18, + SCE_REBOL_TIME = 19, + SCE_REBOL_IDENTIFIER = 20, + SCE_REBOL_WORD = 21, + SCE_REBOL_WORD2 = 22, + SCE_REBOL_WORD3 = 23, + SCE_REBOL_WORD4 = 24, + SCE_REBOL_WORD5 = 25, + SCE_REBOL_WORD6 = 26, + SCE_REBOL_WORD7 = 27, + SCE_REBOL_WORD8 = 28, + SCE_SQL_DEFAULT = 0, + SCE_SQL_COMMENT = 1, + SCE_SQL_COMMENTLINE = 2, + SCE_SQL_COMMENTDOC = 3, + SCE_SQL_NUMBER = 4, + SCE_SQL_WORD = 5, + SCE_SQL_STRING = 6, + SCE_SQL_CHARACTER = 7, + SCE_SQL_SQLPLUS = 8, + SCE_SQL_SQLPLUS_PROMPT = 9, + SCE_SQL_OPERATOR = 10, + SCE_SQL_IDENTIFIER = 11, + SCE_SQL_SQLPLUS_COMMENT = 13, + SCE_SQL_COMMENTLINEDOC = 15, + SCE_SQL_WORD2 = 16, + SCE_SQL_COMMENTDOCKEYWORD = 17, + SCE_SQL_COMMENTDOCKEYWORDERROR = 18, + SCE_SQL_USER1 = 19, + SCE_SQL_USER2 = 20, + SCE_SQL_USER3 = 21, + SCE_SQL_USER4 = 22, + SCE_SQL_QUOTEDIDENTIFIER = 23, + SCE_SQL_QOPERATOR = 24, + SCE_ST_DEFAULT = 0, + SCE_ST_STRING = 1, + SCE_ST_NUMBER = 2, + SCE_ST_COMMENT = 3, + SCE_ST_SYMBOL = 4, + SCE_ST_BINARY = 5, + SCE_ST_BOOL = 6, + SCE_ST_SELF = 7, + SCE_ST_SUPER = 8, + SCE_ST_NIL = 9, + SCE_ST_GLOBAL = 10, + SCE_ST_RETURN = 11, + SCE_ST_SPECIAL = 12, + SCE_ST_KWSEND = 13, + SCE_ST_ASSIGN = 14, + SCE_ST_CHARACTER = 15, + SCE_ST_SPEC_SEL = 16, + SCE_FS_DEFAULT = 0, + SCE_FS_COMMENT = 1, + SCE_FS_COMMENTLINE = 2, + SCE_FS_COMMENTDOC = 3, + SCE_FS_COMMENTLINEDOC = 4, + SCE_FS_COMMENTDOCKEYWORD = 5, + SCE_FS_COMMENTDOCKEYWORDERROR = 6, + SCE_FS_KEYWORD = 7, + SCE_FS_KEYWORD2 = 8, + SCE_FS_KEYWORD3 = 9, + SCE_FS_KEYWORD4 = 10, + SCE_FS_NUMBER = 11, + SCE_FS_STRING = 12, + SCE_FS_PREPROCESSOR = 13, + SCE_FS_OPERATOR = 14, + SCE_FS_IDENTIFIER = 15, + SCE_FS_DATE = 16, + SCE_FS_STRINGEOL = 17, + SCE_FS_CONSTANT = 18, + SCE_FS_WORDOPERATOR = 19, + SCE_FS_DISABLEDCODE = 20, + SCE_FS_DEFAULT_C = 21, + SCE_FS_COMMENTDOC_C = 22, + SCE_FS_COMMENTLINEDOC_C = 23, + SCE_FS_KEYWORD_C = 24, + SCE_FS_KEYWORD2_C = 25, + SCE_FS_NUMBER_C = 26, + SCE_FS_STRING_C = 27, + SCE_FS_PREPROCESSOR_C = 28, + SCE_FS_OPERATOR_C = 29, + SCE_FS_IDENTIFIER_C = 30, + SCE_FS_STRINGEOL_C = 31, + SCE_CSOUND_DEFAULT = 0, + SCE_CSOUND_COMMENT = 1, + SCE_CSOUND_NUMBER = 2, + SCE_CSOUND_OPERATOR = 3, + SCE_CSOUND_INSTR = 4, + SCE_CSOUND_IDENTIFIER = 5, + SCE_CSOUND_OPCODE = 6, + SCE_CSOUND_HEADERSTMT = 7, + SCE_CSOUND_USERKEYWORD = 8, + SCE_CSOUND_COMMENTBLOCK = 9, + SCE_CSOUND_PARAM = 10, + SCE_CSOUND_ARATE_VAR = 11, + SCE_CSOUND_KRATE_VAR = 12, + SCE_CSOUND_IRATE_VAR = 13, + SCE_CSOUND_GLOBAL_VAR = 14, + SCE_CSOUND_STRINGEOL = 15, + SCE_INNO_DEFAULT = 0, + SCE_INNO_COMMENT = 1, + SCE_INNO_KEYWORD = 2, + SCE_INNO_PARAMETER = 3, + SCE_INNO_SECTION = 4, + SCE_INNO_PREPROC = 5, + SCE_INNO_INLINE_EXPANSION = 6, + SCE_INNO_COMMENT_PASCAL = 7, + SCE_INNO_KEYWORD_PASCAL = 8, + SCE_INNO_KEYWORD_USER = 9, + SCE_INNO_STRING_DOUBLE = 10, + SCE_INNO_STRING_SINGLE = 11, + SCE_INNO_IDENTIFIER = 12, + SCE_OPAL_SPACE = 0, + SCE_OPAL_COMMENT_BLOCK = 1, + SCE_OPAL_COMMENT_LINE = 2, + SCE_OPAL_INTEGER = 3, + SCE_OPAL_KEYWORD = 4, + SCE_OPAL_SORT = 5, + SCE_OPAL_STRING = 6, + SCE_OPAL_PAR = 7, + SCE_OPAL_BOOL_CONST = 8, + SCE_OPAL_DEFAULT = 32, + SCE_SPICE_DEFAULT = 0, + SCE_SPICE_IDENTIFIER = 1, + SCE_SPICE_KEYWORD = 2, + SCE_SPICE_KEYWORD2 = 3, + SCE_SPICE_KEYWORD3 = 4, + SCE_SPICE_NUMBER = 5, + SCE_SPICE_DELIMITER = 6, + SCE_SPICE_VALUE = 7, + SCE_SPICE_COMMENTLINE = 8, + SCE_CMAKE_DEFAULT = 0, + SCE_CMAKE_COMMENT = 1, + SCE_CMAKE_STRINGDQ = 2, + SCE_CMAKE_STRINGLQ = 3, + SCE_CMAKE_STRINGRQ = 4, + SCE_CMAKE_COMMANDS = 5, + SCE_CMAKE_PARAMETERS = 6, + SCE_CMAKE_VARIABLE = 7, + SCE_CMAKE_USERDEFINED = 8, + SCE_CMAKE_WHILEDEF = 9, + SCE_CMAKE_FOREACHDEF = 10, + SCE_CMAKE_IFDEFINEDEF = 11, + SCE_CMAKE_MACRODEF = 12, + SCE_CMAKE_STRINGVAR = 13, + SCE_CMAKE_NUMBER = 14, + SCE_GAP_DEFAULT = 0, + SCE_GAP_IDENTIFIER = 1, + SCE_GAP_KEYWORD = 2, + SCE_GAP_KEYWORD2 = 3, + SCE_GAP_KEYWORD3 = 4, + SCE_GAP_KEYWORD4 = 5, + SCE_GAP_STRING = 6, + SCE_GAP_CHAR = 7, + SCE_GAP_OPERATOR = 8, + SCE_GAP_COMMENT = 9, + SCE_GAP_NUMBER = 10, + SCE_GAP_STRINGEOL = 11, + SCE_PLM_DEFAULT = 0, + SCE_PLM_COMMENT = 1, + SCE_PLM_STRING = 2, + SCE_PLM_NUMBER = 3, + SCE_PLM_IDENTIFIER = 4, + SCE_PLM_OPERATOR = 5, + SCE_PLM_CONTROL = 6, + SCE_PLM_KEYWORD = 7, + SCE_4GL_DEFAULT = 0, + SCE_4GL_NUMBER = 1, + SCE_4GL_WORD = 2, + SCE_4GL_STRING = 3, + SCE_4GL_CHARACTER = 4, + SCE_4GL_PREPROCESSOR = 5, + SCE_4GL_OPERATOR = 6, + SCE_4GL_IDENTIFIER = 7, + SCE_4GL_BLOCK = 8, + SCE_4GL_END = 9, + SCE_4GL_COMMENT1 = 10, + SCE_4GL_COMMENT2 = 11, + SCE_4GL_COMMENT3 = 12, + SCE_4GL_COMMENT4 = 13, + SCE_4GL_COMMENT5 = 14, + SCE_4GL_COMMENT6 = 15, + SCE_4GL_DEFAULT_ = 16, + SCE_4GL_NUMBER_ = 17, + SCE_4GL_WORD_ = 18, + SCE_4GL_STRING_ = 19, + SCE_4GL_CHARACTER_ = 20, + SCE_4GL_PREPROCESSOR_ = 21, + SCE_4GL_OPERATOR_ = 22, + SCE_4GL_IDENTIFIER_ = 23, + SCE_4GL_BLOCK_ = 24, + SCE_4GL_END_ = 25, + SCE_4GL_COMMENT1_ = 26, + SCE_4GL_COMMENT2_ = 27, + SCE_4GL_COMMENT3_ = 28, + SCE_4GL_COMMENT4_ = 29, + SCE_4GL_COMMENT5_ = 30, + SCE_4GL_COMMENT6_ = 31, + SCE_ABAQUS_DEFAULT = 0, + SCE_ABAQUS_COMMENT = 1, + SCE_ABAQUS_COMMENTBLOCK = 2, + SCE_ABAQUS_NUMBER = 3, + SCE_ABAQUS_STRING = 4, + SCE_ABAQUS_OPERATOR = 5, + SCE_ABAQUS_WORD = 6, + SCE_ABAQUS_PROCESSOR = 7, + SCE_ABAQUS_COMMAND = 8, + SCE_ABAQUS_SLASHCOMMAND = 9, + SCE_ABAQUS_STARCOMMAND = 10, + SCE_ABAQUS_ARGUMENT = 11, + SCE_ABAQUS_FUNCTION = 12, + SCE_ASY_DEFAULT = 0, + SCE_ASY_COMMENT = 1, + SCE_ASY_COMMENTLINE = 2, + SCE_ASY_NUMBER = 3, + SCE_ASY_WORD = 4, + SCE_ASY_STRING = 5, + SCE_ASY_CHARACTER = 6, + SCE_ASY_OPERATOR = 7, + SCE_ASY_IDENTIFIER = 8, + SCE_ASY_STRINGEOL = 9, + SCE_ASY_COMMENTLINEDOC = 10, + SCE_ASY_WORD2 = 11, + SCE_R_DEFAULT = 0, + SCE_R_COMMENT = 1, + SCE_R_KWORD = 2, + SCE_R_BASEKWORD = 3, + SCE_R_OTHERKWORD = 4, + SCE_R_NUMBER = 5, + SCE_R_STRING = 6, + SCE_R_STRING2 = 7, + SCE_R_OPERATOR = 8, + SCE_R_IDENTIFIER = 9, + SCE_R_INFIX = 10, + SCE_R_INFIXEOL = 11, + SCE_MAGIK_DEFAULT = 0, + SCE_MAGIK_COMMENT = 1, + SCE_MAGIK_HYPER_COMMENT = 16, + SCE_MAGIK_STRING = 2, + SCE_MAGIK_CHARACTER = 3, + SCE_MAGIK_NUMBER = 4, + SCE_MAGIK_IDENTIFIER = 5, + SCE_MAGIK_OPERATOR = 6, + SCE_MAGIK_FLOW = 7, + SCE_MAGIK_CONTAINER = 8, + SCE_MAGIK_BRACKET_BLOCK = 9, + SCE_MAGIK_BRACE_BLOCK = 10, + SCE_MAGIK_SQBRACKET_BLOCK = 11, + SCE_MAGIK_UNKNOWN_KEYWORD = 12, + SCE_MAGIK_KEYWORD = 13, + SCE_MAGIK_PRAGMA = 14, + SCE_MAGIK_SYMBOL = 15, + SCE_POWERSHELL_DEFAULT = 0, + SCE_POWERSHELL_COMMENT = 1, + SCE_POWERSHELL_STRING = 2, + SCE_POWERSHELL_CHARACTER = 3, + SCE_POWERSHELL_NUMBER = 4, + SCE_POWERSHELL_VARIABLE = 5, + SCE_POWERSHELL_OPERATOR = 6, + SCE_POWERSHELL_IDENTIFIER = 7, + SCE_POWERSHELL_KEYWORD = 8, + SCE_POWERSHELL_CMDLET = 9, + SCE_POWERSHELL_ALIAS = 10, + SCE_POWERSHELL_FUNCTION = 11, + SCE_POWERSHELL_USER1 = 12, + SCE_POWERSHELL_COMMENTSTREAM = 13, + SCE_POWERSHELL_HERE_STRING = 14, + SCE_POWERSHELL_HERE_CHARACTER = 15, + SCE_POWERSHELL_COMMENTDOCKEYWORD = 16, + SCE_MYSQL_DEFAULT = 0, + SCE_MYSQL_COMMENT = 1, + SCE_MYSQL_COMMENTLINE = 2, + SCE_MYSQL_VARIABLE = 3, + SCE_MYSQL_SYSTEMVARIABLE = 4, + SCE_MYSQL_KNOWNSYSTEMVARIABLE = 5, + SCE_MYSQL_NUMBER = 6, + SCE_MYSQL_MAJORKEYWORD = 7, + SCE_MYSQL_KEYWORD = 8, + SCE_MYSQL_DATABASEOBJECT = 9, + SCE_MYSQL_PROCEDUREKEYWORD = 10, + SCE_MYSQL_STRING = 11, + SCE_MYSQL_SQSTRING = 12, + SCE_MYSQL_DQSTRING = 13, + SCE_MYSQL_OPERATOR = 14, + SCE_MYSQL_FUNCTION = 15, + SCE_MYSQL_IDENTIFIER = 16, + SCE_MYSQL_QUOTEDIDENTIFIER = 17, + SCE_MYSQL_USER1 = 18, + SCE_MYSQL_USER2 = 19, + SCE_MYSQL_USER3 = 20, + SCE_MYSQL_HIDDENCOMMAND = 21, + SCE_MYSQL_PLACEHOLDER = 22, + SCE_PO_DEFAULT = 0, + SCE_PO_COMMENT = 1, + SCE_PO_MSGID = 2, + SCE_PO_MSGID_TEXT = 3, + SCE_PO_MSGSTR = 4, + SCE_PO_MSGSTR_TEXT = 5, + SCE_PO_MSGCTXT = 6, + SCE_PO_MSGCTXT_TEXT = 7, + SCE_PO_FUZZY = 8, + SCE_PO_PROGRAMMER_COMMENT = 9, + SCE_PO_REFERENCE = 10, + SCE_PO_FLAGS = 11, + SCE_PO_MSGID_TEXT_EOL = 12, + SCE_PO_MSGSTR_TEXT_EOL = 13, + SCE_PO_MSGCTXT_TEXT_EOL = 14, + SCE_PO_ERROR = 15, + SCE_PAS_DEFAULT = 0, + SCE_PAS_IDENTIFIER = 1, + SCE_PAS_COMMENT = 2, + SCE_PAS_COMMENT2 = 3, + SCE_PAS_COMMENTLINE = 4, + SCE_PAS_PREPROCESSOR = 5, + SCE_PAS_PREPROCESSOR2 = 6, + SCE_PAS_NUMBER = 7, + SCE_PAS_HEXNUMBER = 8, + SCE_PAS_WORD = 9, + SCE_PAS_STRING = 10, + SCE_PAS_STRINGEOL = 11, + SCE_PAS_CHARACTER = 12, + SCE_PAS_OPERATOR = 13, + SCE_PAS_ASM = 14, + SCE_SORCUS_DEFAULT = 0, + SCE_SORCUS_COMMAND = 1, + SCE_SORCUS_PARAMETER = 2, + SCE_SORCUS_COMMENTLINE = 3, + SCE_SORCUS_STRING = 4, + SCE_SORCUS_STRINGEOL = 5, + SCE_SORCUS_IDENTIFIER = 6, + SCE_SORCUS_OPERATOR = 7, + SCE_SORCUS_NUMBER = 8, + SCE_SORCUS_CONSTANT = 9, + SCE_POWERPRO_DEFAULT = 0, + SCE_POWERPRO_COMMENTBLOCK = 1, + SCE_POWERPRO_COMMENTLINE = 2, + SCE_POWERPRO_NUMBER = 3, + SCE_POWERPRO_WORD = 4, + SCE_POWERPRO_WORD2 = 5, + SCE_POWERPRO_WORD3 = 6, + SCE_POWERPRO_WORD4 = 7, + SCE_POWERPRO_DOUBLEQUOTEDSTRING = 8, + SCE_POWERPRO_SINGLEQUOTEDSTRING = 9, + SCE_POWERPRO_LINECONTINUE = 10, + SCE_POWERPRO_OPERATOR = 11, + SCE_POWERPRO_IDENTIFIER = 12, + SCE_POWERPRO_STRINGEOL = 13, + SCE_POWERPRO_VERBATIM = 14, + SCE_POWERPRO_ALTQUOTE = 15, + SCE_POWERPRO_FUNCTION = 16, + SCE_SML_DEFAULT = 0, + SCE_SML_IDENTIFIER = 1, + SCE_SML_TAGNAME = 2, + SCE_SML_KEYWORD = 3, + SCE_SML_KEYWORD2 = 4, + SCE_SML_KEYWORD3 = 5, + SCE_SML_LINENUM = 6, + SCE_SML_OPERATOR = 7, + SCE_SML_NUMBER = 8, + SCE_SML_CHAR = 9, + SCE_SML_STRING = 11, + SCE_SML_COMMENT = 12, + SCE_SML_COMMENT1 = 13, + SCE_SML_COMMENT2 = 14, + SCE_SML_COMMENT3 = 15, + SCE_MARKDOWN_DEFAULT = 0, + SCE_MARKDOWN_LINE_BEGIN = 1, + SCE_MARKDOWN_STRONG1 = 2, + SCE_MARKDOWN_STRONG2 = 3, + SCE_MARKDOWN_EM1 = 4, + SCE_MARKDOWN_EM2 = 5, + SCE_MARKDOWN_HEADER1 = 6, + SCE_MARKDOWN_HEADER2 = 7, + SCE_MARKDOWN_HEADER3 = 8, + SCE_MARKDOWN_HEADER4 = 9, + SCE_MARKDOWN_HEADER5 = 10, + SCE_MARKDOWN_HEADER6 = 11, + SCE_MARKDOWN_PRECHAR = 12, + SCE_MARKDOWN_ULIST_ITEM = 13, + SCE_MARKDOWN_OLIST_ITEM = 14, + SCE_MARKDOWN_BLOCKQUOTE = 15, + SCE_MARKDOWN_STRIKEOUT = 16, + SCE_MARKDOWN_HRULE = 17, + SCE_MARKDOWN_LINK = 18, + SCE_MARKDOWN_CODE = 19, + SCE_MARKDOWN_CODE2 = 20, + SCE_MARKDOWN_CODEBK = 21, + SCE_TXT2TAGS_DEFAULT = 0, + SCE_TXT2TAGS_LINE_BEGIN = 1, + SCE_TXT2TAGS_STRONG1 = 2, + SCE_TXT2TAGS_STRONG2 = 3, + SCE_TXT2TAGS_EM1 = 4, + SCE_TXT2TAGS_EM2 = 5, + SCE_TXT2TAGS_HEADER1 = 6, + SCE_TXT2TAGS_HEADER2 = 7, + SCE_TXT2TAGS_HEADER3 = 8, + SCE_TXT2TAGS_HEADER4 = 9, + SCE_TXT2TAGS_HEADER5 = 10, + SCE_TXT2TAGS_HEADER6 = 11, + SCE_TXT2TAGS_PRECHAR = 12, + SCE_TXT2TAGS_ULIST_ITEM = 13, + SCE_TXT2TAGS_OLIST_ITEM = 14, + SCE_TXT2TAGS_BLOCKQUOTE = 15, + SCE_TXT2TAGS_STRIKEOUT = 16, + SCE_TXT2TAGS_HRULE = 17, + SCE_TXT2TAGS_LINK = 18, + SCE_TXT2TAGS_CODE = 19, + SCE_TXT2TAGS_CODE2 = 20, + SCE_TXT2TAGS_CODEBK = 21, + SCE_TXT2TAGS_COMMENT = 22, + SCE_TXT2TAGS_OPTION = 23, + SCE_TXT2TAGS_PREPROC = 24, + SCE_TXT2TAGS_POSTPROC = 25, + SCE_A68K_DEFAULT = 0, + SCE_A68K_COMMENT = 1, + SCE_A68K_NUMBER_DEC = 2, + SCE_A68K_NUMBER_BIN = 3, + SCE_A68K_NUMBER_HEX = 4, + SCE_A68K_STRING1 = 5, + SCE_A68K_OPERATOR = 6, + SCE_A68K_CPUINSTRUCTION = 7, + SCE_A68K_EXTINSTRUCTION = 8, + SCE_A68K_REGISTER = 9, + SCE_A68K_DIRECTIVE = 10, + SCE_A68K_MACRO_ARG = 11, + SCE_A68K_LABEL = 12, + SCE_A68K_STRING2 = 13, + SCE_A68K_IDENTIFIER = 14, + SCE_A68K_MACRO_DECLARATION = 15, + SCE_A68K_COMMENT_WORD = 16, + SCE_A68K_COMMENT_SPECIAL = 17, + SCE_A68K_COMMENT_DOXYGEN = 18, + SCE_MODULA_DEFAULT = 0, + SCE_MODULA_COMMENT = 1, + SCE_MODULA_DOXYCOMM = 2, + SCE_MODULA_DOXYKEY = 3, + SCE_MODULA_KEYWORD = 4, + SCE_MODULA_RESERVED = 5, + SCE_MODULA_NUMBER = 6, + SCE_MODULA_BASENUM = 7, + SCE_MODULA_FLOAT = 8, + SCE_MODULA_STRING = 9, + SCE_MODULA_STRSPEC = 10, + SCE_MODULA_CHAR = 11, + SCE_MODULA_CHARSPEC = 12, + SCE_MODULA_PROC = 13, + SCE_MODULA_PRAGMA = 14, + SCE_MODULA_PRGKEY = 15, + SCE_MODULA_OPERATOR = 16, + SCE_MODULA_BADSTR = 17, + SCE_COFFEESCRIPT_DEFAULT = 0, + SCE_COFFEESCRIPT_COMMENT = 1, + SCE_COFFEESCRIPT_COMMENTLINE = 2, + SCE_COFFEESCRIPT_COMMENTDOC = 3, + SCE_COFFEESCRIPT_NUMBER = 4, + SCE_COFFEESCRIPT_WORD = 5, + SCE_COFFEESCRIPT_STRING = 6, + SCE_COFFEESCRIPT_CHARACTER = 7, + SCE_COFFEESCRIPT_UUID = 8, + SCE_COFFEESCRIPT_PREPROCESSOR = 9, + SCE_COFFEESCRIPT_OPERATOR = 10, + SCE_COFFEESCRIPT_IDENTIFIER = 11, + SCE_COFFEESCRIPT_STRINGEOL = 12, + SCE_COFFEESCRIPT_VERBATIM = 13, + SCE_COFFEESCRIPT_REGEX = 14, + SCE_COFFEESCRIPT_COMMENTLINEDOC = 15, + SCE_COFFEESCRIPT_WORD2 = 16, + SCE_COFFEESCRIPT_COMMENTDOCKEYWORD = 17, + SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR = 18, + SCE_COFFEESCRIPT_GLOBALCLASS = 19, + SCE_COFFEESCRIPT_STRINGRAW = 20, + SCE_COFFEESCRIPT_TRIPLEVERBATIM = 21, + SCE_COFFEESCRIPT_COMMENTBLOCK = 22, + SCE_COFFEESCRIPT_VERBOSE_REGEX = 23, + SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT = 24, + SCE_AVS_DEFAULT = 0, + SCE_AVS_COMMENTBLOCK = 1, + SCE_AVS_COMMENTBLOCKN = 2, + SCE_AVS_COMMENTLINE = 3, + SCE_AVS_NUMBER = 4, + SCE_AVS_OPERATOR = 5, + SCE_AVS_IDENTIFIER = 6, + SCE_AVS_STRING = 7, + SCE_AVS_TRIPLESTRING = 8, + SCE_AVS_KEYWORD = 9, + SCE_AVS_FILTER = 10, + SCE_AVS_PLUGIN = 11, + SCE_AVS_FUNCTION = 12, + SCE_AVS_CLIPPROP = 13, + SCE_AVS_USERDFN = 14, + SCE_ECL_DEFAULT = 0, + SCE_ECL_COMMENT = 1, + SCE_ECL_COMMENTLINE = 2, + SCE_ECL_NUMBER = 3, + SCE_ECL_STRING = 4, + SCE_ECL_WORD0 = 5, + SCE_ECL_OPERATOR = 6, + SCE_ECL_CHARACTER = 7, + SCE_ECL_UUID = 8, + SCE_ECL_PREPROCESSOR = 9, + SCE_ECL_UNKNOWN = 10, + SCE_ECL_IDENTIFIER = 11, + SCE_ECL_STRINGEOL = 12, + SCE_ECL_VERBATIM = 13, + SCE_ECL_REGEX = 14, + SCE_ECL_COMMENTLINEDOC = 15, + SCE_ECL_WORD1 = 16, + SCE_ECL_COMMENTDOCKEYWORD = 17, + SCE_ECL_COMMENTDOCKEYWORDERROR = 18, + SCE_ECL_WORD2 = 19, + SCE_ECL_WORD3 = 20, + SCE_ECL_WORD4 = 21, + SCE_ECL_WORD5 = 22, + SCE_ECL_COMMENTDOC = 23, + SCE_ECL_ADDED = 24, + SCE_ECL_DELETED = 25, + SCE_ECL_CHANGED = 26, + SCE_ECL_MOVED = 27, + SCE_OSCRIPT_DEFAULT = 0, + SCE_OSCRIPT_LINE_COMMENT = 1, + SCE_OSCRIPT_BLOCK_COMMENT = 2, + SCE_OSCRIPT_DOC_COMMENT = 3, + SCE_OSCRIPT_PREPROCESSOR = 4, + SCE_OSCRIPT_NUMBER = 5, + SCE_OSCRIPT_SINGLEQUOTE_STRING = 6, + SCE_OSCRIPT_DOUBLEQUOTE_STRING = 7, + SCE_OSCRIPT_CONSTANT = 8, + SCE_OSCRIPT_IDENTIFIER = 9, + SCE_OSCRIPT_GLOBAL = 10, + SCE_OSCRIPT_KEYWORD = 11, + SCE_OSCRIPT_OPERATOR = 12, + SCE_OSCRIPT_LABEL = 13, + SCE_OSCRIPT_TYPE = 14, + SCE_OSCRIPT_FUNCTION = 15, + SCE_OSCRIPT_OBJECT = 16, + SCE_OSCRIPT_PROPERTY = 17, + SCE_OSCRIPT_METHOD = 18, + SCE_VISUALPROLOG_DEFAULT = 0, + SCE_VISUALPROLOG_KEY_MAJOR = 1, + SCE_VISUALPROLOG_KEY_MINOR = 2, + SCE_VISUALPROLOG_KEY_DIRECTIVE = 3, + SCE_VISUALPROLOG_COMMENT_BLOCK = 4, + SCE_VISUALPROLOG_COMMENT_LINE = 5, + SCE_VISUALPROLOG_COMMENT_KEY = 6, + SCE_VISUALPROLOG_COMMENT_KEY_ERROR = 7, + SCE_VISUALPROLOG_IDENTIFIER = 8, + SCE_VISUALPROLOG_VARIABLE = 9, + SCE_VISUALPROLOG_ANONYMOUS = 10, + SCE_VISUALPROLOG_NUMBER = 11, + SCE_VISUALPROLOG_OPERATOR = 12, + SCE_VISUALPROLOG_CHARACTER = 13, + SCE_VISUALPROLOG_CHARACTER_TOO_MANY = 14, + SCE_VISUALPROLOG_CHARACTER_ESCAPE_ERROR = 15, + SCE_VISUALPROLOG_STRING = 16, + SCE_VISUALPROLOG_STRING_ESCAPE = 17, + SCE_VISUALPROLOG_STRING_ESCAPE_ERROR = 18, + SCE_VISUALPROLOG_STRING_EOL_OPEN = 19, + SCE_VISUALPROLOG_STRING_VERBATIM = 20, + SCE_VISUALPROLOG_STRING_VERBATIM_SPECIAL = 21, + SCE_VISUALPROLOG_STRING_VERBATIM_EOL = 22, + SCE_STTXT_DEFAULT = 0, + SCE_STTXT_COMMENT = 1, + SCE_STTXT_COMMENTLINE = 2, + SCE_STTXT_KEYWORD = 3, + SCE_STTXT_TYPE = 4, + SCE_STTXT_FUNCTION = 5, + SCE_STTXT_FB = 6, + SCE_STTXT_NUMBER = 7, + SCE_STTXT_HEXNUMBER = 8, + SCE_STTXT_PRAGMA = 9, + SCE_STTXT_OPERATOR = 10, + SCE_STTXT_CHARACTER = 11, + SCE_STTXT_STRING1 = 12, + SCE_STTXT_STRING2 = 13, + SCE_STTXT_STRINGEOL = 14, + SCE_STTXT_IDENTIFIER = 15, + SCE_STTXT_DATETIME = 16, + SCE_STTXT_VARS = 17, + SCE_STTXT_PRAGMAS = 18, + SCE_KVIRC_DEFAULT = 0, + SCE_KVIRC_COMMENT = 1, + SCE_KVIRC_COMMENTBLOCK = 2, + SCE_KVIRC_STRING = 3, + SCE_KVIRC_WORD = 4, + SCE_KVIRC_KEYWORD = 5, + SCE_KVIRC_FUNCTION_KEYWORD = 6, + SCE_KVIRC_FUNCTION = 7, + SCE_KVIRC_VARIABLE = 8, + SCE_KVIRC_NUMBER = 9, + SCE_KVIRC_OPERATOR = 10, + SCE_KVIRC_STRING_FUNCTION = 11, + SCE_KVIRC_STRING_VARIABLE = 12, + SCE_RUST_DEFAULT = 0, + SCE_RUST_COMMENTBLOCK = 1, + SCE_RUST_COMMENTLINE = 2, + SCE_RUST_COMMENTBLOCKDOC = 3, + SCE_RUST_COMMENTLINEDOC = 4, + SCE_RUST_NUMBER = 5, + SCE_RUST_WORD = 6, + SCE_RUST_WORD2 = 7, + SCE_RUST_WORD3 = 8, + SCE_RUST_WORD4 = 9, + SCE_RUST_WORD5 = 10, + SCE_RUST_WORD6 = 11, + SCE_RUST_WORD7 = 12, + SCE_RUST_STRING = 13, + SCE_RUST_STRINGR = 14, + SCE_RUST_CHARACTER = 15, + SCE_RUST_OPERATOR = 16, + SCE_RUST_IDENTIFIER = 17, + SCE_RUST_LIFETIME = 18, + SCE_RUST_MACRO = 19, + SCE_RUST_LEXERROR = 20, + SCE_RUST_BYTESTRING = 21, + SCE_RUST_BYTESTRINGR = 22, + SCE_RUST_BYTECHARACTER = 23, + SCE_DMAP_DEFAULT = 0, + SCE_DMAP_COMMENT = 1, + SCE_DMAP_NUMBER = 2, + SCE_DMAP_STRING1 = 3, + SCE_DMAP_STRING2 = 4, + SCE_DMAP_STRINGEOL = 5, + SCE_DMAP_OPERATOR = 6, + SCE_DMAP_IDENTIFIER = 7, + SCE_DMAP_WORD = 8, + SCE_DMAP_WORD2 = 9, + SCE_DMAP_WORD3 = 10, + SCE_DMIS_DEFAULT = 0, + SCE_DMIS_COMMENT = 1, + SCE_DMIS_STRING = 2, + SCE_DMIS_NUMBER = 3, + SCE_DMIS_KEYWORD = 4, + SCE_DMIS_MAJORWORD = 5, + SCE_DMIS_MINORWORD = 6, + SCE_DMIS_UNSUPPORTED_MAJOR = 7, + SCE_DMIS_UNSUPPORTED_MINOR = 8, + SCE_DMIS_LABEL = 9, + SCE_REG_DEFAULT = 0, + SCE_REG_COMMENT = 1, + SCE_REG_VALUENAME = 2, + SCE_REG_STRING = 3, + SCE_REG_HEXDIGIT = 4, + SCE_REG_VALUETYPE = 5, + SCE_REG_ADDEDKEY = 6, + SCE_REG_DELETEDKEY = 7, + SCE_REG_ESCAPED = 8, + SCE_REG_KEYPATH_GUID = 9, + SCE_REG_STRING_GUID = 10, + SCE_REG_PARAMETER = 11, + SCE_REG_OPERATOR = 12, + SCE_BIBTEX_DEFAULT = 0, + SCE_BIBTEX_ENTRY = 1, + SCE_BIBTEX_UNKNOWN_ENTRY = 2, + SCE_BIBTEX_KEY = 3, + SCE_BIBTEX_PARAMETER = 4, + SCE_BIBTEX_VALUE = 5, + SCE_BIBTEX_COMMENT = 6 + diff --git a/tools/WEE/scintilla/License.txt b/tools/WEE/scintilla/License.txt new file mode 100644 index 0000000..cbe25b2 --- /dev/null +++ b/tools/WEE/scintilla/License.txt @@ -0,0 +1,20 @@ +License for Scintilla and SciTE + +Copyright 1998-2003 by Neil Hodgson + +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation. + +NEIL HODGSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS, IN NO EVENT SHALL NEIL HODGSON BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE +OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file diff --git a/tools/WEE/scintilla/SciLexer.dll b/tools/WEE/scintilla/SciLexer.dll new file mode 100644 index 0000000..d0ac86c Binary files /dev/null and b/tools/WEE/scintilla/SciLexer.dll differ diff --git a/tools/WEE/scintilla/SciLexer64.dll b/tools/WEE/scintilla/SciLexer64.dll new file mode 100644 index 0000000..0ab9b0a Binary files /dev/null and b/tools/WEE/scintilla/SciLexer64.dll differ diff --git a/tools/WEE/scintilla/gtk_makefile b/tools/WEE/scintilla/gtk_makefile new file mode 100644 index 0000000..63e3c6e --- /dev/null +++ b/tools/WEE/scintilla/gtk_makefile @@ -0,0 +1,110 @@ +# Make file for Scintilla on Linux or compatible OS +# Copyright 1998-2010 by Neil Hodgson +# The License.txt file describes the conditions under which this software may be distributed. +# This makefile assumes GCC 4.3 is used and changes will be needed to use other compilers. +# GNU make does not like \r\n line endings so should be saved to CVS in binary form. +# Builds for GTK+ 2 and no longer supports GTK+ 1. +# Also works with ming32-make on Windows. + +.SUFFIXES: .cxx .c .o .h .a +ifdef CLANG +CXX = clang++ -Wno-deprecated-register +CC = clang +# Can choose aspect to sanitize: address and undefined can simply change SANITIZE but for +# thread also need to create Position Independent Executable -> search online documentation +SANITIZE = address +#SANITIZE = undefined +endif +RANLIB = touch + +ifdef GTK3 +GTKVERSION=gtk+-3.0 +else +GTKVERSION=gtk+-2.0 +endif + +# Environment variable windir always defined on Win32 + +ifndef windir +ifeq ($(shell uname),Darwin) +RANLIB = ranlib +endif +endif + +ifdef windir +DEL = del /q +COMPLIB=..\bin\scintilla.a +else +DEL = rm -f +COMPLIB=../bin/scintilla.a +SOLIB=../bin/scintilla.so +endif + +vpath %.h ../src ../include ../lexlib +vpath %.cxx ../src ../lexlib ../lexers + +INCLUDEDIRS=-I ../include -I ../src -I ../lexlib +ifdef CHECK_DEPRECATED +DEPRECATED=-DGDK_PIXBUF_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DDISABLE_GDK_FONT +endif +CXXBASEFLAGS=-Wall -pedantic -DGTK -DSCI_LEXER $(INCLUDEDIRS) $(DEPRECATED) -fPIC + +ifdef NOTHREADS +THREADFLAGS=-DG_THREADS_IMPL_NONE +else +THREADFLAGS= +endif + +ifdef CXX11_REGEX +REFLAGS=-DCXX11_REGEX +endif + +ifdef DEBUG +ifdef CLANG +CTFLAGS=-DDEBUG -g -fsanitize=$(SANITIZE) $(CXXBASEFLAGS) $(THREADFLAGS) +else +CTFLAGS=-DDEBUG -g $(CXXBASEFLAGS) $(THREADFLAGS) +endif +else +CTFLAGS=-DNDEBUG -Os $(CXXBASEFLAGS) $(THREADFLAGS) +endif + +CFLAGS:=$(CTFLAGS) +CXXTFLAGS:=--std=c++0x $(CTFLAGS) $(REFLAGS) + +CONFIGFLAGS:=$(shell pkg-config --cflags $(GTKVERSION)) +MARSHALLER=scintilla-marshal.o + +.cxx.o: + $(CXX) $(CONFIGFLAGS) $(CXXTFLAGS) $(CXXFLAGS) -c $< +.c.o: + $(CC) $(CONFIGFLAGS) $(CFLAGS) -w -c $< + +LEXOBJS:=$(addsuffix .o,$(basename $(notdir $(wildcard ../lexers/Lex*.cxx)))) + +all: $(COMPLIB) $(SOLIB) + +clean: + $(DEL) *.o $(COMPLIB) *.plist + +analyze: + clang --analyze $(CONFIGFLAGS) $(CXXTFLAGS) $(CXXFLAGS) *.cxx ../src/*.cxx ../lexlib/*.cxx ../lexers/*.cxx + +deps: + $(CXX) -MM $(CONFIGFLAGS) $(CXXTFLAGS) *.cxx ../src/*.cxx ../lexlib/*.cxx ../lexers/*.cxx | sed -e 's/\/usr.* //' | grep [a-zA-Z] >deps.mak + +COMPLIBS=Accessor.o CharacterSet.o LexerBase.o LexerModule.o LexerSimple.o StyleContext.o WordList.o \ + CharClassify.o Decoration.o Document.o PerLine.o Catalogue.o CallTip.o CaseConvert.o CaseFolder.o \ + ScintillaBase.o ContractionState.o EditModel.o Editor.o EditView.o ExternalLexer.o MarginView.o \ + PropSetSimple.o PlatGTK.o \ + KeyMap.o LineMarker.o PositionCache.o ScintillaGTK.o CellBuffer.o CharacterCategory.o ViewStyle.o \ + RESearch.o RunStyles.o Selection.o Style.o Indicator.o AutoComplete.o UniConversion.o XPM.o \ + $(MARSHALLER) $(LEXOBJS) +$(COMPLIB): $(COMPLIBS) + $(AR) rc $@ $^ + $(RANLIB) $@ +$(SOLIB): $(COMPLIBS) + $(CC) $(CFLAGS) -shared -o $@ $^ -lm -lstdc++ `pkg-config --libs $(GTKVERSION) gthread-2.0 gmodule-2.0` + +# Automatically generate header dependencies with "make deps" +include deps.mak diff --git a/tools/WEE/scintilla/scintilla32.so b/tools/WEE/scintilla/scintilla32.so new file mode 100755 index 0000000..08b03b8 Binary files /dev/null and b/tools/WEE/scintilla/scintilla32.so differ diff --git a/tools/WEE/scintilla/scintilla32armhf.so b/tools/WEE/scintilla/scintilla32armhf.so new file mode 100755 index 0000000..57c708d Binary files /dev/null and b/tools/WEE/scintilla/scintilla32armhf.so differ diff --git a/tools/WEE/scintilla/scintilla64.so b/tools/WEE/scintilla/scintilla64.so new file mode 100755 index 0000000..5fe6e7d Binary files /dev/null and b/tools/WEE/scintilla/scintilla64.so differ diff --git a/tools/WEE/scintilla/scintillaOSX.dylib b/tools/WEE/scintilla/scintillaOSX.dylib new file mode 100755 index 0000000..85ebf57 Binary files /dev/null and b/tools/WEE/scintilla/scintillaOSX.dylib differ diff --git a/tools/WEE/ui_gtk.e b/tools/WEE/ui_gtk.e new file mode 100644 index 0000000..ff571b4 --- /dev/null +++ b/tools/WEE/ui_gtk.e @@ -0,0 +1,1504 @@ +-- ui_gtk.e + +-- A huge thanks to Irv Mullins for making EuGTK, which made the Linux +-- and OSX GTK ports painless. Thanks to Irv for: +-- * focus-in-event for checking modified tabs +-- * current folder for load and save dialogs +-- * window placement taking window theme into account +-- * file dialog filters +-- * menu accelerator appearance +-- * new subs dialog + +-- Changes: +-- fix intermittent hang on quit (found it, caused by putting the program in the +-- background using Ctrl-Z and "bg". It blocks on doing something to console +-- before exiting, so need to do "fg" to unfreeze and exit normally.) + +-- font seems to be ok on OSX now, +-- needed to strip spaces and "bold", "italic", from the font name. + +-- Todo: +-- fix modifier keys not working on OS X (might be ok now using gtk accelerators) +-- menu accelerator labels show up as "-/-" on OS X +-- investigate if widgets need to be Destroy'd + + +public include std/machine.e +public include std/error.e +include std/get.e +include std/regex.e +include std/sort.e +include scintilla.e +include EuGTK/GtkEngine.e +include EuGTK/GtkEvents.e +include wee.exw as wee +include weeicon.e + +-- nifty shortcut, thanks Greg Haberek +function callback(sequence name, atom rid = routine_id(name)) + if rid = -1 then + crash("routine '"&name&"' is not visible") + end if + return call_back(rid) +end function + +-- check to see if 64-bit callback arguments are broken +ifdef BITS64 then +function check_callback_func(atom x) + if x = 0 then + crash("You need a newer 64-bit Euphoria with callback bug fix: 4.1.0 Beta 2 or later") + end if + return 0 +end function + +c_proc(define_c_proc("", callback("check_callback_func"), {C_LONG}), + {#100000000}) +end ifdef + + + +wee_init() -- initialize global variables + +x_pos = 100 y_pos = 50 +x_size = 500 y_size = 600 + +constant wee_conf_file = getenv("HOME") & "/.wee_conf" +load_wee_conf(wee_conf_file) + +-- bind the icon so it won't have to be found at runtime; +constant wee_icon = gtk_func("gdk_pixbuf_new_from_xpm_data", {P}, + {allocate_string_pointer_array(wee_xpm)}) + +-------------------------------------------------- +-- Find dialog + +constant + GTK_RESPONSE_FIND = 1, + GTK_RESPONSE_REPLACE = 2, + GTK_RESPONSE_REPLACE_ALL = 3 + +integer find_backward = 0 + +procedure find_dialog(integer replace_flag) + atom dialog, content, row, vbox, hbox, lbl, hedit, + find_entry, rep_entry, chk_word, chk_case, chk_backward + integer flags, result, pos + sequence text + + text = get_selection() + if length(text) then + find_phrase = text + end if + + dialog = create(GtkDialog, { + {"border width", 5}, + {"transient for", win}, + {"title", "Find"}, + {"modal", TRUE}, + {"add button", "gtk-close", GTK_RESPONSE_DELETE_EVENT}}) + if replace_flag then + set(dialog, "add button", "Replace All", GTK_RESPONSE_REPLACE_ALL) + set(dialog, "add button", "Replace", GTK_RESPONSE_REPLACE) + end if + set(dialog, "add button", "Find Next", GTK_RESPONSE_FIND) + set(dialog, "default response", GTK_RESPONSE_FIND) + + content = gtk:get(dialog, "content area") + + vbox = create(GtkBox, VERTICAL, 5) + set(vbox, "margin bottom", 5) + add(content, vbox) + + hbox = create(GtkBox, HORIZONTAL, 5) + pack(vbox, hbox) + pack(hbox, create(GtkLabel, "Find What:")) + find_entry = create(GtkEntry, { + {"activates default", TRUE}, + {"text", find_phrase}}) + pack(hbox, find_entry, TRUE, TRUE) + + hedit = tab_hedit() + + if replace_flag then + set(dialog, "default response", GTK_RESPONSE_REPLACE) + hbox = create(GtkBox, HORIZONTAL, 5) + pack(vbox, hbox) + pack(hbox, create(GtkLabel, "Replace With:")) + rep_entry = create(GtkEntry, { + {"activates default", TRUE}, + {"text", replace_phrase}}) + pack(hbox, rep_entry, TRUE, TRUE) + + -- clear the target so that first replace won't reuse old one + SSM(hedit, SCI_SETTARGETSTART, 0) + SSM(hedit, SCI_SETTARGETEND, 0) + end if + + flags = SSM(hedit, SCI_GETSEARCHFLAGS) + + chk_word = create(GtkCheckButton, { + {"label", "Match whole word only"}, + {"active", 0 != and_bits(flags, SCFIND_WHOLEWORD)}}) + pack(vbox, chk_word) + + chk_case = create(GtkCheckButton, { + {"label", "Match case"}, + {"active", 0 != and_bits(flags, SCFIND_MATCHCASE)}}) + pack(vbox, chk_case) + + chk_backward = create(GtkCheckButton, { + {"label", "Search backward"}, + {"active", find_backward}}) + pack(vbox, chk_backward) + + show_all(dialog) + + result = set(dialog, "run") + while result != GTK_RESPONSE_DELETE_EVENT do + flags = 0 + if gtk:get(chk_word, "active") then + flags += SCFIND_WHOLEWORD + end if + if gtk:get(chk_case, "active") then + flags += SCFIND_MATCHCASE + end if + find_backward = gtk:get(chk_backward, "active") + + SSM(hedit, SCI_SETSEARCHFLAGS, flags) + find_phrase = gtk:get(find_entry, "text") + + if result = GTK_RESPONSE_FIND then + if search_find(find_phrase, find_backward) = 0 then + Info(dialog, "Find", "Unable to find a match.") + end if + else + replace_phrase = gtk:get(rep_entry, "text") + if result = GTK_RESPONSE_REPLACE_ALL then + result = search_replace_all(find_phrase, replace_phrase) + if result then + Info(dialog, "Replace All", sprintf("%d replacements.", {result})) + else + Info(dialog, "Replace All", "Unable to find a match.") + end if + else + result = search_replace(replace_phrase) + if search_find(find_phrase, find_backward) = 0 and result = 0 then + Info(dialog, "Replace", "Unable to find a match.") + end if + end if + end if + result = set(dialog, "run") + end while + hide(dialog) + return +end procedure + + +-------------------------------------------------- +-- functions called from menu items + +function FileNew() new_file() return 0 end function +function FileOpen() open_file("", 0) return 0 end function +function FileSave() save_if_modified(0) return 0 end function +function FileSaveAs() save_file_as() return 0 end function +function FileClose() close_tab() return 0 end function +function FileQuit() + if save_modified_tabs() then + save_wee_conf(wee_conf_file) + Quit() + end if + return 0 +end function +function EditUndo() SSM(tab_hedit(), SCI_UNDO) return 0 end function +function EditRedo() SSM(tab_hedit(), SCI_REDO) return 0 end function +function EditCut() SSM(tab_hedit(), SCI_CUT) return 0 end function +function EditCopy() SSM(tab_hedit(), SCI_COPY) return 0 end function +function EditPaste() SSM(tab_hedit(), SCI_PASTE) return 0 end function +function EditClear() SSM(tab_hedit(), SCI_CLEAR) return 0 end function +function EditSelectAll() SSM(tab_hedit(), SCI_SELECTALL) return 0 end function +function EditToggleComment() toggle_comment() return 0 end function +function SearchFind() find_dialog(0) return 0 end function +function SearchFindNext() + if length(find_phrase) = 0 then + return SearchFind() + end if + search_find(find_phrase, 0) + return 0 +end function +function SearchFindPrevious() search_find(find_phrase, 1) return 0 end function +function SearchReplace() find_dialog(1) return 0 end function +function ViewDecl() view_declaration() return 0 end function +function ViewArgs() view_subroutine_arguments() return 0 end function +function ViewComp() view_completions() return 0 end function +function ViewError() ui_view_error() return 0 end function +function GoBack() go_back() return 0 end function + +function OldViewSubs() + sequence text, word, subs, tmp + integer pos, result + atom dialog, scroll, list, content, row, lbl + + text = get_edit_text() + pos = get_pos() + word = word_pos(text, pos) + tmp = get_subroutines(parse(text, file_name)) + word = word[1] + + subs = repeat(0, floor(length(tmp)/2)) + for i = 1 to length(subs) do + subs[i] = {tmp[i*2-1], tmp[i*2]} + end for + if sorted_subs then + subs = sort(subs) + end if + + dialog = create(GtkDialog, { + {"border width", 5}, + {"default size", 200, 400}, + {"add button", "gtk-close", GTK_RESPONSE_CLOSE}, + {"add button", "gtk-ok", GTK_RESPONSE_OK}, + {"transient for", win}, + {"title", "Subroutines"}, + {"default response", GTK_RESPONSE_OK}, + {"modal", TRUE}}) + + content = gtk:get(dialog, "content area") + scroll = create(GtkScrolledWindow) + pack(content, scroll, TRUE, TRUE) + + list = create(GtkListBox) + add(scroll, list) + for i = 1 to length(subs) do + lbl = create(GtkLabel, subs[i][1]) + set(lbl, "halign", GTK_ALIGN_START) + set(list, "insert", lbl, -1) + if equal(subs[i][1], word) then + row = gtk:get(list, "row at index", i-1) + set(list, "select row", row) + end if + end for + + show_all(dialog) + if set(dialog, "run") = GTK_RESPONSE_OK then + row = gtk:get(list, "selected row") + --result = gtk:get(row, "index") -- doesn't work? + for i = 1 to length(subs) do + if row = gtk:get(list, "row at index", i-1) then + word = subs[i][1] + pos = subs[i][2] + goto_pos(pos, length(word)) + exit + end if + end for + end if + hide(dialog) + return 0 +end function + +function RowActivated(atom ctl, atom path, atom col, atom dialog) + --? {ctl, path, col, dialog} + set(dialog, "response", GTK_RESPONSE_OK) + return 0 +end function +constant row_activated = callback("RowActivated") + +-- contributed by Irv +function ViewSubs() + sequence text, word, subs + integer pos, result + atom dialog, scroll, list, content, row, lbl + + text = get_edit_text() + pos = get_pos() + word = word_pos(text, pos) + subs = get_subroutines(parse(text, file_name)) + word = word[1] + + dialog = create(GtkDialog, { + {"border width", 5}, + {"default size", 200, 400}, + {"add button", "gtk-close", GTK_RESPONSE_CLOSE}, + {"add button", "gtk-ok", GTK_RESPONSE_OK}, + {"transient for", win}, + {"title", "Subroutines"}, + {"default response", GTK_RESPONSE_OK}, + {"modal", TRUE}}) + + content = gtk:get(dialog, "content area") + scroll = create(GtkScrolledWindow) + pack(content, scroll, TRUE, TRUE) + + object routines = subs, data + if sorted_subs then + routines = sort(routines) + end if + + list = create(GtkTreeView) + add(scroll, list) + object store = create(GtkListStore, {gSTR, gINT}) + set(list, "model", store) + object col1 = create(GtkTreeViewColumn) + object rend1 = create(GtkCellRendererText) + add(col1, rend1) + set(col1, "add attribute", rend1, "text", 1) + set(col1, "sort indicator", TRUE) + set(col1, "max width", 100) + set(col1, "title", "Routine Name") + set(list, "append columns", col1) + + object col2 = create(GtkTreeViewColumn) + object rend2 = create(GtkCellRendererText) + add(col2, rend2) + set(col2, "add attribute", rend2, "text", 2) + set(list, "append columns", col2) + set(store, "data", routines) + + object selection = gtk:get(list,"selection") + set(selection, "mode", GTK_SELECTION_SINGLE) + set(col2, "visible", FALSE) + + set(col1, "sort column id", 1) + connect(list, "row-activated", row_activated, dialog) + + show_all(dialog) + if gtk:get(dialog, "run") = GTK_RESPONSE_OK then + row = gtk:get(selection, "selected row") + data = gtk:get(store, "row data", row) + word = data[1] + pos = data[2] + goto_pos(pos, length(word)) + end if + hide(dialog) + + return 0 +end function + +function OptionsFont() + atom dialog + sequence font, tmp + + dialog = create(GtkFontChooserDialog, "Font...", win) + set(dialog, "font", sprintf("%s %d", {font_name, font_height})) + if set(dialog, "run") = MB_OK then + font = gtk:get(dialog, "font") + for i = length(font) to 1 by -1 do + if font[i] = ' ' then + tmp = value(font[i+1..$]) + if tmp[1] = 0 then + font_height = tmp[2] + font_name = font[1..i-1] + --printf(1, "%s %d\n", {font_name, font_height}) + reinit_all_edits() + end if + exit + end if + end for + end if + set(dialog, "hide") + + return 0 +end function + +function RunColorDialog(integer color) + object ccd = create(GtkColorChooserDialog, { + {"title", "Select a color"}, + {"transient for", win}, + {"use alpha", FALSE}, + {"rgba", sprintf("#%02x%02x%02x", + and_bits(floor(color/{1,#100,#10000}),#FF))}}) + if gtk:get(ccd, "run") = MB_OK then + color = gtk:get(ccd, "rgba", 2) + color = floor(and_bits(color, #FF0000) / #10000) + + and_bits(color, #FF00) + and_bits(color, #FF) * #10000 + end if + set(ccd, "hide") + return color +end function + +function ColorButton(atom ctl, atom w) + if w = 1 then + normal_color = RunColorDialog(normal_color) + elsif w = 2 then + background_color = RunColorDialog(background_color) + elsif w = 3 then + comment_color = RunColorDialog(comment_color) + elsif w = 4 then + string_color = RunColorDialog(string_color) + elsif w = 5 then + keyword_color = RunColorDialog(keyword_color) + elsif w = 6 then + builtin_color = RunColorDialog(builtin_color) + elsif w = 7 then + number_color = RunColorDialog(number_color) + elsif w = 8 then + bracelight_color = RunColorDialog(bracelight_color) + elsif w = 9 then + linenumber_color = RunColorDialog(linenumber_color) + end if + reinit_all_edits() + return 0 +end function + +function BoldToggle(atom ctl, atom flag) + if gtk:get(ctl, "active") then + bold_flags = or_bits(bold_flags, flag) + else + bold_flags = and_bits(bold_flags, not_bits(flag)) + end if + reinit_all_edits() + return 0 +end function + +constant color_button = callback("ColorButton") +constant bold_toggle = callback("BoldToggle") + +function OptionsColors() + atom dialog, grid + + dialog = create(GtkDialog, { + {"border width", 5}, + {"default size", 200, 300}, + {"add button", "gtk-close", GTK_RESPONSE_CLOSE}, + {"transient for", win}, + {"title", "Colors"}, + {"default response", GTK_RESPONSE_OK}, + {"modal", TRUE}}) + + grid = create(GtkGrid, VERTICAL) + set(grid, "margin bottom", 5) + add(gtk:get(dialog, "content area"), grid) + + set(grid, { + {"row spacing", 2}, + {"column spacing", 2}, + {"attach", create(GtkButton, "Normal", color_button, 1), 1, 2, 1, 1}, + {"attach", create(GtkButton, "Background", color_button, 2), 1, 3, 1, 1}, + {"attach", create(GtkButton, "Comment", color_button, 3), 1, 4, 1, 1}, + {"attach", create(GtkButton, "String", color_button, 4), 1, 5, 1, 1}, + {"attach", create(GtkButton, "Keyword", color_button, 5), 1, 6, 1, 1}, + {"attach", create(GtkButton, "Built-in", color_button, 6), 1, 7, 1, 1}, + {"attach", create(GtkButton, "Number", color_button, 7), 1, 8, 1, 1}, + {"attach", create(GtkButton, "Brace Highlight", color_button, 8), 1, 9, 1, 1}, + {"attach", create(GtkButton, "Line Number", color_button, 9), 1, 10, 1, 1}, + {"attach", create(GtkCheckButton, { + {"label", "Bold"}, {"active", 0 != and_bits(bold_flags, 1)}}, + bold_toggle, 1), 2, 2, 1, 1}, + {"attach", create(GtkCheckButton, { + {"label", "Bold"}, {"active", 0 != and_bits(bold_flags, 2)}}, + bold_toggle, 2), 2, 4, 1, 1}, + {"attach", create(GtkCheckButton, { + {"label", "Bold"}, {"active", 0 != and_bits(bold_flags, 4)}}, + bold_toggle, 4), 2, 5, 1, 1}, + {"attach", create(GtkCheckButton, { + {"label", "Bold"}, {"active", 0 != and_bits(bold_flags, 8)}}, + bold_toggle, 8), 2, 6, 1, 1}, + {"attach", create(GtkCheckButton, { + {"label", "Bold"}, {"active", 0 != and_bits(bold_flags, #10)}}, + bold_toggle, #10), 2, 7, 1, 1}, + {"attach", create(GtkCheckButton, { + {"label", "Bold"}, {"active", 0 != and_bits(bold_flags, #20)}}, + bold_toggle, #20), 2, 8, 1, 1}, + {"attach", create(GtkCheckButton, { + {"label", "Bold"}, {"active", 0 != and_bits(bold_flags, #40)}}, + bold_toggle, #40), 2, 9, 1, 1} + }) + + show_all(dialog) + set(dialog, "run") + set(dialog, "hide") + return 0 +end function + +function OptionsLineNumbers(atom handle) + line_numbers = gtk:get(handle, "active") + reinit_all_edits() + return 0 +end function + +function OptionsSortedSubs(atom handle) + sorted_subs = gtk:get(handle, "active") + return 0 +end function + +function OptionsLineWrap(atom handle) + line_wrap = gtk:get(handle, "active") + reinit_all_edits() + return 0 +end function + +function OptionsReopenTabs(atom handle) + reopen_tabs = gtk:get(handle, "active") + return 0 +end function + +function OptionsCompleteStatements(atom handle) + complete_statements = gtk:get(handle, "active") + return 0 +end function + +function OptionsCompleteBraces(atom handle) + complete_braces = gtk:get(handle, "active") + return 0 +end function + +function OptionsErrorIndicators(atom handle) + auto_indicator = gtk:get(handle, "active") + return 0 +end function + +function OptionsIndent(atom handle) + atom dialog, panel, hbox, hedit, indent_entry, tabs_entry, chk_guides, chk_usetabs + integer indent_width, tab_width, use_tabs + sequence val + + hedit = tab_hedit() + tab_width = SSM(hedit, SCI_GETTABWIDTH) + indent_width = SSM(hedit, SCI_GETINDENT) + use_tabs = SSM(hedit, SCI_GETUSETABS) + + dialog = create(GtkDialog, { + {"border width", 5}, + {"add button", "gtk-close", GTK_RESPONSE_DELETE_EVENT}, + {"add button", "gtk-ok", GTK_RESPONSE_OK}, + {"transient for", win}, + {"title", "Indent"}, + {"default response", GTK_RESPONSE_OK}, + {"modal", TRUE}}) + + panel = create(GtkBox, VERTICAL, 5) + set(panel, "margin bottom", 5) + add(gtk:get(dialog, "content area"), panel) + + hbox = create(GtkBox, HORIZONTAL, 5) + add(panel, hbox) + add(hbox, create(GtkLabel, "Indent Size")) + + indent_entry = create(GtkEntry, { + {"text", sprintf("%d", {indent_width})}}) + add(hbox, indent_entry) + + chk_guides = create(GtkCheckButton, { + {"label", "Show indentation guides"}, + {"active", indentation_guides}}) + pack(panel, chk_guides) + + chk_usetabs = create(GtkCheckButton, { + {"label", "Use tabs in indentation"}, + {"active", use_tabs}}) + pack(panel, chk_usetabs) + + hbox = create(GtkBox, HORIZONTAL, 5) + add(panel, hbox) + add(hbox, create(GtkLabel, "Tab Size")) + + tabs_entry = create(GtkEntry, { + {"text", sprintf("%d", {tab_width})}}) + add(hbox, tabs_entry) + + show_all(dialog) + while set(dialog, "run") = GTK_RESPONSE_OK do + + val = value(gtk:get(indent_entry, "text")) + if val[1] = 0 and integer(val[2]) and val[2] >= 1 and val[2] <= 8 then + indent_width = val[2] + else + set(indent_entry, "grab focus") + continue + end if + + val = value(gtk:get(tabs_entry, "text")) + if val[1] = 0 and integer(val[2]) and val[2] >= 1 and val[2] <= 8 then + tab_width = val[2] + else + set(tabs_entry, "grab focus") + continue + end if + + use_tabs = gtk:get(chk_usetabs, "active") + indentation_guides = gtk:get(chk_guides, "active") + + SSM(hedit, SCI_SETTABWIDTH, tab_width) + SSM(hedit, SCI_SETINDENT, indent_width) + SSM(hedit, SCI_SETUSETABS, use_tabs) + reinit_all_edits() + exit + + end while + hide(dialog) + return 0 +end function + +-- runs the script, maybe in a terminal emulator +procedure Run(sequence script) + sequence tmp_name = sprintf("/tmp/wee_run_%d.sh", {rand(1000000)}) + sequence cmd = tmp_name + if length(terminal_program) then + if run_waitkey then + -- need bash for "read -n" + script = "#!/bin/bash\n" & + -- don't show "Press Enter" on errors + match_replace("eui ", script, "eui -batch ") & + "\nread -n1 -s -p \"Press any key...\"\n" + end if + cmd = terminal_program & ' ' & tmp_name + end if + -- write script file + if write_file(tmp_name, script) = -1 then + printf(2, "Failed to write file %s\n", {tmp_name}) + return + end if + -- remove script after running it + cmd &= "; rm " & tmp_name + if run_background then + -- put the command in background + cmd = "(" & cmd & ") &" + end if + -- make script executable and run it + system("chmod +x " & tmp_name & "; " & cmd) +end procedure + +function RunStart(atom ctl) + object lbl = gtk:get(ctl, "label") + sequence cmd = "" + + if save_if_modified(0) = 0 or length(file_name) = 0 then + return 0 -- cancelled, or no name + end if + + run_file_name = file_name + cmd = "cd " & dirname(run_file_name) & "\n" + if match("Start", lbl) = 1 then + reset_ex_err() + cmd &= get_eu_bin(interpreter) & ' ' & quote_spaces(file_name) + if not equal(lbl, "Start") then -- with arguments + if length(get_tab_arguments()) = 0 then + if RunSetArguments() then + return 0 + end if + end if + cmd &= ' ' & get_tab_arguments() + end if + Run(cmd) + check_ex_err() + elsif equal(lbl, "Bind") then + cmd &= get_eu_bin("eubind") & ' ' & quote_spaces(file_name) + cmd &= "\nwhich upx && upx " & filebase(file_name) + if run_testrun then + cmd &= "\n./" & filebase(file_name) + end if + Run(cmd) + elsif equal(lbl, "Shroud") then + cmd &= get_eu_bin("eushroud") & ' ' & quote_spaces(file_name) + if run_testrun then + cmd &= "\n./" & filebase(file_name) & ".il" + end if + Run(cmd) + elsif equal(lbl, "Translate and Compile") then + cmd &= get_eu_bin("euc") & ' ' & quote_spaces(file_name) + cmd &= "\nwhich upx && upx " & filebase(file_name) + if run_testrun then + cmd &= "\n./" & filebase(file_name) + end if + Run(cmd) + elsif equal(lbl, "Run Terminal Emulator") then + Run(cmd & "$SHELL") + else + crash("Unable to get menu label") + end if + return 0 +end function + +function RunSetArguments() + atom dialog, content, text_entry, result = -1 + + dialog = create(GtkDialog, { + {"border width", 5}, + {"add button", "gtk-close", GTK_RESPONSE_DELETE_EVENT}, + {"add button", "gtk-ok", GTK_RESPONSE_OK}, + {"transient for", win}, + {"title", "Arguments"}, + {"default response", GTK_RESPONSE_OK}, + {"modal", TRUE}}) + content = gtk:get(dialog, "content area") + + text_entry = create(GtkEntry, { + {"activates default", TRUE}, + {"text", get_tab_arguments()}, + {"margin bottom", 5}}) + add(content, text_entry) + + show_all(dialog) + if set(dialog, "run") = GTK_RESPONSE_OK then + set_tab_arguments(gtk:get(text_entry, "text")) + result = 0 + end if + hide(dialog) + return result +end function + +function ChooseInterpreter(atom ctl, atom text_entry) + atom dialog + sequence filenames + + dialog = create(GtkFileChooserDialog, { + {"title", "Open..."}, + {"transient for", win}, + {"action", GTK_FILE_CHOOSER_ACTION_OPEN}, + {"add button", "gtk-cancel", GTK_RESPONSE_CLOSE}, + {"add button", "gtk-ok", GTK_RESPONSE_OK}, + {"position", GTK_WIN_POS_MOUSE}, + {"current folder", pathname(canonical_path(interpreter))}}) + + if gtk:get(dialog, "run") = GTK_RESPONSE_OK then + set(text_entry, "prepend text", gtk:get(dialog, "filename")) + set(text_entry, "active", 1) + end if + set(dialog, "hide") + return 0 +end function + +constant choose_interpreter = callback("ChooseInterpreter") + +function RunSetInterpreter() + atom dialog, text_entry, panel, row + sequence interpreters = get_interpreters() + integer index + + dialog = create(GtkDialog, { + {"border width", 5}, + {"add button", "gtk-close", GTK_RESPONSE_DELETE_EVENT}, + {"add button", "gtk-ok", GTK_RESPONSE_OK}, + {"transient for", win}, + {"title", "Choose Interpreter"}, + {"default response", GTK_RESPONSE_OK}, + {"modal", TRUE}}) + + panel = create(GtkBox, VERTICAL, 5) + set(panel, "margin bottom", 5) + add(gtk:get(dialog, "content area"), panel) + + pack(panel, create(GtkLabel, +`Enter an interpreter to use to run programs, or select one from the list. +Leave blank to use the default first item in the list.`)) + + row = create(GtkBox, HORIZONTAL, 5) + pack(panel, row, TRUE) + + text_entry = create(GtkComboBoxEntry, { + {"margin bottom", 5}, + {"activates default", TRUE}}) + pack(row, text_entry, TRUE, TRUE) + if length(interpreters) then + add(text_entry, interpreters) + index = find(interpreter, interpreters) + if index then + set(text_entry, "active", index) + end if + end if + pack(row, create(GtkButton, "...", choose_interpreter, text_entry)) + + show_all(dialog) + if set(dialog, "run") = GTK_RESPONSE_OK then + interpreter = gtk:get(text_entry, "active text") + end if + hide(dialog) + return 0 +end function + +constant terminals = {"x-terminal-emulator", "urxvt", "rxvt", + "terminator", "Eterm", "aterm", "xterm", "gnome-terminal", + "roxterm", "xfce4-terminal", "termite", "lxterminal", + "mate-terminal", "terminology"} + +function RunSetTerminal() + atom dialog, text_entry, panel + sequence text + integer n = 0 + + dialog = create(GtkDialog, { + {"border width", 5}, + {"add button", "gtk-close", GTK_RESPONSE_DELETE_EVENT}, + {"add button", "gtk-ok", GTK_RESPONSE_OK}, + {"transient for", win}, + {"title", "Choose Terminal Emulator"}, + {"default response", GTK_RESPONSE_OK}, + {"modal", TRUE}}) + + panel = create(GtkBox, VERTICAL, 5) + set(panel, "margin bottom", 5) + add(gtk:get(dialog, "content area"), panel) + + pack(panel, create(GtkLabel, +`Enter a terminal emulator to use to run programs, or select one +from the list. Leave blank to run in parent terminal.`)) + + text_entry = create(GtkComboBoxEntry, { + {"margin bottom", 5}, + {"activates default", TRUE}}) + pack(panel, text_entry) + for i = 1 to length(terminals) do + if system_exec("which " & terminals[i] & " >/dev/null 2>&1") = 0 then + text = terminals[i] + if find(text, {"gnome-terminal", "xfce4-terminal"}) then + text &= " -x" + else + text &= " -e" + end if + add(text_entry, {text}) + n += 1 + if equal(text, terminal_program) then + set(text_entry, "active", n) + end if + end if + end for + if length(terminal_program) and gtk:get(text_entry, "active") = 0 then + set(text_entry, "prepend text", terminal_program) + set(text_entry, "active", 1) + end if + + show_all(dialog) + if set(dialog, "run") = GTK_RESPONSE_OK then + terminal_program = gtk:get(text_entry, "active text") + end if + hide(dialog) + return 0 +end function + +function RunTestRun(atom handle) + run_testrun = gtk:get(handle, "active") + return 0 +end function + +function RunBackground(atom handle) + run_background = gtk:get(handle, "active") + return 0 +end function + +function RunWaitKey(atom handle) + run_waitkey = gtk:get(handle, "active") + return 0 +end function + +function HelpAbout() + set(about_dialog, "run") + set(about_dialog, "hide") + return 0 +end function + +function HelpReleaseNotes() + release_notes() + return 0 +end function + +function HelpTutorial() + open_tutorial() + return 0 +end function + +function HelpHelp() + context_help() + return 0 +end function + +-------------------------------------- +-- functions called from window events + +-- this gets called when window is moved or resized +function configure_event(atom w, atom s) + atom left_margin, top_margin -- not used, just for show + {left_margin, top_margin, x_size, y_size} = + gtk:get(gtk:get(w, "window"), "geometry") + {x_pos, y_pos} = gtk:get(w, "position") + return 0 +end function + +-- called before window is closed, return TRUE to prevent close, otherwise FALSE +function delete_event() + if save_modified_tabs() then + save_wee_conf(wee_conf_file) + return FALSE + end if + return TRUE +end function + +function window_set_focus(atom widget) + check_externally_modified_tabs() + check_ex_err() + return 0 +end function + +------------------------------------------------------------- + +constant + group = create(GtkAccelGroup), + win = create(GtkWindow, { + {"border width", 0}, + {"add accel group", group}, + {"default size", x_size, y_size}, + {"move", x_pos, y_pos}}), + panel = create(GtkBox, VERTICAL) + +gtk_func("gtk_window_set_icon", {P,P}, {win, wee_icon}) +connect(win, "destroy", main_quit) +connect(win, "configure-event", callback("configure_event")) +connect(win, "delete-event", callback("delete_event")) +connect(win, "focus-in-event", callback("window_set_focus")) +add(win, panel) + +constant + about_dialog = create(GtkAboutDialog, { + {"transient for", win}, + {"name", "about:dialog"}, + {"program name", window_title}, + {"comments", "A small editor for Euphoria programming."}, + {"version", wee:version}, + {"authors", {author, "EuGTK by Irv Mullins http://sites.google.com/site/euphoriagtk/Home/"}}, + {"website", "https://github.com/peberlein/WEE/"}, + {"website label", "Wee on GitHub"}, + {"logo", wee_icon} + }) + + +constant + menubar = create(GtkMenuBar), + menuFile = create(GtkMenuItem, "_File"), + menuEdit = create(GtkMenuItem, "_Edit"), + menuSearch = create(GtkMenuItem, "_Search"), + menuView = create(GtkMenuItem, "_View"), + menuRun = create(GtkMenuItem, "_Run"), + menuOptions = create(GtkMenuItem, "_Options"), + menuHelp = create(GtkMenuItem, "_Help"), + filemenu = create(GtkMenu, {{"accel group", group}}), + editmenu = create(GtkMenu, {{"accel group", group}}), + searchmenu = create(GtkMenu, {{"accel group", group}}), + viewmenu = create(GtkMenu, {{"accel group", group}}), + runmenu = create(GtkMenu, {{"accel group", group}}), + optionsmenu = create(GtkMenu, {{"accel group", group}}), + helpmenu = create(GtkMenu, {{"accel group", group}}), + chooseinterpreter_menu = create(GtkMenu), + tabmenu = create(GtkMenu) + +-- create a menu item with "activate" signal connected to local routine +-- and add parsed accelerator key +function createmenuitem(sequence text, object r, object key = 0, object check = -1) + atom widget, x + if equal(check, -1) or sequence(check) then + if sequence(key) then + widget = create(GtkMenuItem, text, 0, 0, {group, key}) + if sequence(check) then + -- check could be a second accelerator + set(widget, "add accelerator", {group, check}) + end if + else + widget = create(GtkMenuItem, text) + end if + else + widget = create(GtkCheckMenuItem, text) + set(widget, "active", check) + end if + if sequence(r) then + x = routine_id(r) + if x <= 0 then + crash(r &" is not a visible function") + end if + r = call_back(x) + end if + connect(widget, "activate", r) + return widget +end function + +add(filemenu, { + createmenuitem("_New", "FileNew", "N"), + createmenuitem("_Open...", "FileOpen", "O"), + createmenuitem("_Save", "FileSave", "S"), + createmenuitem("Save _As...", "FileSaveAs", "S"), + createmenuitem("_Close", "FileClose", "W"), + create(GtkSeparatorMenuItem), + createmenuitem("_Quit", "FileQuit", "Q") + }) +set(menuFile, "submenu", filemenu) + +add(editmenu, { + createmenuitem("_Undo", "EditUndo", "Z"), + createmenuitem("_Redo", "EditRedo", "Z"), + create(GtkSeparatorMenuItem), + createmenuitem("_Cut", "EditCut", "X"), + createmenuitem("C_opy", "EditCopy", "C"), + createmenuitem("_Paste", "EditPaste", "V"), + createmenuitem("Clear", "EditClear"), + createmenuitem("Select _All", "EditSelectAll", "A"), + create(GtkSeparatorMenuItem), + createmenuitem("Toggle Comment", "EditToggleComment", "M") + }) +set(menuEdit, "submenu", editmenu) + +add(searchmenu, { + createmenuitem("Find...", "SearchFind", "F", "F3"), + createmenuitem("Find Next", "SearchFindNext", "G", "F3"), + createmenuitem("Find Previous", "SearchFindPrevious", "G", "F3"), + createmenuitem("Replace...", "SearchReplace", "R") + }) +set(menuSearch, "submenu", searchmenu) + +add(viewmenu, { + createmenuitem("Subroutines...", "ViewSubs", "F2"), + createmenuitem("Declaration", "ViewDecl", "D", "F2"), + createmenuitem("Subroutine Arguments...", "ViewArgs", "F2"), + createmenuitem("Completions...", "ViewComp", "space"), + createmenuitem("Goto Error", "ViewError", "F4"), + createmenuitem("Go Back", "GoBack", "Escape") + }) +set(menuView, "submenu", viewmenu) + +add(runmenu, { + createmenuitem("Start", "RunStart", "F5"), + createmenuitem("Start with Arguments", "RunStart", "F5"), + createmenuitem("Set Arguments...", "RunSetArguments"), + createmenuitem("Run In Background", "RunBackground", 0, run_background), + create(GtkSeparatorMenuItem), + createmenuitem("Set Interpreter...", "RunSetInterpreter"), + createmenuitem("Set Terminal Emulator...", "RunSetTerminal"), + createmenuitem("Run Terminal Emulator", "RunStart"), + createmenuitem("Wait for Keypress after Run in Terminal", "RunWaitKey", 0, run_waitkey), + create(GtkSeparatorMenuItem), + createmenuitem("Bind", "RunStart"), + createmenuitem("Shroud", "RunStart"), + createmenuitem("Translate and Compile", "RunStart", "F9"), + create(GtkSeparatorMenuItem), + createmenuitem("Test Run after Bind/Shroud/Translate", "RunTestRun", 0, run_testrun) + }) +set(menuRun, "submenu", runmenu) + +add(optionsmenu, { + createmenuitem("Font...", "OptionsFont"), + createmenuitem("Line Numbers", "OptionsLineNumbers", 0, line_numbers), + createmenuitem("Sort View Subroutines", "OptionsSortedSubs", 0, sorted_subs), + createmenuitem("Colors...", "OptionsColors"), + createmenuitem("Line Wrap", "OptionsLineWrap", 0, line_wrap), + createmenuitem("Reopen Tabs Next Time", "OptionsReopenTabs", 0, reopen_tabs), + createmenuitem("Complete Statements", "OptionsCompleteStatements", 0, complete_statements), + createmenuitem("Complete Braces", "OptionsCompleteBraces", 0, complete_braces), + createmenuitem("Indent...", "OptionsIndent"), + createmenuitem("Error Indicators", "OptionsErrorIndicators", 0, auto_indicator) + }) +set(menuOptions, "submenu", optionsmenu) + +add(helpmenu, { + createmenuitem("About...", "HelpAbout"), + createmenuitem("Release Notes...", "HelpReleaseNotes"), + createmenuitem("Tutorial", "HelpTutorial"), + createmenuitem("Help", "HelpHelp", "F1") + }) +set(menuHelp, "submenu", helpmenu) + +-- popup menu for tab controls +add(tabmenu, { + createmenuitem("Save", "FileSave"), + createmenuitem("Save As...", "FileSaveAs"), + createmenuitem("Close", "FileClose") +}) +show_all(tabmenu) + +add(menubar, { + menuFile, + menuEdit, + menuSearch, + menuView, + menuRun, + menuOptions, + menuHelp}) + +pack(panel, menubar) + +------------------------------------------------- +function NotebookSwitchPage(atom nb, atom page, atom page_num) + select_tab(page_num + 1) + return 0 +end function + +function NotebookButtonPressEvent(atom nb, atom event) + integer button = events:button(event) + + -- right click or middle click + if button = 3 or button = 2 then + atom x, y, lx, ly, lw, lh + {x,y} = events:xy(event) -- get mouse coordinates + atom allocation = allocate(4*4) + for i = 1 to gtk:get(nb, "n_pages") do + atom pg = gtk:get(nb, "nth_page", i-1) + atom lbl = gtk:get(nb, "tab_label", pg) + + gtk_func("gtk_widget_get_allocation", {P,P}, {lbl, allocation}) + {lx, ly, lw, lh} = peek4u({allocation, 4}) -- get label rect + + if x >= lx-10 and x <= lx+lw+10 then + if button = 3 then -- right click + select_tab(i) + set(tabmenu, "popup", NULL, NULL, NULL, NULL, 0, events:time(event)) + elsif button = 2 then -- middle click + select_tab(i) + close_tab() + end if + exit + end if + end for + free(allocation) + return 1 + end if + + return 0 +end function + +-- switch tabs when mouse wheel is scrolled +function NotebookScrollEvent(atom nb, atom event) + integer dir = events:scroll_dir(event) + if dir = 1 then + select_tab(get_next_tab()) + elsif dir = 0 then + select_tab(get_prev_tab()) + end if + return 0 +end function + +-- detect Tab and Tab +function NotebookKeyPressEvent(atom nb, atom event) + integer mod = events:state(event) + if key(event) = -9 and and_bits(mod, GDK_CONTROL_MASK) then + if and_bits(mod, GDK_SHIFT_MASK) then + select_tab(get_prev_tab()) + else + select_tab(get_next_tab()) + end if + return 1 + end if + return 0 +end function + + +constant + status_label = create(GtkLabel, "status"), + notebook = create(GtkNotebook, { + {"add_events", GDK_SCROLL_MASK}, + {"scrollable", TRUE}, + {"show border", FALSE}, -- seems to have opposite effect? + {"action widget", status_label, GTK_PACK_END}}) + +pack(panel, notebook, TRUE, TRUE) +show(status_label) + +connect(notebook, "switch-page", callback("NotebookSwitchPage")) +connect(notebook, "button-press-event", callback("NotebookButtonPressEvent")) +connect(notebook, "scroll-event", callback("NotebookScrollEvent")) +connect(notebook, "key-press-event", callback("NotebookKeyPressEvent")) + +-------------------------------------------------- + +sequence ui_hedits +ui_hedits = {} + +function tab_hedit() + integer tab + tab = gtk:get(notebook, "current page") + return ui_hedits[tab+1] +end function + +-------------------------------------------------- + +global procedure ui_update_status(sequence status) + set(status_label, "text", status) +end procedure + +function file_open_recent(atom handle, integer idx) + open_recent(idx) + return 0 +end function + +sequence filemenu_items = {} + +global procedure ui_refresh_file_menu(sequence items) + atom widget + if length(filemenu_items) = 0 and length(items) != 0 then + add(filemenu, create(GtkSeparatorMenuItem)) + end if + for i = 1 to length(items) do + if i > length(filemenu_items) then + widget = create(GtkMenuItem, items[i]) + set(widget, "use underline", 0) + filemenu_items &= widget + add(filemenu, widget) + connect(widget, "activate", callback("file_open_recent"), i) + else + set(filemenu_items[i], "label", items[i]) + end if + end for +end procedure + +global procedure ui_select_tab(integer tab) + set(notebook, "current page", tab - 1) + gtk_proc("gtk_widget_grab_focus", {P}, ui_hedits[tab]) +end procedure + +global procedure ui_update_window_title(sequence name) + set(win, "title", name & " ~ " & window_title) +end procedure + +global procedure ui_update_tab_name(integer tab, sequence name) + set(notebook, "tab label text", ui_hedits[tab], name) + set(gtk:get(notebook, "tab label", ui_hedits[tab]), "tooltip text", file_name) +end procedure + +constant sci_notify_cb = callback("sci_notify") + +global function ui_new_tab(sequence name) + atom editor + + editor = scintilla_new() + ui_hedits &= editor + init_edit(editor) + gtk_proc("gtk_widget_show", {P}, editor) + + set(notebook, "append page", editor, create(GtkLabel, name)) + + connect(editor, "sci-notify", sci_notify_cb, 0) + + return editor +end function + +global procedure ui_close_tab(integer tab) + set(notebook, "remove page", tab-1) + + -- remove the window handle + ui_hedits = ui_hedits[1..tab-1] & ui_hedits[tab+1..$] +end procedure + + +constant filters = { + create(GtkFileFilter, { + {"name", "Euphoria files"}, + {"add pattern", "*.e"}, + {"add pattern", "*.ex"}, + {"add pattern", "*.exw"}, + {"add pattern", "*.ew"}, + {"add pattern", "ex.err"}, + {"add pattern", "eu.cfg"}}), + create(GtkFileFilter, { + {"name", "Text files"}, + {"add mime type", "text/*"}}), + create(GtkFileFilter, { + {"name", "All files"}, + {"add pattern", "*"}})} +atom current_filter = filters[1] + +global function ui_get_open_file_name() + atom dialog + sequence filename + + dialog = create(GtkFileChooserDialog, { + {"title", "Open..."}, + {"transient for", win}, + {"action", GTK_FILE_CHOOSER_ACTION_OPEN}, + {"select multiple", TRUE}, + {"add button", "gtk-cancel", GTK_RESPONSE_CLOSE}, + {"add button", "gtk-ok", GTK_RESPONSE_OK}, + {"position", GTK_WIN_POS_MOUSE}, + {"current folder", pathname(canonical_path(file_name))}}) + add(dialog, filters) + set(dialog, "filter", current_filter) + + if gtk:get(dialog, "run") = GTK_RESPONSE_OK then + current_filter = gtk:get(dialog, "filter") + filename = gtk:get(dialog, "filenames") + if length(filename) = 1 then + -- single filename selected + filename = filename[1] + end if + else + filename = "" + end if + set(dialog, "hide") + + return filename +end function + +global function ui_get_save_file_name(sequence filename) + atom dialog + + dialog = create(GtkFileChooserDialog, { + {"title", "Save As..."}, + {"transient for", win}, + {"action", GTK_FILE_CHOOSER_ACTION_SAVE}, + {"select multiple", FALSE}, + {"do overwrite confirmation", TRUE}, + {"add button", "gtk-cancel", GTK_RESPONSE_CLOSE}, + {"add button", "gtk-ok", GTK_RESPONSE_OK}, + {"filename", filename}, + {"position", GTK_WIN_POS_MOUSE}, + {"current folder", pathname(canonical_path(file_name))}}) + add(dialog, filters) + + if gtk:get(dialog, "run") = GTK_RESPONSE_OK then + current_filter = gtk:get(dialog, "filter") + filename = gtk:get(dialog, "filename") + else + filename = "" + end if + set(dialog, "hide") + + return filename +end function + +-- returns yes=1 no=0 +global function ui_message_box_yes_no(sequence title, sequence message) + integer result + result = Question(win, title, "", message) + return (result = MB_YES) +end function + +-- returns yes=1 no=0 cancel=-1 +global function ui_message_box_yes_no_cancel(sequence title, sequence message) + atom dialog, result + dialog = create(GtkMessageDialog, { + {"title", title}, + {"transient for", win}, + {"add button", "gtk-cancel", -1}, + {"add button", "gtk-no", 0}, + {"add button", "gtk-yes", 1}, + {"transient for", win}, + {"destroy with parent", TRUE}, + {"text", message}, + {"position", GTK_WIN_POS_CENTER_ON_PARENT}}) + + result = gtk:get(dialog, "run") + set(dialog, "hide") + + return result +end function + +global function ui_message_box_error(sequence title, sequence message) + Error(win, title, , message, GTK_BUTTONS_OK) + return 0 +end function + +global procedure ui_view_error() + sequence err + atom dialog, scroll, list, content, row, lbl + integer result + + err = get_ex_err() + if length(err) = 0 then return end if + + dialog = create(GtkDialog, { + {"border width", 5}, + {"default size", 200, 400}, + {"add button", "gtk-close", GTK_RESPONSE_CLOSE}, + {"add button", "Open Ex.Err", GTK_RESPONSE_YES}, + {"add button", "Goto Error", GTK_RESPONSE_OK}, + {"transient for", win}, + {"title", "View Error"}, + {"default response", GTK_RESPONSE_OK}, + {"modal", TRUE}}) + content = gtk:get(dialog, "content area") + + lbl = create(GtkLabel, err[2]) + pack(content, lbl) + + content = gtk:get(dialog, "content area") + scroll = create(GtkScrolledWindow) + pack(content, scroll, TRUE, TRUE) + + list = create(GtkListBox) + add(scroll, list) + for i = 3 to length(err) do + lbl = create(GtkLabel, err[i]) + set(lbl, "halign", GTK_ALIGN_START) + set(list, "insert", lbl, -1) + end for + + show_all(dialog) + result = set(dialog, "run") + if result = GTK_RESPONSE_OK then + row = gtk:get(list, "selected row") + --result = gtk:get(row, "index") -- doesn't work? + for i = 0 to length(err)-3 do + if row = gtk:get(list, "row at index", i) then + goto_error(err, i+1) + exit + end if + end for + elsif result = GTK_RESPONSE_YES then + open_file(ex_err_name, 1) + end if + hide(dialog) +end procedure + +-------------------------------------------------- +-- help window + +function HelpActivateLink(atom handle, atom uri, atom userdata) + puts(1, peek_string(uri)&"\n") + return 1 +end function + +function Hide(atom handle) + set(handle,"visible",FALSE) + return 1 +end function + +constant helpwin = create(GtkWindow, { + {"transient for", win}, + {"title", "Help"}, + {"default size", 400, 400}, + {"border width", 10}, + {"deletable", FALSE}, --! + {"resizable", FALSE}}) +connect(helpwin, "delete-event", callback("Hide")) + +constant helplbl = create(GtkLabel) +add(helpwin,helplbl) +connect(helplbl, "activate-link", callback("HelpActivateLink")) + +function re(sequence txt, sequence rx, sequence rep) + return regex:find_replace(regex:new(rx), txt, rep) +end function + +-- FIXME this doesn't work very well +function html_to_markup(sequence html) + html = re(html, `([A-Za-z0-9. ]*)`, `\1`) + html = re(html, `

?`, ``) + html = re(html, `

`, ``) + html = re(html, ``, `
`) + html = re(html, `
`, ``)
+    html = re(html, `
`, ``) + html = re(html, `
`, ``) + html = re(html, `
`, ``) + html = re(html, `
    `, `\n`) + html = re(html, `
`, ``) + html = re(html, `
  • `, ` 1. `) + html = re(html, `
  • `, `\n`) + html = re(html, `
      `, `\n`) + html = re(html, `
    `, ``) + html = re(html, `\n\n+`, `\n\n`) + puts(1, html) + return html +end function + +global function ui_show_help(sequence html) + set(helplbl,"markup",html_to_markup(html)) + show_all(helpwin) + return 0 +end function + +global procedure ui_show_uri(sequence uri) + show_uri(uri) +end procedure + +-------------------------------------------------- + +ui_refresh_file_menu(recent_files) + +-- open files from last time and on command line +open_tabs() + +show_all(win) +main() diff --git a/tools/WEE/ui_win.e b/tools/WEE/ui_win.e new file mode 100644 index 0000000..118ec83 --- /dev/null +++ b/tools/WEE/ui_win.e @@ -0,0 +1,1866 @@ +-- ui_win.e + +include window.ew +include wee.exw +include std/text.e +include std/filesys.e +include std/sort.e +include std/machine.e +include std/dll.e +include std/get.e + +-- MenuItem constants +constant + File_New = 101, + File_Open = 102, + File_Save = 103, + File_SaveAs = 104, + File_Close = 105, + File_PageSetup = 106, + File_Print = 107, + File_Exit = 108, + File_Recent = 110, + Edit_Undo = 201, + Edit_Cut = 202, + Edit_Copy = 203, + Edit_Paste = 204, + Edit_Clear = 205, + Edit_SelectAll = 206, + Edit_Redo = 207, + Edit_ToggleComment = 208, + Search_Find = 301, + Search_Find_Next = 302, + Search_Find_Prev = 303, + Search_Replace = 304, + View_Subs = 401, + View_Error = 402, + View_Completions = 404, + View_Declaration = 405, + View_GoBack = 406, + View_SubArgs = 407, + Run_Start = 501, + Run_WithArgs = 502, + Run_Arguments = 503, + Run_Interpreter = 507, + Run_Bind = 504, + Run_Shroud = 505, + Run_Translate = 506, + Options_Font = 601, + Options_LineNumbers = 602, + Options_SortedSubs = 603, + Options_Colors = 604, + Options_LineWrap = 605, + Options_ReopenTabs = 606, + Options_CompleteStatements = 607, + Options_CompleteBraces = 608, + Options_Indent = 609, + Options_ErrorIndicators = 610, + Help_About = 701, + Help_ReleaseNotes = 702, + Help_Tutorial = 703, + Help_Context = 704, + Select_Tab = 801, + Select_Next_Tab = 811, + Select_Prev_Tab = 812 + +constant file_filters = allocate_string( + "Euphoria files (*.ex,*.exw,*.e,*.ew)"&0&"*.EX;*.EXW;*.E;*.EW;ex.err;eu.cfg"&0& + "Text or Document files (*.txt,*.doc)"&0&"*.TXT;*.DOC"&0& + "All files (*.*)"&0&"*.*"&0&0) + + +atom hMainWnd, hFindDlg, hDlg, class, + hmenu, hfilemenu, heditmenu, hsearchmenu, hviewmenu, + hrunmenu, hoptionsmenu, hhelpmenu, htabmenu, + hstatus, htabs, hcode, hedit, htooltip, + WM_FIND + +sequence ui_hedits +ui_hedits = {} + +class = 0 +WM_FIND = 0 +hMainWnd = 0 -- the main window +hFindDlg = 0 +hDlg = 0 +hedit = 0 -- the richedit control +hstatus = 0 -- the static control showing cursor position +htabs = 0 -- the tab control +hcode = 0 -- the listbox control for code completions +hedit = 0 + +constant tab_h = 24 + + +x_pos = CW_USEDEFAULT +y_pos = CW_USEDEFAULT +x_size = CW_USEDEFAULT +y_size = CW_USEDEFAULT + +constant + ansi_var_font = c_func(GetStockObject, {ANSI_VAR_FONT}), + ansi_fixed_font = c_func(GetStockObject, {ANSI_FIXED_FONT}) + +atom captionFont, smCaptionFont, menuFont, statusFont, messageFont + + +-- nifty shortcut, thanks Greg Haberek +function callback(sequence name, atom rid = routine_id(name)) + return call_back(rid) +end function + + +global procedure ui_update_window_title(sequence name) + atom result + result = c_func(SendMessage, {hMainWnd, WM_SETTEXT, 0, + alloc_string(name & " ~ " & window_title)}) + free_strings() +end procedure + +global procedure ui_update_status(sequence status) + atom txt, junk + txt = allocate_string(status) + junk = c_func(SendMessage, {hstatus, WM_SETTEXT, 0, txt}) + free(txt) +end procedure + +global procedure ui_refresh_file_menu(sequence recent_files) + atom junk, count + count = c_func(GetMenuItemCount, {hfilemenu}) - 7 + if count = 0 and length(recent_files) > 0 then + junk = c_func(AppendMenu, {hfilemenu, MF_BYPOSITION + MF_SEPARATOR, 0, 0}) + end if + for i = 1 to length(recent_files) do + if i >= count then + junk = c_func(AppendMenu, {hfilemenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + File_Recent+i, alloc_string(recent_files[i])}) + else + junk = c_func(ModifyMenu, {hfilemenu, i+7, MF_BYPOSITION + MF_STRING + MF_ENABLED, + File_Recent+i, alloc_string(recent_files[i])}) + end if + end for + free_strings() +end procedure + +global procedure ui_update_tab_name(integer tab, sequence name) + atom junk, tcitem + tcitem = allocate_pack("dddsiip", {TCIF_TEXT, 0, 0, name, 0, 0, 0}) + junk = c_func(SendMessage, {htabs, TCM_SETITEMA, tab-1, tcitem}) + free(tcitem) + free_strings() +end procedure + + +-- select the tab and show the hedit +global procedure ui_select_tab(integer tab) + atom junk, rect + integer w, h + + -- change tab, and highlight it to make it stand out + junk = c_func(SendMessage, {htabs, TCM_HIGHLIGHTITEM, + c_func(SendMessage, {htabs, TCM_GETCURSEL, 0, 0}), 0}) + junk = c_func(SendMessage, {htabs, TCM_SETCURSEL, tab-1, 0}) + junk = c_func(SendMessage, {htabs, TCM_HIGHLIGHTITEM, tab-1, 1}) + + if hedit then + -- hide the previous hedit + c_proc(ShowWindow, {hedit, SW_HIDE}) + end if + + hedit = ui_hedits[tab] + + -- update the richedit control to the window size + rect = allocate(16) + c_proc(GetClientRect, {hMainWnd, rect}) + c_proc(MoveWindow, {hedit, 0, tab_h, peek4u(rect+8), peek4u(rect+12)-tab_h, 1}) + free(rect) + c_proc(ShowWindow, {hedit, SW_SHOW}) + junk = c_func(SetFocus, {hedit}) + + junk = allocate_pack("zdppddddps", { -- TOOLINFO + TTF_IDISHWND + TTF_SUBCLASS, -- uFlags + hMainWnd, -- hwnd + htabs, -- uId + 0,0,0,0, -- rect + 0, -- hinst + file_name -- lpszText + }) + c_func(SendMessage, {htooltip, TTM_UPDATETIPTEXT, 0, junk}) + free(junk) + +end procedure + +global function ui_new_tab(sequence name) + atom junk, tcitem, tab, hedit + tab = c_func(SendMessage, {htabs, TCM_GETITEMCOUNT, 0, 0}) + + tcitem = allocate_pack("dddsiip", {TCIF_TEXT, 0, 0, name, 0, 0, 0}) + junk = c_func(SendMessage, {htabs, TCM_INSERTITEMA, tab+(tab!=0), tcitem}) + free(tcitem) + free_strings() + + hedit = CreateWindow({ + 0, + "Scintilla", + "", + {WS_CHILD, WS_VISIBLE, WS_TABSTOP, WS_CLIPCHILDREN}, + 0,0,0,0, -- position and size set later by hMainWnd + hMainWnd, NULL, 0, NULL}) + + -- save the window handle + ui_hedits = append(ui_hedits, hedit) + return c_func(SendMessage, {hedit, SCI_GETDIRECTPOINTER, 0, 0}) +end function + +global procedure ui_close_tab(integer tab) + atom junk + + -- get the edit window handle and destroy it + junk = c_func(DestroyWindow, {hedit}) + hedit = 0 + -- delete the tab + junk = c_func(SendMessage, {htabs, TCM_DELETEITEM, tab-1, 0}) + -- remove the window handle + ui_hedits = ui_hedits[1..tab-1] & ui_hedits[tab+1..$] +end procedure + +procedure rightclick_tab() + atom point + integer tab, x, y + point = allocate(12) + c_func(GetCursorPos, {point}) + x = peek4u(point) + y = peek4u(point+4) + c_func(ScreenToClient, {hMainWnd, point}) + tab = c_func(SendMessage, {htabs, TCM_HITTEST, 0, point}) + if tab >= 0 then + select_tab(tab + 1) + c_func(TrackPopupMenu, {htabmenu, TPM_LEFTALIGN, x, y, 0, hMainWnd, 0}) + end if + free(point) +end procedure + + +integer current_filter +current_filter = 1 + +global function ui_get_open_file_name(integer multiple = 1) + sequence temp + temp = GetOpenFileName({hMainWnd, 0, file_filters, current_filter, + "", 0, 0, + OFN_EXPLORER + OFN_PATHMUSTEXIST + OFN_FILEMUSTEXIST + OFN_HIDEREADONLY + + (multiple != 0) * OFN_ALLOWMULTISELECT + , 0}) + if length(temp) < 2 then return "" end if + current_filter = temp[1] + return temp[2] +end function + +global function ui_get_save_file_name(sequence file_name) + sequence temp + temp = GetSaveFileName({hMainWnd, 0, file_filters, current_filter, + file_name, 0, 0, OFN_EXPLORER + OFN_PATHMUSTEXIST + OFN_HIDEREADONLY, 0}) + if length(temp) < 2 then return "" end if + current_filter = temp[1] + return temp[2] +end function + +-- returns yes=1 no=0 +global function ui_message_box_yes_no(sequence title, sequence message) + atom result + result = c_func(MessageBox, {hMainWnd, + alloc_string(message), + alloc_string(title), + or_all({MB_APPLMODAL, MB_ICONINFORMATION, MB_YESNO})}) + free_strings() + return result = IDYES +end function + +-- returns yes=1 no=0 cancel=-1 +global function ui_message_box_yes_no_cancel(sequence title, sequence message) + atom result + result = c_func(MessageBox, {hMainWnd, + alloc_string(message), + alloc_string(title), + or_all({MB_APPLMODAL, MB_ICONINFORMATION, MB_YESNOCANCEL})}) + free_strings() + return (result = IDYES) - (result = IDCANCEL) +end function + +global function ui_message_box_error(sequence title, sequence message) + atom result + result = c_func(MessageBox, {hMainWnd, + alloc_string(message), + alloc_string(title), + or_all({MB_APPLMODAL, MB_ICONSTOP, MB_OK})}) + free_strings() + return result +end function + +procedure get_window_size() + atom rect + rect = allocate(16) + c_proc(GetWindowRect, {hMainWnd, rect}) + x_pos = peek4u(rect) + y_pos = peek4u(rect+4) + x_size = peek4u(rect+8) - x_pos + y_size = peek4u(rect+12) - y_pos + free(rect) +end procedure + + +procedure about_box() + atom result + result = c_func(MessageBox, {hMainWnd, + alloc_string(window_title&"\n\nVersion "&version&"\n\nBy "&author), + alloc_string("About "&window_title), + or_all({MB_APPLMODAL, MB_ICONINFORMATION, MB_OK})}) + free_strings() +end procedure + +constant + DialogListID = 1000, + DialogLabelID = 1001, + DialogEditID = 1002, + DialogOpenID = 1003 +sequence subs + +function SubsDialogProc(atom hdlg, atom iMsg, atom wParam, atom lParam) + atom junk, hList, pos + sequence text, word, tmp + + --? {hdlg, iMsg, wParam, HIWORD(lParam), LOWORD(lParam)} + + if iMsg = WM_INITDIALOG then + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, IDOK}), + WM_SETFONT, captionFont, 0}) + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, IDCANCEL}), + WM_SETFONT, captionFont, 0}) + hList = c_func(GetDlgItem, {hdlg, DialogListID}) + junk = c_func(SendMessage, {hList, WM_SETFONT, messageFont, 0}) + text = get_edit_text() + pos = get_pos() + word = word_pos(text, pos) + subs = get_subroutines(parse(text, file_name)) + if sorted_subs then + subs = sort(subs) + end if + + for i = 1 to length(subs) do + junk = c_func(SendMessage, {hList, LB_ADDSTRING, 0, alloc_string(subs[i][1])}) + if equal(word[1], subs[i][1]) then + junk = c_func(SendMessage, {hList, LB_SETCURSEL, i-1, 0}) + end if + end for + free_strings() + + elsif iMsg = WM_COMMAND then + if LOWORD(wParam) = IDOK then + hList = c_func(GetDlgItem, {hdlg, DialogListID}) + pos = c_func(SendMessage, {hList, LB_GETCURSEL, 0, 0})+1 + if pos >= 1 and pos <= length(subs) then + word = subs[pos][1] + pos = subs[pos][2]-1 + --printf(1, "%s: pos=%d line=%d\n", {word, pos, + -- c_func(SendMessage, {hedit, SCI_LINEFROMPOSITION, pos, 0})}) + junk = c_func(SendMessage, {hedit, SCI_SETSEL, pos, pos+length(word)}) + set_top_line(-1) -- set the top visible line to the current line + end if + junk = c_func(EndDialog, {hdlg, 1}) + return 1 + elsif LOWORD(wParam) = IDCANCEL then + junk = c_func(EndDialog, {hdlg, 0}) + return 1 + end if + + elsif iMsg = WM_CLOSE then --closing dialog + junk = c_func(EndDialog, {hdlg, 0}) + end if + + return 0 +end function + +constant SubsDialogCallback = callback("SubsDialogProc") + +-- used for struct DLGITEMTEMPLATE +constant + DIALOG_CLASS_BUTTON = #0080, + DIALOG_CLASS_EDIT = #0081, + DIALOG_CLASS_STATIC = #0082, + DIALOG_CLASS_LIST = #0083, + DIALOG_CLASS_SCROLLBAR = #0084, + DIALOG_CLASS_COMBOBOX = #0085 + +procedure view_subroutines() + atom junk + junk = DialogBoxIndirectParam(c_func(GetModuleHandle, {NULL}), { + --DLGTEMPLATE{style, exstyle, x, y, cx, cy, menu, wndclass, text} + {{WS_POPUP, WS_BORDER, WS_SYSMENU, DS_MODALFRAME, WS_CAPTION}, 0, + 50,50, 100,124, 0, 0, "Subroutines"}, + --DLGITEMTEMPLATE{style, exstyle, x, y, cx, cy, id, dlgclass, text} + {{WS_CHILD, WS_VISIBLE, WS_VSCROLL}, WS_EX_CLIENTEDGE, + 4,4, 92,110, DialogListID, DIALOG_CLASS_LIST, "ListBox"}, + {{WS_CHILD, WS_VISIBLE, BS_PUSHBUTTON}, 0, + 4,108, 44,12, IDCANCEL, DIALOG_CLASS_BUTTON, "Cancel"}, + {{WS_CHILD, WS_VISIBLE, BS_DEFPUSHBUTTON}, 0, + 52,108, 44,12, IDOK, DIALOG_CLASS_BUTTON, "OK"} + }, + hMainWnd, + SubsDialogCallback, + 0) + subs = {} +end procedure + + +sequence err + +function ViewErrorProc(atom hdlg, atom iMsg, atom wParam, atom lParam) + atom junk, hList, hLabel, pos, len, item + + --? {hdlg, iMsg, wParam, HIWORD(lParam), LOWORD(lParam)} + + if iMsg = WM_INITDIALOG then + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, IDOK}), + WM_SETFONT, captionFont, 0}) + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, IDCANCEL}), + WM_SETFONT, captionFont, 0}) + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, IDRETRY}), + WM_SETFONT, captionFont, 0}) + hList = c_func(GetDlgItem, {hdlg, DialogListID}) + junk = c_func(SendMessage, {hList, WM_SETFONT, messageFont, 0}) + hLabel = c_func(GetDlgItem, {hdlg, DialogLabelID}) + junk = c_func(SendMessage, {hLabel, WM_SETFONT, messageFont, 0}) + + err = get_ex_err() + if length(err) = 0 then + junk = c_func(EndDialog, {hdlg, 0}) + return 1 + end if + junk = c_func(SendMessage, {hLabel, WM_SETTEXT, 0, alloc_string(err[2])}) + + for i = 3 to length(err) do + junk = c_func(SendMessage, {hList, LB_ADDSTRING, 0, alloc_string(err[i])}) + end for + junk = c_func(SendMessage, {hList, LB_SETCURSEL, 0, 0}) + junk = c_func(SetFocus, {hList}) + + elsif iMsg = WM_COMMAND then + if LOWORD(wParam) = IDOK then + hList = c_func(GetDlgItem, {hdlg, DialogListID}) + pos = c_func(SendMessage, {hList, LB_GETCURSEL, 0, 0}) + if pos != -1 then + goto_error(err, pos+1) + end if + junk = c_func(EndDialog, {hdlg, 1}) + return 1 + elsif LOWORD(wParam) = IDRETRY then + open_file(ex_err_name, 1) + junk = c_func(EndDialog, {hdlg, 0}) + return 1 + elsif LOWORD(wParam) = IDCANCEL then + junk = c_func(EndDialog, {hdlg, 0}) + return 1 + end if + + elsif iMsg = WM_CLOSE then --closing dialog + junk = c_func(EndDialog, {hdlg, 0}) + end if + + return 0 +end function + +constant ViewErrorCallback = callback("ViewErrorProc") + +global procedure ui_view_error() + integer junk + junk = DialogBoxIndirectParam(c_func(GetModuleHandle, {NULL}), { + --DLGTEMPLATE{style, exstyle, x, y, cx, cy, menu, wndclass, text} + {{WS_POPUP, WS_CAPTION, WS_SYSMENU, DS_MODALFRAME}, 0, + 50, 50, 200,150, 0, 0, "View Error"}, + --DLGITEMTEMPLATE{style, exstyle, x, y, cx, cy, id, dlgclass, text} + {{WS_CHILD, WS_VISIBLE, WS_VSCROLL}, WS_EX_CLIENTEDGE, + 4,24, 192,108, DialogListID, DIALOG_CLASS_LIST, "ListBox"}, + {{WS_CHILD, WS_VISIBLE}, 0, + 4,4, 192,20, DialogLabelID, DIALOG_CLASS_STATIC, "Static"}, + {{WS_CHILD, WS_VISIBLE, BS_PUSHBUTTON}, 0, + 54,132, 44,12, IDCANCEL, DIALOG_CLASS_BUTTON, "Cancel"}, + {{WS_CHILD, WS_VISIBLE, BS_PUSHBUTTON}, 0, + 102,132, 44,12, IDRETRY, DIALOG_CLASS_BUTTON, "Open ex.err"}, + {{WS_CHILD, WS_VISIBLE, BS_DEFPUSHBUTTON}, 0, + 150,132, 44,12, IDOK, DIALOG_CLASS_BUTTON, "Goto Error"} + }, + hMainWnd, + ViewErrorCallback, + 0) +end procedure + +global procedure ui_show_help(sequence html) + -- TODO +end procedure + +global procedure ui_show_uri(sequence uri) + atom result + -- TODO: get default browser from + -- HKEY_LOCAL_MACHINE\SOFTWARE\Classes\http\shell\open\command + -- note: just opening the uri won't work, since shellexecute will + -- strip off any #anchor text, so using iexplore.exe for now + result = c_func(ShellExecute, { + hMainWnd, NULL, + alloc_string("iexplore.exe"), + alloc_string(uri), + NULL, + SW_SHOWNORMAL}) + free_strings() +end procedure + + +procedure process_find(atom struc) + atom flags, junk, result + integer backward + + flags = GetFindFlags(struc) + if and_bits(flags, FR_DIALOGTERM) then + find_phrase = GetFindWhat(struc) + replace_phrase = GetReplaceWith(struc) + --puts(1, find_phrase&" "&replace_phrase&"\n") + hFindDlg = 0 + return + end if + --printf(1, "flags=%x\n", {flags}) + + backward = not and_bits(flags, FR_DOWN) + result = 0 + if and_bits(flags, FR_MATCHCASE) then + result += SCFIND_MATCHCASE + end if + if and_bits(flags, FR_WHOLEWORD) then + result += SCFIND_WHOLEWORD + end if + junk = c_func(SendMessage, {hedit, SCI_SETSEARCHFLAGS, result, 0}) + + if and_bits(flags, FR_FINDNEXT) then + if search_find(GetFindWhat(struc), backward) = 0 then + result = c_func(MessageBox, {hFindDlg, + alloc_string("Unable to find a match."), + alloc_string("Find"), + or_all({MB_APPLMODAL, MB_ICONINFORMATION, MB_OK})}) + end if + elsif and_bits(flags, FR_REPLACE) then + result = search_replace(GetReplaceWith(struc)) + if search_find(GetFindWhat(struc), backward) = 0 and result = 0 then + result = c_func(MessageBox, {hFindDlg, + alloc_string("Unable to find a match."), + alloc_string("Replace"), + or_all({MB_APPLMODAL, MB_ICONINFORMATION, MB_OK})}) + end if + elsif and_bits(flags, FR_REPLACEALL) then + result = search_replace_all(GetFindWhat(struc), GetReplaceWith(struc)) + if result then + result = c_func(MessageBox, {hFindDlg, + alloc_string(sprintf("%d replacements.", {result})), + alloc_string("Replace All"), + or_all({MB_APPLMODAL, MB_ICONINFORMATION, MB_OK})}) + else + result = c_func(MessageBox, {hFindDlg, + alloc_string("Unable to find a match."), + alloc_string("Replace All"), + or_all({MB_APPLMODAL, MB_ICONINFORMATION, MB_OK})}) + end if + end if + free_strings() +end procedure + + +function RunArgsProc(atom hdlg, atom iMsg, atom wParam, atom lParam) + atom junk, hEdit, len, buf + + --? {hdlg, iMsg, wParam, HIWORD(lParam), LOWORD(lParam)} + + if iMsg = WM_INITDIALOG then + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, IDOK}), + WM_SETFONT, captionFont, 0}) + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, IDCANCEL}), + WM_SETFONT, captionFont, 0}) + hEdit = c_func(GetDlgItem, {hdlg, DialogEditID}) + junk = c_func(SendMessage, {hEdit, WM_SETFONT, messageFont, 0}) + + junk = c_func(SendMessage, {hEdit, WM_SETTEXT, 0, alloc_string(get_tab_arguments())}) + junk = c_func(SetFocus, {hEdit}) + junk = c_func(SendMessage, {hEdit, EM_SETSEL, 0, -1}) + + elsif iMsg = WM_COMMAND then + if LOWORD(wParam) = IDOK then + hEdit = c_func(GetDlgItem, {hdlg, DialogEditID}) + len = 1 + c_func(SendMessage, {hEdit, WM_GETTEXTLENGTH, 0, 0}) + buf = allocate(len) + junk = c_func(SendMessage, {hEdit, WM_GETTEXT, len, buf}) + junk = c_func(EndDialog, {hdlg, buf}) + return 1 + elsif LOWORD(wParam) = IDCANCEL then + junk = c_func(EndDialog, {hdlg, 0}) + return 1 + end if + + elsif iMsg = WM_CLOSE then --closing dialog + junk = c_func(EndDialog, {hdlg, 0}) + end if + + return 0 +end function + +constant RunArgsCallback = callback("RunArgsProc") + +global procedure run_arguments() + integer junk + junk = DialogBoxIndirectParam(c_func(GetModuleHandle, {NULL}), { + --DLGTEMPLATE{style, exstyle, x, y, cx, cy, menu, wndclass, text} + {{WS_POPUP, WS_CAPTION, WS_SYSMENU, DS_MODALFRAME}, 0, + 50,50, 200,36, 0, 0, "Set Arguments"}, + --DLGITEMTEMPLATE{style, exstyle, x, y, cx, cy, id, dlgclass, text} + {{WS_CHILD, WS_VISIBLE, WS_BORDER, ES_AUTOHSCROLL}, 0, + 4,4, 192,12, DialogEditID, DIALOG_CLASS_EDIT, "tab arguments"}, + {{WS_CHILD, WS_VISIBLE, BS_PUSHBUTTON}, 0, + 104,20, 44,12, IDCANCEL, DIALOG_CLASS_BUTTON, "Cancel"}, + {{WS_CHILD, WS_VISIBLE, BS_DEFPUSHBUTTON}, 0, + 152,20, 44,12, IDOK, DIALOG_CLASS_BUTTON, "OK"} + }, + hMainWnd, + RunArgsCallback, + 0) + if junk then + set_tab_arguments(peek_string(junk)) + free(junk) + end if +end procedure + + +function RunInterpreterProc(atom hdlg, atom iMsg, atom wParam, atom lParam) + atom junk, hEdit, hLabel, len, buf + sequence interpreters + integer index + + --? {hdlg, iMsg, wParam, HIWORD(lParam), LOWORD(lParam)} + + if iMsg = WM_INITDIALOG then + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, IDOK}), + WM_SETFONT, captionFont, 0}) + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, IDCANCEL}), + WM_SETFONT, captionFont, 0}) + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, DialogOpenID}), + WM_SETFONT, captionFont, 0}) + hLabel = c_func(GetDlgItem, {hdlg, DialogLabelID}) + junk = c_func(SendMessage, {hLabel, WM_SETFONT, messageFont, 0}) + hEdit = c_func(GetDlgItem, {hdlg, DialogEditID}) + junk = c_func(SendMessage, {hEdit, WM_SETFONT, messageFont, 0}) + + interpreters = get_interpreters() + for i = 1 to length(interpreters) do + junk = c_func(SendMessage, {hEdit, CB_ADDSTRING, 0, alloc_string(interpreters[i])}) + end for + index = find(interpreter, interpreters) + if index then + junk = c_func(SendMessage, {hEdit, CB_SETCURSEL, index-1, 0}) + end if + + junk = c_func(SetFocus, {hEdit}) + junk = c_func(SendMessage, {hEdit, EM_SETSEL, 0, -1}) + + elsif iMsg = WM_COMMAND then + if LOWORD(wParam) = DialogOpenID then + sequence temp = GetOpenFileName({hMainWnd, 0, alloc_string("Executable Files (*.exe)"&0&"*.EXE"&0&0), 0, + "", 0, 0, + OFN_EXPLORER + OFN_PATHMUSTEXIST + OFN_FILEMUSTEXIST + OFN_HIDEREADONLY + , 0}) + if length(temp) then + temp = temp[2] -- just the filename + hEdit = c_func(GetDlgItem, {hdlg, DialogEditID}) + junk = c_func(SendMessage, {hEdit, CB_SELECTSTRING, -1, alloc_string(temp)}) + if junk = CB_ERR then + -- add a new filename since it wasn't found + junk = c_func(SendMessage, {hEdit, CB_INSERTSTRING, 0, alloc_string(temp)}) + junk = c_func(SendMessage, {hEdit, CB_SETCURSEL, 0, 0}) + end if + end if + free_strings() + elsif LOWORD(wParam) = IDOK then + hEdit = c_func(GetDlgItem, {hdlg, DialogEditID}) + len = 1 + c_func(SendMessage, {hEdit, WM_GETTEXTLENGTH, 0, 0}) + buf = allocate(len) + junk = c_func(SendMessage, {hEdit, WM_GETTEXT, len, buf}) + junk = c_func(EndDialog, {hdlg, buf}) + return 1 + elsif LOWORD(wParam) = IDCANCEL then + junk = c_func(EndDialog, {hdlg, 0}) + return 1 + end if + + elsif iMsg = WM_CLOSE then --closing dialog + junk = c_func(EndDialog, {hdlg, 0}) + end if + + return 0 +end function + +constant RunInterpreterCallback = callback("RunInterpreterProc") + +global procedure run_interpreter() + integer junk + junk = DialogBoxIndirectParam(c_func(GetModuleHandle, {NULL}), { + --DLGTEMPLATE{style, exstyle, x, y, cx, cy, menu, wndclass, text} + {{WS_POPUP, WS_CAPTION, WS_SYSMENU, DS_MODALFRAME}, 0, + 50,50, 200,56, 0, 0, "Set Interpreter"}, + --DLGITEMTEMPLATE{style, exstyle, x, y, cx, cy, id, dlgclass, text} + {{WS_CHILD, WS_VISIBLE}, 0, + 4,4, 192,20, DialogLabelID, DIALOG_CLASS_STATIC, + "Enter an interpreter to use to run programs, or select one from the list.\n"& + "Leave blank to use the default first item in the list."}, + {{WS_CHILD, WS_VISIBLE, WS_BORDER, WS_HSCROLL, CBS_AUTOHSCROLL, CBS_DROPDOWN}, 0, + 4,24, 176,12, DialogEditID, DIALOG_CLASS_COMBOBOX, "interpreter"}, + {{WS_CHILD, WS_VISIBLE, BS_PUSHBUTTON}, 0, + 184,24, 12,12, DialogOpenID, DIALOG_CLASS_BUTTON, "..."}, + {{WS_CHILD, WS_VISIBLE, BS_PUSHBUTTON}, 0, + 104,40, 44,12, IDCANCEL, DIALOG_CLASS_BUTTON, "Cancel"}, + {{WS_CHILD, WS_VISIBLE, BS_DEFPUSHBUTTON}, 0, + 152,40, 44,12, IDOK, DIALOG_CLASS_BUTTON, "OK"} + }, + hMainWnd, + RunInterpreterCallback, + 0) + if junk then + interpreter = peek_string(junk) + free(junk) + end if +end procedure + +procedure run_start(integer with_args) + atom result + sequence args + + -- save, no confirm + if save_if_modified(0) = 0 or length(file_name) = 0 then + return -- cancelled, or no name + end if + + run_file_name = file_name + reset_ex_err() + + args = quote_spaces(run_file_name) + if with_args then + if length(get_tab_arguments()) = 0 then + run_arguments() + end if + args &= ' ' & get_tab_arguments() + end if + + -- if interpreter is set, use it + -- elsif Eu file and eu.cfg points to eudir use it (.exw,.ew->euiw,exw, .ex,.e->eui,ex) + -- else let OS handle it + -- and if that fails use EUDIR or include_paths + + result = c_func(ShellExecute, { + hMainWnd, NULL, + alloc_string(get_eu_bin("")), + alloc_string(args), + alloc_string(dirname(run_file_name)), + SW_SHOWNORMAL}) + if result < 33 then + -- shellexecute failed + if match(".exw", lower(run_file_name)) or + match(".ew", lower(run_file_name)) then + system(quote_spaces(get_eu_bin("euiw")) & ' ' & args) + else + system(quote_spaces(get_eu_bin("eui")) & ' ' & args) + end if + end if + free_strings() +end procedure + +procedure run_convert(sequence name, sequence cmd) + atom result + + -- save, no confirm + if save_if_modified(0) = 0 or length(file_name) = 0 then + return -- cancelled, or no name + end if + result = c_func(ShellExecute, { + hMainWnd, NULL, + alloc_string(get_eu_bin(cmd)), + alloc_string(quote_spaces(file_name)), + alloc_string(dirname(file_name)), + SW_SHOWNORMAL}) + if result < 33 then + ui_message_box_error(name, cmd & " failed") + end if +end procedure + +function get_appdata_path() + atom junk, path + sequence appdata + path = allocate(MAX_PATH) + junk = c_func(SHGetFolderPath, { + NULL, + CSIDL_LOCAL_APPDATA + CSIDL_FLAG_CREATE, + NULL, + 0, + path}) + appdata = peek_string(path) + free(path) + return appdata +end function + +constant wee_conf_filename = get_appdata_path() & "\\wee_conf.txt" + + +function ColorsDialogProc(atom hdlg, atom iMsg, atom wParam, atom lParam) + atom junk, hEdit, len, buf + integer id + + --? {hdlg, iMsg, wParam, HIWORD(lParam), LOWORD(lParam)} + + if iMsg = WM_INITDIALOG then + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, IDOK}), + WM_SETFONT, captionFont, 0}) + for i = 1000 to 1016 do + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, i}), + WM_SETFONT, captionFont, 0}) + end for + for i = 0 to 6 do + if and_bits(bold_flags, power(2, i)) then + junk = BST_CHECKED + else + junk = BST_UNCHECKED + end if + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, 1010+i}), + BM_SETCHECK, junk, 0}) + end for + + elsif iMsg = WM_COMMAND then + id = LOWORD(wParam) + if id = IDOK then + junk = c_func(EndDialog, {hdlg, 1}) + return 1 + elsif id = IDCANCEL then + junk = c_func(EndDialog, {hdlg, 0}) + return 1 + elsif id = 1000 then + normal_color = ChooseColor(hMainWnd, normal_color) + reinit_all_edits() + return 0 + elsif id = 1001 then + background_color = ChooseColor(hMainWnd, background_color) + reinit_all_edits() + return 0 + elsif id = 1002 then + comment_color = ChooseColor(hMainWnd, comment_color) + reinit_all_edits() + return 0 + elsif id = 1003 then + string_color = ChooseColor(hMainWnd, string_color) + reinit_all_edits() + return 0 + elsif id = 1004 then + keyword_color = ChooseColor(hMainWnd, keyword_color) + reinit_all_edits() + return 0 + elsif id = 1005 then + builtin_color = ChooseColor(hMainWnd, builtin_color) + reinit_all_edits() + return 0 + elsif id = 1006 then + number_color = ChooseColor(hMainWnd, number_color) + reinit_all_edits() + return 0 + elsif id = 1007 then + bracelight_color = ChooseColor(hMainWnd, bracelight_color) + reinit_all_edits() + return 0 + elsif id = 1008 then + linenumber_color = ChooseColor(hMainWnd, linenumber_color) + reinit_all_edits() + return 0 + elsif id >= 1010 and id <= 1016 then + junk = power(2, id - 1010) + if and_bits(bold_flags, junk) then + bold_flags = and_bits(bold_flags, not_bits(junk)) + junk = BST_UNCHECKED + else + bold_flags = or_bits(bold_flags, junk) + junk = BST_CHECKED + end if + junk = c_func(SendMessage, { + c_func(GetDlgItem, {hdlg, id}), BM_SETCHECK, junk, 0}) + reinit_all_edits() + return 0 + end if + + elsif iMsg = WM_CLOSE then --closing dialog + junk = c_func(EndDialog, {hdlg, 0}) + end if + + return 0 +end function + +constant ColorsDialogCallback = callback("ColorsDialogProc") + +global procedure choose_colors() + integer junk + junk = DialogBoxIndirectParam(c_func(GetModuleHandle, {NULL}), { + --DLGTEMPLATE{style, exstyle, x, y, cx, cy, menu, wndclass, text} + {{WS_POPUP, WS_CAPTION, WS_SYSMENU, DS_MODALFRAME}, 0, + 50,50, 100,166, 0, 0, "Colors"}, + --DLGITEMTEMPLATE{style, exstyle, x, y, cx, cy, id, dlgclass, text} + {{WS_CHILD, WS_VISIBLE, BS_PUSHBUTTON}, 0, + 4,4, 64,12, 1000, DIALOG_CLASS_BUTTON, "Normal"}, + {{WS_CHILD, WS_VISIBLE, BS_PUSHBUTTON}, 0, + 4,20, 64,12, 1001, DIALOG_CLASS_BUTTON, "Background"}, + {{WS_CHILD, WS_VISIBLE, BS_PUSHBUTTON}, 0, + 4,36, 64,12, 1002, DIALOG_CLASS_BUTTON, "Comment"}, + {{WS_CHILD, WS_VISIBLE, BS_PUSHBUTTON}, 0, + 4,52, 64,12, 1003, DIALOG_CLASS_BUTTON, "String"}, + {{WS_CHILD, WS_VISIBLE, BS_PUSHBUTTON}, 0, + 4,68, 64,12, 1004, DIALOG_CLASS_BUTTON, "Keyword"}, + {{WS_CHILD, WS_VISIBLE, BS_PUSHBUTTON}, 0, + 4,84, 64,12, 1005, DIALOG_CLASS_BUTTON, "Built-in"}, + {{WS_CHILD, WS_VISIBLE, BS_PUSHBUTTON}, 0, + 4,100, 64,12, 1006, DIALOG_CLASS_BUTTON, "Number"}, + {{WS_CHILD, WS_VISIBLE, BS_PUSHBUTTON}, 0, + 4,116, 64,12, 1007, DIALOG_CLASS_BUTTON, "Brace Highlight"}, + {{WS_CHILD, WS_VISIBLE, BS_PUSHBUTTON}, 0, + 4,132, 64,12, 1008, DIALOG_CLASS_BUTTON, "Line Number"}, + + + {{WS_CHILD, WS_VISIBLE, BS_CHECKBOX}, 0, + 72,4, 32,12, 1010, DIALOG_CLASS_BUTTON, "Bold"}, + {{WS_CHILD, WS_VISIBLE, BS_CHECKBOX}, 0, + 72,36, 32,12, 1011, DIALOG_CLASS_BUTTON, "Bold"}, + {{WS_CHILD, WS_VISIBLE, BS_CHECKBOX}, 0, + 72,52, 32,12, 1012, DIALOG_CLASS_BUTTON, "Bold"}, + {{WS_CHILD, WS_VISIBLE, BS_CHECKBOX}, 0, + 72,68, 32,12, 1013, DIALOG_CLASS_BUTTON, "Bold"}, + {{WS_CHILD, WS_VISIBLE, BS_CHECKBOX}, 0, + 72,84, 32,12, 1014, DIALOG_CLASS_BUTTON, "Bold"}, + {{WS_CHILD, WS_VISIBLE, BS_CHECKBOX}, 0, + 72,100, 32,12, 1015, DIALOG_CLASS_BUTTON, "Bold"}, + {{WS_CHILD, WS_VISIBLE, BS_CHECKBOX}, 0, + 72,116, 32,12, 1016, DIALOG_CLASS_BUTTON, "Bold"}, + + {{WS_CHILD, WS_VISIBLE, BS_DEFPUSHBUTTON}, 0, + 4,150, 44,12, IDOK, DIALOG_CLASS_BUTTON, "Close"} + }, + hMainWnd, + ColorsDialogCallback, + 0) +end procedure + +function icon_from_xpm(sequence xpm) + sequence colors = repeat(0,255), pixels = {}, andbits = {} + integer w = 0, h = 0, clear = 0 + atom buf, handle, mask, iconinfo, hbmMask, hbmColor + + for i = 2 to length(xpm) do + if length(xpm[i]) >= 6 and xpm[i][3] = 'c' then + if equal(xpm[i][5..$], "None") then + clear = xpm[i][1] + else + colors[xpm[i][1]] = value(xpm[i][5..$]) + end if + else + w = length(xpm[i]) + h += 1 + for j = 1 to length(xpm[i]) do + if remainder(j, 8) = 1 then + andbits &= 0 + end if + if xpm[i][j] = clear then + andbits[$] = or_bits(andbits[$], power(2, 7-and_bits(j-1,7))) + pixels &= 0 + else + pixels &= #FF000000 + colors[xpm[i][j]][2] + end if + end for + end if + end for + mask = allocate(length(andbits)) + poke(mask, andbits) + buf = allocate(length(pixels)*4) + poke4(buf, pixels) + hbmMask = c_func(CreateBitmap, {w, h, 1, 1, mask}) + hbmColor = c_func(CreateBitmap, {w, h, 1, 32, buf}) + iconinfo = allocate_pack("iddpp", {1,0,0,hbmMask,hbmColor}) + handle = c_func(CreateIconIndirect, {iconinfo}) + c_func(DeleteObject, {hbmMask}) + c_func(DeleteObject, {hbmColor}) + free(buf) + free(mask) + free(iconinfo) + + return handle +end function + +include weeicon.e +constant wee_icon = icon_from_xpm(wee_xpm) + +function IndentDialogProc(atom hdlg, atom iMsg, atom wParam, atom lParam) + atom junk, len, buf + integer id, tab_width, indent_width, use_tabs, check + sequence val + + --? {hdlg, iMsg, wParam, HIWORD(lParam), LOWORD(lParam)} + + if iMsg = WM_INITDIALOG then + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, IDOK}), + WM_SETFONT, captionFont, 0}) + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, IDCANCEL}), + WM_SETFONT, captionFont, 0}) + for i = 1000 to 1005 do + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, i}), + WM_SETFONT, captionFont, 0}) + end for + hDlg = hdlg + + tab_width = c_func(SendMessage, {hedit, SCI_GETTABWIDTH, 0, 0}) + indent_width = c_func(SendMessage, {hedit, SCI_GETINDENT, 0, 0}) + use_tabs = c_func(SendMessage, {hedit, SCI_GETUSETABS, 0, 0}) + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, 1001}), + WM_SETTEXT, 0, alloc_string(sprintf("%d", {tab_width}))}) + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, 1003}), + WM_SETTEXT, 0, alloc_string(sprintf("%d", {indent_width}))}) + + if use_tabs then + check = BST_CHECKED + else + check = BST_UNCHECKED + end if + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, 1004}), + BM_SETCHECK, check, 0}) + if indentation_guides then + check = BST_CHECKED + else + check = BST_UNCHECKED + end if + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, 1005}), + BM_SETCHECK, check, 0}) + + elsif iMsg = WM_COMMAND then + id = LOWORD(wParam) + if id = IDOK then + buf = allocate(16) + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, 1001}), + WM_GETTEXT, 16, buf}) + val = value(peek_string(buf)) + if val[1] = 0 and integer(val[2]) then + tab_width = val[2] + else + tab_width = 0 + end if + junk = c_func(SendMessage, {c_func(GetDlgItem, {hdlg, 1003}), + WM_GETTEXT, 16, buf}) + val = value(peek_string(buf)) + if val[1] = 0 and integer(val[2]) then + indent_width = val[2] + else + indent_width = 0 + end if + free(buf) + + if indent_width < 1 or indent_width > 8 or + tab_width < 1 or tab_width > 8 then + return 0 + end if + + use_tabs = BST_CHECKED = c_func(SendMessage, { + c_func(GetDlgItem, {hdlg, 1004}), BM_GETCHECK, 0, 0}) + indentation_guides = BST_CHECKED = c_func(SendMessage, { + c_func(GetDlgItem, {hdlg, 1005}), BM_GETCHECK, 0, 0}) + + junk = c_func(SendMessage, {hedit, SCI_SETTABWIDTH, tab_width, 0}) + junk = c_func(SendMessage, {hedit, SCI_SETINDENT, indent_width, 0}) + junk = c_func(SendMessage, {hedit, SCI_SETUSETABS, use_tabs, 0}) + reinit_all_edits() + + junk = c_func(EndDialog, {hdlg, 1}) + return 1 + elsif id = IDCANCEL then + junk = c_func(EndDialog, {hdlg, 0}) + return 1 + elsif id = 1004 or id = 1005 then + junk = c_func(SendMessage, { + c_func(GetDlgItem, {hdlg, id}), BM_GETCHECK, 0, 0}) + if junk = BST_CHECKED then + junk = BST_UNCHECKED + else + junk = BST_CHECKED + end if + junk = c_func(SendMessage, { + c_func(GetDlgItem, {hdlg, id}), BM_SETCHECK, junk, 0}) + end if + + elsif iMsg = WM_CLOSE then --closing dialog + junk = c_func(EndDialog, {hdlg, 0}) + hDlg = 0 + end if + + return 0 +end function + +constant IndentDialogCallback = callback("IndentDialogProc") + +global procedure indent_dialog() + integer junk + junk = DialogBoxIndirectParam(c_func(GetModuleHandle, {NULL}), { + --DLGTEMPLATE{style, exstyle, x, y, cx, cy, menu, wndclass, text} + {{WS_POPUP, WS_CAPTION, WS_SYSMENU, DS_MODALFRAME}, 0, + 50,50, 100,82, 0, 0, "Indent"}, + --DLGITEMTEMPLATE{style, exstyle, x, y, cx, cy, id, dlgclass, text} + + {{WS_CHILD, WS_VISIBLE}, 0, + 4,4, 44,12, 1002, DIALOG_CLASS_STATIC, "Indent size"}, + {{WS_CHILD, WS_VISIBLE, WS_BORDER, ES_AUTOHSCROLL, ES_NUMBER}, 0, + 52,4, 44,12, 1003, DIALOG_CLASS_EDIT, ""}, + + {{WS_CHILD, WS_VISIBLE, BS_CHECKBOX}, 0, + 4,20, 92,12, 1005, DIALOG_CLASS_BUTTON, "Show indentation guides"}, + + {{WS_CHILD, WS_VISIBLE, BS_CHECKBOX}, 0, + 4,34, 92,12, 1004, DIALOG_CLASS_BUTTON, "Use tabs in indentation"}, + + {{WS_CHILD, WS_VISIBLE}, 0, + 4,50, 44,12, 1000, DIALOG_CLASS_STATIC, "Tab size"}, + {{WS_CHILD, WS_VISIBLE, WS_BORDER, ES_AUTOHSCROLL, ES_NUMBER}, 0, + 52,50, 44,12, 1001, DIALOG_CLASS_EDIT, ""}, + + {{WS_CHILD, WS_VISIBLE, BS_PUSHBUTTON}, 0, + 4,66, 44,12, IDCANCEL, DIALOG_CLASS_BUTTON, "Cancel"}, + {{WS_CHILD, WS_VISIBLE, BS_DEFPUSHBUTTON}, 0, + 52,66, 44,12, IDOK, DIALOG_CLASS_BUTTON, "OK"} + }, + hMainWnd, + IndentDialogCallback, + 0) +end procedure + + + +procedure init_fonts() + atom junk, lf_facesize, lf_size, size, ncm, lf, + lfCaptionFont, lfSmCaptionFont, lfMenuFont, lfStatusFont, lfMessageFont + + lf_facesize = 32 + lf_size = 4*5 + 8 + lf_facesize + size = 4 + 4*5 + lfCaptionFont = size + size += lf_size + 4*2 + lfSmCaptionFont = size + size += lf_size + 4*2 + lfMenuFont = size + size += lf_size + lfStatusFont = size + size += lf_size + lfMessageFont = size + size += lf_size + ncm = allocate(size) + + poke4(ncm, size) + poke4(ncm+lfCaptionFont, -1) + poke4(ncm+lfSmCaptionFont, -1) + poke4(ncm+lfMenuFont, -1) + poke4(ncm+lfStatusFont, -1) + poke4(ncm+lfMessageFont, -1) + + junk = c_func(SystemParametersInfo, {SPI_GETNONCLIENTMETRICS, size, ncm, 0}) + + captionFont = c_func(CreateFontIndirect, {ncm+lfCaptionFont}) + smCaptionFont = c_func(CreateFontIndirect, {ncm+lfSmCaptionFont}) + menuFont = c_func(CreateFontIndirect, {ncm+lfMenuFont}) + statusFont = c_func(CreateFontIndirect, {ncm+lfStatusFont}) + messageFont = c_func(CreateFontIndirect, {ncm+lfMessageFont}) + free(ncm) +end procedure + +procedure process_dropfiles(atom hDrop) + integer count, len, size + atom buf, junk + + -- get the number of files dropped + count = c_func(DragQueryFile, {hDrop, #FFFFFFFF, NULL, 0}) + for i = 0 to count-1 do + -- get the length of the indexed filename and null-terminator + size = c_func(DragQueryFile, {hDrop, i, NULL, 0}) + 1 + buf = allocate(size) + -- get the indexed filename into our buffer and open it + junk = c_func(DragQueryFile, {hDrop, i, buf, size}) + open_file(peek_string(buf), 0) + free(buf) + end for + c_proc(DragFinish, {hDrop}) +end procedure + + +integer doing_setfocus_checks +doing_setfocus_checks = 0 + +global function WndProc(atom hwnd, atom iMsg, atom wParam, atom lParam) +-- callback routine to handle Window class + atom junk, hwndFrom, code + integer rc + rc = 0 + + if hwnd != hMainWnd then + --? {hwnd, iMsg, wParam, lParam} + return c_func(DefWindowProc, {hwnd, iMsg, wParam, lParam}) + end if + if iMsg = WM_NOTIFY then + sequence nmhdr = unpack(lParam, "ppi") + -- lParam is pointer to NMHDR { HWND hwndFrom; UINT_PTR idFrom; UINT code; } + hwndFrom = nmhdr[1] + code = nmhdr[3] + --printf(1, "hwndFrom=%x idFrom=%x code=%x %x %x\n", nmhdr & {LOWORD(code), HIWORD(code)}) + + if hwndFrom = hedit then + sci_notify(c_func(SendMessage, {hedit, SCI_GETDIRECTPOINTER, 0, 0}), 0, lParam, 0) + return rc + + elsif hwndFrom = htabs then + if code = TCN_SELCHANGE then + select_tab(1 + c_func(SendMessage, {htabs, TCM_GETCURSEL, 0, 0})) + elsif code = TCN_SELCHANGING then + -- unhighlight the current tab + junk = c_func(SendMessage, {htabs, TCM_HIGHLIGHTITEM, + c_func(SendMessage, {htabs, TCM_GETCURSEL, 0, 0}), 0}) + elsif code = NM_RCLICK then + rightclick_tab() + end if + elsif hwndFrom = htooltip and code = TTN_NEEDTEXT then + junk = allocate_pack("zdppddddps", { -- TOOLINFO + TTF_IDISHWND + TTF_SUBCLASS, -- uFlags + hMainWnd, -- hwnd + htabs, -- uId + 0,0,0,0, -- rect + 0, -- hinst + file_name -- lpszText + }) + c_func(SendMessage, {htooltip, TTM_UPDATETIPTEXT, 0, junk}) + free(junk) + end if + end if + + if iMsg = WM_CREATE then + return rc + elsif iMsg = WM_DESTROY then + c_proc(PostQuitMessage, {0}) + get_window_size() + save_wee_conf(wee_conf_filename) + return rc + elsif iMsg = WM_SIZE then --resize the rich edit control to fit the window + c_proc(MoveWindow, {hedit, 0, tab_h, LOWORD(lParam), HIWORD(lParam)-tab_h, 1}) + c_proc(MoveWindow, {hstatus, LOWORD(lParam)-64, 2, 64, tab_h-4, 1}) + c_proc(MoveWindow, {htabs, 0, 0, LOWORD(lParam), tab_h, 1}) + return rc + elsif iMsg = WM_CLOSE then --closing window + if save_modified_tabs() then + junk = c_func(DestroyWindow, {hwnd}) + end if + return rc + elsif iMsg = WM_SETFOCUS then --always pass focus on to rich edit control + if not doing_setfocus_checks then + doing_setfocus_checks = 1 + check_ex_err() + check_externally_modified_tabs() + junk = c_func(SetFocus, {hedit}) + doing_setfocus_checks = 0 + end if + return rc + elsif iMsg = WM_COMMAND then + if lParam = 0 then + if wParam = File_New then + new_file() + return rc + elsif wParam = File_Open then + open_file("", 0) + return rc + elsif wParam = File_Save then + save_if_modified(0) -- no confirm + return rc + elsif wParam = File_SaveAs then + junk = save_file_as() + return rc + elsif wParam = File_Close then + close_tab() + return rc + elsif wParam = File_Exit then + return c_func(SendMessage, {hwnd, WM_CLOSE, 0, 0}) + elsif wParam = Edit_Undo then + return c_func(SendMessage, {hedit, WM_UNDO, 0, 0}) + elsif wParam = Edit_Redo then + return c_func(SendMessage, {hedit, SCI_REDO, 0, 0}) + elsif wParam = Edit_Cut then + return c_func(SendMessage, {hedit, WM_CUT, 0, 0}) + elsif wParam = Edit_Copy then + return c_func(SendMessage, {hedit, WM_COPY, 0, 0}) + elsif wParam = Edit_Paste then + return c_func(SendMessage, {hedit, WM_PASTE, 0, 0}) + elsif wParam = Edit_Clear then + return c_func(SendMessage, {hedit, WM_CLEAR, 0, 0}) + elsif wParam = Edit_SelectAll then + return c_func(SendMessage, {hedit, EM_SETSEL, 0, -1}) + elsif wParam = Edit_ToggleComment then + toggle_comment() + return rc + elsif wParam = Search_Find then + sequence s = get_selection() + if length(s) then + find_phrase = s + end if + hFindDlg = FindText(hMainWnd,0,FR_DOWN,find_phrase) + return rc + elsif wParam = Search_Find_Next then + if length(find_phrase) = 0 then + sequence s = get_selection() + if length(s) then + find_phrase = s + end if + hFindDlg = FindText(hMainWnd,0,FR_DOWN,find_phrase) + else + search_find(find_phrase, 0) + end if + return rc + elsif wParam = Search_Find_Prev then + search_find(find_phrase, 1) + return rc + elsif wParam = Search_Replace then + sequence s = get_selection() + if length(s) then + find_phrase = s + end if + hFindDlg = ReplaceText(hMainWnd,0,FR_DOWN,find_phrase,replace_phrase) + return rc + elsif wParam = View_Subs then + view_subroutines() + return rc + elsif wParam = View_Error then + ui_view_error() + return rc + elsif wParam = View_Completions then + view_completions() + return rc + elsif wParam = View_Declaration then + view_declaration() + return rc + elsif wParam = View_SubArgs then + view_subroutine_arguments() + return rc + elsif wParam = View_GoBack then + go_back() + return rc + elsif wParam = Run_Start then + run_start(0) + return rc + elsif wParam = Run_WithArgs then + run_start(1) + return rc + elsif wParam = Run_Arguments then + run_arguments() + return rc + elsif wParam = Run_Interpreter then + run_interpreter() + elsif wParam = Run_Bind then + run_convert("Bind", "eubind") + return rc + elsif wParam = Run_Shroud then + run_convert("Shroud", "eushroud") + return rc + elsif wParam = Run_Translate then + run_convert("Translate", "euc") + return rc + elsif wParam = Options_Font then + sequence s = ChooseFont(hMainWnd, font_name, font_height) + if length(s) then + font_name = s[1] + font_height = s[2] + reinit_all_edits() + end if + return rc + elsif wParam = Options_LineNumbers then + line_numbers = not line_numbers + reinit_all_edits() + return c_func(CheckMenuItem, {hoptionsmenu, Options_LineNumbers, MF_CHECKED*line_numbers}) + elsif wParam = Options_SortedSubs then + sorted_subs = not sorted_subs + return c_func(CheckMenuItem, {hoptionsmenu, Options_SortedSubs, MF_CHECKED*sorted_subs}) + elsif wParam = Options_Colors then + choose_colors() + return rc + elsif wParam = Options_LineWrap then + line_wrap = not line_wrap + reinit_all_edits() + return c_func(CheckMenuItem, {hoptionsmenu, Options_LineWrap, MF_CHECKED*line_wrap}) + elsif wParam = Options_ReopenTabs then + reopen_tabs = not reopen_tabs + return c_func(CheckMenuItem, {hoptionsmenu, Options_ReopenTabs, MF_CHECKED*reopen_tabs}) + elsif wParam = Options_CompleteStatements then + complete_statements = not complete_statements + return c_func(CheckMenuItem, {hoptionsmenu, Options_CompleteStatements, MF_CHECKED*complete_statements}) + elsif wParam = Options_CompleteBraces then + complete_braces = not complete_braces + return c_func(CheckMenuItem, {hoptionsmenu, Options_CompleteBraces, MF_CHECKED*complete_braces}) + elsif wParam = Options_ErrorIndicators then + auto_indicator = not auto_indicator + return c_func(CheckMenuItem, {hoptionsmenu, Options_ErrorIndicators, MF_CHECKED*auto_indicator}) + elsif wParam = Options_Indent then + indent_dialog() + return rc + elsif wParam = Help_About then + about_box() + return rc + elsif wParam = Help_Tutorial then + open_tutorial() + return rc + elsif wParam = Help_ReleaseNotes then + release_notes() + return rc + elsif wParam = Help_Context then + context_help() + return rc + elsif wParam > File_Recent and wParam <= File_Recent + max_recent_files then + open_recent(wParam - File_Recent) + elsif wParam >= Select_Tab and wParam <= Select_Tab + 9 then + select_tab(wParam - Select_Tab + 1) + elsif wParam = Select_Prev_Tab then + select_tab(get_prev_tab()) + elsif wParam = Select_Next_Tab then + select_tab(get_next_tab()) + else + printf(1, "%d %d\n", {wParam, lParam}) + end if + else + --printf(1, "HIWORD:%d LOWORD:%d LPARAM:%d\n", {HIWORD(wParam), LOWORD(wParam), lParam}) + end if + elsif iMsg = WM_FIND then -- find/replace dialog + process_find(lParam) + elsif iMsg = WM_DROPFILES then + process_dropfiles(wParam) + else + --printf(1, "hwnd=%x iMsg=%d #%x wParam=%d lParam=%d\n", {hwnd, iMsg, iMsg, wParam, lParam}) + + end if + + return c_func(DefWindowProc, {hwnd, iMsg, wParam, lParam}) +end function + +-- The scintilla edit control doesn't offer a way to hook accelerator keys +-- so we have to process messages in our message loop, and intercept and +-- rewrite them into WM_COMMAND messages for the main window handle. +procedure translate_editor_keys(atom msg) + atom hwnd, iMsg, wParam, lParam + sequence m + integer ctrl, shift + + m = unpack(msg, "pdpp") + + hwnd = m[1] + iMsg = m[2] + wParam = m[3] + lParam = m[4] + + if hwnd != hedit then + if hwnd = htabs and iMsg = WM_MBUTTONDOWN then + atom point + integer tab + point = allocate(12) + poke4(point, {LOWORD(lParam), HIWORD(lParam), 0}) + tab = c_func(SendMessage, {htabs, TCM_HITTEST, 0, point}) + free(point) + if tab >= 0 then + -- middle click to close tab + select_tab(tab + 1) + m = {hMainWnd, WM_COMMAND, File_Close, 0} + pack(msg, "pdpp", m) + end if + elsif hwnd = htabs and iMsg = WM_MOUSEWHEEL then + -- select prev/next tabs when scrolled by mouse wheel + if HIWORD(wParam) < #8000 then + m = {hMainWnd, WM_COMMAND, Select_Prev_Tab, 0} + else + m = {hMainWnd, WM_COMMAND, Select_Next_Tab, 0} + end if + pack(msg, "pdpp", m) + end if + return + end if + + if iMsg = WM_CHAR then + shift = and_bits(c_func(GetKeyState, {VK_SHIFT}), #8000) + ctrl = and_bits(c_func(GetKeyState, {VK_CONTROL}), #8000) + --printf(1, "%x %x %x %x\n", {hwnd, iMsg, wParam, lParam}) + if wParam = 27 then -- Esc + m = {hMainWnd, WM_COMMAND, View_GoBack, 0} + elsif not ctrl then + -- control key is not pressed + elsif wParam = #13 then -- Ctrl+S + m = {hMainWnd, WM_COMMAND, File_Save, 0} + elsif wParam = #6 then -- Ctrl+F + m = {hMainWnd, WM_COMMAND, Search_Find, 0} + elsif wParam = #12 then -- Ctrl+R + m = {hMainWnd, WM_COMMAND, Search_Replace, 0} + elsif wParam = #7 then -- Ctrl+G + if shift then + m = {hMainWnd, WM_COMMAND, Search_Find_Prev, 0} + else + m = {hMainWnd, WM_COMMAND, Search_Find_Next, 0} + end if + elsif wParam = #17 then -- Ctrl+W + m = {hMainWnd, WM_COMMAND, File_Close, 0} + elsif wParam = #D then -- Ctrl+M + m = {hMainWnd, WM_COMMAND, Edit_ToggleComment, 0} + elsif wParam = #E then -- Ctrl+N + m = {hMainWnd, WM_COMMAND, File_New, 0} + elsif wParam = #F then -- Ctrl+O + m = {hMainWnd, WM_COMMAND, File_Open, 0} + elsif wParam = #11 then -- Ctrl+Q + m = {hMainWnd, WM_COMMAND, File_Exit, 0} + elsif wParam = VK_SPACE then + m = {hMainWnd, WM_COMMAND, View_Completions, 0} + elsif wParam = 26 and shift then + m = {hMainWnd, WM_COMMAND, Edit_Redo, 0} + elsif wParam = 25 then -- Ctrl+Y + m = {hMainWnd, WM_COMMAND, Edit_Redo, 0} + else + return + end if + elsif iMsg = WM_KEYUP then + shift = and_bits(c_func(GetKeyState, {VK_SHIFT}), #8000) + ctrl = and_bits(c_func(GetKeyState, {VK_CONTROL}), #8000) + if wParam = VK_F5 and shift then + m = {hMainWnd, WM_COMMAND, Run_WithArgs, 0} + elsif wParam = VK_F5 then + m = {hMainWnd, WM_COMMAND, Run_Start, 0} + elsif wParam = VK_F4 and ctrl then + m = {hMainWnd, WM_COMMAND, File_Close, 0} + elsif wParam = VK_F4 then + m = {hMainWnd, WM_COMMAND, View_Error, 0} + elsif wParam = VK_F3 then + if shift then + m = {hMainWnd, WM_COMMAND, Search_Find_Prev, 0} + elsif ctrl then + m = {hMainWnd, WM_COMMAND, Search_Find, 0} + else + m = {hMainWnd, WM_COMMAND, Search_Find_Next, 0} + end if + elsif wParam = VK_F2 and ctrl then + m = {hMainWnd, WM_COMMAND, View_Declaration, 0} + elsif wParam = VK_F2 and shift then + m = {hMainWnd, WM_COMMAND, View_SubArgs, 0} + elsif wParam = VK_F2 then + m = {hMainWnd, WM_COMMAND, View_Subs, 0} + elsif wParam = #5A and ctrl and shift then + m = {hMainWnd, WM_COMMAND, Edit_Redo, 0} + elsif (wParam = VK_PRIOR or (wParam = VK_TAB and shift)) and ctrl then + m = {hMainWnd, WM_COMMAND, Select_Prev_Tab, 0} + elsif (wParam = VK_NEXT or wParam = VK_TAB) and ctrl then + m = {hMainWnd, WM_COMMAND, Select_Next_Tab, 0} + elsif wParam = VK_F1 then + m = {hMainWnd, WM_COMMAND, Help_Context, 0} + else + return + end if + elsif iMsg = WM_SYSCHAR then + if wParam >= '1' and wParam <= '9' then + m = {hMainWnd, WM_COMMAND, wParam - '1' + Select_Tab, 0} + else + return + end if + else + return + end if + --printf(1, "%x %x %x %x\n", m) + pack(msg, "pdpp", m) +end procedure + + +constant AppName = "WeeEditor" + + +global procedure ui_main() +-- main routine + atom msg + integer id + atom junk, tcitem + + init_fonts() + + msg = allocate(SIZE_OF_MESSAGE) + + id = routine_id("WndProc") + if id = -1 then + puts(1, "routine_id failed!\n") + abort(1) + end if + class = RegisterClass({ + or_bits(CS_HREDRAW, CS_VREDRAW), + call_back(id), -- get 32-bit address for callback + 0, + 0, + 0, + c_func(LoadIcon, {NULL, IDI_APPLICATION}), + c_func(LoadCursor, {NULL, IDC_ARROW}), + c_func(GetStockObject, {WHITE_BRUSH}), + NULL, + AppName, + c_func(LoadIcon, {NULL, IDI_APPLICATION})}) + if class = 0 then + puts(1, "Couldn't register class\n") + abort(1) + end if + + -- this is required for FindText,ReplaceText common dialogs to work + WM_FIND = c_func(RegisterWindowMessage,{alloc_string(FINDMSGSTRING)}) + +-- menu creation +-- file menu + hfilemenu = c_func(CreateMenu, {}) + junk = c_func(AppendMenu, {hfilemenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + File_New, alloc_string("&New\tCtrl+N")}) + junk = c_func(AppendMenu, {hfilemenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + File_Open, alloc_string("&Open...\tCtrl+O")}) + junk = c_func(AppendMenu, {hfilemenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + File_Save, alloc_string("&Save\tCtrl+S")}) + junk = c_func(AppendMenu, {hfilemenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + File_SaveAs, alloc_string("Save &As...")}) + junk = c_func(AppendMenu, {hfilemenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + File_Close, alloc_string("&Close\tCtrl+W")}) +-- junk = c_func(AppendMenu, {hfilemenu, MF_BYPOSITION + MF_SEPARATOR, 0, 0}) +-- junk = c_func(AppendMenu, {hfilemenu, MF_BYPOSITION + MF_STRING + MF_GRAYED, +-- File_Print, alloc_string("Print...")}) +-- junk = c_func(AppendMenu, {hfilemenu, MF_BYPOSITION + MF_STRING + MF_GRAYED, +-- File_PageSetup, alloc_string("Page Setup...")}) + junk = c_func(AppendMenu, {hfilemenu, MF_BYPOSITION + MF_SEPARATOR, 0, 0}) + junk = c_func(AppendMenu, {hfilemenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + File_Exit, alloc_string("E&xit\tAlt+F4")}) +-- edit menu + heditmenu = c_func(CreateMenu, {}) + junk = c_func(AppendMenu, {heditmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Edit_Undo, alloc_string("U&ndo\tCtrl+Z")}) + junk = c_func(AppendMenu, {heditmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Edit_Redo, alloc_string("&Redo\tShift+Ctrl+Z")}) + junk = c_func(AppendMenu, {heditmenu, MF_BYPOSITION + MF_SEPARATOR, 0, 0}) + junk = c_func(AppendMenu, {heditmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Edit_Cut, alloc_string("Cu&t\tCtrl+X")}) + junk = c_func(AppendMenu, {heditmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Edit_Copy, alloc_string("&Copy\tCtrl+C")}) + junk = c_func(AppendMenu, {heditmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Edit_Paste, alloc_string("&Paste\tCtrl+V")}) + junk = c_func(AppendMenu, {heditmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Edit_Clear, alloc_string("Cl&ear\tDel")}) + junk = c_func(AppendMenu, {heditmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Edit_SelectAll, alloc_string("Select &All\tCtrl+A")}) + junk = c_func(AppendMenu, {heditmenu, MF_BYPOSITION + MF_SEPARATOR, 0, 0}) + junk = c_func(AppendMenu, {heditmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Edit_ToggleComment, alloc_string("Toggle Co&mment\tCtrl+M")}) +-- search menu + hsearchmenu = c_func(CreateMenu, {}) + junk = c_func(AppendMenu, {hsearchmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Search_Find, alloc_string("&Find...\tCtrl+F3")}) + junk = c_func(AppendMenu, {hsearchmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Search_Find_Next, alloc_string("Find &Next\tF3")}) + junk = c_func(AppendMenu, {hsearchmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Search_Find_Prev, alloc_string("Find &Previous\tShift+F3")}) + junk = c_func(AppendMenu, {hsearchmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Search_Replace, alloc_string("&Replace...")}) +-- view menu + hviewmenu = c_func(CreateMenu, {}) + junk = c_func(AppendMenu, {hviewmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + View_Subs, alloc_string("&Subroutines...\tF2")}) + junk = c_func(AppendMenu, {hviewmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + View_Declaration, alloc_string("&Declaration\tCtrl+F2")}) + junk = c_func(AppendMenu, {hviewmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + View_SubArgs, alloc_string("Subroutine &Arguments...\tShift+F2")}) + junk = c_func(AppendMenu, {hviewmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + View_Completions, alloc_string("&Completions...\tCtrl+Space")}) + junk = c_func(AppendMenu, {hviewmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + View_Error, alloc_string("Goto &Error\tF4")}) + junk = c_func(AppendMenu, {hviewmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + View_GoBack, alloc_string("Go &Back\tEsc")}) +-- run menu + hrunmenu = c_func(CreateMenu, {}) + junk = c_func(AppendMenu, {hrunmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Run_Start, alloc_string("&Start\tF5")}) + junk = c_func(AppendMenu, {hrunmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Run_WithArgs, alloc_string("Start with &Arguments\tShift-F5")}) + junk = c_func(AppendMenu, {hrunmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Run_Arguments, alloc_string("Set Arguments...")}) + junk = c_func(AppendMenu, {hrunmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Run_Interpreter, alloc_string("Set Interpreter...")}) + junk = c_func(AppendMenu, {hrunmenu, MF_BYPOSITION + MF_SEPARATOR, 0, 0}) + junk = c_func(AppendMenu, {hrunmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Run_Bind, alloc_string("&Bind")}) + junk = c_func(AppendMenu, {hrunmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Run_Shroud, alloc_string("S&hroud")}) + junk = c_func(AppendMenu, {hrunmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Run_Translate, alloc_string("&Translate and Compile")}) +-- options menu + hoptionsmenu = c_func(CreateMenu, {}) + junk = c_func(AppendMenu, {hoptionsmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Options_Font, alloc_string("&Font...")}) + junk = c_func(AppendMenu, {hoptionsmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Options_LineNumbers, alloc_string("&Line Numbers")}) + junk = c_func(AppendMenu, {hoptionsmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Options_SortedSubs, alloc_string("&Sort View Subroutines")}) + junk = c_func(AppendMenu, {hoptionsmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Options_Colors, alloc_string("&Colors...")}) + junk = c_func(AppendMenu, {hoptionsmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Options_LineWrap, alloc_string("Line &Wrap")}) + junk = c_func(AppendMenu, {hoptionsmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Options_ReopenTabs, alloc_string("&Reopen Tabs Next Time")}) + junk = c_func(AppendMenu, {hoptionsmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Options_CompleteStatements, alloc_string("Complete Statements")}) + junk = c_func(AppendMenu, {hoptionsmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Options_CompleteBraces, alloc_string("Complete Braces")}) + junk = c_func(AppendMenu, {hoptionsmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Options_Indent, alloc_string("&Indents...")}) + junk = c_func(AppendMenu, {hoptionsmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Options_ErrorIndicators, alloc_string("Error Indicators")}) +-- help menu + hhelpmenu = c_func(CreateMenu, {}) + junk = c_func(AppendMenu, {hhelpmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Help_About, alloc_string("&About...")}) + junk = c_func(AppendMenu, {hhelpmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Help_ReleaseNotes, alloc_string("&Release Notes...")}) + junk = c_func(AppendMenu, {hhelpmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Help_Tutorial, alloc_string("&Tutorial")}) + junk = c_func(AppendMenu, {hhelpmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + Help_Context, alloc_string("&Help\tF1")}) +-- main menu + hmenu = c_func(CreateMenu, {}) + junk = c_func(AppendMenu, {hmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED + MF_POPUP, + hfilemenu, alloc_string("&File")}) + junk = c_func(AppendMenu, {hmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED + MF_POPUP, + heditmenu, alloc_string("&Edit")}) + junk = c_func(AppendMenu, {hmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED + MF_POPUP, + hsearchmenu, alloc_string("&Search")}) + junk = c_func(AppendMenu, {hmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED + MF_POPUP, + hviewmenu, alloc_string("&View")}) + junk = c_func(AppendMenu, {hmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED + MF_POPUP, + hrunmenu, alloc_string("&Run")}) + junk = c_func(AppendMenu, {hmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED + MF_POPUP, + hoptionsmenu, alloc_string("&Options")}) + junk = c_func(AppendMenu, {hmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED + MF_POPUP, + hhelpmenu, alloc_string("&Help")}) + +-- tab popup menu + htabmenu = c_func(CreatePopupMenu) + junk = c_func(AppendMenu, {htabmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + File_Save, alloc_string("Save")}) + junk = c_func(AppendMenu, {htabmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + File_SaveAs, alloc_string("Save As")}) + junk = c_func(AppendMenu, {htabmenu, MF_BYPOSITION + MF_STRING + MF_ENABLED, + File_Close, alloc_string("Close")}) + + free_strings() -- garbage collect menu strings + + load_wee_conf(wee_conf_filename) + + -- set the recent items on the file menu + ui_refresh_file_menu(recent_files) + + -- set the checkmark on the Line Numbers menu item + c_func(CheckMenuItem, {hoptionsmenu, Options_LineNumbers, MF_CHECKED*line_numbers}) + c_func(CheckMenuItem, {hoptionsmenu, Options_SortedSubs, MF_CHECKED*sorted_subs}) + c_func(CheckMenuItem, {hoptionsmenu, Options_LineWrap, MF_CHECKED*line_wrap}) + c_func(CheckMenuItem, {hoptionsmenu, Options_ReopenTabs, MF_CHECKED*reopen_tabs}) + c_func(CheckMenuItem, {hoptionsmenu, Options_CompleteStatements, MF_CHECKED*complete_statements}) + c_func(CheckMenuItem, {hoptionsmenu, Options_CompleteBraces, MF_CHECKED*complete_braces}) + c_func(CheckMenuItem, {hoptionsmenu, Options_ErrorIndicators, MF_CHECKED*auto_indicator}) + +-- window creation + hMainWnd = CreateWindow({ + 0, -- extended style + AppName, -- window class name + "", -- window caption + WS_OVERLAPPEDWINDOW, -- window style + x_pos, -- initial x position + y_pos, -- initial y position + x_size, -- initial x size + y_size, -- initial y size + NULL, -- parent window handle + hmenu, -- window menu handle + 0 , --hInstance // program instance handle + NULL}) -- creation parameters + + junk = c_func(LoadLibrary, {alloc_string("RICHED32.DLL")}) --needed for richedit + + hstatus = CreateWindow({0, "STATIC", "static", + {WS_CHILD,WS_VISIBLE,SS_RIGHT}, + 0,0,0,0, -- set by resize + hMainWnd, + NULL, + 0, + NULL}) + junk = c_func(SendMessage, {hstatus, WM_SETFONT, statusFont, 0}) + + htabs = CreateWindow({0,"SysTabControl32", "tabs", + {WS_CHILD,WS_VISIBLE,TCS_FOCUSNEVER}, + 0,0,200,20, -- set by resize + hMainWnd, + NULL, + 0, + NULL}) + junk = c_func(SendMessage, {htabs, WM_SETFONT, statusFont, 0}) + + htooltip = CreateWindow({0, "tooltips_class32", 0, + {WS_POPUP,TTS_ALWAYSTIP}, + CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, + hMainWnd, NULL, + 0, NULL}) + + --printf(1, "hMainWnd=%x hstatus=%x htabs=%x\n", {hMainWnd, hstatus, htabs}) + if hMainWnd = 0 or hstatus = 0 or htabs = 0 or htooltip = 0 then + puts(1, "Couldn't CreateWindow\n") + abort(1) + end if + + c_func(SendMessage, {hMainWnd, WM_SETICON, ICON_BIG, wee_icon}) + c_func(SendMessage, {hMainWnd, WM_SETICON, ICON_SMALL, wee_icon}) + + -- attach tooltip to tab control + junk = allocate_pack("zdppddddps", { -- TOOLINFO + TTF_IDISHWND + TTF_SUBCLASS, -- uFlags + hMainWnd, -- hwnd + htabs, -- uId + 0,0,0,0, -- rect + 0, -- hinst + LPSTR_TEXTCALLBACK -- lpszText + }) + c_func(SendMessage, {htooltip, TTM_ADDTOOL, 0, junk}) + free(junk) + + -- open files from last time and on command line + open_tabs() + + --if SetThemeAppProperties != -1 then + -- c_proc(SetThemeAppProperties, {STAP_ALLOW_NONCLIENT+STAP_ALLOW_CONTROLS}) + -- junk = c_func(SendMessage, {hMainWnd, WM_THEMECHANGED, 0, 0}) + --end if + + c_proc(ShowWindow, {hMainWnd, SW_SHOWNORMAL}) + c_proc(UpdateWindow, {hMainWnd}) + c_proc(DragAcceptFiles, {hMainWnd, 1}) + + while c_func(GetMessage, {msg, NULL, 0, 0}) do + if hFindDlg and c_func(IsDialogMessage,{hFindDlg,msg}) then + -- this message is handled by find dialog (thanks Jacques) + -- it makes the tab key work for find/replace dialogs + elsif hDlg and c_func(IsDialogMessage,{hDlg,msg}) then + -- ditto + ? hDlg + else + translate_editor_keys(msg) + junk = c_func(TranslateMessage, {msg}) + junk = c_func(DispatchMessage, {msg}) + end if + end while + +end procedure + +wee_init() +ui_main() diff --git a/tools/WEE/updater.ex b/tools/WEE/updater.ex new file mode 100644 index 0000000..6040f08 --- /dev/null +++ b/tools/WEE/updater.ex @@ -0,0 +1,106 @@ +-- WEE source code updater + +include std/console.e +include std/net/http.e +include std/io.e +include std/get.e +include std/filesys.e +include std/hash.e + +puts(1, "=== WEE Source Code Updater ===\n"& + "This will overwrite any local changes to the source files.\n"& + "Press a key to continue, or 'q' to quit.\n") +if wait_key() = 'q' then + abort(0) +end if + +constant + repo = "peberlein/WEE/", + base_url = "http://cdn.rawgit.com/" & repo -- & "commit/filename" + +-- this needs to be .json since rawgit.com has a whitelist of extensions +-- otherwise it will just redirect to https://raw.githubusercontent.com +-- and http_get doesn't support https: protocol +constant + manifest = http_get("http://rawgit.com/"& repo &"master/manifest.json") + +procedure fail(sequence fmt, object args={}) + printf(1, fmt, args) + puts(1, "\nPress any key to exit, then try updating again.\n") + wait_key() + abort(1) +end procedure + +if atom(manifest) or not equal(manifest[1][1][2], "200") then + display(manifest) + fail("Failed to download manifest.json\n") +end if + +-- manifest format +-- { +-- {"pathname", hash, "commit-tag", platform-bits, platforms...} +-- } + +sequence files, name, commit_tag +files = value(manifest[2]) +--display(files) +if files[1] != 0 then + fail("Failed to parse manifest\n") +end if +files = files[2] + +ifdef BITS64 then +constant PLATFORM_BITS = 64 +elsedef +constant PLATFORM_BITS = 32 +end ifdef + +integer platform_bits +sequence platforms, subdir + +object result, hashcode + +for i = 1 to length(files) do + if length(files[i]) < 4 then + fail("Manifest file has invalid format.\n") + end if + + name = files[i][1] + hashcode = files[i][2] + commit_tag = files[i][3] + platform_bits = files[i][4] + platforms = files[i][5..$] + + if length(platforms) and not find(platform(), platforms) then + -- file not used on this platform + + elsif platform_bits != 0 and platform_bits != PLATFORM_BITS then + -- file not compatible with 32/64-bit platform + + elsif equal(hashcode, hash(read_file(name), HSIEH30)) then + -- file hash is ok + printf(1, "%s is up-to-date.\n", {name}) + + else + printf(1, "Updating %s...\n", {name}) + result = http_get(base_url & commit_tag & "/" & name) + if atom(result) or not equal(result[1][1][2], "200") then + display(result) + fail("Failed to download %s\n", {name}) + elsif not equal(hashcode, hash(result[2], HSIEH30)) then + fail("Failed to validate %s\n", {name}) + else + subdir = dirname(name) + if length(subdir) and atom(dir(subdir)) then + printf(1, "Creating directory %s\n", {subdir}) + create_directory(subdir) + end if + if write_file(name, result[2]) = -1 then + printf(1, "Failed to write_file %s\n", {name}) + end if + end if + end if +end for + +puts(1, "Done. Press any key to exit.\n") +wait_key() diff --git a/tools/WEE/wee b/tools/WEE/wee new file mode 100755 index 0000000..152c2af Binary files /dev/null and b/tools/WEE/wee differ diff --git a/tools/WEE/wee.exw b/tools/WEE/wee.exw new file mode 100644 index 0000000..e12c7a5 --- /dev/null +++ b/tools/WEE/wee.exw @@ -0,0 +1,2879 @@ +-- Wee Euphoria Editor +-- +-- Copyright (c) 1998-2016 Pete Eberlein +-- +-- Permission is hereby granted, free of charge, to any person obtaining a copy +-- of this software and associated documentation files (the "Software"), to deal +-- in the Software without restriction, including without limitation the rights +-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +-- copies of the Software, and to permit persons to whom the Software is +-- furnished to do so, subject to the following conditions: +-- +-- The above copyright notice and this permission notice shall be included in +-- all copies or substantial portions of the Software. +-- +-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +-- THE SOFTWARE. + +global constant + window_title = "Wee Euphoria Editor", + author = "Pete Eberlein ", + version = "0.48", + changelog = ` + +Version 0.48 + - Bug fix: hang during replace all (thanks Andreas) + - Auto-detect EOL characters when opening + +Version 0.47 + - Bug fix: parser support for "loop until" statement (thanks dcuny) + +Version 0.46 + - Bug fix: parser should allow case statements inside ifdef + - Bug fix: crash in parser for non-existent namespace include (thanks Andreas) + +Version 0.45 + - Help->Release Notes to view changelog + - Bug fix: use EUDIR when locating help index + - Bug fix: 'not' in ifdefs was flagged as an error + - Bug fix: set default indentation for new tabs + - Bug fix: clear insert chars after auto-indent + +Version 0.44 + - ARM scintilla library (tested on Raspberry Pi 2) + +Version 0.43 + - Bug fixed: open shell in current directory (UNIX) + +Version 0.42 + - Run commands in a temporary script (Linux/OSX) + +Version 0.41 + - Improved parsing speed + +Version 0.40 + - Bug fixed: crashes on auto-completion and error parsing (thanks dcuny) + +Version 0.39 + - Error indicators and mouse dwell message + - Add namespaces to auto-complete (with 'n' icon) + - Add EUDIR support + - Bug fixed: mousewheel tab change on Windows + +Version 0.38 + - Adding run options: background and test run (thanks KDR) + - Bug fixed: crash on fail to open file during parsing (thanks sdpringle) + - Bug fixed: crash on error while saving (thanks sdpringle) + +Version 0.37 + - Filename first in window title + - Tabs now have mouseover tooltip with full path (win32: only the active tab) + - Bug fixed: crash when interpreter list is empty (thanks Irv) + +Version 0.36 + - Windows icon built-in + - Run Set Interpreter now lets you override the interpreter used + +Version 0.35 + - Allow quoted include filename (thanks dcuny) + +Version 0.34 + - Bug fix: crash on parsing "-type ..." (thanks dcuny) + +Version 0.33 + - select next/prev tab using mouse wheel over tabs + - close tab with middle mouse button + - select next tab (Ctrl+Tab) and previous tab (Shift+Ctrl+Tab) + +Version 0.32 + - 64-bit supported on Windows (joining Linux/OSX) + - Bug fix: no message when opening saved tab whose file no longer exists + +Version 0.31 + - Bug fix: cursor color changes based on background (thanks Andreas) + - Bug fix: string color not loaded from config file (thanks Andreas) + - Bug fix: bold options reversed for String and Number + - Bug fix: incorrect tab or new tab selected when reopening tabs + +Version 0.30 + - Options to disable auto-completing statements or braces + - Auto-completion and syntax coloring disabled for non-Euphoria files + - Bold options for syntax coloring + - Bug fix: crash when typing character literals with calltip active + - Bug fix: GTK version: close tab didn't prompt to save modified files + +Version 0.29 + - Bug fix: crash + lose wee_conf when closing on Windows with reopen_tabs=1 + +Version 0.28 + - Run menu choose which intepreter to use + - Run will choose interpreter location (based on eu.cfg include path) + - Option to reopen tabs next time + +Version 0.27 + - autocompletion list shows icons for each type of declaration + +Version 0.26 + - line wrap option + - Bug fix: preserve selection during comment/uncomment lines + +Version 0.25 + - fill in Find dialog with current selection + - allow search backward in Find and Replace dialogs + - quick search Find Next (Ctrl+G) Find Previous (Shift+Ctrl+G) + - comment/uncomment selected lines (Ctrl+M) + - go back (Esc) after doing View Declaration or Goto Error + - if there is a selection, it will be deselected first + +Version 0.24 + - drag'n'drop files + +Version 0.23 + - Bug fix: run/bind/shroud/translate didn't like spaces in the path + +Version 0.22 + - Bug fix: better at locating scintilla library when bound/compiled + +Version 0.21 + - dialog to change syntax highlighting colors + - popup menu on tab control + +Version 0.20 + - run with arguments (Shift+F5) + - move options to separate menu + - option to sort subroutines in View Subroutines dialog + - added Bind, Shroud and Translate to Run menu + +Version 0.19 + - Linux/Mac (using EuGTK) + - context-sensitive help (hit F1 on a word) + +Version 0.18 + - store syntax highlighting colors in wee.conf + +Version 0.17 + - updated: indent/unindent selection with tab/shift-tab + +Version 0.16 + - updated: ex.err dialog with buttons: + - and listbox with call stack or multiple undeclared references + - Bug fix: weirdness with deletion autoinserted closing characters + - Bug fix: calltip popup displaying incorrect highlight after first time + - Bug fix: EOL mode on Linux/OSX + - Bug fix: completions are now sorted + - Bug fix: switch/case syntax highlight and autocomplete were missing + - Bug fix: shift-ctrl-Z does redo + +Version 0.15 + - hardcoded list of builtins and arguments in get_subroutine_arguents() + +Version 0.13 + - auto-complete with include puts it near top of file + - auto insert closing characters for ( { [ " ' + - typing '(' after a subroutine will popup hints + - Bug fix: autocomplete avoids activating inside comments and strings + +Version 0.12 + - auto expansions for "if" "while" "for" and subroutines (thanks dcuny) + - auto indent newlines + - type ':' to autocomplete a namespace + +Version 0.11 + - view completions will search std includes + - Search->Find will remember last phrase + - fixed tab names not updating when save-as + - fixed "too many open files" error, wasn't closing files in view_error function + - fixed parsing ifdefs + - fixed crash after changing font (thanks euphoric) + - reloading a file that is modified externally loads into wrong tab (thanks dcuny) + +Version 0.10 + - Bug fix: ViewCompletions on whitespace crash + +Version 0.09 + - Scintilla edit control (using Lua lexer :/) + +Version 0.08 + - watch tabs for changes to files and ex.err + - goto declaration (Ctrl+F2) and view completions (Ctrl+Space) + +Version 0.07 + - tabs (can be selected using Alt+1..9) + +Older Versions + - syntax coloring! + - Bug fix: save mode changed to "wb" (Thanks Lucius) + - replace all + - goto error + - hotkeys + - cursor position + - recent files list + - saving window pos+size and recent files to "wee_conf.txt" + - subroutines list dialog (F2) + - choose font dialog (we suggest "Consolas" 11pt) + + - bugs fixed: + - ViewDeclaration wrong cursor pos + - audible ding when pressing Alt+1..9 + - parser updates cache for modified include files + - files are now opened in binary mode since scintilla can handle any line endings +` + +-- todo: +-- bug with reloading files, first few characters get garbled +-- expanding "for" should then tab between "=", "to", and "do" +-- as it is now, its really annoying (but better with overtyping) +-- fix brace highlighting in comments and strings +-- put arguments after each subroutine completion (maybe) +-- investigate Mike Duffy's scintilla Euphoria Lexer +-- multicolored brackets and parens +-- multiline comments and strings +-- code-aware identifier rename +-- add function to parser to get all instances of identifier in scope +-- use multi-select to replace all instances in one shot +-- limited to a single file (too difficult otherwise) +-- macro recording (SCI_STARTRECORD/SCI_STOPRECORD/SCN_MACRORECORD) +-- disable menu items when the action has no effect +-- disable cut/copy when no selection, or paste with empty clipboard +-- disable undo/redo when nothing to do +-- disable go back when nowhere to go back to +-- old calltips sometimes pop up after a calltip elsewhere is closed +-- probably due to nesting calltips +-- will crash by putting a function after sci_notify() (Linux/OSX 64-bit) +-- triggered by using Alt+1-9 to change tabs +-- Euphoria bug? file a ticket +-- help->check for updates +-- updating dll would require updater.ex +-- option to bind/shround/recompile +-- edit->tidy, to clean up indentation/formatting + +--without warning + +include parser.e +include scintilla.e +include std/get.e +include std/filesys.e +include std/sequence.e +include std/text.e +include std/machine.e +include std/error.e +include std/io.e +include weeicon.e + +-- The ui includes are circular includes: +-- wee.exw -> ui_win.e -> wee.exw +-- The ui include is responsible for calling wee_init() and startup. +ifdef WINDOWS then +include ui_win.e +elsedef +include ui_gtk.e +end ifdef + +-- all variables must be initialized in wee_init() due to circular include +global constant max_recent_files = 5 + + +-- these are configuration settings saved to wee_conf +global atom x_pos, y_pos, x_size, y_size +global sequence font_name, recent_files, + terminal_program -- for GTK, runs programs in a terminal +global integer font_height, + line_numbers, -- boolean + sorted_subs, -- boolean + line_wrap, -- boolean + reopen_tabs, -- boolean + tab_width, -- usually 8 + indentation_guides, -- boolean + caret_width, -- in pixels + complete_statements, -- when typing "if " -> "if | then\n \nend if" + complete_braces, -- when typing '(' or '[' or '{' or ''' or '"' + auto_namespace, -- when typing ':' + auto_complete, -- when typing two word chars or backspace + auto_arguments, -- when typing '(' after an identifier + auto_indent, -- when creating a new line + auto_indicator, -- underline words that are not in scope + run_testrun, -- run exe after bind/shroud/translate + run_background, -- for GTK, run programs/terminal in background + run_waitkey, -- wait for keypress after running in a terminal + keyword_color, builtin_color, string_color, + comment_color, number_color, normal_color, background_color, + linenumber_color, bracelight_color, bold_flags +sequence tabs_to_open -- {{"filename", pos, topline},...} +sequence file_types -- {{{"ext1","ext2",...}, SCLEX_x, {index, "keywords ...", ...}, {"match", "expand",...} + + +global sequence file_name, run_file_name, ex_err_name +global sequence find_phrase, replace_phrase, interpreter, wee_path + + +-- local variables +sequence + tab_hedits, tab_file_names, tab_timestamps, + recent_pos, tab_arguments, tab_pos_stack +integer current_tab, modified, initial_tab +atom hedit +atom ex_err_timestamp +integer expand_line, last_deleted_char +sequence insert_chars +sequence calltip_args -- {{start,end},...} +integer calltip_pos +sequence calltip_stack -- {calltip_pos, calltip_args...} +sequence calltip_text -- "routine_name(type1 arg1, ...)" +integer calltip_dwell -- flag indicating calltip from mouse dwell +sequence wee_conf_filename +sequence search_idx, search_dat +sequence expansions +sequence last_errors +atom change_time -- when to perform error indicator checking + +-- shorthand helper function +function ssm(integer m, object w=0, object l=0) + return scintilla_send_message(hedit, m, w, l) +end function + + +function crash_cleanup(object x) + ui_message_box_error(window_title, + "Houston, Wee've had a problem.\n\n" & + "The editor crashed and is closing now.\n") + save_modified_tabs() + if length(wee_conf_filename) then + save_wee_conf(wee_conf_filename) + end if + return 0 +end function + + + +constant -- colors of various syntax classes + Black = #000000, + Gray = #AAAAAA, + DGray = #808080, + Green = #00AA00, + Yellow = #88FFFF, + Magenta = #AA00AA, + Cyan = #AAAA00, + Red = #0000AA, + Blue = #AA0000, + LightBlue = #FFFFDD, + White = #FFFFFF, + BrightRed = #0000FF + +global procedure wee_init() + sequence cmdline + + wee_conf_filename = "" + + crash_routine(routine_id("crash_cleanup")) + + recent_files = {} + recent_pos = {} + + font_name = "" + font_height = 10 + line_numbers = 0 + sorted_subs = 0 + line_wrap = 0 + + file_name = "" + hedit = 0 + + run_file_name = "" + ex_err_name = "ex.err" + ex_err_timestamp = get_timestamp(ex_err_name) + interpreter = "" + + tab_hedits = {} + tab_file_names = {} + tab_timestamps = {} + tab_arguments = {} + tab_pos_stack = {} + last_errors = {} + + modified = 0 + expand_line = -1 + insert_chars = "" + last_deleted_char = 0 + auto_namespace = 1 + auto_complete = 1 + complete_statements = 1 + complete_braces = 1 + auto_arguments = 1 + auto_indent = 1 + tab_width = 8 + indentation_guides = 0 + caret_width = 2 + auto_indicator = 1 + run_testrun = 0 + run_background = 1 + run_waitkey = 1 + + calltip_args = {} + calltip_pos = -1 + calltip_stack = {} + calltip_text = "" + calltip_dwell = 0 + + current_tab = 0 + + normal_color = Black + background_color = White + comment_color = DGray + number_color = Black + keyword_color = Green + builtin_color = Magenta + string_color = Blue + bracelight_color = LightBlue + linenumber_color = DGray + bold_flags = #40 + + search_idx = {} + search_dat = {} + + find_phrase = "" + replace_phrase = "" + terminal_program = "" + + reopen_tabs = 1 + tabs_to_open = {} + initial_tab = 1 + + cmdline = command_line() + wee_path = canonical_path(dirname(cmdline[2])) + if length(wee_path) and wee_path[$] = SLASH then + wee_path = wee_path[1..$-1] + end if + + file_types = { + { + -- extensions + {"ex", "e", "exw", "ew", "exu", "eu"}, + -- SCLEX_constant + SCLEX_LUA, + -- identifiers used with SCI_SETIDENTIFIERS + {0, + "procedure function type end and or xor not if then elsif else for to by do while "& + "global constant include with without return exit "& + -- OE4 + "public export enum as namespace ifdef elsifdef elsedef "& + "label entry break continue loop until routine switch case fallthru", + 1, + get_builtins() + }, + -- expansions used with auto_expand() + {{"if", "", " then", "end if"}, + {"elsif", "", " then"}, + {"while", "", " do", "end while"}, + {"for", " = to ", " do", "end for"}, + {"case", "", " then"}, + {"loop", "", "do", "end loop"}, + {"switch", "", " do", "end switch"}, + {0, "global ", "public ", "export "}, + {"procedure", "()", "", "end procedure"}, + {"function", "()", "", "end function"}, + {"type", "()", "", "end type"} + }, + interpreter + }, + { + -- extensions + {"c", "h", "cpp", "hpp"}, + -- SCLEX_constant + SCLEX_CPP, + -- identifiers used with SCI_SETKEYWORDS + {0, + "if else for do while switch case default "& + "return break continue "& + "enum typedef struct union static const ", + 1, + "void int char unsigned long sizeof" + }, + -- expansions used with auto_expand() + {{"if", "()", " {", "}"}, + {"} else if", "()", " { "}, + {"while", "()", " {", "}"}, + {"for", "(;;)", " {", "}"}, + {"switch", "()", " {", "}"}, + {"case", "", ":", "break;"} + } + }, + { + -- extensions + {"htm", "html"}, + -- SCLEX_constant + SCLEX_HTML, + -- identifiers used with SCI_SETKEYWORDS + {}, + -- expansions used with auto_expand() + {} + } + } + expansions = {} +end procedure + + + +global procedure load_wee_conf(sequence wee_conf_file) + integer f, eq, int_ok + object l + sequence key, val + f = open(wee_conf_file, "r") + if f = -1 then return end if + wee_conf_filename = wee_conf_file + l = gets(f) + while sequence(l) do + eq = find('=', l) + if eq then + key = l[1..eq-1] + val = l[eq+1..length(l)-1] + l = value(val) + int_ok = (l[1] = 0 and integer(l[2])) + if equal(key, "x_pos") and int_ok then + x_pos = l[2] + elsif equal(key, "y_pos") and int_ok then + y_pos = l[2] + elsif equal(key, "x_size") and int_ok then + x_size = l[2] + elsif equal(key, "y_size") and int_ok then + y_size = l[2] + elsif equal(key, "recent_file") then + recent_files &= {val} + elsif equal(key, "recent_pos") and int_ok then + recent_pos &= l[2] + elsif equal(key, "font_name") then + font_name = val + elsif equal(key, "font_height") and int_ok then + font_height = l[2] + if font_height < 0 then + font_height = -floor((font_height*96+36)/72) + end if + elsif equal(key, "line_numbers") and int_ok then + line_numbers = l[2] + elsif equal(key, "normal_color") and int_ok then + normal_color = l[2] + elsif equal(key, "background_color") and int_ok then + background_color = l[2] + elsif equal(key, "comment_color") and int_ok then + comment_color = l[2] + elsif equal(key, "keyword_color") and int_ok then + keyword_color = l[2] + elsif equal(key, "builtin_color") and int_ok then + builtin_color = l[2] + elsif equal(key, "number_color") and int_ok then + number_color = l[2] + elsif equal(key, "string_color") and int_ok then + string_color = l[2] + elsif equal(key, "linenumber_color") and int_ok then + linenumber_color = l[2] + elsif equal(key, "bracelight_color") and int_ok then + bracelight_color = l[2] + elsif equal(key, "sorted_subs") and int_ok then + sorted_subs = l[2] + elsif equal(key, "line_wrap") and int_ok then + line_wrap = l[2] + elsif equal(key, "interpreter") then + if not find(val, {"eui","euiw","ex","exw"}) then + interpreter = val + end if + elsif equal(key, "reopen_tabs") and int_ok then + reopen_tabs = l[2] + elsif equal(key, "open_tab") then + if length(l[2]) = 3 and sequence(l[2][1]) and integer(l[2][2]) and integer(l[2][3]) then + tabs_to_open = append(tabs_to_open, l[2]) + else + tabs_to_open = append(tabs_to_open, {val, 0, 0}) + end if + elsif equal(key, "open_tab_pos") and int_ok then + tabs_to_open[$][2] = l[2] + elsif equal(key, "open_tab_line") and int_ok then + tabs_to_open[$][3] = l[2] + elsif equal(key, "initial_tab") and int_ok then + initial_tab = l[2] + elsif equal(key, "complete_statements") and int_ok then + complete_statements = l[2] + elsif equal(key, "complete_braces") and int_ok then + complete_braces = l[2] + elsif equal(key, "bold_flags") and int_ok then + bold_flags = l[2] + elsif equal(key, "tab_width") and int_ok then + tab_width = l[2] + elsif equal(key, "indentation_guides") and int_ok then + indentation_guides = l[2] + elsif equal(key, "caret_width") and int_ok then + caret_width = l[2] + elsif equal(key, "terminal_program") then + terminal_program = val + elsif equal(key, "run_testrun") and int_ok then + run_testrun = l[2] + elsif equal(key, "run_background") and int_ok then + run_background = l[2] + elsif equal(key, "run_waitkey") and int_ok then + run_waitkey = l[2] + end if + end if + l = gets(f) + end while + close(f) +end procedure + +global procedure save_wee_conf(sequence wee_conf_file) + integer f + f = open(wee_conf_file, "w") + printf(f, "x_pos=%d\ny_pos=%d\nx_size=%d\ny_size=%d\nline_numbers=%d\n", + {x_pos, y_pos, x_size, y_size, line_numbers}) + for i = 1 to length(recent_files) do + puts(f, "recent_file="&recent_files[i]&"\n") + printf(f, "recent_pos=%d\n", {recent_pos[i]}) + end for + if length(font_name) and font_height != 0 then + printf(f, "font_name=%s\nfont_height=%d\n", {font_name, font_height}) + end if + printf(f, "normal_color=#%06x\n", {normal_color}) + printf(f, "background_color=#%06x\n", {background_color}) + printf(f, "keyword_color=#%06x\n", {keyword_color}) + printf(f, "builtin_color=#%06x\n", {builtin_color}) + printf(f, "comment_color=#%06x\n", {comment_color}) + printf(f, "number_color=#%06x\n", {number_color}) + printf(f, "string_color=#%06x\n", {string_color}) + printf(f, "linenumber_color=#%06x\n", {linenumber_color}) + printf(f, "bracelight_color=#%06x\n", {bracelight_color}) + printf(f, "bold_flags=#%x\n", {bold_flags}) + printf(f, "sorted_subs=%d\n", {sorted_subs}) + printf(f, "line_wrap=%d\n", {line_wrap}) + printf(f, "interpreter=%s\n", {interpreter}) + printf(f, "reopen_tabs=%d\n", {reopen_tabs}) + printf(f, "initial_tab=%d\n", {current_tab}) + if reopen_tabs then + for i = 1 to length(tab_file_names) do + if length(tab_file_names[i]) then + hedit = tab_hedits[i] + printf(f, "open_tab=%s\nopen_tab_pos=%d\nopen_tab_line=%d\n", { + tab_file_names[i], + ssm(SCI_GETCURRENTPOS), + ssm(SCI_GETFIRSTVISIBLELINE)}) + end if + end for + end if + printf(f, "complete_statements=%d\n", {complete_statements}) + printf(f, "complete_braces=%d\n", {complete_braces}) + printf(f, "tab_width=%d\n", {tab_width}) + printf(f, "indentation_guides=%d\n", {indentation_guides}) + printf(f, "caret_width=%d\n", {caret_width}) + printf(f, "terminal_program=%s\n", {terminal_program}) + printf(f, "run_testrun=%d\n", {run_testrun}) + printf(f, "run_background=%d\n", {run_background}) + printf(f, "run_waitkey=%d\n", {run_waitkey}) + close(f) +end procedure + + + +function sreplace(sequence text, sequence what, sequence replacement) + integer i + i = match(what, text) + if i then + return text[1..i-1] & replacement & text[i+length(what)..$] + end if + return text +end function + +-- update the hedit lexer based on the file extension +procedure update_lexer() + sequence ext, keywords + integer lexer + + if length(tab_file_names[current_tab]) then + ext = lower(fileext(tab_file_names[current_tab])) + else + ext = "ex" -- New file + end if + + lexer = SCLEX_NULL + expansions = {} + keywords = {} + for i = 1 to length(file_types) do + if find(ext, file_types[i][1]) then + lexer = file_types[i][2] + keywords = file_types[i][3] + expansions = file_types[i][4] + exit + end if + end for + if lexer != ssm(SCI_GETLEXER) then + ssm(SCI_SETLEXER, lexer) + init_edit(hedit) + for k = 1 to length(keywords) by 2 do + ssm(SCI_SETKEYWORDS, keywords[k], keywords[k+1]) + end for + end if +end procedure + + +-- init edit, (or reinit all existing edits when hedit = 0) +global procedure init_edit(atom edit) + sequence font + integer lexer + + hedit = edit + + font = font_name + ifdef not WINDOWS then + font = sreplace(font, "Medium", "") + font = sreplace(font, "Thin", "") + font = sreplace(font, "Bold", "") + font = sreplace(font, "Italic", "") + font = sreplace(font, "Condensed", "") + font = rtrim(font) + end ifdef + + ssm(SCI_STYLESETFONT, STYLE_DEFAULT, font) + ifdef not WINDOWS then + ssm(SCI_STYLESETBOLD, STYLE_DEFAULT, match(" Bold", font_name)) + ssm(SCI_STYLESETITALIC, STYLE_DEFAULT, match(" Italic", font_name)) + end ifdef + ssm(SCI_STYLESETSIZE, STYLE_DEFAULT, font_height) + ssm(SCI_STYLESETFORE, STYLE_DEFAULT, normal_color) + ssm(SCI_STYLESETBACK, STYLE_DEFAULT, background_color) + ssm(SCI_SETCARETFORE, xor_bits(background_color, #FFFFFF)) + ssm(SCI_STYLESETBOLD, STYLE_DEFAULT, and_bits(bold_flags, 1)) + ssm(SCI_STYLECLEARALL) + + lexer = ssm(SCI_GETLEXER) + + if lexer = SCLEX_LUA then + ssm(SCI_STYLESETFORE, SCE_LUA_COMMENT, comment_color) + ssm(SCI_STYLESETBOLD, SCE_LUA_COMMENT, 0 != and_bits(bold_flags, 2)) + ssm(SCI_STYLESETFORE, SCE_LUA_COMMENTLINE, comment_color) + ssm(SCI_STYLESETBOLD, SCE_LUA_COMMENTLINE, 0 != and_bits(bold_flags, 2)) + ssm(SCI_STYLESETFORE, SCE_LUA_STRING, string_color) + ssm(SCI_STYLESETBOLD, SCE_LUA_STRING, 0 != and_bits(bold_flags, 4)) + ssm(SCI_STYLESETFORE, SCE_LUA_WORD, keyword_color) + ssm(SCI_STYLESETBOLD, SCE_LUA_WORD, 0 != and_bits(bold_flags, 8)) + ssm(SCI_STYLESETFORE, SCE_LUA_WORD2, builtin_color) + ssm(SCI_STYLESETBOLD, SCE_LUA_WORD2, 0 != and_bits(bold_flags, #10)) + ssm(SCI_STYLESETFORE, SCE_LUA_NUMBER, number_color) + ssm(SCI_STYLESETBOLD, SCE_LUA_NUMBER, 0 != and_bits(bold_flags, #20)) + elsif lexer = SCLEX_CPP then + ssm(SCI_STYLESETFORE, SCE_C_COMMENT, comment_color) + ssm(SCI_STYLESETBOLD, SCE_C_COMMENT, 0 != and_bits(bold_flags, 2)) + ssm(SCI_STYLESETFORE, SCE_C_COMMENTLINE, comment_color) + ssm(SCI_STYLESETBOLD, SCE_C_COMMENTLINE, 0 != and_bits(bold_flags, 2)) + ssm(SCI_STYLESETFORE, SCE_C_STRING, string_color) + ssm(SCI_STYLESETBOLD, SCE_C_STRING, 0 != and_bits(bold_flags, 4)) + ssm(SCI_STYLESETFORE, SCE_C_WORD, keyword_color) + ssm(SCI_STYLESETBOLD, SCE_C_WORD, 0 != and_bits(bold_flags, 8)) + ssm(SCI_STYLESETFORE, SCE_C_WORD2, builtin_color) + ssm(SCI_STYLESETBOLD, SCE_C_WORD2, 0 != and_bits(bold_flags, #10)) + ssm(SCI_STYLESETFORE, SCE_C_NUMBER, number_color) + ssm(SCI_STYLESETBOLD, SCE_C_NUMBER, 0 != and_bits(bold_flags, #20)) + end if + + ssm(SCI_STYLESETBACK, STYLE_BRACELIGHT, bracelight_color) + ssm(SCI_STYLESETBOLD, STYLE_BRACELIGHT, 0 != and_bits(bold_flags, #40)) + + ssm(SCI_STYLESETFORE, STYLE_LINENUMBER, linenumber_color) + ssm(SCI_STYLESETBOLD, STYLE_LINENUMBER, 0 != and_bits(bold_flags, #80)) + + ssm(SCI_SETMARGINWIDTHN, 0, 48*line_numbers) -- line numbers margin visible + ssm(SCI_SETMARGINWIDTHN, 1, 0) -- non-folding symbols margin hidden + + ssm(SCI_SETTABINDENTS, 1) + ssm(SCI_SETBACKSPACEUNINDENTS, 1) + ssm(SCI_SETINDENTATIONGUIDES, indentation_guides) + ssm(SCI_SETTABWIDTH, tab_width) + ssm(SCI_SETCARETWIDTH, caret_width) + + ssm(SCI_AUTOCSETSEPARATOR, '\n') + ssm(SCI_AUTOCSTOPS, 0, " ") + ssm(SCI_AUTOCSETFILLUPS, 0, "") + --ssm(SCI_AUTOCSETORDER, SC_ORDER_CUSTOM) -- declaration order + ssm(SCI_AUTOCSETORDER, SC_ORDER_PERFORMSORT) -- scintilla should sort + ssm(SCI_AUTOCSETCANCELATSTART) + + -- call tips display above text + ssm(SCI_CALLTIPSETPOSITION, 1) + + -- get modification events for deletetext + ssm(SCI_SETMODEVENTMASK, + SC_MOD_INSERTTEXT + + SC_MOD_DELETETEXT + + SC_MOD_BEFOREDELETE) + + ssm(SCI_SETWRAPMODE, line_wrap) + + ifdef WINDOWS then + ssm(SCI_SETEOLMODE, SC_EOL_CRLF) + elsedef + ssm(SCI_SETEOLMODE, SC_EOL_LF) + end ifdef + + ssm(SCI_REGISTERIMAGE, DECL_ATOM, a_xpm) + ssm(SCI_REGISTERIMAGE, DECL_CONSTANT, c_xpm) + ssm(SCI_REGISTERIMAGE, DECL_ENUM, e_xpm) + ssm(SCI_REGISTERIMAGE, DECL_FUNCTION, f_xpm) + ssm(SCI_REGISTERIMAGE, DECL_INTEGER, i_xpm) + ssm(SCI_REGISTERIMAGE, DECL_NAMESPACE, n_xpm) + ssm(SCI_REGISTERIMAGE, DECL_OBJECT, o_xpm) + ssm(SCI_REGISTERIMAGE, DECL_PROCEDURE, p_xpm) + ssm(SCI_REGISTERIMAGE, DECL_SEQUENCE, s_xpm) + ssm(SCI_REGISTERIMAGE, DECL_TYPE, t_xpm) + + ssm(SCI_INDICSETSTYLE, 3, INDIC_SQUIGGLE) + ssm(SCI_INDICSETFORE, 3, BrightRed) + ssm(SCI_SETINDICATORCURRENT, 3) + ssm(SCI_SETMOUSEDWELLTIME, 500) -- milliseconds + +end procedure + +global procedure reinit_all_edits() + atom saved_hedit + saved_hedit = hedit + for i = 1 to length(tab_hedits) do + init_edit(tab_hedits[i]) + end for + hedit = saved_hedit +end procedure + +procedure auto_detect_indent(sequence text) + integer i = 0, indent = 0, last = 0, tabs_used = 0, spaces_used = 0 + integer cr = 0, crlf = 0, lf = 0 + sequence indents = repeat(0, 8) + + while i < length(text) do + i += 1 + -- count spaces and tabs + if text[i] = ' ' then + indent += 1 + if remainder(indent, tab_width) = 0 then + spaces_used += 1 + end if + continue + end if + if text[i] = '\t' then + indent += tab_width - remainder(indent, tab_width) + tabs_used += 1 + continue + end if + + -- record positive indents + if indent - last >= 1 and indent - last <= length(indents) then + indents[indent - last] += 1 + end if + last = indent + indent = 0 + + -- scan to end of line and count eol styles + while i <= length(text) do + if text[i] = '\r' then -- cr + if i < length(text) and text[i+1] = '\n' then -- crlf + i += 1 + crlf += 1 + else + cr += 1 + end if + exit + elsif text[i] = '\n' then -- lf + lf += 1 + if i < length(text) and text[i+1] = '\r' then -- lfcr - not counted + i += 1 + end if + exit + end if + i += 1 + end while + + end while + + -- pick the max used indent size + indent = 1 + for x = 2 to length(indents) do + if indents[x] > indents[indent] then + indent = x + end if + end for + + ssm(SCI_SETINDENT, indent) + ssm(SCI_SETUSETABS, tabs_used > spaces_used) + + -- pick the most used eol style + if cr > crlf and cr > lf then + ssm(SCI_SETEOLMODE, SC_EOL_CR) + elsif crlf > cr and crlf > lf then + ssm(SCI_SETEOLMODE, SC_EOL_CRLF) + elsif lf > cr and lf > crlf then + ssm(SCI_SETEOLMODE, SC_EOL_LF) + end if + +end procedure + +-- pos is integer position in current tab, or {"filename", pos} +-- note: first character in document is at pos=1 +global procedure goto_pos(object pos, integer len=0) + sequence prev = {ssm(SCI_GETCURRENTPOS), + ssm(SCI_GETFIRSTVISIBLELINE)} + + if sequence(pos) then + sequence prev_file = file_name + if open_file(pos[1], 0) = 0 then + return -- file not found + end if + pos = pos[2] + if not equal(file_name, prev_file) then + -- open_file probably changed the current_tab + prev &= {prev_file} + end if + end if + tab_pos_stack[current_tab] &= {prev} + pos -= 1 + ssm(SCI_SETANCHOR, pos) + ssm(SCI_SETCURRENTPOS, pos + len) + set_top_line(-1) +end procedure + +-- restore the previous cursor and scroll position, +-- or clear the selection or autocompletion if there is one +global procedure go_back() + object pos = ssm(SCI_GETCURRENTPOS) + + -- clear any active autocomplete, and return + -- cancel any active call tip, and return + if ssm(SCI_AUTOCACTIVE) or ssm(SCI_CALLTIPACTIVE) then + ssm(SCI_AUTOCCANCEL) + ssm(SCI_CALLTIPCANCEL) + calltip_pos = -1 + calltip_stack = {} + return + end if + + -- clear any selection, and return + if pos != ssm(SCI_GETANCHOR) then + ssm(SCI_SETEMPTYSELECTION, pos) + return + end if + + if length(tab_pos_stack[current_tab]) = 0 then + return -- empty stack + end if + + -- get the last {pos,top_line,[filename]} on stack, and remove it + pos = tab_pos_stack[current_tab][$] + tab_pos_stack[current_tab] = tab_pos_stack[current_tab][1..$-1] + + if sequence(pos) and length(pos) >= 3 then + if length(pos[3]) = 0 then + -- fixme: pick first untitled tab + integer tab = find("", tab_file_names) + if tab = 0 then + return + end if + select_tab(tab) + elsif open_file(pos[3], 0) = 0 then + return -- file not found or user cancelled + end if + end if + ssm(SCI_SETEMPTYSELECTION, pos[1]) + set_top_line(pos[2]) +end procedure + +global function get_pos() + return ssm(SCI_GETCURRENTPOS) +end function + +global function get_selection() + integer len + atom buf + sequence text + + len = ssm(SCI_GETSELTEXT) + if len <= 1 then + return "" + end if + buf = allocate(len) + ssm(SCI_GETSELTEXT, 0, buf) + text = peek({buf, len - 1}) + free(buf) + return text +end function + +global procedure set_top_line(integer line) + integer fv, los + if line = -1 then + line = ssm(SCI_LINEFROMPOSITION, get_pos()) + end if + fv = ssm(SCI_GETFIRSTVISIBLELINE) + los = ssm(SCI_LINESONSCREEN) + if line >= fv and line < fv + los-1 then + return -- don't need to scroll + end if + line = ssm(SCI_SETFIRSTVISIBLELINE, line) +end procedure + +global function get_modified() + return ssm(SCI_GETMODIFY) +end function + +global function get_line_length(integer line) + if line = -1 then + line = ssm(SCI_LINEFROMPOSITION, get_pos()) + end if + return ssm(SCI_LINELENGTH, line) +end function + +global function get_line_end_position(integer line) + if line = -1 then + line = ssm(SCI_LINEFROMPOSITION, get_pos()) + end if + return ssm(SCI_GETLINEENDPOSITION, line) +end function + +global function get_line_start_position(integer line) + if line = -1 then + line = ssm(SCI_LINEFROMPOSITION, get_pos()) + end if + return ssm(SCI_POSITIONFROMLINE, line) +end function + + +global function get_line(integer line) + atom junk, len, buf + sequence text + + if line = -1 then + line = ssm(SCI_LINEFROMPOSITION, get_pos()) + end if + len = get_line_length(line) + buf = allocate(len+1) + ssm(SCI_GETLINE, line, buf) + text = peek({buf, len}) + free(buf) + return text +end function + +global function get_edit_text() + atom junk, text_buffer, text_len + sequence text + + text_len = ssm(SCI_GETTEXTLENGTH)+1 + text_buffer = allocate(text_len) + ssm(SCI_GETTEXT, text_len, text_buffer) + text = peek({text_buffer, text_len-1}) + free(text_buffer) + return text +end function + +global procedure update_status() + atom pos, line, col + pos = get_pos() + line = 1+ssm(SCI_LINEFROMPOSITION, pos) + col = 1+ssm(SCI_GETCOLUMN, pos) + ui_update_status(sprintf("%d:%d ", {line, col})) + if line-1 != expand_line then + expand_line = -1 + end if +end procedure + + +-------------------------------------- +-- search and replace +-------------------------------------- + +-- search for the phrase (sequence or pointer) and set the editor target +-- returns 1 if found, otherwise 0 +global function search_find(sequence phrase, integer backward = 0, integer in_replace_all = 0) + if backward then + ssm(SCI_SETTARGETSTART, ssm(SCI_GETSELECTIONSTART)) + ssm(SCI_SETTARGETEND, 0) + else + ssm(SCI_SETTARGETSTART, ssm(SCI_GETSELECTIONEND)) + ssm(SCI_SETTARGETEND, ssm(SCI_GETTEXTLENGTH)) + end if + + if ssm(SCI_SEARCHINTARGET, length(phrase), phrase) < 0 then + -- wrap around and search again + if in_replace_all then + return 0 + elsif backward then + ssm(SCI_SETTARGETSTART, ssm(SCI_GETTEXTLENGTH)) + else + ssm(SCI_SETTARGETSTART, 0) + end if + if ssm(SCI_SEARCHINTARGET, length(phrase), phrase) < 0 then + -- clear the target so search_replace won't do bad things + ssm(SCI_SETTARGETSTART, 0) + ssm(SCI_SETTARGETEND, 0) + return 0 + end if + end if + -- scroll to left side first + ssm(SCI_SETXOFFSET, 0) + -- set selection from target + ssm(SCI_SETSEL, ssm(SCI_GETTARGETSTART), ssm(SCI_GETTARGETEND)) + + return 1 +end function + +-- replace the editor target with the phrase (sequence or pointer) +-- returns 1 if replace made, otherwise 0 +global function search_replace(sequence phrase) + integer pos = ssm(SCI_GETTARGETSTART) + if pos >= ssm(SCI_GETTARGETEND) then + -- target not set + if not equal(get_selection(), find_phrase) then + return 0 + end if + SSM(hedit, SCI_TARGETFROMSELECTION) + end if + -- replace or replace_all + ssm(SCI_REPLACETARGET, length(phrase), phrase) + -- set the current pos to the end, so that the next + -- find doesn't search within the replacement phrase + ssm(SCI_SETSEL, pos, pos + length(phrase)) + return 1 +end function + +-- replace all in document, saving the cursor position +-- returns count of replacements made +global function search_replace_all(sequence what, sequence phrase) + integer + pos = ssm(SCI_GETCURRENTPOS), + anchor = ssm(SCI_GETANCHOR), + count = 0 + -- save the current position to be restored later + ssm(SCI_SETANCHOR, 0) + ssm(SCI_SETCURRENTPOS, 0) + -- search until not found + ssm(SCI_BEGINUNDOACTION) + while search_find(what, 0, 1) do + search_replace(phrase) + count += 1 + end while + ssm(SCI_ENDUNDOACTION) + ssm(SCI_SETSEL, anchor, pos) + return count +end function + + +-------------------------------------- +-- tab management +-------------------------------------- + +global function get_prev_tab() + if current_tab <= 1 then + return length(tab_hedits) + end if + return current_tab - 1 +end function + +global function get_next_tab() + if current_tab >= length(tab_hedits) then + return 1 + end if + return current_tab + 1 +end function + +global function make_tab_name() + sequence name + + if length(file_name) = 0 then + name = "New File" + else + name = file_name + for i = length(name) to 1 by -1 do + if name[i] = '\\' or name[i] = '/' then + name = name[i+1..$] + exit + end if + end for + end if + return name +end function + + +procedure update_tab_timestamp() + if length(file_name) then + tab_timestamps[current_tab] = get_timestamp(file_name) + else + tab_timestamps[current_tab] = -1 + end if +end procedure + + +global procedure select_tab(integer tab) + if tab < 1 or tab > length(tab_hedits) or tab = current_tab then + return + end if + current_tab = tab + file_name = tab_file_names[tab] + hedit = tab_hedits[tab] + modified = get_modified() + + expand_line = -1 + insert_chars = "" + calltip_args = {} + calltip_pos = -1 + calltip_stack = {} + calltip_text = "" + last_errors = {} + ui_select_tab(tab) + ui_update_window_title(make_tab_name()) + update_status() + + update_lexer() + change_time = time() + .5 +end procedure + +global procedure update_tab_name() + sequence name = make_tab_name() + ui_update_window_title(name) + if modified then name &= "*" end if + ui_update_tab_name(current_tab, name) +end procedure + +global procedure new_tab(sequence file_name) + integer tab + + if equal(tab_file_names, {""}) and modified = 0 then + -- unmodified new file, just reuse it and update the tab name + tab = 1 + tab_file_names[tab] = file_name + update_tab_name() + current_tab = 0 -- to force select_tab + else + hedit = ui_new_tab(make_tab_name()) + + tab_hedits = append(tab_hedits, hedit) + tab_file_names = append(tab_file_names, file_name) + tab_timestamps = append(tab_timestamps, -1) + tab_arguments = append(tab_arguments, "") + tab_pos_stack = append(tab_pos_stack, {}) + tab = length(tab_hedits) + end if + select_tab(tab) + init_edit(hedit) + ssm(SCI_SETINDENT, 4) + ssm(SCI_SETUSETABS, 0) +end procedure + +global procedure close_tab() + integer tab + + if save_if_modified(1) = 0 then + return -- user cancelled the save + end if + + tab = current_tab + save_recent_pos() + ui_close_tab(tab) + + tab_hedits = tab_hedits[1..tab-1] & tab_hedits[tab+1..$] + tab_file_names = tab_file_names[1..tab-1] & tab_file_names[tab+1..$] + tab_timestamps = tab_timestamps[1..tab-1] & tab_timestamps[tab+1..$] + tab_arguments = tab_arguments[1..tab-1] & tab_arguments[tab+1..$] + tab_pos_stack = tab_pos_stack[1..tab-1] & tab_pos_stack[tab+1..$] + current_tab = 0 + if length(tab_hedits) = 0 then + new_file() -- must always have a edit available + elsif tab > length(tab_hedits) then + tab = length(tab_hedits) + end if + select_tab(tab) +end procedure + +global function get_tab_arguments() + return tab_arguments[current_tab] +end function + +global procedure set_tab_arguments(sequence s) + tab_arguments[current_tab] = s +end procedure + + + +-------------------------------------- +-- file open/save +-------------------------------------- + +-- returns tab index of opened file, or 0 if cancelled +global function open_file(sequence file_name, integer reload) + atom result, text_buffer + integer fn, tab, initial_pos = 0, first_visible_line = 0 + object temp, s + sequence text + + if length(file_name) = 0 then + file_name = ui_get_open_file_name() + if length(file_name) = 0 then return 0 end if + if sequence(file_name[1]) then + -- multiple open + for i = 1 to length(file_name) do + open_file(file_name[i], reload) + end for + return 0 + end if + elsif sequence(file_name[1]) then + -- filename is {"file_name", initial_pos, first_visible_line} + if length(file_name) >= 2 and integer(file_name[2]) then + initial_pos = file_name[2] + end if + if length(file_name) >= 3 and integer(file_name[3]) then + first_visible_line = file_name[3] + end if + file_name = file_name[1] + end if + + file_name = canonical_path(file_name, 0, CORRECT) + + -- check if already existing tab + tab = find(file_name, tab_file_names) + if tab and reload = 0 then + select_tab(tab) + return tab + end if + + text = "" + fn = open(file_name, "rb") + if fn = -1 then + -- file couldn't be opened + if ui_message_box_yes_no("Open", "Unable to open "&file_name&"\n\n"& + "Do you want to create it?") = 0 then + return 0 + end if + else + -- read the contents of the file into text + s = gets(fn) + while sequence(s) do + text &= s + s = gets(fn) + end while + close(fn) + end if + + if not tab then + new_tab(file_name) + tab = current_tab + end if + update_tab_timestamp() + + result = ssm(SCI_CLEARALL) + result = ssm(SCI_SETTEXT, 0, text) + result = ssm(SCI_SETSAVEPOINT) + modified = 0 + if tab then + update_tab_name() + end if + + result = ssm(SCI_SETFIRSTVISIBLELINE, first_visible_line) + result = ssm(SCI_SETEMPTYSELECTION, initial_pos) + result = ssm(SCI_EMPTYUNDOBUFFER) + auto_detect_indent(text) + + add_recent_file(file_name) + return tab +end function + +-- open files on startup and saved tabs +global procedure open_tabs() + sequence cmdline + -- open files from previous session + for i = 1 to length(tabs_to_open) do + if file_exists(tabs_to_open[i][1]) then + open_file(tabs_to_open[i], 0) + end if + end for + -- open files on command line + cmdline = command_line() + for i = 3 to length(cmdline) do + open_file(cmdline[i], 0) + end for + if length(tab_file_names) = 0 and length(cmdline) < 3 then + new_file() + elsif length(cmdline) < 3 then + -- select initial tab if no files on command line + select_tab(initial_tab) + end if +end procedure + +-- returns 1 if ok, 0 on error +function save_file() + atom fn, junk + sequence text + + ssm(SCI_SETSAVEPOINT, 0, 0) + modified = 0 + + fn = open(file_name, "wb") + if fn = -1 then + ui_message_box_error("Save", "Unable to save file. Please make sure the file location is not read-only.") + return 0 + end if + text = get_edit_text() + puts(fn, text) + junk = where(fn) + close(fn) + + if junk != length(text) then + ui_message_box_error("Save", "The file could not be written completely. Please make sure there is enough free space.") + return 0 + end if + + update_tab_name() + update_tab_timestamp() + return 1 +end function + +global function save_file_as() -- returns 1 if ok, 0 if cancelled/error + object temp + + temp = ui_get_save_file_name(file_name) + if length(temp) = 0 then return 0 end if + + file_name = canonical_path(temp, 0, CORRECT) + tab_file_names[current_tab] = file_name + if save_file() = 0 then + return 0 + end if + update_tab_name() + update_lexer() + return 1 +end function + + +global function save_if_modified(integer confirm) -- returns 1 if ok, 0 if cancelled/error + atom result, junk + sequence text + + if not get_modified() and (length(file_name) != 0 or confirm) then + return 1 + end if + + if confirm then + text = "" + if length(file_name) then + text = " in " & file_name + end if + text = "The text"&text&" has changed.\n\nDo you want to save the changes?" + result = ui_message_box_yes_no_cancel(window_title, text) + if result != 1 then -- no or cancel + return result + 1 + end if + end if + + if length(file_name) = 0 then + return save_file_as() + end if + return save_file() +end function + +global function save_modified_tabs() --returns 1 if ok, 0 if cancelled + integer idx + atom saved_hedit + saved_hedit = hedit + for tab = 1 to length(tab_hedits) do + hedit = tab_hedits[tab] + idx = find(tab_file_names[tab], recent_files) + if idx then + recent_pos[idx] = get_pos() + end if + if get_modified() then + select_tab(tab) + if save_if_modified(1) = 0 then + return 0 -- cancelled + end if + saved_hedit = hedit + end if + end for + hedit = saved_hedit + return 1 +end function + +global procedure new_file() + atom junk + + new_tab("") + ssm(SCI_SETTEXT, 0, "") + ssm(SCI_SETSAVEPOINT, 0, 0) +end procedure + + +global procedure check_externally_modified_tabs() + atom ts + for i = 1 to length(tab_file_names) do + if length(tab_file_names[i]) and tab_timestamps[i] != -1 then + ts = get_timestamp(tab_file_names[i]) + if ts != tab_timestamps[i] then + -- clear the timestamp here so that don't repeat when the MessageBox retriggers WM_SETFOCUS + tab_timestamps[i] = -1 + if ui_message_box_yes_no(window_title, tab_file_names[i] & + "\n\nThis file has been modified by another application. Do you want to reload it?") then + integer pos + select_tab(i) + pos = get_pos() + open_file(tab_file_names[i], 1) + goto_pos(pos) + else + tab_timestamps[i] = ts + end if + end if + end if + end for +end procedure + + +global procedure add_recent_file(sequence filename) + integer idx + idx = find(filename, recent_files) + if idx then + -- move it to the top of the list + recent_files = {recent_files[idx]} & recent_files[1..idx-1] & + recent_files[idx+1..length(recent_files)] + recent_pos = {recent_pos[idx]} & recent_pos[1..idx-1] & + recent_pos[idx+1..length(recent_pos)] + else + idx = length(recent_files) + if idx >= max_recent_files then + idx -= 1 + end if + recent_files = {filename} & recent_files[1..idx] + recent_pos = {0} & recent_pos[1..idx] + end if + ui_refresh_file_menu(recent_files) +end procedure + +global procedure save_recent_pos() + integer idx + idx = find(file_name, recent_files) + if idx then + recent_pos[idx] = get_pos() + end if +end procedure + +global procedure open_recent(integer idx) + atom junk + integer tab + if idx >= 1 and idx <= length(recent_files) then + tab = open_file(recent_files[idx], 0) + if tab then + ssm(SCI_SETSEL, recent_pos[1], recent_pos[1]) + set_top_line(-1) -- set the top visible line to the current line + end if + end if +end procedure + + +-------------------------------------- +-- help routines +-------------------------------------- + +sequence help_dir + +function tr(sequence s, sequence src, sequence dst) + for i = 1 to length(s) do + integer x = find(s[i], src) + if x then + s[i] = dst[x] + end if + end for + return s +end function + +global procedure context_help() + sequence text, decls, word, name_space, path + integer pos, junk + object help + + text = get_edit_text() + pos = get_pos() + word = word_pos(text, pos) + if length(word) < 2 then + name_space = "" + word = "" + else + name_space = word[2] + word = word[1] + end if + + -- load the search.dat file + if length(search_dat) = 0 then + sequence paths = include_search_paths + for i = 1 to length(paths) do + path = paths[i] + if path[$] = SLASH then + path = path[1..$-1] + end if + path &= join_path({"..","docs","html"}) & SLASH + --puts(1, path&"\n") + integer f = open(path & "js" & SLASH & "search.js","r") + if f != -1 then + help_dir = canonical_path(path) + if help_dir[$] != SLASH then + help_dir &= SLASH + end if + object line = gets(f) + while sequence(line) do + integer x = find(':', line) + if x and line[1] = '"' then + --puts(1, line[2..x-2]&" "&line[x+1..$]&"\n") + search_idx = append(search_idx, line[2..x-2]) + line = tr(line[x+1..$-1], "[]", "{}") + line = value(line) + search_dat = append(search_dat, line[2]) + end if + line = gets(f) + end while + close(f) + exit + end if + end for + if length(search_dat) = 0 then + ui_message_box_error(window_title, "File not found: euphoria/docs/html/js/search.js") + return + end if + end if + + -- search search.dat for matching entry + help = {} + for i = 1 to length(search_idx) do + if equal(search_idx[i], word) then + help = search_dat[i] + exit + end if + end for + if atom(help) or length(help) = 0 then + ui_message_box_error("Help", + "Didn't find any help on the topic: "&word& + "\nPlease put the cursor over an Euphoria identifier"& + "\nor standard library routine and try again.") + return + end if + + if length(help) > 1 then + -- multiple help entries + path = "" + decls = get_declarations(parse(text, file_name), pos, name_space) + for j = 1 to length(decls) by 2 do + if equal(decls[j], word) then + if atom(decls[j+1]) then + path = file_name + else + path = decls[j+1][1] + end if + + for i = 1 to length(help) do + if match(sreplace(help[i][1],"_",{SLASH})&".e", path) then + --show_help(help[i][1], help[i][2]) + ui_show_uri("file://" & help_dir & help[i][1] & ".html#" & help[i][2]) + return + end if + end for + end if + end for + end if + + -- only one help entry, just show it + --show_help(help[1][1], help[1][2]) + ui_show_uri("file://" & help_dir & help[1][1] & ".html#" & help[1][2]) +end procedure + +global procedure release_notes() + new_file() + ssm(SCI_SETLEXER, SCLEX_NULL) + ssm(SCI_SETTEXT, 0, changelog) + ssm(SCI_SETSAVEPOINT) +end procedure + +global procedure open_tutorial() + new_file() + ssm(SCI_SETTEXT, 0, ` +---------------------------------------- +-- Welcome to the Wee Euphoria Editor -- +---------------------------------------- + +-- Scintilla Keys: +-- +-- Text Size +-- Magnify Control keypad + +-- Reduce Control keypad - +-- Normal Control keypad / +-- +-- Cursor Movement +-- Go to start of document Control Home +-- Go to end of document Control End +-- Go to start of line Home +-- Go to end of line End +-- Go to previous paragraph Control Up +-- Go to next paragraph Control Down +-- Go to previous word Control Left +-- Go to next word Control Right +-- (shift extends selection) +-- +-- Delete Text +-- To start of line Control Shift Backspace +-- To start of word Control Backspace +-- To end of word Control Delete +-- +-- Indent +-- Indent block Tab +-- Unindent block Shift Tab +-- Comment/uncomment block Control M + +-- Editor Tab Management +-- Switch to next tab Control PgDn / Control Tab +-- Switch to previous tab Control PgUp / Shift Control Tab +-- Switch tabs Mouse wheel +-- Tab menu Right click +-- Close tab Middle click + +-- Wee offers autocompletion for the following keywords. +-- Type a space at the end of each keyword below to see the +-- expansion. After the expansion, press Enter to jump over +-- the "then" or "do" to the next line. + +if + +------------------------- +while + +------------------------- +switch + +------------------------- +procedure + +------------------------- +function + +------------------------- +type + +------------------------- +for + +-- The "for" keyword also inserts " = to " but is overtypable, +-- meaning you can continue typing " = " and it will replace the +-- existing characters. Or you can move your cursor using the +-- arrow keys. + +-- Likewise, pair characters are inserted for typing the following +-- characters: ( [ { " ' +-- And you can overtype the closing character if you wish. +-- Pressing "(" results in "()" +-- Typing "123" results in "(123)" +-- Pressing ")" results in "(123)" +-- Try it! + +-- Here's a longer example demonstrating the overtype mechanism: + +-- type result +-- ------- --------------------- +-- foo[ foo[] +-- 123 foo[123] +-- ] foo[123] +-- [ foo[123][] +-- ( foo[123][()] +-- i+1 foo[123][(i+1)] +-- )*2 foo[123][(i+1)*2] +-- ] foo[123][(i+1)*2] +-- = { foo[123][(i+1)*2] = {} +-- 1, { foo[123][(i+1)*2] = {1, {}} +-- " foo[123][(i+1)*2] = {1, {""}} +-- bar foo[123][(i+1)*2] = {1, {"bar"}} +-- " foo[123][(i+1)*2] = {1, {"bar"}} +-- } foo[123][(i+1)*2] = {1, {"bar"}} +-- } foo[123][(i+1)*2] = {1, {"bar"}} + + +-- If the initial character is deleted using backspace, the +-- inserted pair will also be removed. (This does not work +-- with quotation marks however, only parens and braces.) +-- Pressing "(" results in "()" +-- Pressing backspace results in "" + +-- Wee also knows about subroutines you've defined. +-- Press F2 to see a list. If you've filled in names for the +-- subroutine declarations above, they should appear. +-- Pressing OK or Enter will move the cursor to the subroutine +-- definition. If your cursor is on the name of an existing +-- subroutine, it will be the highlighted entry. +-- Try it! Type the name of a subroutine and hit F2. + + +-- Autocompletion for any type of identifier is done with +-- Control+Space. The standard library is also searched for +-- completions, indicated by "--include" in the list entry, and +-- when selected, the include statement will be inserted +-- automatically near the top of the file. + + +-- Typing ':' after a namespace identifier will show an auto- +-- complete list for definitions within a specific namespace. + + +-- Pressing Ctrl+F2 while on an identifier will move the cursor +-- to the definition of that identifier, and select it. +-- Pressing escape will deselect the text, and pressing escape +-- again will return the cursor to the previous location, think +-- of it as pressing Back in a web browser. + + +-- Pressing Shift+F2 while on a subroutine identifier will display +-- a calltips popup. The popup shows the types and names of the +-- arguments to the subroutine, with default arguments enclosed in +-- square brackets. + + +-- Typing '(' after a subroutine identifier will show the calltips +-- popup, and highlight the argument position as you type. + + +-- Pressing F4 will open a dialog showing the most recent ex.err +-- file, with the error message and a list of either: +-- the call stack of the subroutines at the point of the crash, +-- or a list of undefined symbols. +-- Select an item in the list and press Goto Error to move the +-- cursor to that location. + + +-- That's all, have fun! +`) + ssm(SCI_SETSAVEPOINT) +end procedure + + + +------------------------------------------------------------------- +-- ex.err file handling routines +------------------------------------------------------------------- + +-- returns {"filename:line", "message", "line1", "line2", "line3"...} +global function get_ex_err() + integer fn + object line, msg, txt + sequence result, tmp + + fn = open(ex_err_name, "r") + if fn = -1 then + return {} + end if + result = {} + line = gets(fn) -- filename:line + if not atom(line) then + msg = gets(fn) + result = {line, msg} + if match("Errors resolving the following references", msg) then + txt = gets(fn) + while sequence(txt) and length(txt) > 1 do + result = append(result, txt) + txt = gets(fn) + end while + else + result = append(result, line) + tmp = "... called from " + txt = gets(fn) + while sequence(txt) and length(result) < 100 do + if length(txt) > length(tmp) and equal(txt[1..length(tmp)], tmp) then + result = append(result, txt[length(tmp)+1..$]) + end if + txt = gets(fn) + end while + end if + end if + close(fn) + return result +end function + +-- get the text between two delimeters, searching from end of text +function text_between(sequence text, integer delim1, integer delim2) + for i = length(text) to 1 by -1 do + if text[i] = delim2 then + for j = i-1 to 1 by -1 do + if text[j] = delim1 then + return text[j+1..i-1] + end if + end for + exit + end if + end for + return "" +end function + +global procedure goto_error(sequence err, integer idx) + integer a, b, c, line, tab, col + sequence val, file, item, text + + if idx < 0 or idx > length(err)-2 then + return + end if + + text = err[idx+2] + + a = find('(', text) + b = find(')', text) + c = 0 + for i = length(text) to 1 by -1 do + if text[i] = ':' then + c = i + exit + end if + end for + item = "" + if a < c and c < b then + -- 'blah' (filename:line) has not been declared + file = dirname(ex_err_name) & SLASH & text[a+1..c-1] + val = value(text[c+1..b-1]) + item = text_between(text, '\'', '\'') + elsif c then + -- c:\path\to\filename.ext:line subroutine_name() + file = text[1..c-1] + val = value(text[c+1..$]) + item = text_between(err[2], '\'', '\'') + else + return + end if + tab = open_file(file, 0) + if tab and val[1] = GET_SUCCESS then + line = val[2]-1 + col = 0 + if length(item) then + col = match(item, get_line(line)) + if col then + col -= 1 + else + item = "" + end if + end if + col += ssm(SCI_POSITIONFROMLINE, line) + ssm(SCI_SETSEL, col, col + length(item)) + set_top_line(line) + end if +end procedure + +global procedure reset_ex_err() + if length(run_file_name) = 0 then + return + end if + ex_err_name = dirname(run_file_name) & SLASH & "ex.err" + ex_err_timestamp = get_timestamp(ex_err_name) +end procedure + +global procedure check_ex_err() + atom ts + + if length(run_file_name) = 0 then return end if + + ts = get_timestamp(ex_err_name) + if ts > ex_err_timestamp then + run_file_name = "" + ui_view_error() + end if + ex_err_timestamp = ts +end procedure + + +------------------------------------------------------------------- +-- code syntax routines +------------------------------------------------------------------- + +-- move to the declaration of the word under the cursor +global procedure view_declaration() + sequence text, decls, word, name_space + integer pos + + text = get_edit_text() + pos = get_pos() + word = word_pos(text, pos) + if length(word) < 2 then return end if + name_space = word[2] + word = word[1] + + decls = get_declarations(parse(text, file_name), pos, name_space) + for i = 1 to length(decls) do + if equal(decls[i][1], word) then + goto_pos(decls[i][2], length(word)) + exit + end if + end for +end procedure + +-- check the current document for errors, show underline indicators +procedure do_error_indicators() + if ssm(SCI_GETLEXER) != SCLEX_LUA then + return + end if + sequence text = get_edit_text() + sequence s = parse_errors(text, file_name) + if equal(s, last_errors) then + return + end if + last_errors = s + ssm(SCI_INDICATORCLEARRANGE, 0, ssm(SCI_GETTEXTLENGTH)) + for i = 1 to length(s) by 3 do + ssm(SCI_INDICATORFILLRANGE, s[i]-1, s[i+1]) + end for +end procedure + +-- when the mouse hovers over an error, show the message in calltip +procedure dwell_error(integer dwell_pos) + integer pos, len + for i = 1 to length(last_errors) by 3 do + pos = last_errors[i]-1 + len = last_errors[i+1] + if dwell_pos >= pos and dwell_pos < pos + len then + ssm(SCI_CALLTIPSHOW, pos, last_errors[i+2]) + calltip_dwell = 1 + return + end if + end for +end procedure + +-- show a list of possible words when autocomplete is triggered +global procedure view_completions() + sequence text, word, ast, decls, name_space, suggestions + integer pos, junk, style, ns = 0 + + if ssm(SCI_AUTOCACTIVE) then + return -- autocomplete is already active + end if + + pos = get_pos() + + style = ssm(SCI_GETSTYLEAT, pos-2) + if style = SCE_LUA_STRING or style = SCE_LUA_COMMENTLINE then + return -- no completion in strings or comments + end if + + -- use scintilla's code completion + text = get_edit_text() + word = word_pos(text, pos) + if length(word) < 4 then + return + end if + ssm(SCI_SETSEL, word[4], word[4]) + name_space = word[2] + word = word[1] + + ast = parse(text, file_name) + decls = get_declarations(ast, pos, name_space) + + if length(decls) = 0 or length(name_space) = 0 then + suggestions = suggest_includes(word, name_space) + if length(suggestions) = 0 and length(word) = 0 and length(name_space) > 0 then + decls = get_declarations(ast, pos, "") + suggestions = suggest_includes(name_space, "") + ns = DECL_NAMESPACE + word = name_space + end if + + -- filter duplicate suggestions + for i = 1 to length(suggestions) do + sequence tmp = suggestions[i] + if ns = 0 or tmp[3] = ns then + integer found = 0 + tmp = {tmp[1], tmp[1][1..find(' ', tmp[1])-1]} + for j = 1 to length(decls) do + if find(decls[j][1], tmp) then + found = 1 + exit + end if + end for + if not found then + decls = append(decls, suggestions[i]) + end if + end if + end for + end if + + text = "" + for i = 1 to length(decls) do + if (ns = 0 or decls[i][3] = ns) + and length(decls[i][1]) >= length(word) + and equal(decls[i][1][1..length(word)], word) then + if length(text) then + text &= "\n" + end if + text &= decls[i][1] & sprintf("?%d", {decls[i][3]}) + end if + end for + if length(text) then + ssm(SCI_AUTOCSHOW, length(word) * (ns = 0), text) + end if +end procedure + +-- show the subroutine arguments, usually triggered after a pressing '(' +global procedure view_subroutine_arguments() + sequence text, word, decls, name_space + integer pos, end_pos, junk, calltip_save, style + + pos = get_pos() + style = ssm(SCI_GETSTYLEAT, pos-2) + if style = SCE_LUA_STRING or style = SCE_LUA_COMMENTLINE then + return -- no completion in strings or comments + end if + + calltip_save = calltip_pos + if ssm(SCI_GETCHARAT, pos-1) = '(' then + calltip_pos = pos + pos -= 1 + end if + + -- use scintilla's code completion + text = get_edit_text() + word = word_pos(text, pos) + if length(word) < 4 or length(word[1]) = 0 then + calltip_pos = calltip_save + return + end if + pos = word[3] + end_pos = word[4] + name_space = word[2] + word = word[1] + + decls = get_subroutine_arguments(parse(text, file_name), word, name_space) + if length(decls) then + decls = decls[$] -- overloaded? use the last one + if calltip_save != -1 then + calltip_stack &= {calltip_save, calltip_args, calltip_text} + end if + text = decls[1] & " " & decls[2] & "(" + calltip_args = {} + for i = 3 to length(decls) by 3 do + if i != 3 then text &= ", " end if + if decls[i+2] then text &= "[" end if + calltip_args &= {{length(text), 0}} + text &= decls[i] & " " & decls[i+1] + calltip_args[$][2] = length(text) + if decls[i+2] then text &= "]" end if + end for + text &= ")" + --puts(1, text & "\n") + calltip_text = text + ssm(SCI_CALLTIPSHOW, pos, text) + if length(calltip_args) then + --ssm(SCI_CALLTIPSETHLT, calltip_args[1][1], calltip_args[1][2]) + calltip_pos = end_pos+1 + else + calltip_pos = -1 -- no arguments, no need to update + end if + return + end if + + -- decl not found, search includes instead + decls = suggest_includes(word, name_space) + text = "" + for i = 1 to length(decls) by 2 do + if length(decls[i]) >= length(word) and equal(decls[i][1..length(word)], word) then + if length(text) then + text &= '\n' + end if + text &= sreplace(decls[i], " --", "( --") + end if + end for + if length(text) then + ssm(SCI_GOTOPOS, end_pos+1) + ssm(SCI_AUTOCSHOW, length(word)+1, text) + end if +end procedure + + +procedure update_subroutine_arguments() + sequence text + integer pos, arg, ch + + pos = get_pos() + + ch = ssm(SCI_GETCHARAT, pos-1, 0) + if ch != ',' and ch != '(' and ch != ')' and ssm(SCI_GETCHARAT, pos, 0) != ',' and last_deleted_char != ',' then + -- this isn't reliable; backspace over comma, or delete selection containing comma, etc. + return + end if + + while 1 do + + while calltip_pos = -1 or pos < calltip_pos do + if length(calltip_stack) = 0 then + calltip_pos = -1 + return + end if + calltip_pos = calltip_stack[$-2] + calltip_args = calltip_stack[$-1] + calltip_text = calltip_stack[$] + ssm(SCI_CALLTIPSHOW, calltip_pos, calltip_text) + calltip_stack = calltip_stack[1..$-3] + end while + + -- get the text from after '(' up to the cursor + text = repeat(0, pos - calltip_pos) + for i = 1 to length(text) do + text[i] = ssm(SCI_GETCHARAT, calltip_pos+i-1) + end for + + arg = parse_argument_position(text) + if arg = 0 then + -- parsed closing ')' + ssm(SCI_CALLTIPCANCEL) + calltip_pos = -1 + elsif arg > length(calltip_args) then + -- parsed too many arguments + ssm(SCI_CALLTIPSETHLT, 0, 0) + exit + else + -- highlight argument at cursor position + ssm(SCI_CALLTIPSETHLT, calltip_args[arg][1], calltip_args[arg][2]) + exit + end if + + end while +end procedure + + +function ltrim(sequence s) + for i = 1 to length(s) do + if not find(s[i], " \t\n\r") then + return s[i..$] + end if + end for + return "" +end function + +function rtrim(sequence s) + for i = length(s) to 1 by -1 do + if not find(s[i], " \t\n\r") then + return s[1..i] + end if + end for + return "" +end function + + +-- expand "if " to "if then\n\nend if", etc. +procedure auto_expand() + sequence text, indent, indent_str + integer pos, end_pos + atom junk + + if length(expansions) = 0 then + return + end if + + -- make sure the current position is at the end of the line + pos = get_pos() + end_pos = get_line_end_position(-1) + if pos != end_pos then return end if + + -- save the indentation and trim the line + indent = get_line(-1) + text = ltrim(indent) + indent = "\n" & indent[1..$-length(text)] + text = rtrim(text) + + -- try the expansions and get the text to insert + for i = 1 to length(expansions) do + if integer(expansions[i][1]) then + -- try removing "global", "public", "export" + for k = 2 to length(expansions[i]) do + if match(expansions[i][k], text) = 1 then + text = ltrim(text[length(expansions[i][k])..$]) + exit + end if + end for + elsif equal(text, expansions[i][1]) then + text = expansions[i][2..$] + insert_chars = reverse(text[1]) + exit + elsif i = length(expansions) then + return + end if + end for + + indent_str = repeat(' ', ssm(SCI_GETINDENT)) + if length(text) >= 3 then + indent_str &= indent & text[3] + end if + text = text[1] & text[2] & indent & indent_str + + -- save the line for auto_indent() + expand_line = ssm(SCI_LINEFROMPOSITION, pos) + + -- insert the text and restore cursor position + ssm(SCI_INSERTTEXT, pos, text) +end procedure + + +procedure do_auto_indent() + integer line, pos, end_pos + sequence indent + + -- get the previous line and get the indentation + pos = get_pos() + line = ssm(SCI_LINEFROMPOSITION, pos) - 1 + end_pos = get_line_end_position(line) + + if line = expand_line then + -- delete the newline character and go to end of the next line + ssm(SCI_DELETERANGE, end_pos, pos - end_pos) + end_pos = get_line_end_position(line + 1) + ssm(SCI_GOTOPOS, end_pos) + expand_line = -1 + insert_chars = {} + return + end if + expand_line = -1 + + -- get the indentation of the previous line, and remove newline + indent = get_line(line) + for i = length(indent)-length(ltrim(indent)) to 0 by -1 do + if i = 0 or (indent[i] != '\n' and indent[i] != '\r') then + indent = indent[1..i] + exit + end if + end for + + -- insert the indentation + ssm(SCI_ADDTEXT, length(indent), indent) +end procedure + + +procedure do_brace_highlight(atom hedit) + integer pos, brace, ch + brace = -1 + pos = get_pos()-1 + if find(ssm(SCI_GETCHARAT, pos, 0), "{}()[]") then + brace = ssm(SCI_BRACEMATCH, pos, 0) + end if + if brace = -1 then + pos += 1 + if find(ssm(SCI_GETCHARAT, pos, 0), "{}()[]") then + brace = ssm(SCI_BRACEMATCH, pos, 0) + end if + if brace = -1 then + pos = -1 + end if + end if + brace = ssm(SCI_BRACEHIGHLIGHT, pos, brace) +end procedure +-- FIXME: this has a problem with brace chars within strings, for ex: {1, "}{", 2} + + +procedure auto_complete_selection(integer pos, sequence text) + integer inc, len, insert_line, arg, ns + sequence line + + -- insert include statement if completion contains it + inc = match(" --include", text) + + ns = find(':', text) + if ns and ssm(SCI_GETCHARAT, pos-1) = ':' then + line = "" + while length(line) < ns do + line = ssm(SCI_GETCHARAT, pos-length(line)-2) & line + if equal(line, text[1..length(line)]) then + ssm(SCI_DELETERANGE, pos-length(line)-1, length(line)+1) + exit + end if + end while + if not inc then + ssm(SCI_ADDTEXT, length(text), text) + ssm(SCI_AUTOCCANCEL, 0, 0) + end if + end if + + if inc then + ssm(SCI_AUTOCCANCEL, 0, 0) + + len = get_pos() - pos + + arg = text[inc-1] = '(' + if arg then + -- delete the existing '(' since we are adding another one + len -= 1 + ssm(SCI_DELETERANGE, pos + len, 1) + end if + + if len < 0 then + len = 0 + end if + -- add in the selected text + if len+1 <= inc then + ssm(SCI_ADDTEXT, inc-1-len, text[len+1..inc]) + end if + text = text[inc+3..$] & "\n" + + -- search first few lines for include statements + insert_line = -1 + for i = 0 to 100 do + line = ltrim(get_line(i)) + if length(line) >= 8 and equal(line[1..8], "include ") then + insert_line = i+1 + elsif insert_line != -1 then + exit + end if + end for + if insert_line = -1 then + -- insert after consecutive comment lines + insert_line = 0 + for i = 0 to 100 do + line = ltrim(get_line(i)) + if length(line) >= 2 and line[1]='-' and line[2]='-' then + insert_line = i+1 + else + exit + end if + end for + end if + inc = ssm(SCI_POSITIONFROMLINE, insert_line, 0) + if inc = -1 or inc > pos then + inc = 0 + end if + ssm(SCI_INSERTTEXT, inc, text) + if arg then + view_subroutine_arguments() + end if + end if + +end procedure + +-- insert closing character when user types ( [ { ' " +procedure insert_pair() + integer pos, style, ch + + if not complete_braces then return end if + + pos = get_pos()-1 + + -- avoid inside strings and comments + if pos != get_line_start_position(-1) then + style = ssm(SCI_GETSTYLEAT, pos-1) + if style = SCE_LUA_COMMENTLINE or + (style = SCE_LUA_STRING and + style = ssm(SCI_GETSTYLEAT, pos+1)) then + return + end if + end if + + -- avoid inside words or numbers + for i = pos+1 to get_line_end_position(-1) do + ch = ssm(SCI_GETCHARAT, i) + style = ssm(SCI_GETSTYLEAT, i) + if find(ch, ",)}]\r\n+-*/=!<>#&\0") or style = SCE_LUA_WORD then + exit + elsif ch != ' ' and ch != '\t' then + return + end if + end for + ch = ssm(SCI_GETCHARAT, pos, 0) + if ch = '(' then + ch = ')' + elsif ch = '{' then + ch = '}' + elsif ch = '[' then + ch = ']' + end if + ssm(SCI_INSERTTEXT, pos+1, {ch}) + insert_chars &= ch +end procedure + +-- remove the characters inserted by insert_pair(), won't work for ' " tho +procedure delete_pair() + if length(insert_chars) = 0 then + return + end if + if insert_chars[$] = last_deleted_char then + insert_chars = insert_chars[1..$-1] + elsif (last_deleted_char = '(' and insert_chars[$] = ')') or + (last_deleted_char = '[' and insert_chars[$] = ']') or + (last_deleted_char = '{' and insert_chars[$] = '}') then + ssm(SCI_DELETERANGE, get_pos(), 1) + insert_chars = insert_chars[1..$-1] + end if +end procedure + +-- open file(s) from a drag and drop operation +procedure open_uri(sequence uri) + uri = split(uri, "\r\n") + for i = 1 to length(uri) do + if match("file://", uri[i]) = 1 then + open_file(uri[i][8..$], 0) + end if + end for +end procedure + +-- toggle the comment at the start of each line in selection +global procedure toggle_comment() + integer + pos = ssm(SCI_GETCURRENTPOS), + anchor = ssm(SCI_GETANCHOR), + line_pos = ssm(SCI_LINEFROMPOSITION, pos), + line_anchor = ssm(SCI_LINEFROMPOSITION, anchor), + col_pos = pos - ssm(SCI_POSITIONFROMLINE, line_pos), + col_anchor = anchor - ssm(SCI_POSITIONFROMLINE, line_anchor), + line_start = ssm(SCI_LINEFROMPOSITION, ssm(SCI_GETSELECTIONSTART)), + line_end = ssm(SCI_LINEFROMPOSITION, ssm(SCI_GETSELECTIONEND)-1) + integer uncomment = 1 + if line_end < line_start then + line_end = line_start + end if + -- check to see if all lines are commented + for i = line_start to line_end do + pos = ssm(SCI_POSITIONFROMLINE, i) + if ssm(SCI_GETCHARAT, pos) != '-' or + ssm(SCI_GETCHARAT, pos+1) != '-' then + uncomment = 0 -- non comment detected + exit + end if + end for + -- insert/remove comment markers + ssm(SCI_BEGINUNDOACTION) + for i = line_start to line_end do + pos = ssm(SCI_POSITIONFROMLINE, i) + if uncomment then + ssm(SCI_DELETERANGE, pos, 2) + else + ssm(SCI_INSERTTEXT, pos, "--") + end if + end for + ssm(SCI_ENDUNDOACTION) + -- adjust the selection to be the same column as it was before + pos = ssm(SCI_POSITIONFROMLINE, line_pos) + col_pos + anchor = ssm(SCI_POSITIONFROMLINE, line_anchor) + col_anchor + if col_pos != 0 then + pos -= uncomment*4-2 + end if + if col_anchor != 0 then + anchor -= uncomment*4-2 + end if + ssm(SCI_SETSEL, anchor, pos) +end procedure + +------------------------------------------------------------------- +-- eu.cfg handling +------------------------------------------------------------------- + +-- returns a list of interpreters that exist on disk +global function get_interpreters() + sequence paths, try, exe, bin, result = {} + integer index + + if find(fileext(file_name), {"ew","exw"}) then + bin = {"euiw", "eui", "exw", "ex"} + else + bin = {"eui", "euiw", "ex", "exw"} + end if + ifdef UNIX then + bin = append(bin, "exu") + end ifdef + paths = parse_eu_cfg(dirname(file_name) & SLASH & "eu.cfg") + paths &= include_search_paths -- fallback to running interpreter + for i = 1 to length(paths) do + try = paths[i] + if try[$] = SLASH then + try = try[1..$-1] + end if + for j = 1 to length(bin) do + exe = try & join_path({"..", "bin", bin[j]}) + ifdef WINDOWS then + exe &= ".exe" + end ifdef + exe = canonical_path(exe) + if not find(exe, result) and file_exists(exe) then + result = append(result, exe) + end if + end for + end for + if length(interpreter) and not find(interpreter, result) then + result = prepend(result, interpreter) + end if + return result +end function + +-- if bin="" returns an interpreter from one of these locations: +-- interpreter global variable if set +-- some interpreter from the paths in eu.cfg +-- the running interpreter's include_paths +-- if bin is "eubind" "eushroud" or "euc" then use the same search +-- paths as above to locate it +global function get_eu_bin(sequence bin) + sequence paths, try, exe + + if length(bin) = 0 then + if length(interpreter) != 0 then + return interpreter + end if + if find(fileext(file_name), {"ew","exw"}) then + bin = {"euiw", "eui", "exw", "ex"} + else + bin = {"eui", "euiw", "ex", "exw"} + end if + ifdef UNIX then + bin = append(bin, "exu") + end ifdef + else + bin = {bin} + end if + + paths = parse_eu_cfg(dirname(file_name) & SLASH & "eu.cfg") + paths &= include_search_paths -- fallback to running interpreter + try = dirname(interpreter) + if length(try) then + paths = prepend(paths, try) + end if + for i = 1 to length(paths) do + try = paths[i] + if try[$] = SLASH then + try = try[1..$-1] + end if + for j = 1 to length(bin) do + exe = try & join_path({"..", "bin", bin[j]}) + ifdef WINDOWS then + exe &= ".exe" + end ifdef + exe = canonical_path(exe) + if file_exists(exe) then + return exe + end if + end for + end for + return bin[1] +end function + +-- returns text in quotes if it contains spaces +global function quote_spaces(sequence text) + if find(' ', text) then + for i = length(text) to 1 by -1 do + if text[i] = '"' or text[i] = '\\' then + text = text[1..i-1] & '\\' & text[i..$] + end if + end for + return '"' & text & '"' + end if + return text +end function + + +------------------------------------------------------------------- +-- scintilla editor notifications +------------------------------------------------------------------- + +procedure log_notification(atom notification) + integer code, pos, ch, modifiers + code = peek4u(notification+8) + pos = peek4u(notification+12) + if code = SCN_STYLENEEDED then + puts(1, "SCN_STYLENEEDED\n") + elsif code = SCN_CHARADDED then + ch = peek4s(notification+16) + printf(1, "SCN_CHARADDED ch=%d '%s'\n", {ch, {ch}}) + elsif code = SCN_SAVEPOINTREACHED then + puts(1, "SCN_SAVEPOINTREACHED\n") + elsif code = SCN_SAVEPOINTLEFT then + puts(1, "SCN_SAVEPOINTLEFT\n") + elsif code = SCN_MODIFYATTEMPTRO then + puts(1, "SCN_MODIFYATTEMPTRO\n") + elsif code = SCN_KEY then + ch = peek4s(notification+16) + modifiers = peek4s(notification+20) + printf(1, "SCN_KEY ch=%d modifiers=#%x\n", {ch, modifiers}) + elsif code = SCN_DOUBLECLICK then + puts(1, "SCN_DOUBLECLICK\n") + elsif code = SCN_UPDATEUI then + printf(1, "SCN_UPDATEUI updated=#%x\n", {peek4s(notification+88)}) + elsif code = SCN_MODIFIED then + puts(1, "SCN_MODIFIED\n") + elsif code = SCN_MACRORECORD then + puts(1, "SCN_MACRORECORD\n") + elsif code = SCN_MARGINCLICK then + puts(1, "SCN_MARGINCLICK\n") + elsif code = SCN_NEEDSHOWN then + puts(1, "SCN_NEEDSHOWN\n") + elsif code = SCN_PAINTED then + --gets sent after each caret blink + --puts(1, "SCN_PAINTED\n") + elsif code = SCN_USERLISTSELECTION then + puts(1, "SCN_USERLISTSELECTION\n") + elsif code = SCN_URIDROPPED then + puts(1, "SCN_URIDROPPED\n") + elsif code = SCN_DWELLSTART then + puts(1, "SCN_DWELLSTART\n") + elsif code = SCN_DWELLEND then + puts(1, "SCN_DWELLEND\n") + elsif code = SCN_ZOOM then + puts(1, "SCN_ZOOM\n") + elsif code = SCN_HOTSPOTCLICK then + puts(1, "SCN_HOTSPOTCLICK\n") + elsif code = SCN_HOTSPOTDOUBLECLICK then + puts(1, "SCN_HOTSPOTDOUBLECLICK\n") + elsif code = SCN_HOTSPOTRELEASECLICK then + puts(1, "SCN_HOTSPOTRELEASECLICK\n") + elsif code = SCN_INDICATORCLICK then + puts(1, "SCN_INDICATORCLICK\n") + elsif code = SCN_INDICATORRELEASE then + puts(1, "SCN_INDICATORRELEASE\n") + elsif code = SCN_CALLTIPCLICK then + puts(1, "SCN_CALLTIPCLICK\n") + elsif code = SCN_AUTOCSELECTION then + puts(1, "SCN_AUTOCSELECTION\n") + elsif code = SCN_AUTOCCANCELLED then + puts(1, "SCN_AUTOCCANCELLED\n") + elsif code = SCN_AUTOCCHARDELETED then + puts(1, "SCN_AUTOCCHARDELETED\n") + elsif code = SCN_FOCUSIN then + puts(1, "SCN_FOCUSIN\n") + elsif code = SCN_FOCUSOUT then + puts(1, "SCN_FOCUSOUT\n") + end if +end procedure + +ifdef BITS64 then +constant + NOTIFICATION_CODE = 16, + NOTIFICATION_POS = 24, + NOTIFICATION_CH = 28, + NOTIFICATION_MODIFIERS = 32, + NOTIFICATION_MODIFICATIONTYPE = 36, + NOTIFICATION_TEXT = 40, + NOTIFICATION_LENGTH = 48, + NOTIFICATION_UPDATED = 116 +elsedef +constant + NOTIFICATION_CODE = 8, + NOTIFICATION_POS = 12, + NOTIFICATION_CH = 16, + NOTIFICATION_MODIFIERS = 20, + NOTIFICATION_MODIFICATIONTYPE = 24, + NOTIFICATION_TEXT = 28, + NOTIFICATION_LENGTH = 32, + NOTIFICATION_UPDATED = 88 +end ifdef + +function notification_text(atom notification) + ifdef BITS64 then + return peek_string(peek8u(notification+NOTIFICATION_TEXT)) + elsedef + return peek_string(peek4u(notification+NOTIFICATION_TEXT)) + end ifdef +end function + +global function sci_notify(atom hedit, atom data, atom notification, atom userdata) + integer code, pos, ch, modifiers, updated, len + + if notification = 0 then return 0 end if + --log_notification(notification) + code = peek4u(notification+NOTIFICATION_CODE) + if code = SCN_UPDATEUI then + updated = peek4u(notification+NOTIFICATION_UPDATED) + if ssm(SCI_CALLTIPACTIVE) then + update_subroutine_arguments() + end if + if and_bits(updated, SC_UPDATE_SELECTION+SC_UPDATE_CONTENT) = SC_UPDATE_SELECTION then + -- selection moved and content was not changed + insert_chars = "" + elsif last_deleted_char then + delete_pair() + last_deleted_char = 0 + end if + if and_bits(updated, SC_UPDATE_SELECTION) then + update_status() + end if + + do_brace_highlight(hedit) + + elsif code = SCN_SAVEPOINTREACHED or code = SCN_SAVEPOINTLEFT then + modified = (code = SCN_SAVEPOINTLEFT) + update_tab_name() + + elsif code = SCN_KEY then + ch = peek4s(notification+NOTIFICATION_CH) + modifiers = peek4s(notification+NOTIFICATION_MODIFIERS) + -- on OSX X11, META and SHIFT are the only modifiers we receive + + if ch = 'Z' and and_bits(modifiers, SCMOD_CTRL+SCMOD_META) then + if and_bits(modifiers, SCMOD_SHIFT) then + ssm(SCI_REDO, 0, 0) + else + ssm(SCI_UNDO, 0, 0) + end if + + elsif ch >= '1' and ch <= '9' and and_bits(modifiers, SCMOD_ALT+SCMOD_META) then + select_tab(ch - '0') + + elsif ch < 128 then + --printf(1, "SCN_KEY ch=%d '%s' modifiers=%d\n", {ch, {ch}, modifiers}) + else + --printf(1, "SCN_KEY ch=#%x modifiers=%d\n", {ch, modifiers}) + end if + + elsif code = SCN_CHARADDED then + ch = peek4s(notification+NOTIFICATION_CH) + + if length(insert_chars) and ch = insert_chars[$] then + -- the user retyped the insert character, so delete it + ssm(SCI_DELETERANGE, get_pos(), 1) + -- the UPDATEUI will remove the insert_chars[$] + elsif ch = ':' and auto_namespace then + view_completions() + elsif ch = ' ' and complete_statements then + auto_expand() + elsif ch = '\n' and auto_indent then + do_auto_indent() + elsif ch = '(' then + -- check for displaying subroutine arguments + if complete_braces then + insert_pair() + end if + if auto_arguments then + view_subroutine_arguments() + end if + elsif ch = '{' or ch = '[' and complete_braces then + insert_pair() + elsif ch = '"' or ch = '\'' and complete_braces then + insert_pair() + end if + + elsif code = SCN_AUTOCSELECTION then + -- check for "--include" in selection, then add include statement near top of file + -- or after the first non-commented line, or ideally with other includes + pos = peek4s(notification+NOTIFICATION_POS) + auto_complete_selection(pos, notification_text(notification)) + + elsif code = SCN_MODIFIED then + modifiers = peek4u(notification+NOTIFICATION_MODIFICATIONTYPE) + if and_bits(modifiers, SC_MOD_BEFOREDELETE) then + pos = peek4s(notification+NOTIFICATION_POS) + len = peek4u(notification+NOTIFICATION_LENGTH) + if len = 1 then + last_deleted_char = ssm(SCI_GETCHARAT, pos) + end if + end if + if auto_indicator and ssm(SCI_GETLEXER) = SCLEX_LUA and + and_bits(modifiers, SC_MOD_INSERTTEXT + SC_MOD_DELETETEXT) then + change_time = time() + .5 + end if + + elsif code = SCN_URIDROPPED then + open_uri(notification_text(notification)) + + elsif code = SCN_DWELLSTART then + pos = peek4s(notification+NOTIFICATION_POS) + if change_time = 0 then + dwell_error(pos) + end if + + elsif code = SCN_DWELLEND then + if calltip_dwell then + ssm(SCI_CALLTIPCANCEL) + calltip_dwell = 0 + end if + + elsif code = SCN_PAINTED then + -- could run some background processing during painted, every time cursor blinks + + if auto_indicator and change_time and change_time <= time() then + do_error_indicators() + change_time = 0 + end if + end if + return 0 +end function diff --git a/tools/WEE/wee.ico b/tools/WEE/wee.ico new file mode 100644 index 0000000..c7acba2 Binary files /dev/null and b/tools/WEE/wee.ico differ diff --git a/tools/WEE/weeicon.e b/tools/WEE/weeicon.e new file mode 100644 index 0000000..668e872 --- /dev/null +++ b/tools/WEE/weeicon.e @@ -0,0 +1,507 @@ +-- wee icons in XPM format + +export constant wee_xpm = { +"32 32 60 1", +" c None", +". c #FF6600", +"+ c #FFFFFF", +"@ c #FED8BF", +"# c #FED3B6", +"$ c #FEEADD", +"% c #FED3B7", +"& c #FE6601", +"* c #FEA56B", +"= c #FEE5D5", +"- c #FEF9F6", +"; c #FEEADE", +"> c #FEA76D", +", c #FE8738", +"' c #FEE9DC", +") c #FE6C0C", +"! c #FEFAF8", +"~ c #FE7A23", +"{ c #FE6B0A", +"] c #FEF5F0", +"^ c #FE7114", +"/ c #FEA469", +"( c #FE6B09", +"_ c #FE9651", +": c #FEE7D8", +"< c #FE8230", +"[ c #FE9854", +"} c #FEA468", +"| c #FE9B5A", +"1 c #FED7BD", +"2 c #FEE6D6", +"3 c #FED9C0", +"4 c #FEAE7A", +"5 c #FEB584", +"6 c #FEC7A3", +"7 c #FECFB0", +"8 c #FECEAE", +"9 c #FED1B3", +"0 c #FEA56A", +"a c #FEF8F5", +"b c #FEF2EB", +"c c #FE771D", +"d c #FEFDFD", +"e c #FEE8DA", +"f c #FEF3EC", +"g c #FE7820", +"h c #FEF6F1", +"i c #FEF9F7", +"j c #FE7419", +"k c #FE6D0D", +"l c #FEDEC9", +"m c #FECBA9", +"n c #FEDAC3", +"o c #FEA870", +"p c #FEB787", +"q c #FEDAC2", +"r c #FE9E5E", +"s c #FEE4D4", +"t c #FEF2EA", +"u c #FE7418", +" ......... ", +" .............. ", +" .................. ", +" .................... ", +" ...................... ", +" ........................ ", +" .......................... ", +" ............................ ", +" ............................ ", +" .............................. ", +" .............................. ", +"............................... ", +"................................", +"...+++@.#$.%++&*=-;>..&*=-;>....", +"...,+'.)!+~{]^>+/(>+_.>+/(>+_...", +"....:+<[++}|1.2+(.{+3.2+(.{+3...", +"....4+567+890.a+++++b.a+++++b...", +"....cdefghhij.2+k.....2+k.......", +".....1+l.m+n..o+pk)>q.o+pk)>q...", +".....r+4.|+o..&>s-tmu.&>s-tmu...", +" .............................. ", +" .............................. ", +" .............................. ", +" ............................ ", +" ............................ ", +" .......................... ", +" ........................ ", +" ...................... ", +" .................... ", +" .................. ", +" .............. ", +" ........ "} + +export constant +a_xpm = `/* XPM */ +"16 16 28 1", +" c None", +". c #3300CC", +"+ c #FFFFFF", +"@ c #FBFBFD", +"# c #E6E1F8", +"$ c #AD99EA", +"% c #4011CE", +"& c #7553DB", +"* c #3807CC", +"= c #8061DE", +"- c #B3A1EB", +"; c #3503CC", +"> c #EBE7F9", +", c #4A1DD1", +"' c #B9A8ED", +") c #FDFDFD", +"! c #CBBEF1", +"~ c #947AE3", +"{ c #3A0ACD", +"] c #F6F4FC", +"^ c #3A09CD", +"/ c #DAD2F5", +"( c #7958DD", +"_ c #3908CC", +": c #8E72E2", +"< c #5F38D6", +"[ c #DAD1F5", +"} c #8162DF", +" ...... ", +" .......... ", +" ............ ", +" .............. ", +" ....++@#$%.... ", +".....+&*=+-.....", +"........;+>.....", +"....,'>)+++.....", +"....!+~{.++.....", +"....]+^.;++.....", +"..../+(_:++.....", +" ...<[]/}+++... ", +" .............. ", +" ............ ", +" .......... ", +" ...... "};`, +c_xpm = `/* XPM */ +static char * c_xpm[] = { +"16 16 33 1", +" c None", +". c #3399CC", +"+ c #6EB6DA", +"@ c #D1E7F3", +"# c #F7FAFC", +"$ c #F2F8FB", +"% c #C3E0EF", +"& c #6AB4D9", +"* c #FDFDFD", +"= c #BFDFEE", +"- c #46A2D0", +"; c #42A0CF", +"> c #BBDDED", +", c #FFFFFF", +"' c #D0E7F2", +") c #55A9D3", +"! c #4AA4D1", +"~ c #F6FAFC", +"{ c #3A9CCD", +"] c #D2E8F3", +"^ c #56AAD4", +"/ c #4BA4D1", +"( c #E1EFF6", +"_ c #72B8DB", +": c #C1DFEF", +"< c #43A0CF", +"[ c #93C8E3", +"} c #73B8DB", +"| c #D4E9F3", +"1 c #F8FBFC", +"2 c #EBF4F9", +"3 c #A4D1E8", +"4 c #3599CC", +" ...... ", +" .......... ", +" ............ ", +" .............. ", +" ....+@#$%&.... ", +"....+*=-;>,.....", +"....',)..!,.....", +"....~,{.........", +"....~,{.........", +"....],^../(.....", +"...._,:-<=[.....", +" ....}|1234.... ", +" .............. ", +" ............ ", +" .......... ", +" ...... "};`, +e_xpm = `/* XPM */ +static char * e_xpm[] = { +"16 16 37 1", +" c None", +". c #CC0099", +"+ c #D844B3", +"@ c #F1C0E5", +"# c #FBF3F9", +"$ c #FCF6FA", +"% c #F3C8E8", +"& c #DA4EB7", +"* c #D945B4", +"= c #FDFCFD", +"- c #E684CD", +"; c #CE0E9E", +"> c #CE0F9E", +", c #E688CF", +"' c #FDFDFD", +") c #D73BB0", +"! c #F2C3E6", +"~ c #FFFFFF", +"{ c #CD0C9D", +"] c #F0B8E2", +"^ c #FCF5FA", +"/ c #F9E9F5", +"( c #CD0B9C", +"_ c #F2C5E7", +": c #D637AE", +"< c #D42DAA", +"[ c #F5D2EC", +"} c #DA4AB6", +"| c #F3C7E8", +"1 c #D32BA9", +"2 c #CC089B", +"3 c #D534AD", +"4 c #F4D0EB", +"5 c #DE5EBE", +"6 c #D948B5", +"7 c #F4CFEB", +"8 c #DE60BF", +" ...... ", +" .......... ", +" ............ ", +" .............. ", +" ....+@#$%&.... ", +"....*=-;>,')....", +"....!~{..;~]....", +"....^~~~~~~/....", +"....^~(.........", +"...._~:...<[....", +"....}'|12345....", +" ....6@##78.... ", +" .............. ", +" ............ ", +" .......... ", +" ...... "};`, +f_xpm = `/* XPM */ +static char * f_xpm[] = { +"16 16 11 1", +" c None", +". c #0044FF", +"+ c #2A62FE", +"@ c #BDCEFE", +"# c #F2F5FE", +"$ c #FFFFFF", +"% c #CBD8FE", +"& c #3A6EFE", +"* c #366BFE", +"= c #FAFBFE", +"- c #0044FE", +" ...... ", +" .......... ", +" ............ ", +" .....+@#$$.... ", +" .....%$&*$.... ", +"......=$-.......", +".....$$$$$......", +"......$$........", +"......$$........", +"......$$........", +"......$$........", +" .....$$....... ", +" .....$$....... ", +" ...$$$$..... ", +" .......... ", +" ...... "};`, +i_xpm = `/* XPM */ +static char * i_xpm[] = { +"16 16 6 1", +" c None", +". c #CC0033", +"+ c #F2C4CF", +"@ c #F2C3CF", +"# c #F3C6D1", +"$ c #FFFFFF", +" ...... ", +" .......... ", +" .....+@..... ", +" ......#+...... ", +" .............. ", +"......$$$.......", +".......$$.......", +".......$$.......", +".......$$.......", +".......$$.......", +".......$$.......", +" ......$$...... ", +" .....$$$$..... ", +" ............ ", +" .......... ", +" ...... "};`, +n_xpm = `/* XPM */ +static char * n_xpm[] = { +"16 16 13 1", +" c None", +". c #CCCCCC", +"+ c #C9C9C9", +"@ c #CBCBCB", +"# c #CACACA", +"$ c #E9E9E9", +"% c #FFFFFF", +"& c #E4E4E4", +"* c #EEEEEE", +"= c #DFDFDF", +"- c #CDCDCD", +"; c #FEFEFE", +"> c #D7D7D7", +" ...... ", +" .......... ", +" ............ ", +" .............. ", +" ...+++@++..... ", +"...#$%%&*%=.....", +"....+%%-+%;+....", +"....+%%++%%+....", +"....+%%++%%+....", +"....+%%++%%+....", +"...#$%%$>%%$....", +" ...++++@+++... ", +" .............. ", +" ............ ", +" .......... ", +" ...... "}; +`, +o_xpm = `/* XPM */ +static char * o_xpm[] = { +"16 16 20 1", +" c None", +". c #00CC99", +"+ c #45D9B4", +"@ c #C2F2E6", +"# c #F5FCFA", +"$ c #FCFDFD", +"% c #A8EDDB", +"& c #16CFA1", +"* c #14CFA0", +"= c #A3ECD9", +"- c #C3F2E6", +"; c #FFFFFF", +"> c #23D2A6", +", c #22D2A6", +"' c #04CC9A", +") c #03CC99", +"! c #A6ECDB", +"~ c #15CFA0", +"{ c #A5ECDA", +"] c #44D8B3", +" ...... ", +" .......... ", +" ............ ", +" .............. ", +" ....+@##@+.... ", +"....+$%&*=$+....", +"....-;>..,;@....", +"....#;'..);#....", +"....#;)..';#....", +"....@;>..>;@....", +"....+$!~*{$]....", +" ....+-##-+.... ", +" .............. ", +" ............ ", +" .......... ", +" ...... "};`, +p_xpm = `/* XPM */ +static char * p_xpm[] = { +"16 16 25 1", +" c None", +". c #FF6600", +"+ c #FFFFFF", +"@ c #FEA66C", +"# c #FEEDE3", +"$ c #FEFAF8", +"% c #FEE3D1", +"& c #FE9854", +"* c #FECAA8", +"= c #FE7216", +"- c #FE7215", +"; c #FE8D42", +"> c #FE7A22", +", c #FE7B24", +"' c #FED8BF", +") c #FE6703", +"! c #FE6804", +"~ c #FEF3EC", +"{ c #FEC9A6", +"] c #FECAA7", +"^ c #FE8E43", +"/ c #FEEEE4", +"( c #FEFBF9", +"_ c #FEE3D2", +": c #FE9A57", +" ...... ", +" .......... ", +" ............ ", +" ...+++@#$%&... ", +" ....++*=-*+;.. ", +".....++>..,+'...", +".....++)..!+~...", +".....++)..!+~...", +".....++>..,+'...", +".....++{--]+^...", +".....++@/(_:....", +" ....++........ ", +" ....++........ ", +" ..++++...... ", +" .......... ", +" ...... "};`, +s_xpm = `/* XPM */ +static char * s_xpm[] = { +"16 16 34 1", +" c None", +". c #33CC00", +"+ c #4BD11F", +"@ c #B6ECA4", +"# c #E8F8E3", +"$ c #FAFDF9", +"% c #FFFFFF", +"& c #D2F3C7", +"* c #7BDD5B", +"= c #38CC07", +"- c #4AD11D", +"; c #C0EEB1", +"> c #F7FCF6", +", c #6AD945", +"' c #35CC03", +") c #CAF1BD", +"! c #F9FCF8", +"~ c #E0F6D9", +"{ c #A4E78D", +"] c #41CE12", +"^ c #44CF16", +"/ c #EBF9E7", +"( c #CBF1BE", +"_ c #4ED222", +": c #3DCD0D", +"< c #77DC55", +"[ c #F6FCF4", +"} c #C8F0BB", +"| c #37CC06", +"1 c #78DC57", +"2 c #D3F3C9", +"3 c #FCFDFC", +"4 c #ECF9E8", +"5 c #BCEDAC", +" ...... ", +" .......... ", +" ............ ", +" .............. ", +" ....+@#$%%%... ", +".....&%*=-;%....", +".....>%,'.-%....", +".....)%%!~{]....", +".....^@/%%%(....", +".....%_.:<%[....", +".....%}_|1%2....", +" ....%%%345+... ", +" .............. ", +" ............ ", +" .......... ", +" ...... "};`, +t_xpm = `/* XPM */ +static char * t_xpm[] = { +"16 16 11 1", +" c None", +". c #CC9900", +"+ c #FFFFFF", +"@ c #F9F4E6", +"# c #D2A622", +"$ c #D5AD34", +"% c #DEBF60", +"& c #F8F2E1", +"* c #FDFCF9", +"= c #F8F3E3", +"- c #DEBE5E", +" ...... ", +" .......... ", +" ............ ", +" .....++....... ", +" .....++....... ", +".....+++++......", +"......++........", +"......++........", +"......++........", +"......++........", +"......++........", +" .....@+#$@.... ", +" .....%&*=-.... ", +" ............ ", +" .......... ", +" ...... "};` + diff --git a/tools/WEE/window.ew b/tools/WEE/window.ew new file mode 100644 index 0000000..5820c8e --- /dev/null +++ b/tools/WEE/window.ew @@ -0,0 +1,2341 @@ +-- window.ew + +include std/error.e +include std/machine.e +include std/dll.e + +global function or_all(sequence s) +-- or together all elements of a sequence + atom result + + result = 0 + for i = 1 to length(s) do + result = or_bits(result, s[i]) + end for + return result +end function + +global function HIWORD(atom x) + return floor(x / 65536) + 65536*(x < 0) +end function + +global function LOWORD(atom x) + return and_bits(x, #FFFF) +end function + +-- bytes must be a power of 2 +function align(atom ptr, integer bytes) + integer result + result = and_bits(ptr, bytes - 1) + if result then + ptr += bytes - result + end if + return ptr +end function + +-- strings ------------------------------------------------------------------ +sequence strings +strings = {} + +-- allocate string that can be garbage collected later +global function alloc_string(object str) + atom ptr + if atom(str) then + return str + end if + ptr = allocate(length(str)+1) + strings = append(strings, ptr) + poke(ptr, str) + poke(ptr + length(str), 0) + return ptr +end function + +-- garbage collect strings +global procedure free_strings() + for i = 1 to length(strings) do + free(strings[i]) + end for + strings = {} +end procedure + +global function peek_string(atom a) + integer i + sequence s + s = "" + if a then + i = peek(a) + while i do + s = append(s, i) + a = a + 1 + i = peek(a) + end while + end if + return s +end function + + +procedure pokeWideCharString(atom ptr, sequence str) + for i = 1 to length(str) by 2 do + if i < length(str) then + poke4(ptr, str[i] + str[i+1]*#10000) + else + poke4(ptr, str[i]) + return + end if + ptr += 4 + end for + poke(ptr, {0, 0}) +end procedure + +global function allocWideCharString(sequence s) + atom ptr + ptr = allocate(length(s) * 2 + 2) + strings = append(strings, ptr) + pokeWideCharString(ptr, s) + return ptr +end function + +global function peekWideCharString(atom ptr) + sequence result + integer ch + if ptr = 0 then + return 0 + end if + result = "" + ch = peek2u(ptr) + while ch do + result &= ch + ptr += 2 + ch = peek2u(ptr) + end while + return result +end function + + +-- structs ------------------------------------------------------------------ + +-- pack/unpack pattern characters +-- "d" dword 4 bytes +-- "w" word 2 bytes +-- "b" byte 1 byte +-- "i" int 4 bytes +-- "c" char 1 byte +-- "q" qword/int64 8 bytes +-- "p" pointer 4 or 8 bytes +-- "s" string pointer 4 or 8 bytes (alloc_string'd) +-- "m" multibyte string pointer +-- "z" dword 4 bytes, size of struct, must be first in pattern +-- "$" aligns the total struct size to the size of the largest member + +-- When converting Windows struct member types, this may be useful: +-- https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx + +function sizeof(sequence pattern) + integer size, x, max_align + size = 0 + max_align = 1 + for i = 1 to length(pattern) do + x = pattern[i] + if x = 'b' or x = 'c' then + x = 1 + elsif x = 'w' then + x = 2 + elsif x = 'd' or x = 'i' or x = 'z' then + x = 4 + elsif x = 'q' then + x = 8 + elsif x = 'p' or x = 's' or x = 'm' then + ifdef BITS64 then + x = 8 + elsedef + x = 4 + end ifdef + elsif x = '$' then + size = align(size, max_align) + exit + else + printf(1, "unknown pack char %s\n", {{x}}) + x = 0 + end if + size = align(size, x) + x + if x > max_align then + max_align = x + end if + end for + return size +end function + +global function pack(atom ptr, sequence pattern, sequence data) + object tmp + integer x + + for i = 1 to length(pattern) do + x = pattern[i] + tmp = data[i] + if x = 's' then + tmp = alloc_string(tmp) + elsif x = 'm' then + tmp = allocWideCharString(tmp) + elsif sequence(tmp) then + tmp = or_all(tmp) + end if + if x = 'b' or x = 'c' then + poke(ptr, tmp) + ptr += 1 + elsif x = 'w' then + ptr = align(ptr, 2) + poke2(ptr, tmp) + ptr += 2 + elsif x = 'd' or x = 'i' or x = 'z' then + ptr = align(ptr, 4) + poke4(ptr, tmp) + ptr += 4 + elsif x = 'q' then + ifdef BITS64 then + ptr = align(ptr, 8) + poke8(ptr, tmp) + elsedef + poke4(ptr, and_bits(tmp, #FFFFFFFF)) + poke4(ptr + 4, floor(tmp/#100000000)) + end ifdef + ptr += 8 + elsif x = 'p' or x = 's' or x = 'm' then + ifdef BITS64 then + ptr = align(ptr, 8) + poke8(ptr, tmp) + ptr += 8 + elsedef + ptr = align(ptr, 4) + poke4(ptr, tmp) + ptr += 4 + end ifdef + elsif x = '$' then + else + printf(1, "unknown pack char %s\n", {{x}}) + end if + end for + return ptr +end function + +global function allocate_pack(sequence pattern, sequence data) + atom ptr + integer size + size = sizeof(pattern) + if pattern[1] = 'z' then + data = prepend(data, size) + end if + if pattern[$] = '$' then + data = append(data, 0) + end if + ptr = allocate(size) + --printf(1, "ptr=%x pattern=%s size=%d\n", {ptr, pattern, size}) + atom tmp = pack(ptr, pattern, data) + if tmp - ptr != size then + printf(1, "overflow! ptr=%x pattern=%s size=%d\n", {ptr, pattern, size}) + end if + + return ptr +end function + +global function unpack(atom ptr, sequence pattern) + sequence data + object tmp + integer x + data = repeat(0, length(pattern)) + for i = 1 to length(pattern) do + x = pattern[i] + if x = 'b' then + data[i] = peek(ptr) + ptr += 1 + elsif x = 'c' then + tmp = peek(ptr) + ptr += 1 + data[i] = tmp - 2*and_bits(tmp, #80) + elsif x = 'w' then + ptr = align(ptr, 2) + data[i] = peek2u(ptr) + ptr += 2 + elsif x = 'd' or x = 'z' then + ptr = align(ptr, 4) + data[i] = peek4u(ptr) + ptr += 4 + elsif x = 'i' then + ptr = align(ptr, 4) + data[i] = peek4s(ptr) + ptr += 4 + elsif x = 'p' or x = 's' or x = 'm' then + ifdef BITS64 then + ptr = align(ptr, 8) + tmp = peek8u(ptr) + ptr += 8 + elsedef + ptr = align(ptr, 4) + tmp = peek4u(ptr) + ptr += 4 + end ifdef + if x = 's' then + tmp = peek_string(tmp) + elsif x = 'm' then + tmp = peekWideCharString(tmp) + end if + data[i] = tmp + elsif x = '$' then + else + printf(1, "unknown pack char %s\n", {{x}}) + end if + end for + return data +end function + +-- dll wrapping ------------------------------------------------------- + +procedure not_found(sequence name) + crash("Couldn't find " & name) +end procedure + +function link_c_func(atom dll, sequence name, sequence args, atom result) +-- dynamically link a C routine as a Euphoria function + integer handle + + handle = define_c_func(dll, name, args, result) + if handle = -1 then + not_found(name) + end if + return handle +end function + +function link_c_proc(atom dll, sequence name, sequence args) +-- dynamically link a C routine as a Euphoria function + integer handle + + handle = define_c_proc(dll, name, args) + if handle = -1 then + not_found(name) + end if + return handle +end function + +function get_dll(sequence name) + atom handle + handle = open_dll(name) + if handle = NULL then + not_found(name) + end if + return handle +end function + +constant + user32 = get_dll("user32.dll"), + gdi32 = get_dll("gdi32.dll"), + winmm = get_dll("winmm.dll"), + kernel32 = get_dll("kernel32.dll"), + shell32 = get_dll("shell32.dll") + +-- get handles to some dll routines + +global constant + LoadIcon = link_c_func(user32, "LoadIconA", {C_POINTER, C_INT}, C_INT), + LoadCursor = link_c_func(user32, "LoadCursorA", {C_POINTER, C_INT}, C_INT), + GetStockObject = link_c_func(gdi32, "GetStockObject", {C_INT}, C_INT), + DeleteObject = link_c_func(gdi32, "DeleteObject", {C_INT}, C_INT), + CreateFontIndirect = link_c_func(gdi32, "CreateFontIndirectA", {C_POINTER}, C_INT), + CreateBitmap = link_c_func(gdi32, "CreateBitmap", {C_INT, C_INT, C_UINT, C_UINT, C_POINTER}, C_INT), + CreateIcon = link_c_func(user32, "CreateIcon", {C_POINTER, C_INT, C_INT, C_UINT, C_UINT, C_POINTER, C_POINTER}, C_INT), + CreateIconIndirect = link_c_func(user32, "CreateIconIndirect", {C_POINTER}, C_INT), + RegisterClassEx = link_c_func(user32, "RegisterClassExA", {C_POINTER}, C_USHORT), + CreateWindowEx = link_c_func(user32, "CreateWindowExA", + {C_UINT,C_POINTER,C_POINTER,C_UINT,C_INT,C_INT,C_INT,C_INT,C_UINT,C_UINT,C_UINT,C_POINTER}, + C_UINT), + CloseWindow = link_c_proc(user32, "CloseWindow", {C_POINTER}), + DestroyWindow = link_c_func(user32, "DestroyWindow", {C_POINTER}, C_INT), + MoveWindow = link_c_proc(user32, "MoveWindow", {C_POINTER, C_INT, C_INT, C_INT, C_LONG, C_INT}), + ShowWindow = link_c_proc(user32, "ShowWindow", {C_POINTER, C_INT}), + UpdateWindow = link_c_proc(user32, "UpdateWindow", {C_POINTER}), + RegisterWindowMessage = link_c_func(user32, "RegisterWindowMessageA", {C_POINTER}, C_LONG), + PlaySound = link_c_proc(winmm, "PlaySound", {C_INT, C_INT, C_INT}), + BeginPaint = link_c_func(user32, "BeginPaint", {C_INT, C_POINTER}, C_INT), + GetClientRect = link_c_proc(user32, "GetClientRect", {C_INT, C_POINTER}), + GetWindowRect = link_c_proc(user32, "GetWindowRect", {C_INT, C_POINTER}), + InvalidateRect = link_c_proc(user32, "InvalidateRect", {C_INT, C_POINTER, C_INT}), + DrawText = link_c_proc(user32, "DrawTextA", + {C_INT, C_INT, C_INT, C_INT, C_INT}), + EndPaint = link_c_proc(user32, "EndPaint", {C_INT, C_INT}), + PostQuitMessage = link_c_proc(user32, "PostQuitMessage", {C_POINTER}), + DefWindowProc = link_c_func(user32, "DefWindowProcA", + {C_POINTER, C_INT, C_POINTER, C_POINTER}, C_INT), + + SetFocus = link_c_func(user32, "SetFocus", {C_LONG}, C_LONG), + GetFocus = link_c_func(user32, "GetFocus", {}, C_LONG), + GetActiveWindow = link_c_func(user32, "GetActiveWindow", {}, C_LONG), + EnableWindow = link_c_func(user32, "EnableWindow", {C_LONG, C_LONG}, C_LONG), + IsWindowEnabled = link_c_func(user32, "IsWindowEnabled", {C_LONG}, C_LONG), + GetScrollPos = link_c_func(user32, "GetScrollPos", {C_INT, C_INT}, C_INT), + SetScrollPos = link_c_func(user32, "SetScrollPos", {C_INT, C_INT, C_INT, C_INT}, C_INT), + GetKeyState = link_c_func(user32, "GetKeyState", {C_INT}, C_INT), + GetCursorPos = link_c_func(user32, "GetCursorPos", {C_POINTER}, C_INT), + ScreenToClient = link_c_func(user32, "ScreenToClient", {C_LONG, C_POINTER}, C_INT), + + LoadLibrary = link_c_func(kernel32, "LoadLibraryA", {C_POINTER}, C_LONG), + GetModuleHandle = link_c_func(kernel32, "GetModuleHandleA", {C_POINTER}, C_INT), + GetLastError = link_c_func(kernel32, "GetLastError", {}, C_UINT), + ShellExecute = link_c_func(shell32, "ShellExecuteA", {C_INT,C_INT,C_INT,C_INT,C_INT,C_INT}, C_INT), + SHGetFolderPath = link_c_func(shell32, "SHGetFolderPathA", {C_INT, C_INT, C_INT, C_LONG, C_POINTER}, C_INT), + DragAcceptFiles = link_c_proc(shell32, "DragAcceptFiles", {C_INT, C_INT}), + DragFinish = link_c_proc(shell32, "DragFinish", {C_POINTER}), + DragQueryFile = link_c_func(shell32, "DragQueryFile", {C_POINTER, C_UINT, C_POINTER, C_UINT}, C_UINT), + DragQueryPoint = link_c_func(shell32, "DragQueryPoint", {C_POINTER, C_POINTER}, C_INT) + +global constant + CW_USEDEFAULT = #80000000, + MAX_PATH = #104, + CSIDL_LOCAL_APPDATA = 28, + CSIDL_FLAG_CREATE = #8000 + +-- Class styles +global constant + CS_VREDRAW = #1, + CS_HREDRAW = #2, + CS_KEYCVTWINDOW = #4, + CS_DBLCLKS = #8, + CS_OWNDC = #20, + CS_CLASSDC = #40, + CS_PARENTDC = #80, + CS_NOKEYCVT = #100, + CS_NOCLOSE = #200, + CS_SAVEBITS = #800, + CS_BYTEALIGNCLIENT = #1000, + CS_BYTEALIGNWINDOW = #2000, + CS_PUBLICCLASS = #4000 + +-- ShowWindow() Commands +global constant + SW_HIDE = 0, + SW_SHOWNORMAL = 1, + SW_NORMAL = 1, + SW_SHOWMINIMIZED = 2, + SW_SHOWMAXIMIZED = 3, + SW_MAXIMIZE = 3, + SW_SHOWNOACTIVATE = 4, + SW_SHOW = 5, + SW_MINIMIZE = 6, + SW_SHOWMINNOACTIVE = 7, + SW_SHOWNA = 8, + SW_RESTORE = 9, + SW_SHOWDEFAULT = 10, + SW_MAX = 10 + +-- Window Messages +global constant + WM_NULL = #0, + WM_CREATE = #1, + WM_DESTROY = #2, + WM_MOVE = #3, + WM_SIZE = #5, + + WM_ACTIVATE = #6, +-- +-- WM_ACTIVATE state values + + WA_INACTIVE = 0, + WA_ACTIVE = 1, + WA_CLICKACTIVE = 2, + + WM_SETFOCUS = #7, + WM_KILLFOCUS = #8, + WM_ENABLE = #A, + WM_SETREDRAW = #B, + WM_SETTEXT = #C, + WM_GETTEXT = #D, + WM_GETTEXTLENGTH = #E, + WM_PAINT = #F, + WM_CLOSE = #10, + WM_QUERYENDSESSION = #11, + WM_QUIT = #12, + WM_QUERYOPEN = #13, + WM_ERASEBKGND = #14, + WM_SYSCOLORCHANGE = #15, + WM_ENDSESSION = #16, + WM_SHOWWINDOW = #18, + WM_WININICHANGE = #1A, + WM_DEVMODECHANGE = #1B, + WM_ACTIVATEAPP = #1C, + WM_FONTCHANGE = #1D, + WM_TIMECHANGE = #1E, + WM_CANCELMODE = #1F, + WM_SETCURSOR = #20, + WM_MOUSEACTIVATE = #21, + WM_CHILDACTIVATE = #22, + WM_QUEUESYNC = #23, + + WM_GETMINMAXINFO = #24 +-- Type MINMAXINFO +global constant + MINMAXINFO_ptReserved = 8, + MINMAXINFO_ptMaxSize = 16, + MINMAXINFO_ptMaxPosition = 24, + MINMAXINFO_ptMinTrackSize = 32, + MINMAXINFO_ptMaxTrackSize = 40 + +global constant + WM_PAINTICON = #26, + WM_ICONERASEBKGND = #27, + WM_NEXTDLGCTL = #28, + WM_SPOOLERSTATUS = #2A, + WM_DRAWITEM = #2B, + WM_MEASUREITEM = #2C, + WM_DELETEITEM = #2D, + WM_VKEYTOITEM = #2E, + WM_CHARTOITEM = #2F, + WM_SETFONT = #30, + WM_GETFONT = #31, + WM_SETHOTKEY = #32, + WM_GETHOTKEY = #33, + WM_QUERYDRAGICON = #37, + WM_COMPAREITEM = #39, + WM_COMPACTING = #41, + + WM_WINDOWPOSCHANGING = #46, + WM_WINDOWPOSCHANGED = #47, + + WM_POWER = #48, +-- +-- wParam for WM_POWER window message and DRV_POWER driver notification + + PWR_OK = 1, + PWR_FAIL = (-1), + PWR_SUSPENDREQUEST = 1, + PWR_SUSPENDRESUME = 2, + PWR_CRITICALRESUME = 3, + + WM_COPYDATA = #4A, + WM_CANCELJOURNAL = #4B, + +-- Type COPYDATASTRUCT + COPYDATASTRUCT_dwData = 4, + COPYDATASTRUCT_cbData = 8, + COPYDATASTRUCT_lpData = 12, + + WM_NOTIFY = #4E, + + WM_SETICON = #80, ICON_BIG = 1, ICON_SMALL = 0, + WM_NCCREATE = #81, + WM_NCDESTROY = #82, + WM_NCCALCSIZE = #83, + WM_NCHITTEST = #84, + WM_NCPAINT = #85, + WM_NCACTIVATE = #86, + WM_GETDLGCODE = #87, + WM_NCMOUSEMOVE = #A0, + WM_NCLBUTTONDOWN = #A1, + WM_NCLBUTTONUP = #A2, + WM_NCLBUTTONDBLCLK = #A3, + WM_NCRBUTTONDOWN = #A4, + WM_NCRBUTTONUP = #A5, + WM_NCRBUTTONDBLCLK = #A6, + WM_NCMBUTTONDOWN = #A7, + WM_NCMBUTTONUP = #A8, + WM_NCMBUTTONDBLCLK = #A9, + + WM_KEYFIRST = #100, + WM_KEYDOWN = #100, + WM_KEYUP = #101, + WM_CHAR = #102, + WM_DEADCHAR = #103, + WM_SYSKEYDOWN = #104, + WM_SYSKEYUP = #105, + WM_SYSCHAR = #106, + WM_SYSDEADCHAR = #107, + WM_KEYLAST = #108, + WM_INITDIALOG = #110, + WM_COMMAND = #111, + WM_SYSCOMMAND = #112, + WM_TIMER = #113, + WM_HSCROLL = #114, + WM_VSCROLL = #115, + WM_INITMENU = #116, + WM_INITMENUPOPUP = #117, + WM_MENUSELECT = #11F, + WM_MENUCHAR = #120, + WM_ENTERIDLE = #121, + + WM_CTLCOLORMSGBOX = #132, + WM_CTLCOLOREDIT = #133, + WM_CTLCOLORLISTBOX = #134, + WM_CTLCOLORBTN = #135, + WM_CTLCOLORDLG = #136, + WM_CTLCOLORSCROLLBAR = #137, + WM_CTLCOLORSTATIC = #138, + + WM_MOUSEFIRST = #200, + WM_MOUSEMOVE = #200, + WM_LBUTTONDOWN = #201, + WM_LBUTTONUP = #202, + WM_LBUTTONDBLCLK = #203, + WM_RBUTTONDOWN = #204, + WM_RBUTTONUP = #205, + WM_RBUTTONDBLCLK = #206, + WM_MBUTTONDOWN = #207, + WM_MBUTTONUP = #208, + WM_MBUTTONDBLCLK = #209, + WM_MOUSELAST = #209, + WM_MOUSEWHEEL = #20A, + WM_MOUSEHWHEEL = #20E, + + WM_PARENTNOTIFY = #210, + WM_ENTERMENULOOP = #211, + WM_EXITMENULOOP = #212, + WM_MDICREATE = #220, + WM_MDIDESTROY = #221, + WM_MDIACTIVATE = #222, + WM_MDIRESTORE = #223, + WM_MDINEXT = #224, + WM_MDIMAXIMIZE = #225, + WM_MDITILE = #226, + WM_MDICASCADE = #227, + WM_MDIICONARRANGE = #228, + WM_MDIGETACTIVE = #229, + WM_MDISETMENU = #230, + WM_DROPFILES = #233, + WM_MDIREFRESHMENU = #234, + + WM_CUT = #300, + WM_COPY = #301, + WM_PASTE = #302, + WM_CLEAR = #303, + WM_UNDO = #304, + WM_RENDERFORMAT = #305, + WM_RENDERALLFORMATS = #306, + WM_DESTROYCLIPBOARD = #307, + WM_DRAWCLIPBOARD = #308, + WM_PAINTCLIPBOARD = #309, + WM_VSCROLLCLIPBOARD = #30A, + WM_SIZECLIPBOARD = #30B, + WM_ASKCBFORMATNAME = #30C, + WM_CHANGECBCHAIN = #30D, + WM_HSCROLLCLIPBOARD = #30E, + WM_QUERYNEWPALETTE = #30F, + WM_PALETTEISCHANGING = #310, + WM_PALETTECHANGED = #311, + WM_HOTKEY = #312, + + WM_THEMECHANGED = #31A, + + WM_PENWINFIRST = #380, + WM_PENWINLAST = #38F, + +-- NOTE: All Message Numbers below 0x0400 are RESERVED. + +-- Private Window Messages Start Here: + WM_USER = #400 + + +global constant + SND_FILENAME = #00020000, + SND_ASYNC = #00000001 + +global constant + DT_SINGLELINE = #0020, + DT_CENTER = #0001, + DT_VCENTER = #0004 + + + +-- Window Styles +global constant + WS_OVERLAPPED = #00000000, + WS_POPUP = #80000000, + WS_CHILD = #40000000, + WS_MINIMIZE = #20000000, + WS_VISIBLE = #10000000, + WS_DISABLED = #8000000, + WS_CLIPSIBLINGS = #4000000, + WS_CLIPCHILDREN = #2000000, + WS_MAXIMIZE = #1000000, + WS_CAPTION = #C00000, -- WS_BORDER Or WS_DLGFRAME + WS_BORDER = #800000, + WS_DLGFRAME = #400000, + WS_VSCROLL = #200000, + WS_HSCROLL = #100000, + WS_SYSMENU = #80000, + WS_THICKFRAME = #40000, + WS_GROUP = #20000, + WS_TABSTOP = #10000, + + WS_MINIMIZEBOX = #20000, + WS_MAXIMIZEBOX = #10000, + + WS_TILED = WS_OVERLAPPED, + WS_ICONIC = WS_MINIMIZE, + WS_SIZEBOX = WS_THICKFRAME, + WS_OVERLAPPEDWINDOW = or_all({WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, + WS_THICKFRAME, WS_MINIMIZEBOX, + WS_MAXIMIZEBOX}), + WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW + +-- Common Window Styles +global constant + WS_POPUPWINDOW = or_all({WS_POPUP, WS_BORDER, WS_SYSMENU}), + WS_CHILDWINDOW = (WS_CHILD) + +-- Extended Window Styles +global constant + WS_EX_DLGMODALFRAME = #1, + WS_EX_NOPARENTNOTIFY = #4, + WS_EX_TOPMOST = #8, + WS_EX_ACCEPTFILES = #10, + WS_EX_TRANSPARENT = #20, + WS_EX_MDICHILD = #40, + WS_EX_TOOLWINDOW = #80, + WS_EX_WINDOWEDGE = #100, + WS_EX_PALETTEWINDOW = #188, + WS_EX_CLIENTEDGE = #200, + WS_EX_OVERLAPPEDWINDOW = #300, + WS_EX_CONTEXTHELP = #400, + WS_EX_RIGHT = #1000, + WS_EX_LEFTSCROLLBAR = #4000, + WS_EX_CONTROLPARENT = #10000, + WS_EX_APPWINDOW = #40000 + + + +-- Standard Cursor IDs +global constant + IDC_ARROW = 32512, + IDC_IBEAM = 32513, + IDC_WAIT = 32514, + IDC_CROSS = 32515, + IDC_UPARROW = 32516, + IDC_SIZE = 32640, + IDC_ICON = 32641, + IDC_SIZENWSE = 32642, + IDC_SIZENESW = 32643, + IDC_SIZEWE = 32644, + IDC_SIZENS = 32645, + IDC_SIZEALL = 32646, + IDC_NO = 32648, + IDC_APPSTARTING = 32650 + +-- Standard Icon IDs +global constant + IDI_APPLICATION = 32512, + IDI_HAND = 32513, + IDI_QUESTION = 32514, + IDI_EXCLAMATION = 32515, + IDI_ASTERISK = 32516 + + +-- Stock Logical Objects +global constant + WHITE_BRUSH = 0, + LTGRAY_BRUSH = 1, + GRAY_BRUSH = 2, + DKGRAY_BRUSH = 3, + BLACK_BRUSH = 4, + NULL_BRUSH = 5, + HOLLOW_BRUSH = NULL_BRUSH, + WHITE_PEN = 6, + BLACK_PEN = 7, + NULL_PEN = 8, + OEM_FIXED_FONT = 10, + ANSI_FIXED_FONT = 11, + ANSI_VAR_FONT = 12, + SYSTEM_FONT = 13, + DEVICE_DEFAULT_FONT = 14, + DEFAULT_PALETTE = 15, + SYSTEM_FIXED_FONT = 16, + STOCK_LAST = 16 + + +global constant +-- Dialog Box Command IDs + IDOK = 1, + IDCANCEL = 2, + IDABORT = 3, + IDRETRY = 4, + IDIGNORE = 5, + IDYES = 6, + IDNO = 7, + +-- Control Manager Structures and Definitions + +-- Edit Control Styles + ES_LEFT = #0, + ES_CENTER = #1, + ES_RIGHT = #2, + ES_MULTILINE = #4, + ES_UPPERCASE = #8, + ES_LOWERCASE = #10, + ES_PASSWORD = #20, + ES_AUTOVSCROLL = #40, + ES_AUTOHSCROLL = #80, + ES_NOHIDESEL = #100, + ES_OEMCONVERT = #400, + ES_READONLY = #800, + ES_WANTRETURN = #1000, + ES_NUMBER = #2000, + +-- Edit Control Notification Codes + EN_SETFOCUS = #100, + EN_KILLFOCUS = #200, + EN_CHANGE = #300, + EN_UPDATE = #400, + EN_ERRSPACE = #500, + EN_MAXTEXT = #501, + EN_HSCROLL = #601, + EN_VSCROLL = #602, + +-- Edit Control Messages + EM_GETSEL = #B0, + EM_SETSEL = #B1, + EM_GETRECT = #B2, + EM_SETRECT = #B3, + EM_SETRECTNP = #B4, + EM_SCROLL = #B5, + EM_LINESCROLL = #B6, + EM_SCROLLCARET = #B7, + EM_GETMODIFY = #B8, + EM_SETMODIFY = #B9, + EM_GETLINECOUNT = #BA, + EM_LINEINDEX = #BB, + EM_SETHANDLE = #BC, + EM_GETHANDLE = #BD, + EM_GETTHUMB = #BE, + EM_LINELENGTH = #C1, + EM_REPLACESEL = #C2, + EM_GETLINE = #C4, + EM_LIMITTEXT = #C5, + EM_CANUNDO = #C6, + EM_UNDO = #C7, + EM_FMTLINES = #C8, + EM_LINEFROMCHAR = #C9, + EM_SETTABSTOPS = #CB, + EM_SETPASSWORDCHAR = #CC, + EM_EMPTYUNDOBUFFER = #CD, + EM_GETFIRSTVISIBLELINE = #CE, + EM_SETREADONLY = #CF, + EM_SETWORDBREAKPROC = #D0, + EM_GETWORDBREAKPROC = #D1, + EM_GETPASSWORDCHAR = #D2, + + EM_GETLIMITTEXT = #D5, + EM_SETLIMITTEXT = #C5, + + EM_CANPASTE = 1074, + EM_DISPLAYBAND = 1075, + EM_EXGETSEL = 1076, + EM_EXLIMITTEXT = 1077, + EM_EXLINEFROMCHAR = 1078, + EM_EXSETSEL = 1079, + EM_FINDTEXT = 1080, + EM_FORMATRANGE = 1081, + EM_GETCHARFORMAT = 1082, + EM_GETEVENTMASK = 1083, + EM_GETOLEINTERFACE = 1084, + EM_GETPARAFORMAT = 1085, + EM_GETSELTEXT = 1086, + EM_HIDESELECTION = 1087, + EM_PASTESPECIAL = 1088, + EM_REQUESTRESIZE = 1089, + EM_SELECTIONTYPE = 1090, + EM_SETBKGNDCOLOR = 1091, + EM_SETCHARFORMAT = 1092, + EM_SETEVENTMASK = 1093, + EM_SETOLECALLBACK = 1094, + EM_SETPARAFORMAT = 1095, + EM_SETTARGETDEVICE = 1096, + EM_STREAMIN = 1097, + EM_STREAMOUT = 1098, + EM_GETTEXTRANGE = 1099, + EM_FINDWORDBREAK = 1100, + EM_SETOPTIONS = 1101, + EM_GETOPTIONS = 1102, + EM_SETWORDBREAKPROCEX = 1105, + EM_FINDTEXTEX = 1103, + EM_GETWORDBREAKPROCEX = 1104, + EM_SETPUNCTUATION = 1124, + EM_GETPUNCTUATION = 1125, + EM_SETWORDWRAPMODE = 1126, + EM_GETWORDWRAPMODE = 1127, + EM_SETIMECOLOR = 1128, + EM_GETIMECOLOR = 1129, + EM_SETIMEOPTIONS = 1130, + EM_GETIMEOPTIONS = 1131, + +-- RichEdit Control + CFM_BOLD = 1, + CFM_ITALIC = 2, + CFM_UNDERLINE = 4, + CFM_STRIKEOUT = 8, + CFM_PROTECTED = 16, + CFM_LINK = 32, + CFM_SIZE = #80000000, + CFM_COLOR = #40000000, + CFM_FACE = #20000000, + CFM_OFFSET = #10000000, + CFM_CHARSET = #08000000, + CFM_SUBSCRIPT = #00030000, + CFM_SUPERSCRIPT = #00030000, + CFE_BOLD = 1, + CFE_ITALIC = 2, + CFE_UNDERLINE = 4, + CFE_STRIKEOUT = 8, + CFE_PROTECTED = 16, + CFE_AUTOCOLOR = #40000000, + CFE_SUBSCRIPT = #00010000, + CFE_SUPERSCRIPT = #00020000, + CFM_EFFECTS = or_all({CFM_BOLD, CFM_ITALIC, CFM_UNDERLINE, CFM_COLOR, CFM_STRIKEOUT, CFE_PROTECTED, CFM_LINK}), + IMF_FORCENONE = 1, + IMF_FORCEENABLE = 2, + IMF_FORCEDISABLE = 4, + IMF_CLOSESTATUSWINDOW = 8, + IMF_VERTICAL = 32, + IMF_FORCEACTIVE = 64, + IMF_FORCEINACTIVE = 128, + IMF_FORCEREMEMBER = 256, + SEL_EMPTY = 0, + SEL_TEXT = 1, + SEL_OBJECT = 2, + SEL_MULTICHAR = 4, + SEL_MULTIOBJECT = 8, + MAX_TAB_STOPS = 32, + PFM_ALIGNMENT = 8, + PFM_NUMBERING = 32, + PFM_OFFSET = 4, + PFM_OFFSETINDENT = #80000000, + PFM_RIGHTINDENT = 2, + PFM_STARTINDENT = 1, + PFM_TABSTOPS = 16, + PFN_BULLET = 1, + PFA_LEFT = 1, + PFA_RIGHT = 2, + PFA_CENTER = 3, + SF_TEXT = 1, + SF_RTF = 2, + SF_RTFNOOBJS = 3, + SF_TEXTIZED = 4, + SF_UNICODE = 16, + SF_USECODEPAGE = 32, + SF_NCRFORNONASCII = 64, + SF_RTFVAL = #0700, + SFF_PWD = #0800, + SFF_KEEPDOCINFO = #1000, + SFF_PERSISTVIEWSCALE = #2000, + SFF_PLAINRTF = #4000, + SFF_SELECTION = #8000, + WB_CLASSIFY = 3, + WB_MOVEWORDLEFT = 4, + WB_MOVEWORDRIGHT = 5, + WB_LEFTBREAK = 6, + WB_RIGHTBREAK = 7, + WB_MOVEWORDPREV = 4, + WB_MOVEWORDNEXT = 5, + WB_PREVBREAK = 6, + WB_NEXTBREAK = 7, + WBF_WORDWRAP = 16, + WBF_WORDBREAK = 32, + WBF_OVERFLOW = 64, + WBF_LEVEL1 = 128, + WBF_LEVEL2 = 256, + WBF_CUSTOM = 512, + ES_DISABLENOSCROLL = 8192, + ES_EX_NOCALLOLEINIT = 16777216, + ES_NOIME = 524288, + ES_SAVESEL = 32768, + ES_SELFIME = 262144, + ES_SUNKEN = 16384, + ES_VERTICAL = 4194304, + ES_SELECTIONBAR = 16777216, +-- EM_CANPASTE = (WM_USER+50), +-- EM_DISPLAYBAND = (WM_USER+51), +-- EM_EXGETSEL = (WM_USER+52), +-- EM_EXLIMITTEXT = (WM_USER+53), +-- EM_EXLINEFROMCHAR = (WM_USER+54), +-- EM_EXSETSEL = (WM_USER+55), +-- EM_FINDTEXT = (WM_USER+56), +-- EM_FORMATRANGE = (WM_USER+57), +-- EM_GETCHARFORMAT = (WM_USER+58), +-- EM_GETEVENTMASK = (WM_USER+59), +-- EM_GETOLEINTERFACE = (WM_USER+60), +-- EM_GETPARAFORMAT = (WM_USER+61), +-- EM_GETSELTEXT = (WM_USER+62), +-- EM_HIDESELECTION = (WM_USER+63), +-- EM_PASTESPECIAL = (WM_USER+64), +-- EM_REQUESTRESIZE = (WM_USER+65), +-- EM_SELECTIONTYPE = (WM_USER+66), +-- EM_SETBKGNDCOLOR = (WM_USER+67), +-- EM_SETCHARFORMAT = (WM_USER+68), +-- EM_SETEVENTMASK = (WM_USER+69), +-- EM_SETOLECALLBACK = (WM_USER+70), +-- EM_SETPARAFORMAT = (WM_USER+71), +-- EM_SETTARGETDEVICE = (WM_USER+72), +-- EM_STREAMIN = (WM_USER+73), +-- EM_STREAMOUT = (WM_USER+74), +-- EM_GETTEXTRANGE = (WM_USER+75), +-- EM_FINDWORDBREAK = (WM_USER+76), +-- EM_SETOPTIONS = (WM_USER+77), +-- EM_GETOPTIONS = (WM_USER+78), +-- EM_FINDTEXTEX = (WM_USER+79), +-- EM_GETWORDBREAKPROCEX = (WM_USER+80), +-- EM_SETWORDBREAKPROCEX = (WM_USER+81), +-- RichEdit 2.0 messages + EM_SETUNDOLIMIT = (WM_USER+82), + EM_REDO = (WM_USER+84), + EM_CANREDO = (WM_USER+85), + EM_GETUNDONAME = (WM_USER+86), + EM_GETREDONAME = (WM_USER+87), + EM_STOPGROUPTYPING = (WM_USER+88), + EM_SETTEXTMODE = (WM_USER+89), + EM_GETTEXTMODE = (WM_USER+90), + EM_GETTEXTLENGTHEX = (WM_USER+95), + EM_SETLANGOPTIONS = (WM_USER+120), + EM_GETLANGOPTIONS = (WM_USER+121), + EM_GETIMECOMPMODE = (WM_USER+122), + EM_SETTYPOGRAPHYOPTIONS = (WM_USER+202), + EM_GETTYPOGRAPHYOPTIONS = (WM_USER+203), + EM_SETFONTSIZE = (WM_USER+223), + EM_GETZOOM = (WM_USER+224), + EM_SETZOOM = (WM_USER+225), + + TM_PLAINTEXT = 1, + TM_RICHTEXT = 2, + TM_SINGLELEVELUNDO = 4, + TM_MULTILEVELUNDO = 8, + TM_SINGLECODEPAGE = 16, + TM_MULTICODEPAGE = 32, + + EN_CORRECTTEXT = 1797, + EN_DROPFILES = 1795, + EN_IMECHANGE = 1799, + EN_MSGFILTER = 1792, + EN_OLEOPFAILED = 1801, + EN_PROTECTED = 1796, + EN_REQUESTRESIZE = 1793, + EN_SAVECLIPBOARD = 1800, + EN_SELCHANGE = 1794, + EN_STOPNOUNDO = 1798, + ENM_NONE = 0, + ENM_CHANGE = 1, + ENM_CORRECTTEXT = 4194304, + ENM_DROPFILES = 1048576, + ENM_KEYEVENTS = 65536, + ENM_MOUSEEVENTS = 131072, + ENM_PROTECTED = 2097152, + ENM_REQUESTRESIZE = 262144, + ENM_SCROLL = 4, + ENM_SELCHANGE = 524288, + ENM_UPDATE = 2, + ECO_AUTOWORDSELECTION = 1, + ECO_AUTOVSCROLL = 64, + ECO_AUTOHSCROLL = 128, + ECO_NOHIDESEL = 256, + ECO_READONLY = 2048, + ECO_WANTRETURN = 4096, + ECO_SAVESEL = #8000, + ECO_SELECTIONBAR = #1000000, + ECO_VERTICAL = #400000, + ECOOP_SET = 1, + ECOOP_OR = 2, + ECOOP_AND = 3, + ECOOP_XOR = 4, + SCF_DEFAULT = 0, + SCF_SELECTION = 1, + SCF_WORD = 2, + SCF_ALL = 4, + SCF_USEUIRULES = 8, + yHeightCharPtsMost = 1638, + lDefaultTab = 720, + +-- EDITWORDBREAKPROC code values + WB_LEFT = 0, + WB_RIGHT = 1, + WB_ISDELIMITER = 2, + +-- Button Control Styles + BS_PUSHBUTTON = #0, + BS_DEFPUSHBUTTON = #1, + BS_CHECKBOX = #2, + BS_AUTOCHECKBOX = #3, + BS_RADIOBUTTON = #4, + BS_3STATE = #5, + BS_AUTO3STATE = #6, + BS_GROUPBOX = #7, + BS_USERBUTTON = #8, + BS_AUTORADIOBUTTON = #9, + BS_OWNERDRAW = #B, + BS_LEFTTEXT = #20, + +-- User Button Notification Codes + BN_CLICKED = 0, + BN_PAINT = 1, + BN_HILITE = 2, + BN_UNHILITE = 3, + BN_DISABLE = 4, + BN_DOUBLECLICKED = 5, + +-- Button Control Messages + BM_GETCHECK = #F0, + BM_SETCHECK = #F1, + BM_GETSTATE = #F2, + BM_SETSTATE = #F3, + BM_SETSTYLE = #F4, + BST_CHECKED = 1, + BST_INDETERMINATE = 2, + BST_UNCHECKED = 0, + +-- Tab Control stuff + TCS_FORCEICONLEFT = 16, + TCS_FORCELABELLEFT = 32, + TCS_TABS = 0, + TCS_BUTTONS = 256, + TCS_SINGLELINE = 0, + TCS_MULTILINE = 512, + TCS_RIGHTJUSTIFY = 0, + TCS_FIXEDWIDTH = 1024, + TCS_RAGGEDRIGHT = 2048, + TCS_FOCUSONBUTTONDOWN = #1000, + TCS_OWNERDRAWFIXED = #2000, + TCS_TOOLTIPS = #4000, + TCS_FOCUSNEVER = #8000, + TCS_BOTTOM = 2, + TCS_RIGHT = 2, + TCS_VERTICAL = 128, + TCS_SCROLLOPPOSITE = #0001, + TCS_HOTTRACK = #0040, + TCS_MULTISELECT = #0004, + TCS_FLATBUTTONS = #0008, + TCS_EX_FLATSEPARATORS = #00000001, + TCS_EX_REGISTERDROP = #00000002, + TCIF_TEXT = 1, + TCIF_IMAGE = 2, + TCIF_RTLREADING = 4, + TCIF_PARAM = 8, + TCIF_STATE = 16, + TCIS_BUTTONPRESSED = 1, + TCIS_HIGHLIGHTED = 2, + TCM_FIRST = #1300, + TCM_GETIMAGELIST = (TCM_FIRST+2), + TCM_SETIMAGELIST = (TCM_FIRST+3), + TCM_GETITEMCOUNT = (TCM_FIRST+4), + TCM_GETITEMA = (TCM_FIRST+5), + TCM_GETITEMW = (TCM_FIRST+60), + TCM_SETITEMA = (TCM_FIRST+6), + TCM_SETITEMW = (TCM_FIRST+61), + TCM_INSERTITEMA = (TCM_FIRST+7), + TCM_INSERTITEMW = (TCM_FIRST+62), + TCM_DELETEITEM = (TCM_FIRST+8), + TCM_DELETEALLITEMS = (TCM_FIRST+9), + TCM_GETITEMRECT = (TCM_FIRST+10), + TCM_GETCURSEL = (TCM_FIRST+11), + TCM_SETCURSEL = (TCM_FIRST+12), + TCM_HITTEST = (TCM_FIRST+13), + TCM_SETITEMEXTRA = (TCM_FIRST+14), + + TCM_ADJUSTRECT = (TCM_FIRST+40), + TCM_SETITEMSIZE = (TCM_FIRST+41), + TCM_REMOVEIMAGE = (TCM_FIRST+42), + TCM_SETPADDING = (TCM_FIRST+43), + TCM_GETROWCOUNT = (TCM_FIRST+44), + TCM_GETTOOLTIPS = (TCM_FIRST+45), + TCM_SETTOOLTIPS = (TCM_FIRST+46), + TCM_GETCURFOCUS = (TCM_FIRST+47), + TCM_SETCURFOCUS = (TCM_FIRST+48), + TCM_SETMINTABWIDTH = (TCM_FIRST + 49), + TCM_DESELECTALL = (TCM_FIRST + 50), + TCM_HIGHLIGHTITEM = (TCM_FIRST + 51), + TCM_SETEXTENDEDSTYLE = (TCM_FIRST + 52), + TCM_GETEXTENDEDSTYLE = (TCM_FIRST + 53), + --TCM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT, + --TCM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT, + TCN_FIRST = -550, + TCN_LAST = -580, + TCN_KEYDOWN = TCN_FIRST, + TCN_SELCHANGE = (TCN_FIRST-1), + TCN_SELCHANGING = (TCN_FIRST-2), + + NM_FIRST = 0, + NM_LAST = NM_FIRST - 99, + NM_OUTOFMEMORY = NM_FIRST - 1, + NM_CLICK = NM_FIRST - 2, + NM_DBLCLK = NM_FIRST - 3, + NM_RETURN = NM_FIRST - 4, + NM_RCLICK = NM_FIRST - 5, + NM_RDBLCLK = NM_FIRST - 6, + NM_SETFOCUS = NM_FIRST - 7, + NM_KILLFOCUS = NM_FIRST - 8, + NM_CUSTOMDRAW = NM_FIRST - 12, + NM_HOVER = NM_FIRST - 13, + NM_NCHITTEST = NM_FIRST - 14, + NM_KEYDOWN = NM_FIRST - 15, + NM_RELEASEDCAPTURE = NM_FIRST - 16, + NM_SETCURSOR = NM_FIRST - 17, + NM_CHAR = NM_FIRST - 18, + NM_TOOLTIPSCREATED = NM_FIRST - 19, + NM_LDOWN = NM_FIRST - 20, + NM_RDOWN = NM_FIRST - 21, + NM_THEMECHANGED = NM_FIRST - 22, + NM_FONTCHANGED = NM_FIRST - 23, + NM_CUSTOMTEXT = NM_FIRST - 24, + NM_TVSTATEIMAGECHANGING = NM_FIRST - 24, + +-- tooltip stuff + TTN_FIRST = -520, + TTN_GETDISPINFO = TTN_FIRST - 0, + TTN_SHOW = TTN_FIRST-1, + TTN_POP = TTN_FIRST-2, + TTN_LINKCLICK = TTN_FIRST-3, + TTN_NEEDTEXT = TTN_GETDISPINFO, + + TTS_ALWAYSTIP = #01, + TTS_NOPREFIX = #02, + TTS_NOANIMATE = #10, + TTS_NOFADE = #20, + TTS_BALLOON = #40, + TTS_CLOSE = #80, + TTS_USEVISUALSTYLE = #100, + TTF_IDISHWND = #0001, + TTF_CENTERTIP = #0002, + TTF_RTLREADING = #0004, + TTF_SUBCLASS = #0010, + TTF_TRACK = #0020, + TTF_ABSOLUTE = #0080, + TTF_TRANSPARENT = #0100, + TTF_PARSELINKS = #1000, + TTF_DI_SETITEM = #8000, + + TTM_ACTIVATE = WM_USER + 1, + TTM_SETDELAYTIME = WM_USER + 3, + TTM_ADDTOOL = WM_USER + 4, + TTM_DELTOOL = WM_USER + 5, + TTM_NEWTOOLRECT = WM_USER + 6, + TTM_RELAYEVENT = WM_USER + 7, + TTM_GETTOOLINFO = WM_USER + 8, + TTM_SETTOOLINFO = WM_USER + 9, + TTM_HITTEST = WM_USER + 10, + TTM_GETTEXT = WM_USER + 11, + TTM_UPDATETIPTEXT = WM_USER + 12, + TTM_GETTOOLCOUNT = WM_USER + 13, + TTM_ENUMTOOLS = WM_USER + 14, + TTM_GETCURRENTTOOL = WM_USER + 15, + TTM_WINDOWFROMPOINT = WM_USER + 16, + TTM_TRACKACTIVATE = WM_USER + 17, + TTM_TRACKPOSITION = WM_USER + 18, + TTM_SETTIPBKCOLOR = WM_USER + 19, + TTM_SETTIPTEXTCOLOR = WM_USER + 20, + TTM_GETDELAYTIME = WM_USER + 21, + TTM_GETTIPBKCOLOR = WM_USER + 22, + TTM_GETTIPTEXTCOLOR = WM_USER + 23, + TTM_SETMAXTIPWIDTH = WM_USER + 24, + TTM_GETMAXTIPWIDTH = WM_USER + 25, + TTM_SETMARGIN = WM_USER + 26, + TTM_GETMARGIN = WM_USER + 27, + TTM_POP = WM_USER + 29, + TTM_GETBUBBLESIZE = WM_USER + 30, + TTM_ADJUSTRECT = WM_USER + 31, + TTM_SETTITLE = WM_USER + 30, + LPSTR_TEXTCALLBACK = -1 + +-- dialog specific stuff +global constant + EndDialog = link_c_func(user32, "EndDialog", {C_LONG, C_LONG}, C_LONG), + GetDlgItem = link_c_func(user32, "GetDlgItem", {C_LONG, C_LONG}, C_LONG), + SetDlgItemInt = link_c_func(user32, "SetDlgItemInt", {C_LONG, C_LONG, C_LONG, C_LONG}, C_LONG), + GetDlgItemInt = link_c_func(user32, "GetDlgItemInt", {C_LONG, C_LONG, C_LONG, C_LONG}, C_LONG), + SetDlgItemText = link_c_func(user32, "SetDlgItemTextA", {C_LONG, C_LONG, C_POINTER}, C_LONG), + GetDlgItemText = link_c_func(user32, "GetDlgItemTextA", {C_LONG, C_LONG, C_POINTER, C_LONG}, C_LONG), +-- CheckDlgButton = link_c_func(user32, "CheckDLGButtonA", {C_LONG, C_LONG, C_LONG}, C_LONG), +-- CheckRadioButton = link_c_func(user32, "CheckRadioButtonA", {C_LONG, C_LONG, C_LONG, C_LONG}, C_LONG), + IsDlgButtonChecked = link_c_func(user32, "IsDlgButtonChecked", {C_LONG, C_LONG}, C_LONG), + SendDlgItemMessage = link_c_func(user32, "SendDlgItemMessageA", {C_LONG, C_LONG, C_LONG, C_INT, C_LONG}, C_LONG), + GetNextDlgGroupItem = link_c_func(user32, "GetNextDlgGroupItem", {C_LONG, C_LONG, C_LONG}, C_LONG), + GetNextDlgTabItem = link_c_func(user32, "GetNextDlgTabItem", {C_LONG, C_LONG, C_LONG}, C_LONG), + GetDlgCtrlID = link_c_func(user32, "GetDlgCtrlID", {C_LONG}, C_LONG), + GetDialogBaseUnits = link_c_func(user32, "GetDialogBaseUnits", {}, C_LONG), + DefDlgProc = link_c_func(user32, "DefDlgProcA", {C_LONG, C_LONG, C_INT, C_LONG}, C_LONG), + CreateDialogIndirectParam_ = link_c_func(user32, "CreateDialogIndirectParamW", {C_LONG, C_POINTER, C_LONG, C_POINTER, C_LONG}, C_LONG), + DialogBoxIndirectParam_ = link_c_func(user32, "DialogBoxIndirectParamW", {C_LONG, C_POINTER, C_LONG, C_POINTER, C_LONG}, C_LONG) + + +global constant +-- Static Control Constants + SS_LEFT = #0, + SS_CENTER = #1, + SS_RIGHT = #2, + SS_ICON = #3, + SS_BLACKRECT = #4, + SS_GRAYRECT = #5, + SS_WHITERECT = #6, + SS_BLACKFRAME = #7, + SS_GRAYFRAME = #8, + SS_WHITEFRAME = #9, + SS_USERITEM = #A, + SS_SIMPLE = #B, + SS_LEFTNOWORDWRAP = #C, + SS_NOPREFIX = #80, -- Don't do "" character translation + +-- Static Control Mesages + STM_SETICON = #170, + STM_GETICON = #171, + STM_MSGMAX = #172, + + WC_DIALOG = 8002, + +-- Get/SetWindowWord/Long offsets for use with WC_DIALOG windows + DWL_MSGRESULT = 0, + DWL_DLGPROC = 4, + DWL_USER = 8, + +-- Dialog Manager Routines + IsDialogMessage = link_c_func(user32, "IsDialogMessageA", {C_POINTER, C_POINTER}, C_LONG), + MapDialogRect = link_c_func(user32, "MapDialogRect", {C_LONG, C_POINTER}, C_LONG), + DlgDirList = link_c_func(user32, "DlgDirListA", {C_LONG, C_POINTER, C_LONG, C_LONG, C_LONG}, C_LONG), + +-- DlgDirList, DlgDirListComboBox flags values + DDL_READWRITE = #0, + DDL_READONLY = #1, + DDL_HIDDEN = #2, + DDL_SYSTEM = #4, + DDL_DIRECTORY = #10, + DDL_ARCHIVE = #20, + + DDL_POSTMSGS = #2000, + DDL_DRIVES = #4000, + DDL_EXCLUSIVE = #8000, + + DlgDirSelectEx = link_c_func(user32, "DlgDirSelectExA", {C_LONG, C_POINTER, C_LONG, C_LONG}, C_LONG), + DlgDirListComboBox = link_c_func(user32, "DlgDirListComboBoxA", {C_LONG, C_POINTER, C_LONG, C_LONG, C_LONG}, C_LONG), + DlgDirSelectComboBoxEx = link_c_func(user32, "DlgDirSelectComboBoxExA", {C_LONG, C_POINTER, C_LONG, C_LONG}, C_LONG), + +-- Dialog Styles + DS_ABSALIGN = #1, + DS_SYSMODAL = #2, + DS_LOCALEDIT = #20, -- Edit items get Local storage. + DS_SETFONT = #40, -- User specified font for Dlg controls + DS_MODALFRAME = #80, -- Can be combined with WS_CAPTION + DS_NOIDLEMSG = #100, -- WM_ENTERIDLE message will not be sent + DS_SETFOREGROUND = #200, -- not in win3.1 + + DM_GETDEFID = WM_USER + 0, + DM_SETDEFID = WM_USER + 1, + DC_HASDEFID = #534, --0x534B + +-- Dialog Codes + DLGC_WANTARROWS = #1, -- Control wants arrow keys + DLGC_WANTTAB = #2, -- Control wants tab keys + DLGC_WANTALLKEYS = #4, -- Control wants all keys + DLGC_WANTMESSAGE = #4, -- Pass message to control + DLGC_HASSETSEL = #8, -- Understands EM_SETSEL message + DLGC_DEFPUSHBUTTON = #10, -- Default pushbutton + DLGC_UNDEFPUSHBUTTON = #20, -- Non-default pushbutton + DLGC_RADIOBUTTON = #40, -- Radio button + DLGC_WANTCHARS = #80, -- Want WM_CHAR messages + DLGC_STATIC = #100, -- Static item: don't include + DLGC_BUTTON = #2000, -- Button item: can be checked + + LB_CTLCODE = 0, + +-- Listbox Return Values + LB_OKAY = 0, + LB_ERR = (-1), + LB_ERRSPACE = (-2), + +-- The idStaticPath parameter to DlgDirList can have the following values +-- ORed if the list box should show other details of the files along with +-- the name of the files; +-- all other details also will be returned + +-- Listbox Notification Codes + LBN_ERRSPACE = (-2), + LBN_SELCHANGE = 1, + LBN_DBLCLK = 2, + LBN_SELCANCEL = 3, + LBN_SETFOCUS = 4, + LBN_KILLFOCUS = 5, + +-- Listbox messages + LB_ADDSTRING = #180, + LB_INSERTSTRING = #181, + LB_DELETESTRING = #182, + LB_SELITEMRANGEEX = #183, + LB_RESETCONTENT = #184, + LB_SETSEL = #185, + LB_SETCURSEL = #186, + LB_GETSEL = #187, + LB_GETCURSEL = #188, + LB_GETTEXT = #189, + LB_GETTEXTLEN = #18A, + LB_GETCOUNT = #18B, + LB_SELECTSTRING = #18C, + LB_DIR = #18D, + LB_GETTOPINDEX = #18E, + LB_FINDSTRING = #18F, + LB_GETSELCOUNT = #190, + LB_GETSELITEMS = #191, + LB_SETTABSTOPS = #192, + LB_GETHORIZONTALEXTENT = #193, + LB_SETHORIZONTALEXTENT = #194, + LB_SETCOLUMNWIDTH = #195, + LB_ADDFILE = #196, + LB_SETTOPINDEX = #197, + LB_GETITEMRECT = #198, + LB_GETITEMDATA = #199, + LB_SETITEMDATA = #19A, + LB_SELITEMRANGE = #19B, + LB_SETANCHORINDEX = #19C, + LB_GETANCHORINDEX = #19D, + LB_SETCARETINDEX = #19E, + LB_GETCARETINDEX = #19F, + LB_SETITEMHEIGHT = #1A0, + LB_GETITEMHEIGHT = #1A1, + LB_FINDSTRINGEXACT = #1A2, + LB_SETLOCALE = #1A5, + LB_GETLOCALE = #1A6, + LB_SETCOUNT = #1A7, + LB_MSGMAX = #1A8, + +-- Listbox Styles + LBS_NOTIFY = #1, + LBS_SORT = #2, + LBS_NOREDRAW = #4, + LBS_MULTIPLESEL = #8, + LBS_OWNERDRAWFIXED = #10, + LBS_OWNERDRAWVARIABLE = #20, + LBS_HASSTRINGS = #40, + LBS_USETABSTOPS = #80, + LBS_NOINTEGRALHEIGHT = #100, + LBS_MULTICOLUMN = #200, + LBS_WANTKEYBOARDINPUT = #400, + LBS_EXTENDEDSEL = #800, + LBS_DISABLENOSCROLL = #1000, + LBS_NODATA = #2000, + LBS_STANDARD = or_all({LBS_NOTIFY, LBS_SORT, WS_VSCROLL, WS_BORDER}), + +-- Combo Box return Values + CB_OKAY = 0, + CB_ERR = (-1), + CB_ERRSPACE = (-2), + +-- Combo Box Notification Codes + CBN_ERRSPACE = (-1), + CBN_SELCHANGE = 1, + CBN_DBLCLK = 2, + CBN_SETFOCUS = 3, + CBN_KILLFOCUS = 4, + CBN_EDITCHANGE = 5, + CBN_EDITUPDATE = 6, + CBN_DROPDOWN = 7, + CBN_CLOSEUP = 8, + CBN_SELENDOK = 9, + CBN_SELENDCANCEL = 10, + +-- Combo Box styles + CBS_SIMPLE = #1, + CBS_DROPDOWN = #2, + CBS_DROPDOWNLIST = #3, + CBS_OWNERDRAWFIXED = #10, + CBS_OWNERDRAWVARIABLE = #20, + CBS_AUTOHSCROLL = #40, + CBS_OEMCONVERT = #80, + CBS_SORT = #100, + CBS_HASSTRINGS = #200, + CBS_NOINTEGRALHEIGHT = #400, + CBS_DISABLENOSCROLL = #800, + +-- Combo Box messages + CB_GETEDITSEL = #140, + CB_LIMITTEXT = #141, + CB_SETEDITSEL = #142, + CB_ADDSTRING = #143, + CB_DELETESTRING = #144, + CB_DIR = #145, + CB_GETCOUNT = #146, + CB_GETCURSEL = #147, + CB_GETLBTEXT = #148, + CB_GETLBTEXTLEN = #149, + CB_INSERTSTRING = #14A, + CB_RESETCONTENT = #14B, + CB_FINDSTRING = #14C, + CB_SELECTSTRING = #14D, + CB_SETCURSEL = #14E, + CB_SHOWDROPDOWN = #14F, + CB_GETITEMDATA = #150, + CB_SETITEMDATA = #151, + CB_GETDROPPEDCONTROLRECT = #152, + CB_SETITEMHEIGHT = #153, + CB_GETITEMHEIGHT = #154, + CB_SETEXTENDEDUI = #155, + CB_GETEXTENDEDUI = #156, + CB_GETDROPPEDSTATE = #157, + CB_FINDSTRINGEXACT = #158, + CB_SETLOCALE = #159, + CB_GETLOCALE = #15A, + CB_MSGMAX = #15B, + +-- Scroll Bar Styles + SBS_HORZ = #0, + SBS_VERT = #1, + SBS_TOPALIGN = #2, + SBS_LEFTALIGN = #2, + SBS_BOTTOMALIGN = #4, + SBS_RIGHTALIGN = #4, + SBS_SIZEBOXTOPLEFTALIGN = #2, + SBS_SIZEBOXBOTTOMRIGHTALIGN = #4, + SBS_SIZEBOX = #8, + +-- Scroll bar messages + SBM_SETPOS = #E0, -- not in win3.1 + SBM_GETPOS = #E1, -- not in win3.1 + SBM_SETRANGE = #E2, -- not in win3.1 + SBM_SETRANGEREDRAW = #E6, -- not in win3.1 + SBM_GETRANGE = #E3, -- not in win3.1 + SBM_ENABLE_ARROWS = #E4, -- not in win3.1 + + MDIS_ALLCHILDSTYLES = #1, + +-- wParam values for WM_MDITILE and WM_MDICASCADE messages. + MDITILE_VERTICAL = #0, + MDITILE_HORIZONTAL = #1, + MDITILE_SKIPDISABLED = #2, + +-- Type MDICREATESTRUCT + MDICREATESTRUCT_szClass = 0, + MDICREATESTRUCT_szTitle = 4, + MDICREATESTRUCT_hOwner = 8, + MDICREATESTRUCT_x = 12, + MDICREATESTRUCT_y = 16, + MDICREATESTRUCT_cx = 20, + MDICREATESTRUCT_cy = 24, + MDICREATESTRUCT_style = 28, + MDICREATESTRUCT_lParam = 32, + SIZEOF_MDICREATESTRUCT = 36, + +-- Type CLIENTCREATESTRUCT + CLIENTCREATESTRUCT_hWindowMenu = 0, + CLIENTCREATESTRUCT_idFirstChild = 4, + SIZEOF_CLIENTCREATESTRUCT = 8, + + DefFrameProc = link_c_func(user32, "DefFrameProcA", {C_LONG, C_LONG, C_LONG, C_INT, C_LONG}, C_LONG), + DefMDIChildProc = link_c_func(user32, "DefMDIChildProcA", {C_LONG, C_LONG, C_INT, C_LONG}, C_LONG), + + TranslateMDISysAccel = link_c_func(user32, "TranslateMDISysAccel", {C_LONG, C_POINTER}, C_LONG), + + ArrangeIconicWindows = link_c_func(user32, "ArrangeIconicWindows", {C_LONG}, C_LONG), + + CreateMDIWindow = link_c_func(user32, "CreateMDIWindowA", {C_POINTER, C_POINTER, C_LONG, C_LONG, C_LONG, C_LONG, C_LONG, C_LONG, + C_LONG, C_LONG}, C_LONG) + +global constant +-- Message Function Templates + GetMessage = link_c_func(user32, "GetMessageA", {C_POINTER, C_LONG, C_LONG, C_LONG}, C_LONG), + TranslateMessage = link_c_func(user32, "TranslateMessage", {C_POINTER}, C_LONG), + DispatchMessage = link_c_func(user32, "DispatchMessageA", {C_POINTER}, C_LONG), + PeekMessage = link_c_func(user32, "PeekMessageA", {C_POINTER, C_LONG, C_LONG, C_LONG, C_LONG}, C_LONG), + +-- PeekMessage() Options + PM_NOREMOVE = #0, + PM_REMOVE = #1, + PM_NOYIELD = #2, + + RegisterHotKey = link_c_func(user32, "RegisterHotKey", {C_LONG, C_LONG, C_LONG, C_LONG}, C_LONG), + UnregisterHotKey = link_c_func(user32, "UnregisterHotKey", {C_LONG, C_LONG}, C_LONG), + + MOD_ALT = #1, + MOD_CONTROL = #2, + MOD_SHIFT = #4, + + IDHOT_SNAPWINDOW = (-1), -- SHIFT-PRINTSCRN + IDHOT_SNAPDESKTOP = (-2), -- PRINTSCRN + + EWX_LOGOFF = 0, + EWX_SHUTDOWN = 1, + EWX_REBOOT = 2, + EWX_FORCE = 4, + + READAPI = 0, -- Flags for _lopen + WRITEAPI = 1, + READ_WRITE = 2, + +-- ExitWindows = link_c_func(user32, "ExitWindows", {C_LONG, C_LONG}, C_LONG), + ExitWindowsEx = link_c_func(user32, "ExitWindowsEx", {C_LONG, C_LONG}, C_LONG), + + SwapMouseButton = link_c_func(user32, "SwapMouseButton", {C_INT}, C_INT), + GetMessagePos = link_c_func(user32, "GetMessagePos", {}, C_UINT), + GetMessageTime = link_c_func(user32, "GetMessageTime", {}, C_LONG), + GetMessageExtraInfo = link_c_func(user32, "GetMessageExtraInfo", {}, C_POINTER), + SendMessage = link_c_func(user32, "SendMessageA", {C_POINTER, C_UINT, C_POINTER, C_POINTER}, C_LONG), + SendMessageTimeout = link_c_func(user32, "SendMessageTimeoutA", {C_LONG, C_LONG, C_INT, C_LONG, C_LONG, C_LONG, C_LONG}, C_LONG), + SendNotifyMessage = link_c_func(user32, "SendNotifyMessageA", {C_LONG, C_LONG, C_INT, C_LONG}, C_LONG), + SendMessageCallback = link_c_func(user32, "SendMessageCallbackA", {C_LONG, C_LONG, C_INT, C_LONG, C_LONG, C_LONG}, C_LONG), + PostMessage = link_c_func(user32, "PostMessageA", {C_LONG, C_LONG, C_INT, C_LONG}, C_LONG), + PostThreadMessage = link_c_func(user32, "PostThreadMessageA", {C_LONG, C_LONG, C_INT, C_LONG}, C_LONG), + +-- Special HWND value for use with PostMessage and SendMessage + HWND_BROADCAST = #FFFF + + +global constant +-- Virtual Keys, Standard Set + VK_LBUTTON = #1, + VK_RBUTTON = #2, + VK_CANCEL = #3, + VK_MBUTTON = #4, -- NOT contiguous with L RBUTTON + + VK_BACK = #8, + VK_TAB = #9, + + VK_CLEAR = #C, + VK_RETURN = #D, + + VK_SHIFT = #10, + VK_CONTROL = #11, + VK_MENU = #12, + VK_PAUSE = #13, + VK_CAPITAL = #14, + + VK_ESCAPE = #1B, + + VK_SPACE = #20, + VK_PRIOR = #21, + VK_NEXT = #22, + VK_END = #23, + VK_HOME = #24, + VK_LEFT = #25, + VK_UP = #26, + VK_RIGHT = #27, + VK_DOWN = #28, + VK_SELECT = #29, + VK_PRINT = #2A, + VK_EXECUTE = #2B, + VK_SNAPSHOT = #2C, + VK_INSERT = #2D, + VK_DELETE = #2E, + VK_HELP = #2F, + +-- VK_A thru VK_Z are the same as their ASCII equivalents: 'A' thru 'Z' +-- VK_0 thru VK_9 are the same as their ASCII equivalents: '0' thru '9' + + VK_NUMPAD0 = #60, + VK_NUMPAD1 = #61, + VK_NUMPAD2 = #62, + VK_NUMPAD3 = #63, + VK_NUMPAD4 = #64, + VK_NUMPAD5 = #65, + VK_NUMPAD6 = #66, + VK_NUMPAD7 = #67, + VK_NUMPAD8 = #68, + VK_NUMPAD9 = #69, + VK_MULTIPLY = #6A, + VK_ADD = #6B, + VK_SEPARATOR = #6C, + VK_SUBTRACT = #6D, + VK_DECIMAL = #6E, + VK_DIVIDE = #6F, + VK_F1 = #70, + VK_F2 = #71, + VK_F3 = #72, + VK_F4 = #73, + VK_F5 = #74, + VK_F6 = #75, + VK_F7 = #76, + VK_F8 = #77, + VK_F9 = #78, + VK_F10 = #79, + VK_F11 = #7A, + VK_F12 = #7B, + VK_F13 = #7C, + VK_F14 = #7D, + VK_F15 = #7E, + VK_F16 = #7F, + VK_F17 = #80, + VK_F18 = #81, + VK_F19 = #82, + VK_F20 = #83, + VK_F21 = #84, + VK_F22 = #85, + VK_F23 = #86, + VK_F24 = #87, + + VK_NUMLOCK = #90, + VK_SCROLL = #91, + +-- +-- VK_L VK_R - left and right Alt, Ctrl and Shift virtual keys. +-- Used only as parameters to GetAsyncKeyState() and GetKeyState(). +-- No other API or message will distinguish left and right keys in this way. +-- / + VK_LSHIFT = #A0, + VK_RSHIFT = #A1, + VK_LCONTROL = #A2, + VK_RCONTROL = #A3, + VK_LMENU = #A4, + VK_RMENU = #A5, + + VK_ATTN = #F6, + VK_CRSEL = #F7, + VK_EXSEL = #F8, + VK_EREOF = #F9, + VK_PLAY = #FA, + VK_ZOOM = #FB, + VK_NONAME = #FC, + VK_PA1 = #FD, + VK_OEM_CLEAR = #FE + + + +-- menu-specific commands +global constant + LoadMenu = link_c_func(user32, "LoadMenuA", {C_LONG, C_POINTER}, C_LONG), + LoadMenuIndirect = link_c_func(user32, "LoadMenuIndirectA", {C_LONG}, C_LONG), + GetMenu = link_c_func(user32, "GetMenu", {C_LONG}, C_LONG), + SetMenu = link_c_func(user32, "SetMenu", {C_LONG, C_LONG}, C_LONG), + HiliteMenuItem = link_c_func(user32, "HiliteMenuItem", {C_LONG, C_LONG, C_LONG, C_LONG}, C_LONG), + GetMenuString = link_c_func(user32, "GetMenuStringA", {C_LONG, C_LONG, C_POINTER, C_LONG, C_LONG}, C_LONG), + GetMenuState = link_c_func(user32, "GetMenuState", {C_LONG, C_LONG, C_LONG}, C_LONG), + DrawMenuBar = link_c_func(user32, "DrawMenuBar", {C_LONG}, C_LONG), + GetSystemMenu = link_c_func(user32, "GetSystemMenu", {C_LONG, C_LONG}, C_LONG), + CreateMenu = link_c_func(user32, "CreateMenu", {}, C_LONG), + CreatePopupMenu = link_c_func(user32, "CreatePopupMenu", {}, C_LONG), + DestroyMenu = link_c_func(user32, "DestroyMenu", {C_LONG}, C_LONG), + CheckMenuItem = link_c_func(user32, "CheckMenuItem", {C_LONG, C_LONG, C_LONG}, C_LONG), + CheckMenuRadioItem = link_c_func(user32, "CheckMenuRadioItem", {C_LONG, C_LONG, C_LONG, C_LONG, C_LONG}, C_LONG), + EnableMenuItem = link_c_func(user32, "EnableMenuItem", {C_LONG, C_LONG, C_LONG}, C_LONG), + GetSubMenu = link_c_func(user32, "GetSubMenu", {C_LONG, C_LONG}, C_LONG), + GetMenuItemID = link_c_func(user32, "GetMenuItemID", {C_LONG, C_LONG}, C_LONG), + GetMenuItemCount = link_c_func(user32, "GetMenuItemCount", {C_LONG}, C_LONG), + + InsertMenu = link_c_func(user32, "InsertMenuA", {C_LONG, C_LONG, C_LONG, C_LONG, C_POINTER}, C_LONG), + AppendMenu = link_c_func(user32, "AppendMenuA", {C_LONG, C_LONG, C_LONG, C_POINTER}, C_LONG), + ModifyMenu = link_c_func(user32, "ModifyMenuA", {C_LONG, C_LONG, C_LONG, C_LONG, C_POINTER}, C_LONG), + RemoveMenu = link_c_func(user32, "RemoveMenu", {C_LONG, C_LONG, C_LONG}, C_LONG), + DeleteMenu = link_c_func(user32, "DeleteMenu", {C_LONG, C_LONG, C_LONG}, C_LONG), + SetMenuItemBitmaps = link_c_func(user32, "SetMenuItemBitmaps", {C_LONG, C_LONG, C_LONG, C_LONG, C_LONG}, C_LONG), + GetMenuCheckMarkDimensions = link_c_func(user32, "GetMenuCheckMarkDimensions", {}, C_LONG), + TrackPopupMenu = link_c_func(user32, "TrackPopupMenu", {C_LONG, C_LONG, C_LONG, C_LONG, C_LONG, C_LONG, C_POINTER}, C_LONG), + +-- Menu flags for Add/Check/EnableMenuItem() + MF_INSERT = #0, + MF_CHANGE = #80, + MF_APPEND = #100, + MF_DELETE = #200, + MF_REMOVE = #1000, + + MF_BYCOMMAND = #0, + MF_BYPOSITION = #400, + + MF_SEPARATOR = #800, + + MF_ENABLED = #0, + MF_GRAYED = #1, + MF_DISABLED = #2, + + MF_UNCHECKED = #0, + MF_CHECKED = #8, + MF_USECHECKBITMAPS = #200, + + MF_STRING = #0, + MF_BITMAP = #4, + MF_OWNERDRAW = #100, + + MF_POPUP = #10, + MF_MENUBARBREAK = #20, + MF_MENUBREAK = #40, + + MF_UNHILITE = #0, + MF_HILITE = #80, + + MF_SYSMENU = #2000, + MF_HELP = #4000, + MF_MOUSESELECT = #8000, + +-- Flags for TrackPopupMenu + TPM_LEFTBUTTON = #0, + TPM_RIGHTBUTTON = #2, + TPM_LEFTALIGN = #0, + TPM_CENTERALIGN = #4, + TPM_RIGHTALIGN = #8 + + +-- message box stuff +global constant + MessageBox = link_c_func(user32, "MessageBoxA", {C_LONG, C_POINTER, C_POINTER, C_LONG}, C_LONG), + MessageBoxEx = link_c_func(user32, "MessageBoxExA", {C_LONG, C_POINTER, C_POINTER, C_LONG, C_LONG}, C_LONG), + +-- MessageBox() Flags + MB_OK = #0, + MB_OKCANCEL = #1, + MB_ABORTRETRYIGNORE = #2, + MB_YESNOCANCEL = #3, + MB_YESNO = #4, + MB_RETRYCANCEL = #5, + + MB_ICONHAND = #10, + MB_ICONQUESTION = #20, + MB_ICONEXCLAMATION = #30, + MB_ICONASTERISK = #40, + + MB_ICONINFORMATION = MB_ICONASTERISK, + MB_ICONSTOP = MB_ICONHAND, + + MB_DEFBUTTON1 = #0, + MB_DEFBUTTON2 = #100, + MB_DEFBUTTON3 = #200, + + MB_APPLMODAL = #0, + MB_SYSTEMMODAL = #1000, + MB_TASKMODAL = #2000, + + MB_NOFOCUS = #8000, + MB_SETFOREGROUND = #10000, + MB_DEFAULT_DESKTOP_ONLY = #20000, + + MB_TYPEMASK = #F, + MB_ICONMASK = #F0, + MB_DEFMASK = #F00, + MB_MODEMASK = #3000, + MB_MISCMASK = #C000 + +-- Status Box flags +global constant + SB_GETBORDERS = 1031, + SB_GETPARTS = 1030, + SB_GETRECT = 1034, + SB_GETTEXTW = 1037, + SB_GETTEXTLENGTHW = 1036, + SB_SETTEXTW = 1035, + SB_GETTEXTA = 1026, + SB_GETTEXTLENGTHA = 1027, + SB_SETTEXTA = 1025, + SB_SETMINHEIGHT = 1032, + SB_SETPARTS = 1028, + SB_SIMPLE = 1033, + +-- Scroll Bar constants + SB_HORZ = 0, + SB_VERT = 0 + +global constant SIZE_OF_MESSAGE = sizeof("pdppddd") + + +--constant SIZE_OF_WNDCLASS = 48 +global function RegisterClass(sequence info) +-- info = {style, lpfnWndProc, cbClsExtra, cbWndExtra, hInstance, +-- hIcon, hCursor, hbrBackground, lpszMenuName, lpszClassName, hIconSm} + atom WndClass, result + + WndClass = allocate_pack("zdpiippppssp", info) + result = c_func(RegisterClassEx, {WndClass}) + if result = 0 then + printf(1, "%x\n", {c_func(GetLastError, {})}) + end if + free_strings() + free(WndClass) + return result +end function + +global function CreateWindow(sequence info) +-- info = {dwExStyle, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, +-- hWndParent, hMenu, hInstance, lpParam} + atom result + if sequence(info[2]) then + info[2] = alloc_string(info[2]) -- lpClassName + end if + if sequence(info[3]) then + info[3] = alloc_string(info[3]) -- lpWindowName + end if + if sequence(info[4]) then + info[4] = or_all(info[4]) -- style + end if + + result = c_func(CreateWindowEx, info) + if result = 0 then + printf(1, "%x\n", {c_func(GetLastError, {})}) + end if + free_strings() + return result +end function + + + +function allocDialogTemplate(sequence info) + atom data, ptr, style, exstyle, cdit, id, x, y, cx, cy, class, result + sequence text + + data = allocate(1024) + ptr = data + + cdit = length(info)-1 + + for i = 1 to length(info) do + if sequence(info[i][1]) then + style = or_all(info[i][1]) + else + style = info[i][1] + end if + if sequence(info[i][2]) then + exstyle = or_all(info[i][2]) + else + exstyle = info[i][2] + end if + x = info[i][3] + y = info[i][4] + cx = info[i][5] + cy = info[i][6] + id = info[i][7] -- menu or id + class = info[i][8] -- window or dialog class + text = info[i][9] + + -- struct DLGITEMTEMPLATE or DLGITEMTEMPLATE + poke4(ptr, { + style, -- DWORD style; + exstyle -- DWORD dwExtendedStyle; + }) + ptr += 8 + + if i = 1 then + poke(ptr, {cdit, 0}) -- WORD cdit; + ptr += 2 + end if + + poke4(ptr, { + x + y * #10000, -- short x; short y; + cx+cy * #10000, -- short cx; short cy; + id -- WORD id; or menu + }) + ptr += 10 + + if i = 1 then + -- window class + poke4(ptr, class) + ptr += 2 + else + -- ordinal class + poke4(ptr, #FFFF + class * #10000) + ptr += 4 + end if + + pokeWideCharString(ptr, text) + ptr += 2 * length(text) + 2 + + if i != 1 then + -- no creation data + poke(ptr, {0,0}) + ptr += 2 + end if + ptr = align(ptr, 4) + + end for + return data +end function + + +global function DialogBoxIndirectParam(atom instance, object info, atom hWndParent, atom dialogFunc, atom param) + atom data, result + + if atom(info) then + return c_func(DialogBoxIndirectParam_, {instance, info, hWndParent, dialogFunc, param}) + end if + + data = allocDialogTemplate(info) + result = c_func(DialogBoxIndirectParam_, {instance, data, hWndParent, dialogFunc, param}) + free(data) + return result +end function + +global function CreateDialogIndirectParam(atom instance, object info, atom hWndParent, atom dialogFunc, atom param) + atom data, result + + if atom(info) then + return c_func(CreateDialogIndirectParam_, {instance, info, hWndParent, dialogFunc, param}) + end if + + data = allocDialogTemplate(info) + result = c_func(CreateDialogIndirectParam_, {instance, data, hWndParent, dialogFunc, param}) + free(data) + return result +end function + + + +-- open/save filename common dialogs +global constant + comdlg32 = get_dll("comdlg32.dll"), + GetOpenFileName_ = link_c_func(comdlg32, "GetOpenFileNameA", {C_POINTER}, C_LONG), + GetSaveFileName_ = link_c_func(comdlg32, "GetSaveFileNameA", {C_POINTER}, C_LONG), + GetFileTitle_ = link_c_func(comdlg32, "GetFileTitleA", {C_POINTER, C_POINTER, C_INT}, C_INT), + + OFN_READONLY = #1, + OFN_OVERWRITEPROMPT = #2, + OFN_HIDEREADONLY = #4, + OFN_NOCHANGEDIR = #8, + OFN_SHOWHELP = #10, + OFN_ENABLEHOOK = #20, + OFN_ENABLETEMPLATE = #40, + OFN_ENABLETEMPLATEHANDLE = #80, + OFN_NOVALIDATE = #100, + OFN_ALLOWMULTISELECT = #200, + OFN_EXTENSIONDIFFERENT = #400, + OFN_PATHMUSTEXIST = #800, + OFN_FILEMUSTEXIST = #1000, + OFN_CREATEPROMPT = #2000, + OFN_SHAREAWARE = #4000, + OFN_NOREADONLYRETURN = #8000, + OFN_NOTESTFILECREATE = #10000, + OFN_NONETWORKBUTTON = #20000, + OFN_NOLONGNAMES = #40000, -- force no long names for 4.x modules + OFN_EXPLORER = #80000, -- new look commdlg + OFN_NODEREFERENCELINKS = #100000, + OFN_LONGNAMES = #200000, -- force long names for 3.x modules + + OFN_SHAREFALLTHROUGH = 2, + OFN_SHARENOWARN = 1, + OFN_SHAREWARN = 0 + +function peek_multi_strings(atom ptr) + sequence path, name, result + path = peek_string(ptr) + ptr += length(path) + 1 + result = {} + name = peek_string(ptr) + if length(name) = 0 then + return path + end if + while length(name) do + result = append(result, path & '\\' & name) + ptr += length(name) + 1 + name = peek_string(ptr) + end while + return result +end function + + +function GetFileNameDialog(atom func, sequence info) +-- info = {hwndOwner, hInstance, lpstrFilter, nFilterIndex, lpstrFile, +-- lpstrInitialDir, lpstrTitle, Flags, lpstrDefExt} +-- returns: {nFilterIndex, FileName, Flags, nFileOffset, nFileExtension} + atom struc + object result + integer maxsize + maxsize = 260 + if and_bits(info[8], OFN_ALLOWMULTISELECT) then + maxsize = 4096 + end if + if compare(info[5], 0) then + info[5] = repeat(0, maxsize) + elsif length(info[5]) < maxsize then + info[5] = info[5] & repeat(0, maxsize - length(info[5])) + end if + + struc = allocate_pack("zppspddsdppssdwwsppp", { + info[1], -- hwndOwner + info[2], -- hInstance + info[3], -- lpstrFilter + 0, -- lpstrCustomFilter + 0, -- nMaxCustFilter + info[4], -- nFilterIndex + info[5], -- lpstrFile + length(info[5]), -- nMaxFile + 0, -- lpstrFileTitle + 0, -- nMaxFileTitle + info[6], -- lpstrInitialDir + info[7], -- lpstrTitle + info[8], -- Flags + 0, -- nFileOffset + 0, -- nFileExtension + info[9], -- lpstrDefExt + 0, -- lCustData + 0, -- lpfnHook + 0}) -- lpTemplateName + + if c_func(func, {struc}) then + result = unpack(struc, "zppppddpdppppdwwpppp") + if and_bits(info[8], OFN_ALLOWMULTISELECT) then + result[8] = peek_multi_strings(result[8]) + else + result[8] = peek_string(result[8]) + end if + result = { + result[7], -- nFilterIndex + result[8], -- lpstrFile + result[14], -- Flags + result[15], -- nFileOffset + result[16]} -- nFileExtension + else + result = {} + end if + free(struc) + free_strings() + return result +end function + +global function GetOpenFileName(sequence info) +-- info = {hwndOwner, hInstance, lpstrFilter, nFilterIndex, lpstrFile, +-- lpstrInitialDir, lpstrTitle, Flags, lpstrDefExt} +-- returns: {nFilterIndex, FileName, Flags, nFileOffset, nFileExtension} + return GetFileNameDialog(GetOpenFileName_, info) +end function + +global function GetSaveFileName(sequence info) +-- info = {hwndOwner, hInstance, lpstrFilter, nFilterIndex, lpstrFile, +-- lpstrInitialDir, lpstrTitle, Flags, lpstrDefExt} +-- returns: {nFilterIndex, FileName, Flags, nFileOffset, nFileExtension} + return GetFileNameDialog(GetSaveFileName_, info) +end function + + +global constant + FILEOKSTRING = "commdlg_FileNameOK", + COLOROKSTRING = "commdlg_ColorOK", + SETRGBSTRING = "commdlg_SetRGBColor", + HELPMSGSTRING = "commdlg_help", + FINDMSGSTRING = "commdlg_FindReplace" + +-- find/replace common dialogs +global constant + FR_DOWN = #1, + FR_WHOLEWORD = #2, + FR_MATCHCASE = #4, + FR_FINDNEXT = #8, + FR_REPLACE = #10, + FR_REPLACEALL = #20, + FR_DIALOGTERM = #40, + FR_SHOWHELP = #80, + FR_ENABLEHOOK = #100, + FR_ENABLETEMPLATE = #200, + FR_NOUPDOWN = #400, + FR_NOMATCHCASE = #800, + FR_NOWHOLEWORD = #1000, + FR_ENABLETEMPLATEHANDLE = #2000, + FR_HIDEUPDOWN = #4000, + FR_HIDEMATCHCASE = #8000, + FR_HIDEWHOLEWORD = #10000, + + FindText_ = link_c_func(comdlg32, "FindTextA", {C_POINTER}, C_LONG), + ReplaceText_ = link_c_func(comdlg32, "ReplaceTextA", {C_POINTER}, C_LONG) + +constant + struct_FINDREPLACE = "zppdsswwppp", + SIZE_OF_FINDREPLACE = sizeof(struct_FINDREPLACE), + Flags_offset = sizeof(struct_FINDREPLACE[1..3]), + FindWhat_offset = sizeof(struct_FINDREPLACE[1..4]), + ReplaceWith_offset = sizeof(struct_FINDREPLACE[1..5]) + -- 0 DWORD lStructSize; + -- 4 HWND hwndOwner; + -- 8 HINSTANCE hInstance; + -- 12 DWORD Flags; + -- 16 LPTSTR lpstrFindWhat; + -- 20 LPTSTR lpstrReplaceWith; + -- 24 WORD wFindWhatLen; + -- 26 WORD wReplaceWithLen; + -- 28 LPARAM lCustData; + -- 32 LPFRHOOKPROC lpfnHook; + -- 36 LPCTSTR lpTemplateName; + +global function GetFindFlags(atom struc) + return peek4u(struc + Flags_offset) +end function + +global function GetFindWhat(atom struc) + sequence tmp + tmp = unpack(struc + FindWhat_offset, "s") + return tmp[1] +end function + +global function GetReplaceWith(atom struc) + sequence tmp + tmp = unpack(struc + ReplaceWith_offset, "s") + return tmp[1] +end function + +atom find_struc, hwnd_find +find_struc = 0 +hwnd_find = 0 + +function FindReplaceText(atom func, atom hwndOwner, atom hInstance, atom Flags, sequence FindWhat, sequence ReplaceWith) +-- returns: hwndFindDialog + atom junk + integer Len + Len = 256 + if length(FindWhat) >= Len then FindWhat = FindWhat[1..Len-1] end if + if length(ReplaceWith) >= Len then ReplaceWith = ReplaceWith[1..Len-1] end if + if find_struc then + if hwnd_find then + junk = c_func(DestroyWindow, {hwnd_find}) + end if + else + find_struc = allocate(SIZE_OF_FINDREPLACE + Len + Len) + pack(find_struc, struct_FINDREPLACE, { + SIZE_OF_FINDREPLACE, + hwndOwner, + 0, -- hInstance + Flags, + find_struc + SIZE_OF_FINDREPLACE, -- lpstrFindWhat + find_struc + SIZE_OF_FINDREPLACE + Len, --lpstrReplaceWith + Len, -- wFindWhatLen + Len, -- wReplaceWithLen + NULL, -- lCustData + NULL, -- lpfnHook + NULL -- lpTemplateName + }) + end if + pack(find_struc, "zppd", { + SIZE_OF_FINDREPLACE, + hwndOwner, + 0, + Flags}) + poke(find_struc + SIZE_OF_FINDREPLACE, FindWhat & 0) + poke(find_struc + SIZE_OF_FINDREPLACE + Len, ReplaceWith & 0) + + hwnd_find = c_func(func, {find_struc}) + if hwnd_find = 0 then + free(find_struc) + find_struc = 0 + end if + return hwnd_find +end function + +global function FindText(atom hwndOwner, atom hInstance, atom Flags, sequence FindWhat) +-- returns: hwndFindDialog + return FindReplaceText(FindText_, hwndOwner, hInstance, Flags, FindWhat, "") +end function + +global function ReplaceText(atom hwndOwner, atom hInstance, atom Flags, sequence FindWhat, sequence ReplaceWith) +-- returns: hwndFindDialog + return FindReplaceText(ReplaceText_, hwndOwner, hInstance, Flags, FindWhat, ReplaceWith) +end function + + +-- choose font common dialog +global constant + ChooseFont_ = link_c_func(comdlg32, "ChooseFontA", {C_POINTER}, C_INT), + CF_SCREENFONTS = 1, + CF_PRINTERFONTS = 2, + CF_BOTH = 3, + CF_SHOWHELP = 4, + CF_ENABLEHOOK = 8, + CF_ENABLETEMPLATE = 16, + CF_ENABLETEMPLATEHANDLE = 32, + CF_INITTOLOGFONTSTRUCT = 64, + CF_USESTYLE = 128, + CF_EFFECTS = 256, + CF_APPLY = 512, + CF_ANSIONLY = 1024, + CF_SCRIPTSONLY = CF_ANSIONLY, + CF_NOVECTORFONTS = 2048, + CF_NOOEMFONTS = 2048, + CF_NOSIMULATIONS = 4096, + CF_LIMITSIZE = 8192, + CF_FIXEDPITCHONLY = 16384, + CF_WYSIWYG = 32768, + CF_FORCEFONTEXIST = 65536, + CF_SCALABLEONLY = 131072, + CF_TTONLY = 262144, + CF_NOFACESEL = 524288, + CF_NOSTYLESEL = 1048576, + CF_NOSIZESEL = 2097152, + CF_SELECTSCRIPT = 4194304, + CF_NOSCRIPTSEL = 8388608, + CF_NOVERTFONTS = #1000000, + SIMULATED_FONTTYPE = #8000, + PRINTER_FONTTYPE = #4000, + SCREEN_FONTTYPE = #2000, + BOLD_FONTTYPE = #100, + ITALIC_FONTTYPE = #0200, + REGULAR_FONTTYPE = #0400, + WM_CHOOSEFONT_GETLOGFONT = (WM_USER+1), + WM_CHOOSEFONT_SETLOGFONT = (WM_USER+101), + WM_CHOOSEFONT_SETFLAGS = (WM_USER+102) + +global function ChooseFont(atom hwndOwner, sequence font_name, integer font_height) + atom cf, lf, size, lf_facesize, lf_size, hedit + sequence result + + lf_facesize = 32 + lf_size = 4*5 + 8 + lf_facesize + lf = allocate(lf_size) + poke4(lf, {-floor((font_height*96+36)/72),0,0,0,0,0,0}) + poke(lf+lf_size-lf_facesize, font_name&0) + + cf = allocate_pack("zpppiddpppppwii$", { + hwndOwner, -- hwndOwner; + NULL, -- hDC; + lf, -- lpLogFont; + 0, -- iPointSize + CF_INITTOLOGFONTSTRUCT, -- Flags + 0, -- rgbColors + NULL, -- lCustData + NULL, -- lpfnHook + NULL, -- lpTemplateName + NULL, -- hInstance + NULL, -- lpszStyle + 0, -- nFontType + 0, -- nSizeMin + 0 -- nSizeMax + }) + result = {} + if c_func(ChooseFont_, {cf}) then + font_name = peek_string(lf+lf_size-lf_facesize) + font_height = floor(peek4u(cf + sizeof("zppp")) / 10) + --? font_height + --printf(1, "height=%d %d width=%d weight=%d facename=%s pointsize=%d\n", { + -- peek4s(lf), + -- -floor((font_height*96+36)/72), + -- peek4u(lf+4), + -- peek4u(lf+16), + -- font_name, + -- peek4u(cf+16)}) + result = {font_name, font_height} + end if + free(cf) + free(lf) + return result +end function + + +-- choose color common dialog +global constant + ChooseColor_ = link_c_func(comdlg32, "ChooseColorA", {C_POINTER}, C_INT), + CC_ANYCOLOR = #100, + CC_ENABLEHOOK = #10, + CC_ENABLETEMPLATE = #20, + CC_ENABLETEMPLATEHANDLE = #40, + CC_FULLOPEN = #2, + CC_PREVENTFULLOPEN = #4, + CC_RGBINIT = #1, + CC_SHOWHELP = #8, + CC_SOLIDCOLOR = #80 + +sequence cur_palette +cur_palette = repeat(0, 16) + +global function ChooseColor(atom hwnd, integer rgb) + atom struc, pal + sequence result + pal = allocate(4*length(cur_palette)) + poke4(pal, cur_palette) + struc = allocate_pack("zppdpdppp", { + hwnd, -- hwndOwner + 0, -- hInstance + rgb, -- rgbResult + pal, -- lpCustColors + CC_RGBINIT+CC_FULLOPEN, -- Flags + 0, -- lpCustData + 0, -- lpfnHook + 0 -- lpTemplateName + }) + if c_func(ChooseColor_, {struc}) != 0 then + result = unpack(struc, "zppdpdppp") + rgb = result[4] + end if + cur_palette = peek4u({pal, length(cur_palette)}) + free(struc) + free(pal) + return rgb +end function + + + +---------------------------------------------------------------------------- +global constant + SPI_GETNONCLIENTMETRICS = #29, + SystemParametersInfo = link_c_func(user32, "SystemParametersInfoA", + {C_INT, C_INT, C_POINTER, C_INT}, C_INT) + diff --git a/tools/euphoria-manager b/tools/euphoria-manager new file mode 100755 index 0000000..1f99758 --- /dev/null +++ b/tools/euphoria-manager @@ -0,0 +1,200 @@ +#!/bin/bash + +############################################################################### +## ISC LICENSE: +## +## Permission to use, copy, modify, and/or distribute this software for +## any purpose with or without fee is hereby granted, provided that the above +## copyright notice and this permission notice appear in all copies. +## +## THE SOFTWARE IS PROVIDED “AS IS” AND ISC DISCLAIMS ALL WARRANTIES WITH +## REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +## AND FITNESS. +## IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, +## OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +## USE, DATA OR PROFITS, +## WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +################################################################################ +## [META Info] +## +## Title: geuphoria.sh +## Version: 0.03 +## Description: manage installation and removal of Euphoria Programming Language +## Author: Mollusk +## ############################################################################# + + +name="euphoria" +version="4.1.0" +state="beta2" +arch="x64" +fext="tar.gz" +extcmd="tar" +deps="curl" +target_dir="/usr/local" +url="http://nbtelecom.dl.sourceforge.net/project/rapideuphoria/Euphoria/${version}-${state}/${name}-${version}-Linux-${arch}-57179171dbed.${fext}" +tmpdir="/tmp" + +check_deps(){ + + get_path=$(which curl) + + if [ ! ${get_path} ];then + printf "Please install: ${deps}\n" + exit 0; + else + printf "Deps passed checks..moving on\n" + fi + +} + +check_root(){ + + if [[ $EUID -ne 0 ]]; then + printf "${LRED}This script must be run as root${NC}\n" 1>&2 + exit 1 + fi +} + +check_install(){ + + if [ ! -d ${target_dir}/${name}-${version}-Linux-${arch} ];then + printf "Install check passed...moving on...\n" + else + printf "${0}: ${name}-${version} is already installed\n" + exit 0; + fi +} + +download_pkgs(){ + + if [ ! -f ${tmpdir}/${name}-${version}.${fext} ];then + curl -o ${tmpdir}/${name}-${version}.${fext} ${url} + else + printf "The archive already exists..moving to extraction phase\n" + fi +} + +extract_files(){ + cd ${tmpdir} + if [ ! -f ${name}-${version}.${fext} ];then + printf "${0}: ${tmpdir}/${name}-${version}.${fext}: no such file\n" + else + ${extcmd} xvzf ${name}-${version}.${fext} + fi +} + +install_build(){ + cd ${tmpdir} + if [ ! -d ${name}-${version}-Linux-${arch} ];then + printf "${0}: ${name}-${version}-Linux-${arch}: No such firectory\n" + else + cp -r ${tmpdir}/${name}-${version}-Linux-${arch} ${target_dir}/ + fi +} + +post_install(){ + ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eui /usr/bin + ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/euc /usr/bin + ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eutest /usr/bin + ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eudist /usr/bin + ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eudoc /usr/bin + ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eushroud /usr/bin + ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/euloc /usr/bin + ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eudis /usr/bin + ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eubind /usr/bin + ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eub /usr/bin + ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/echoversion /usr/bin + ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/creole /usr/bin + ln -v -s ${target_dir}/${name}-${version}-Linux-${arch}/bin/eucoverage /usr/bin +} + +uninstall_pkg(){ + if [ ! -d ${target_dir}/${name}-${version}-Linux-${arch} ];then + printf "${name}-${version} is not installed\n" + else + + rm -v -r ${target_dir}/${name}-${version}-Linux-${arch} + rm -v /usr/bin/eui + rm -v /usr/bin/euc + rm -v /usr/bin/eutest + rm -v /usr/bin/eudist + rm -v /usr/bin/eudoc + rm -v /usr/bin/eushroud + rm -v /usr/bin/euloc + rm -v /usr/bin/eudis + rm -v /usr/bin/eubind + rm -v /usr/bin/eub + rm -v /usr/bin/echoversion + rm -v /usr/bin/creole + rm -v /usr/bin/eucoverage + + if [ ! -d ${target_dir}/${name}-${version}-Linux-${arch} ];then + echo + printf "${name}-${version} is uninstalled\n" + else + printf "${name}-${version} still exists on the system\n" + printf "Location: ${target_dir}/${name}-${version}-Linux-${arch}\n" + fi + fi +} + +remove_tmp(){ + echo + printf "Do you want to remove ${tmpdir}/${name}-${version}-Linux-${arch} and ${tmpdir}/${name}-${version}.${fext}" + printf "[y/n]: " + read choice + + if [ "${choice}" = "y" ];then + rm -v -r ${tmpdir}/${name}-${version}-Linux-${arch} + rm -v -r ${tmpdir}/${name}-${version}.${fext} + if [ ! -d ${tmpdir}/${name}-${version}-Linux-${arch} ] && [ ! -f ${tmpdir}/${name}-${version}.${fext} ];then + printf "${tmpdir} cleared\n" + else + printf "Failed to remove files\n" + fi + elif [ "${choice}" = "n" ];then + printf "Exiting...\n" + exit 0; + else + printf "Skipping and exiting...\n" + exit 0; + fi +} + + +case $1 in + install | i) + check_root + check_deps + check_install + download_pkgs + extract_files + install_build + post_install + ;; + + remove | r) + check_root + uninstall_pkg + ;; + + clean | c) + remove_tmp + ;; + + *) + printf """ + [SYNOPSIS] + ${0}