|
Post by vovchik on Sept 3, 2014 16:25:16 GMT 1
Dear Joe,
And here is a BaConized version of aspect frame:
' *********************** ' COMPILER OPTIONS ' ***********************
PRAGMA OPTIONS `pkg-config --cflags gtk+-3.0` PRAGMA LDFLAGS `pkg-config --libs gtk+-3.0` OPTION PARSE FALSE
' *********************** ' END COMPILER OPTIONS ' ***********************
' *********************** ' INITIALIZATION ' ***********************
DECLARE *window TYPE void DECLARE *aspect_frame TYPE void DECLARE *drawing_area TYPE void CONST MY_VERSION$ = "v.01a"
' *********************** ' END INITIALIZATION ' ***********************
' *********************** ' SUB & FUNCTIONS ' ***********************
' ***********************
' ----------------- SUB DESTROY(NUMBER widget, void* data) ' ----------------- gtk_main_quit() END SUB
' ----------------- SUB MK_GUI() ' ----------------- gtk_init(0, 0) window = gtk_window_new(0) gtk_window_set_title(window, "AFrame - " & MY_VERSION$) g_signal_connect_data(window, "destroy", ADDRESS(DESTROY), 0, 0, 0) gtk_container_set_border_width(window, 10) ' Create an aspect_frame and add it to our toplevel window ' arguments: label, center_x center_y, aspect ratio (e.g. xsize/ysize = 2), ' boolean ignore child's aspect aspect_frame = gtk_aspect_frame_new ("2x1", 0.5, 0.5, 2, FALSE) gtk_container_add(window, aspect_frame) gtk_widget_show(aspect_frame) ' Now add a child widget to the aspect frame drawing_area = gtk_drawing_area_new() ' Ask for a 200x200 window, but the Aspect Frame will give us a 200x100 ' window since we are forcing a 2x1 aspect ratio gtk_widget_set_size_request(drawing_area, 200, 200) gtk_container_add(aspect_frame, drawing_area) gtk_widget_show(drawing_area) gtk_widget_show(window) END SUB
' *********************** ' END SUBS & FUNCTIONS ' ***********************
' *********************** ' MAIN ' ***********************
MK_GUI() gtk_main()
' *********************** ' END MAIN ' ***********************
With kind regards, vovchik
|
|
|
Post by vovchik on Sept 3, 2014 16:44:26 GMT 1
Dear Joe, And now with a gratuitous bit of css... ' *********************** ' COMPILER OPTIONS ' ***********************
PRAGMA OPTIONS `pkg-config --cflags gtk+-3.0` PRAGMA LDFLAGS `pkg-config --libs gtk+-3.0` OPTION PARSE FALSE
' *********************** ' END COMPILER OPTIONS ' ***********************
' *********************** ' INITIALIZATION ' ***********************
DECLARE *window TYPE void DECLARE *aspect_frame TYPE void DECLARE *drawing_area TYPE void CONST MY_VERSION$ = "v.01a"
' *********************** ' END INITIALIZATION ' ***********************
' *********************** ' SUB & FUNCTIONS ' ***********************
' ***********************
' ----------------- SUB DESTROY(NUMBER widget, void* data) ' ----------------- gtk_main_quit() END SUB
' ----------------- SUB FIX_FRAME(STRING bg$, STRING border$, int size, int pad, int radius, int style) ' ----------------- ' use #xxxxxx or named color in quotes ' plus thickness, pad, radius and style as int LOCAL provider TYPE void* LOCAL display TYPE void* LOCAL screen TYPE void* LOCAL data$, style$ TYPE STRING ' The border-style property accepts the 'none', 'solid', ' 'inset' and 'outset' keywords. SELECT style CASE 0 style$ = "none" CASE 1 style$ = "solid" CASE 2 style$ = "inset" CASE 3 style$ = "outset" END SELECT data$ = ".frame{" & \ "background-color:" & bg$ & ";" & \ "border-color: shade (mix (rgb (14, 15, 10), " & border$ & ", 0.5), 0.9);" & \ "padding:" & STR$(pad) & "px;" & \ "border-radius:" & STR$(radius) & "px;" \ "border-style:" & style$ & ";" & \ " }" provider = gtk_css_provider_new() display = gdk_display_get_default() screen = gdk_display_get_default_screen(display) gtk_style_context_add_provider_for_screen (screen, provider, 600) gtk_css_provider_load_from_data(provider, data$, -1, NULL) g_object_unref(provider) END SUB
' ----------------- SUB MK_GUI() ' ----------------- gtk_init(0, 0) window = gtk_window_new(0) gtk_window_set_title(window, "AFrame - " & MY_VERSION$) g_signal_connect_data(window, "destroy", ADDRESS(DESTROY), 0, 0, 0) gtk_container_set_border_width(window, 10) ' Create an aspect_frame and add it to our toplevel window ' arguments: label, center_x center_y, aspect ratio (e.g. xsize/ysize = 2), ' boolean ignore child's aspect aspect_frame = gtk_aspect_frame_new ("2x1", 0.5, 0.5, 1, FALSE) gtk_container_add(window, aspect_frame) gtk_widget_show(aspect_frame) ' Now add a child widget to the aspect frame drawing_area = gtk_drawing_area_new() ' Ask for a 200x200 window, but the Aspect Frame will give us a 200x100 ' window since we are forcing a 2x1 aspect ratio gtk_widget_set_size_request(drawing_area, 200, 200) gtk_container_add(aspect_frame, drawing_area) gtk_widget_show(drawing_area) FIX_FRAME("#cacaca", "dimgray", 5, 5, 9, 2) gtk_widget_show(window) END SUB
' *********************** ' END SUBS & FUNCTIONS ' ***********************
' *********************** ' MAIN ' ***********************
MK_GUI() gtk_main()
' *********************** ' END MAIN ' ***********************
With kind regards, vovchik
|
|
|
Post by bigbass on Sept 3, 2014 17:03:09 GMT 1
Hey Vovchik Thanks for those great demos will add them to the docs! When we finally write our own gtk3 docs along the way Here is the simple version for the getting started with gtk3 and aspect frames BTW I haven't seen an example in gtk3 so it's good we have an optional way who needs all that gtk header casting anyway developer.gnome.org/gtk3/3.7/GtkAspectFrame.html
PRAGMA OPTIONS `pkg-config --cflags gtk+-3.0` PRAGMA LDFLAGS `pkg-config --libs gtk+-3.0` OPTION PARSE FALSE
'--- Port of a gtk2 demo to gtk3 then BaConized by bigbass
DECLARE *window TYPE void DECLARE *aspect_frame TYPE void DECLARE *drawing_area TYPE void GTK_WINDOW_TOPLEVEL = 0
'========================================== SUB close_window (void) '==========================================
gtk_main_quit ()
END SUB
gtk_init (0,0) window = gtk_window_new (GTK_WINDOW_TOPLEVEL) gtk_window_set_title (window, "Aspect Frame") g_signal_connect_data(window, "delete-event", close_window, 0, 0, 0) gtk_container_set_border_width (window, 10) '--- Create an aspect_frame and add it to our toplevel window aspect_frame = gtk_aspect_frame_new ("2x1", 0.5, 0.5, 2, FALSE ) gtk_container_add (window, aspect_frame) gtk_widget_show (aspect_frame) '--- Now add a child widget to the aspect frame drawing_area = gtk_drawing_area_new () '--- Ask for a 200x200 window, but the AspectFrame will give us a 200x100 '--- window since we are forcing a 2x1 aspect ratio gtk_widget_set_size_request (drawing_area, 200, 200) gtk_container_add (aspect_frame, drawing_area) gtk_widget_show (drawing_area) gtk_widget_show (window) gtk_main ()
|
|
|
Post by vovchik on Sept 4, 2014 15:38:19 GMT 1
Dear Joe, Here is a parametrized version of a sub that sets per-frame css styles (i.e. a per widget basis). I think we are slowly getting somewhere with some of this new css stuff. With kind regards, vovchik PS. I also included a plain style in the archive that looks very similar to the old gtk2 styles. Attachments:
frames.tar.gz (17.55 KB)
|
|
|
Post by bigbass on Sept 4, 2014 17:29:56 GMT 1
Hey vovchik
Excellent demos! They show all the possibles that we could need
Too bad there aren't good examples of gtk3/C code going over all of the widgets and explaining the process with working snippets like you posted
Since we had some good results compiling with HUG3 we can slowly start adding these discoveries
and try to keep some things basic as default built in to keep the syntax hug style
The most important part is get stuff working the we can go back and and plug it into HUG3
Joe
|
|
|
Post by vovchik on Sept 4, 2014 17:37:05 GMT 1
Dear Joe, We can also use this technique with other widgets. This is a somewhat crazy demo of css styled buttons. Click and hover to see how they change. We are learning. I am certain that some people has access to useful gtk/css documentation - but not us - so it is really trial and error stuff. With kind regards, vovchik
|
|
|
Post by jcfuller on Sept 4, 2014 18:45:29 GMT 1
Hey guys, It's been awhile since I did any BaCon coding so be nice On the examples I am getting warnings that I would like to eliminate. I'm running Linux Mint 17 64 cinnamon. These are from Joe's example: James
|
|
|
Post by vovchik on Sept 4, 2014 22:03:55 GMT 1
Dear James (and Joe),
Can you try replacing the DECLAREs at the top with the following:
DECLARE window TYPE intptr_t DECLARE aspect_frame TYPE intptr_t DECLARE drawing_area TYPE intptr_t
I would be interested to see whether that mod gets rid of the error on 64-bit linux setups. My Mint is 32-bit, so I have not experienced the problem you describe, but the above also works for me.
With kind regards, vovchik
|
|
|
Post by jcfuller on Sept 4, 2014 23:18:21 GMT 1
vovchik, Thank you, that did the trick. No more warnings.
James
|
|
|
Post by bigbass on Sept 5, 2014 5:18:40 GMT 1
Thanks vovchik You get a box of the Fine chocolates for that Sorry James I am on 32 bit and didn't think that would cause problems on 64 bit I will use the way vovchik did it to be portable I looked up the why and what for to prevent this mishap again www.ibm.com/developerworks/linux/library/l-port64/Joe
|
|
|
Post by vovchik on Sept 5, 2014 9:50:11 GMT 1
Dear Joe, Thanks, but we really have to thank James for pointing out the weirdness of frames in gtk3 and the void* problem in 64-bit setups. I think we may have to update a lot of our things to use intptr_t. And we are learning about CSS. With kind regards, vovchik
|
|
|
Post by jcfuller on Sept 5, 2014 13:13:29 GMT 1
vovchik, I had only tested set_frame_css.bac with intptr_t before my affirmative post but all the others fail to run with: ./set_frame_css-trans: error while loading shared libraries: libgtk-3.so.0: cannot open shared object file: No such file or directory
They all compile without warnings or errors. Maybe I got carried away with the void* -> intptr_t changes??
James
|
|
|
Post by vovchik on Sept 5, 2014 13:24:14 GMT 1
Dear James, It works for me - but I had to make a few more of those changes - not just at the top but in the SUBs, too. Can you try out the attached version? Many thanks. With kind regards, vovchik PS. I use the following compile line, in a script: bacon -o -Os -o -fdata-sections -o -ffunction-sections -o -Wl,--gc-sections xxx.bac
and do not know whether that is at all relevant to your problem - but it does produce much smaller binaries.
|
|
|
Post by jcfuller on Sept 5, 2014 14:25:48 GMT 1
Seems ok. I think it's my BaCon setup
James
|
|
|
Post by Pjot on Sept 25, 2014 18:39:38 GMT 1
Folks, just to mention that GTK3 frames seem to be visible in the default GTK theme if they do not have a caption...
BR Peter
|
|