Hug Imager
May 3, 2023 9:19:29 GMT 1
Post by alexfish on May 3, 2023 9:19:29 GMT 1
Hi All
GTK FLOW BOX
GtkFlowBox was added in GTK+ 3.12.
Looks like the gtk update I mentioned earlier
+ got something near logically correct SIMPLE
play with flowbox size x1 and y-1 for vertical and horizontal + play with widget sizes + flowbox sizes
each child widget can have a callback so can identify none windowed widget likes label & image
Later:: will post more details
Need to buy a new mouse:: & keyboard : I think they are designed to Break one day after guarantee is up
LOOKING at the options :: for flowbox
BR
Alex
GTK FLOW BOX
GtkFlowBox was added in GTK+ 3.12.
Description
[src]
class Gtk.FlowBox : Gtk.Container
implements Atk.ImplementorIface, Gtk.Buildable, Gtk.Orientable {
/* No available fields */
}
A GtkFlowBox positions child widgets in sequence according to its orientation.
For instance, with the horizontal orientation, the widgets will be arranged from left to right,
starting a new row under the previous row when necessary. Reducing the width in this case will require more rows,
so a larger height will be requested.
Likewise, with the vertical orientation, the widgets will be arranged from top to bottom,
starting a new column to the right when necessary. Reducing the height will require more columns,
so a larger width will be requested.
The size request of a GtkFlowBox alone may not be what you expect;
if you need to be able to shrink it along both axes and dynamically reflow its children,
you may have to wrap it in a GtkScrolledWindow to enable that.
The children of a GtkFlowBox can be dynamically sorted and filtered.
Although a GtkFlowBox must have only GtkFlowBoxChild children,
you can add any kind of widget to it via gtk_container_add(),
and a GtkFlowBoxChild widget will automatically be
inserted between the box and the widget.
Also see GtkListBox.
GtkFlowBox was added in GTK+ 3.12.
Looks like the gtk update I mentioned earlier
+ got something near logically correct SIMPLE
play with flowbox size x1 and y-1 for vertical and horizontal + play with widget sizes + flowbox sizes
each child widget can have a callback so can identify none windowed widget likes label & image
Later:: will post more details
Need to buy a new mouse:: & keyboard : I think they are designed to Break one day after guarantee is up
INCLUDE "hug351.bac"
HUGOPTIONS("NOSCALING")
OPTION UTF8 TRUE
'=======================================================
HOME$= GETENVIRON$("HOME")
gtk$ = HUGLIB$("gtk")
IMPORT "gtk_text_view_set_cursor_visible (long,int)" FROM gtk$ TYPE void
IMPORT "gtk_text_buffer_insert_pixbuf (long,long,long)" FROM gtk$ TYPE void
IMPORT "gtk_text_buffer_create_tag(long,char*,char*,...)" FROM gtk$ TYPE long
IMPORT "gtk_text_buffer_insert_with_tags_by_name(long,long,char*,...)" FROM gtk$ TYPE void
IMPORT "gtk_text_buffer_apply_tag(long,long,long,long)" FROM gtk$ TYPE void
IMPORT "gtk_text_buffer_get_iter_at_offset(long,long,int)" FROM gtk$ TYPE void
IMPORT "gtk_flow_box_new(void)" FROM gtk$ TYPE long
IMPORT "gtk_flow_box_insert (long,long,int)" FROM gtk$ TYPE void
IMPORT "gtk_flow_box_set_max_children_per_line(long,int)" FROM gtk$ TYPE void
'IMPORT "gtk_text_view_add_overlay (long,long,int,int)" FROM gtk$ TYPE void
cairo$ = HUGLIB$("cairo")
'Requires
IMPORT cairo_text_extents(long,const char*,void*) FROM cairo$ TYPE void
'=======================================================
PRINT HUG_VERSION$
'=======================================================
'======================================================================
FUNCTION TEXT_WIDTH(long cr, hug_text$) TYPE double
RECORD extent
LOCAL x_bearing TYPE double
LOCAL y_bearing TYPE double
LOCAL width TYPE double
LOCAL height TYPE double
LOCAL x_advance TYPE double
LOCAL y_advance TYPE double
END RECORD
cairo_text_extents (cr,hug_text$,&extent)
RETURN extent.width
END FUNCTION
'======================================================================
FUNCTION TEXT_HEIGHT(long cr,hug_text$) TYPE double
RECORD extent
LOCAL x_bearing TYPE double
LOCAL y_bearing TYPE double
LOCAL width TYPE double
LOCAL height TYPE double
LOCAL x_advance TYPE double
LOCAL y_advance TYPE double
END RECORD
cairo_text_extents (cr,hug_text$,&extent)
RETURN extent.height
END FUNCTION
FUNCTION PARAGRAPH (int hug_xsize, int hug_ysize)
LOCAL buffer, view, here
buffer = gtk_text_buffer_new(0)
view = gtk_text_view_new_with_buffer(buffer)
gtk_text_view_set_editable(view, 0)
gtk_text_view_set_wrap_mode(view, 3)
gtk_text_view_set_cursor_visible(view,FALSE)
IF HUG_WIDGET_SHOW THEN gtk_widget_show_all(view)
SETSIZE(view,hug_xsize,hug_ysize)
hug_widget_xsize(STR$(view)) = hug_xsize
hug_widget_ysize(STR$(view)) = hug_ysize
hug_widget_signal(STR$(view)) = 5
hug_widget_s_widget(STR$(view)) = buffer
hug_widget_type$(STR$(view)) = "edit"
hug_widget_font(STR$(view)) = view
hug_widget_focus(STR$(view)) = view
WIDGET = view
RETURN view
END FUNCTION
'=======================================================
SUB BLUETAG(long hug_widget,int start,int end)
A$ = GRAB$(ed)
LOCAL iters,itere,buf,pixbuf
buf = hug_widget_s_widget(STR$(hug_widget))
iters = MEMORY(HUG_DEFAULT_WIDGET_SIZE)
itere = MEMORY(HUG_DEFAULT_WIDGET_SIZE)
gtk_text_buffer_get_iter_at_offset(buf,iters,LEN(A$)-start)
gtk_text_buffer_get_iter_at_offset(buf,itere,LEN(A$)-end)
'gtk_text_buffer_get_end_iter(hug_widget_s_widget(STR$(hug_widget)), iters)
tag = gtk_text_buffer_create_tag(buf,"blue_foreground", "foreground", "blue", NULL)
'gtk_text_buffer_insert_with_tags_by_name(buf, iters,"This", tag, NULL)
gtk_text_buffer_apply_tag(buf,tag,iters,itere)
FREE iters
FREE itere
END SUB
'=======================================================
SUB INSERTIMAGE(long hug_widget,STRING hug_text$)
LOCAL iter,buf,pixbuf
buf = hug_widget_s_widget(STR$(hug_widget))
pixbuf = gdk_pixbuf_new_from_file(hug_text$, 0)
iter = MEMORY(HUG_DEFAULT_WIDGET_SIZE)
gtk_text_buffer_get_end_iter(hug_widget_s_widget(STR$(hug_widget)), iter)
gtk_text_buffer_insert_pixbuf(buf,iter,pixbuf)
g_object_unref(pixbuf)
FREE iter
END SUB
'=======================================================
LOCAL surf,cr
LOCAL text_width,text_height TYPE double
surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,200,100)
cr = cairo_create (surf)
' default font Mono Space
cairo_select_font_face (cr,CAIROFONT$,0, 0)
' default font_size USES px pixel
cairo_set_font_size(cr,16)
text_width = TEXT_WIDTH(cr,"See you at Basic Converter Forum HERE ")
flowbox = gtk_flow_box_new()
gtk_flow_box_set_max_children_per_line(flowbox,6)
but = BUTTON("TEST",100,25)
SETSIZE(but,-1,-1)
win= WINDOW("para",806,606)
gtk_fixed_put(hug_widget_attach(STR$(win)),flowbox,3,3)
text_heigh=TEXT_HEIGHT(cr,"S")+3
ed= PARAGRAPH(text_width+3,text_height*3)
FONT(ed,"Mono Space 16px")
gtk_flow_box_insert(flowbox,ed,0)
gtk_widget_show_all(flowbox)
SETSIZE(flowbox,800,-1)
TEXT(ed,"HELLO 0 WORLD" & NL$)
TEXT(ed,"Have Fun playing with HUG")
INSERTIMAGE(ed,HOME$ & "/test12.png")
TEXT(ed,NL$)
TEXT(ed,"See you at Basic Converter Forum HERE" & NL$)
BLUETAG(ed ,4,0)
text_width = TEXT_WIDTH(cr,"HELLO WORLD2")
ed= PARAGRAPH(text_width,text_height)
FONT(ed,"Mono Space 16px")
gtk_flow_box_insert(flowbox,ed,1)
TEXT(ed,"HELLO WORLD2" & NL$)
TEXT(ed,"Have Fun\nMore fun playing")
INSERTIMAGE(ed,HOME$ & "/test12.png")
TEXT(ed,NL$)
TEXT(ed," We Are \nWHERE" & NL$)
BLUETAG(ed ,5,0)
gtk_flow_box_insert(flowbox,but,1)
'=======================================================
DISPLAY
LOOKING at the options :: for flowbox
BR
Alex